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