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