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