Sun, 22 Jul 2012 19:57:09 -0400
Merge with release-2.x.y.
| 9306 | 1 | /* |
| 15884 | 2 | * purple |
| 9306 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 9306 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 9306 | 21 | * |
| 22 | */ | |
| 23 | ||
| 24 | #include "internal.h" | |
| 25 | ||
| 26 | #include "account.h" | |
| 27 | #include "accountopt.h" | |
| 28 | #include "blist.h" | |
| 29 | #include "debug.h" | |
|
23960
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
30 | #include "privacy.h" |
| 9306 | 31 | #include "prpl.h" |
| 32 | #include "proxy.h" | |
| 33 | #include "util.h" | |
| 34 | ||
|
27555
afb7cb5c350c
Update for file renames.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27467
diff
changeset
|
35 | #include "libymsg.h" |
| 10392 | 36 | #include "yahoo_packet.h" |
| 9306 | 37 | #include "yahoo_friend.h" |
| 38 | #include "yahoo_picture.h" | |
| 39 | ||
| 40 | ||
| 41 | struct yahoo_fetch_picture_data { | |
| 15884 | 42 | PurpleConnection *gc; |
| 9306 | 43 | char *who; |
| 44 | int checksum; | |
| 45 | }; | |
| 46 | ||
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
47 | static void |
| 15884 | 48 | yahoo_fetch_picture_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
49 | const gchar *pic_data, size_t len, const gchar *error_message) |
| 9306 | 50 | { |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
51 | struct yahoo_fetch_picture_data *d; |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27958
diff
changeset
|
52 | YahooData *yd; |
| 9306 | 53 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
54 | d = user_data; |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
55 | yd = purple_connection_get_protocol_data(d->gc); |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
56 | yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
57 | |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
58 | if (error_message != NULL) { |
| 15884 | 59 | purple_debug_error("yahoo", "Fetching buddy icon failed: %s\n", error_message); |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
60 | } else if (len == 0) { |
| 15884 | 61 | purple_debug_error("yahoo", "Fetched an icon with length 0. Strange.\n"); |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
62 | } else { |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
63 | char *checksum = g_strdup_printf("%i", d->checksum); |
|
16539
75a20ae3a527
Change the imgstore and by extension, then the buddy icon code to take over
Richard Laager <rlaager@pidgin.im>
parents:
16538
diff
changeset
|
64 | purple_buddy_icons_set_for_user(purple_connection_get_account(d->gc), d->who, g_memdup(pic_data, len), len, checksum); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
65 | g_free(checksum); |
| 9306 | 66 | } |
| 67 | ||
| 68 | g_free(d->who); | |
| 69 | g_free(d); | |
| 70 | } | |
| 71 | ||
| 15884 | 72 | void yahoo_process_picture(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 73 | { |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27958
diff
changeset
|
74 | YahooData *yd; |
| 9306 | 75 | GSList *l = pkt->hash; |
| 76 | char *who = NULL, *us = NULL; | |
| 77 | gboolean got_icon_info = FALSE, send_icon_info = FALSE; | |
| 78 | char *url = NULL; | |
| 79 | int checksum = 0; | |
| 80 | ||
| 81 | while (l) { | |
| 82 | struct yahoo_pair *pair = l->data; | |
| 83 | ||
| 84 | switch (pair->key) { | |
| 85 | case 1: | |
| 86 | case 4: | |
| 87 | who = pair->value; | |
| 88 | break; | |
| 89 | case 5: | |
| 90 | us = pair->value; | |
| 91 | break; | |
| 92 | case 13: { | |
| 93 | int tmp; | |
| 94 | tmp = strtol(pair->value, NULL, 10); | |
| 95 | if (tmp == 1) { | |
| 96 | send_icon_info = TRUE; | |
| 97 | } else if (tmp == 2) { | |
| 98 | got_icon_info = TRUE; | |
| 99 | } | |
| 100 | break; | |
| 101 | } | |
| 102 | case 20: | |
| 103 | url = pair->value; | |
| 104 | break; | |
| 105 | case 192: | |
| 106 | checksum = strtol(pair->value, NULL, 10); | |
| 107 | break; | |
| 108 | } | |
| 109 | ||
| 110 | l = l->next; | |
| 111 | } | |
| 112 | ||
|
27400
d8c31c7e084d
This should prevent pidgin from crashing, as reported by the ticket #9426.
Sulabh Mahajan <sulabh@pidgin.im>
parents:
27361
diff
changeset
|
113 | if (!who) |
|
d8c31c7e084d
This should prevent pidgin from crashing, as reported by the ticket #9426.
Sulabh Mahajan <sulabh@pidgin.im>
parents:
27361
diff
changeset
|
114 | return; |
|
d8c31c7e084d
This should prevent pidgin from crashing, as reported by the ticket #9426.
Sulabh Mahajan <sulabh@pidgin.im>
parents:
27361
diff
changeset
|
115 | |
|
23960
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
116 | if (!purple_privacy_check(purple_connection_get_account(gc), who)) { |
|
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
117 | purple_debug_info("yahoo", "Picture packet from %s dropped.\n", who); |
|
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
118 | return; |
|
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
119 | } |
|
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
120 | |
|
9675
127db3bbb4f2
[gaim-migrate @ 10527]
Peter Lawler <pidgin@bleeter.id.au>
parents:
9329
diff
changeset
|
121 | /* Yahoo IM 6 spits out 0.png as the URL if the buddy icon is not set */ |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
17151
diff
changeset
|
122 | if (who && got_icon_info && url && !g_ascii_strncasecmp(url, "http://", 7)) { |
| 9306 | 123 | /* TODO: make this work p2p, try p2p before the url */ |
| 15884 | 124 | PurpleUtilFetchUrlData *url_data; |
| 9306 | 125 | struct yahoo_fetch_picture_data *data; |
|
22145
458640401515
A patch from Gideon N. Guillen, with some minor modifications from me. This
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
126 | /* use whole URL if using HTTP Proxy */ |
|
24181
e028e31dcc67
Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <datallah@pidgin.im>
parents:
23960
diff
changeset
|
127 | gboolean use_whole_url = yahoo_account_use_http_proxy(gc); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
128 | |
| 9306 | 129 | data = g_new0(struct yahoo_fetch_picture_data, 1); |
| 130 | data->gc = gc; | |
| 131 | data->who = g_strdup(who); | |
| 132 | data->checksum = checksum; | |
|
25762
0c1a4287c70c
Backport the parts of b859960a4a19f57f20db0536c1815a6d79e08e36 that apply to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25152
diff
changeset
|
133 | /* TODO: Does this need to be MSIE 5.0? */ |
|
22145
458640401515
A patch from Gideon N. Guillen, with some minor modifications from me. This
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
134 | url_data = purple_util_fetch_url(url, use_whole_url, |
|
32596
927575c2af4e
* purple_util_fetch_url_request_len() renamed to purple_util_fetch_url_request().
Andrew Victor <andrew.victor@mxit.com>
parents:
32332
diff
changeset
|
135 | "Mozilla/4.0 (compatible; MSIE 5.5)", FALSE, -1, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
136 | yahoo_fetch_picture_cb, data); |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
137 | if (url_data != NULL) { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
138 | yd = purple_connection_get_protocol_data(gc); |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
139 | yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
140 | } |
| 9306 | 141 | } else if (who && send_icon_info) { |
| 142 | yahoo_send_picture_info(gc, who); | |
| 143 | } | |
| 144 | } | |
| 145 | ||
| 15884 | 146 | void yahoo_process_picture_checksum(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 147 | { |
| 148 | GSList *l = pkt->hash; | |
| 149 | char *who = NULL; | |
| 150 | int checksum = 0; | |
| 151 | ||
| 152 | while (l) { | |
| 153 | struct yahoo_pair *pair = l->data; | |
| 154 | ||
| 155 | switch (pair->key) { | |
| 156 | case 4: | |
| 157 | who = pair->value; | |
| 158 | break; | |
| 159 | case 5: | |
| 160 | /* us */ | |
| 161 | break; | |
| 162 | case 192: | |
| 163 | checksum = strtol(pair->value, NULL, 10); | |
| 164 | break; | |
| 165 | } | |
| 166 | l = l->next; | |
| 167 | } | |
| 168 | ||
| 169 | if (who) { | |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32596
diff
changeset
|
170 | PurpleBuddy *b = purple_find_buddy(purple_connection_get_account(gc), who); |
|
16606
b31fca4f6f60
Thanks to Bleeter, yahoo will not crash for non-existent buddyicons anymore.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16539
diff
changeset
|
171 | const char *locksum = NULL; |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
172 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
173 | /* FIXME: Cleanup this strtol() stuff if possible. */ |
|
17151
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
174 | if (b) { |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
175 | locksum = purple_buddy_icons_get_checksum_for_user(b); |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
176 | if (!locksum || (checksum != strtol(locksum, NULL, 10))) |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
177 | yahoo_send_picture_request(gc, who); |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
178 | } |
| 9306 | 179 | } |
| 180 | } | |
| 181 | ||
| 15884 | 182 | void yahoo_process_picture_upload(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 183 | { |
| 15884 | 184 | PurpleAccount *account = purple_connection_get_account(gc); |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
185 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9306 | 186 | GSList *l = pkt->hash; |
| 187 | char *url = NULL; | |
| 188 | ||
| 189 | while (l) { | |
| 190 | struct yahoo_pair *pair = l->data; | |
| 191 | ||
| 192 | switch (pair->key) { | |
| 193 | case 5: | |
| 194 | /* us */ | |
| 195 | break; | |
| 196 | case 27: | |
| 197 | /* filename on our computer. */ | |
| 198 | break; | |
| 199 | case 20: /* url at yahoo */ | |
| 200 | url = pair->value; | |
| 201 | case 38: /* timestamp */ | |
| 202 | break; | |
| 203 | } | |
| 204 | l = l->next; | |
| 205 | } | |
| 206 | ||
| 207 | if (url) { | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
208 | g_free(yd->picture_url); |
| 9306 | 209 | yd->picture_url = g_strdup(url); |
| 15884 | 210 | purple_account_set_string(account, YAHOO_PICURL_SETTING, url); |
| 211 | purple_account_set_int(account, YAHOO_PICCKSUM_SETTING, yd->picture_checksum); | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
212 | yahoo_send_picture_checksum(gc); |
| 9310 | 213 | yahoo_send_picture_update(gc, 2); |
| 9306 | 214 | } |
| 215 | } | |
| 216 | ||
| 15884 | 217 | void yahoo_process_avatar_update(PurpleConnection *gc, struct yahoo_packet *pkt) |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
218 | { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
219 | GSList *l = pkt->hash; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
220 | char *who = NULL; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
221 | int avatar = 0; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
222 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
223 | while (l) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
224 | struct yahoo_pair *pair = l->data; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
225 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
226 | switch (pair->key) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
227 | case 4: |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
228 | who = pair->value; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
229 | break; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
230 | case 5: |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
231 | /* us */ |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
232 | break; |
|
27467
5fd6936c4ed7
Some more fixes for when unsetting buddy picture, for both when sending and receiving updates.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27413
diff
changeset
|
233 | case 206: /* Older versions. Still needed? */ |
|
5fd6936c4ed7
Some more fixes for when unsetting buddy picture, for both when sending and receiving updates.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27413
diff
changeset
|
234 | case 213: /* Newer versions */ |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
235 | /* |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
236 | * 0 - No icon or avatar |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
237 | * 1 - Using an avatar |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
238 | * 2 - Using an icon |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
239 | */ |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
240 | avatar = strtol(pair->value, NULL, 10); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
241 | break; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
242 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
243 | l = l->next; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
244 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
245 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
246 | if (who) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
247 | if (avatar == 2) |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
248 | yahoo_send_picture_request(gc, who); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
249 | else if ((avatar == 0) || (avatar == 1)) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
250 | YahooFriend *f; |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32596
diff
changeset
|
251 | purple_buddy_icons_set_for_user(purple_connection_get_account(gc), who, NULL, 0, NULL); |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
252 | if ((f = yahoo_friend_find(gc, who))) |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
253 | yahoo_friend_set_buddy_icon_need_request(f, TRUE); |
| 15884 | 254 | purple_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who); |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
255 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
256 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
257 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
258 | |
| 15884 | 259 | void yahoo_send_picture_info(PurpleConnection *gc, const char *who) |
| 9322 | 260 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
261 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9322 | 262 | struct yahoo_packet *pkt; |
| 263 | ||
| 9329 | 264 | if (!yd->picture_url) { |
| 15884 | 265 | purple_debug_warning("yahoo", "Attempted to send picture info without a picture\n"); |
| 9322 | 266 | return; |
| 9329 | 267 | } |
| 9322 | 268 | |
|
27866
4a8d47263e98
Change a bunch more of our yahoo packets to use the session ID. I believe this
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27555
diff
changeset
|
269 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
|
27413
2c10bbbac69c
This fixes sending updates to buddies when I change my pic.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27412
diff
changeset
|
270 | yahoo_packet_hash(pkt, "ssssi", 1, purple_connection_get_display_name(gc), |
|
2c10bbbac69c
This fixes sending updates to buddies when I change my pic.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27412
diff
changeset
|
271 | 5, who, |
| 10394 | 272 | 13, "2", 20, yd->picture_url, 192, yd->picture_checksum); |
| 10392 | 273 | yahoo_packet_send_and_free(pkt, yd); |
| 9322 | 274 | } |
| 9306 | 275 | |
| 15884 | 276 | void yahoo_send_picture_request(PurpleConnection *gc, const char *who) |
| 9306 | 277 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
278 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9306 | 279 | struct yahoo_packet *pkt; |
| 280 | ||
|
27866
4a8d47263e98
Change a bunch more of our yahoo packets to use the session ID. I believe this
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27555
diff
changeset
|
281 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
|
27412
1db60cfcad9b
This fixes buddyicon fetches for me.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27409
diff
changeset
|
282 | yahoo_packet_hash_str(pkt, 1, purple_connection_get_display_name(gc)); /* me */ |
| 10394 | 283 | yahoo_packet_hash_str(pkt, 5, who); /* the other guy */ |
| 284 | yahoo_packet_hash_str(pkt, 13, "1"); /* 1 = request, 2 = reply */ | |
| 10392 | 285 | yahoo_packet_send_and_free(pkt, yd); |
| 9306 | 286 | } |
| 287 | ||
| 15884 | 288 | void yahoo_send_picture_checksum(PurpleConnection *gc) |
| 9310 | 289 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
290 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9310 | 291 | struct yahoo_packet *pkt; |
| 292 | ||
|
27866
4a8d47263e98
Change a bunch more of our yahoo packets to use the session ID. I believe this
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27555
diff
changeset
|
293 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 15884 | 294 | yahoo_packet_hash(pkt, "ssi", 1, purple_connection_get_display_name(gc), |
| 10394 | 295 | 212, "1", 192, yd->picture_checksum); |
| 10392 | 296 | yahoo_packet_send_and_free(pkt, yd); |
| 9310 | 297 | } |
| 298 | ||
| 15884 | 299 | void yahoo_send_picture_update_to_user(PurpleConnection *gc, const char *who, int type) |
| 9310 | 300 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
301 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9310 | 302 | struct yahoo_packet *pkt; |
| 303 | ||
|
27866
4a8d47263e98
Change a bunch more of our yahoo packets to use the session ID. I believe this
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27555
diff
changeset
|
304 | pkt = yahoo_packet_new(YAHOO_SERVICE_AVATAR_UPDATE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
|
27467
5fd6936c4ed7
Some more fixes for when unsetting buddy picture, for both when sending and receiving updates.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27413
diff
changeset
|
305 | yahoo_packet_hash(pkt, "si", 3, who, 213, type); |
| 10392 | 306 | yahoo_packet_send_and_free(pkt, yd); |
| 9310 | 307 | } |
| 308 | ||
| 309 | struct yspufe { | |
| 15884 | 310 | PurpleConnection *gc; |
| 9310 | 311 | int type; |
| 312 | }; | |
| 313 | ||
| 314 | static void yahoo_send_picture_update_foreach(gpointer key, gpointer value, gpointer data) | |
| 315 | { | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
316 | const char *who = key; |
| 9310 | 317 | YahooFriend *f = value; |
| 318 | struct yspufe *d = data; | |
| 319 | ||
| 320 | if (f->status != YAHOO_STATUS_OFFLINE) | |
| 321 | yahoo_send_picture_update_to_user(d->gc, who, d->type); | |
| 322 | } | |
| 323 | ||
| 15884 | 324 | void yahoo_send_picture_update(PurpleConnection *gc, int type) |
| 9310 | 325 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
326 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9310 | 327 | struct yspufe data; |
| 328 | ||
| 329 | data.gc = gc; | |
| 330 | data.type = type; | |
| 331 | ||
| 332 | g_hash_table_foreach(yd->friends, yahoo_send_picture_update_foreach, &data); | |
| 333 | } | |
| 334 | ||
| 9306 | 335 | void yahoo_buddy_icon_upload_data_free(struct yahoo_buddy_icon_upload_data *d) |
| 336 | { | |
| 15884 | 337 | purple_debug_misc("yahoo", "In yahoo_buddy_icon_upload_data_free()\n"); |
| 9306 | 338 | |
| 339 | if (d->str) | |
| 340 | g_string_free(d->str, TRUE); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
341 | g_free(d->filename); |
| 9306 | 342 | if (d->watcher) |
| 15884 | 343 | purple_input_remove(d->watcher); |
| 9306 | 344 | if (d->fd != -1) |
| 345 | close(d->fd); | |
| 346 | g_free(d); | |
| 347 | } | |
| 348 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
349 | /* we couldn't care less about the server's response, but yahoo gets grumpy if we close before it sends it */ |
| 15884 | 350 | static void yahoo_buddy_icon_upload_reading(gpointer data, gint source, PurpleInputCondition condition) |
| 9306 | 351 | { |
| 352 | struct yahoo_buddy_icon_upload_data *d = data; | |
| 15884 | 353 | PurpleConnection *gc = d->gc; |
| 9306 | 354 | char buf[1024]; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
355 | int ret; |
| 9306 | 356 | |
| 15884 | 357 | if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 9306 | 358 | yahoo_buddy_icon_upload_data_free(d); |
| 359 | return; | |
| 360 | } | |
| 361 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
362 | ret = read(d->fd, buf, sizeof(buf)); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
363 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
364 | if (ret < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
365 | return; |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
366 | else if (ret <= 0) { |
|
25152
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
24181
diff
changeset
|
367 | /* There are other problems if d->str->len overflows, so shut up the |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
24181
diff
changeset
|
368 | * warning on 64-bit. */ |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
24181
diff
changeset
|
369 | purple_debug_info("yahoo", "Buddy icon upload response (%" G_GSIZE_FORMAT ") bytes (> ~400 indicates failure):\n%.*s\n", |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
24181
diff
changeset
|
370 | d->str->len, (guint)d->str->len, d->str->str); |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
371 | |
| 9306 | 372 | yahoo_buddy_icon_upload_data_free(d); |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
373 | return; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
374 | } |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
375 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
376 | g_string_append_len(d->str, buf, ret); |
| 9306 | 377 | } |
| 378 | ||
| 15884 | 379 | static void yahoo_buddy_icon_upload_pending(gpointer data, gint source, PurpleInputCondition condition) |
| 9306 | 380 | { |
| 381 | struct yahoo_buddy_icon_upload_data *d = data; | |
| 15884 | 382 | PurpleConnection *gc = d->gc; |
|
23073
e731fbd84c71
Use gssize instead of ssize_t as the latter isn't available everywhere.
Daniel Atallah <datallah@pidgin.im>
parents:
22145
diff
changeset
|
383 | gssize wrote; |
| 9306 | 384 | |
| 15884 | 385 | if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 9306 | 386 | yahoo_buddy_icon_upload_data_free(d); |
| 387 | return; | |
| 388 | } | |
| 389 | ||
| 390 | wrote = write(d->fd, d->str->str + d->pos, d->str->len - d->pos); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
391 | if (wrote < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
392 | return; |
| 9306 | 393 | if (wrote <= 0) { |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
394 | purple_debug_info("yahoo", "Error uploading buddy icon.\n"); |
| 9306 | 395 | yahoo_buddy_icon_upload_data_free(d); |
| 396 | return; | |
| 397 | } | |
| 398 | d->pos += wrote; | |
| 399 | if (d->pos >= d->str->len) { | |
| 15884 | 400 | purple_debug_misc("yahoo", "Finished uploading buddy icon.\n"); |
| 401 | purple_input_remove(d->watcher); | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
402 | /* Clean out the sent buffer and reuse it to read the result */ |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
403 | g_string_free(d->str, TRUE); |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
404 | d->str = g_string_new(""); |
| 15884 | 405 | d->watcher = purple_input_add(d->fd, PURPLE_INPUT_READ, yahoo_buddy_icon_upload_reading, d); |
| 9306 | 406 | } |
| 407 | } | |
| 408 | ||
|
14182
517f4531b8a0
[gaim-migrate @ 16754]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
409 | static void yahoo_buddy_icon_upload_connected(gpointer data, gint source, const gchar *error_message) |
| 9306 | 410 | { |
| 411 | struct yahoo_buddy_icon_upload_data *d = data; | |
| 412 | struct yahoo_packet *pkt; | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
413 | gchar *tmp, *header; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
414 | guchar *pkt_buf; |
|
10576
ce7a6c585bc6
[gaim-migrate @ 11970]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10394
diff
changeset
|
415 | const char *host; |
|
13272
fd4f3356640f
[gaim-migrate @ 15637]
Daniel Atallah <datallah@pidgin.im>
parents:
13201
diff
changeset
|
416 | int port; |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
417 | gsize pkt_buf_len; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
418 | PurpleConnection *gc = d->gc; |
| 15884 | 419 | PurpleAccount *account; |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27958
diff
changeset
|
420 | YahooData *yd; |
|
24181
e028e31dcc67
Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <datallah@pidgin.im>
parents:
23960
diff
changeset
|
421 | /* use whole URL if using HTTP Proxy */ |
|
e028e31dcc67
Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <datallah@pidgin.im>
parents:
23960
diff
changeset
|
422 | gboolean use_whole_url = yahoo_account_use_http_proxy(gc); |
| 9306 | 423 | |
| 15884 | 424 | account = purple_connection_get_account(gc); |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
425 | yd = purple_connection_get_protocol_data(gc); |
| 9306 | 426 | |
| 15884 | 427 | /* Buddy icon connect is now complete; clear the PurpleProxyConnectData */ |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
428 | yd->buddy_icon_connect_data = NULL; |
|
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
429 | |
| 9306 | 430 | if (source < 0) { |
| 15884 | 431 | purple_debug_error("yahoo", "Buddy icon upload failed: %s\n", error_message); |
| 9306 | 432 | yahoo_buddy_icon_upload_data_free(d); |
| 433 | return; | |
| 434 | } | |
| 435 | ||
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
436 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 9306 | 437 | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
438 | tmp = g_strdup_printf("%" G_GSIZE_FORMAT, d->str->len); |
| 9306 | 439 | /* 1 = me, 38 = expire time(?), 0 = me, 28 = size, 27 = filename, 14 = NULL, 29 = data */ |
| 15884 | 440 | yahoo_packet_hash_str(pkt, 1, purple_connection_get_display_name(gc)); |
| 10394 | 441 | yahoo_packet_hash_str(pkt, 38, "604800"); /* time til expire */ |
| 15884 | 442 | purple_account_set_int(account, YAHOO_PICEXPIRE_SETTING, time(NULL) + 604800); |
| 443 | yahoo_packet_hash_str(pkt, 0, purple_connection_get_display_name(gc)); | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
444 | yahoo_packet_hash_str(pkt, 28, tmp); |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
445 | g_free(tmp); |
| 10394 | 446 | yahoo_packet_hash_str(pkt, 27, d->filename); |
| 447 | yahoo_packet_hash_str(pkt, 14, ""); | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
448 | /* 4 padding for the 29 key name */ |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
449 | pkt_buf_len = yahoo_packet_build(pkt, 4, FALSE, yd->jp, &pkt_buf); |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
450 | yahoo_packet_free(pkt); |
| 9306 | 451 | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
452 | /* header + packet + "29" + 0xc0 + 0x80) + pictureblob */ |
| 9306 | 453 | |
|
27958
761556eeff82
And clean up two instances where Yahoo Japan needs to be correctly detected
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27866
diff
changeset
|
454 | host = purple_account_get_string(account, "xfer_host", yd->jp? YAHOOJP_XFER_HOST : YAHOO_XFER_HOST); |
| 15884 | 455 | port = purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT); |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
456 | tmp = g_strdup_printf("%s:%d", host, port); |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
457 | header = g_strdup_printf("POST %s%s/notifyft HTTP/1.1\r\n" |
|
25762
0c1a4287c70c
Backport the parts of b859960a4a19f57f20db0536c1815a6d79e08e36 that apply to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25152
diff
changeset
|
458 | "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n" |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
459 | "Cookie: T=%s; Y=%s\r\n" |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
460 | "Host: %s\r\n" |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
461 | "Content-Length: %" G_GSIZE_FORMAT "\r\n" |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
462 | "Cache-Control: no-cache\r\n\r\n", |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
463 | use_whole_url ? "http://" : "", use_whole_url ? tmp : "", |
|
27335
06a805d4e690
Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents:
27052
diff
changeset
|
464 | yd->cookie_t, yd->cookie_y, |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
465 | tmp, |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
466 | pkt_buf_len + 4 + d->str->len); |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
467 | g_free(tmp); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
468 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
469 | /* There's no magic here, we just need to prepend in reverse order */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
470 | g_string_prepend(d->str, "29\xc0\x80"); |
| 9306 | 471 | |
| 14321 | 472 | g_string_prepend_len(d->str, (char *)pkt_buf, pkt_buf_len); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
473 | g_free(pkt_buf); |
| 9306 | 474 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
475 | g_string_prepend(d->str, header); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
476 | g_free(header); |
| 9306 | 477 | |
|
25152
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
24181
diff
changeset
|
478 | /* There are other problems if we're uploading over 4GB of data */ |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
24181
diff
changeset
|
479 | purple_debug_info("yahoo", "Buddy icon upload data:\n%.*s\n", (guint)d->str->len, d->str->str); |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
480 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
481 | d->fd = source; |
| 15884 | 482 | d->watcher = purple_input_add(d->fd, PURPLE_INPUT_WRITE, yahoo_buddy_icon_upload_pending, d); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
483 | |
| 15884 | 484 | yahoo_buddy_icon_upload_pending(d, d->fd, PURPLE_INPUT_WRITE); |
| 9306 | 485 | } |
| 486 | ||
| 15884 | 487 | void yahoo_buddy_icon_upload(PurpleConnection *gc, struct yahoo_buddy_icon_upload_data *d) |
| 9306 | 488 | { |
| 15884 | 489 | PurpleAccount *account = purple_connection_get_account(gc); |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
490 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9306 | 491 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
492 | if (yd->buddy_icon_connect_data != NULL) { |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
493 | /* Cancel any in-progress buddy icon upload */ |
| 15884 | 494 | purple_proxy_connect_cancel(yd->buddy_icon_connect_data); |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
495 | yd->buddy_icon_connect_data = NULL; |
|
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
496 | } |
|
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
497 | |
| 15884 | 498 | yd->buddy_icon_connect_data = purple_proxy_connect(NULL, account, |
|
27958
761556eeff82
And clean up two instances where Yahoo Japan needs to be correctly detected
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27866
diff
changeset
|
499 | purple_account_get_string(account, "xfer_host", |
|
761556eeff82
And clean up two instances where Yahoo Japan needs to be correctly detected
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27866
diff
changeset
|
500 | yd->jp? YAHOOJP_XFER_HOST : YAHOO_XFER_HOST), |
| 15884 | 501 | purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
502 | yahoo_buddy_icon_upload_connected, d); |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
503 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
504 | if (yd->buddy_icon_connect_data == NULL) |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
505 | { |
| 15884 | 506 | purple_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n"); |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
507 | yahoo_buddy_icon_upload_data_free(d); |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
508 | } |
| 9306 | 509 | } |
| 510 | ||
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
511 | static int yahoo_buddy_icon_calculate_checksum(const guchar *data, gsize len) |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
512 | { |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
513 | /* This code is borrowed from Kopete, which seems to be managing to calculate |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
514 | checksums in such a manner that Yahoo!'s servers are happy */ |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
515 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
516 | const guchar *p = data; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
517 | int checksum = 0, g, i = len; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
518 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
519 | while(i--) { |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
520 | checksum = (checksum << 4) + *p++; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
521 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
522 | if((g = (checksum & 0xf0000000)) != 0) |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
523 | checksum ^= g >> 23; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
524 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
525 | checksum &= ~g; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
526 | } |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
527 | |
|
25895
ab35a3dda3c5
Add a newline to this log message
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
528 | purple_debug_misc("yahoo", "Calculated buddy icon checksum: %d\n", checksum); |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
529 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
530 | return checksum; |
|
27335
06a805d4e690
Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents:
27052
diff
changeset
|
531 | } |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
532 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
533 | void yahoo_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) |
| 9306 | 534 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
535 | YahooData *yd = purple_connection_get_protocol_data(gc); |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32596
diff
changeset
|
536 | PurpleAccount *account = purple_connection_get_account(gc); |
| 9306 | 537 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
538 | if (img == NULL) { |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
539 | g_free(yd->picture_url); |
| 9306 | 540 | yd->picture_url = NULL; |
| 541 | ||
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
542 | /* TODO: don't we have to clear it on the server too?! */ |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
543 | |
| 15884 | 544 | purple_account_set_string(account, YAHOO_PICURL_SETTING, NULL); |
| 545 | purple_account_set_int(account, YAHOO_PICCKSUM_SETTING, 0); | |
| 546 | purple_account_set_int(account, YAHOO_PICEXPIRE_SETTING, 0); | |
| 9310 | 547 | if (yd->logged_in) |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
548 | /* Tell everyone we ain't got one no more */ |
| 9310 | 549 | yahoo_send_picture_update(gc, 0); |
| 9306 | 550 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
551 | } else { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
552 | gconstpointer data = purple_imgstore_get_data(img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
553 | size_t len = purple_imgstore_get_size(img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
554 | GString *s = g_string_new_len(data, len); |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
555 | struct yahoo_buddy_icon_upload_data *d; |
| 15884 | 556 | int oldcksum = purple_account_get_int(account, YAHOO_PICCKSUM_SETTING, 0); |
| 557 | int expire = purple_account_get_int(account, YAHOO_PICEXPIRE_SETTING, 0); | |
| 558 | const char *oldurl = purple_account_get_string(account, YAHOO_PICURL_SETTING, NULL); | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
559 | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
560 | yd->picture_checksum = yahoo_buddy_icon_calculate_checksum(data, len); |
| 9306 | 561 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
562 | if ((yd->picture_checksum == oldcksum) && |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
563 | (expire > (time(NULL) + 60*60*24)) && oldurl) |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
564 | { |
| 15884 | 565 | purple_debug_misc("yahoo", "buddy icon is up to date. Not reuploading.\n"); |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
566 | g_string_free(s, TRUE); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
567 | g_free(yd->picture_url); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
568 | yd->picture_url = g_strdup(oldurl); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
569 | return; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
570 | } |
| 9306 | 571 | |
|
16757
aae5c0ced2da
Update the comments about yahoo buddy icons. Only send the filename and not the whole path.
Tim Ringenbach <marv@pidgin.im>
parents:
16606
diff
changeset
|
572 | /* We use this solely for sending a filename to the server */ |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
573 | d = g_new0(struct yahoo_buddy_icon_upload_data, 1); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
574 | d->gc = gc; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
575 | d->str = s; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
576 | d->fd = -1; |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
577 | d->filename = g_strdup(purple_imgstore_get_filename(img)); |
| 9306 | 578 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
579 | if (!yd->logged_in) { |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
580 | yd->picture_upload_todo = d; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
581 | return; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
582 | } |
| 9306 | 583 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
584 | yahoo_buddy_icon_upload(gc, d); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
585 | |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
586 | } |
|
15245
3abed8bd82fb
[gaim-migrate @ 17972]
Mark Doliner <markdoliner@pidgin.im>
parents:
15239
diff
changeset
|
587 | } |