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