Thu, 19 Jun 2008 02:54:25 +0000
applied changes from 980e5e2fedd41d52ed3f1640268e8964d4b02cde
through 7a490c356e10f7fff3432f875897aa0ca0ad1ff0
| 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" | |
| 30 | #include "prpl.h" | |
| 31 | #include "proxy.h" | |
| 32 | #include "util.h" | |
| 33 | ||
| 34 | #include "yahoo.h" | |
| 10392 | 35 | #include "yahoo_packet.h" |
| 9306 | 36 | #include "yahoo_friend.h" |
| 37 | #include "yahoo_picture.h" | |
| 38 | ||
| 39 | ||
| 40 | struct yahoo_fetch_picture_data { | |
| 15884 | 41 | PurpleConnection *gc; |
| 9306 | 42 | char *who; |
| 43 | int checksum; | |
| 44 | }; | |
| 45 | ||
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
46 | static void |
| 15884 | 47 | yahoo_fetch_picture_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
48 | const gchar *pic_data, size_t len, const gchar *error_message) |
| 9306 | 49 | { |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
50 | struct yahoo_fetch_picture_data *d; |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
51 | struct yahoo_data *yd; |
| 9306 | 52 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
53 | d = user_data; |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
54 | yd = d->gc->proto_data; |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
55 | yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
56 | |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
57 | if (error_message != NULL) { |
| 15884 | 58 | 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
|
59 | } else if (len == 0) { |
| 15884 | 60 | 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
|
61 | } 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
|
62 | 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
|
63 | 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
|
64 | g_free(checksum); |
| 9306 | 65 | } |
| 66 | ||
| 67 | g_free(d->who); | |
| 68 | g_free(d); | |
| 69 | } | |
| 70 | ||
| 15884 | 71 | void yahoo_process_picture(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 72 | { |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
73 | struct yahoo_data *yd; |
| 9306 | 74 | GSList *l = pkt->hash; |
| 75 | char *who = NULL, *us = NULL; | |
| 76 | gboolean got_icon_info = FALSE, send_icon_info = FALSE; | |
| 77 | char *url = NULL; | |
| 78 | int checksum = 0; | |
| 79 | ||
| 80 | while (l) { | |
| 81 | struct yahoo_pair *pair = l->data; | |
| 82 | ||
| 83 | switch (pair->key) { | |
| 84 | case 1: | |
| 85 | case 4: | |
| 86 | who = pair->value; | |
| 87 | break; | |
| 88 | case 5: | |
| 89 | us = pair->value; | |
| 90 | break; | |
| 91 | case 13: { | |
| 92 | int tmp; | |
| 93 | tmp = strtol(pair->value, NULL, 10); | |
| 94 | if (tmp == 1) { | |
| 95 | send_icon_info = TRUE; | |
| 96 | } else if (tmp == 2) { | |
| 97 | got_icon_info = TRUE; | |
| 98 | } | |
| 99 | break; | |
| 100 | } | |
| 101 | case 20: | |
| 102 | url = pair->value; | |
| 103 | break; | |
| 104 | case 192: | |
| 105 | checksum = strtol(pair->value, NULL, 10); | |
| 106 | break; | |
| 107 | } | |
| 108 | ||
| 109 | l = l->next; | |
| 110 | } | |
| 111 | ||
|
9675
127db3bbb4f2
[gaim-migrate @ 10527]
Peter Lawler <pidgin@bleeter.id.au>
parents:
9329
diff
changeset
|
112 | /* 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
|
113 | if (who && got_icon_info && url && !g_ascii_strncasecmp(url, "http://", 7)) { |
| 9306 | 114 | /* TODO: make this work p2p, try p2p before the url */ |
| 15884 | 115 | PurpleUtilFetchUrlData *url_data; |
| 9306 | 116 | struct yahoo_fetch_picture_data *data; |
| 15884 | 117 | PurpleBuddy *b = purple_find_buddy(gc->account, 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
|
118 | const char *locksum = NULL; |
|
22145
458640401515
A patch from Gideon N. Guillen, with some minor modifications from me. This
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
119 | gboolean use_whole_url = FALSE; |
|
458640401515
A patch from Gideon N. Guillen, with some minor modifications from me. This
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
120 | |
|
458640401515
A patch from Gideon N. Guillen, with some minor modifications from me. This
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
121 | /* use whole URL if using HTTP Proxy */ |
|
458640401515
A patch from Gideon N. Guillen, with some minor modifications from me. This
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
122 | if ((gc->account->proxy_info) && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP)) |
|
458640401515
A patch from Gideon N. Guillen, with some minor modifications from me. This
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
123 | use_whole_url = TRUE; |
|
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
|
124 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
125 | /* FIXME: Cleanup this strtol() stuff if possible. */ |
|
16606
b31fca4f6f60
Thanks to Bleeter, yahoo will not crash for non-existent buddyicons anymore.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16539
diff
changeset
|
126 | if (b && (locksum = purple_buddy_icons_get_checksum_for_user(b)) != NULL && |
|
b31fca4f6f60
Thanks to Bleeter, yahoo will not crash for non-existent buddyicons anymore.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16539
diff
changeset
|
127 | (checksum == strtol(locksum, NULL, 10))) |
| 9306 | 128 | return; |
| 129 | ||
| 130 | data = g_new0(struct yahoo_fetch_picture_data, 1); | |
| 131 | data->gc = gc; | |
| 132 | data->who = g_strdup(who); | |
| 133 | data->checksum = checksum; | |
|
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, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
135 | "Mozilla/4.0 (compatible; MSIE 5.0)", FALSE, |
|
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) { |
|
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
138 | yd = gc->proto_data; |
|
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_update(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 147 | { |
| 148 | GSList *l = pkt->hash; | |
| 149 | char *who = NULL; | |
| 150 | int icon = 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; | |
|
17151
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
162 | /* NOTE: currently the server seems to only send 213; 206 was used |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
163 | * in older versions. Check whether it's still needed. */ |
| 9306 | 164 | case 206: |
|
17151
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
165 | case 213: |
| 9306 | 166 | icon = strtol(pair->value, NULL, 10); |
| 167 | break; | |
| 168 | } | |
| 169 | l = l->next; | |
| 170 | } | |
| 171 | ||
| 172 | if (who) { | |
| 173 | if (icon == 2) | |
| 9310 | 174 | yahoo_send_picture_request(gc, who); |
| 9322 | 175 | else if ((icon == 0) || (icon == 1)) { |
| 9325 | 176 | YahooFriend *f; |
|
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
|
177 | purple_buddy_icons_set_for_user(gc->account, who, NULL, 0, NULL); |
| 9325 | 178 | if ((f = yahoo_friend_find(gc, who))) |
| 179 | yahoo_friend_set_buddy_icon_need_request(f, TRUE); | |
| 15884 | 180 | purple_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who); |
| 9322 | 181 | } |
| 9306 | 182 | } |
| 183 | } | |
| 184 | ||
| 15884 | 185 | void yahoo_process_picture_checksum(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 186 | { |
| 187 | GSList *l = pkt->hash; | |
| 188 | char *who = NULL; | |
| 189 | int checksum = 0; | |
| 190 | ||
| 191 | while (l) { | |
| 192 | struct yahoo_pair *pair = l->data; | |
| 193 | ||
| 194 | switch (pair->key) { | |
| 195 | case 4: | |
| 196 | who = pair->value; | |
| 197 | break; | |
| 198 | case 5: | |
| 199 | /* us */ | |
| 200 | break; | |
| 201 | case 192: | |
| 202 | checksum = strtol(pair->value, NULL, 10); | |
| 203 | break; | |
| 204 | } | |
| 205 | l = l->next; | |
| 206 | } | |
| 207 | ||
| 208 | if (who) { | |
| 15884 | 209 | PurpleBuddy *b = purple_find_buddy(gc->account, 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
|
210 | 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
|
211 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
212 | /* 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
|
213 | if (b) { |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
214 | 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
|
215 | 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
|
216 | 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
|
217 | } |
| 9306 | 218 | } |
| 219 | } | |
| 220 | ||
| 15884 | 221 | void yahoo_process_picture_upload(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 222 | { |
| 15884 | 223 | PurpleAccount *account = purple_connection_get_account(gc); |
| 9306 | 224 | struct yahoo_data *yd = gc->proto_data; |
| 225 | GSList *l = pkt->hash; | |
| 226 | char *url = NULL; | |
| 227 | ||
| 228 | while (l) { | |
| 229 | struct yahoo_pair *pair = l->data; | |
| 230 | ||
| 231 | switch (pair->key) { | |
| 232 | case 5: | |
| 233 | /* us */ | |
| 234 | break; | |
| 235 | case 27: | |
| 236 | /* filename on our computer. */ | |
| 237 | break; | |
| 238 | case 20: /* url at yahoo */ | |
| 239 | url = pair->value; | |
| 240 | case 38: /* timestamp */ | |
| 241 | break; | |
| 242 | } | |
| 243 | l = l->next; | |
| 244 | } | |
| 245 | ||
| 246 | if (url) { | |
| 247 | if (yd->picture_url) | |
| 248 | g_free(yd->picture_url); | |
| 249 | yd->picture_url = g_strdup(url); | |
| 15884 | 250 | purple_account_set_string(account, YAHOO_PICURL_SETTING, url); |
| 251 | purple_account_set_int(account, YAHOO_PICCKSUM_SETTING, yd->picture_checksum); | |
| 9310 | 252 | yahoo_send_picture_update(gc, 2); |
| 253 | yahoo_send_picture_checksum(gc); | |
| 9306 | 254 | } |
| 255 | } | |
| 256 | ||
| 15884 | 257 | 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
|
258 | { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
259 | GSList *l = pkt->hash; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
260 | char *who = NULL; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
261 | int avatar = 0; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
262 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
263 | while (l) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
264 | struct yahoo_pair *pair = l->data; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
265 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
266 | switch (pair->key) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
267 | case 4: |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
268 | who = pair->value; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
269 | break; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
270 | case 5: |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
271 | /* us */ |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
272 | break; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
273 | case 206: |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
274 | /* |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
275 | * 0 - No icon or avatar |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
276 | * 1 - Using an avatar |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
277 | * 2 - Using an icon |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
278 | */ |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
279 | avatar = strtol(pair->value, NULL, 10); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
280 | break; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
281 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
282 | l = l->next; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
283 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
284 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
285 | if (who) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
286 | if (avatar == 2) |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
287 | yahoo_send_picture_request(gc, who); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
288 | else if ((avatar == 0) || (avatar == 1)) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
289 | YahooFriend *f; |
|
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
|
290 | purple_buddy_icons_set_for_user(gc->account, who, NULL, 0, NULL); |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
291 | if ((f = yahoo_friend_find(gc, who))) |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
292 | yahoo_friend_set_buddy_icon_need_request(f, TRUE); |
| 15884 | 293 | 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
|
294 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
295 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
296 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
297 | |
| 15884 | 298 | void yahoo_send_picture_info(PurpleConnection *gc, const char *who) |
| 9322 | 299 | { |
| 300 | struct yahoo_data *yd = gc->proto_data; | |
| 301 | struct yahoo_packet *pkt; | |
| 302 | ||
| 9329 | 303 | if (!yd->picture_url) { |
| 15884 | 304 | purple_debug_warning("yahoo", "Attempted to send picture info without a picture\n"); |
| 9322 | 305 | return; |
| 9329 | 306 | } |
| 9322 | 307 | |
| 308 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); | |
| 15884 | 309 | yahoo_packet_hash(pkt, "sssssi", 1, purple_connection_get_display_name(gc), |
| 310 | 4, purple_connection_get_display_name(gc), 5, who, | |
| 10394 | 311 | 13, "2", 20, yd->picture_url, 192, yd->picture_checksum); |
| 10392 | 312 | yahoo_packet_send_and_free(pkt, yd); |
| 9322 | 313 | } |
| 9306 | 314 | |
| 15884 | 315 | void yahoo_send_picture_request(PurpleConnection *gc, const char *who) |
| 9306 | 316 | { |
| 317 | struct yahoo_data *yd = gc->proto_data; | |
| 318 | struct yahoo_packet *pkt; | |
| 319 | ||
| 320 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); | |
| 15884 | 321 | yahoo_packet_hash_str(pkt, 4, purple_connection_get_display_name(gc)); /* me */ |
| 10394 | 322 | yahoo_packet_hash_str(pkt, 5, who); /* the other guy */ |
| 323 | yahoo_packet_hash_str(pkt, 13, "1"); /* 1 = request, 2 = reply */ | |
| 10392 | 324 | yahoo_packet_send_and_free(pkt, yd); |
| 9306 | 325 | } |
| 326 | ||
| 15884 | 327 | void yahoo_send_picture_checksum(PurpleConnection *gc) |
| 9310 | 328 | { |
| 329 | struct yahoo_data *yd = gc->proto_data; | |
| 330 | struct yahoo_packet *pkt; | |
| 331 | ||
| 332 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0); | |
| 15884 | 333 | yahoo_packet_hash(pkt, "ssi", 1, purple_connection_get_display_name(gc), |
| 10394 | 334 | 212, "1", 192, yd->picture_checksum); |
| 10392 | 335 | yahoo_packet_send_and_free(pkt, yd); |
| 9310 | 336 | } |
| 337 | ||
| 15884 | 338 | void yahoo_send_picture_update_to_user(PurpleConnection *gc, const char *who, int type) |
| 9310 | 339 | { |
| 340 | struct yahoo_data *yd = gc->proto_data; | |
| 341 | struct yahoo_packet *pkt; | |
| 342 | ||
| 343 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | |
| 15884 | 344 | yahoo_packet_hash(pkt, "ssi", 1, purple_connection_get_display_name(gc), 5, who, 206, type); |
| 10392 | 345 | yahoo_packet_send_and_free(pkt, yd); |
| 9310 | 346 | } |
| 347 | ||
| 348 | struct yspufe { | |
| 15884 | 349 | PurpleConnection *gc; |
| 9310 | 350 | int type; |
| 351 | }; | |
| 352 | ||
| 353 | static void yahoo_send_picture_update_foreach(gpointer key, gpointer value, gpointer data) | |
| 354 | { | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
355 | const char *who = key; |
| 9310 | 356 | YahooFriend *f = value; |
| 357 | struct yspufe *d = data; | |
| 358 | ||
| 359 | if (f->status != YAHOO_STATUS_OFFLINE) | |
| 360 | yahoo_send_picture_update_to_user(d->gc, who, d->type); | |
| 361 | } | |
| 362 | ||
| 15884 | 363 | void yahoo_send_picture_update(PurpleConnection *gc, int type) |
| 9310 | 364 | { |
| 365 | struct yahoo_data *yd = gc->proto_data; | |
| 366 | struct yspufe data; | |
| 367 | ||
| 368 | data.gc = gc; | |
| 369 | data.type = type; | |
| 370 | ||
| 371 | g_hash_table_foreach(yd->friends, yahoo_send_picture_update_foreach, &data); | |
| 372 | } | |
| 373 | ||
| 9306 | 374 | void yahoo_buddy_icon_upload_data_free(struct yahoo_buddy_icon_upload_data *d) |
| 375 | { | |
| 15884 | 376 | purple_debug_misc("yahoo", "In yahoo_buddy_icon_upload_data_free()\n"); |
| 9306 | 377 | |
| 378 | if (d->str) | |
| 379 | g_string_free(d->str, TRUE); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
380 | g_free(d->filename); |
| 9306 | 381 | if (d->watcher) |
| 15884 | 382 | purple_input_remove(d->watcher); |
| 9306 | 383 | if (d->fd != -1) |
| 384 | close(d->fd); | |
| 385 | g_free(d); | |
| 386 | } | |
| 387 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
388 | /* we couldn't care less about the server's response, but yahoo gets grumpy if we close before it sends it */ |
| 15884 | 389 | static void yahoo_buddy_icon_upload_reading(gpointer data, gint source, PurpleInputCondition condition) |
| 9306 | 390 | { |
| 391 | struct yahoo_buddy_icon_upload_data *d = data; | |
| 15884 | 392 | PurpleConnection *gc = d->gc; |
| 9306 | 393 | char buf[1024]; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
394 | int ret; |
| 9306 | 395 | |
| 15884 | 396 | if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 9306 | 397 | yahoo_buddy_icon_upload_data_free(d); |
| 398 | return; | |
| 399 | } | |
| 400 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
401 | ret = read(d->fd, buf, sizeof(buf)); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
402 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
403 | if (ret < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
404 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
405 | else if (ret <= 0) |
| 9306 | 406 | yahoo_buddy_icon_upload_data_free(d); |
| 407 | } | |
| 408 | ||
| 15884 | 409 | static void yahoo_buddy_icon_upload_pending(gpointer data, gint source, PurpleInputCondition condition) |
| 9306 | 410 | { |
| 411 | struct yahoo_buddy_icon_upload_data *d = data; | |
| 15884 | 412 | 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
|
413 | gssize wrote; |
| 9306 | 414 | |
| 15884 | 415 | if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 9306 | 416 | yahoo_buddy_icon_upload_data_free(d); |
| 417 | return; | |
| 418 | } | |
| 419 | ||
| 420 | 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
|
421 | if (wrote < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
422 | return; |
| 9306 | 423 | if (wrote <= 0) { |
| 424 | yahoo_buddy_icon_upload_data_free(d); | |
| 425 | return; | |
| 426 | } | |
| 427 | d->pos += wrote; | |
| 428 | if (d->pos >= d->str->len) { | |
| 15884 | 429 | purple_debug_misc("yahoo", "Finished uploading buddy icon.\n"); |
| 430 | purple_input_remove(d->watcher); | |
| 431 | d->watcher = purple_input_add(d->fd, PURPLE_INPUT_READ, yahoo_buddy_icon_upload_reading, d); | |
| 9306 | 432 | } |
| 433 | } | |
| 434 | ||
|
14182
517f4531b8a0
[gaim-migrate @ 16754]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
435 | static void yahoo_buddy_icon_upload_connected(gpointer data, gint source, const gchar *error_message) |
| 9306 | 436 | { |
| 437 | struct yahoo_buddy_icon_upload_data *d = data; | |
| 438 | struct yahoo_packet *pkt; | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
439 | gchar *size, *header; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
440 | guchar *pkt_buf; |
|
10576
ce7a6c585bc6
[gaim-migrate @ 11970]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10394
diff
changeset
|
441 | const char *host; |
|
13272
fd4f3356640f
[gaim-migrate @ 15637]
Daniel Atallah <datallah@pidgin.im>
parents:
13201
diff
changeset
|
442 | int port; |
|
13277
c8a85dd74704
[gaim-migrate @ 15642]
Richard Laager <rlaager@pidgin.im>
parents:
13272
diff
changeset
|
443 | size_t content_length, pkt_buf_len; |
| 15884 | 444 | PurpleConnection *gc; |
| 445 | PurpleAccount *account; | |
| 9306 | 446 | struct yahoo_data *yd; |
| 447 | ||
| 448 | gc = d->gc; | |
| 15884 | 449 | account = purple_connection_get_account(gc); |
| 9306 | 450 | yd = gc->proto_data; |
| 451 | ||
| 15884 | 452 | /* Buddy icon connect is now complete; clear the PurpleProxyConnectData */ |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
453 | yd->buddy_icon_connect_data = NULL; |
|
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
454 | |
| 9306 | 455 | if (source < 0) { |
| 15884 | 456 | purple_debug_error("yahoo", "Buddy icon upload failed: %s\n", error_message); |
| 9306 | 457 | yahoo_buddy_icon_upload_data_free(d); |
| 458 | return; | |
| 459 | } | |
| 460 | ||
| 461 | pkt = yahoo_packet_new(0xc2, YAHOO_STATUS_AVAILABLE, yd->session_id); | |
| 462 | ||
| 10111 | 463 | size = g_strdup_printf("%" G_GSIZE_FORMAT, d->str->len); |
| 9306 | 464 | /* 1 = me, 38 = expire time(?), 0 = me, 28 = size, 27 = filename, 14 = NULL, 29 = data */ |
| 15884 | 465 | yahoo_packet_hash_str(pkt, 1, purple_connection_get_display_name(gc)); |
| 10394 | 466 | yahoo_packet_hash_str(pkt, 38, "604800"); /* time til expire */ |
| 15884 | 467 | purple_account_set_int(account, YAHOO_PICEXPIRE_SETTING, time(NULL) + 604800); |
| 468 | yahoo_packet_hash_str(pkt, 0, purple_connection_get_display_name(gc)); | |
| 10394 | 469 | yahoo_packet_hash_str(pkt, 28, size); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
470 | g_free(size); |
| 10394 | 471 | yahoo_packet_hash_str(pkt, 27, d->filename); |
| 472 | yahoo_packet_hash_str(pkt, 14, ""); | |
| 9306 | 473 | |
| 474 | content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); | |
| 475 | ||
| 15884 | 476 | host = purple_account_get_string(account, "xfer_host", YAHOO_XFER_HOST); |
| 477 | port = purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
478 | header = g_strdup_printf( |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
479 | "POST http://%s:%d/notifyft HTTP/1.0\r\n" |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
480 | "Content-length: %" G_GSIZE_FORMAT "\r\n" |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
481 | "Host: %s:%d\r\n" |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
482 | "Cookie: Y=%s; T=%s\r\n" |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
483 | "\r\n", |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
484 | host, port, content_length + 4 + d->str->len, |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
485 | host, port, yd->cookie_y, yd->cookie_t); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
486 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
487 | /* 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
|
488 | g_string_prepend(d->str, "29\xc0\x80"); |
| 9306 | 489 | |
|
14508
02d80a119d80
[gaim-migrate @ 17160]
Evan Schoenberg <evands@pidgin.im>
parents:
14416
diff
changeset
|
490 | pkt_buf_len = yahoo_packet_build(pkt, 8, FALSE, yd->jp, &pkt_buf); |
| 9306 | 491 | yahoo_packet_free(pkt); |
| 14321 | 492 | 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
|
493 | g_free(pkt_buf); |
| 9306 | 494 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
495 | g_string_prepend(d->str, header); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
496 | g_free(header); |
| 9306 | 497 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
498 | d->fd = source; |
| 15884 | 499 | 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
|
500 | |
| 15884 | 501 | yahoo_buddy_icon_upload_pending(d, d->fd, PURPLE_INPUT_WRITE); |
| 9306 | 502 | } |
| 503 | ||
| 15884 | 504 | void yahoo_buddy_icon_upload(PurpleConnection *gc, struct yahoo_buddy_icon_upload_data *d) |
| 9306 | 505 | { |
| 15884 | 506 | PurpleAccount *account = purple_connection_get_account(gc); |
| 9306 | 507 | struct yahoo_data *yd = gc->proto_data; |
| 508 | ||
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
509 | if (yd->buddy_icon_connect_data != NULL) { |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
510 | /* Cancel any in-progress buddy icon upload */ |
| 15884 | 511 | purple_proxy_connect_cancel(yd->buddy_icon_connect_data); |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
512 | yd->buddy_icon_connect_data = NULL; |
|
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
513 | } |
|
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
514 | |
| 15884 | 515 | yd->buddy_icon_connect_data = purple_proxy_connect(NULL, account, |
| 516 | yd->jp ? purple_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST) | |
| 517 | : purple_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), | |
| 518 | purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
519 | yahoo_buddy_icon_upload_connected, d); |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
520 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
521 | if (yd->buddy_icon_connect_data == NULL) |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
522 | { |
| 15884 | 523 | 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
|
524 | yahoo_buddy_icon_upload_data_free(d); |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
525 | } |
| 9306 | 526 | } |
| 527 | ||
|
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
|
528 | void yahoo_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) |
| 9306 | 529 | { |
| 530 | struct yahoo_data *yd = gc->proto_data; | |
| 15884 | 531 | PurpleAccount *account = gc->account; |
| 9306 | 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 | if (img == NULL) { |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
534 | g_free(yd->picture_url); |
| 9306 | 535 | yd->picture_url = NULL; |
| 536 | ||
| 15884 | 537 | purple_account_set_string(account, YAHOO_PICURL_SETTING, NULL); |
| 538 | purple_account_set_int(account, YAHOO_PICCKSUM_SETTING, 0); | |
| 539 | purple_account_set_int(account, YAHOO_PICEXPIRE_SETTING, 0); | |
| 9310 | 540 | if (yd->logged_in) |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
541 | /* Tell everyone we ain't got one no more */ |
| 9310 | 542 | yahoo_send_picture_update(gc, 0); |
| 9306 | 543 | |
|
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
|
544 | } 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
|
545 | 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
|
546 | 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
|
547 | GString *s = g_string_new_len(data, len); |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
548 | struct yahoo_buddy_icon_upload_data *d; |
| 15884 | 549 | int oldcksum = purple_account_get_int(account, YAHOO_PICCKSUM_SETTING, 0); |
| 550 | int expire = purple_account_get_int(account, YAHOO_PICEXPIRE_SETTING, 0); | |
| 551 | const char *oldurl = purple_account_get_string(account, YAHOO_PICURL_SETTING, NULL); | |
|
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
|
552 | char *iconfile; |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
553 | |
|
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
|
554 | /* TODO: At some point, it'd be nice to fix this for real, or |
|
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
|
555 | * TODO: at least change it to be something like: |
|
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
|
556 | * TODO: purple_imgstore_get_filename(img); |
|
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
|
557 | * TODO: But it would be great if we knew how to calculate the |
|
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
|
558 | * TODO: Checksum correctly. */ |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
559 | yd->picture_checksum = g_string_hash(s); |
| 9306 | 560 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
561 | if ((yd->picture_checksum == oldcksum) && |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
562 | (expire > (time(NULL) + 60*60*24)) && oldurl) |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
563 | { |
| 15884 | 564 | 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
|
565 | g_string_free(s, TRUE); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
566 | g_free(yd->picture_url); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
567 | yd->picture_url = g_strdup(oldurl); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
568 | return; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
569 | } |
| 9306 | 570 | |
|
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
|
571 | /* We use this solely for sending a filename to the server */ |
|
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 | iconfile = g_strdup(purple_imgstore_get_filename(img)); |
|
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; |
|
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
|
577 | d->filename = iconfile; |
| 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 | } |