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