Mercurial > pidgin
annotate src/protocols/yahoo/yahoo.c @ 9369:241a799cc821
[gaim-migrate @ 10177]
There's always WEBMESSENGER.
*sigh*
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Thu, 24 Jun 2004 02:59:14 +0000 |
| parents | d42f3e4fd7ad |
| children | 76f4bffcfb23 |
| rev | line source |
|---|---|
| 2681 | 1 /* |
| 2 * gaim | |
| 3 * | |
| 8046 | 4 * Gaim is the legal property of its developers, whose names are too numerous |
| 5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 * source distribution. | |
| 2681 | 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 | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 * | |
| 22 */ | |
| 9369 | 23 #define YAHOO_WEBMESSENGER |
| 24 | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
25 #include "internal.h" |
| 2681 | 26 |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
27 #include "account.h" |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
28 #include "accountopt.h" |
| 6760 | 29 #include "blist.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
30 #include "debug.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
31 #include "notify.h" |
| 6760 | 32 #include "privacy.h" |
| 2681 | 33 #include "prpl.h" |
| 34 #include "proxy.h" | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
35 #include "request.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
36 #include "server.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
37 #include "util.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
38 |
| 6986 | 39 #include "sha.h" |
| 6513 | 40 #include "yahoo.h" |
| 9278 | 41 #include "yahoo_friend.h" |
| 6729 | 42 #include "yahoochat.h" |
| 8349 | 43 #include "yahoo_auth.h" |
| 7651 | 44 #include "yahoo_filexfer.h" |
| 9306 | 45 #include "yahoo_picture.h" |
| 3147 | 46 #include "md5.h" |
| 2681 | 47 |
| 5583 | 48 extern char *yahoo_crypt(const char *, const char *); |
|
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
49 |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
50 /* #define YAHOO_DEBUG */ |
| 2681 | 51 |
| 9285 | 52 static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *, GaimGroup *); |
| 9306 | 53 |
| 6784 | 54 |
| 6729 | 55 struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) |
| 2681 | 56 { |
| 57 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); | |
| 58 | |
| 59 pkt->service = service; | |
| 60 pkt->status = status; | |
| 61 pkt->id = id; | |
| 62 | |
| 63 return pkt; | |
| 64 } | |
| 65 | |
| 6729 | 66 void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value) |
| 2681 | 67 { |
| 68 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
| 69 pair->key = key; | |
| 70 pair->value = g_strdup(value); | |
| 71 pkt->hash = g_slist_append(pkt->hash, pair); | |
| 72 } | |
| 73 | |
| 7651 | 74 int yahoo_packet_length(struct yahoo_packet *pkt) |
| 2681 | 75 { |
| 76 GSList *l; | |
| 77 | |
| 78 int len = 0; | |
| 79 | |
| 80 l = pkt->hash; | |
| 81 while (l) { | |
| 82 struct yahoo_pair *pair = l->data; | |
| 83 int tmp = pair->key; | |
| 84 do { | |
| 85 tmp /= 10; | |
| 86 len++; | |
| 87 } while (tmp); | |
| 88 len += 2; | |
| 89 len += strlen(pair->value); | |
| 90 len += 2; | |
| 91 l = l->next; | |
| 92 } | |
| 93 | |
| 94 return len; | |
| 95 } | |
| 96 | |
| 97 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) | |
| 98 { | |
| 99 int pos = 0; | |
| 100 | |
| 101 while (pos + 1 < len) { | |
| 6629 | 102 char key[64], *value = NULL, *esc; |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
103 int accept; |
| 2681 | 104 int x; |
| 105 | |
| 106 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
| 107 | |
| 9329 | 108 /* this is weird, and in one of the chat packets, and causes us |
| 109 * think all the values are keys and all the keys are values after | |
| 110 * this point if we don't handle it */ | |
| 111 if (data[pos] == '\0') { | |
| 112 while (pos + 1 < len) { | |
| 113 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
| 114 break; | |
| 115 pos++; | |
| 116 } | |
| 117 pos += 2; | |
| 118 g_free(pair); | |
| 119 continue; | |
| 120 } | |
| 121 | |
| 2681 | 122 x = 0; |
| 123 while (pos + 1 < len) { | |
| 124 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
| 125 break; | |
| 8118 | 126 if (x >= sizeof(key)-1) { |
| 127 x++; | |
| 8357 | 128 pos++; |
| 8118 | 129 continue; |
| 130 } | |
| 2681 | 131 key[x++] = data[pos++]; |
| 132 } | |
| 8118 | 133 if (x >= sizeof(key)-1) { |
| 134 x = 0; | |
| 135 } | |
| 2681 | 136 key[x] = 0; |
| 137 pos += 2; | |
| 138 pair->key = strtol(key, NULL, 10); | |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
139 accept = x; /* if x is 0 there was no key, so don't accept it */ |
| 2681 | 140 |
|
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
141 if (len - pos + 1 <= 0) { |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
142 /* Truncated. Garbage or something. */ |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
143 accept = 0; |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
144 } |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
145 |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
146 if (accept) { |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
147 value = g_malloc(len - pos + 1); |
|
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
148 x = 0; |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
149 while (pos + 1 < len) { |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
150 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
151 break; |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
152 value[x++] = data[pos++]; |
|
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
153 } |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
154 value[x] = 0; |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
155 pair->value = g_strdup(value); |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
156 g_free(value); |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
157 pkt->hash = g_slist_append(pkt->hash, pair); |
| 6629 | 158 esc = g_strescape(pair->value, NULL); |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
159 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
| 6629 | 160 "Key: %d \tValue: %s\n", pair->key, esc); |
| 161 g_free(esc); | |
|
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
162 } else { |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
163 g_free(pair); |
|
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
164 } |
|
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
165 pos += 2; |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
166 |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
167 /* Skip over garbage we've noticed in the mail notifications */ |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
168 if (data[0] == '9' && data[pos] == 0x01) |
|
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
169 pos++; |
| 2681 | 170 } |
| 171 } | |
| 172 | |
| 7651 | 173 void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) |
| 2681 | 174 { |
| 175 GSList *l = pkt->hash; | |
| 176 int pos = 0; | |
| 177 | |
| 178 while (l) { | |
| 179 struct yahoo_pair *pair = l->data; | |
| 180 guchar buf[100]; | |
| 181 | |
| 182 g_snprintf(buf, sizeof(buf), "%d", pair->key); | |
| 183 strcpy(data + pos, buf); | |
| 184 pos += strlen(buf); | |
| 185 data[pos++] = 0xc0; | |
| 186 data[pos++] = 0x80; | |
| 187 | |
| 188 strcpy(data + pos, pair->value); | |
| 189 pos += strlen(pair->value); | |
| 190 data[pos++] = 0xc0; | |
| 191 data[pos++] = 0x80; | |
| 192 | |
| 193 l = l->next; | |
| 194 } | |
| 195 } | |
| 196 | |
| 197 static void yahoo_packet_dump(guchar *data, int len) | |
| 198 { | |
| 199 #ifdef YAHOO_DEBUG | |
| 200 int i; | |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
201 |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
202 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
203 |
| 2681 | 204 for (i = 0; i + 1 < len; i += 2) { |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
205 if ((i % 16 == 0) && i) { |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
206 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
207 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
208 } |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
209 |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
210 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]); |
| 2681 | 211 } |
| 212 if (i < len) | |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
213 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]); |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
214 |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
215 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
216 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
217 |
| 2681 | 218 for (i = 0; i < len; i++) { |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
219 if ((i % 16 == 0) && i) { |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
220 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
221 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
222 } |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
223 |
| 6686 | 224 if (g_ascii_isprint(data[i])) |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
225 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]); |
| 2681 | 226 else |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
227 gaim_debug(GAIM_DEBUG_MISC, NULL, ". "); |
| 2681 | 228 } |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
229 |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
230 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
| 2681 | 231 #endif |
| 232 } | |
| 233 | |
| 6729 | 234 int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt) |
| 2681 | 235 { |
| 236 int pktlen = yahoo_packet_length(pkt); | |
| 237 int len = YAHOO_PACKET_HDRLEN + pktlen; | |
| 238 int ret; | |
| 239 | |
| 240 guchar *data; | |
| 241 int pos = 0; | |
| 242 | |
| 243 if (yd->fd < 0) | |
| 244 return -1; | |
| 245 | |
| 246 data = g_malloc0(len + 1); | |
| 247 | |
| 248 memcpy(data + pos, "YMSG", 4); pos += 4; | |
| 3467 | 249 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); |
| 2681 | 250 pos += yahoo_put16(data + pos, 0x0000); |
| 251 pos += yahoo_put16(data + pos, pktlen); | |
| 252 pos += yahoo_put16(data + pos, pkt->service); | |
| 253 pos += yahoo_put32(data + pos, pkt->status); | |
| 254 pos += yahoo_put32(data + pos, pkt->id); | |
| 255 | |
| 256 yahoo_packet_write(pkt, data + pos); | |
| 257 | |
| 258 yahoo_packet_dump(data, len); | |
| 259 ret = write(yd->fd, data, len); | |
| 9329 | 260 if (ret != len) |
| 261 gaim_debug_warning("yahoo", "Only wrote %d of %d bytes!", ret, len); | |
| 2681 | 262 g_free(data); |
| 263 | |
| 264 return ret; | |
| 265 } | |
| 266 | |
| 9306 | 267 int yahoo_send_packet_special(int fd, struct yahoo_packet *pkt, int pad) |
| 268 { | |
| 269 int pktlen = yahoo_packet_length(pkt); | |
| 270 int len = YAHOO_PACKET_HDRLEN + pktlen; | |
| 271 int ret; | |
| 272 | |
| 273 guchar *data; | |
| 274 int pos = 0; | |
| 275 | |
| 276 if (fd < 0) | |
| 277 return -1; | |
| 278 | |
| 279 data = g_malloc0(len + 1); | |
| 280 | |
| 281 memcpy(data + pos, "YMSG", 4); pos += 4; | |
| 282 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); | |
| 283 pos += yahoo_put16(data + pos, 0x0000); | |
| 284 pos += yahoo_put16(data + pos, pktlen + pad); | |
| 285 pos += yahoo_put16(data + pos, pkt->service); | |
| 286 pos += yahoo_put32(data + pos, pkt->status); | |
| 287 pos += yahoo_put32(data + pos, pkt->id); | |
| 288 | |
| 289 yahoo_packet_write(pkt, data + pos); | |
| 290 | |
| 291 ret = write(fd, data, len); | |
| 292 g_free(data); | |
| 293 | |
| 294 return ret; | |
| 295 } | |
| 296 | |
| 6729 | 297 void yahoo_packet_free(struct yahoo_packet *pkt) |
| 2681 | 298 { |
| 299 while (pkt->hash) { | |
| 300 struct yahoo_pair *pair = pkt->hash->data; | |
| 301 g_free(pair->value); | |
| 302 g_free(pair); | |
| 303 pkt->hash = g_slist_remove(pkt->hash, pair); | |
| 304 } | |
| 305 g_free(pkt); | |
| 306 } | |
| 307 | |
| 9278 | 308 static void yahoo_update_status(GaimConnection *gc, const char *name, YahooFriend *f) |
| 6784 | 309 { |
| 6840 | 310 int online = 1; |
| 311 | |
| 6784 | 312 if (!gc || !name || !f || !gaim_find_buddy(gaim_connection_get_account(gc), name)) |
| 313 return; | |
| 314 | |
| 6840 | 315 if (f->status == YAHOO_STATUS_OFFLINE) |
| 316 online = 0; | |
| 317 | |
| 318 serv_got_update(gc, name, online, 0, 0, f->idle, f->away ? UC_UNAVAILABLE : 0); | |
| 6784 | 319 } |
| 320 | |
| 5583 | 321 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 322 { |
| 323 struct yahoo_data *yd = gc->proto_data; | |
| 324 GSList *l = pkt->hash; | |
| 9278 | 325 YahooFriend *f = NULL; |
| 2681 | 326 char *name = NULL; |
| 6784 | 327 |
| 7892 | 328 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { |
| 8383 | 329 gc->wants_to_die = TRUE; |
| 7892 | 330 gaim_connection_error(gc, _("You have been logged off as you have logged in on a different machine or device.")); |
| 331 return; | |
| 332 } | |
| 6686 | 333 |
| 2681 | 334 while (l) { |
| 335 struct yahoo_pair *pair = l->data; | |
| 336 | |
| 337 switch (pair->key) { | |
| 338 case 0: /* we won't actually do anything with this */ | |
| 339 break; | |
| 340 case 1: /* we don't get the full buddy list here. */ | |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
341 if (!yd->logged_in) { |
| 7664 | 342 gaim_connection_set_display_name(gc, pair->value); |
| 5583 | 343 gaim_connection_set_state(gc, GAIM_CONNECTED); |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
344 serv_finish_login(gc); |
|
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
345 yd->logged_in = TRUE; |
| 9306 | 346 if (yd->picture_upload_todo) { |
| 347 yahoo_buddy_icon_upload(gc, yd->picture_upload_todo); | |
| 348 yd->picture_upload_todo = NULL; | |
| 349 } | |
| 2681 | 350 |
| 3147 | 351 /* this requests the list. i have a feeling that this is very evil |
| 352 * | |
| 6686 | 353 * scs.yahoo.com sends you the list before this packet without it being |
| 3147 | 354 * requested |
| 355 * | |
| 356 * do_import(gc, NULL); | |
| 357 * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); | |
| 358 * yahoo_send_packet(yd, newpkt); | |
| 359 * yahoo_packet_free(newpkt); | |
| 360 */ | |
| 361 | |
| 362 } | |
| 2681 | 363 break; |
| 364 case 8: /* how many online buddies we have */ | |
| 365 break; | |
| 366 case 7: /* the current buddy */ | |
| 367 name = pair->value; | |
| 9279 | 368 f = yahoo_friend_find_or_new(gc, name); |
| 2681 | 369 break; |
| 370 case 10: /* state */ | |
| 6784 | 371 if (!f) |
| 372 break; | |
| 373 | |
| 374 f->status = strtol(pair->value, NULL, 10); | |
| 375 if ((f->status >= YAHOO_STATUS_BRB) && (f->status <= YAHOO_STATUS_STEPPEDOUT)) | |
| 376 f->away = 1; | |
| 377 else | |
| 378 f->away = 0; | |
| 379 if (f->status == YAHOO_STATUS_IDLE) | |
| 380 f->idle = time(NULL); | |
| 6804 | 381 else |
| 382 f->idle = 0; | |
| 9283 | 383 if (f->status != YAHOO_STATUS_CUSTOM) |
| 384 yahoo_friend_set_status_message(f, NULL); | |
| 6847 | 385 |
| 386 f->sms = 0; | |
| 2681 | 387 break; |
| 388 case 19: /* custom message */ | |
| 9283 | 389 if (f) |
| 390 yahoo_friend_set_status_message(f, yahoo_string_decode(gc, pair->value, FALSE)); | |
| 2681 | 391 break; |
| 6686 | 392 case 11: /* this is the buddy's session id */ |
| 2681 | 393 break; |
| 394 case 17: /* in chat? */ | |
| 395 break; | |
| 6784 | 396 case 47: /* is custom status away or not? 2=idle*/ |
| 397 if (!f) | |
| 398 break; | |
| 8441 | 399 |
| 400 /* I have no idea what it means when this is | |
| 401 * set when someone's available, but it doesn't | |
| 402 * mean idle. */ | |
| 403 if (f->status == YAHOO_STATUS_AVAILABLE) | |
| 404 break; | |
| 6784 | 405 f->away = strtol(pair->value, NULL, 10); |
| 406 if (f->away == 2) | |
| 407 f->idle = time(NULL); | |
| 6686 | 408 break; |
| 6784 | 409 case 138: /* either we're not idle, or we are but won't say how long */ |
| 410 if (!f) | |
| 411 break; | |
| 412 | |
| 413 if (f->idle) | |
| 414 f->idle = -1; | |
| 415 break; | |
| 416 case 137: /* usually idle time in seconds, sometimes login time */ | |
| 417 if (!f) | |
| 418 break; | |
| 419 | |
| 420 if (f->status != YAHOO_STATUS_AVAILABLE) | |
| 421 f->idle = time(NULL) - strtol(pair->value, NULL, 10); | |
| 6686 | 422 break; |
| 423 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ | |
| 6784 | 424 if (strtol(pair->value, NULL, 10) == 0) { |
| 425 if (f) | |
| 426 f->status = YAHOO_STATUS_OFFLINE; | |
| 4732 | 427 serv_got_update(gc, name, 0, 0, 0, 0, 0); |
|
2807
f01e6a425136
[gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2805
diff
changeset
|
428 break; |
|
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
429 } |
| 6784 | 430 |
| 431 if (f) | |
| 432 yahoo_update_status(gc, name, f); | |
| 433 break; | |
| 434 case 60: /* SMS */ | |
| 435 if (f) { | |
| 436 f->sms = strtol(pair->value, NULL, 10); | |
| 437 yahoo_update_status(gc, name, f); | |
|
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
438 } |
|
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
439 break; |
| 9292 | 440 case 197: /* Avatars */ |
| 9277 | 441 { |
| 442 char *decoded, *tmp; | |
| 443 guint len; | |
| 444 | |
| 445 if (pair->value) { | |
| 446 gaim_base64_decode(pair->value, &decoded, &len); | |
| 447 if (len) { | |
| 448 tmp = gaim_str_binary_to_ascii(decoded, len); | |
| 449 gaim_debug_info("yahoo", "Got key 197, value = %s\n", tmp); | |
| 450 g_free(tmp); | |
| 451 } | |
| 452 g_free(decoded); | |
| 453 } | |
| 454 break; | |
| 455 } | |
| 9292 | 456 case 192: /* Pictures, aka Buddy Icons, checksum */ |
| 457 { | |
| 458 int cksum = strtol(pair->value, NULL, 10); | |
| 459 GaimBuddy *b; | |
| 460 | |
| 461 if (!name) | |
| 462 break; | |
| 463 | |
| 9325 | 464 b = gaim_find_buddy(gc->account, name); |
| 465 | |
| 9292 | 466 if (!cksum || (cksum == -1)) { |
| 9325 | 467 if (f) |
| 468 yahoo_friend_set_buddy_icon_need_request(f, TRUE); | |
| 9292 | 469 gaim_buddy_icons_set_for_user(gc->account, name, NULL, 0); |
| 9325 | 470 if (b) |
| 471 gaim_blist_node_remove_setting((GaimBlistNode *)b, YAHOO_ICON_CHECKSUM_KEY); | |
| 9292 | 472 break; |
| 473 } | |
| 474 | |
| 475 if (!f) | |
| 476 break; | |
| 9325 | 477 |
| 9292 | 478 yahoo_friend_set_buddy_icon_need_request(f, FALSE); |
| 479 if (cksum != gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY)) | |
| 9310 | 480 yahoo_send_picture_request(gc, name); |
| 9292 | 481 |
| 482 break; | |
| 483 } | |
| 2979 | 484 case 16: /* Custom error message */ |
| 7827 | 485 { |
| 486 char *tmp = yahoo_string_decode(gc, pair->value, TRUE); | |
| 487 gaim_notify_error(gc, NULL, tmp, NULL); | |
| 488 g_free(tmp); | |
| 489 } | |
| 2951 | 490 break; |
| 2681 | 491 default: |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
492 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
493 "Unknown status key %d\n", pair->key); |
| 2681 | 494 break; |
| 495 } | |
| 496 | |
| 497 l = l->next; | |
| 498 } | |
| 499 } | |
| 500 | |
| 9285 | 501 static void yahoo_do_group_check(GaimAccount *account, GHashTable *ht, const char *name, const char *group) |
| 6820 | 502 { |
| 503 GaimBuddy *b; | |
| 504 GaimGroup *g; | |
| 505 GSList *list, *i; | |
| 506 gboolean onlist = 0; | |
| 507 char *oname = NULL; | |
| 508 | |
| 9015 | 509 char **oname_p = &oname; |
| 510 GSList **list_p = &list; | |
| 511 | |
| 512 if (!g_hash_table_lookup_extended(ht, gaim_normalize(account, name), (gpointer *) oname_p, (gpointer *) list_p)) | |
| 6820 | 513 list = gaim_find_buddies(account, name); |
| 514 else | |
| 515 g_hash_table_steal(ht, name); | |
| 516 | |
| 517 for (i = list; i; i = i->next) { | |
| 518 b = i->data; | |
| 519 g = gaim_find_buddys_group(b); | |
| 520 if (!gaim_utf8_strcasecmp(group, g->name)) { | |
| 521 gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
| 522 "Oh good, %s is in the right group (%s).\n", name, group); | |
| 523 list = g_slist_delete_link(list, i); | |
| 524 onlist = 1; | |
| 525 break; | |
| 526 } | |
| 527 } | |
| 528 | |
| 529 if (!onlist) { | |
| 530 gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
| 531 "Uhoh, %s isn't on the list (or not in this group), adding him to group %s.\n", name, group); | |
| 532 if (!(g = gaim_find_group(group))) { | |
| 533 g = gaim_group_new(group); | |
| 534 gaim_blist_add_group(g, NULL); | |
| 535 } | |
| 536 b = gaim_buddy_new(account, name, NULL); | |
| 537 gaim_blist_add_buddy(b, NULL, g, NULL); | |
| 538 } | |
| 539 | |
| 540 if (list) { | |
| 541 if (!oname) | |
| 7823 | 542 oname = g_strdup(gaim_normalize(account, name)); |
| 6820 | 543 g_hash_table_insert(ht, oname, list); |
| 544 } else if (oname) | |
| 545 g_free(oname); | |
| 546 } | |
| 547 | |
| 548 static void yahoo_do_group_cleanup(gpointer key, gpointer value, gpointer user_data) | |
| 549 { | |
| 550 char *name = key; | |
| 551 GSList *list = value, *i; | |
| 552 GaimBuddy *b; | |
| 553 GaimGroup *g; | |
| 554 | |
| 555 for (i = list; i; i = i->next) { | |
| 556 b = i->data; | |
| 557 g = gaim_find_buddys_group(b); | |
| 558 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, g->name); | |
| 559 gaim_blist_remove_buddy(b); | |
| 560 } | |
| 561 } | |
| 562 | |
| 7651 | 563 static char *_getcookie(char *rawcookie) |
| 564 { | |
| 565 char *cookie = NULL; | |
| 566 char *tmpcookie; | |
| 567 char *cookieend; | |
| 568 | |
| 569 if (strlen(rawcookie) < 2) | |
| 570 return NULL; | |
| 571 tmpcookie = g_strdup(rawcookie+2); | |
| 572 cookieend = strchr(tmpcookie, ';'); | |
| 573 | |
| 574 if (cookieend) | |
| 575 *cookieend = '\0'; | |
| 576 | |
| 577 cookie = g_strdup(tmpcookie); | |
| 578 g_free(tmpcookie); | |
| 579 | |
| 580 return cookie; | |
| 581 } | |
| 582 | |
| 583 static void yahoo_process_cookie(struct yahoo_data *yd, char *c) | |
| 584 { | |
| 585 if (c[0] == 'Y') { | |
| 586 if (yd->cookie_y) | |
| 587 g_free(yd->cookie_y); | |
| 588 yd->cookie_y = _getcookie(c); | |
| 589 } else if (c[0] == 'T') { | |
| 590 if (yd->cookie_t) | |
| 591 g_free(yd->cookie_t); | |
| 592 yd->cookie_t = _getcookie(c); | |
| 593 } | |
| 594 } | |
| 595 | |
| 5583 | 596 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 597 { |
| 598 GSList *l = pkt->hash; | |
| 599 gboolean export = FALSE; | |
| 6760 | 600 gboolean got_serv_list = FALSE; |
| 6695 | 601 GaimBuddy *b; |
| 602 GaimGroup *g; | |
| 9278 | 603 YahooFriend *f = NULL; |
| 6820 | 604 GaimAccount *account = gaim_connection_get_account(gc); |
| 6784 | 605 struct yahoo_data *yd = gc->proto_data; |
| 6820 | 606 GHashTable *ht; |
| 6784 | 607 |
| 608 char **lines; | |
| 609 char **split; | |
| 610 char **buddies; | |
| 7823 | 611 char **tmp, **bud, *norm_bud; |
| 7827 | 612 char *grp = NULL; |
| 2681 | 613 |
| 7651 | 614 if (pkt->id) |
| 615 yd->session_id = pkt->id; | |
| 616 | |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
617 while (l) { |
|
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
618 struct yahoo_pair *pair = l->data; |
|
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
619 l = l->next; |
|
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
620 |
| 6760 | 621 switch (pair->key) { |
| 622 case 87: | |
| 6784 | 623 if (!yd->tmp_serv_blist) |
| 624 yd->tmp_serv_blist = g_string_new(pair->value); | |
| 625 else | |
| 626 g_string_append(yd->tmp_serv_blist, pair->value); | |
| 6760 | 627 break; |
| 628 case 88: | |
| 6784 | 629 if (!yd->tmp_serv_ilist) |
| 630 yd->tmp_serv_ilist = g_string_new(pair->value); | |
| 631 else | |
| 632 g_string_append(yd->tmp_serv_ilist, pair->value); | |
| 6760 | 633 break; |
| 7651 | 634 case 59: /* cookies, yum */ |
| 635 yahoo_process_cookie(yd, pair->value); | |
| 636 break; | |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
637 } |
|
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
638 } |
| 2681 | 639 |
| 6784 | 640 if (pkt->status != 0) |
| 641 return; | |
| 642 | |
| 643 if (yd->tmp_serv_blist) { | |
| 6820 | 644 ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free); |
| 645 | |
| 6784 | 646 lines = g_strsplit(yd->tmp_serv_blist->str, "\n", -1); |
| 647 for (tmp = lines; *tmp; tmp++) { | |
| 648 split = g_strsplit(*tmp, ":", 2); | |
| 649 if (!split) | |
| 650 continue; | |
| 651 if (!split[0] || !split[1]) { | |
| 652 g_strfreev(split); | |
| 653 continue; | |
| 654 } | |
| 7827 | 655 grp = yahoo_string_decode(gc, split[0], FALSE); |
| 6784 | 656 buddies = g_strsplit(split[1], ",", -1); |
| 657 for (bud = buddies; bud && *bud; bud++) { | |
| 7823 | 658 norm_bud = g_strdup(gaim_normalize(account, *bud)); |
| 9279 | 659 f = yahoo_friend_find_or_new(gc, norm_bud); |
| 660 | |
| 7827 | 661 if (!(b = gaim_find_buddy(account, norm_bud))) { |
| 662 if (!(g = gaim_find_group(grp))) { | |
| 663 g = gaim_group_new(grp); | |
| 6784 | 664 gaim_blist_add_group(g, NULL); |
| 665 } | |
| 7823 | 666 b = gaim_buddy_new(account, norm_bud, NULL); |
| 6784 | 667 gaim_blist_add_buddy(b, NULL, g, NULL); |
| 668 export = TRUE; | |
| 6820 | 669 } |
| 6784 | 670 |
| 9285 | 671 yahoo_do_group_check(account, ht, norm_bud, grp); |
| 7823 | 672 g_free(norm_bud); |
| 6784 | 673 } |
| 674 g_strfreev(buddies); | |
| 675 g_strfreev(split); | |
| 7827 | 676 g_free(grp); |
| 6784 | 677 } |
| 678 g_strfreev(lines); | |
| 679 | |
| 680 g_string_free(yd->tmp_serv_blist, TRUE); | |
| 681 yd->tmp_serv_blist = NULL; | |
| 9285 | 682 g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); |
| 6820 | 683 g_hash_table_destroy(ht); |
| 6784 | 684 } |
| 685 | |
| 686 | |
| 687 if (yd->tmp_serv_ilist) { | |
| 688 buddies = g_strsplit(yd->tmp_serv_ilist->str, ",", -1); | |
| 689 for (bud = buddies; bud && *bud; bud++) { | |
| 690 /* The server is already ignoring the user */ | |
| 691 got_serv_list = TRUE; | |
| 692 gaim_privacy_deny_add(gc->account, *bud, 1); | |
| 693 } | |
| 694 g_strfreev(buddies); | |
| 695 | |
| 696 g_string_free(yd->tmp_serv_ilist, TRUE); | |
| 697 yd->tmp_serv_ilist = NULL; | |
| 698 } | |
| 699 | |
| 700 if (got_serv_list) { | |
| 701 gc->account->perm_deny = 4; | |
| 702 serv_set_permit_deny(gc); | |
| 703 } | |
| 2681 | 704 } |
| 705 | |
| 5583 | 706 static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2993 | 707 { |
| 708 char *msg = NULL; | |
| 709 char *from = NULL; | |
| 3019 | 710 char *stat = NULL; |
| 711 char *game = NULL; | |
| 9278 | 712 YahooFriend *f = NULL; |
| 2993 | 713 GSList *l = pkt->hash; |
| 6784 | 714 |
| 2993 | 715 while (l) { |
| 716 struct yahoo_pair *pair = l->data; | |
| 717 if (pair->key == 4) | |
| 718 from = pair->value; | |
| 719 if (pair->key == 49) | |
| 720 msg = pair->value; | |
| 3001 | 721 if (pair->key == 13) |
| 3019 | 722 stat = pair->value; |
| 723 if (pair->key == 14) | |
| 724 game = pair->value; | |
| 2993 | 725 l = l->next; |
| 726 } | |
| 3640 | 727 |
| 6784 | 728 if (!from || !msg) |
| 3640 | 729 return; |
| 6686 | 730 |
| 4793 | 731 if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) { |
| 3019 | 732 if (*stat == '1') |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
733 serv_got_typing(gc, from, 0, GAIM_TYPING); |
| 3019 | 734 else |
| 735 serv_got_typing_stopped(gc, from); | |
| 4793 | 736 } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) { |
| 6695 | 737 GaimBuddy *bud = gaim_find_buddy(gc->account, from); |
| 6784 | 738 |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
739 if (!bud) { |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
740 gaim_debug(GAIM_DEBUG_WARNING, "yahoo", |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
741 "%s is playing a game, and doesn't want " |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
742 "you to know.\n", from); |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
743 } |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
744 |
| 9279 | 745 f = yahoo_friend_find(gc, from); |
| 6784 | 746 if (!f) |
| 747 return; /* if they're not on the list, don't bother */ | |
| 748 | |
| 9283 | 749 yahoo_friend_set_game(f, NULL); |
| 6784 | 750 |
| 3019 | 751 if (*stat == '1') { |
| 9283 | 752 yahoo_friend_set_game(f, game); |
| 3020 | 753 if (bud) |
| 6784 | 754 yahoo_update_status(gc, from, f); |
| 3019 | 755 } |
| 756 } | |
| 2993 | 757 } |
| 758 | |
| 7827 | 759 |
| 760 struct _yahoo_im { | |
| 761 char *from; | |
| 762 int time; | |
| 763 int utf8; | |
| 9284 | 764 int buddy_icon; |
| 7827 | 765 char *msg; |
| 766 }; | |
| 767 | |
| 5583 | 768 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 769 { |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
770 GSList *l = pkt->hash; |
| 7827 | 771 GSList *list = NULL; |
| 772 struct _yahoo_im *im = NULL; | |
| 6069 | 773 |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
774 if (pkt->status <= 1 || pkt->status == 5) { |
|
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
775 while (l) { |
|
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
776 struct yahoo_pair *pair = l->data; |
| 7827 | 777 if (pair->key == 4) { |
| 778 im = g_new0(struct _yahoo_im, 1); | |
| 779 list = g_slist_append(list, im); | |
| 780 im->from = pair->value; | |
| 781 im->time = time(NULL); | |
| 782 } | |
| 783 if (pair->key == 97) | |
| 784 if (im) | |
| 785 im->utf8 = strtol(pair->value, NULL, 10); | |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
786 if (pair->key == 15) |
| 7827 | 787 if (im) |
| 788 im->time = strtol(pair->value, NULL, 10); | |
| 9284 | 789 if (pair->key == 206) |
| 790 if (im) | |
| 791 im->buddy_icon = strtol(pair->value, NULL, 10); | |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
792 if (pair->key == 14) { |
| 7827 | 793 if (im) |
| 794 im->msg = pair->value; | |
| 6687 | 795 } |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
796 l = l->next; |
| 6687 | 797 } |
| 2681 | 798 } else if (pkt->status == 2) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
799 gaim_notify_error(gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
800 _("Your Yahoo! message did not get sent."), NULL); |
| 2681 | 801 } |
| 7827 | 802 |
| 803 for (l = list; l; l = l->next) { | |
| 9306 | 804 YahooFriend *f; |
| 7827 | 805 char *m, *m2; |
| 806 im = l->data; | |
| 807 | |
| 808 if (!im->from || !im->msg) { | |
| 809 g_free(im); | |
| 810 continue; | |
| 811 } | |
| 812 | |
| 813 m = yahoo_string_decode(gc, im->msg, im->utf8); | |
| 814 gaim_str_strip_cr(m); | |
| 8375 | 815 |
| 816 if (!strcmp(m, "<ding>")) { | |
| 817 GaimConversation *c = gaim_conversation_new(GAIM_CONV_IM, | |
| 818 gaim_connection_get_account(gc), im->from); | |
| 819 gaim_conv_im_write(GAIM_CONV_IM(c), "", _("Buzz!!"), GAIM_MESSAGE_NICK|GAIM_MESSAGE_RECV, | |
| 820 im->time); | |
| 821 g_free(m); | |
| 822 g_free(im); | |
| 823 continue; | |
| 824 } | |
| 825 | |
| 7827 | 826 m2 = yahoo_codes_to_html(m); |
| 827 g_free(m); | |
| 828 serv_got_im(gc, im->from, m2, 0, im->time); | |
| 829 g_free(m2); | |
| 9284 | 830 |
| 831 if ((f = yahoo_friend_find(gc, im->from)) && im->buddy_icon == 2) { | |
| 832 if (yahoo_friend_get_buddy_icon_need_request(f)) { | |
| 9310 | 833 yahoo_send_picture_request(gc, im->from); |
| 9284 | 834 yahoo_friend_set_buddy_icon_need_request(f, FALSE); |
| 835 } | |
| 836 } | |
| 837 | |
| 7827 | 838 g_free(im); |
| 839 } | |
| 840 g_slist_free(list); | |
| 2681 | 841 } |
| 842 | |
| 7865 | 843 static void yahoo_process_sysmessage(GaimConnection *gc, struct yahoo_packet *pkt) |
| 844 { | |
| 845 GSList *l = pkt->hash; | |
| 846 char *prim, *me = NULL, *msg = NULL; | |
| 847 | |
| 848 while (l) { | |
| 849 struct yahoo_pair *pair = l->data; | |
| 850 | |
| 851 if (pair->key == 5) | |
| 852 me = pair->value; | |
| 853 if (pair->key == 14) | |
| 854 msg = pair->value; | |
| 855 | |
| 856 l = l->next; | |
| 857 } | |
| 858 | |
| 859 if (!msg) | |
| 860 return; | |
| 861 | |
| 862 prim = g_strdup_printf(_("Yahoo! system message for %s:"), | |
| 863 me?me:gaim_connection_get_display_name(gc)); | |
| 864 gaim_notify_info(NULL, NULL, prim, msg); | |
| 865 g_free(prim); | |
| 866 } | |
| 867 | |
| 6686 | 868 static void yahoo_buddy_added_us(GaimConnection *gc, struct yahoo_packet *pkt) { |
| 2681 | 869 char *id = NULL; |
| 870 char *who = NULL; | |
| 7827 | 871 char *msg = NULL, *tmpmsg = NULL; |
| 2681 | 872 GSList *l = pkt->hash; |
| 873 | |
| 874 while (l) { | |
| 875 struct yahoo_pair *pair = l->data; | |
| 6686 | 876 |
| 877 switch (pair->key) { | |
| 878 case 1: | |
| 2681 | 879 id = pair->value; |
| 6686 | 880 break; |
| 881 case 3: | |
| 2681 | 882 who = pair->value; |
| 6686 | 883 break; |
| 884 case 15: /* time, for when they add us and we're offline */ | |
| 885 break; | |
| 886 case 14: | |
| 2681 | 887 msg = pair->value; |
| 6686 | 888 break; |
| 889 } | |
| 2681 | 890 l = l->next; |
| 891 } | |
| 892 | |
| 7827 | 893 if (id) { |
| 894 if (msg) | |
| 895 tmpmsg = yahoo_string_decode(gc, msg, FALSE); | |
| 896 gaim_account_notify_added(gc->account, id, who, NULL, tmpmsg); | |
| 897 if (tmpmsg) | |
| 898 g_free(tmpmsg); | |
| 899 } | |
| 6686 | 900 } |
| 901 | |
| 902 static void yahoo_buddy_denied_our_add(GaimConnection *gc, struct yahoo_packet *pkt) | |
| 903 { | |
| 904 char *who = NULL; | |
| 905 char *msg = NULL; | |
| 906 GSList *l = pkt->hash; | |
| 907 GString *buf = NULL; | |
| 6784 | 908 struct yahoo_data *yd = gc->proto_data; |
| 6686 | 909 |
| 910 while (l) { | |
| 911 struct yahoo_pair *pair = l->data; | |
| 912 | |
| 913 switch (pair->key) { | |
| 914 case 3: | |
| 915 who = pair->value; | |
| 916 break; | |
| 917 case 14: | |
| 918 msg = pair->value; | |
| 919 break; | |
| 920 } | |
| 921 l = l->next; | |
| 922 } | |
| 923 | |
| 924 if (who) { | |
| 7827 | 925 char *msg2; |
| 6686 | 926 buf = g_string_sized_new(0); |
| 7827 | 927 if (!msg) { |
| 6686 | 928 g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list."), who); |
| 7827 | 929 } else { |
| 930 msg2 = yahoo_string_decode(gc, msg, FALSE); | |
| 931 g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg2); | |
| 932 g_free(msg2); | |
| 933 } | |
| 6840 | 934 gaim_notify_info(gc, NULL, _("Add buddy rejected"), buf->str); |
| 6686 | 935 g_string_free(buf, TRUE); |
| 6784 | 936 g_hash_table_remove(yd->friends, who); |
| 937 serv_got_update(gc, who, 0, 0, 0, 0, 0); | |
| 6686 | 938 } |
| 939 } | |
| 940 | |
| 941 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt) | |
| 942 { | |
| 943 | |
| 944 | |
| 945 switch (pkt->status) { | |
| 946 case 1: | |
| 947 yahoo_process_status(gc, pkt); | |
| 948 return; | |
| 949 case 3: | |
| 950 yahoo_buddy_added_us(gc, pkt); | |
| 951 break; | |
| 952 case 7: | |
| 953 yahoo_buddy_denied_our_add(gc, pkt); | |
| 954 break; | |
| 955 default: | |
| 956 break; | |
|
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
957 } |
| 2681 | 958 } |
| 959 | |
| 7747 | 960 #define OUT_CHARSET "utf-8" |
| 961 | |
| 962 static char *yahoo_decode(const char *text) | |
| 963 { | |
| 9221 | 964 char *converted = NULL; |
| 8125 | 965 char *n, *new; |
| 966 const char *end, *p; | |
| 8616 | 967 int i, k; |
| 8125 | 968 |
| 7771 | 969 n = new = g_malloc(strlen (text) + 1); |
| 8118 | 970 end = text + strlen(text); |
| 971 | |
| 8125 | 972 for (p = text; p < end; p++, n++) { |
| 7747 | 973 if (*p == '\\') { |
| 9064 | 974 if (p[1] >= '0' && p[1] <= '7') { |
| 975 p += 1; | |
| 976 for (i = 0, k = 0; k < 3; k += 1) { | |
| 977 char c = p[k]; | |
| 9065 | 978 if (c < '0' || c > '7') break; |
| 9064 | 979 i *= 8; |
| 980 i += c - '0'; | |
| 981 } | |
| 982 *n = i; | |
| 983 p += k - 1; | |
| 984 } else { /* bug 959248 */ | |
| 985 /* If we see a \ not followed by an octal number, | |
| 986 * it means that it is actually a \\ with one \ | |
| 987 * already eaten by some unknown function. | |
| 988 * This is arguably broken. | |
| 989 * | |
| 990 * I think wing is wrong here, there is no function | |
| 991 * called that I see that could have done it. I guess | |
| 992 * it is just really sending single \'s. That's yahoo | |
| 993 * for you. | |
| 994 */ | |
| 995 *n = *p; | |
| 996 } | |
| 7747 | 997 } |
| 998 else | |
| 999 *n = *p; | |
| 1000 } | |
| 1001 | |
| 1002 *n = '\0'; | |
| 8125 | 1003 |
| 9221 | 1004 if (strstr(text, "\033$B")) |
| 1005 converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL); | |
| 1006 if (!converted) | |
| 1007 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL); | |
| 7747 | 1008 g_free(new); |
| 1009 | |
| 1010 return converted; | |
| 1011 } | |
| 1012 | |
| 5583 | 1013 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 1014 { |
| 5583 | 1015 GaimAccount *account = gaim_connection_get_account(gc); |
| 9221 | 1016 struct yahoo_data *yd = gc->proto_data; |
| 2681 | 1017 char *who = NULL; |
| 1018 char *email = NULL; | |
| 1019 char *subj = NULL; | |
| 9221 | 1020 char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); |
| 2681 | 1021 int count = 0; |
| 1022 GSList *l = pkt->hash; | |
| 1023 | |
| 5583 | 1024 if (!gaim_account_get_check_mail(account)) |
|
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1025 return; |
|
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1026 |
| 2681 | 1027 while (l) { |
| 1028 struct yahoo_pair *pair = l->data; | |
| 1029 if (pair->key == 9) | |
| 1030 count = strtol(pair->value, NULL, 10); | |
| 1031 else if (pair->key == 43) | |
| 1032 who = pair->value; | |
| 1033 else if (pair->key == 42) | |
| 1034 email = pair->value; | |
| 1035 else if (pair->key == 18) | |
| 1036 subj = pair->value; | |
| 1037 l = l->next; | |
| 1038 } | |
| 1039 | |
| 4001 | 1040 if (who && subj && email && *email) { |
| 7747 | 1041 char *dec_who = yahoo_decode(who); |
| 1042 char *dec_subj = yahoo_decode(subj); | |
| 1043 char *from = g_strdup_printf("%s (%s)", dec_who, email); | |
| 1044 | |
| 1045 gaim_notify_email(gc, dec_subj, from, gaim_account_get_username(account), | |
| 9221 | 1046 yahoo_mail_url, NULL, NULL); |
|
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1047 |
| 7747 | 1048 g_free(dec_who); |
| 1049 g_free(dec_subj); | |
|
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
1050 g_free(from); |
|
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1051 } else if (count > 0) { |
| 5583 | 1052 const char *to = gaim_account_get_username(account); |
| 9221 | 1053 const char *url = yahoo_mail_url; |
|
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1054 |
|
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1055 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, |
|
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1056 NULL, NULL); |
|
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
1057 } |
| 2681 | 1058 } |
| 3147 | 1059 /* This is the y64 alphabet... it's like base64, but has a . and a _ */ |
| 1060 char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; | |
| 1061 | |
| 1062 /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function | |
| 1063 * in util.c, but it has a bug I don't feel like finding right now ;) */ | |
| 1064 void to_y64(unsigned char *out, const unsigned char *in, int inlen) | |
| 1065 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ | |
| 1066 { | |
| 1067 for (; inlen >= 3; inlen -= 3) | |
| 1068 { | |
| 1069 *out++ = base64digits[in[0] >> 2]; | |
| 1070 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | |
| 1071 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; | |
| 1072 *out++ = base64digits[in[2] & 0x3f]; | |
| 1073 in += 3; | |
| 1074 } | |
| 1075 if (inlen > 0) | |
| 1076 { | |
| 1077 unsigned char fragment; | |
| 1078 | |
| 1079 *out++ = base64digits[in[0] >> 2]; | |
| 1080 fragment = (in[0] << 4) & 0x30; | |
| 1081 if (inlen > 1) | |
| 1082 fragment |= in[1] >> 4; | |
| 1083 *out++ = base64digits[fragment]; | |
| 1084 *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c]; | |
| 1085 *out++ = '-'; | |
| 1086 } | |
| 1087 *out = '\0'; | |
| 1088 } | |
| 1089 | |
| 6986 | 1090 static void yahoo_process_auth_old(GaimConnection *gc, const char *seed) |
| 1091 { | |
| 1092 struct yahoo_packet *pack; | |
| 1093 GaimAccount *account = gaim_connection_get_account(gc); | |
| 7261 | 1094 const char *name = gaim_normalize(account, gaim_account_get_username(account)); |
| 6986 | 1095 const char *pass = gaim_account_get_password(account); |
| 1096 struct yahoo_data *yd = gc->proto_data; | |
| 1097 | |
| 1098 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly | |
| 1099 * will soon do so in the rest of the world. | |
| 1100 * | |
| 1101 * The new clients use this authentication method. I warn you in advance, it's | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1102 * bizarre, convoluted, inordinately complicated. It's also no more secure than |
| 6986 | 1103 * crypt() was. The only purpose this scheme could serve is to prevent third |
| 1104 * part clients from connecting to their servers. | |
| 1105 * | |
| 1106 * Sorry, Yahoo. | |
| 1107 */ | |
| 9277 | 1108 |
| 6986 | 1109 md5_byte_t result[16]; |
| 1110 md5_state_t ctx; | |
| 9277 | 1111 |
| 6986 | 1112 char *crypt_result; |
| 1113 char password_hash[25]; | |
| 1114 char crypt_hash[25]; | |
| 1115 char *hash_string_p = g_malloc(50 + strlen(name)); | |
| 1116 char *hash_string_c = g_malloc(50 + strlen(name)); | |
| 9277 | 1117 |
| 6986 | 1118 char checksum; |
| 9277 | 1119 |
| 6986 | 1120 int sv; |
| 9277 | 1121 |
| 6986 | 1122 char result6[25]; |
| 1123 char result96[25]; | |
| 1124 | |
| 1125 sv = seed[15]; | |
| 1126 sv = sv % 8; | |
| 1127 | |
| 1128 md5_init(&ctx); | |
| 1129 md5_append(&ctx, pass, strlen(pass)); | |
| 1130 md5_finish(&ctx, result); | |
| 1131 to_y64(password_hash, result, 16); | |
| 9277 | 1132 |
| 6986 | 1133 md5_init(&ctx); |
| 9277 | 1134 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
| 6986 | 1135 md5_append(&ctx, crypt_result, strlen(crypt_result)); |
| 1136 md5_finish(&ctx, result); | |
| 1137 to_y64(crypt_hash, result, 16); | |
| 1138 | |
| 1139 switch (sv) { | |
| 1140 case 1: | |
| 1141 case 6: | |
| 1142 checksum = seed[seed[9] % 16]; | |
| 1143 g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1144 "%c%s%s%s", checksum, name, seed, password_hash); | |
| 1145 g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1146 "%c%s%s%s", checksum, name, seed, crypt_hash); | |
| 1147 break; | |
| 1148 case 2: | |
| 1149 case 7: | |
| 1150 checksum = seed[seed[15] % 16]; | |
| 1151 g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1152 "%c%s%s%s", checksum, seed, password_hash, name); | |
| 1153 g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1154 "%c%s%s%s", checksum, seed, crypt_hash, name); | |
| 1155 break; | |
| 1156 case 3: | |
| 1157 checksum = seed[seed[1] % 16]; | |
| 1158 g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1159 "%c%s%s%s", checksum, name, password_hash, seed); | |
| 1160 g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1161 "%c%s%s%s", checksum, name, crypt_hash, seed); | |
| 1162 break; | |
| 1163 case 4: | |
| 1164 checksum = seed[seed[3] % 16]; | |
| 1165 g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1166 "%c%s%s%s", checksum, password_hash, seed, name); | |
| 1167 g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1168 "%c%s%s%s", checksum, crypt_hash, seed, name); | |
| 1169 break; | |
| 1170 case 0: | |
| 1171 case 5: | |
| 1172 checksum = seed[seed[7] % 16]; | |
| 1173 g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1174 "%c%s%s%s", checksum, password_hash, name, seed); | |
| 1175 g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1176 "%c%s%s%s", checksum, crypt_hash, name, seed); | |
| 1177 break; | |
| 1178 } | |
| 9277 | 1179 |
| 1180 md5_init(&ctx); | |
| 6986 | 1181 md5_append(&ctx, hash_string_p, strlen(hash_string_p)); |
| 1182 md5_finish(&ctx, result); | |
| 1183 to_y64(result6, result, 16); | |
| 9277 | 1184 |
| 1185 md5_init(&ctx); | |
| 6986 | 1186 md5_append(&ctx, hash_string_c, strlen(hash_string_c)); |
| 1187 md5_finish(&ctx, result); | |
| 1188 to_y64(result96, result, 16); | |
| 1189 | |
| 1190 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | |
| 1191 yahoo_packet_hash(pack, 0, name); | |
| 1192 yahoo_packet_hash(pack, 6, result6); | |
| 1193 yahoo_packet_hash(pack, 96, result96); | |
| 1194 yahoo_packet_hash(pack, 1, name); | |
| 9277 | 1195 |
| 6986 | 1196 yahoo_send_packet(yd, pack); |
| 9277 | 1197 |
| 6986 | 1198 g_free(hash_string_p); |
| 1199 g_free(hash_string_c); | |
| 9277 | 1200 |
| 6986 | 1201 yahoo_packet_free(pack); |
| 9277 | 1202 |
| 6986 | 1203 } |
| 1204 | |
| 6998 | 1205 /* I'm dishing out some uber-mad props to Cerulean Studios for cracking this |
| 1206 * and sending the fix! Thanks guys. */ | |
| 1207 | |
| 6986 | 1208 static void yahoo_process_auth_new(GaimConnection *gc, const char *seed) |
| 1209 { | |
| 1210 struct yahoo_packet *pack = NULL; | |
| 1211 GaimAccount *account = gaim_connection_get_account(gc); | |
| 7261 | 1212 const char *name = gaim_normalize(account, gaim_account_get_username(account)); |
| 6986 | 1213 const char *pass = gaim_account_get_password(account); |
| 1214 struct yahoo_data *yd = gc->proto_data; | |
| 9277 | 1215 |
| 8349 | 1216 md5_byte_t result[16]; |
| 1217 md5_state_t ctx; | |
| 9277 | 1218 |
| 8349 | 1219 SHA_CTX ctx1; |
| 1220 SHA_CTX ctx2; | |
| 9277 | 1221 |
| 8349 | 1222 char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; |
| 1223 char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop"; | |
| 1224 | |
| 1225 char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5"; | |
| 1226 char *operand_lookup = "+|&%/*^-"; | |
| 1227 char *delimit_lookup = ",;"; | |
| 1228 | |
| 1229 char *password_hash = (char *)g_malloc(25); | |
| 1230 char *crypt_hash = (char *)g_malloc(25); | |
| 1231 char *crypt_result = NULL; | |
| 1232 | |
| 1233 char pass_hash_xor1[64]; | |
| 1234 char pass_hash_xor2[64]; | |
| 1235 char crypt_hash_xor1[64]; | |
| 1236 char crypt_hash_xor2[64]; | |
| 1237 char resp_6[100]; | |
| 1238 char resp_96[100]; | |
| 1239 | |
| 1240 unsigned char digest1[20]; | |
| 1241 unsigned char digest2[20]; | |
| 1242 unsigned char comparison_src[20]; | |
| 1243 unsigned char magic_key_char[4]; | |
| 8375 | 1244 const unsigned char *magic_ptr; |
| 8349 | 1245 |
| 1246 unsigned int magic[64]; | |
| 1247 unsigned int magic_work = 0; | |
| 1248 unsigned int magic_4 = 0; | |
| 1249 | |
| 1250 int x; | |
| 1251 int y; | |
| 1252 int cnt = 0; | |
| 1253 int magic_cnt = 0; | |
| 1254 int magic_len; | |
| 1255 | |
| 1256 memset(password_hash, 0, 25); | |
| 1257 memset(crypt_hash, 0, 25); | |
| 6986 | 1258 memset(&pass_hash_xor1, 0, 64); |
| 1259 memset(&pass_hash_xor2, 0, 64); | |
| 1260 memset(&crypt_hash_xor1, 0, 64); | |
| 1261 memset(&crypt_hash_xor2, 0, 64); | |
| 1262 memset(&digest1, 0, 20); | |
| 1263 memset(&digest2, 0, 20); | |
| 1264 memset(&magic, 0, 64); | |
| 1265 memset(&resp_6, 0, 100); | |
| 1266 memset(&resp_96, 0, 100); | |
| 1267 memset(&magic_key_char, 0, 4); | |
| 8349 | 1268 memset(&comparison_src, 0, 20); |
| 6986 | 1269 |
| 1270 /* | |
| 8349 | 1271 * Magic: Phase 1. Generate what seems to be a 30 byte value (could change if base64 |
| 1272 * ends up differently? I don't remember and I'm tired, so use a 64 byte buffer. | |
| 6986 | 1273 */ |
| 9277 | 1274 |
| 6986 | 1275 magic_ptr = seed; |
| 8375 | 1276 |
| 6986 | 1277 while (*magic_ptr != (int)NULL) { |
| 8349 | 1278 char *loc; |
| 6986 | 1279 |
| 8349 | 1280 /* Ignore parentheses. |
| 1281 */ | |
| 6986 | 1282 |
| 1283 if (*magic_ptr == '(' || *magic_ptr == ')') { | |
| 1284 magic_ptr++; | |
| 1285 continue; | |
| 1286 } | |
| 1287 | |
| 8349 | 1288 /* Characters and digits verify against the challenge lookup. |
| 1289 */ | |
| 6986 | 1290 |
| 1291 if (isalpha(*magic_ptr) || isdigit(*magic_ptr)) { | |
| 1292 loc = strchr(challenge_lookup, *magic_ptr); | |
| 1293 if (!loc) { | |
| 8349 | 1294 /* SME XXX Error - disconnect here */ |
| 6986 | 1295 } |
| 1296 | |
| 8349 | 1297 /* Get offset into lookup table and shl 3. |
| 1298 */ | |
| 6986 | 1299 |
| 1300 magic_work = loc - challenge_lookup; | |
| 1301 magic_work <<= 3; | |
| 1302 | |
| 1303 magic_ptr++; | |
| 1304 continue; | |
| 1305 } else { | |
| 8349 | 1306 unsigned int local_store; |
| 6986 | 1307 |
| 1308 loc = strchr(operand_lookup, *magic_ptr); | |
| 1309 if (!loc) { | |
| 8349 | 1310 /* SME XXX Disconnect */ |
| 6986 | 1311 } |
| 1312 | |
| 1313 local_store = loc - operand_lookup; | |
| 8349 | 1314 |
| 1315 /* Oops; how did this happen? | |
| 1316 */ | |
| 1317 | |
| 6986 | 1318 if (magic_cnt >= 64) |
| 1319 break; | |
| 8349 | 1320 |
| 6986 | 1321 magic[magic_cnt++] = magic_work | local_store; |
| 1322 magic_ptr++; | |
| 1323 continue; | |
| 1324 } | |
| 8349 | 1325 } |
| 6986 | 1326 |
| 1327 magic_len = magic_cnt; | |
| 1328 magic_cnt = 0; | |
| 1329 | |
| 8349 | 1330 /* Magic: Phase 2. Take generated magic value and sprinkle fairy dust on the values. |
| 1331 */ | |
| 1332 | |
| 6986 | 1333 for (magic_cnt = magic_len-2; magic_cnt >= 0; magic_cnt--) { |
| 8349 | 1334 unsigned char byte1; |
| 1335 unsigned char byte2; | |
| 6986 | 1336 |
| 1337 /* Bad. Abort. | |
| 1338 */ | |
| 8349 | 1339 |
| 1340 if ((magic_cnt + 1 > magic_len) || (magic_cnt > magic_len)) | |
| 6986 | 1341 break; |
| 1342 | |
| 1343 byte1 = magic[magic_cnt]; | |
| 1344 byte2 = magic[magic_cnt+1]; | |
| 8349 | 1345 |
| 6986 | 1346 byte1 *= 0xcd; |
| 1347 byte1 ^= byte2; | |
| 1348 | |
| 1349 magic[magic_cnt+1] = byte1; | |
| 8349 | 1350 } |
| 1351 | |
| 1352 /* | |
| 1353 * Magic: Phase 3. This computes 20 bytes. The first 4 bytes are used as our magic | |
| 1354 * key (and may be changed later); the next 16 bytes are an MD5 sum of the magic key | |
| 1355 * plus 3 bytes. The 3 bytes are found by looping, and they represent the offsets | |
| 1356 * into particular functions we'll later call to potentially alter the magic key. | |
| 1357 * | |
| 1358 * %-) | |
| 1359 */ | |
| 1360 | |
| 1361 magic_cnt = 1; | |
| 1362 x = 0; | |
| 1363 | |
| 1364 do { | |
| 1365 unsigned int bl = 0; | |
| 1366 unsigned int cl = magic[magic_cnt++]; | |
| 1367 | |
| 1368 if (magic_cnt >= magic_len) | |
| 1369 break; | |
| 1370 | |
| 1371 if (cl > 0x7F) { | |
| 1372 if (cl < 0xe0) | |
| 1373 bl = cl = (cl & 0x1f) << 6; | |
| 1374 else { | |
| 1375 bl = magic[magic_cnt++]; | |
| 1376 cl = (cl & 0x0f) << 6; | |
| 1377 bl = ((bl & 0x3f) + cl) << 6; | |
| 1378 } | |
| 9277 | 1379 |
| 8349 | 1380 cl = magic[magic_cnt++]; |
| 1381 bl = (cl & 0x3f) + bl; | |
| 1382 } else | |
| 1383 bl = cl; | |
| 1384 | |
| 1385 comparison_src[x++] = (bl & 0xff00) >> 8; | |
| 1386 comparison_src[x++] = bl & 0xff; | |
| 1387 } while (x < 20); | |
| 1388 | |
| 1389 /* First four bytes are magic key. | |
| 1390 */ | |
| 1391 | |
| 1392 memcpy(&magic_key_char[0], comparison_src, 4); | |
| 8482 | 1393 magic_4 = magic_key_char[0] | (magic_key_char[1]<<8) | (magic_key_char[2]<<16) | (magic_key_char[3]<<24); |
| 8349 | 1394 |
| 1395 /* | |
| 1396 * Magic: Phase 4. Determine what function to use later by getting outside/inside | |
| 1397 * loop values until we match our previous buffer. | |
| 1398 */ | |
| 1399 | |
| 1400 for (x = 0; x < 65535; x++) { | |
| 1401 int leave = 0; | |
| 1402 | |
| 1403 for (y = 0; y < 5; y++) { | |
| 1404 md5_byte_t result[16]; | |
| 1405 md5_state_t ctx; | |
| 1406 | |
| 1407 unsigned char test[3]; | |
| 1408 | |
| 1409 memset(&result, 0, 16); | |
| 1410 memset(&test, 0, 3); | |
| 1411 | |
| 1412 /* Calculate buffer. | |
| 1413 */ | |
| 1414 | |
| 1415 test[0] = x; | |
| 1416 test[1] = x >> 8; | |
| 1417 test[2] = y; | |
| 1418 | |
| 1419 md5_init(&ctx); | |
| 1420 md5_append(&ctx, magic_key_char, 4); | |
| 1421 md5_append(&ctx, test, 3); | |
| 1422 md5_finish(&ctx, result); | |
| 1423 | |
| 1424 if (!memcmp(result, comparison_src+4, 16)) { | |
| 1425 leave = 1; | |
| 1426 break; | |
| 1427 } | |
| 1428 } | |
| 1429 | |
| 1430 if (leave == 1) | |
| 1431 break; | |
| 6986 | 1432 } |
| 1433 | |
| 8349 | 1434 /* If y != 0, we need some help. |
| 1435 */ | |
| 6986 | 1436 |
| 8349 | 1437 if (y != 0) { |
| 1438 unsigned int updated_key; | |
| 6986 | 1439 |
| 8349 | 1440 /* Update magic stuff. Call it twice because Yahoo's encryption is super bad ass. |
| 1441 */ | |
| 7127 | 1442 |
| 8349 | 1443 updated_key = yahoo_auth_finalCountdown(magic_4, 0x60, y, x); |
| 1444 updated_key = yahoo_auth_finalCountdown(updated_key, 0x60, y, x); | |
| 6986 | 1445 |
| 8482 | 1446 magic_key_char[0] = updated_key & 0xff; |
| 1447 magic_key_char[1] = (updated_key >> 8) & 0xff; | |
| 1448 magic_key_char[2] = (updated_key >> 16) & 0xff; | |
| 1449 magic_key_char[3] = (updated_key >> 24) & 0xff; | |
| 8349 | 1450 } |
| 7127 | 1451 |
| 8349 | 1452 /* Get password and crypt hashes as per usual. |
| 1453 */ | |
| 1454 | |
| 6986 | 1455 md5_init(&ctx); |
| 8349 | 1456 md5_append(&ctx, pass, strlen(pass)); |
| 6986 | 1457 md5_finish(&ctx, result); |
| 1458 to_y64(password_hash, result, 16); | |
| 1459 | |
| 1460 md5_init(&ctx); | |
| 1461 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); | |
| 1462 md5_append(&ctx, crypt_result, strlen(crypt_result)); | |
| 1463 md5_finish(&ctx, result); | |
| 1464 to_y64(crypt_hash, result, 16); | |
| 8349 | 1465 |
| 1466 /* Our first authentication response is based off of the password hash. | |
| 1467 */ | |
| 6986 | 1468 |
| 1469 for (x = 0; x < (int)strlen(password_hash); x++) | |
| 1470 pass_hash_xor1[cnt++] = password_hash[x] ^ 0x36; | |
| 1471 | |
| 1472 if (cnt < 64) | |
| 1473 memset(&(pass_hash_xor1[cnt]), 0x36, 64-cnt); | |
| 8349 | 1474 |
| 6986 | 1475 cnt = 0; |
| 1476 | |
| 1477 for (x = 0; x < (int)strlen(password_hash); x++) | |
| 1478 pass_hash_xor2[cnt++] = password_hash[x] ^ 0x5c; | |
| 1479 | |
| 1480 if (cnt < 64) | |
| 1481 memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt); | |
| 1482 | |
| 1483 shaInit(&ctx1); | |
| 1484 shaInit(&ctx2); | |
| 1485 | |
| 8349 | 1486 /* |
| 1487 * The first context gets the password hash XORed with 0x36 plus a magic value | |
| 1488 * which we previously extrapolated from our challenge. | |
| 1489 */ | |
| 6986 | 1490 |
| 1491 shaUpdate(&ctx1, pass_hash_xor1, 64); | |
| 1492 shaUpdate(&ctx1, magic_key_char, 4); | |
| 1493 shaFinal(&ctx1, digest1); | |
| 1494 | |
| 8349 | 1495 /* |
| 1496 * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest | |
| 1497 * of the first context. | |
| 1498 */ | |
| 6986 | 1499 |
| 1500 shaUpdate(&ctx2, pass_hash_xor2, 64); | |
| 1501 shaUpdate(&ctx2, digest1, 20); | |
| 1502 shaFinal(&ctx2, digest2); | |
| 1503 | |
| 8349 | 1504 /* |
| 1505 * Now that we have digest2, use it to fetch characters from an alphabet to construct | |
| 1506 * our first authentication response. | |
| 1507 */ | |
| 1508 | |
| 6986 | 1509 for (x = 0; x < 20; x += 2) { |
| 8349 | 1510 unsigned int val = 0; |
| 1511 unsigned int lookup = 0; | |
| 6986 | 1512 |
| 8349 | 1513 char byte[6]; |
| 1514 | |
| 6986 | 1515 memset(&byte, 0, 6); |
| 8349 | 1516 |
| 1517 /* First two bytes of digest stuffed together. | |
| 6986 | 1518 */ |
| 9277 | 1519 |
| 6986 | 1520 val = digest2[x]; |
| 1521 val <<= 8; | |
| 1522 val += digest2[x+1]; | |
| 1523 | |
| 1524 lookup = (val >> 0x0b); | |
| 1525 lookup &= 0x1f; | |
| 1526 if (lookup >= strlen(alphabet1)) | |
| 1527 break; | |
| 1528 sprintf(byte, "%c", alphabet1[lookup]); | |
| 1529 strcat(resp_6, byte); | |
| 1530 strcat(resp_6, "="); | |
| 8349 | 1531 |
| 6986 | 1532 lookup = (val >> 0x06); |
| 1533 lookup &= 0x1f; | |
| 1534 if (lookup >= strlen(alphabet2)) | |
| 1535 break; | |
| 1536 sprintf(byte, "%c", alphabet2[lookup]); | |
| 1537 strcat(resp_6, byte); | |
| 1538 | |
| 1539 lookup = (val >> 0x01); | |
| 1540 lookup &= 0x1f; | |
| 1541 if (lookup >= strlen(alphabet2)) | |
| 1542 break; | |
| 1543 sprintf(byte, "%c", alphabet2[lookup]); | |
| 1544 strcat(resp_6, byte); | |
| 8349 | 1545 |
| 6986 | 1546 lookup = (val & 0x01); |
| 1547 if (lookup >= strlen(delimit_lookup)) | |
| 1548 break; | |
| 1549 sprintf(byte, "%c", delimit_lookup[lookup]); | |
| 1550 strcat(resp_6, byte); | |
| 1551 } | |
| 1552 | |
| 8349 | 1553 /* Our second authentication response is based off of the crypto hash. |
| 1554 */ | |
| 6986 | 1555 |
| 1556 cnt = 0; | |
| 1557 memset(&digest1, 0, 20); | |
| 1558 memset(&digest2, 0, 20); | |
| 1559 | |
| 1560 for (x = 0; x < (int)strlen(crypt_hash); x++) | |
| 1561 crypt_hash_xor1[cnt++] = crypt_hash[x] ^ 0x36; | |
| 1562 | |
| 1563 if (cnt < 64) | |
| 1564 memset(&(crypt_hash_xor1[cnt]), 0x36, 64-cnt); | |
| 8349 | 1565 |
| 6986 | 1566 cnt = 0; |
| 1567 | |
| 1568 for (x = 0; x < (int)strlen(crypt_hash); x++) | |
| 1569 crypt_hash_xor2[cnt++] = crypt_hash[x] ^ 0x5c; | |
| 1570 | |
| 1571 if (cnt < 64) | |
| 1572 memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt); | |
| 1573 | |
| 1574 shaInit(&ctx1); | |
| 1575 shaInit(&ctx2); | |
| 1576 | |
| 8349 | 1577 /* |
| 1578 * The first context gets the password hash XORed with 0x36 plus a magic value | |
| 1579 * which we previously extrapolated from our challenge. | |
| 1580 */ | |
| 6986 | 1581 |
| 1582 shaUpdate(&ctx1, crypt_hash_xor1, 64); | |
| 1583 shaUpdate(&ctx1, magic_key_char, 4); | |
| 1584 shaFinal(&ctx1, digest1); | |
| 1585 | |
| 8349 | 1586 /* |
| 1587 * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest | |
| 1588 * of the first context. | |
| 1589 */ | |
| 6986 | 1590 |
| 1591 shaUpdate(&ctx2, crypt_hash_xor2, 64); | |
| 1592 shaUpdate(&ctx2, digest1, 20); | |
| 1593 shaFinal(&ctx2, digest2); | |
| 1594 | |
| 8349 | 1595 /* |
| 1596 * Now that we have digest2, use it to fetch characters from an alphabet to construct | |
| 1597 * our first authentication response. | |
| 1598 */ | |
| 6986 | 1599 |
| 1600 for (x = 0; x < 20; x += 2) { | |
| 8349 | 1601 unsigned int val = 0; |
| 1602 unsigned int lookup = 0; | |
| 6986 | 1603 |
| 8349 | 1604 char byte[6]; |
| 6986 | 1605 |
| 1606 memset(&byte, 0, 6); | |
| 1607 | |
| 8349 | 1608 /* First two bytes of digest stuffed together. |
| 1609 */ | |
| 6986 | 1610 |
| 1611 val = digest2[x]; | |
| 1612 val <<= 8; | |
| 1613 val += digest2[x+1]; | |
| 8349 | 1614 |
| 6986 | 1615 lookup = (val >> 0x0b); |
| 1616 lookup &= 0x1f; | |
| 1617 if (lookup >= strlen(alphabet1)) | |
| 1618 break; | |
| 1619 sprintf(byte, "%c", alphabet1[lookup]); | |
| 1620 strcat(resp_96, byte); | |
| 1621 strcat(resp_96, "="); | |
| 1622 | |
| 1623 lookup = (val >> 0x06); | |
| 1624 lookup &= 0x1f; | |
| 1625 if (lookup >= strlen(alphabet2)) | |
| 1626 break; | |
| 1627 sprintf(byte, "%c", alphabet2[lookup]); | |
| 1628 strcat(resp_96, byte); | |
| 1629 | |
| 1630 lookup = (val >> 0x01); | |
| 1631 lookup &= 0x1f; | |
| 1632 if (lookup >= strlen(alphabet2)) | |
| 1633 break; | |
| 1634 sprintf(byte, "%c", alphabet2[lookup]); | |
| 1635 strcat(resp_96, byte); | |
| 1636 | |
| 1637 lookup = (val & 0x01); | |
| 1638 if (lookup >= strlen(delimit_lookup)) | |
| 1639 break; | |
| 1640 sprintf(byte, "%c", delimit_lookup[lookup]); | |
| 1641 strcat(resp_96, byte); | |
| 1642 } | |
| 1643 | |
| 1644 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | |
| 1645 yahoo_packet_hash(pack, 0, name); | |
| 1646 yahoo_packet_hash(pack, 6, resp_6); | |
| 1647 yahoo_packet_hash(pack, 96, resp_96); | |
| 1648 yahoo_packet_hash(pack, 1, name); | |
| 9306 | 1649 if (yd->picture_checksum) { |
| 1650 char *cksum = g_strdup_printf("%d", yd->picture_checksum); | |
| 1651 yahoo_packet_hash(pack, 192, cksum); | |
| 1652 g_free(cksum); | |
| 1653 } | |
| 6986 | 1654 yahoo_send_packet(yd, pack); |
| 1655 yahoo_packet_free(pack); | |
| 1656 | |
| 7424 | 1657 g_free(password_hash); |
| 1658 g_free(crypt_hash); | |
| 6986 | 1659 } |
| 1660 | |
| 5583 | 1661 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt) |
| 3147 | 1662 { |
| 1663 char *seed = NULL; | |
| 1664 char *sn = NULL; | |
| 1665 GSList *l = pkt->hash; | |
| 7010 | 1666 int m = 0; |
| 9277 | 1667 gchar *buf; |
| 1668 | |
| 1669 | |
| 3147 | 1670 while (l) { |
| 1671 struct yahoo_pair *pair = l->data; | |
| 1672 if (pair->key == 94) | |
| 1673 seed = pair->value; | |
| 1674 if (pair->key == 1) | |
| 1675 sn = pair->value; | |
| 6986 | 1676 if (pair->key == 13) |
| 1677 m = atoi(pair->value); | |
| 3147 | 1678 l = l->next; |
| 1679 } | |
| 9277 | 1680 |
| 3147 | 1681 if (seed) { |
| 6986 | 1682 switch (m) { |
| 1683 case 0: | |
| 1684 yahoo_process_auth_old(gc, seed); | |
| 1685 break; | |
| 3147 | 1686 case 1: |
| 6986 | 1687 yahoo_process_auth_new(gc, seed); |
| 3147 | 1688 break; |
| 6986 | 1689 default: |
| 7043 | 1690 buf = g_strdup_printf(_("The Yahoo server has requested the use of an unrecognized " |
| 7129 | 1691 "authentication method. This version of Gaim will likely not be able " |
| 7043 | 1692 "to successfully sign on to Yahoo. Check %s for updates."), GAIM_WEBSITE); |
| 6986 | 1693 gaim_notify_error(gc, "", _("Failed Yahoo! Authentication"), |
| 7043 | 1694 buf); |
| 1695 g_free(buf); | |
| 6986 | 1696 yahoo_process_auth_new(gc, seed); /* Can't hurt to try it anyway. */ |
| 3147 | 1697 } |
| 1698 } | |
| 1699 } | |
| 2681 | 1700 |
| 9285 | 1701 static void ignore_buddy(GaimBuddy *buddy) { |
| 1702 GaimGroup *group; | |
| 1703 GaimConversation *conv; | |
| 6760 | 1704 GaimAccount *account; |
| 1705 gchar *name; | |
| 1706 | |
| 9285 | 1707 if (!buddy) |
| 6792 | 1708 return; |
| 6760 | 1709 |
| 9285 | 1710 group = gaim_find_buddys_group(buddy); |
| 1711 name = g_strdup(buddy->name); | |
| 1712 account = buddy->account; | |
| 6760 | 1713 |
| 6792 | 1714 gaim_debug(GAIM_DEBUG_INFO, "blist", |
| 9285 | 1715 "Removing '%s' from buddy list.\n", buddy->name); |
| 1716 serv_remove_buddy(account->gc, buddy, group); | |
| 1717 gaim_blist_remove_buddy(buddy); | |
| 6760 | 1718 |
| 6792 | 1719 serv_add_deny(account->gc, name); |
| 9285 | 1720 |
| 1721 conv = gaim_find_conversation_with_account(name, account); | |
| 1722 | |
| 1723 if (conv != NULL) | |
| 1724 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
| 6760 | 1725 |
| 1726 g_free(name); | |
| 1727 } | |
| 1728 | |
| 1729 static void keep_buddy(GaimBuddy *b) { | |
| 1730 gaim_privacy_deny_remove(b->account, b->name, 1); | |
| 1731 } | |
| 1732 | |
| 1733 static void yahoo_process_ignore(GaimConnection *gc, struct yahoo_packet *pkt) { | |
| 1734 GaimBuddy *b; | |
| 1735 GSList *l; | |
| 1736 gchar *who = NULL; | |
| 1737 gchar *sn = NULL; | |
| 1738 gchar buf[BUF_LONG]; | |
| 1739 gint ignore = 0; | |
| 1740 gint status = 0; | |
| 1741 | |
| 1742 for (l = pkt->hash; l; l = l->next) { | |
| 1743 struct yahoo_pair *pair = l->data; | |
| 1744 switch (pair->key) { | |
| 1745 case 0: | |
| 1746 who = pair->value; | |
| 1747 break; | |
| 1748 case 1: | |
| 1749 sn = pair->value; | |
| 1750 break; | |
| 1751 case 13: | |
| 1752 ignore = strtol(pair->value, NULL, 10); | |
| 1753 break; | |
| 1754 case 66: | |
| 1755 status = strtol(pair->value, NULL, 10); | |
| 1756 break; | |
| 1757 default: | |
| 1758 break; | |
| 1759 } | |
| 1760 } | |
| 1761 | |
| 1762 switch (status) { | |
| 1763 case 12: | |
| 1764 b = gaim_find_buddy(gc->account, who); | |
| 1765 g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " | |
| 1766 "user is on your buddy list. Clicking \"Yes\" " | |
| 1767 "will remove and ignore the buddy."), who); | |
| 1768 gaim_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, b, | |
| 1769 G_CALLBACK(ignore_buddy), | |
| 1770 G_CALLBACK(keep_buddy)); | |
| 1771 break; | |
| 1772 case 2: | |
| 1773 case 3: | |
| 1774 case 0: | |
| 1775 default: | |
| 1776 break; | |
| 1777 } | |
| 1778 } | |
| 1779 | |
| 6761 | 1780 static void yahoo_process_authresp(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1781 { | |
| 1782 GSList *l = pkt->hash; | |
| 1783 int err = 0; | |
| 1784 char *msg; | |
| 7865 | 1785 char *url = NULL; |
| 1786 char *fullmsg; | |
| 6761 | 1787 |
| 1788 while (l) { | |
| 1789 struct yahoo_pair *pair = l->data; | |
| 1790 | |
| 1791 if (pair->key == 66) | |
| 1792 err = strtol(pair->value, NULL, 10); | |
| 7865 | 1793 if (pair->key == 20) |
| 1794 url = pair->value; | |
| 6761 | 1795 |
| 1796 l = l->next; | |
| 1797 } | |
| 1798 | |
| 1799 switch (err) { | |
| 1800 case 3: | |
| 7865 | 1801 msg = g_strdup(_("Invalid username.")); |
| 6761 | 1802 break; |
| 1803 case 13: | |
| 7865 | 1804 msg = g_strdup(_("Incorrect password.")); |
| 1805 break; | |
| 1806 case 14: | |
| 9280 | 1807 msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website.")); |
| 6761 | 1808 break; |
| 1809 default: | |
| 9280 | 1810 msg = g_strdup_printf(_("Unknown error number %d. Logging into the Yahoo! website may fix this."), err); |
| 6761 | 1811 } |
| 7865 | 1812 |
| 1813 if (url) | |
| 1814 fullmsg = g_strdup_printf("%s\n%s", msg, url); | |
| 1815 else | |
| 1816 fullmsg = g_strdup(msg); | |
| 1817 | |
| 9280 | 1818 gc->wants_to_die = TRUE; |
| 7865 | 1819 gaim_connection_error(gc, fullmsg); |
| 1820 g_free(msg); | |
| 1821 g_free(fullmsg); | |
| 6761 | 1822 } |
| 1823 | |
| 6840 | 1824 static void yahoo_process_addbuddy(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1825 { | |
| 1826 int err = 0; | |
| 1827 char *who = NULL; | |
| 1828 char *group = NULL; | |
| 7827 | 1829 char *decoded_group; |
| 6840 | 1830 char *buf; |
| 9278 | 1831 YahooFriend *f; |
| 6840 | 1832 GSList *l = pkt->hash; |
| 1833 | |
| 1834 while (l) { | |
| 1835 struct yahoo_pair *pair = l->data; | |
| 1836 | |
| 1837 switch (pair->key) { | |
| 1838 case 66: | |
| 1839 err = strtol(pair->value, NULL, 10); | |
| 1840 break; | |
| 1841 case 7: | |
| 1842 who = pair->value; | |
| 1843 break; | |
| 1844 case 65: | |
| 1845 group = pair->value; | |
| 1846 break; | |
| 1847 } | |
| 1848 | |
| 1849 l = l->next; | |
| 1850 } | |
| 1851 | |
| 1852 if (!who) | |
| 1853 return; | |
| 1854 if (!group) | |
| 1855 group = ""; | |
| 1856 | |
| 1857 if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */ | |
| 9279 | 1858 f = yahoo_friend_find_or_new(gc, who); |
| 1859 yahoo_update_status(gc, who, f); | |
| 6840 | 1860 return; |
| 1861 } | |
| 1862 | |
| 7827 | 1863 decoded_group = yahoo_string_decode(gc, group, FALSE); |
| 6840 | 1864 buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."), |
| 7827 | 1865 who, decoded_group, gaim_connection_get_display_name(gc)); |
| 6840 | 1866 gaim_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); |
| 1867 g_free(buf); | |
| 7827 | 1868 g_free(decoded_group); |
| 6840 | 1869 } |
| 1870 | |
| 9062 | 1871 static void yahoo_process_p2p(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1872 { | |
| 1873 GSList *l = pkt->hash; | |
| 1874 char *who = NULL; | |
| 1875 char *base64 = NULL; | |
| 9277 | 1876 char *decoded; |
| 9062 | 1877 int len; |
| 1878 | |
| 1879 while (l) { | |
| 1880 struct yahoo_pair *pair = l->data; | |
| 1881 | |
| 1882 switch (pair->key) { | |
| 1883 case 5: | |
| 1884 /* our identity */ | |
| 1885 break; | |
| 1886 case 4: | |
| 1887 who = pair->value; | |
| 1888 break; | |
| 1889 case 1: | |
| 1890 /* who again, the master identity this time? */ | |
| 1891 break; | |
| 1892 case 12: | |
| 1893 base64 = pair->value; | |
| 1894 /* so, this is an ip address. in base64. decoded it's in ascii. | |
| 1895 after strtol, it's in reversed byte order. Who thought this up?*/ | |
| 1896 break; | |
| 1897 /* | |
| 1898 TODO: figure these out | |
| 1899 yahoo: Key: 61 Value: 0 | |
| 1900 yahoo: Key: 2 Value: | |
| 1901 yahoo: Key: 13 Value: 0 | |
| 1902 yahoo: Key: 49 Value: PEERTOPEER | |
| 1903 yahoo: Key: 140 Value: 1 | |
| 1904 yahoo: Key: 11 Value: -1786225828 | |
| 1905 */ | |
| 1906 | |
| 1907 } | |
| 1908 | |
| 1909 l = l->next; | |
| 1910 } | |
| 1911 | |
| 9277 | 1912 if (base64) { |
| 9281 | 1913 guint32 ip; |
| 1914 char *tmp2; | |
| 1915 YahooFriend *f; | |
| 1916 | |
| 9062 | 1917 gaim_base64_decode(base64, &decoded, &len); |
| 9277 | 1918 if (len) { |
| 1919 char *tmp = gaim_str_binary_to_ascii(decoded, len); | |
| 1920 gaim_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, tmp); | |
| 1921 g_free(tmp); | |
| 1922 } | |
| 9281 | 1923 |
| 1924 tmp2 = g_strndup(decoded, len); /* so its \0 terminated...*/ | |
| 1925 ip = strtol(tmp2, NULL, 10); | |
| 1926 g_free(tmp2); | |
| 9062 | 1927 g_free(decoded); |
| 9281 | 1928 tmp2 = g_strdup_printf("%u.%u.%u.%u", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, |
| 1929 (ip >> 24) & 0xff); | |
| 1930 f = yahoo_friend_find(gc, who); | |
| 1931 if (f) | |
| 1932 yahoo_friend_set_ip(f, tmp2); | |
| 1933 g_free(tmp2); | |
| 9062 | 1934 } |
| 1935 } | |
| 1936 | |
| 5583 | 1937 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 1938 { |
| 6760 | 1939 switch (pkt->service) { |
| 2681 | 1940 case YAHOO_SERVICE_LOGON: |
|
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
1941 case YAHOO_SERVICE_LOGOFF: |
| 2681 | 1942 case YAHOO_SERVICE_ISAWAY: |
|
2737
f61c1f3a6afa
[gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2724
diff
changeset
|
1943 case YAHOO_SERVICE_ISBACK: |
| 3019 | 1944 case YAHOO_SERVICE_GAMELOGON: |
| 1945 case YAHOO_SERVICE_GAMELOGOFF: | |
| 6686 | 1946 case YAHOO_SERVICE_CHATLOGON: |
| 1947 case YAHOO_SERVICE_CHATLOGOFF: | |
| 2681 | 1948 yahoo_process_status(gc, pkt); |
| 1949 break; | |
| 3019 | 1950 case YAHOO_SERVICE_NOTIFY: |
| 1951 yahoo_process_notify(gc, pkt); | |
| 2993 | 1952 break; |
| 2681 | 1953 case YAHOO_SERVICE_MESSAGE: |
|
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
1954 case YAHOO_SERVICE_GAMEMSG: |
| 5939 | 1955 case YAHOO_SERVICE_CHATMSG: |
| 2681 | 1956 yahoo_process_message(gc, pkt); |
| 1957 break; | |
| 7865 | 1958 case YAHOO_SERVICE_SYSMESSAGE: |
| 1959 yahoo_process_sysmessage(gc, pkt); | |
| 1960 break; | |
| 2681 | 1961 case YAHOO_SERVICE_NEWMAIL: |
| 1962 yahoo_process_mail(gc, pkt); | |
| 1963 break; | |
| 1964 case YAHOO_SERVICE_NEWCONTACT: | |
| 1965 yahoo_process_contact(gc, pkt); | |
| 1966 break; | |
| 6784 | 1967 case YAHOO_SERVICE_AUTHRESP: |
| 1968 yahoo_process_authresp(gc, pkt); | |
| 1969 break; | |
| 2681 | 1970 case YAHOO_SERVICE_LIST: |
| 1971 yahoo_process_list(gc, pkt); | |
| 1972 break; | |
| 3147 | 1973 case YAHOO_SERVICE_AUTH: |
| 1974 yahoo_process_auth(gc, pkt); | |
| 1975 break; | |
| 6840 | 1976 case YAHOO_SERVICE_ADDBUDDY: |
| 1977 yahoo_process_addbuddy(gc, pkt); | |
| 1978 break; | |
| 6760 | 1979 case YAHOO_SERVICE_IGNORECONTACT: |
| 1980 yahoo_process_ignore(gc, pkt); | |
| 1981 break; | |
| 6729 | 1982 case YAHOO_SERVICE_CONFINVITE: |
| 1983 case YAHOO_SERVICE_CONFADDINVITE: | |
| 1984 yahoo_process_conference_invite(gc, pkt); | |
| 1985 break; | |
| 1986 case YAHOO_SERVICE_CONFDECLINE: | |
| 1987 yahoo_process_conference_decline(gc, pkt); | |
| 1988 break; | |
| 1989 case YAHOO_SERVICE_CONFLOGON: | |
| 1990 yahoo_process_conference_logon(gc, pkt); | |
| 1991 break; | |
| 1992 case YAHOO_SERVICE_CONFLOGOFF: | |
| 1993 yahoo_process_conference_logoff(gc, pkt); | |
| 1994 break; | |
| 1995 case YAHOO_SERVICE_CONFMSG: | |
| 1996 yahoo_process_conference_message(gc, pkt); | |
| 1997 break; | |
| 1998 case YAHOO_SERVICE_CHATONLINE: | |
| 1999 yahoo_process_chat_online(gc, pkt); | |
| 2000 break; | |
| 2001 case YAHOO_SERVICE_CHATLOGOUT: | |
| 2002 yahoo_process_chat_logout(gc, pkt); | |
| 2003 break; | |
| 2004 case YAHOO_SERVICE_CHATGOTO: | |
| 2005 yahoo_process_chat_goto(gc, pkt); | |
| 2006 break; | |
| 2007 case YAHOO_SERVICE_CHATJOIN: | |
| 2008 yahoo_process_chat_join(gc, pkt); | |
| 2009 break; | |
| 2010 case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */ | |
| 2011 case YAHOO_SERVICE_CHATEXIT: | |
| 2012 yahoo_process_chat_exit(gc, pkt); | |
| 2013 break; | |
| 2014 case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */ | |
| 2015 case YAHOO_SERVICE_CHATADDINVITE: | |
| 2016 yahoo_process_chat_addinvite(gc, pkt); | |
| 2017 break; | |
| 2018 case YAHOO_SERVICE_COMMENT: | |
| 2019 yahoo_process_chat_message(gc, pkt); | |
| 2020 break; | |
| 7651 | 2021 case YAHOO_SERVICE_P2PFILEXFER: |
| 2022 case YAHOO_SERVICE_FILETRANSFER: | |
| 2023 yahoo_process_filetransfer(gc, pkt); | |
| 2024 break; | |
| 9062 | 2025 case YAHOO_SERVICE_PEEPTOPEER: |
| 2026 yahoo_process_p2p(gc, pkt); | |
| 2027 break; | |
| 9284 | 2028 case YAHOO_SERVICE_PICTURE: |
| 2029 yahoo_process_picture(gc, pkt); | |
| 2030 break; | |
| 9292 | 2031 case YAHOO_SERVICE_PICTURE_UPDATE: |
| 2032 yahoo_process_picture_update(gc, pkt); | |
| 2033 break; | |
| 2034 case YAHOO_SERVICE_PICTURE_CHECKSUM: | |
| 2035 yahoo_process_picture_checksum(gc, pkt); | |
| 2036 break; | |
| 9306 | 2037 case YAHOO_SERVICE_PICTURE_UPLOAD: |
| 2038 yahoo_process_picture_upload(gc, pkt); | |
| 2039 break; | |
| 2681 | 2040 default: |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2041 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2042 "Unhandled service 0x%02x\n", pkt->service); |
| 2681 | 2043 break; |
| 2044 } | |
| 2045 } | |
| 2046 | |
| 2047 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
| 2048 { | |
| 5583 | 2049 GaimConnection *gc = data; |
| 2681 | 2050 struct yahoo_data *yd = gc->proto_data; |
| 2051 char buf[1024]; | |
| 2052 int len; | |
| 2053 | |
| 2054 len = read(yd->fd, buf, sizeof(buf)); | |
| 2055 | |
| 2056 if (len <= 0) { | |
| 6321 | 2057 gaim_connection_error(gc, _("Unable to read")); |
| 2681 | 2058 return; |
| 2059 } | |
| 2060 | |
| 2061 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
| 2062 memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
| 2063 yd->rxlen += len; | |
| 2064 | |
| 2065 while (1) { | |
| 2066 struct yahoo_packet *pkt; | |
| 2067 int pos = 0; | |
| 2068 int pktlen; | |
| 2069 | |
| 2070 if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
| 2071 return; | |
| 2072 | |
| 2073 pos += 4; /* YMSG */ | |
| 2074 pos += 2; | |
| 2075 pos += 2; | |
| 2076 | |
| 2077 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2078 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2079 "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
| 2681 | 2080 |
| 2081 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
| 2082 return; | |
| 2083 | |
| 2084 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
| 2085 | |
| 2086 pkt = yahoo_packet_new(0, 0, 0); | |
| 2087 | |
| 2088 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
| 3021 | 2089 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
|
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2090 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
|
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2091 "Yahoo Service: 0x%02x Status: %d\n", |
|
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2092 pkt->service, pkt->status); |
| 2681 | 2093 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
| 2094 | |
| 2095 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
| 2096 | |
| 2097 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
| 2098 if (yd->rxlen) { | |
| 2099 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
| 2100 g_free(yd->rxqueue); | |
| 2101 yd->rxqueue = tmp; | |
| 2102 } else { | |
| 2103 g_free(yd->rxqueue); | |
| 2104 yd->rxqueue = NULL; | |
| 2105 } | |
| 2106 | |
| 2107 yahoo_packet_process(gc, pkt); | |
| 2108 | |
| 2109 yahoo_packet_free(pkt); | |
| 2110 } | |
| 2111 } | |
| 2112 | |
|
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2113 #ifndef YAHOO_WEBMESSENGER |
| 2681 | 2114 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) |
| 2115 { | |
| 5583 | 2116 GaimConnection *gc = data; |
| 2681 | 2117 struct yahoo_data *yd; |
| 2118 struct yahoo_packet *pkt; | |
| 2119 | |
|
5590
011a0a975060
[gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents:
5583
diff
changeset
|
2120 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2681 | 2121 close(source); |
| 2122 return; | |
| 2123 } | |
| 2124 | |
| 2125 if (source < 0) { | |
| 8057 | 2126 gaim_connection_error(gc, _("Unable to connect.")); |
| 2681 | 2127 return; |
| 2128 } | |
| 2129 | |
| 2130 yd = gc->proto_data; | |
| 2131 yd->fd = source; | |
| 2132 | |
| 3147 | 2133 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); |
| 2681 | 2134 |
| 7261 | 2135 yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); |
| 2681 | 2136 yahoo_send_packet(yd, pkt); |
| 2137 | |
| 2138 yahoo_packet_free(pkt); | |
| 2139 | |
| 2140 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
| 2141 } | |
|
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2142 #endif |
| 2681 | 2143 |
| 7134 | 2144 #ifdef YAHOO_WEBMESSENGER |
| 2145 static void yahoo_got_web_connected(gpointer data, gint source, GaimInputCondition cond) | |
| 2146 { | |
| 2147 GaimConnection *gc = data; | |
| 2148 struct yahoo_data *yd; | |
| 2149 struct yahoo_packet *pkt; | |
| 2150 | |
| 2151 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
| 2152 close(source); | |
| 2153 return; | |
| 2154 } | |
| 2155 | |
| 2156 if (source < 0) { | |
| 8057 | 2157 gaim_connection_error(gc, _("Unable to connect.")); |
| 7134 | 2158 return; |
| 2159 } | |
| 2160 | |
| 2161 yd = gc->proto_data; | |
| 2162 yd->fd = source; | |
| 2163 | |
| 2164 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); | |
| 2165 | |
| 7261 | 2166 yahoo_packet_hash(pkt, 0, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); |
| 2167 yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); | |
| 7134 | 2168 yahoo_packet_hash(pkt, 6, yd->auth); |
| 2169 yahoo_send_packet(yd, pkt); | |
| 2170 | |
| 2171 yahoo_packet_free(pkt); | |
| 2172 g_free(yd->auth); | |
| 2173 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
| 2174 } | |
| 2175 | |
| 2176 static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond) | |
| 2177 { | |
| 2178 GaimConnection *gc = data; | |
| 2179 GaimAccount *account = gaim_connection_get_account(gc); | |
| 2180 struct yahoo_data *yd = gc->proto_data; | |
| 8243 | 2181 char buf[2048], *i = buf; |
| 8161 | 2182 int len; |
| 2183 GString *s; | |
| 7134 | 2184 |
| 8118 | 2185 len = read(source, buf, sizeof(buf)-1); |
|
8216
dcace041cfb8
[gaim-migrate @ 8939]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
2186 if (len <= 0 || (strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) && |
|
dcace041cfb8
[gaim-migrate @ 8939]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
2187 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { |
| 7134 | 2188 gaim_connection_error(gc, _("Unable to read")); |
| 2189 return; | |
| 2190 } | |
| 8161 | 2191 |
| 2192 s = g_string_sized_new(len); | |
| 8118 | 2193 buf[sizeof(buf)-1] = '\0'; |
| 8161 | 2194 |
| 2195 while ((i = strstr(i, "Set-Cookie: "))) { | |
| 2196 i += strlen("Set-Cookie: "); | |
| 8243 | 2197 for (;*i != ';' && *i != '\0'; i++) |
| 8161 | 2198 g_string_append_c(s, *i); |
| 2199 | |
| 2200 g_string_append(s, "; "); | |
| 7134 | 2201 } |
| 8161 | 2202 |
| 2203 yd->auth = g_string_free(s, FALSE); | |
| 7134 | 2204 gaim_input_remove(gc->inpa); |
| 2205 close(source); | |
| 2206 /* Now we have our cookies to login with. I'll go get the milk. */ | |
| 8045 | 2207 if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", |
| 7134 | 2208 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), |
| 2209 yahoo_got_web_connected, gc) != 0) { | |
| 2210 gaim_connection_error(gc, _("Connection problem")); | |
| 2211 return; | |
| 2212 } | |
| 2213 } | |
| 2214 | |
| 2215 static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) | |
| 2216 { | |
| 2217 GaimConnection *gc = data; | |
| 2218 struct yahoo_data *yd = gc->proto_data; | |
| 2219 if (source < 0) { | |
| 8057 | 2220 gaim_connection_error(gc, _("Unable to connect.")); |
| 7134 | 2221 return; |
| 2222 } | |
| 2223 write(source, yd->auth, strlen(yd->auth)); | |
| 2224 g_free(yd->auth); | |
| 2225 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); | |
| 2226 } | |
| 2227 | |
| 2228 static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url) | |
| 2229 { | |
| 2230 if (!strcmp(key, "passwd")) | |
| 2231 return; | |
| 2232 url = g_string_append_c(url, '&'); | |
| 2233 url = g_string_append(url, key); | |
| 2234 url = g_string_append_c(url, '='); | |
| 2235 if (!strcmp(key, ".save") || !strcmp(key, ".js")) | |
| 2236 url = g_string_append_c(url, '1'); | |
| 2237 else if (!strcmp(key, ".challenge")) | |
| 2238 url = g_string_append(url, val); | |
| 2239 else | |
| 2240 url = g_string_append(url, gaim_url_encode(val)); | |
| 2241 } | |
| 2242 | |
| 2243 static GHashTable *yahoo_login_page_hash(const char *buf, size_t len) | |
| 2244 { | |
| 2245 GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
|
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2246 const char *c = buf; |
|
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2247 char *d; |
| 7134 | 2248 char name[64], value[64]; |
| 8118 | 2249 int count = sizeof(name)-1; |
| 7134 | 2250 while ((c < (buf + len)) && (c = strstr(c, "<input "))) { |
| 2251 c = strstr(c, "name=\"") + strlen("name=\""); | |
| 8118 | 2252 for (d = name; *c!='"' && count; c++, d++, count--) |
| 7134 | 2253 *d = *c; |
| 2254 *d = '\0'; | |
| 8118 | 2255 count = sizeof(value)-1; |
| 7134 | 2256 d = strstr(c, "value=\"") + strlen("value=\""); |
| 2257 if (strchr(c, '>') < d) | |
| 2258 break; | |
| 8118 | 2259 for (c = d, d = value; *c!='"' && count; c++, d++, count--) |
| 7134 | 2260 *d = *c; |
| 2261 *d = '\0'; | |
| 2262 g_hash_table_insert(hash, g_strdup(name), g_strdup(value)); | |
| 2263 } | |
| 2264 return hash; | |
| 2265 } | |
| 2266 | |
|
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2267 static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len) |
| 7134 | 2268 { |
|
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2269 GaimConnection *gc = (GaimConnection *)user_data; |
| 7134 | 2270 GaimAccount *account = gaim_connection_get_account(gc); |
| 2271 struct yahoo_data *yd = gc->proto_data; | |
| 2272 const char *sn = gaim_account_get_username(account); | |
| 2273 const char *pass = gaim_account_get_password(account); | |
| 2274 GHashTable *hash = yahoo_login_page_hash(buf, len); | |
| 2275 GString *url = g_string_new("GET /config/login?login="); | |
| 2276 char md5[33], *hashp = md5, *chal; | |
| 2277 int i; | |
| 2278 md5_byte_t result[16]; | |
| 2279 md5_state_t ctx; | |
|
7191
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2280 |
|
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2281 url = g_string_append(url, sn); |
|
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2282 url = g_string_append(url, "&passwd="); |
|
4bd3892cded3
[gaim-migrate @ 7760]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7161
diff
changeset
|
2283 |
| 7134 | 2284 md5_init(&ctx); |
| 2285 md5_append(&ctx, pass, strlen(pass)); | |
| 2286 md5_finish(&ctx, result); | |
| 2287 for (i = 0; i < 16; ++i) { | |
| 2288 g_snprintf(hashp, 3, "%02x", result[i]); | |
| 2289 hashp += 2; | |
| 2290 } | |
| 2291 chal = g_strconcat(md5, g_hash_table_lookup(hash, ".challenge"), NULL); | |
| 2292 md5_init(&ctx); | |
| 2293 md5_append(&ctx, chal, strlen(chal)); | |
| 2294 md5_finish(&ctx, result); | |
| 2295 hashp = md5; | |
| 2296 for (i = 0; i < 16; ++i) { | |
| 2297 g_snprintf(hashp, 3, "%02x", result[i]); | |
| 2298 hashp += 2; | |
| 2299 } | |
| 2300 /* | |
| 2301 md5_init(&ctx); | |
| 2302 md5_append(&ctx, md5, strlen(md5)); | |
| 2303 md5_finish(&ctx, result); | |
| 2304 hashp = md5; | |
| 2305 for (i = 0; i < 16; ++i) { | |
| 2306 g_snprintf(hashp, 3, "%02x", result[i]); | |
| 2307 hashp += 2; | |
| 2308 } | |
| 2309 */ | |
| 2310 g_free(chal); | |
| 2311 | |
| 2312 url = g_string_append(url, md5); | |
|
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2313 g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url); |
| 7134 | 2314 |
| 2315 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" | |
| 2316 "Host: login.yahoo.com\r\n\r\n"); | |
| 2317 g_hash_table_destroy(hash); | |
| 2318 yd->auth = g_string_free(url, FALSE); | |
| 2319 if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) { | |
| 2320 gaim_connection_error(gc, _("Connection problem")); | |
| 2321 return; | |
| 2322 } | |
| 2323 } | |
| 2324 | |
| 2325 #endif /* YAHOO_WEBMESSENGER */ | |
| 2326 | |
| 7883 | 2327 #ifndef YAHOO_WEBMESSENGER |
| 2328 static void yahoo_server_check(GaimAccount *account) | |
| 2329 { | |
| 2330 const char *server; | |
| 2331 | |
| 2332 server = gaim_account_get_string(account, "server", YAHOO_PAGER_HOST); | |
| 2333 | |
| 2334 if (strcmp(server, "scs.yahoo.com") == 0) | |
| 2335 gaim_account_set_string(account, "server", YAHOO_PAGER_HOST); | |
| 2336 } | |
| 9306 | 2337 |
| 2338 static void yahoo_picture_check(GaimAccount *account) | |
| 2339 { | |
| 2340 GaimConnection *gc = gaim_account_get_connection(account); | |
| 2341 const char *buddyicon; | |
| 2342 | |
| 2343 buddyicon = gaim_account_get_buddy_icon(account); | |
| 2344 yahoo_set_buddy_icon(gc, buddyicon); | |
| 2345 } | |
| 2346 | |
| 7883 | 2347 #endif |
| 2348 | |
| 5583 | 2349 static void yahoo_login(GaimAccount *account) { |
| 2350 GaimConnection *gc = gaim_account_get_connection(account); | |
| 2681 | 2351 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
| 2352 | |
| 9041 | 2353 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC; |
| 6629 | 2354 |
| 5583 | 2355 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
| 2681 | 2356 |
| 8235 | 2357 gaim_connection_set_display_name(gc, gaim_account_get_username(account)); |
| 2358 | |
| 2681 | 2359 yd->fd = -1; |
| 6784 | 2360 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
| 6729 | 2361 yd->confs = NULL; |
| 2362 yd->conf_id = 2; | |
| 2681 | 2363 |
| 7134 | 2364 #ifndef YAHOO_WEBMESSENGER |
| 7827 | 2365 |
| 7883 | 2366 yahoo_server_check(account); |
| 9306 | 2367 yahoo_picture_check(account); |
| 7883 | 2368 |
| 9164 | 2369 if (gaim_account_get_bool(account, "yahoojp", FALSE)) { |
| 2370 yd->jp = TRUE; | |
| 2371 if (gaim_proxy_connect(account, | |
| 2372 gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), | |
| 2373 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
| 2374 yahoo_got_connected, gc) != 0) | |
| 2375 { | |
| 2376 gaim_connection_error(gc, _("Connection problem")); | |
| 2377 return; | |
| 2378 } | |
| 2379 } else { | |
| 2380 yd->jp = FALSE; | |
| 2381 if (gaim_proxy_connect(account, | |
| 2382 gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), | |
| 2383 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
| 2384 yahoo_got_connected, gc) != 0) | |
| 2385 { | |
| 2386 gaim_connection_error(gc, _("Connection problem")); | |
| 2387 return; | |
| 2388 } | |
| 2681 | 2389 } |
| 7134 | 2390 #else |
|
7138
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2391 gaim_url_fetch(WEBMESSENGER_URL, TRUE, "Gaim/" VERSION, FALSE, |
|
f189f8ccaa98
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2392 yahoo_login_page_cb, gc); |
| 7134 | 2393 #endif |
| 2681 | 2394 |
| 2395 } | |
| 2396 | |
| 5583 | 2397 static void yahoo_close(GaimConnection *gc) { |
| 2681 | 2398 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 6729 | 2399 |
| 6784 | 2400 g_hash_table_destroy(yd->friends); |
| 6729 | 2401 g_slist_free(yd->confs); |
| 6784 | 2402 if (yd->chat_name) |
| 2403 g_free(yd->chat_name); | |
| 6729 | 2404 |
| 7651 | 2405 if (yd->cookie_y) |
| 2406 g_free(yd->cookie_y); | |
| 2407 if (yd->cookie_t) | |
| 2408 g_free(yd->cookie_t); | |
| 2409 | |
| 2681 | 2410 if (yd->fd >= 0) |
| 2411 close(yd->fd); | |
|
3720
34c95669952f
[gaim-migrate @ 3853]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3642
diff
changeset
|
2412 |
| 2681 | 2413 if (yd->rxqueue) |
| 2414 g_free(yd->rxqueue); | |
|
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2686
diff
changeset
|
2415 yd->rxlen = 0; |
| 9306 | 2416 if (yd->picture_url) |
| 2417 g_free(yd->picture_url); | |
| 2418 if (yd->picture_upload_todo) | |
| 2419 yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo); | |
| 2681 | 2420 if (gc->inpa) |
| 2421 gaim_input_remove(gc->inpa); | |
| 2422 g_free(yd); | |
| 2423 } | |
| 2424 | |
| 6695 | 2425 static const char *yahoo_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2681 | 2426 { |
| 4687 | 2427 return "yahoo"; |
| 2681 | 2428 } |
| 4916 | 2429 |
| 6695 | 2430 static void yahoo_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
| 4916 | 2431 { |
| 2432 int i = 0; | |
| 2433 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
| 6784 | 2434 GaimAccount *account; |
| 2435 GaimConnection *gc; | |
| 2436 struct yahoo_data *yd; | |
| 9278 | 2437 YahooFriend *f; |
| 6784 | 2438 |
| 2439 if (!b || !(account = b->account) || !(gc = gaim_account_get_connection(account)) || | |
| 2440 !(yd = gc->proto_data)) | |
| 2441 return; | |
| 2442 | |
| 9279 | 2443 f = yahoo_friend_find(gc, b->name); |
| 6784 | 2444 if (!f) { |
| 2445 *se = "notauthorized"; | |
| 2446 return; | |
| 2447 } | |
| 2448 | |
| 5068 | 2449 if (b->present == GAIM_BUDDY_OFFLINE) { |
| 4916 | 2450 *se = "offline"; |
| 2451 return; | |
| 2452 } else { | |
| 6784 | 2453 if (f->away) |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2454 emblems[i++] = "away"; |
| 6784 | 2455 if (f->sms) |
| 2456 emblems[i++] = "wireless"; | |
| 9283 | 2457 if (yahoo_friend_get_game(f)) |
| 4916 | 2458 emblems[i++] = "game"; |
| 2459 } | |
| 2460 *se = emblems[0]; | |
| 2461 *sw = emblems[1]; | |
| 2462 *nw = emblems[2]; | |
| 2463 *ne = emblems[3]; | |
| 2464 } | |
| 2681 | 2465 |
| 2466 static char *yahoo_get_status_string(enum yahoo_status a) | |
| 2467 { | |
| 2468 switch (a) { | |
| 2469 case YAHOO_STATUS_BRB: | |
| 4596 | 2470 return _("Be Right Back"); |
| 2681 | 2471 case YAHOO_STATUS_BUSY: |
| 4596 | 2472 return _("Busy"); |
| 2681 | 2473 case YAHOO_STATUS_NOTATHOME: |
| 4596 | 2474 return _("Not At Home"); |
| 2681 | 2475 case YAHOO_STATUS_NOTATDESK: |
| 4596 | 2476 return _("Not At Desk"); |
| 2681 | 2477 case YAHOO_STATUS_NOTINOFFICE: |
| 4596 | 2478 return _("Not In Office"); |
| 2681 | 2479 case YAHOO_STATUS_ONPHONE: |
| 4606 | 2480 return _("On The Phone"); |
| 2681 | 2481 case YAHOO_STATUS_ONVACATION: |
| 4596 | 2482 return _("On Vacation"); |
| 2681 | 2483 case YAHOO_STATUS_OUTTOLUNCH: |
| 4596 | 2484 return _("Out To Lunch"); |
| 2681 | 2485 case YAHOO_STATUS_STEPPEDOUT: |
| 4596 | 2486 return _("Stepped Out"); |
|
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
2487 case YAHOO_STATUS_INVISIBLE: |
| 4596 | 2488 return _("Invisible"); |
| 4730 | 2489 case YAHOO_STATUS_IDLE: |
| 2490 return _("Idle"); | |
| 6784 | 2491 case YAHOO_STATUS_OFFLINE: |
| 2492 return _("Offline"); | |
|
2879
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
2493 default: |
| 4596 | 2494 return _("Online"); |
| 2681 | 2495 } |
| 2496 } | |
| 2497 | |
| 9030 | 2498 static void yahoo_initiate_conference(GaimBlistNode *node, gpointer data) { |
| 2499 | |
| 2500 GaimBuddy *buddy; | |
| 2501 GaimConnection *gc; | |
| 2502 | |
| 6729 | 2503 GHashTable *components; |
| 2504 struct yahoo_data *yd; | |
| 2505 int id; | |
| 2506 | |
| 9030 | 2507 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
| 2508 | |
| 2509 buddy = (GaimBuddy *) node; | |
| 2510 gc = gaim_account_get_connection(buddy->account); | |
| 6729 | 2511 yd = gc->proto_data; |
| 2512 id = yd->conf_id; | |
| 2513 | |
| 2514 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 2515 g_hash_table_replace(components, g_strdup("room"), | |
| 2516 g_strdup_printf("%s-%d", gaim_connection_get_display_name(gc), id)); | |
| 2517 g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference...")); | |
| 2518 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | |
| 2519 yahoo_c_join(gc, components); | |
| 2520 g_hash_table_destroy(components); | |
| 2521 | |
| 9030 | 2522 yahoo_c_invite(gc, id, "Join my conference...", buddy->name); |
| 6729 | 2523 } |
| 2524 | |
| 9030 | 2525 static void yahoo_game(GaimBlistNode *node, gpointer data) { |
| 2526 | |
| 2527 GaimBuddy *buddy; | |
| 2528 GaimConnection *gc; | |
| 2529 | |
| 2530 struct yahoo_data *yd; | |
| 9283 | 2531 const char *game; |
| 2532 char *game2; | |
| 3019 | 2533 char *t; |
| 2534 char url[256]; | |
| 9278 | 2535 YahooFriend *f; |
| 3019 | 2536 |
| 9030 | 2537 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
| 2538 | |
| 2539 buddy = (GaimBuddy *) node; | |
| 2540 gc = gaim_account_get_connection(buddy->account); | |
| 2541 yd = (struct yahoo_data *) gc->proto_data; | |
| 2542 | |
| 9279 | 2543 f = yahoo_friend_find(gc, buddy->name); |
| 6784 | 2544 if (!f) |
| 2545 return; | |
| 2546 | |
| 9283 | 2547 game = yahoo_friend_get_game(f); |
| 3019 | 2548 if (!game) |
| 2549 return; | |
| 6784 | 2550 |
| 9283 | 2551 t = game2 = g_strdup(strstr(game, "ante?room=")); |
| 2552 while (*t && *t != '\t') | |
| 3019 | 2553 t++; |
| 2554 *t = 0; | |
| 9283 | 2555 g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game2); |
|
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
2556 gaim_notify_uri(gc, url); |
| 9283 | 2557 g_free(game2); |
| 3019 | 2558 } |
| 4722 | 2559 |
| 6695 | 2560 static char *yahoo_status_text(GaimBuddy *b) |
| 4722 | 2561 { |
| 9278 | 2562 YahooFriend *f = NULL; |
| 9283 | 2563 const char *msg; |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2564 |
| 9279 | 2565 f = yahoo_friend_find(b->account->gc, b->name); |
| 6784 | 2566 if (!f) |
| 2567 return g_strdup(_("Not on server list")); | |
| 2568 | |
| 2569 switch (f->status) { | |
| 2570 case YAHOO_STATUS_AVAILABLE: | |
| 2571 return NULL; | |
| 2572 case YAHOO_STATUS_IDLE: | |
| 2573 if (f->idle == -1) | |
| 2574 return g_strdup(yahoo_get_status_string(f->status)); | |
| 2575 return NULL; | |
| 2576 case YAHOO_STATUS_CUSTOM: | |
| 9283 | 2577 if (!(msg = yahoo_friend_get_status_message(f))) |
| 6784 | 2578 return NULL; |
| 9283 | 2579 return g_markup_escape_text(msg, strlen(msg)); |
| 9224 | 2580 |
| 6784 | 2581 default: |
| 2582 return g_strdup(yahoo_get_status_string(f->status)); | |
| 2583 } | |
| 4722 | 2584 } |
| 2585 | |
| 9220 | 2586 char *yahoo_tooltip_text(GaimBuddy *b) |
| 4724 | 2587 { |
| 9278 | 2588 YahooFriend *f; |
| 6784 | 2589 char *escaped, *status, *ret; |
| 2590 | |
| 9279 | 2591 f = yahoo_friend_find(b->account->gc, b->name); |
| 6784 | 2592 if (!f) |
| 8591 | 2593 status = g_strdup_printf("\n%s", _("Not on server list")); |
| 6784 | 2594 else |
| 2595 switch (f->status) { | |
| 2596 case YAHOO_STATUS_IDLE: | |
| 2597 if (f->idle == -1) { | |
| 2598 status = g_strdup(yahoo_get_status_string(f->status)); | |
| 2599 break; | |
| 2600 } | |
| 2601 return NULL; | |
| 2602 case YAHOO_STATUS_CUSTOM: | |
| 9283 | 2603 if (!yahoo_friend_get_status_message(f)) |
| 6784 | 2604 return NULL; |
| 9283 | 2605 status = g_strdup(yahoo_friend_get_status_message(f)); |
| 6784 | 2606 break; |
| 2607 default: | |
| 2608 status = g_strdup(yahoo_get_status_string(f->status)); | |
| 2609 break; | |
| 4745 | 2610 } |
| 6784 | 2611 |
| 2612 escaped = g_markup_escape_text(status, strlen(status)); | |
| 8591 | 2613 ret = g_strdup_printf(_("\n<b>%s:</b> %s"), _("Status"), escaped); |
| 6784 | 2614 g_free(status); |
| 2615 g_free(escaped); | |
| 2616 | |
| 2617 return ret; | |
| 4729 | 2618 } |
| 2619 | |
| 9030 | 2620 static void yahoo_addbuddyfrommenu_cb(GaimBlistNode *node, gpointer data) |
| 2621 { | |
| 2622 GaimBuddy *buddy; | |
| 2623 GaimConnection *gc; | |
| 2624 | |
| 2625 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 2626 | |
| 2627 buddy = (GaimBuddy *) node; | |
| 2628 gc = gaim_account_get_connection(buddy->account); | |
| 2629 | |
| 9285 | 2630 yahoo_add_buddy(gc, buddy, NULL); |
| 9030 | 2631 } |
| 2632 | |
| 2633 | |
| 2634 static void yahoo_chat_goto_menu(GaimBlistNode *node, gpointer data) | |
| 6796 | 2635 { |
| 9030 | 2636 GaimBuddy *buddy; |
| 2637 GaimConnection *gc; | |
| 2638 | |
| 2639 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 2640 | |
| 2641 buddy = (GaimBuddy *) node; | |
| 2642 gc = gaim_account_get_connection(buddy->account); | |
| 2643 | |
| 2644 yahoo_chat_goto(gc, buddy->name); | |
| 6796 | 2645 } |
| 2646 | |
| 9030 | 2647 |
| 2648 static void yahoo_ask_send_file_menu(GaimBlistNode *node, gpointer data) | |
| 2649 { | |
| 2650 GaimBuddy *buddy; | |
| 2651 GaimConnection *gc; | |
| 2652 | |
| 2653 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 2654 | |
| 2655 buddy = (GaimBuddy *) node; | |
| 2656 gc = gaim_account_get_connection(buddy->account); | |
| 2657 | |
| 2658 yahoo_ask_send_file(gc, buddy->name); | |
| 2659 } | |
| 2660 | |
| 2661 | |
| 2662 static GList *yahoo_buddy_menu(GaimBuddy *buddy) | |
| 2681 | 2663 { |
| 2664 GList *m = NULL; | |
| 9030 | 2665 GaimBlistNodeAction *act; |
| 2666 | |
| 2667 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
| 3019 | 2668 static char buf2[1024]; |
| 9278 | 2669 YahooFriend *f; |
| 6784 | 2670 |
| 9279 | 2671 f = yahoo_friend_find(gc, buddy->name); |
| 6784 | 2672 |
| 2673 if (!f) { | |
| 9030 | 2674 act = gaim_blist_node_action_new(_("Add Buddy"), |
| 2675 yahoo_addbuddyfrommenu_cb, NULL); | |
| 2676 m = g_list_append(m, act); | |
| 6784 | 2677 |
| 2678 return m; | |
| 9030 | 2679 |
| 2680 } else if (f->status == YAHOO_STATUS_OFFLINE) { | |
| 6784 | 2681 return NULL; |
| 9030 | 2682 } |
| 2683 | |
| 2684 act = gaim_blist_node_action_new(_("Join in Chat"), | |
| 2685 yahoo_chat_goto_menu, NULL); | |
| 2686 m = g_list_append(m, act); | |
| 2687 | |
| 2688 act = gaim_blist_node_action_new(_("Initiate Conference"), | |
| 2689 yahoo_initiate_conference, NULL); | |
| 2690 m = g_list_append(m, act); | |
| 6729 | 2691 |
| 7651 | 2692 /* FIXME: remove this when the ui does it for us. */ |
| 9030 | 2693 act = gaim_blist_node_action_new(_("Send File"), |
| 2694 yahoo_ask_send_file_menu, NULL); | |
| 2695 m = g_list_append(m, act); | |
| 7651 | 2696 |
| 9283 | 2697 if (yahoo_friend_get_game(f)) { |
| 2698 const char *game = yahoo_friend_get_game(f); | |
| 3019 | 2699 char *room; |
| 6784 | 2700 char *t; |
| 2701 | |
| 2702 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ | |
| 2703 return m; | |
| 2704 while (*room && *room != '\t') /* skip to the tab */ | |
| 2705 room++; | |
| 2706 t = room++; /* room as now at the name */ | |
| 2707 while (*t != '\n') | |
| 2708 t++; /* replace the \n with a space */ | |
| 2709 *t = ' '; | |
| 2710 g_snprintf(buf2, sizeof buf2, "%s", room); | |
| 9030 | 2711 |
| 2712 act = gaim_blist_node_action_new(buf2, yahoo_game, NULL); | |
| 2713 m = g_list_append(m, act); | |
| 3019 | 2714 } |
| 6729 | 2715 |
| 2681 | 2716 return m; |
| 2717 } | |
| 2718 | |
| 9030 | 2719 |
| 2720 static GList *yahoo_blist_node_menu(GaimBlistNode *node) | |
| 2721 { | |
| 2722 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
| 2723 return yahoo_buddy_menu((GaimBuddy *) node); | |
| 2724 } else { | |
| 2725 return NULL; | |
| 2726 } | |
| 2727 } | |
| 2728 | |
| 2729 | |
| 5583 | 2730 static void yahoo_act_id(GaimConnection *gc, const char *entry) |
| 2681 | 2731 { |
| 2732 struct yahoo_data *yd = gc->proto_data; | |
| 2733 | |
| 2734 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 2735 yahoo_packet_hash(pkt, 3, entry); | |
| 2736 yahoo_send_packet(yd, pkt); | |
| 2737 yahoo_packet_free(pkt); | |
| 2738 | |
| 5583 | 2739 gaim_connection_set_display_name(gc, entry); |
| 2681 | 2740 } |
| 2741 | |
| 9015 | 2742 static void yahoo_show_act_id(GaimPluginAction *action) |
| 2681 | 2743 { |
| 9015 | 2744 GaimConnection *gc = (GaimConnection *) action->context; |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2745 gaim_request_input(gc, NULL, _("Active which ID?"), NULL, |
| 8697 | 2746 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2747 _("OK"), G_CALLBACK(yahoo_act_id), |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2748 _("Cancel"), NULL, gc); |
| 2681 | 2749 } |
| 2750 | |
| 9015 | 2751 static void yahoo_show_chat_goto(GaimPluginAction *action) |
| 7878 | 2752 { |
| 9015 | 2753 GaimConnection *gc = (GaimConnection *) action->context; |
| 7878 | 2754 gaim_request_input(gc, NULL, _("Join who in chat?"), NULL, |
| 8697 | 2755 "", FALSE, FALSE, NULL, |
| 7878 | 2756 _("OK"), G_CALLBACK(yahoo_chat_goto), |
| 2757 _("Cancel"), NULL, gc); | |
| 2758 } | |
| 2759 | |
| 9015 | 2760 static GList *yahoo_actions(GaimPlugin *plugin, gpointer context) { |
| 2681 | 2761 GList *m = NULL; |
| 9015 | 2762 GaimPluginAction *act; |
| 2763 | |
| 2764 act = gaim_plugin_action_new(_("Activate ID..."), | |
| 2765 yahoo_show_act_id); | |
| 2766 m = g_list_append(m, act); | |
| 2767 | |
| 2768 act = gaim_plugin_action_new(_("Join user in chat..."), | |
| 2769 yahoo_show_chat_goto); | |
| 2770 m = g_list_append(m, act); | |
| 7878 | 2771 |
| 2681 | 2772 return m; |
| 2773 } | |
| 2774 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7112
diff
changeset
|
2775 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, GaimConvImFlags flags) |
| 2681 | 2776 { |
| 2777 struct yahoo_data *yd = gc->proto_data; | |
| 2778 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
| 6629 | 2779 char *msg = yahoo_html_to_codes(what); |
| 7827 | 2780 char *msg2; |
| 2781 gboolean utf8 = TRUE; | |
| 2782 | |
| 2783 msg2 = yahoo_string_encode(gc, msg, &utf8); | |
| 2681 | 2784 |
| 5583 | 2785 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 2681 | 2786 yahoo_packet_hash(pkt, 5, who); |
| 7827 | 2787 if (utf8) |
| 2788 yahoo_packet_hash(pkt, 97, "1"); | |
| 2789 yahoo_packet_hash(pkt, 14, msg2); | |
| 2790 | |
| 9280 | 2791 yahoo_packet_hash(pkt, 63, ";0"); /* IMvironment */ |
| 2792 yahoo_packet_hash(pkt, 64, "0"); /* no idea */ | |
| 9062 | 2793 yahoo_packet_hash(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */ |
| 9306 | 2794 if (!yd->picture_url) |
| 2795 yahoo_packet_hash(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */ | |
| 2796 else | |
| 2797 yahoo_packet_hash(pkt, 206, "2"); | |
| 2681 | 2798 |
| 2799 yahoo_send_packet(yd, pkt); | |
| 2800 | |
| 2801 yahoo_packet_free(pkt); | |
| 6629 | 2802 |
| 2803 g_free(msg); | |
| 7827 | 2804 g_free(msg2); |
| 6629 | 2805 |
| 2681 | 2806 return 1; |
| 2807 } | |
| 2808 | |
| 6059 | 2809 int yahoo_send_typing(GaimConnection *gc, const char *who, int typ) |
| 2993 | 2810 { |
| 2811 struct yahoo_data *yd = gc->proto_data; | |
| 3019 | 2812 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
| 2993 | 2813 yahoo_packet_hash(pkt, 49, "TYPING"); |
| 5583 | 2814 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 2993 | 2815 yahoo_packet_hash(pkt, 14, " "); |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
2816 yahoo_packet_hash(pkt, 13, typ == GAIM_TYPING ? "1" : "0"); |
| 2993 | 2817 yahoo_packet_hash(pkt, 5, who); |
| 2818 yahoo_packet_hash(pkt, 1002, "1"); | |
| 2819 | |
| 2820 yahoo_send_packet(yd, pkt); | |
| 2821 | |
| 2822 yahoo_packet_free(pkt); | |
| 2823 | |
| 3001 | 2824 return 0; |
| 2993 | 2825 } |
| 2826 | |
| 6059 | 2827 static void yahoo_set_away(GaimConnection *gc, const char *state, const char *msg) |
| 2681 | 2828 { |
| 2829 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 2830 struct yahoo_packet *pkt; | |
|
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2831 int service; |
| 2681 | 2832 char s[4]; |
| 7827 | 2833 char *conv_msg = NULL; |
| 8503 | 2834 char *conv_msg2 = NULL; |
|
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2835 |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2836 if (gc->away) { |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2837 g_free(gc->away); |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2838 gc->away = NULL; |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2839 } |
| 2681 | 2840 |
| 2841 if (msg) { | |
| 2842 yd->current_status = YAHOO_STATUS_CUSTOM; | |
| 6847 | 2843 gc->away = g_strndup(msg, YAHOO_MAX_STATUS_MESSAGE_LENGTH); |
| 2681 | 2844 } else if (state) { |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
2845 gc->away = g_strdup(""); |
| 4596 | 2846 if (!strcmp(state, _("Available"))) { |
| 2681 | 2847 yd->current_status = YAHOO_STATUS_AVAILABLE; |
| 4596 | 2848 } else if (!strcmp(state, _("Be Right Back"))) { |
| 2681 | 2849 yd->current_status = YAHOO_STATUS_BRB; |
| 4596 | 2850 } else if (!strcmp(state, _("Busy"))) { |
| 2681 | 2851 yd->current_status = YAHOO_STATUS_BUSY; |
| 4596 | 2852 } else if (!strcmp(state, _("Not At Home"))) { |
| 2681 | 2853 yd->current_status = YAHOO_STATUS_NOTATHOME; |
| 4596 | 2854 } else if (!strcmp(state, _("Not At Desk"))) { |
| 2681 | 2855 yd->current_status = YAHOO_STATUS_NOTATDESK; |
| 4596 | 2856 } else if (!strcmp(state, _("Not In Office"))) { |
| 2681 | 2857 yd->current_status = YAHOO_STATUS_NOTINOFFICE; |
| 4606 | 2858 } else if (!strcmp(state, _("On The Phone"))) { |
| 2681 | 2859 yd->current_status = YAHOO_STATUS_ONPHONE; |
| 4596 | 2860 } else if (!strcmp(state, _("On Vacation"))) { |
| 2681 | 2861 yd->current_status = YAHOO_STATUS_ONVACATION; |
| 4596 | 2862 } else if (!strcmp(state, _("Out To Lunch"))) { |
| 2681 | 2863 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; |
| 4596 | 2864 } else if (!strcmp(state, _("Stepped Out"))) { |
| 2681 | 2865 yd->current_status = YAHOO_STATUS_STEPPEDOUT; |
| 4596 | 2866 } else if (!strcmp(state, _("Invisible"))) { |
| 2681 | 2867 yd->current_status = YAHOO_STATUS_INVISIBLE; |
| 6847 | 2868 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { /* this should never happen? */ |
| 2681 | 2869 if (gc->is_idle) { |
| 2870 yd->current_status = YAHOO_STATUS_IDLE; | |
| 2871 } else { | |
| 2872 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 2873 } | |
| 2874 } | |
| 2875 } else if (gc->is_idle) { | |
| 2876 yd->current_status = YAHOO_STATUS_IDLE; | |
| 2877 } else { | |
| 2878 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 2879 } | |
| 2880 | |
|
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2881 if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
|
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2882 service = YAHOO_SERVICE_ISBACK; |
|
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2883 else |
|
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
2884 service = YAHOO_SERVICE_ISAWAY; |
| 6847 | 2885 |
| 2886 pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, 0); | |
| 2681 | 2887 g_snprintf(s, sizeof(s), "%d", yd->current_status); |
| 2888 yahoo_packet_hash(pkt, 10, s); | |
| 6847 | 2889 |
| 7827 | 2890 if ((yd->current_status == YAHOO_STATUS_CUSTOM) && gc->away) { |
| 2891 conv_msg = yahoo_string_encode(gc, gc->away, NULL); | |
| 8503 | 2892 conv_msg2 = gaim_unescape_html(conv_msg); |
| 2893 yahoo_packet_hash(pkt, 19, conv_msg2); | |
| 7827 | 2894 } |
| 6847 | 2895 |
| 2896 if ((yd->current_status != YAHOO_STATUS_AVAILABLE) && | |
| 2897 (yd->current_status != YAHOO_STATUS_IDLE)) { | |
| 6784 | 2898 if (gc->is_idle) |
| 2899 yahoo_packet_hash(pkt, 47, "2"); | |
| 2900 else | |
| 2901 yahoo_packet_hash(pkt, 47, "1"); | |
| 6686 | 2902 } |
| 2681 | 2903 |
| 2904 yahoo_send_packet(yd, pkt); | |
| 2905 yahoo_packet_free(pkt); | |
| 7827 | 2906 if (conv_msg) |
| 2907 g_free(conv_msg); | |
| 8503 | 2908 if (conv_msg2) |
| 2909 g_free(conv_msg2); | |
| 2681 | 2910 } |
| 2911 | |
| 5583 | 2912 static void yahoo_set_idle(GaimConnection *gc, int idle) |
| 2681 | 2913 { |
| 2914 struct yahoo_data *yd = gc->proto_data; | |
| 2915 struct yahoo_packet *pkt = NULL; | |
| 8503 | 2916 char *msg = NULL, *msg2 = NULL; |
| 2681 | 2917 |
| 2918 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
| 6847 | 2919 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); |
| 2681 | 2920 yd->current_status = YAHOO_STATUS_IDLE; |
| 2921 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
| 2922 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
| 2923 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 6847 | 2924 } else { |
| 6784 | 2925 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); |
| 2681 | 2926 } |
| 2927 | |
| 2928 if (pkt) { | |
| 2929 char buf[4]; | |
| 2930 g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
| 2931 yahoo_packet_hash(pkt, 10, buf); | |
| 6784 | 2932 if (gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) { |
| 7827 | 2933 msg = yahoo_string_encode(gc, gc->away, NULL); |
| 8503 | 2934 msg2 = gaim_unescape_html(msg); |
| 2935 yahoo_packet_hash(pkt, 19, msg2); | |
| 6784 | 2936 if (idle) |
| 2937 yahoo_packet_hash(pkt, 47, "2"); | |
| 2938 else | |
| 2939 yahoo_packet_hash(pkt, 47, "1"); /* fixme when available messages are possible */ | |
| 6847 | 2940 } else if (idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) && |
| 2941 (yd->current_status != YAHOO_STATUS_IDLE)) { | |
| 2942 yahoo_packet_hash(pkt, 47, "2"); | |
| 2943 } else if (!idle && (yd->current_status != YAHOO_STATUS_AVAILABLE) && | |
| 2944 (yd->current_status != YAHOO_STATUS_IDLE)) { | |
| 2945 yahoo_packet_hash(pkt, 47, "1"); | |
| 6784 | 2946 } |
| 6847 | 2947 |
| 2681 | 2948 yahoo_send_packet(yd, pkt); |
| 2949 yahoo_packet_free(pkt); | |
| 2950 } | |
| 7827 | 2951 if (msg) |
| 2952 g_free(msg); | |
| 8503 | 2953 if (msg2) |
| 2954 g_free(msg2); | |
| 2681 | 2955 } |
| 2956 | |
| 5583 | 2957 static GList *yahoo_away_states(GaimConnection *gc) |
| 2681 | 2958 { |
| 2959 GList *m = NULL; | |
| 2960 | |
| 4596 | 2961 m = g_list_append(m, _("Available")); |
| 2962 m = g_list_append(m, _("Be Right Back")); | |
| 2963 m = g_list_append(m, _("Busy")); | |
| 2964 m = g_list_append(m, _("Not At Home")); | |
| 2965 m = g_list_append(m, _("Not At Desk")); | |
| 2966 m = g_list_append(m, _("Not In Office")); | |
| 4606 | 2967 m = g_list_append(m, _("On The Phone")); |
| 4596 | 2968 m = g_list_append(m, _("On Vacation")); |
| 2969 m = g_list_append(m, _("Out To Lunch")); | |
| 2970 m = g_list_append(m, _("Stepped Out")); | |
| 2971 m = g_list_append(m, _("Invisible")); | |
| 2681 | 2972 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
| 2973 | |
| 2974 return m; | |
| 2975 } | |
| 2976 | |
| 5583 | 2977 static void yahoo_keepalive(GaimConnection *gc) |
| 2681 | 2978 { |
| 2979 struct yahoo_data *yd = gc->proto_data; | |
| 2980 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
| 2981 yahoo_send_packet(yd, pkt); | |
| 2982 yahoo_packet_free(pkt); | |
| 6729 | 2983 |
| 2984 if (!yd->chat_online) | |
| 2985 return; | |
| 2986 | |
| 2987 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); | |
| 2988 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); | |
| 2989 yahoo_send_packet(yd, pkt); | |
| 2990 yahoo_packet_free(pkt); | |
| 2681 | 2991 } |
| 2992 | |
| 9285 | 2993 /* XXX - What's the deal with GaimGroup *foo? */ |
| 2994 static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *foo) | |
| 2681 | 2995 { |
| 2996 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 2997 struct yahoo_packet *pkt; | |
| 6695 | 2998 GaimGroup *g; |
| 2681 | 2999 char *group = NULL; |
| 7829 | 3000 char *group2 = NULL; |
| 2681 | 3001 |
| 3002 if (!yd->logged_in) | |
| 3003 return; | |
| 3004 | |
| 6840 | 3005 if (foo) |
| 3006 group = foo->name; | |
| 3007 if (!group) { | |
| 9285 | 3008 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, buddy->name)); |
| 6840 | 3009 if (g) |
| 3010 group = g->name; | |
| 3011 else | |
| 3012 group = "Buddies"; | |
| 3013 } | |
| 2681 | 3014 |
| 7829 | 3015 group2 = yahoo_string_encode(gc, group, NULL); |
| 2681 | 3016 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
| 5583 | 3017 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 9285 | 3018 yahoo_packet_hash(pkt, 7, buddy->name); |
| 7829 | 3019 yahoo_packet_hash(pkt, 65, group2); |
| 6820 | 3020 yahoo_packet_hash(pkt, 14, ""); |
| 2681 | 3021 yahoo_send_packet(yd, pkt); |
| 3022 yahoo_packet_free(pkt); | |
| 7829 | 3023 g_free(group2); |
| 2681 | 3024 } |
| 3025 | |
| 9285 | 3026 static void yahoo_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 2681 | 3027 { |
| 3028 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 9278 | 3029 YahooFriend *f; |
|
6795
40ba19133882
[gaim-migrate @ 7334]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6793
diff
changeset
|
3030 struct yahoo_packet *pkt; |
| 6840 | 3031 GSList *buddies, *l; |
| 3032 GaimGroup *g; | |
| 3033 gboolean remove = TRUE; | |
| 7827 | 3034 char *cg; |
| 6784 | 3035 |
| 9285 | 3036 if (!(f = yahoo_friend_find(gc, buddy->name))) |
| 6784 | 3037 return; |
| 3038 | |
| 9285 | 3039 buddies = gaim_find_buddies(gaim_connection_get_account(gc), buddy->name); |
| 6840 | 3040 for (l = buddies; l; l = l->next) { |
| 3041 g = gaim_find_buddys_group(l->data); | |
| 9285 | 3042 if (gaim_utf8_strcasecmp(group->name, g->name)) { |
| 6840 | 3043 remove = FALSE; |
| 3044 break; | |
| 3045 } | |
| 3046 } | |
| 3047 | |
| 3048 g_slist_free(buddies); | |
| 3049 | |
| 3050 if (remove) | |
| 9285 | 3051 g_hash_table_remove(yd->friends, buddy->name); |
| 3052 | |
| 3053 cg = yahoo_string_encode(gc, group->name, NULL); | |
|
6795
40ba19133882
[gaim-migrate @ 7334]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6793
diff
changeset
|
3054 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
| 5583 | 3055 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 9285 | 3056 yahoo_packet_hash(pkt, 7, buddy->name); |
| 7827 | 3057 yahoo_packet_hash(pkt, 65, cg); |
| 2681 | 3058 yahoo_send_packet(yd, pkt); |
| 3059 yahoo_packet_free(pkt); | |
| 7827 | 3060 g_free(cg); |
| 2681 | 3061 } |
| 3062 | |
| 6760 | 3063 static void yahoo_add_deny(GaimConnection *gc, const char *who) { |
| 3064 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 3065 struct yahoo_packet *pkt; | |
| 3066 | |
| 3067 if (!yd->logged_in) | |
| 3068 return; | |
| 8057 | 3069 /* It seems to work better without this */ |
| 3070 | |
| 8113 | 3071 /* if (gc->account->perm_deny != 4) |
| 3072 return; */ | |
| 3073 | |
| 3074 if (!who || who[0] == '\0') | |
| 3075 return; | |
| 3076 | |
| 6760 | 3077 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); |
| 3078 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 3079 yahoo_packet_hash(pkt, 7, who); | |
| 3080 yahoo_packet_hash(pkt, 13, "1"); | |
| 3081 yahoo_send_packet(yd, pkt); | |
| 3082 yahoo_packet_free(pkt); | |
| 3083 } | |
| 3084 | |
| 3085 static void yahoo_rem_deny(GaimConnection *gc, const char *who) { | |
| 3086 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 3087 struct yahoo_packet *pkt; | |
| 3088 | |
| 3089 if (!yd->logged_in) | |
| 3090 return; | |
| 3091 | |
| 3092 if (!who || who[0] == '\0') | |
| 3093 return; | |
| 3094 | |
| 3095 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 3096 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 3097 yahoo_packet_hash(pkt, 7, who); | |
| 3098 yahoo_packet_hash(pkt, 13, "2"); | |
| 3099 yahoo_send_packet(yd, pkt); | |
| 3100 yahoo_packet_free(pkt); | |
| 3101 } | |
| 3102 | |
| 3103 static void yahoo_set_permit_deny(GaimConnection *gc) { | |
| 3104 GaimAccount *acct; | |
| 3105 GSList *deny; | |
| 3106 | |
| 3107 acct = gc->account; | |
| 3108 | |
| 3109 switch (acct->perm_deny) { | |
| 3110 case 1: | |
| 3111 case 3: | |
| 3112 case 5: | |
| 3113 for (deny = acct->deny;deny;deny = deny->next) | |
| 3114 yahoo_rem_deny(gc, deny->data); | |
| 3115 break; | |
| 3116 case 4: | |
| 3117 for (deny = acct->deny;deny;deny = deny->next) | |
| 3118 yahoo_add_deny(gc, deny->data); | |
| 3119 break; | |
| 3120 case 2: | |
| 3121 default: | |
| 3122 break; | |
| 3123 } | |
| 3124 } | |
| 3125 | |
| 6513 | 3126 static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
| 3127 { | |
| 3128 yahoo_dest_colorht(); | |
| 3129 return TRUE; | |
| 3130 } | |
| 3131 | |
| 6793 | 3132 static void yahoo_change_buddys_group(GaimConnection *gc, const char *who, |
| 3133 const char *old_group, const char *new_group) | |
| 3134 { | |
| 3135 struct yahoo_data *yd = gc->proto_data; | |
| 3136 struct yahoo_packet *pkt; | |
| 7827 | 3137 char *gpn, *gpo; |
| 6793 | 3138 |
| 3139 /* Step 0: If they aren't on the server list anyway, | |
| 3140 * don't bother letting the server know. | |
| 3141 */ | |
| 9279 | 3142 if (!yahoo_friend_find(gc, who)) |
| 6793 | 3143 return; |
| 3144 | |
| 7827 | 3145 /* If old and new are the same, we would probably |
| 3146 * end up deleting the buddy, which would be bad. | |
| 3147 * This might happen because of the charset conversation. | |
| 3148 */ | |
| 3149 gpn = yahoo_string_encode(gc, new_group, NULL); | |
| 3150 gpo = yahoo_string_encode(gc, old_group, NULL); | |
| 3151 if (!strcmp(gpn, gpo)) { | |
| 3152 g_free(gpn); | |
| 3153 g_free(gpo); | |
| 3154 return; | |
| 3155 } | |
| 3156 | |
| 6793 | 3157 /* Step 1: Add buddy to new group. */ |
| 3158 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 3159 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 3160 yahoo_packet_hash(pkt, 7, who); | |
| 7827 | 3161 yahoo_packet_hash(pkt, 65, gpn); |
| 6793 | 3162 yahoo_packet_hash(pkt, 14, ""); |
| 3163 yahoo_send_packet(yd, pkt); | |
| 3164 yahoo_packet_free(pkt); | |
| 3165 | |
| 3166 /* Step 2: Remove buddy from old group */ | |
| 3167 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 3168 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 3169 yahoo_packet_hash(pkt, 7, who); | |
| 7827 | 3170 yahoo_packet_hash(pkt, 65, gpo); |
| 6793 | 3171 yahoo_send_packet(yd, pkt); |
| 3172 yahoo_packet_free(pkt); | |
| 7827 | 3173 g_free(gpn); |
| 3174 g_free(gpo); | |
| 6793 | 3175 } |
| 3176 | |
| 9285 | 3177 static void yahoo_rename_group(GaimConnection *gc, const char *old_name, |
| 3178 GaimGroup *group, GList *moved_buddies) | |
| 6793 | 3179 { |
| 3180 struct yahoo_data *yd = gc->proto_data; | |
| 3181 struct yahoo_packet *pkt; | |
| 7827 | 3182 char *gpn, *gpo; |
| 3183 | |
| 9285 | 3184 gpn = yahoo_string_encode(gc, group->name, NULL); |
| 3185 gpo = yahoo_string_encode(gc, old_name, NULL); | |
| 7827 | 3186 if (!strcmp(gpn, gpo)) { |
| 3187 g_free(gpn); | |
| 3188 g_free(gpo); | |
| 3189 return; | |
| 3190 } | |
| 6793 | 3191 |
| 3192 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); | |
| 3193 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
| 7827 | 3194 yahoo_packet_hash(pkt, 65, gpo); |
| 3195 yahoo_packet_hash(pkt, 67, gpn); | |
| 6793 | 3196 yahoo_send_packet(yd, pkt); |
| 3197 yahoo_packet_free(pkt); | |
| 7827 | 3198 g_free(gpn); |
| 3199 g_free(gpo); | |
| 6793 | 3200 } |
| 3201 | |
| 7696 | 3202 #if 0 |
| 7651 | 3203 static gboolean yahoo_has_send_file(GaimConnection *gc, const char *who) |
| 3204 { | |
| 3205 return TRUE; | |
| 3206 } | |
| 7696 | 3207 #endif |
| 7651 | 3208 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3209 static GaimPlugin *my_protocol = NULL; |
| 2681 | 3210 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3211 static GaimPluginProtocolInfo prpl_info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3212 { |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
3213 GAIM_PRPL_API_VERSION, |
| 9308 | 3214 OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, |
| 6729 | 3215 NULL, /* user_splits */ |
| 3216 NULL, /* protocol_options */ | |
| 9318 | 3217 {"png", 96, 96, 96, 96, GAIM_ICON_SCALE_SEND}, |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3218 yahoo_list_icon, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3219 yahoo_list_emblems, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3220 yahoo_status_text, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3221 yahoo_tooltip_text, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3222 yahoo_away_states, |
| 9030 | 3223 yahoo_blist_node_menu, |
| 6729 | 3224 yahoo_c_info, |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3225 yahoo_login, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3226 yahoo_close, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3227 yahoo_send_im, |
| 6729 | 3228 NULL, /* set info */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3229 yahoo_send_typing, |
| 6514 | 3230 yahoo_get_info, |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3231 yahoo_set_away, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3232 yahoo_set_idle, |
| 6729 | 3233 NULL, /* change_passwd*/ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3234 yahoo_add_buddy, |
| 6729 | 3235 NULL, /* add_buddies */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3236 yahoo_remove_buddy, |
| 6729 | 3237 NULL, /*remove_buddies */ |
| 3238 NULL, /* add_permit */ | |
| 6760 | 3239 yahoo_add_deny, |
| 6729 | 3240 NULL, /* rem_permit */ |
| 6760 | 3241 yahoo_rem_deny, |
| 3242 yahoo_set_permit_deny, | |
| 6729 | 3243 NULL, /* warn */ |
| 3244 yahoo_c_join, | |
| 8562 | 3245 NULL, /* reject chat invite */ |
| 6729 | 3246 yahoo_c_invite, |
| 3247 yahoo_c_leave, | |
| 3248 NULL, /* chat whisper */ | |
| 3249 yahoo_c_send, | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3250 yahoo_keepalive, |
| 6729 | 3251 NULL, /* register_user */ |
| 3252 NULL, /* get_cb_info */ | |
| 3253 NULL, /* get_cb_away */ | |
| 3254 NULL, /* alias_buddy */ | |
| 6793 | 3255 yahoo_change_buddys_group, |
| 3256 yahoo_rename_group, | |
| 6729 | 3257 NULL, /* buddy_free */ |
| 3258 NULL, /* convo_closed */ | |
| 3259 NULL, /* normalize */ | |
| 9306 | 3260 yahoo_set_buddy_icon, |
| 7651 | 3261 NULL, /* void (*remove_group)(GaimConnection *gc, const char *group);*/ |
| 3262 NULL, /* char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); */ | |
| 3263 #if 0 | |
| 3264 yahoo_ask_send_file, | |
| 3265 yahoo_send_file, | |
| 8113 | 3266 yahoo_has_send_file, |
| 7651 | 3267 #endif |
| 8113 | 3268 NULL, |
| 3269 NULL, | |
| 3270 yahoo_roomlist_get_list, | |
| 3271 yahoo_roomlist_cancel, | |
| 9030 | 3272 yahoo_roomlist_expand_category |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3273 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3274 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3275 static GaimPluginInfo info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3276 { |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
3277 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3278 GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3279 NULL, /**< ui_requirement */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3280 0, /**< flags */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3281 NULL, /**< dependencies */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3282 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3283 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3284 "prpl-yahoo", /**< id */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3285 "Yahoo", /**< name */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3286 VERSION, /**< version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3287 /** summary */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3288 N_("Yahoo Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3289 /** description */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3290 N_("Yahoo Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3291 NULL, /**< author */ |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
3292 GAIM_WEBSITE, /**< homepage */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3293 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3294 NULL, /**< load */ |
| 6513 | 3295 yahoo_unload_plugin, /**< unload */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3296 NULL, /**< destroy */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3297 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3298 NULL, /**< ui_info */ |
| 8993 | 3299 &prpl_info, /**< extra_info */ |
| 3300 NULL, | |
| 9015 | 3301 yahoo_actions |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3302 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3303 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3304 static void |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
3305 init_plugin(GaimPlugin *plugin) |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3306 { |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
3307 GaimAccountOption *option; |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3308 |
| 9164 | 3309 option = gaim_account_option_bool_new(_("Yahoo Japan"), "yahoojp", FALSE); |
| 3310 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3311 | |
| 7827 | 3312 option = gaim_account_option_string_new(_("Pager host"), "server", YAHOO_PAGER_HOST); |
| 3313 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3314 | |
| 9164 | 3315 option = gaim_account_option_string_new(_("Japan Pager host"), "serverjp", YAHOOJP_PAGER_HOST); |
| 3316 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3317 | |
| 7827 | 3318 option = gaim_account_option_int_new(_("Pager port"), "port", YAHOO_PAGER_PORT); |
| 3319 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 7651 | 3320 |
| 3321 option = gaim_account_option_string_new(_("File transfer host"), "xfer_host", YAHOO_XFER_HOST); | |
| 3322 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3323 | |
| 9164 | 3324 option = gaim_account_option_string_new(_("Japan File transfer host"), "xferjp_host", YAHOOJP_XFER_HOST); |
| 3325 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3326 | |
| 7651 | 3327 option = gaim_account_option_int_new(_("File transfer port"), "xfer_port", YAHOO_XFER_PORT); |
| 3328 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3329 | |
| 8113 | 3330 option = gaim_account_option_string_new(_("Chat Room List Url"), "room_list", YAHOO_ROOMLIST_URL); |
| 3331 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3332 | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3333 my_protocol = plugin; |
| 6513 | 3334 |
| 3335 yahoo_init_colorht(); | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3336 } |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3337 |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
3338 GAIM_INIT_PLUGIN(yahoo, init_plugin, info); |
