annotate src/protocols/yahoo/yahoo_picture.c @ 9625:3ec0b63d4f2e

[gaim-migrate @ 10469] As far as I know oscar buddy comments are plain-text. Fixes bug 999922. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 31 Jul 2004 23:08:52 +0000
parents d42f3e4fd7ad
children ba78e5a34bed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
1 /*
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
2 * gaim
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
3 *
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
6 * source distribution.
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
7 *
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
12 *
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
17 *
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
21 *
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
22 */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
23
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
24 #include "internal.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
25
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
26 #include "account.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
27 #include "accountopt.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
28 #include "blist.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
29 #include "debug.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
30 #include "prpl.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
31 #include "proxy.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
32 #include "util.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
33
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
34 #include "yahoo.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
35 #include "yahoo_friend.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
36 #include "yahoo_picture.h"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
37
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
38
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
39 struct yahoo_fetch_picture_data {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
40 GaimConnection *gc;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
41 char *who;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
42 int checksum;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
43 };
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
44
9310
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
45
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
46
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
47 void yahoo_fetch_picture_cb(void *user_data, const char *pic_data, size_t len)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
48 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
49 struct yahoo_fetch_picture_data *d = user_data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
50 GaimBuddy *b;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
51
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
52 if (GAIM_CONNECTION_IS_VALID(d->gc) && len) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
53 gaim_buddy_icons_set_for_user(gaim_connection_get_account(d->gc), d->who, (void *)pic_data, len);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
54 b = gaim_find_buddy(gaim_connection_get_account(d->gc), d->who);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
55 if (b)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
56 gaim_blist_node_set_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY, d->checksum);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
57 } else {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
58 gaim_debug_error("yahoo", "Fetching buddy icon failed.\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
59 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
60
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
61 g_free(d->who);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
62 g_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
63 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
64
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
65 void yahoo_process_picture(GaimConnection *gc, struct yahoo_packet *pkt)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
66 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
67 GSList *l = pkt->hash;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
68 char *who = NULL, *us = NULL;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
69 gboolean got_icon_info = FALSE, send_icon_info = FALSE;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
70 char *url = NULL;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
71 int checksum = 0;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
72
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
73 while (l) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
74 struct yahoo_pair *pair = l->data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
75
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
76 switch (pair->key) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
77 case 1:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
78 case 4:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
79 who = pair->value;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
80 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
81 case 5:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
82 us = pair->value;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
83 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
84 case 13: {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
85 int tmp;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
86 tmp = strtol(pair->value, NULL, 10);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
87 if (tmp == 1) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
88 send_icon_info = TRUE;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
89 } else if (tmp == 2) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
90 got_icon_info = TRUE;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
91 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
92 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
93 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
94 case 20:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
95 url = pair->value;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
96 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
97 case 192:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
98 checksum = strtol(pair->value, NULL, 10);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
99 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
100 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
101
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
102 l = l->next;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
103 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
104
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
105 if (who && got_icon_info && url) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
106 /* TODO: make this work p2p, try p2p before the url */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
107 struct yahoo_fetch_picture_data *data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
108 GaimBuddy *b = gaim_find_buddy(gc->account, who);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
109 if (b && (checksum == gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY)))
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
110 return;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
111
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
112 data = g_new0(struct yahoo_fetch_picture_data, 1);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
113 data->gc = gc;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
114 data->who = g_strdup(who);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
115 data->checksum = checksum;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
116 gaim_url_fetch(url, FALSE, "Mozilla/4.0 (compatible; MSIE 5.0)", FALSE,
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
117 yahoo_fetch_picture_cb, data);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
118 } else if (who && send_icon_info) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
119 yahoo_send_picture_info(gc, who);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
120 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
121
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
122 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
123
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
124 void yahoo_process_picture_update(GaimConnection *gc, struct yahoo_packet *pkt)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
125 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
126 GSList *l = pkt->hash;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
127 char *who = NULL;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
128 int icon = 0;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
129
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
130 while (l) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
131 struct yahoo_pair *pair = l->data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
132
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
133 switch (pair->key) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
134 case 4:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
135 who = pair->value;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
136 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
137 case 5:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
138 /* us */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
139 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
140 case 206:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
141 icon = strtol(pair->value, NULL, 10);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
142 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
143 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
144 l = l->next;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
145 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
146
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
147 if (who) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
148 if (icon == 2)
9310
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
149 yahoo_send_picture_request(gc, who);
9322
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
150 else if ((icon == 0) || (icon == 1)) {
9325
f40233043b5a [gaim-migrate @ 10133]
Tim Ringenbach <marv@pidgin.im>
parents: 9322
diff changeset
151 GaimBuddy *b = gaim_find_buddy(gc->account, who);
f40233043b5a [gaim-migrate @ 10133]
Tim Ringenbach <marv@pidgin.im>
parents: 9322
diff changeset
152 YahooFriend *f;
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
153 gaim_buddy_icons_set_for_user(gc->account, who, NULL, 0);
9325
f40233043b5a [gaim-migrate @ 10133]
Tim Ringenbach <marv@pidgin.im>
parents: 9322
diff changeset
154 if (b)
f40233043b5a [gaim-migrate @ 10133]
Tim Ringenbach <marv@pidgin.im>
parents: 9322
diff changeset
155 gaim_blist_node_remove_setting((GaimBlistNode *)b, YAHOO_ICON_CHECKSUM_KEY);
f40233043b5a [gaim-migrate @ 10133]
Tim Ringenbach <marv@pidgin.im>
parents: 9322
diff changeset
156 if ((f = yahoo_friend_find(gc, who)))
f40233043b5a [gaim-migrate @ 10133]
Tim Ringenbach <marv@pidgin.im>
parents: 9322
diff changeset
157 yahoo_friend_set_buddy_icon_need_request(f, TRUE);
9322
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
158 gaim_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
159 }
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
160 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
161 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
162
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
163 void yahoo_process_picture_checksum(GaimConnection *gc, struct yahoo_packet *pkt)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
164 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
165 GSList *l = pkt->hash;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
166 char *who = NULL;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
167 int checksum = 0;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
168
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
169 while (l) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
170 struct yahoo_pair *pair = l->data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
171
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
172 switch (pair->key) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
173 case 4:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
174 who = pair->value;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
175 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
176 case 5:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
177 /* us */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
178 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
179 case 192:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
180 checksum = strtol(pair->value, NULL, 10);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
181 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
182 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
183 l = l->next;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
184 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
185
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
186 if (who) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
187 GaimBuddy *b = gaim_find_buddy(gc->account, who);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
188 if (b && (checksum != gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY)))
9310
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
189 yahoo_send_picture_request(gc, who);
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
190 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
191 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
192
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
193 void yahoo_process_picture_upload(GaimConnection *gc, struct yahoo_packet *pkt)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
194 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
195 GaimAccount *account = gaim_connection_get_account(gc);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
196 struct yahoo_data *yd = gc->proto_data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
197 GSList *l = pkt->hash;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
198 char *url = NULL;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
199
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
200 while (l) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
201 struct yahoo_pair *pair = l->data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
202
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
203 switch (pair->key) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
204 case 5:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
205 /* us */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
206 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
207 case 27:
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
208 /* filename on our computer. */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
209 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
210 case 20: /* url at yahoo */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
211 url = pair->value;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
212 case 38: /* timestamp */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
213 break;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
214 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
215 l = l->next;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
216 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
217
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
218 if (url) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
219 if (yd->picture_url)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
220 g_free(yd->picture_url);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
221 yd->picture_url = g_strdup(url);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
222 gaim_account_set_string(account, YAHOO_PICURL_SETTING, url);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
223 gaim_account_set_int(account, YAHOO_PICCKSUM_SETTING, yd->picture_checksum);
9310
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
224 yahoo_send_picture_update(gc, 2);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
225 yahoo_send_picture_checksum(gc);
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
226 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
227 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
228
9322
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
229 void yahoo_send_picture_info(GaimConnection *gc, const char *who)
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
230 {
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
231 struct yahoo_data *yd = gc->proto_data;
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
232 struct yahoo_packet *pkt;
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
233 char *buf;
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
234
9329
d42f3e4fd7ad [gaim-migrate @ 10137]
Tim Ringenbach <marv@pidgin.im>
parents: 9325
diff changeset
235 if (!yd->picture_url) {
d42f3e4fd7ad [gaim-migrate @ 10137]
Tim Ringenbach <marv@pidgin.im>
parents: 9325
diff changeset
236 gaim_debug_warning("yahoo", "Attempted to send picture info without a picture\n");
9322
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
237 return;
9329
d42f3e4fd7ad [gaim-migrate @ 10137]
Tim Ringenbach <marv@pidgin.im>
parents: 9325
diff changeset
238 }
9322
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
239
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
240 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
241 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
242 yahoo_packet_hash(pkt, 4, gaim_connection_get_display_name(gc));
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
243 yahoo_packet_hash(pkt, 5, who);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
244 yahoo_packet_hash(pkt, 13, "2");
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
245 yahoo_packet_hash(pkt, 20, yd->picture_url);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
246 buf = g_strdup_printf("%d", yd->picture_checksum);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
247 yahoo_packet_hash(pkt, 192, buf);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
248
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
249 yahoo_send_packet(yd, pkt);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
250 yahoo_packet_free(pkt);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
251 g_free(buf);
119f8a2c00b6 [gaim-migrate @ 10130]
Tim Ringenbach <marv@pidgin.im>
parents: 9310
diff changeset
252 }
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
253
9310
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
254 void yahoo_send_picture_request(GaimConnection *gc, const char *who)
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
255 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
256 struct yahoo_data *yd = gc->proto_data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
257 struct yahoo_packet *pkt;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
258
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
259 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
260 yahoo_packet_hash(pkt, 4, gaim_connection_get_display_name(gc)); /* me */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
261 yahoo_packet_hash(pkt, 5, who); /* the other guy */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
262 yahoo_packet_hash(pkt, 13, "1"); /* 1 = request, 2 = reply */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
263 yahoo_send_packet(yd, pkt);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
264 yahoo_packet_free(pkt);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
265 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
266
9310
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
267 void yahoo_send_picture_checksum(GaimConnection *gc)
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
268 {
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
269 struct yahoo_data *yd = gc->proto_data;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
270 struct yahoo_packet *pkt;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
271 char *cksum = g_strdup_printf("%d", yd->picture_checksum);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
272
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
273 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
274 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
275 yahoo_packet_hash(pkt, 212, "1");
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
276 yahoo_packet_hash(pkt, 192, cksum);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
277 yahoo_send_packet(yd, pkt);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
278 yahoo_packet_free(pkt);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
279 g_free(cksum);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
280 }
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
281
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
282 void yahoo_send_picture_update_to_user(GaimConnection *gc, const char *who, int type)
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
283 {
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
284 struct yahoo_data *yd = gc->proto_data;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
285 struct yahoo_packet *pkt;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
286 char *typestr = g_strdup_printf("%d", type);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
287
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
288 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
289 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
290 yahoo_packet_hash(pkt, 5, who);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
291 yahoo_packet_hash(pkt, 206, typestr);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
292 yahoo_send_packet(yd, pkt);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
293 yahoo_packet_free(pkt);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
294
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
295 g_free(typestr);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
296 }
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
297
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
298 struct yspufe {
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
299 GaimConnection *gc;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
300 int type;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
301 };
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
302
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
303 static void yahoo_send_picture_update_foreach(gpointer key, gpointer value, gpointer data)
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
304 {
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
305 char *who = key;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
306 YahooFriend *f = value;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
307 struct yspufe *d = data;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
308
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
309 if (f->status != YAHOO_STATUS_OFFLINE)
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
310 yahoo_send_picture_update_to_user(d->gc, who, d->type);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
311 }
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
312
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
313 void yahoo_send_picture_update(GaimConnection *gc, int type)
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
314 {
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
315 struct yahoo_data *yd = gc->proto_data;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
316 struct yspufe data;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
317
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
318 data.gc = gc;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
319 data.type = type;
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
320
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
321 g_hash_table_foreach(yd->friends, yahoo_send_picture_update_foreach, &data);
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
322 }
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
323
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
324 void yahoo_buddy_icon_upload_data_free(struct yahoo_buddy_icon_upload_data *d)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
325 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
326 gaim_debug_misc("yahoo", "In yahoo_buddy_icon_upload_data_free()\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
327
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
328 if (d->str)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
329 g_string_free(d->str, TRUE);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
330 if (d->filename)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
331 g_free(d->filename);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
332 if (d->watcher)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
333 gaim_input_remove(d->watcher);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
334 if (d->fd != -1)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
335 close(d->fd);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
336 g_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
337 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
338
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
339 /* we could care less about the server's responce, but yahoo gets grumpy if we close before it sends it */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
340 static void yahoo_buddy_icon_upload_reading(gpointer data, gint source, GaimInputCondition condition)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
341 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
342 struct yahoo_buddy_icon_upload_data *d = data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
343 GaimConnection *gc = d->gc;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
344 char buf[1024];
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
345
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
346 if (!GAIM_CONNECTION_IS_VALID(gc)) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
347 yahoo_buddy_icon_upload_data_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
348 return;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
349 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
350
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
351 if (read(d->fd, buf, sizeof(buf)) <= 0)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
352 yahoo_buddy_icon_upload_data_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
353 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
354
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
355 static void yahoo_buddy_icon_upload_pending(gpointer data, gint source, GaimInputCondition condition)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
356 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
357 struct yahoo_buddy_icon_upload_data *d = data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
358 GaimConnection *gc = d->gc;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
359 ssize_t wrote;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
360
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
361 if (!GAIM_CONNECTION_IS_VALID(gc)) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
362 yahoo_buddy_icon_upload_data_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
363 return;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
364 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
365
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
366 wrote = write(d->fd, d->str->str + d->pos, d->str->len - d->pos);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
367 if (wrote <= 0) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
368 yahoo_buddy_icon_upload_data_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
369 return;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
370 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
371 d->pos += wrote;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
372 if (d->pos >= d->str->len) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
373 gaim_debug_misc("yahoo", "Finished uploading buddy icon.\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
374 gaim_input_remove(d->watcher);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
375 d->watcher = gaim_input_add(d->fd, GAIM_INPUT_READ, yahoo_buddy_icon_upload_reading, d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
376 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
377 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
378
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
379 static void yahoo_buddy_icon_upload_connected(gpointer data, gint source, GaimInputCondition condition)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
380 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
381 struct yahoo_buddy_icon_upload_data *d = data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
382 struct yahoo_packet *pkt;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
383 gchar *size, *post, *buf;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
384 int content_length;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
385 GaimConnection *gc;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
386 GaimAccount *account;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
387 struct yahoo_data *yd;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
388
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
389 if (!d)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
390 return;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
391
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
392
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
393 gc = d->gc;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
394 account = gaim_connection_get_account(gc);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
395 yd = gc->proto_data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
396
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
397
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
398 if (source < 0) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
399 gaim_debug_error("yahoo", "Buddy icon upload failed, no file desc.\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
400 yahoo_buddy_icon_upload_data_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
401 return;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
402 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
403
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
404 d->fd = source;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
405 d->watcher = gaim_input_add(d->fd, GAIM_INPUT_WRITE, yahoo_buddy_icon_upload_pending, d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
406
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
407 pkt = yahoo_packet_new(0xc2, YAHOO_STATUS_AVAILABLE, yd->session_id);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
408
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
409 size = g_strdup_printf("%d", d->str->len);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
410 /* 1 = me, 38 = expire time(?), 0 = me, 28 = size, 27 = filename, 14 = NULL, 29 = data */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
411 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
412 yahoo_packet_hash(pkt, 38, "604800"); /* time til expire */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
413 gaim_account_set_int(account, YAHOO_PICEXPIRE_SETTING, time(NULL) + 604800);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
414 yahoo_packet_hash(pkt, 0, gaim_connection_get_display_name(gc));
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
415 yahoo_packet_hash(pkt, 28, size);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
416 yahoo_packet_hash(pkt, 27, d->filename);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
417 yahoo_packet_hash(pkt, 14, "");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
418
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
419 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
420
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
421 buf = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
422
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
423 post = g_strdup_printf("POST /notifyft HTTP/1.0\r\n"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
424 "Content-length: %d\r\n"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
425 "Host: %s:%d\r\n"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
426 "Cookie: %s\r\n"
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
427 "\r\n",
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
428 content_length + 4 + d->str->len,
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
429 gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST),
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
430 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
431 buf);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
432 write(d->fd, post, strlen(post));
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
433
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
434 yahoo_send_packet_special(d->fd, pkt, 8);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
435 yahoo_packet_free(pkt);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
436
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
437 write(d->fd, "29\xc0\x80", 4);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
438
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
439 g_free(size);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
440 g_free(post);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
441 g_free(buf);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
442 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
443
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
444 void yahoo_buddy_icon_upload(GaimConnection *gc, struct yahoo_buddy_icon_upload_data *d)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
445 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
446 GaimAccount *account = gaim_connection_get_account(gc);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
447 struct yahoo_data *yd = gc->proto_data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
448
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
449 if (yd->jp) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
450 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST),
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
451 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
452 yahoo_buddy_icon_upload_connected, d) == -1)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
453 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
454 gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
455 yahoo_buddy_icon_upload_data_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
456 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
457 } else {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
458 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST),
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
459 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
460 yahoo_buddy_icon_upload_connected, d) == -1)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
461 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
462 gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
463 yahoo_buddy_icon_upload_data_free(d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
464 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
465 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
466 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
467
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
468 void yahoo_set_buddy_icon(GaimConnection *gc, const char *iconfile)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
469 {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
470 struct yahoo_data *yd = gc->proto_data;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
471 GaimAccount *account = gc->account;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
472 FILE *file;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
473 struct stat st;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
474
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
475 if (iconfile == NULL) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
476 if (yd->picture_url)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
477 g_free(yd->picture_url);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
478 yd->picture_url = NULL;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
479
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
480 gaim_account_set_string(account, YAHOO_PICURL_SETTING, NULL);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
481 gaim_account_set_int(account, YAHOO_PICCKSUM_SETTING, 0);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
482 gaim_account_set_int(account, YAHOO_PICEXPIRE_SETTING, 0);
9310
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
483 if (yd->logged_in)
085190b9dd64 [gaim-migrate @ 10118]
Tim Ringenbach <marv@pidgin.im>
parents: 9306
diff changeset
484 yahoo_send_picture_update(gc, 0);
9306
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
485 /* TODO: check if we're connected and tell everyone we ain't not one no more */
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
486 } else if (!stat(iconfile, &st)) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
487 file = fopen(iconfile, "rb");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
488 if (file) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
489 GString *s = g_string_sized_new(st.st_size);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
490 size_t len;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
491 struct yahoo_buddy_icon_upload_data *d;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
492 int oldcksum = gaim_account_get_int(account, YAHOO_PICCKSUM_SETTING, 0);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
493 int expire = gaim_account_get_int(account, YAHOO_PICEXPIRE_SETTING, 0);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
494 const char *oldurl = gaim_account_get_string(account, YAHOO_PICURL_SETTING, NULL);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
495
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
496 g_string_set_size(s, st.st_size);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
497 len = fread(s->str, 1, st.st_size, file);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
498 fclose(file);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
499 g_string_set_size(s, len);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
500 yd->picture_checksum = g_string_hash(s);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
501
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
502 if ((yd->picture_checksum == oldcksum) && (expire > (time(NULL) + 60*60*24)) &&
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
503 oldcksum && expire && oldurl) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
504 gaim_debug_misc("yahoo", "buddy icon is up to date. Not reuploading.\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
505 g_string_free(s, TRUE);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
506 if (yd->picture_url)
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
507 g_free(yd->picture_url);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
508 yd->picture_url = g_strdup(oldurl);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
509 return;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
510 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
511
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
512 d = g_new0(struct yahoo_buddy_icon_upload_data, 1);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
513 d->gc = gc;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
514 d->str = s;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
515 d->fd = -1;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
516 d->filename = g_strdup(iconfile);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
517
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
518 if (!yd->logged_in) {
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
519 yd->picture_upload_todo = d;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
520 return;
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
521 }
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
522
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
523 yahoo_buddy_icon_upload(gc, d);
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
524 } else
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
525 gaim_debug_error("yahoo",
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
526 "Can't open buddy icon file!\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
527 } else
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
528 gaim_debug_error("yahooo",
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
529 "Can't stat buddy icon file!\n");
04a3e9e869ee [gaim-migrate @ 10114]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
530 }