Mercurial > pidgin.yaz
annotate src/protocols/yahoo/yahoo.c @ 6791:9927df765fae
[gaim-migrate @ 7330]
compiling is a good thing
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 08 Sep 2003 03:03:53 +0000 |
parents | faa491042c66 |
children | 62aec9fd7aca |
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" |
6115
11bedb793a44
[gaim-migrate @ 6578]
Christian Hammond <chipx86@chipx86.com>
parents:
6069
diff
changeset
|
36 #include "html.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
37 |
6513 | 38 #include "yahoo.h" |
6729 | 39 #include "yahoochat.h" |
3147 | 40 #include "md5.h" |
2681 | 41 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
42 /* XXX */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
43 #include "gtkinternal.h" |
6546 | 44 #include "gaim.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
45 #include "ui.h" |
3630 | 46 |
5583 | 47 extern char *yahoo_crypt(const char *, const char *); |
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
48 |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
49 /* #define YAHOO_DEBUG */ |
2681 | 50 |
51 #define USEROPT_MAIL 0 | |
52 | |
3147 | 53 #define YAHOO_PAGER_HOST "scs.yahoo.com" |
2681 | 54 #define YAHOO_PAGER_PORT 5050 |
6514 | 55 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/" |
2681 | 56 |
3467 | 57 #define YAHOO_PROTO_VER 0x0900 |
58 | |
2681 | 59 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) |
60 | |
6791 | 61 static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *); |
6784 | 62 |
63 static struct yahoo_friend *yahoo_friend_new() | |
64 { | |
65 struct yahoo_friend *ret; | |
66 | |
67 ret = g_new0(struct yahoo_friend, 1); | |
68 ret->status = YAHOO_STATUS_OFFLINE; | |
69 | |
70 return ret; | |
71 } | |
72 | |
73 static void yahoo_friend_free(gpointer p) | |
74 { | |
75 struct yahoo_friend *f = p; | |
76 if (f->msg) | |
77 g_free(f->msg); | |
78 if (f->game) | |
79 g_free(f->game); | |
80 g_free(f); | |
81 } | |
82 | |
6729 | 83 struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) |
2681 | 84 { |
85 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); | |
86 | |
87 pkt->service = service; | |
88 pkt->status = status; | |
89 pkt->id = id; | |
90 | |
91 return pkt; | |
92 } | |
93 | |
6729 | 94 void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value) |
2681 | 95 { |
96 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
97 pair->key = key; | |
98 pair->value = g_strdup(value); | |
99 pkt->hash = g_slist_append(pkt->hash, pair); | |
100 } | |
101 | |
102 static int yahoo_packet_length(struct yahoo_packet *pkt) | |
103 { | |
104 GSList *l; | |
105 | |
106 int len = 0; | |
107 | |
108 l = pkt->hash; | |
109 while (l) { | |
110 struct yahoo_pair *pair = l->data; | |
111 int tmp = pair->key; | |
112 do { | |
113 tmp /= 10; | |
114 len++; | |
115 } while (tmp); | |
116 len += 2; | |
117 len += strlen(pair->value); | |
118 len += 2; | |
119 l = l->next; | |
120 } | |
121 | |
122 return len; | |
123 } | |
124 | |
125 /* sometimes i wish prpls could #include things from other prpls. then i could just | |
126 * use the routines from libfaim and not have to admit to knowing how they work. */ | |
127 #define yahoo_put16(buf, data) ( \ | |
128 (*(buf) = (u_char)((data)>>8)&0xff), \ | |
129 (*((buf)+1) = (u_char)(data)&0xff), \ | |
130 2) | |
131 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
132 #define yahoo_put32(buf, data) ( \ | |
133 (*((buf)) = (u_char)((data)>>24)&0xff), \ | |
134 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ | |
135 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ | |
136 (*((buf)+3) = (u_char)(data)&0xff), \ | |
137 4) | |
138 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
139 (((*((buf)+1))<<16)&0x00ff0000) + \ | |
140 (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
141 (((*((buf)+3) )&0x000000ff))) | |
142 | |
143 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) | |
144 { | |
145 int pos = 0; | |
146 | |
147 while (pos + 1 < len) { | |
6629 | 148 char key[64], *value = NULL, *esc; |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
149 int accept; |
2681 | 150 int x; |
151 | |
152 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
153 | |
154 x = 0; | |
155 while (pos + 1 < len) { | |
156 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
157 break; | |
158 key[x++] = data[pos++]; | |
159 } | |
160 key[x] = 0; | |
161 pos += 2; | |
162 pair->key = strtol(key, NULL, 10); | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
163 accept = x; /* if x is 0 there was no key, so don't accept it */ |
2681 | 164 |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
165 if (len - pos + 1 <= 0) { |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
166 /* Truncated. Garbage or something. */ |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
167 accept = 0; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
168 } |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
169 |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
170 if (accept) { |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
171 value = g_malloc(len - pos + 1); |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
172 x = 0; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
173 while (pos + 1 < len) { |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
174 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
175 break; |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
176 value[x++] = data[pos++]; |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
177 } |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
178 value[x] = 0; |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
179 pair->value = g_strdup(value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
180 g_free(value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
181 pkt->hash = g_slist_append(pkt->hash, pair); |
6629 | 182 esc = g_strescape(pair->value, NULL); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
183 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
6629 | 184 "Key: %d \tValue: %s\n", pair->key, esc); |
185 g_free(esc); | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
186 } else { |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
187 g_free(pair); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
188 } |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
189 pos += 2; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
190 |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
191 /* Skip over garbage we've noticed in the mail notifications */ |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
192 if (data[0] == '9' && data[pos] == 0x01) |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
193 pos++; |
2681 | 194 } |
195 } | |
196 | |
197 static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) | |
198 { | |
199 GSList *l = pkt->hash; | |
200 int pos = 0; | |
201 | |
202 while (l) { | |
203 struct yahoo_pair *pair = l->data; | |
204 guchar buf[100]; | |
205 | |
206 g_snprintf(buf, sizeof(buf), "%d", pair->key); | |
207 strcpy(data + pos, buf); | |
208 pos += strlen(buf); | |
209 data[pos++] = 0xc0; | |
210 data[pos++] = 0x80; | |
211 | |
212 strcpy(data + pos, pair->value); | |
213 pos += strlen(pair->value); | |
214 data[pos++] = 0xc0; | |
215 data[pos++] = 0x80; | |
216 | |
217 l = l->next; | |
218 } | |
219 } | |
220 | |
221 static void yahoo_packet_dump(guchar *data, int len) | |
222 { | |
223 #ifdef YAHOO_DEBUG | |
224 int i; | |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
225 |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
226 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
227 |
2681 | 228 for (i = 0; i + 1 < len; i += 2) { |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
229 if ((i % 16 == 0) && i) { |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
230 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
231 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
232 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
233 |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
234 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]); |
2681 | 235 } |
236 if (i < len) | |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
237 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]); |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
238 |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
239 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
240 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
241 |
2681 | 242 for (i = 0; i < len; i++) { |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
243 if ((i % 16 == 0) && i) { |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
244 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
245 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
246 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
247 |
6686 | 248 if (g_ascii_isprint(data[i])) |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
249 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]); |
2681 | 250 else |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
251 gaim_debug(GAIM_DEBUG_MISC, NULL, ". "); |
2681 | 252 } |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
253 |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
254 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
2681 | 255 #endif |
256 } | |
257 | |
6729 | 258 int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt) |
2681 | 259 { |
260 int pktlen = yahoo_packet_length(pkt); | |
261 int len = YAHOO_PACKET_HDRLEN + pktlen; | |
262 int ret; | |
263 | |
264 guchar *data; | |
265 int pos = 0; | |
266 | |
267 if (yd->fd < 0) | |
268 return -1; | |
269 | |
270 data = g_malloc0(len + 1); | |
271 | |
272 memcpy(data + pos, "YMSG", 4); pos += 4; | |
3467 | 273 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); |
2681 | 274 pos += yahoo_put16(data + pos, 0x0000); |
275 pos += yahoo_put16(data + pos, pktlen); | |
276 pos += yahoo_put16(data + pos, pkt->service); | |
277 pos += yahoo_put32(data + pos, pkt->status); | |
278 pos += yahoo_put32(data + pos, pkt->id); | |
279 | |
280 yahoo_packet_write(pkt, data + pos); | |
281 | |
282 yahoo_packet_dump(data, len); | |
283 ret = write(yd->fd, data, len); | |
284 g_free(data); | |
285 | |
286 return ret; | |
287 } | |
288 | |
6729 | 289 void yahoo_packet_free(struct yahoo_packet *pkt) |
2681 | 290 { |
291 while (pkt->hash) { | |
292 struct yahoo_pair *pair = pkt->hash->data; | |
293 g_free(pair->value); | |
294 g_free(pair); | |
295 pkt->hash = g_slist_remove(pkt->hash, pair); | |
296 } | |
297 g_free(pkt); | |
298 } | |
299 | |
6784 | 300 static void yahoo_update_status(GaimConnection *gc, const char *name, struct yahoo_friend *f) |
301 { | |
302 if (!gc || !name || !f || !gaim_find_buddy(gaim_connection_get_account(gc), name)) | |
303 return; | |
304 | |
305 serv_got_update(gc, name, 1, 0, 0, f->idle, f->away ? UC_UNAVAILABLE : 0); | |
306 } | |
307 | |
5583 | 308 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 309 { |
310 struct yahoo_data *yd = gc->proto_data; | |
311 GSList *l = pkt->hash; | |
6784 | 312 struct yahoo_friend *f = NULL; |
2681 | 313 char *name = NULL; |
6784 | 314 |
6686 | 315 |
2681 | 316 while (l) { |
317 struct yahoo_pair *pair = l->data; | |
318 | |
319 switch (pair->key) { | |
320 case 0: /* we won't actually do anything with this */ | |
321 break; | |
322 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
|
323 if (!yd->logged_in) { |
5583 | 324 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
325 serv_finish_login(gc); |
5583 | 326 gaim_connection_set_display_name(gc, pair->value); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
327 yd->logged_in = TRUE; |
2681 | 328 |
3147 | 329 /* this requests the list. i have a feeling that this is very evil |
330 * | |
6686 | 331 * scs.yahoo.com sends you the list before this packet without it being |
3147 | 332 * requested |
333 * | |
334 * do_import(gc, NULL); | |
335 * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); | |
336 * yahoo_send_packet(yd, newpkt); | |
337 * yahoo_packet_free(newpkt); | |
338 */ | |
339 | |
340 } | |
2681 | 341 break; |
342 case 8: /* how many online buddies we have */ | |
343 break; | |
344 case 7: /* the current buddy */ | |
345 name = pair->value; | |
6784 | 346 f = g_hash_table_lookup(yd->friends, name); |
347 if (!f) { | |
348 f = yahoo_friend_new(); | |
349 g_hash_table_insert(yd->friends, g_strdup(name), f); | |
350 } | |
2681 | 351 break; |
352 case 10: /* state */ | |
6784 | 353 if (!f) |
354 break; | |
355 | |
356 f->status = strtol(pair->value, NULL, 10); | |
357 if ((f->status >= YAHOO_STATUS_BRB) && (f->status <= YAHOO_STATUS_STEPPEDOUT)) | |
358 f->away = 1; | |
359 else | |
360 f->away = 0; | |
361 if (f->status == YAHOO_STATUS_IDLE) | |
362 f->idle = time(NULL); | |
363 if (f->status != YAHOO_STATUS_CUSTOM) { | |
364 g_free(f->msg); | |
365 f->msg = NULL; | |
366 } | |
367 if (f->status == YAHOO_STATUS_AVAILABLE) | |
368 f->idle = 0; | |
2681 | 369 break; |
370 case 19: /* custom message */ | |
6784 | 371 if (f) { |
372 if (f->msg) | |
373 g_free(f->msg); | |
374 f->msg = g_strdup(pair->value); | |
375 } | |
2681 | 376 break; |
6686 | 377 case 11: /* this is the buddy's session id */ |
2681 | 378 break; |
379 case 17: /* in chat? */ | |
380 break; | |
6784 | 381 case 47: /* is custom status away or not? 2=idle*/ |
382 if (!f) | |
383 break; | |
384 f->away = strtol(pair->value, NULL, 10); | |
385 if (f->away == 2) | |
386 f->idle = time(NULL); | |
6686 | 387 break; |
6784 | 388 case 138: /* either we're not idle, or we are but won't say how long */ |
389 if (!f) | |
390 break; | |
391 | |
392 if (f->idle) | |
393 f->idle = -1; | |
394 break; | |
395 case 137: /* usually idle time in seconds, sometimes login time */ | |
396 if (!f) | |
397 break; | |
398 | |
399 if (f->status != YAHOO_STATUS_AVAILABLE) | |
400 f->idle = time(NULL) - strtol(pair->value, NULL, 10); | |
6686 | 401 break; |
402 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ | |
6784 | 403 if (strtol(pair->value, NULL, 10) == 0) { |
404 if (f) | |
405 f->status = YAHOO_STATUS_OFFLINE; | |
4732 | 406 serv_got_update(gc, name, 0, 0, 0, 0, 0); |
2807
f01e6a425136
[gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2805
diff
changeset
|
407 break; |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
408 } |
6784 | 409 |
410 if (f) | |
411 yahoo_update_status(gc, name, f); | |
412 break; | |
413 case 60: /* SMS */ | |
414 if (f) { | |
415 f->sms = strtol(pair->value, NULL, 10); | |
416 yahoo_update_status(gc, name, f); | |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
417 } |
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
418 break; |
2979 | 419 case 16: /* Custom error message */ |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
420 gaim_notify_error(gc, NULL, pair->value, NULL); |
2951 | 421 break; |
2681 | 422 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
423 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
424 "Unknown status key %d\n", pair->key); |
2681 | 425 break; |
426 } | |
427 | |
428 l = l->next; | |
429 } | |
430 } | |
431 | |
5583 | 432 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 433 { |
434 GSList *l = pkt->hash; | |
435 gboolean export = FALSE; | |
6760 | 436 gboolean got_serv_list = FALSE; |
6695 | 437 GaimBuddy *b; |
438 GaimGroup *g; | |
6784 | 439 struct yahoo_friend *f = NULL; |
440 struct yahoo_data *yd = gc->proto_data; | |
441 | |
442 char **lines; | |
443 char **split; | |
444 char **buddies; | |
445 char **tmp, **bud; | |
2681 | 446 |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
447 while (l) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
448 struct yahoo_pair *pair = l->data; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
449 l = l->next; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
450 |
6760 | 451 switch (pair->key) { |
452 case 87: | |
6784 | 453 if (!yd->tmp_serv_blist) |
454 yd->tmp_serv_blist = g_string_new(pair->value); | |
455 else | |
456 g_string_append(yd->tmp_serv_blist, pair->value); | |
6760 | 457 break; |
458 case 88: | |
6784 | 459 if (!yd->tmp_serv_ilist) |
460 yd->tmp_serv_ilist = g_string_new(pair->value); | |
461 else | |
462 g_string_append(yd->tmp_serv_ilist, pair->value); | |
6760 | 463 break; |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
464 } |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
465 } |
2681 | 466 |
6784 | 467 if (pkt->status != 0) |
468 return; | |
469 | |
470 if (yd->tmp_serv_blist) { | |
471 lines = g_strsplit(yd->tmp_serv_blist->str, "\n", -1); | |
472 for (tmp = lines; *tmp; tmp++) { | |
473 split = g_strsplit(*tmp, ":", 2); | |
474 if (!split) | |
475 continue; | |
476 if (!split[0] || !split[1]) { | |
477 g_strfreev(split); | |
478 continue; | |
479 } | |
480 buddies = g_strsplit(split[1], ",", -1); | |
481 for (bud = buddies; bud && *bud; bud++) { | |
482 if (!(f = g_hash_table_lookup(yd->friends, *bud))) { | |
483 f = yahoo_friend_new(*bud); | |
484 g_hash_table_insert(yd->friends, g_strdup(*bud), f); | |
485 } | |
486 if (!(b = gaim_find_buddy(gc->account, *bud))) { | |
487 if (!(g = gaim_find_group(split[0]))) { | |
488 g = gaim_group_new(split[0]); | |
489 gaim_blist_add_group(g, NULL); | |
490 } | |
491 b = gaim_buddy_new(gc->account, *bud, NULL); | |
492 gaim_blist_add_buddy(b, NULL, g, NULL); | |
493 export = TRUE; | |
494 } /*else { do something here is gaim and yahoo don't agree on the buddies group | |
495 GaimGroup *tmpgp; | |
496 | |
497 tmpgp = gaim_find_buddys_group(b); | |
498 if (!tmpgp || !gaim_utf8_strcasecmp(tmpgp->name, split[0])) { | |
499 GaimGroup *ng; | |
500 if (!(ng = gaim_find_group(split[0])) { | |
501 g = gaim_group_new(split[0]); | |
502 gaim_blist_add_group(g, NULL); | |
503 } */ | |
504 | |
505 } | |
506 g_strfreev(buddies); | |
507 g_strfreev(split); | |
508 } | |
509 g_strfreev(lines); | |
510 | |
511 g_string_free(yd->tmp_serv_blist, TRUE); | |
512 yd->tmp_serv_blist = NULL; | |
513 } | |
514 | |
515 | |
516 if (yd->tmp_serv_ilist) { | |
517 buddies = g_strsplit(yd->tmp_serv_ilist->str, ",", -1); | |
518 for (bud = buddies; bud && *bud; bud++) { | |
519 /* The server is already ignoring the user */ | |
520 got_serv_list = TRUE; | |
521 gaim_privacy_deny_add(gc->account, *bud, 1); | |
522 } | |
523 g_strfreev(buddies); | |
524 | |
525 g_string_free(yd->tmp_serv_ilist, TRUE); | |
526 yd->tmp_serv_ilist = NULL; | |
527 } | |
528 | |
529 if (got_serv_list) { | |
530 gc->account->perm_deny = 4; | |
531 serv_set_permit_deny(gc); | |
532 } | |
2681 | 533 if (export) |
4349 | 534 gaim_blist_save(); |
2681 | 535 } |
536 | |
5583 | 537 static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) |
2993 | 538 { |
539 char *msg = NULL; | |
540 char *from = NULL; | |
3019 | 541 char *stat = NULL; |
542 char *game = NULL; | |
6784 | 543 struct yahoo_friend *f = NULL; |
2993 | 544 GSList *l = pkt->hash; |
3019 | 545 struct yahoo_data *yd = (struct yahoo_data*) gc->proto_data; |
6784 | 546 |
2993 | 547 while (l) { |
548 struct yahoo_pair *pair = l->data; | |
549 if (pair->key == 4) | |
550 from = pair->value; | |
551 if (pair->key == 49) | |
552 msg = pair->value; | |
3001 | 553 if (pair->key == 13) |
3019 | 554 stat = pair->value; |
555 if (pair->key == 14) | |
556 game = pair->value; | |
2993 | 557 l = l->next; |
558 } | |
3640 | 559 |
6784 | 560 if (!from || !msg) |
3640 | 561 return; |
6686 | 562 |
4793 | 563 if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) { |
3019 | 564 if (*stat == '1') |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
565 serv_got_typing(gc, from, 0, GAIM_TYPING); |
3019 | 566 else |
567 serv_got_typing_stopped(gc, from); | |
4793 | 568 } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) { |
6695 | 569 GaimBuddy *bud = gaim_find_buddy(gc->account, from); |
6784 | 570 |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
571 if (!bud) { |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
572 gaim_debug(GAIM_DEBUG_WARNING, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
573 "%s is playing a game, and doesn't want " |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
574 "you to know.\n", from); |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
575 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
576 |
6784 | 577 f = g_hash_table_lookup(yd->friends, from); |
578 if (!f) | |
579 return; /* if they're not on the list, don't bother */ | |
580 | |
581 if (f->game) { | |
582 g_free(f->game); | |
583 f->game = NULL; | |
584 } | |
585 | |
3019 | 586 if (*stat == '1') { |
6784 | 587 f->game = g_strdup(game); |
3020 | 588 if (bud) |
6784 | 589 yahoo_update_status(gc, from, f); |
3019 | 590 } |
591 } | |
2993 | 592 } |
593 | |
5583 | 594 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 595 { |
596 char *msg = NULL; | |
597 char *from = NULL; | |
598 time_t tm = time(NULL); | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
599 GSList *l = pkt->hash; |
6069 | 600 |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
601 if (pkt->status <= 1 || pkt->status == 5) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
602 while (l) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
603 struct yahoo_pair *pair = l->data; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
604 if (pair->key == 4) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
605 from = pair->value; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
606 if (pair->key == 15) |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
607 tm = strtol(pair->value, NULL, 10); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
608 if (pair->key == 14) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
609 char *m; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
610 |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
611 msg = pair->value; |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
612 |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
613 strip_linefeed(msg); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
614 m = yahoo_codes_to_html(msg); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
615 serv_got_im(gc, from, m, 0, tm, -1); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
616 g_free(m); |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
617 |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
618 tm = time(NULL); |
6687 | 619 } |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
620 l = l->next; |
6687 | 621 } |
2681 | 622 } else if (pkt->status == 2) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
623 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
624 _("Your Yahoo! message did not get sent."), NULL); |
2681 | 625 } |
626 } | |
627 | |
6686 | 628 static void yahoo_buddy_added_us(GaimConnection *gc, struct yahoo_packet *pkt) { |
2681 | 629 char *id = NULL; |
630 char *who = NULL; | |
631 char *msg = NULL; | |
632 GSList *l = pkt->hash; | |
633 | |
634 while (l) { | |
635 struct yahoo_pair *pair = l->data; | |
6686 | 636 |
637 switch (pair->key) { | |
638 case 1: | |
2681 | 639 id = pair->value; |
6686 | 640 break; |
641 case 3: | |
2681 | 642 who = pair->value; |
6686 | 643 break; |
644 case 15: /* time, for when they add us and we're offline */ | |
645 break; | |
646 case 14: | |
2681 | 647 msg = pair->value; |
6686 | 648 break; |
649 } | |
2681 | 650 l = l->next; |
651 } | |
652 | |
2682
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
653 if (id) |
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
654 show_got_added(gc, id, who, NULL, msg); |
6686 | 655 } |
656 | |
657 static void yahoo_buddy_denied_our_add(GaimConnection *gc, struct yahoo_packet *pkt) | |
658 { | |
659 char *who = NULL; | |
660 char *msg = NULL; | |
661 GSList *l = pkt->hash; | |
662 GString *buf = NULL; | |
6784 | 663 struct yahoo_data *yd = gc->proto_data; |
6686 | 664 |
665 while (l) { | |
666 struct yahoo_pair *pair = l->data; | |
667 | |
668 switch (pair->key) { | |
669 case 3: | |
670 who = pair->value; | |
671 break; | |
672 case 14: | |
673 msg = pair->value; | |
674 break; | |
675 } | |
676 l = l->next; | |
677 } | |
678 | |
679 if (who) { | |
680 buf = g_string_sized_new(0); | |
681 if (!msg) | |
682 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
|
683 else |
6686 | 684 g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg); |
685 gaim_notify_info(gc, NULL, buf->str, NULL); | |
686 g_string_free(buf, TRUE); | |
6784 | 687 g_hash_table_remove(yd->friends, who); |
688 serv_got_update(gc, who, 0, 0, 0, 0, 0); | |
6686 | 689 } |
690 } | |
691 | |
692 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt) | |
693 { | |
694 | |
695 | |
696 switch (pkt->status) { | |
697 case 1: | |
698 yahoo_process_status(gc, pkt); | |
699 return; | |
700 case 3: | |
701 yahoo_buddy_added_us(gc, pkt); | |
702 break; | |
703 case 7: | |
704 yahoo_buddy_denied_our_add(gc, pkt); | |
705 break; | |
706 default: | |
707 break; | |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
708 } |
2681 | 709 } |
710 | |
5583 | 711 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 712 { |
5583 | 713 GaimAccount *account = gaim_connection_get_account(gc); |
2681 | 714 char *who = NULL; |
715 char *email = NULL; | |
716 char *subj = NULL; | |
717 int count = 0; | |
718 GSList *l = pkt->hash; | |
719 | |
5583 | 720 if (!gaim_account_get_check_mail(account)) |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
721 return; |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
722 |
2681 | 723 while (l) { |
724 struct yahoo_pair *pair = l->data; | |
725 if (pair->key == 9) | |
726 count = strtol(pair->value, NULL, 10); | |
727 else if (pair->key == 43) | |
728 who = pair->value; | |
729 else if (pair->key == 42) | |
730 email = pair->value; | |
731 else if (pair->key == 18) | |
732 subj = pair->value; | |
733 l = l->next; | |
734 } | |
735 | |
4001 | 736 if (who && subj && email && *email) { |
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
737 char *from = g_strdup_printf("%s (%s)", who, email); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
738 |
5583 | 739 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
|
740 "http://mail.yahoo.com/", NULL, NULL); |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
741 |
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
742 g_free(from); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
743 } else if (count > 0) { |
5583 | 744 const char *to = gaim_account_get_username(account); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
745 const char *url = "http://mail.yahoo.com/"; |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
746 |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
747 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
748 NULL, NULL); |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
749 } |
2681 | 750 } |
3147 | 751 /* This is the y64 alphabet... it's like base64, but has a . and a _ */ |
752 char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; | |
753 | |
754 /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function | |
755 * in util.c, but it has a bug I don't feel like finding right now ;) */ | |
756 void to_y64(unsigned char *out, const unsigned char *in, int inlen) | |
757 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ | |
758 { | |
759 for (; inlen >= 3; inlen -= 3) | |
760 { | |
761 *out++ = base64digits[in[0] >> 2]; | |
762 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | |
763 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; | |
764 *out++ = base64digits[in[2] & 0x3f]; | |
765 in += 3; | |
766 } | |
767 if (inlen > 0) | |
768 { | |
769 unsigned char fragment; | |
770 | |
771 *out++ = base64digits[in[0] >> 2]; | |
772 fragment = (in[0] << 4) & 0x30; | |
773 if (inlen > 1) | |
774 fragment |= in[1] >> 4; | |
775 *out++ = base64digits[fragment]; | |
776 *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c]; | |
777 *out++ = '-'; | |
778 } | |
779 *out = '\0'; | |
780 } | |
781 | |
5583 | 782 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt) |
3147 | 783 { |
784 char *seed = NULL; | |
785 char *sn = NULL; | |
786 GSList *l = pkt->hash; | |
787 struct yahoo_data *yd = gc->proto_data; | |
6784 | 788 GaimAccount *account = gaim_connection_get_account(gc); |
6761 | 789 |
3147 | 790 while (l) { |
791 struct yahoo_pair *pair = l->data; | |
792 if (pair->key == 94) | |
793 seed = pair->value; | |
794 if (pair->key == 1) | |
795 sn = pair->value; | |
796 l = l->next; | |
797 } | |
798 | |
799 if (seed) { | |
800 struct yahoo_packet *pack; | |
5921 | 801 const char *name = normalize(gaim_account_get_username(account)); |
5583 | 802 const char *pass = gaim_account_get_password(account); |
803 | |
3147 | 804 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly |
805 * will soon do so in the rest of the world. | |
6686 | 806 * |
3147 | 807 * The new clients use this authentication method. I warn you in advance, it's |
808 * bizzare, convoluted, inordinately complicated. It's also no more secure than | |
809 * crypt() was. The only purpose this scheme could serve is to prevent third | |
810 * part clients from connecting to their servers. | |
811 * | |
812 * Sorry, Yahoo. | |
813 */ | |
814 | |
815 md5_byte_t result[16]; | |
816 md5_state_t ctx; | |
5583 | 817 |
3147 | 818 char *crypt_result; |
5583 | 819 char password_hash[25]; |
820 char crypt_hash[25]; | |
3147 | 821 char *hash_string_p = g_malloc(50 + strlen(sn)); |
822 char *hash_string_c = g_malloc(50 + strlen(sn)); | |
823 | |
824 char checksum; | |
825 | |
3157 | 826 int sv; |
3147 | 827 |
5583 | 828 char result6[25]; |
829 char result96[25]; | |
3147 | 830 |
831 sv = seed[15]; | |
3157 | 832 sv = sv % 8; |
3147 | 833 |
834 md5_init(&ctx); | |
5583 | 835 md5_append(&ctx, pass, strlen(pass)); |
3147 | 836 md5_finish(&ctx, result); |
837 to_y64(password_hash, result, 16); | |
838 | |
839 md5_init(&ctx); | |
5583 | 840 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
3147 | 841 md5_append(&ctx, crypt_result, strlen(crypt_result)); |
842 md5_finish(&ctx, result); | |
843 to_y64(crypt_hash, result, 16); | |
3157 | 844 |
845 switch (sv) { | |
3147 | 846 case 1: |
847 case 6: | |
3157 | 848 checksum = seed[seed[9] % 16]; |
3147 | 849 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 850 "%c%s%s%s", checksum, name, seed, password_hash); |
3157 | 851 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 852 "%c%s%s%s", checksum, name, seed, crypt_hash); |
3147 | 853 break; |
854 case 2: | |
855 case 7: | |
3157 | 856 checksum = seed[seed[15] % 16]; |
3147 | 857 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 858 "%c%s%s%s", checksum, seed, password_hash, name); |
3157 | 859 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 860 "%c%s%s%s", checksum, seed, crypt_hash, name); |
3157 | 861 break; |
3147 | 862 case 3: |
3157 | 863 checksum = seed[seed[1] % 16]; |
3147 | 864 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 865 "%c%s%s%s", checksum, name, password_hash, seed); |
3157 | 866 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 867 "%c%s%s%s", checksum, name, crypt_hash, seed); |
3157 | 868 break; |
869 case 4: | |
870 checksum = seed[seed[3] % 16]; | |
871 g_snprintf(hash_string_p, strlen(sn) + 50, | |
5583 | 872 "%c%s%s%s", checksum, password_hash, seed, name); |
3147 | 873 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 874 "%c%s%s%s", checksum, crypt_hash, seed, name); |
3157 | 875 break; |
3147 | 876 case 0: |
877 case 5: | |
3157 | 878 checksum = seed[seed[7] % 16]; |
3147 | 879 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 880 "%c%s%s%s", checksum, password_hash, name, seed); |
3157 | 881 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 882 "%c%s%s%s", checksum, crypt_hash, name, seed); |
3157 | 883 break; |
3147 | 884 } |
3157 | 885 |
3147 | 886 md5_init(&ctx); |
3157 | 887 md5_append(&ctx, hash_string_p, strlen(hash_string_p)); |
3147 | 888 md5_finish(&ctx, result); |
889 to_y64(result6, result, 16); | |
890 | |
891 md5_init(&ctx); | |
892 md5_append(&ctx, hash_string_c, strlen(hash_string_c)); | |
893 md5_finish(&ctx, result); | |
894 to_y64(result96, result, 16); | |
895 | |
6784 | 896 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); |
5583 | 897 yahoo_packet_hash(pack, 0, name); |
3147 | 898 yahoo_packet_hash(pack, 6, result6); |
899 yahoo_packet_hash(pack, 96, result96); | |
5583 | 900 yahoo_packet_hash(pack, 1, name); |
3147 | 901 |
902 yahoo_send_packet(yd, pack); | |
903 | |
904 g_free(hash_string_p); | |
905 g_free(hash_string_c); | |
906 | |
907 yahoo_packet_free(pack); | |
908 } | |
909 } | |
2681 | 910 |
6760 | 911 static void ignore_buddy(GaimBuddy *b) { |
912 GaimGroup *g; | |
913 GaimConversation *c; | |
914 GaimAccount *account; | |
915 gchar *name; | |
916 | |
917 if (!b) | |
918 return; | |
919 | |
920 g = gaim_find_buddys_group(b); | |
921 name = g_strdup(b->name); | |
922 account = b->account; | |
923 | |
924 gaim_debug(GAIM_DEBUG_INFO, "blist", | |
925 "Removing '%s' from buddy list.\n", b->name); | |
926 serv_remove_buddy(account->gc, name, g->name); | |
927 gaim_blist_remove_buddy(b); | |
928 | |
929 gaim_privacy_deny_add(account, name, 0); | |
930 | |
931 gaim_blist_save(); | |
932 | |
933 c = gaim_find_conversation_with_account(name, account); | |
934 | |
935 if (c != NULL) | |
936 gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE); | |
937 | |
938 g_free(name); | |
939 } | |
940 | |
941 static void keep_buddy(GaimBuddy *b) { | |
942 gaim_privacy_deny_remove(b->account, b->name, 1); | |
943 } | |
944 | |
945 static void yahoo_process_ignore(GaimConnection *gc, struct yahoo_packet *pkt) { | |
946 GaimBuddy *b; | |
947 GSList *l; | |
948 gchar *who = NULL; | |
949 gchar *sn = NULL; | |
950 gchar buf[BUF_LONG]; | |
951 gint ignore = 0; | |
952 gint status = 0; | |
953 | |
954 for (l = pkt->hash; l; l = l->next) { | |
955 struct yahoo_pair *pair = l->data; | |
956 switch (pair->key) { | |
957 case 0: | |
958 who = pair->value; | |
959 break; | |
960 case 1: | |
961 sn = pair->value; | |
962 break; | |
963 case 13: | |
964 ignore = strtol(pair->value, NULL, 10); | |
965 break; | |
966 case 66: | |
967 status = strtol(pair->value, NULL, 10); | |
968 break; | |
969 default: | |
970 break; | |
971 } | |
972 } | |
973 | |
974 switch (status) { | |
975 case 12: | |
976 b = gaim_find_buddy(gc->account, who); | |
977 g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " | |
978 "user is on your buddy list. Clicking \"Yes\" " | |
979 "will remove and ignore the buddy."), who); | |
980 gaim_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, b, | |
981 G_CALLBACK(ignore_buddy), | |
982 G_CALLBACK(keep_buddy)); | |
983 break; | |
984 case 2: | |
985 case 3: | |
986 case 0: | |
987 default: | |
988 break; | |
989 } | |
990 } | |
991 | |
6761 | 992 static void yahoo_process_authresp(GaimConnection *gc, struct yahoo_packet *pkt) |
993 { | |
994 GSList *l = pkt->hash; | |
995 int err = 0; | |
996 char *msg; | |
997 | |
998 while (l) { | |
999 struct yahoo_pair *pair = l->data; | |
1000 | |
1001 if (pair->key == 66) | |
1002 err = strtol(pair->value, NULL, 10); | |
1003 | |
1004 l = l->next; | |
1005 } | |
1006 | |
1007 switch (err) { | |
1008 case 3: | |
1009 msg = _("Invalid username."); | |
1010 break; | |
1011 case 13: | |
1012 msg = _("Incorrect password."); | |
1013 break; | |
1014 default: | |
1015 msg = _("Unknown error."); | |
1016 } | |
1017 | |
1018 gaim_connection_error(gc, msg); | |
1019 } | |
1020 | |
5583 | 1021 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 1022 { |
6760 | 1023 switch (pkt->service) { |
2681 | 1024 case YAHOO_SERVICE_LOGON: |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
1025 case YAHOO_SERVICE_LOGOFF: |
2681 | 1026 case YAHOO_SERVICE_ISAWAY: |
2737
f61c1f3a6afa
[gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2724
diff
changeset
|
1027 case YAHOO_SERVICE_ISBACK: |
3019 | 1028 case YAHOO_SERVICE_GAMELOGON: |
1029 case YAHOO_SERVICE_GAMELOGOFF: | |
6686 | 1030 case YAHOO_SERVICE_CHATLOGON: |
1031 case YAHOO_SERVICE_CHATLOGOFF: | |
2681 | 1032 yahoo_process_status(gc, pkt); |
1033 break; | |
3019 | 1034 case YAHOO_SERVICE_NOTIFY: |
1035 yahoo_process_notify(gc, pkt); | |
2993 | 1036 break; |
2681 | 1037 case YAHOO_SERVICE_MESSAGE: |
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
1038 case YAHOO_SERVICE_GAMEMSG: |
5939 | 1039 case YAHOO_SERVICE_CHATMSG: |
2681 | 1040 yahoo_process_message(gc, pkt); |
1041 break; | |
1042 case YAHOO_SERVICE_NEWMAIL: | |
1043 yahoo_process_mail(gc, pkt); | |
1044 break; | |
1045 case YAHOO_SERVICE_NEWCONTACT: | |
1046 yahoo_process_contact(gc, pkt); | |
1047 break; | |
6784 | 1048 case YAHOO_SERVICE_AUTHRESP: |
1049 yahoo_process_authresp(gc, pkt); | |
1050 break; | |
2681 | 1051 case YAHOO_SERVICE_LIST: |
1052 yahoo_process_list(gc, pkt); | |
1053 break; | |
3147 | 1054 case YAHOO_SERVICE_AUTH: |
1055 yahoo_process_auth(gc, pkt); | |
1056 break; | |
6760 | 1057 case YAHOO_SERVICE_IGNORECONTACT: |
1058 yahoo_process_ignore(gc, pkt); | |
1059 break; | |
6729 | 1060 case YAHOO_SERVICE_CONFINVITE: |
1061 case YAHOO_SERVICE_CONFADDINVITE: | |
1062 yahoo_process_conference_invite(gc, pkt); | |
1063 break; | |
1064 case YAHOO_SERVICE_CONFDECLINE: | |
1065 yahoo_process_conference_decline(gc, pkt); | |
1066 break; | |
1067 case YAHOO_SERVICE_CONFLOGON: | |
1068 yahoo_process_conference_logon(gc, pkt); | |
1069 break; | |
1070 case YAHOO_SERVICE_CONFLOGOFF: | |
1071 yahoo_process_conference_logoff(gc, pkt); | |
1072 break; | |
1073 case YAHOO_SERVICE_CONFMSG: | |
1074 yahoo_process_conference_message(gc, pkt); | |
1075 break; | |
1076 case YAHOO_SERVICE_CHATONLINE: | |
1077 yahoo_process_chat_online(gc, pkt); | |
1078 break; | |
1079 case YAHOO_SERVICE_CHATLOGOUT: | |
1080 yahoo_process_chat_logout(gc, pkt); | |
1081 break; | |
1082 case YAHOO_SERVICE_CHATGOTO: | |
1083 yahoo_process_chat_goto(gc, pkt); | |
1084 break; | |
1085 case YAHOO_SERVICE_CHATJOIN: | |
1086 yahoo_process_chat_join(gc, pkt); | |
1087 break; | |
1088 case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */ | |
1089 case YAHOO_SERVICE_CHATEXIT: | |
1090 yahoo_process_chat_exit(gc, pkt); | |
1091 break; | |
1092 case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */ | |
1093 case YAHOO_SERVICE_CHATADDINVITE: | |
1094 yahoo_process_chat_addinvite(gc, pkt); | |
1095 break; | |
1096 case YAHOO_SERVICE_COMMENT: | |
1097 yahoo_process_chat_message(gc, pkt); | |
1098 break; | |
2681 | 1099 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1100 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1101 "Unhandled service 0x%02x\n", pkt->service); |
2681 | 1102 break; |
1103 } | |
1104 } | |
1105 | |
1106 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
1107 { | |
5583 | 1108 GaimConnection *gc = data; |
2681 | 1109 struct yahoo_data *yd = gc->proto_data; |
1110 char buf[1024]; | |
1111 int len; | |
1112 | |
1113 len = read(yd->fd, buf, sizeof(buf)); | |
1114 | |
1115 if (len <= 0) { | |
6321 | 1116 gaim_connection_error(gc, _("Unable to read")); |
2681 | 1117 return; |
1118 } | |
1119 | |
1120 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
1121 memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
1122 yd->rxlen += len; | |
1123 | |
1124 while (1) { | |
1125 struct yahoo_packet *pkt; | |
1126 int pos = 0; | |
1127 int pktlen; | |
1128 | |
1129 if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
1130 return; | |
1131 | |
1132 pos += 4; /* YMSG */ | |
1133 pos += 2; | |
1134 pos += 2; | |
1135 | |
1136 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1137 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1138 "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
2681 | 1139 |
1140 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
1141 return; | |
1142 | |
1143 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
1144 | |
1145 pkt = yahoo_packet_new(0, 0, 0); | |
1146 | |
1147 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
3021 | 1148 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
1149 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1150 "Yahoo Service: 0x%02x Status: %d\n", |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1151 pkt->service, pkt->status); |
2681 | 1152 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
1153 | |
1154 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
1155 | |
1156 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
1157 if (yd->rxlen) { | |
1158 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
1159 g_free(yd->rxqueue); | |
1160 yd->rxqueue = tmp; | |
1161 } else { | |
1162 g_free(yd->rxqueue); | |
1163 yd->rxqueue = NULL; | |
1164 } | |
1165 | |
1166 yahoo_packet_process(gc, pkt); | |
1167 | |
1168 yahoo_packet_free(pkt); | |
1169 } | |
1170 } | |
1171 | |
1172 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
1173 { | |
5583 | 1174 GaimConnection *gc = data; |
2681 | 1175 struct yahoo_data *yd; |
1176 struct yahoo_packet *pkt; | |
1177 | |
5590
011a0a975060
[gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents:
5583
diff
changeset
|
1178 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2681 | 1179 close(source); |
1180 return; | |
1181 } | |
1182 | |
1183 if (source < 0) { | |
6321 | 1184 gaim_connection_error(gc, _("Unable to connect")); |
2681 | 1185 return; |
1186 } | |
1187 | |
1188 yd = gc->proto_data; | |
1189 yd->fd = source; | |
1190 | |
3147 | 1191 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); |
2681 | 1192 |
5921 | 1193 yahoo_packet_hash(pkt, 1, normalize(gaim_account_get_username(gaim_connection_get_account(gc)))); |
2681 | 1194 yahoo_send_packet(yd, pkt); |
1195 | |
1196 yahoo_packet_free(pkt); | |
1197 | |
1198 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
1199 } | |
1200 | |
5583 | 1201 static void yahoo_login(GaimAccount *account) { |
1202 GaimConnection *gc = gaim_account_get_connection(account); | |
2681 | 1203 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
1204 | |
6629 | 1205 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR; |
1206 | |
5583 | 1207 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
2681 | 1208 |
1209 yd->fd = -1; | |
6784 | 1210 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
6729 | 1211 yd->confs = NULL; |
1212 yd->conf_id = 2; | |
2681 | 1213 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
1214 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), |
5583 | 1215 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), |
1216 yahoo_got_connected, gc) != 0) { | |
6321 | 1217 gaim_connection_error(gc, _("Connection problem")); |
2681 | 1218 return; |
1219 } | |
1220 | |
1221 } | |
1222 | |
5583 | 1223 static void yahoo_close(GaimConnection *gc) { |
2681 | 1224 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
6729 | 1225 |
6784 | 1226 g_hash_table_destroy(yd->friends); |
6729 | 1227 g_slist_free(yd->confs); |
6784 | 1228 if (yd->chat_name) |
1229 g_free(yd->chat_name); | |
6729 | 1230 |
2681 | 1231 if (yd->fd >= 0) |
1232 close(yd->fd); | |
3720
34c95669952f
[gaim-migrate @ 3853]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3642
diff
changeset
|
1233 |
2681 | 1234 if (yd->rxqueue) |
1235 g_free(yd->rxqueue); | |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2686
diff
changeset
|
1236 yd->rxlen = 0; |
2681 | 1237 if (gc->inpa) |
1238 gaim_input_remove(gc->inpa); | |
1239 g_free(yd); | |
1240 } | |
1241 | |
6695 | 1242 static const char *yahoo_list_icon(GaimAccount *a, GaimBuddy *b) |
2681 | 1243 { |
4687 | 1244 return "yahoo"; |
2681 | 1245 } |
4916 | 1246 |
6695 | 1247 static void yahoo_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4916 | 1248 { |
1249 int i = 0; | |
1250 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
6784 | 1251 GaimAccount *account; |
1252 GaimConnection *gc; | |
1253 struct yahoo_data *yd; | |
1254 struct yahoo_friend *f; | |
1255 | |
1256 if (!b || !(account = b->account) || !(gc = gaim_account_get_connection(account)) || | |
1257 !(yd = gc->proto_data)) | |
1258 return; | |
1259 | |
1260 f = g_hash_table_lookup(yd->friends, b->name); | |
1261 if (!f) { | |
1262 *se = "notauthorized"; | |
1263 return; | |
1264 } | |
1265 | |
5068 | 1266 if (b->present == GAIM_BUDDY_OFFLINE) { |
4916 | 1267 *se = "offline"; |
1268 return; | |
1269 } else { | |
6784 | 1270 if (f->away) |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1271 emblems[i++] = "away"; |
6784 | 1272 if (f->sms) |
1273 emblems[i++] = "wireless"; | |
1274 if (f->game) | |
4916 | 1275 emblems[i++] = "game"; |
1276 } | |
1277 *se = emblems[0]; | |
1278 *sw = emblems[1]; | |
1279 *nw = emblems[2]; | |
1280 *ne = emblems[3]; | |
1281 } | |
2681 | 1282 |
1283 static char *yahoo_get_status_string(enum yahoo_status a) | |
1284 { | |
1285 switch (a) { | |
1286 case YAHOO_STATUS_BRB: | |
4596 | 1287 return _("Be Right Back"); |
2681 | 1288 case YAHOO_STATUS_BUSY: |
4596 | 1289 return _("Busy"); |
2681 | 1290 case YAHOO_STATUS_NOTATHOME: |
4596 | 1291 return _("Not At Home"); |
2681 | 1292 case YAHOO_STATUS_NOTATDESK: |
4596 | 1293 return _("Not At Desk"); |
2681 | 1294 case YAHOO_STATUS_NOTINOFFICE: |
4596 | 1295 return _("Not In Office"); |
2681 | 1296 case YAHOO_STATUS_ONPHONE: |
4606 | 1297 return _("On The Phone"); |
2681 | 1298 case YAHOO_STATUS_ONVACATION: |
4596 | 1299 return _("On Vacation"); |
2681 | 1300 case YAHOO_STATUS_OUTTOLUNCH: |
4596 | 1301 return _("Out To Lunch"); |
2681 | 1302 case YAHOO_STATUS_STEPPEDOUT: |
4596 | 1303 return _("Stepped Out"); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
1304 case YAHOO_STATUS_INVISIBLE: |
4596 | 1305 return _("Invisible"); |
4730 | 1306 case YAHOO_STATUS_IDLE: |
1307 return _("Idle"); | |
6784 | 1308 case YAHOO_STATUS_OFFLINE: |
1309 return _("Offline"); | |
2879
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
1310 default: |
4596 | 1311 return _("Online"); |
2681 | 1312 } |
1313 } | |
1314 | |
6729 | 1315 static void yahoo_initiate_conference(GaimConnection *gc, const char *name) |
1316 { | |
1317 GHashTable *components; | |
1318 struct yahoo_data *yd; | |
1319 int id; | |
1320 | |
1321 yd = gc->proto_data; | |
1322 id = yd->conf_id; | |
1323 | |
1324 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
1325 g_hash_table_replace(components, g_strdup("room"), | |
1326 g_strdup_printf("%s-%d", gaim_connection_get_display_name(gc), id)); | |
1327 g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference...")); | |
1328 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | |
1329 yahoo_c_join(gc, components); | |
1330 g_hash_table_destroy(components); | |
1331 | |
1332 yahoo_c_invite(gc, id, "Join my conference...", name); | |
1333 } | |
1334 | |
5583 | 1335 static void yahoo_game(GaimConnection *gc, const char *name) { |
3019 | 1336 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
6784 | 1337 char *game = NULL; |
3019 | 1338 char *t; |
1339 char url[256]; | |
6784 | 1340 struct yahoo_friend *f; |
3019 | 1341 |
6784 | 1342 f = g_hash_table_lookup(yd->friends, name); |
1343 if (!f) | |
1344 return; | |
1345 | |
1346 game = f->game; | |
3019 | 1347 if (!game) |
1348 return; | |
6784 | 1349 |
3019 | 1350 t = game = g_strdup(strstr(game, "ante?room=")); |
1351 while (*t != '\t') | |
1352 t++; | |
1353 *t = 0; | |
1354 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
|
1355 gaim_notify_uri(gc, url); |
3019 | 1356 g_free(game); |
1357 } | |
4722 | 1358 |
6695 | 1359 static char *yahoo_status_text(GaimBuddy *b) |
4722 | 1360 { |
1361 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data; | |
6784 | 1362 struct yahoo_friend *f = NULL; |
1363 char *stripped = NULL; | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1364 |
6784 | 1365 f = g_hash_table_lookup(yd->friends, b->name); |
1366 if (!f) | |
1367 return g_strdup(_("Not on server list")); | |
1368 | |
1369 switch (f->status) { | |
1370 case YAHOO_STATUS_AVAILABLE: | |
1371 return NULL; | |
1372 case YAHOO_STATUS_IDLE: | |
1373 if (f->idle == -1) | |
1374 return g_strdup(yahoo_get_status_string(f->status)); | |
1375 return NULL; | |
1376 case YAHOO_STATUS_CUSTOM: | |
1377 if (!f->msg) | |
1378 return NULL; | |
1379 stripped = strip_html(f->msg); | |
1380 if (stripped) { | |
1381 char *ret = g_markup_escape_text(stripped, strlen(stripped)); | |
1382 g_free(stripped); | |
1383 return ret; | |
1384 } | |
1385 return NULL; | |
1386 default: | |
1387 return g_strdup(yahoo_get_status_string(f->status)); | |
1388 } | |
1389 | |
4729 | 1390 return NULL; |
4722 | 1391 } |
1392 | |
6695 | 1393 static char *yahoo_tooltip_text(GaimBuddy *b) |
4724 | 1394 { |
1395 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data; | |
6784 | 1396 struct yahoo_friend *f; |
1397 char *escaped, *status, *ret; | |
1398 | |
1399 f = g_hash_table_lookup(yd->friends, b->name); | |
1400 if (!f) | |
1401 status = g_strdup(_("Not on server list")); | |
1402 else | |
1403 switch (f->status) { | |
1404 case YAHOO_STATUS_IDLE: | |
1405 if (f->idle == -1) { | |
1406 status = g_strdup(yahoo_get_status_string(f->status)); | |
1407 break; | |
1408 } | |
1409 return NULL; | |
1410 case YAHOO_STATUS_CUSTOM: | |
1411 if (!f->msg) | |
1412 return NULL; | |
1413 status = strip_html(f->msg); | |
1414 break; | |
1415 default: | |
1416 status = g_strdup(yahoo_get_status_string(f->status)); | |
1417 break; | |
4745 | 1418 } |
6784 | 1419 |
1420 escaped = g_markup_escape_text(status, strlen(status)); | |
1421 ret = g_strdup_printf(_("<b>Status:</b> %s"), escaped); | |
1422 g_free(status); | |
1423 g_free(escaped); | |
1424 | |
1425 return ret; | |
4729 | 1426 } |
1427 | |
5583 | 1428 static GList *yahoo_buddy_menu(GaimConnection *gc, const char *who) |
2681 | 1429 { |
1430 GList *m = NULL; | |
1431 struct proto_buddy_menu *pbm; | |
1432 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
3019 | 1433 static char buf2[1024]; |
6784 | 1434 struct yahoo_friend *f; |
1435 | |
1436 f = g_hash_table_lookup(yd->friends, who); | |
1437 | |
1438 if (!f) { | |
1439 pbm = g_new0(struct proto_buddy_menu, 1); | |
1440 pbm->label = _("Add Buddy"); | |
1441 pbm->callback = yahoo_add_buddy; | |
1442 pbm->gc = gc; | |
1443 m = g_list_append(m, pbm); | |
1444 | |
1445 return m; | |
1446 } | |
1447 | |
1448 if (f->status == YAHOO_STATUS_OFFLINE) | |
1449 return NULL; | |
4722 | 1450 |
6729 | 1451 pbm = g_new0(struct proto_buddy_menu, 1); |
1452 pbm->label = _("Join in Chat"); | |
1453 pbm->callback = yahoo_chat_goto; | |
1454 pbm->gc = gc; | |
1455 m = g_list_append(m, pbm); | |
1456 | |
1457 pbm = g_new0(struct proto_buddy_menu, 1); | |
1458 pbm->label = _("Initiate Conference"); | |
1459 pbm->callback = yahoo_initiate_conference; | |
1460 pbm->gc = gc; | |
1461 m = g_list_append(m, pbm); | |
1462 | |
6784 | 1463 if (f->game) { |
1464 char *game = f->game; | |
3019 | 1465 char *room; |
6784 | 1466 char *t; |
1467 | |
3019 | 1468 if (!game) |
1469 return m; | |
6784 | 1470 |
1471 pbm = g_new0(struct proto_buddy_menu, 1); | |
1472 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ | |
1473 return m; | |
1474 while (*room && *room != '\t') /* skip to the tab */ | |
1475 room++; | |
1476 t = room++; /* room as now at the name */ | |
1477 while (*t != '\n') | |
1478 t++; /* replace the \n with a space */ | |
1479 *t = ' '; | |
1480 g_snprintf(buf2, sizeof buf2, "%s", room); | |
1481 pbm->label = buf2; | |
1482 pbm->callback = yahoo_game; | |
1483 pbm->gc = gc; | |
1484 m = g_list_append(m, pbm); | |
3019 | 1485 } |
6729 | 1486 |
2681 | 1487 return m; |
1488 } | |
1489 | |
5583 | 1490 static void yahoo_act_id(GaimConnection *gc, const char *entry) |
2681 | 1491 { |
1492 struct yahoo_data *yd = gc->proto_data; | |
1493 | |
1494 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
1495 yahoo_packet_hash(pkt, 3, entry); | |
1496 yahoo_send_packet(yd, pkt); | |
1497 yahoo_packet_free(pkt); | |
1498 | |
5583 | 1499 gaim_connection_set_display_name(gc, entry); |
2681 | 1500 } |
1501 | |
5583 | 1502 static void yahoo_show_act_id(GaimConnection *gc) |
2681 | 1503 { |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1504 gaim_request_input(gc, NULL, _("Active which ID?"), NULL, |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
5939
diff
changeset
|
1505 gaim_connection_get_display_name(gc), FALSE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1506 _("OK"), G_CALLBACK(yahoo_act_id), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1507 _("Cancel"), NULL, gc); |
2681 | 1508 } |
1509 | |
5583 | 1510 static GList *yahoo_actions(GaimConnection *gc) { |
2681 | 1511 GList *m = NULL; |
4333 | 1512 struct proto_actions_menu *pam; |
2681 | 1513 |
4333 | 1514 pam = g_new0(struct proto_actions_menu, 1); |
1515 pam->label = _("Activate ID"); | |
1516 pam->callback = yahoo_show_act_id; | |
1517 pam->gc = gc; | |
1518 m = g_list_append(m, pam); | |
2681 | 1519 |
1520 return m; | |
1521 } | |
1522 | |
6622 | 1523 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, int len, GaimImFlags flags) |
2681 | 1524 { |
1525 struct yahoo_data *yd = gc->proto_data; | |
1526 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
6629 | 1527 char *msg = yahoo_html_to_codes(what); |
2681 | 1528 |
5583 | 1529 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1530 yahoo_packet_hash(pkt, 5, who); |
3493 | 1531 yahoo_packet_hash(pkt, 14, msg); |
6044 | 1532 yahoo_packet_hash(pkt, 97, "1"); |
2681 | 1533 |
1534 yahoo_send_packet(yd, pkt); | |
1535 | |
1536 yahoo_packet_free(pkt); | |
6629 | 1537 |
1538 g_free(msg); | |
1539 | |
2681 | 1540 return 1; |
1541 } | |
1542 | |
6059 | 1543 int yahoo_send_typing(GaimConnection *gc, const char *who, int typ) |
2993 | 1544 { |
1545 struct yahoo_data *yd = gc->proto_data; | |
3019 | 1546 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
2993 | 1547 yahoo_packet_hash(pkt, 49, "TYPING"); |
5583 | 1548 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2993 | 1549 yahoo_packet_hash(pkt, 14, " "); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
1550 yahoo_packet_hash(pkt, 13, typ == GAIM_TYPING ? "1" : "0"); |
2993 | 1551 yahoo_packet_hash(pkt, 5, who); |
1552 yahoo_packet_hash(pkt, 1002, "1"); | |
1553 | |
1554 yahoo_send_packet(yd, pkt); | |
1555 | |
1556 yahoo_packet_free(pkt); | |
1557 | |
3001 | 1558 return 0; |
2993 | 1559 } |
1560 | |
6059 | 1561 static void yahoo_set_away(GaimConnection *gc, const char *state, const char *msg) |
2681 | 1562 { |
1563 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1564 struct yahoo_packet *pkt; | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1565 int service; |
2681 | 1566 char s[4]; |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1567 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1568 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1569 g_free(gc->away); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1570 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1571 } |
2681 | 1572 |
1573 if (msg) { | |
1574 yd->current_status = YAHOO_STATUS_CUSTOM; | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1575 gc->away = g_strdup(msg); |
2681 | 1576 } else if (state) { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1577 gc->away = g_strdup(""); |
4596 | 1578 if (!strcmp(state, _("Available"))) { |
2681 | 1579 yd->current_status = YAHOO_STATUS_AVAILABLE; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1580 g_free(gc->away); |
2681 | 1581 gc->away = NULL; |
4596 | 1582 } else if (!strcmp(state, _("Be Right Back"))) { |
2681 | 1583 yd->current_status = YAHOO_STATUS_BRB; |
4596 | 1584 } else if (!strcmp(state, _("Busy"))) { |
2681 | 1585 yd->current_status = YAHOO_STATUS_BUSY; |
4596 | 1586 } else if (!strcmp(state, _("Not At Home"))) { |
2681 | 1587 yd->current_status = YAHOO_STATUS_NOTATHOME; |
4596 | 1588 } else if (!strcmp(state, _("Not At Desk"))) { |
2681 | 1589 yd->current_status = YAHOO_STATUS_NOTATDESK; |
4596 | 1590 } else if (!strcmp(state, _("Not In Office"))) { |
2681 | 1591 yd->current_status = YAHOO_STATUS_NOTINOFFICE; |
4606 | 1592 } else if (!strcmp(state, _("On The Phone"))) { |
2681 | 1593 yd->current_status = YAHOO_STATUS_ONPHONE; |
4596 | 1594 } else if (!strcmp(state, _("On Vacation"))) { |
2681 | 1595 yd->current_status = YAHOO_STATUS_ONVACATION; |
4596 | 1596 } else if (!strcmp(state, _("Out To Lunch"))) { |
2681 | 1597 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; |
4596 | 1598 } else if (!strcmp(state, _("Stepped Out"))) { |
2681 | 1599 yd->current_status = YAHOO_STATUS_STEPPEDOUT; |
4596 | 1600 } else if (!strcmp(state, _("Invisible"))) { |
2681 | 1601 yd->current_status = YAHOO_STATUS_INVISIBLE; |
1602 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { | |
1603 if (gc->is_idle) { | |
1604 yd->current_status = YAHOO_STATUS_IDLE; | |
1605 } else { | |
1606 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1607 } | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1608 g_free(gc->away); |
2681 | 1609 gc->away = NULL; |
1610 } | |
1611 } else if (gc->is_idle) { | |
1612 yd->current_status = YAHOO_STATUS_IDLE; | |
1613 } else { | |
1614 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1615 } | |
1616 | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1617 if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1618 service = YAHOO_SERVICE_ISBACK; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1619 else |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1620 service = YAHOO_SERVICE_ISAWAY; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1621 pkt = yahoo_packet_new(service, yd->current_status, 0); |
2681 | 1622 g_snprintf(s, sizeof(s), "%d", yd->current_status); |
1623 yahoo_packet_hash(pkt, 10, s); | |
6691
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1624 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
306790891ce7
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
1625 yahoo_packet_hash(pkt, 19, msg); |
6784 | 1626 if (gc->is_idle) |
1627 yahoo_packet_hash(pkt, 47, "2"); | |
1628 else | |
1629 yahoo_packet_hash(pkt, 47, "1"); | |
6686 | 1630 } |
2681 | 1631 |
1632 yahoo_send_packet(yd, pkt); | |
1633 yahoo_packet_free(pkt); | |
1634 } | |
1635 | |
5583 | 1636 static void yahoo_set_idle(GaimConnection *gc, int idle) |
2681 | 1637 { |
1638 struct yahoo_data *yd = gc->proto_data; | |
1639 struct yahoo_packet *pkt = NULL; | |
1640 | |
1641 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
1642 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0); | |
1643 yd->current_status = YAHOO_STATUS_IDLE; | |
1644 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
1645 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
1646 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
6784 | 1647 } else if (idle && gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) { |
1648 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0); | |
1649 } else if (!idle && gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) { | |
1650 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
2681 | 1651 } |
1652 | |
1653 if (pkt) { | |
1654 char buf[4]; | |
1655 g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
1656 yahoo_packet_hash(pkt, 10, buf); | |
6784 | 1657 if (gc->away && yd->current_status == YAHOO_STATUS_CUSTOM) { |
1658 yahoo_packet_hash(pkt, 19, gc->away); | |
1659 if (idle) | |
1660 yahoo_packet_hash(pkt, 47, "2"); | |
1661 else | |
1662 yahoo_packet_hash(pkt, 47, "1"); /* fixme when available messages are possible */ | |
1663 } | |
2681 | 1664 yahoo_send_packet(yd, pkt); |
1665 yahoo_packet_free(pkt); | |
1666 } | |
1667 } | |
1668 | |
5583 | 1669 static GList *yahoo_away_states(GaimConnection *gc) |
2681 | 1670 { |
1671 GList *m = NULL; | |
1672 | |
4596 | 1673 m = g_list_append(m, _("Available")); |
1674 m = g_list_append(m, _("Be Right Back")); | |
1675 m = g_list_append(m, _("Busy")); | |
1676 m = g_list_append(m, _("Not At Home")); | |
1677 m = g_list_append(m, _("Not At Desk")); | |
1678 m = g_list_append(m, _("Not In Office")); | |
4606 | 1679 m = g_list_append(m, _("On The Phone")); |
4596 | 1680 m = g_list_append(m, _("On Vacation")); |
1681 m = g_list_append(m, _("Out To Lunch")); | |
1682 m = g_list_append(m, _("Stepped Out")); | |
1683 m = g_list_append(m, _("Invisible")); | |
2681 | 1684 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
1685 | |
1686 return m; | |
1687 } | |
1688 | |
5583 | 1689 static void yahoo_keepalive(GaimConnection *gc) |
2681 | 1690 { |
1691 struct yahoo_data *yd = gc->proto_data; | |
1692 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
1693 yahoo_send_packet(yd, pkt); | |
1694 yahoo_packet_free(pkt); | |
6729 | 1695 |
1696 if (!yd->chat_online) | |
1697 return; | |
1698 | |
1699 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); | |
1700 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); | |
1701 yahoo_send_packet(yd, pkt); | |
1702 yahoo_packet_free(pkt); | |
2681 | 1703 } |
1704 | |
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6784
diff
changeset
|
1705 static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *foo) |
2681 | 1706 { |
1707 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1708 struct yahoo_packet *pkt; | |
6695 | 1709 GaimGroup *g; |
2681 | 1710 char *group = NULL; |
1711 | |
1712 if (!yd->logged_in) | |
1713 return; | |
1714 | |
4687 | 1715 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, who)); |
2681 | 1716 if (g) |
1717 group = g->name; | |
1718 else | |
1719 group = "Buddies"; | |
1720 | |
1721 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
5583 | 1722 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1723 yahoo_packet_hash(pkt, 7, who); |
1724 yahoo_packet_hash(pkt, 65, group); | |
1725 yahoo_send_packet(yd, pkt); | |
1726 yahoo_packet_free(pkt); | |
1727 } | |
1728 | |
6059 | 1729 static void yahoo_remove_buddy(GaimConnection *gc, const char *who, const char *group) |
2681 | 1730 { |
1731 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
6784 | 1732 struct yahoo_friend *f; |
1733 | |
1734 if (!(f = g_hash_table_lookup(yd->friends, who))) | |
1735 return; | |
1736 | |
1737 g_hash_table_remove(yd->friends, who); | |
2681 | 1738 |
1739 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
5583 | 1740 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1741 yahoo_packet_hash(pkt, 7, who); |
1742 yahoo_packet_hash(pkt, 65, group); | |
1743 yahoo_send_packet(yd, pkt); | |
1744 yahoo_packet_free(pkt); | |
1745 } | |
1746 | |
6760 | 1747 static void yahoo_add_deny(GaimConnection *gc, const char *who) { |
1748 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1749 struct yahoo_packet *pkt; | |
1750 | |
1751 if (!yd->logged_in) | |
1752 return; | |
1753 | |
1754 if (gc->account->perm_deny != 4) | |
1755 return; | |
1756 | |
1757 if (!who || who[0] == '\0') | |
1758 return; | |
1759 | |
1760 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
1761 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
1762 yahoo_packet_hash(pkt, 7, who); | |
1763 yahoo_packet_hash(pkt, 13, "1"); | |
1764 yahoo_send_packet(yd, pkt); | |
1765 yahoo_packet_free(pkt); | |
1766 } | |
1767 | |
1768 static void yahoo_rem_deny(GaimConnection *gc, const char *who) { | |
1769 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1770 struct yahoo_packet *pkt; | |
1771 | |
1772 if (!yd->logged_in) | |
1773 return; | |
1774 | |
1775 if (!who || who[0] == '\0') | |
1776 return; | |
1777 | |
1778 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
1779 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); | |
1780 yahoo_packet_hash(pkt, 7, who); | |
1781 yahoo_packet_hash(pkt, 13, "2"); | |
1782 yahoo_send_packet(yd, pkt); | |
1783 yahoo_packet_free(pkt); | |
1784 } | |
1785 | |
1786 static void yahoo_set_permit_deny(GaimConnection *gc) { | |
1787 GaimAccount *acct; | |
1788 GSList *deny; | |
1789 | |
1790 acct = gc->account; | |
1791 | |
1792 switch (acct->perm_deny) { | |
1793 case 1: | |
1794 case 3: | |
1795 case 5: | |
1796 for (deny = acct->deny;deny;deny = deny->next) | |
1797 yahoo_rem_deny(gc, deny->data); | |
1798 break; | |
1799 case 4: | |
1800 for (deny = acct->deny;deny;deny = deny->next) | |
1801 yahoo_add_deny(gc, deny->data); | |
1802 break; | |
1803 case 2: | |
1804 default: | |
1805 break; | |
1806 } | |
1807 } | |
1808 | |
6513 | 1809 static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
1810 { | |
1811 yahoo_dest_colorht(); | |
1812 return TRUE; | |
1813 } | |
1814 | |
6514 | 1815 static void yahoo_got_info(gpointer data, char *url_text, unsigned long len) |
1816 { | |
1817 char *stripped,*p; | |
1818 char buf[1024]; | |
1819 | |
1820 /* we failed to grab the profile URL */ | |
1821 if (!url_text) { | |
1822 g_show_info_text(NULL, NULL, 2, | |
6573 | 1823 _("<html><body><b>Error retrieving profile</b></body></html>"), NULL); |
6514 | 1824 return; |
1825 } | |
1826 | |
1827 /* we don't yet support the multiple link level of the warning page for | |
1828 * 'adult' profiles, not to mention the fact that yahoo wants you to be | |
1829 * logged in (on the website) to be able to view an 'adult' profile. for | |
1830 * now, just tell them that we can't help them, and provide a link to the | |
1831 * profile if they want to do the web browser thing. | |
1832 */ | |
1833 p = strstr(url_text, "Adult Profiles Warning Message"); | |
1834 if (p) { | |
6573 | 1835 strcpy(buf, _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n")); |
6514 | 1836 info_extract_field(url_text, buf, ".idname=", 0, "%26", 0, NULL, |
6573 | 1837 _("If you wish to view this profile, you will need to visit this link in your web browser"), |
6514 | 1838 1, YAHOO_PROFILE_URL); |
1839 strcat(buf, "</body></html>\n"); | |
1840 g_show_info_text(NULL, NULL, 2, buf, NULL); | |
1841 return; | |
1842 } | |
1843 | |
6630 | 1844 /* at the moment we don't support profile pages with languages other than |
1845 * english. the problem is, that every user may choose his/her own profile | |
1846 * language. this language has nothing to do with the preferences of the | |
1847 * user which looks at the profile | |
1848 */ | |
1849 p = strstr(url_text, "Last Updated:"); | |
1850 if (!p) { | |
1851 strcpy(buf, _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n")); | |
1852 info_extract_field(url_text, buf, "<title>", 0, "'s Yahoo! Profile", 0, NULL, | |
1853 _("If you wish to view this profile, you will need to visit this link in your web browser"), | |
1854 1, YAHOO_PROFILE_URL); | |
1855 strcat(buf, "</body></html>\n"); | |
1856 g_show_info_text(NULL, NULL, 2, buf, NULL); | |
1857 return; | |
1858 } | |
1859 | |
6514 | 1860 /* strip_html() doesn't strip out character entities like and · |
1861 */ | |
1862 while ((p = strstr(url_text, " ")) != NULL) { | |
1863 memmove(p, p + 6, strlen(p + 6)); | |
1864 url_text[strlen(url_text) - 6] = '\0'; | |
1865 } | |
1866 while ((p = strstr(url_text, "·")) != NULL) { | |
1867 memmove(p, p + 6, strlen(p + 6)); | |
1868 url_text[strlen(url_text) - 6] = '\0'; | |
1869 } | |
1870 | |
1871 /* nuke the nasty \r's */ | |
1872 while ((p = strchr(url_text, '\r')) != NULL) { | |
1873 memmove(p, p + 1, strlen(p + 1)); | |
1874 url_text[strlen(url_text) - 1] = '\0'; | |
1875 } | |
1876 | |
1877 /* nuke the html, it's easier than trying to parse the horrid stuff */ | |
1878 stripped = strip_html(url_text); | |
1879 | |
1880 /* gonna re-use the memory we've already got for url_text */ | |
1881 strcpy(url_text, "<html><body>\n"); | |
1882 | |
1883 /* extract their Yahoo! ID and put it in */ | |
1884 info_extract_field(stripped, url_text, "Yahoo! ID:", 2, "\n", 0, | |
6573 | 1885 NULL, _("Yahoo! ID"), 0, NULL); |
6514 | 1886 |
1887 /* extract their Email address and put it in */ | |
1888 info_extract_field(stripped, url_text, "My Email", 5, "\n", 0, | |
6657 | 1889 "Private", _("Email"), 0, NULL); |
6514 | 1890 |
1891 /* extract the Nickname if it exists */ | |
1892 info_extract_field(stripped, url_text, "Nickname:", 1, "\n", '\n', | |
6573 | 1893 NULL, _("Nickname"), 0, NULL); |
6514 | 1894 |
1895 /* extract their RealName and put it in */ | |
1896 info_extract_field(stripped, url_text, "RealName:", 1, "\n", '\n', | |
6623 | 1897 NULL, _("Realname"), 0, NULL); |
6514 | 1898 |
1899 /* extract their Location and put it in */ | |
1900 info_extract_field(stripped, url_text, "Location:", 2, "\n", '\n', | |
6573 | 1901 NULL, _("Location"), 0, NULL); |
6514 | 1902 |
1903 /* extract their Age and put it in */ | |
1904 info_extract_field(stripped, url_text, "Age:", 3, "\n", '\n', | |
6573 | 1905 NULL, _("Age"), 0, NULL); |
6514 | 1906 |
1907 /* extract their MaritalStatus and put it in */ | |
1908 info_extract_field(stripped, url_text, "MaritalStatus:", 3, "\n", '\n', | |
6657 | 1909 "No Answer", _("Marital Status"), 0, NULL); |
6514 | 1910 |
1911 /* extract their Gender and put it in */ | |
1912 info_extract_field(stripped, url_text, "Gender:", 3, "\n", '\n', | |
6657 | 1913 "No Answer", _("Gender"), 0, NULL); |
6514 | 1914 |
1915 /* extract their Occupation and put it in */ | |
1916 info_extract_field(stripped, url_text, "Occupation:", 2, "\n", '\n', | |
6573 | 1917 NULL, _("Occupation"), 0, NULL); |
6514 | 1918 |
1919 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the | |
1920 * values can contain embedded newlines... but any or all of them can also | |
1921 * not appear. The way we delimit them is to successively look for the next | |
1922 * one that _could_ appear, and if all else fails, we end the section by | |
1923 * looking for the 'Links' heading, which is the next thing to follow this | |
1924 * bunch. | |
1925 */ | |
1926 if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Latest News", | |
6573 | 1927 '\n', NULL, _("Hobbies"), 0, NULL)) |
6514 | 1928 if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Favorite Quote", |
6573 | 1929 '\n', NULL, _("Hobbies"), 0, NULL)) |
6514 | 1930 info_extract_field(stripped, url_text, "Hobbies:", 1, "Links", |
6573 | 1931 '\n', NULL, _("Hobbies"), 0, NULL); |
6514 | 1932 if (!info_extract_field(stripped, url_text, "Latest News:", 1, "Favorite Quote", |
6573 | 1933 '\n', NULL, _("Latest News"), 0, NULL)) |
6514 | 1934 info_extract_field(stripped, url_text, "Latest News:", 1, "Links", |
6573 | 1935 '\n', NULL, _("Latest News"), 0, NULL); |
6514 | 1936 info_extract_field(stripped, url_text, "Favorite Quote:", 0, "Links", |
6573 | 1937 '\n', NULL, _("Favorite Quote"), 0, NULL); |
6514 | 1938 |
1939 /* Home Page will either be "No home page specified", | |
1940 * or "Home Page: " and a link. */ | |
1941 p = strstr(stripped, "No home page specified"); | |
1942 if (!p) | |
1943 info_extract_field(stripped, url_text, "Home Page:", 1, " ", 0, NULL, | |
6573 | 1944 _("Home Page"), 1, NULL); |
6514 | 1945 |
1946 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, | |
1947 * then we have none. If we have one however, we'll need to check and see if | |
1948 * we have a second one. If we have a second one, we have to check to see if | |
1949 * we have a third one. | |
1950 */ | |
1951 p = strstr(stripped,"No cool link specified"); | |
1952 if (!p) | |
1953 if (info_extract_field(stripped, url_text, "Cool Link 1:", 1, " ", 0, NULL, | |
6573 | 1954 _("Cool Link 1"), 1, NULL)) |
6514 | 1955 if (info_extract_field(stripped, url_text, "Cool Link 2:", 1, " ", 0, NULL, |
6573 | 1956 _("Cool Link 2"), 1, NULL)) |
6514 | 1957 info_extract_field(stripped, url_text, "Cool Link 3:", 1, " ", 0, NULL, |
6573 | 1958 _("Cool Link 3"), 1, NULL); |
6514 | 1959 |
1960 /* see if Member Since is there, and if so, extract it. */ | |
1961 info_extract_field(stripped, url_text, "Member Since:", 1, "Last Updated:", | |
6573 | 1962 '\n', NULL, _("Member Since"), 0, NULL); |
6514 | 1963 |
1964 /* extract the Last Updated date and put it in */ | |
1965 info_extract_field(stripped, url_text, "Last Updated:", 1, "\n", '\n', NULL, | |
6573 | 1966 _("Last Updated"), 0, NULL); |
6514 | 1967 |
1968 /* finish off the html */ | |
1969 strcat(url_text, "</body></html>\n"); | |
1970 g_free(stripped); | |
1971 | |
1972 /* show it to the user */ | |
1973 g_show_info_text(NULL, NULL, 2, url_text, NULL); | |
1974 } | |
1975 | |
1976 static void yahoo_get_info(GaimConnection *gc, const char *name) | |
1977 { | |
1978 /* struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; */ | |
1979 char url[256]; | |
1980 g_snprintf(url, sizeof url, "%s%s", YAHOO_PROFILE_URL, name); | |
6516 | 1981 grab_url(url, FALSE, yahoo_got_info, NULL, NULL, 0); |
6514 | 1982 } |
1983 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1984 static GaimPlugin *my_protocol = NULL; |
2681 | 1985 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1986 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1987 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1988 GAIM_PROTO_YAHOO, |
6729 | 1989 OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, |
1990 NULL, /* user_splits */ | |
1991 NULL, /* protocol_options */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1992 yahoo_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1993 yahoo_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1994 yahoo_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1995 yahoo_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1996 yahoo_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1997 yahoo_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1998 yahoo_buddy_menu, |
6729 | 1999 yahoo_c_info, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2000 yahoo_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2001 yahoo_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2002 yahoo_send_im, |
6729 | 2003 NULL, /* set info */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2004 yahoo_send_typing, |
6514 | 2005 yahoo_get_info, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2006 yahoo_set_away, |
6729 | 2007 NULL, /* get_away */ |
2008 NULL, /* set_dir */ | |
2009 NULL, /* get_dir */ | |
2010 NULL, /* dir_search */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2011 yahoo_set_idle, |
6729 | 2012 NULL, /* change_passwd*/ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2013 yahoo_add_buddy, |
6729 | 2014 NULL, /* add_buddies */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2015 yahoo_remove_buddy, |
6729 | 2016 NULL, /*remove_buddies */ |
2017 NULL, /* add_permit */ | |
6760 | 2018 yahoo_add_deny, |
6729 | 2019 NULL, /* rem_permit */ |
6760 | 2020 yahoo_rem_deny, |
2021 yahoo_set_permit_deny, | |
6729 | 2022 NULL, /* warn */ |
2023 yahoo_c_join, | |
2024 yahoo_c_invite, | |
2025 yahoo_c_leave, | |
2026 NULL, /* chat whisper */ | |
2027 yahoo_c_send, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2028 yahoo_keepalive, |
6729 | 2029 NULL, /* register_user */ |
2030 NULL, /* get_cb_info */ | |
2031 NULL, /* get_cb_away */ | |
2032 NULL, /* alias_buddy */ | |
2033 NULL, /* change group */ | |
2034 NULL, /* rename group */ | |
2035 NULL, /* buddy_free */ | |
2036 NULL, /* convo_closed */ | |
2037 NULL, /* normalize */ | |
2038 NULL /* set_buddy_icon */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2039 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2040 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2041 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2042 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2043 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2044 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2045 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2046 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2047 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2048 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2049 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2050 "prpl-yahoo", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2051 "Yahoo", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2052 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2053 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2054 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2055 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2056 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2057 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
2058 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2059 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2060 NULL, /**< load */ |
6513 | 2061 yahoo_unload_plugin, /**< unload */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2062 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2063 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2064 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2065 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2066 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2067 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2068 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2069 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2070 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2071 GaimAccountOption *option; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2072 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
2073 option = gaim_account_option_string_new(_("Pager host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2074 YAHOO_PAGER_HOST); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2075 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2076 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2077 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
2078 option = gaim_account_option_int_new(_("Pager port"), "port", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2079 YAHOO_PAGER_PORT); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2080 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
2081 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2082 my_protocol = plugin; |
6513 | 2083 |
2084 yahoo_init_colorht(); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2085 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2086 |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2087 GAIM_INIT_PLUGIN(yahoo, init_plugin, info); |