Mercurial > pidgin
comparison src/protocols/yahoo/yahoo.c @ 7651:580bd39219a2
[gaim-migrate @ 8295]
Tim Ringenbach (marv_sf) " Because Sean asked nicely." implemented yahoo
file transfer for the masses. of this second version of the patch, he adds:
"Here's a new diff, that adds a right click send file menu
like oscar, and should still compile without those new
callbacks that got reverted."
i'm using (and perhaps abusing) the permission to commit yahoo patches from
him that i obtained in previous releases :-)
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 29 Nov 2003 03:30:01 +0000 |
parents | ea2d07ad05a9 |
children | e4264f71fac7 |
comparison
equal
deleted
inserted
replaced
7650:6db061321ec4 | 7651:580bd39219a2 |
---|---|
35 #include "util.h" | 35 #include "util.h" |
36 | 36 |
37 #include "sha.h" | 37 #include "sha.h" |
38 #include "yahoo.h" | 38 #include "yahoo.h" |
39 #include "yahoochat.h" | 39 #include "yahoochat.h" |
40 #include "yahoo_filexfer.h" | |
40 #include "md5.h" | 41 #include "md5.h" |
41 | 42 |
42 extern char *yahoo_crypt(const char *, const char *); | 43 extern char *yahoo_crypt(const char *, const char *); |
43 | 44 |
44 typedef struct | 45 typedef struct |
54 | 55 |
55 #define YAHOO_PAGER_HOST "scs.yahoo.com" | 56 #define YAHOO_PAGER_HOST "scs.yahoo.com" |
56 #define YAHOO_PAGER_PORT 5050 | 57 #define YAHOO_PAGER_PORT 5050 |
57 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/" | 58 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/" |
58 | 59 |
59 #ifdef YAHOO_WEBMESSENGER | |
60 #define YAHOO_PROTO_VER 0x0065 | |
61 #else | |
62 #define YAHOO_PROTO_VER 0x000b | |
63 #endif | |
64 | |
65 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) | |
66 | 60 |
67 static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *); | 61 static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *); |
68 | 62 |
69 static struct yahoo_friend *yahoo_friend_new() | 63 static struct yahoo_friend *yahoo_friend_new() |
70 { | 64 { |
103 pair->key = key; | 97 pair->key = key; |
104 pair->value = g_strdup(value); | 98 pair->value = g_strdup(value); |
105 pkt->hash = g_slist_append(pkt->hash, pair); | 99 pkt->hash = g_slist_append(pkt->hash, pair); |
106 } | 100 } |
107 | 101 |
108 static int yahoo_packet_length(struct yahoo_packet *pkt) | 102 int yahoo_packet_length(struct yahoo_packet *pkt) |
109 { | 103 { |
110 GSList *l; | 104 GSList *l; |
111 | 105 |
112 int len = 0; | 106 int len = 0; |
113 | 107 |
125 l = l->next; | 119 l = l->next; |
126 } | 120 } |
127 | 121 |
128 return len; | 122 return len; |
129 } | 123 } |
130 | |
131 /* sometimes i wish prpls could #include things from other prpls. then i could just | |
132 * use the routines from libfaim and not have to admit to knowing how they work. */ | |
133 #define yahoo_put16(buf, data) ( \ | |
134 (*(buf) = (unsigned char)((data)>>8)&0xff), \ | |
135 (*((buf)+1) = (unsigned char)(data)&0xff), \ | |
136 2) | |
137 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
138 #define yahoo_put32(buf, data) ( \ | |
139 (*((buf)) = (unsigned char)((data)>>24)&0xff), \ | |
140 (*((buf)+1) = (unsigned char)((data)>>16)&0xff), \ | |
141 (*((buf)+2) = (unsigned char)((data)>>8)&0xff), \ | |
142 (*((buf)+3) = (unsigned char)(data)&0xff), \ | |
143 4) | |
144 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
145 (((*((buf)+1))<<16)&0x00ff0000) + \ | |
146 (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
147 (((*((buf)+3) )&0x000000ff))) | |
148 | 124 |
149 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) | 125 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) |
150 { | 126 { |
151 int pos = 0; | 127 int pos = 0; |
152 | 128 |
198 if (data[0] == '9' && data[pos] == 0x01) | 174 if (data[0] == '9' && data[pos] == 0x01) |
199 pos++; | 175 pos++; |
200 } | 176 } |
201 } | 177 } |
202 | 178 |
203 static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) | 179 void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) |
204 { | 180 { |
205 GSList *l = pkt->hash; | 181 GSList *l = pkt->hash; |
206 int pos = 0; | 182 int pos = 0; |
207 | 183 |
208 while (l) { | 184 while (l) { |
505 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, g->name); | 481 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, g->name); |
506 gaim_blist_remove_buddy(b); | 482 gaim_blist_remove_buddy(b); |
507 } | 483 } |
508 } | 484 } |
509 | 485 |
486 static char *_getcookie(char *rawcookie) | |
487 { | |
488 char *cookie = NULL; | |
489 char *tmpcookie; | |
490 char *cookieend; | |
491 | |
492 if (strlen(rawcookie) < 2) | |
493 return NULL; | |
494 tmpcookie = g_strdup(rawcookie+2); | |
495 cookieend = strchr(tmpcookie, ';'); | |
496 | |
497 if (cookieend) | |
498 *cookieend = '\0'; | |
499 | |
500 cookie = g_strdup(tmpcookie); | |
501 g_free(tmpcookie); | |
502 | |
503 return cookie; | |
504 } | |
505 | |
506 static void yahoo_process_cookie(struct yahoo_data *yd, char *c) | |
507 { | |
508 if (c[0] == 'Y') { | |
509 if (yd->cookie_y) | |
510 g_free(yd->cookie_y); | |
511 yd->cookie_y = _getcookie(c); | |
512 } else if (c[0] == 'T') { | |
513 if (yd->cookie_t) | |
514 g_free(yd->cookie_t); | |
515 yd->cookie_t = _getcookie(c); | |
516 } | |
517 } | |
518 | |
510 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) | 519 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) |
511 { | 520 { |
512 GSList *l = pkt->hash; | 521 GSList *l = pkt->hash; |
513 gboolean export = FALSE; | 522 gboolean export = FALSE; |
514 gboolean got_serv_list = FALSE; | 523 gboolean got_serv_list = FALSE; |
522 char **lines; | 531 char **lines; |
523 char **split; | 532 char **split; |
524 char **buddies; | 533 char **buddies; |
525 char **tmp, **bud; | 534 char **tmp, **bud; |
526 | 535 |
536 if (pkt->id) | |
537 yd->session_id = pkt->id; | |
538 | |
527 while (l) { | 539 while (l) { |
528 struct yahoo_pair *pair = l->data; | 540 struct yahoo_pair *pair = l->data; |
529 l = l->next; | 541 l = l->next; |
530 | 542 |
531 switch (pair->key) { | 543 switch (pair->key) { |
538 case 88: | 550 case 88: |
539 if (!yd->tmp_serv_ilist) | 551 if (!yd->tmp_serv_ilist) |
540 yd->tmp_serv_ilist = g_string_new(pair->value); | 552 yd->tmp_serv_ilist = g_string_new(pair->value); |
541 else | 553 else |
542 g_string_append(yd->tmp_serv_ilist, pair->value); | 554 g_string_append(yd->tmp_serv_ilist, pair->value); |
555 break; | |
556 case 59: /* cookies, yum */ | |
557 yahoo_process_cookie(yd, pair->value); | |
543 break; | 558 break; |
544 } | 559 } |
545 } | 560 } |
546 | 561 |
547 if (pkt->status != 0) | 562 if (pkt->status != 0) |
1624 yahoo_process_chat_addinvite(gc, pkt); | 1639 yahoo_process_chat_addinvite(gc, pkt); |
1625 break; | 1640 break; |
1626 case YAHOO_SERVICE_COMMENT: | 1641 case YAHOO_SERVICE_COMMENT: |
1627 yahoo_process_chat_message(gc, pkt); | 1642 yahoo_process_chat_message(gc, pkt); |
1628 break; | 1643 break; |
1644 case YAHOO_SERVICE_P2PFILEXFER: | |
1645 case YAHOO_SERVICE_FILETRANSFER: | |
1646 yahoo_process_filetransfer(gc, pkt); | |
1647 break; | |
1629 default: | 1648 default: |
1630 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", | 1649 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
1631 "Unhandled service 0x%02x\n", pkt->service); | 1650 "Unhandled service 0x%02x\n", pkt->service); |
1632 break; | 1651 break; |
1633 } | 1652 } |
1946 | 1965 |
1947 g_hash_table_destroy(yd->friends); | 1966 g_hash_table_destroy(yd->friends); |
1948 g_slist_free(yd->confs); | 1967 g_slist_free(yd->confs); |
1949 if (yd->chat_name) | 1968 if (yd->chat_name) |
1950 g_free(yd->chat_name); | 1969 g_free(yd->chat_name); |
1970 | |
1971 if (yd->cookie_y) | |
1972 g_free(yd->cookie_y); | |
1973 if (yd->cookie_t) | |
1974 g_free(yd->cookie_t); | |
1951 | 1975 |
1952 if (yd->fd >= 0) | 1976 if (yd->fd >= 0) |
1953 close(yd->fd); | 1977 close(yd->fd); |
1954 | 1978 |
1955 if (yd->rxqueue) | 1979 if (yd->rxqueue) |
2179 m = g_list_append(m, pbm); | 2203 m = g_list_append(m, pbm); |
2180 | 2204 |
2181 pbm = g_new0(struct proto_buddy_menu, 1); | 2205 pbm = g_new0(struct proto_buddy_menu, 1); |
2182 pbm->label = _("Initiate Conference"); | 2206 pbm->label = _("Initiate Conference"); |
2183 pbm->callback = yahoo_initiate_conference; | 2207 pbm->callback = yahoo_initiate_conference; |
2208 pbm->gc = gc; | |
2209 m = g_list_append(m, pbm); | |
2210 | |
2211 /* FIXME: remove this when the ui does it for us. */ | |
2212 pbm = g_new0(struct proto_buddy_menu, 1); | |
2213 pbm->label = _("Send File"); | |
2214 pbm->callback = yahoo_ask_send_file; | |
2184 pbm->gc = gc; | 2215 pbm->gc = gc; |
2185 m = g_list_append(m, pbm); | 2216 m = g_list_append(m, pbm); |
2186 | 2217 |
2187 if (f->game) { | 2218 if (f->game) { |
2188 char *game = f->game; | 2219 char *game = f->game; |
2883 yahoo_packet_hash(pkt, 65, old_group); | 2914 yahoo_packet_hash(pkt, 65, old_group); |
2884 yahoo_packet_hash(pkt, 67, new_group); | 2915 yahoo_packet_hash(pkt, 67, new_group); |
2885 yahoo_send_packet(yd, pkt); | 2916 yahoo_send_packet(yd, pkt); |
2886 yahoo_packet_free(pkt); | 2917 yahoo_packet_free(pkt); |
2887 } | 2918 } |
2919 | |
2920 static gboolean yahoo_has_send_file(GaimConnection *gc, const char *who) | |
2921 { | |
2922 return TRUE; | |
2923 } | |
2924 | |
2888 | 2925 |
2889 static GaimPlugin *my_protocol = NULL; | 2926 static GaimPlugin *my_protocol = NULL; |
2890 | 2927 |
2891 static GaimPluginProtocolInfo prpl_info = | 2928 static GaimPluginProtocolInfo prpl_info = |
2892 { | 2929 { |
2938 yahoo_change_buddys_group, | 2975 yahoo_change_buddys_group, |
2939 yahoo_rename_group, | 2976 yahoo_rename_group, |
2940 NULL, /* buddy_free */ | 2977 NULL, /* buddy_free */ |
2941 NULL, /* convo_closed */ | 2978 NULL, /* convo_closed */ |
2942 NULL, /* normalize */ | 2979 NULL, /* normalize */ |
2943 NULL /* set_buddy_icon */ | 2980 NULL, /* set_buddy_icon */ |
2981 NULL, /* void (*remove_group)(GaimConnection *gc, const char *group);*/ | |
2982 NULL, /* char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); */ | |
2983 #if 0 | |
2984 yahoo_ask_send_file, | |
2985 yahoo_send_file, | |
2986 yahoo_has_send_file | |
2987 #endif | |
2944 }; | 2988 }; |
2945 | 2989 |
2946 static GaimPluginInfo info = | 2990 static GaimPluginInfo info = |
2947 { | 2991 { |
2948 2, /**< api_version */ | 2992 2, /**< api_version */ |
2982 | 3026 |
2983 option = gaim_account_option_int_new(_("Pager port"), "port", | 3027 option = gaim_account_option_int_new(_("Pager port"), "port", |
2984 YAHOO_PAGER_PORT); | 3028 YAHOO_PAGER_PORT); |
2985 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 3029 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2986 option); | 3030 option); |
3031 | |
3032 option = gaim_account_option_string_new(_("File transfer host"), "xfer_host", YAHOO_XFER_HOST); | |
3033 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3034 | |
3035 option = gaim_account_option_int_new(_("File transfer port"), "xfer_port", YAHOO_XFER_PORT); | |
3036 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
3037 | |
2987 my_protocol = plugin; | 3038 my_protocol = plugin; |
2988 | 3039 |
2989 yahoo_init_colorht(); | 3040 yahoo_init_colorht(); |
2990 } | 3041 } |
2991 | 3042 |