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