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