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