Mercurial > pidgin.yaz
annotate src/protocols/yahoo/yahoo.c @ 5685:43ea75092684
[gaim-migrate @ 6106]
Better HIG compliance in the protocol option names.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 03 Jun 2003 03:59:43 +0000 |
parents | 46d7ad0dfa26 |
children | 059d95c67cda |
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 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include "config.h" | |
25 #endif | |
26 | |
3630 | 27 #ifndef _WIN32 |
2681 | 28 #include <netdb.h> |
29 #include <unistd.h> | |
30 #include <netinet/in.h> | |
31 #include <arpa/inet.h> | |
3630 | 32 #include <sys/socket.h> |
33 #else | |
34 #include <winsock.h> | |
35 #endif | |
36 | |
37 #include <errno.h> | |
2681 | 38 #include <string.h> |
39 #include <stdlib.h> | |
40 #include <stdio.h> | |
41 #include <time.h> | |
42 #include <sys/stat.h> | |
43 #include <ctype.h> | |
4608 | 44 #include "gaim.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
45 #include "accountopt.h" |
2681 | 46 #include "multi.h" |
47 #include "prpl.h" | |
48 #include "proxy.h" | |
3147 | 49 #include "md5.h" |
2681 | 50 |
3630 | 51 #ifdef _WIN32 |
52 #include "win32dep.h" | |
53 #endif | |
54 | |
5583 | 55 extern char *yahoo_crypt(const char *, const char *); |
2795
536bb833fdeb
[gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2786
diff
changeset
|
56 |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
57 /* #define YAHOO_DEBUG */ |
2681 | 58 |
59 #define USEROPT_MAIL 0 | |
60 | |
3147 | 61 #define YAHOO_PAGER_HOST "scs.yahoo.com" |
2681 | 62 #define YAHOO_PAGER_PORT 5050 |
63 | |
3467 | 64 #define YAHOO_PROTO_VER 0x0900 |
65 | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
66 enum yahoo_service { /* these are easier to see in hex */ |
2681 | 67 YAHOO_SERVICE_LOGON = 1, |
68 YAHOO_SERVICE_LOGOFF, | |
69 YAHOO_SERVICE_ISAWAY, | |
70 YAHOO_SERVICE_ISBACK, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
71 YAHOO_SERVICE_IDLE, /* 5 (placemarker) */ |
2681 | 72 YAHOO_SERVICE_MESSAGE, |
73 YAHOO_SERVICE_IDACT, | |
74 YAHOO_SERVICE_IDDEACT, | |
75 YAHOO_SERVICE_MAILSTAT, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
76 YAHOO_SERVICE_USERSTAT, /* 0xa */ |
2681 | 77 YAHOO_SERVICE_NEWMAIL, |
78 YAHOO_SERVICE_CHATINVITE, | |
79 YAHOO_SERVICE_CALENDAR, | |
80 YAHOO_SERVICE_NEWPERSONALMAIL, | |
81 YAHOO_SERVICE_NEWCONTACT, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
82 YAHOO_SERVICE_ADDIDENT, /* 0x10 */ |
2681 | 83 YAHOO_SERVICE_ADDIGNORE, |
84 YAHOO_SERVICE_PING, | |
85 YAHOO_SERVICE_GROUPRENAME, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
86 YAHOO_SERVICE_SYSMESSAGE = 0x14, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
87 YAHOO_SERVICE_PASSTHROUGH2 = 0x16, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
88 YAHOO_SERVICE_CONFINVITE = 0x18, |
2681 | 89 YAHOO_SERVICE_CONFLOGON, |
90 YAHOO_SERVICE_CONFDECLINE, | |
91 YAHOO_SERVICE_CONFLOGOFF, | |
92 YAHOO_SERVICE_CONFADDINVITE, | |
93 YAHOO_SERVICE_CONFMSG, | |
94 YAHOO_SERVICE_CHATLOGON, | |
95 YAHOO_SERVICE_CHATLOGOFF, | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
96 YAHOO_SERVICE_CHATMSG = 0x20, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
97 YAHOO_SERVICE_GAMELOGON = 0x28, |
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
98 YAHOO_SERVICE_GAMELOGOFF, |
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
99 YAHOO_SERVICE_GAMEMSG = 0x2a, |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
100 YAHOO_SERVICE_FILETRANSFER = 0x46, |
3019 | 101 YAHOO_SERVICE_NOTIFY = 0x4B, |
3147 | 102 YAHOO_SERVICE_AUTHRESP = 0x54, |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
103 YAHOO_SERVICE_LIST = 0x55, |
3147 | 104 YAHOO_SERVICE_AUTH = 0x57, |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
105 YAHOO_SERVICE_ADDBUDDY = 0x83, |
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
106 YAHOO_SERVICE_REMBUDDY = 0x84 |
2681 | 107 }; |
108 | |
109 enum yahoo_status { | |
2686
7b21c5446baf
[gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2683
diff
changeset
|
110 YAHOO_STATUS_AVAILABLE = 0, |
2681 | 111 YAHOO_STATUS_BRB, |
112 YAHOO_STATUS_BUSY, | |
113 YAHOO_STATUS_NOTATHOME, | |
114 YAHOO_STATUS_NOTATDESK, | |
115 YAHOO_STATUS_NOTINOFFICE, | |
116 YAHOO_STATUS_ONPHONE, | |
117 YAHOO_STATUS_ONVACATION, | |
118 YAHOO_STATUS_OUTTOLUNCH, | |
119 YAHOO_STATUS_STEPPEDOUT, | |
120 YAHOO_STATUS_INVISIBLE = 12, | |
121 YAHOO_STATUS_CUSTOM = 99, | |
122 YAHOO_STATUS_IDLE = 999, | |
2993 | 123 YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */ |
124 YAHOO_STATUS_TYPING = 0x16 | |
2681 | 125 }; |
3019 | 126 #define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */ |
2681 | 127 |
128 struct yahoo_data { | |
129 int fd; | |
130 guchar *rxqueue; | |
131 int rxlen; | |
132 GHashTable *hash; | |
3019 | 133 GHashTable *games; |
2681 | 134 int current_status; |
135 gboolean logged_in; | |
136 }; | |
137 | |
138 struct yahoo_pair { | |
139 int key; | |
140 char *value; | |
141 }; | |
142 | |
143 struct yahoo_packet { | |
144 guint16 service; | |
145 guint32 status; | |
146 guint32 id; | |
147 GSList *hash; | |
148 }; | |
149 | |
150 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) | |
151 | |
152 static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) | |
153 { | |
154 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); | |
155 | |
156 pkt->service = service; | |
157 pkt->status = status; | |
158 pkt->id = id; | |
159 | |
160 return pkt; | |
161 } | |
162 | |
3466 | 163 static void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value) |
2681 | 164 { |
165 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
166 pair->key = key; | |
167 pair->value = g_strdup(value); | |
168 pkt->hash = g_slist_append(pkt->hash, pair); | |
169 } | |
170 | |
171 static int yahoo_packet_length(struct yahoo_packet *pkt) | |
172 { | |
173 GSList *l; | |
174 | |
175 int len = 0; | |
176 | |
177 l = pkt->hash; | |
178 while (l) { | |
179 struct yahoo_pair *pair = l->data; | |
180 int tmp = pair->key; | |
181 do { | |
182 tmp /= 10; | |
183 len++; | |
184 } while (tmp); | |
185 len += 2; | |
186 len += strlen(pair->value); | |
187 len += 2; | |
188 l = l->next; | |
189 } | |
190 | |
191 return len; | |
192 } | |
193 | |
194 /* sometimes i wish prpls could #include things from other prpls. then i could just | |
195 * use the routines from libfaim and not have to admit to knowing how they work. */ | |
196 #define yahoo_put16(buf, data) ( \ | |
197 (*(buf) = (u_char)((data)>>8)&0xff), \ | |
198 (*((buf)+1) = (u_char)(data)&0xff), \ | |
199 2) | |
200 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
201 #define yahoo_put32(buf, data) ( \ | |
202 (*((buf)) = (u_char)((data)>>24)&0xff), \ | |
203 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ | |
204 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ | |
205 (*((buf)+3) = (u_char)(data)&0xff), \ | |
206 4) | |
207 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
208 (((*((buf)+1))<<16)&0x00ff0000) + \ | |
209 (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
210 (((*((buf)+3) )&0x000000ff))) | |
211 | |
212 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) | |
213 { | |
214 int pos = 0; | |
215 | |
216 while (pos + 1 < len) { | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
217 char key[64], *value = NULL; |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
218 int accept; |
2681 | 219 int x; |
220 | |
221 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); | |
222 | |
223 x = 0; | |
224 while (pos + 1 < len) { | |
225 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) | |
226 break; | |
227 key[x++] = data[pos++]; | |
228 } | |
229 key[x] = 0; | |
230 pos += 2; | |
231 pair->key = strtol(key, NULL, 10); | |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
232 accept = x; /* if x is 0 there was no key, so don't accept it */ |
2681 | 233 |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
234 if (len - pos + 1 <= 0) { |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
235 /* Truncated. Garbage or something. */ |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
236 accept = 0; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
237 } |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
238 |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
239 if (accept) { |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
240 value = g_malloc(len - pos + 1); |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
241 x = 0; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
242 while (pos + 1 < len) { |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
243 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
244 break; |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
245 value[x++] = data[pos++]; |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
246 } |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
247 value[x] = 0; |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
248 pair->value = g_strdup(value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
249 g_free(value); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
250 pkt->hash = g_slist_append(pkt->hash, pair); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
251 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
252 "Key: %d \tValue: %s\n", pair->key, pair->value); |
2724
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
253 } else { |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
254 g_free(pair); |
7f3f4aa114ad
[gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2723
diff
changeset
|
255 } |
3996
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
256 pos += 2; |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
257 |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
258 /* Skip over garbage we've noticed in the mail notifications */ |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
259 if (data[0] == '9' && data[pos] == 0x01) |
3fdfe7872118
[gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents:
3768
diff
changeset
|
260 pos++; |
2681 | 261 } |
262 } | |
263 | |
264 static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) | |
265 { | |
266 GSList *l = pkt->hash; | |
267 int pos = 0; | |
268 | |
269 while (l) { | |
270 struct yahoo_pair *pair = l->data; | |
271 guchar buf[100]; | |
272 | |
273 g_snprintf(buf, sizeof(buf), "%d", pair->key); | |
274 strcpy(data + pos, buf); | |
275 pos += strlen(buf); | |
276 data[pos++] = 0xc0; | |
277 data[pos++] = 0x80; | |
278 | |
279 strcpy(data + pos, pair->value); | |
280 pos += strlen(pair->value); | |
281 data[pos++] = 0xc0; | |
282 data[pos++] = 0x80; | |
283 | |
284 l = l->next; | |
285 } | |
286 } | |
287 | |
288 static void yahoo_packet_dump(guchar *data, int len) | |
289 { | |
290 #ifdef YAHOO_DEBUG | |
291 int i; | |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
292 |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
293 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
294 |
2681 | 295 for (i = 0; i + 1 < len; i += 2) { |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
296 if ((i % 16 == 0) && i) { |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
297 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
298 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
299 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
300 |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
301 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]); |
2681 | 302 } |
303 if (i < len) | |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
304 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]); |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
305 |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
306 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
307 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
308 |
2681 | 309 for (i = 0; i < len; i++) { |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
310 if ((i % 16 == 0) && i) { |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
311 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
312 gaim_debug(GAIM_DEBUG_MISC, "yahoo", ""); |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
313 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
314 |
2681 | 315 if (isprint(data[i])) |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
316 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]); |
2681 | 317 else |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
318 gaim_debug(GAIM_DEBUG_MISC, NULL, ". "); |
2681 | 319 } |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
320 |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
321 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
2681 | 322 #endif |
323 } | |
324 | |
325 static int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt) | |
326 { | |
327 int pktlen = yahoo_packet_length(pkt); | |
328 int len = YAHOO_PACKET_HDRLEN + pktlen; | |
329 int ret; | |
330 | |
331 guchar *data; | |
332 int pos = 0; | |
333 | |
334 if (yd->fd < 0) | |
335 return -1; | |
336 | |
337 data = g_malloc0(len + 1); | |
338 | |
339 memcpy(data + pos, "YMSG", 4); pos += 4; | |
3467 | 340 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); |
2681 | 341 pos += yahoo_put16(data + pos, 0x0000); |
342 pos += yahoo_put16(data + pos, pktlen); | |
343 pos += yahoo_put16(data + pos, pkt->service); | |
344 pos += yahoo_put32(data + pos, pkt->status); | |
345 pos += yahoo_put32(data + pos, pkt->id); | |
346 | |
347 yahoo_packet_write(pkt, data + pos); | |
348 | |
349 yahoo_packet_dump(data, len); | |
350 ret = write(yd->fd, data, len); | |
351 g_free(data); | |
352 | |
353 return ret; | |
354 } | |
355 | |
356 static void yahoo_packet_free(struct yahoo_packet *pkt) | |
357 { | |
358 while (pkt->hash) { | |
359 struct yahoo_pair *pair = pkt->hash->data; | |
360 g_free(pair->value); | |
361 g_free(pair); | |
362 pkt->hash = g_slist_remove(pkt->hash, pair); | |
363 } | |
364 g_free(pkt); | |
365 } | |
366 | |
5583 | 367 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 368 { |
369 struct yahoo_data *yd = gc->proto_data; | |
370 GSList *l = pkt->hash; | |
371 char *name = NULL; | |
372 int state = 0; | |
3019 | 373 int gamestate = 0; |
2681 | 374 char *msg = NULL; |
3019 | 375 |
2681 | 376 while (l) { |
377 struct yahoo_pair *pair = l->data; | |
378 | |
379 switch (pair->key) { | |
380 case 0: /* we won't actually do anything with this */ | |
381 break; | |
382 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
|
383 if (!yd->logged_in) { |
5583 | 384 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
385 serv_finish_login(gc); |
5583 | 386 gaim_connection_set_display_name(gc, pair->value); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
387 yd->logged_in = TRUE; |
2681 | 388 |
3147 | 389 /* this requests the list. i have a feeling that this is very evil |
390 * | |
391 * scs.yahoo.com sends you the list before this packet without it being | |
392 * requested | |
393 * | |
394 * do_import(gc, NULL); | |
395 * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); | |
396 * yahoo_send_packet(yd, newpkt); | |
397 * yahoo_packet_free(newpkt); | |
398 */ | |
399 | |
400 } | |
2681 | 401 break; |
402 case 8: /* how many online buddies we have */ | |
403 break; | |
404 case 7: /* the current buddy */ | |
405 name = pair->value; | |
406 break; | |
407 case 10: /* state */ | |
408 state = strtol(pair->value, NULL, 10); | |
409 break; | |
410 case 19: /* custom message */ | |
411 msg = pair->value; | |
412 break; | |
413 case 11: /* i didn't know what this was in the old protocol either */ | |
414 break; | |
415 case 17: /* in chat? */ | |
416 break; | |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
417 case 13: /* in pager? */ |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
418 if (pkt->service == YAHOO_SERVICE_LOGOFF || |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
419 strtol(pair->value, NULL, 10) == 0) { |
4732 | 420 serv_got_update(gc, name, 0, 0, 0, 0, 0); |
2807
f01e6a425136
[gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2805
diff
changeset
|
421 break; |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
422 } |
3019 | 423 if (g_hash_table_lookup(yd->games, name)) |
424 gamestate = YAHOO_STATUS_GAME; | |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
425 if (state == YAHOO_STATUS_CUSTOM) { |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
426 gpointer val = g_hash_table_lookup(yd->hash, name); |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
427 if (val) { |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
428 g_free(val); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
429 g_hash_table_insert(yd->hash, name, |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
430 msg ? g_strdup(msg) : g_malloc0(1)); |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
431 } else |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
432 g_hash_table_insert(yd->hash, g_strdup(name), |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
433 msg ? g_strdup(msg) : g_malloc0(1)); |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
434 } |
4777 | 435 if (state == YAHOO_STATUS_AVAILABLE) |
436 serv_got_update(gc, name, 1, 0, 0, 0, gamestate); | |
5002 | 437 else if (state == YAHOO_STATUS_IDLE) |
438 serv_got_update(gc, name, 1, 0, 0, -1, (state << 2) | UC_UNAVAILABLE | gamestate); | |
4777 | 439 else |
440 serv_got_update(gc, name, 1, 0, 0, 0, (state << 2) | UC_UNAVAILABLE | gamestate); | |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
441 break; |
2805
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
442 case 60: /* no clue */ |
9b3c7d2a6e9a
[gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2795
diff
changeset
|
443 break; |
2979 | 444 case 16: /* Custom error message */ |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
445 gaim_notify_error(gc, NULL, pair->value, NULL); |
2951 | 446 break; |
2681 | 447 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
448 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
449 "Unknown status key %d\n", pair->key); |
2681 | 450 break; |
451 } | |
452 | |
453 l = l->next; | |
454 } | |
455 } | |
456 | |
5583 | 457 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 458 { |
459 GSList *l = pkt->hash; | |
460 gboolean export = FALSE; | |
4775 | 461 struct buddy *b; |
462 struct group *g; | |
2681 | 463 |
464 while (l) { | |
465 char **lines; | |
466 char **split; | |
467 char **buddies; | |
468 char **tmp, **bud; | |
469 | |
470 struct yahoo_pair *pair = l->data; | |
471 l = l->next; | |
472 | |
473 if (pair->key != 87) | |
474 continue; | |
475 | |
476 lines = g_strsplit(pair->value, "\n", -1); | |
477 for (tmp = lines; *tmp; tmp++) { | |
478 split = g_strsplit(*tmp, ":", 2); | |
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
479 if (!split) |
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
480 continue; |
2702
94b4271b9567
[gaim-migrate @ 2715]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2697
diff
changeset
|
481 if (!split[0] || !split[1]) { |
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
482 g_strfreev(split); |
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
483 continue; |
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
484 } |
2681 | 485 buddies = g_strsplit(split[1], ",", -1); |
2697
7759f914a009
[gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
486 for (bud = buddies; bud && *bud; bud++) |
4775 | 487 if (!(b = gaim_find_buddy(gc->account, *bud))) { |
488 if (!(g = gaim_find_group(split[0]))) { | |
489 g = gaim_group_new(split[0]); | |
490 gaim_blist_add_group(g, NULL); | |
491 } | |
492 b = gaim_buddy_new(gc->account, *bud, NULL); | |
493 gaim_blist_add_buddy(b, g, NULL); | |
2681 | 494 export = TRUE; |
495 } | |
496 g_strfreev(buddies); | |
497 g_strfreev(split); | |
498 } | |
499 g_strfreev(lines); | |
500 } | |
501 | |
502 if (export) | |
4349 | 503 gaim_blist_save(); |
2681 | 504 } |
505 | |
5583 | 506 static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) |
2993 | 507 { |
508 char *msg = NULL; | |
509 char *from = NULL; | |
3019 | 510 char *stat = NULL; |
511 char *game = NULL; | |
2993 | 512 GSList *l = pkt->hash; |
3019 | 513 struct yahoo_data *yd = (struct yahoo_data*) gc->proto_data; |
2993 | 514 while (l) { |
515 struct yahoo_pair *pair = l->data; | |
516 if (pair->key == 4) | |
517 from = pair->value; | |
518 if (pair->key == 49) | |
519 msg = pair->value; | |
3001 | 520 if (pair->key == 13) |
3019 | 521 stat = pair->value; |
522 if (pair->key == 14) | |
523 game = pair->value; | |
2993 | 524 l = l->next; |
525 } | |
3640 | 526 |
527 if (!msg) | |
528 return; | |
3019 | 529 |
4793 | 530 if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) { |
3019 | 531 if (*stat == '1') |
3768 | 532 serv_got_typing(gc, from, 0, TYPING); |
3019 | 533 else |
534 serv_got_typing_stopped(gc, from); | |
4793 | 535 } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) { |
4687 | 536 struct buddy *bud = gaim_find_buddy(gc->account, from); |
3019 | 537 void *free1=NULL, *free2=NULL; |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
538 if (!bud) { |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
539 gaim_debug(GAIM_DEBUG_WARNING, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
540 "%s is playing a game, and doesn't want " |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
541 "you to know.\n", from); |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
542 } |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
543 |
3019 | 544 if (*stat == '1') { |
545 if (g_hash_table_lookup_extended (yd->games, from, free1, free2)) { | |
546 g_free(free1); | |
547 g_free(free2); | |
548 } | |
549 g_hash_table_insert (yd->games, g_strdup(from), g_strdup(game)); | |
3020 | 550 if (bud) |
4732 | 551 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc | YAHOO_STATUS_GAME); |
3019 | 552 } else { |
553 if (g_hash_table_lookup_extended (yd->games, from, free1, free2)) { | |
554 g_free(free1); | |
555 g_free(free2); | |
556 g_hash_table_remove (yd->games, from); | |
557 } | |
3020 | 558 if (bud) |
4732 | 559 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc & ~YAHOO_STATUS_GAME); |
3019 | 560 } |
561 } | |
2993 | 562 } |
563 | |
5583 | 564 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 565 { |
566 char *msg = NULL; | |
567 char *from = NULL; | |
568 time_t tm = time(NULL); | |
569 GSList *l = pkt->hash; | |
3021 | 570 |
2681 | 571 while (l) { |
572 struct yahoo_pair *pair = l->data; | |
573 if (pair->key == 4) | |
574 from = pair->value; | |
575 if (pair->key == 14) | |
576 msg = pair->value; | |
577 if (pair->key == 15) | |
578 tm = strtol(pair->value, NULL, 10); | |
579 l = l->next; | |
580 } | |
581 | |
3021 | 582 if (pkt->status <= 1 || pkt->status == 5) { |
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
583 char *m; |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
584 int i, j; |
2681 | 585 strip_linefeed(msg); |
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
586 m = msg; |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
587 for (i = 0, j = 0; m[i]; i++) { |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
588 if (m[i] == 033) { |
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
589 while (m[i] && (m[i] != 'm')) |
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
590 i++; |
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
591 if (!m[i]) |
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
592 i--; |
2715
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
593 continue; |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
594 } |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
595 msg[j++] = m[i]; |
e901fd3ebbad
[gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2708
diff
changeset
|
596 } |
2813
bda5b89ba2f9
[gaim-migrate @ 2826]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2807
diff
changeset
|
597 msg[j] = 0; |
3642 | 598 serv_got_im(gc, from, g_strdup(msg), 0, tm, -1); |
2681 | 599 } else if (pkt->status == 2) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
600 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
601 _("Your Yahoo! message did not get sent."), NULL); |
2681 | 602 } |
603 } | |
604 | |
605 | |
5583 | 606 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 607 { |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
608 struct yahoo_data *yd = gc->proto_data; |
2681 | 609 char *id = NULL; |
610 char *who = NULL; | |
611 char *msg = NULL; | |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
612 char *name = NULL; |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
613 int state = YAHOO_STATUS_AVAILABLE; |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
614 int online = FALSE; |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
615 |
2681 | 616 GSList *l = pkt->hash; |
617 | |
618 while (l) { | |
619 struct yahoo_pair *pair = l->data; | |
620 if (pair->key == 1) | |
621 id = pair->value; | |
622 else if (pair->key == 3) | |
623 who = pair->value; | |
624 else if (pair->key == 14) | |
625 msg = pair->value; | |
5002 | 626 else if (pair->key == 7) |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
627 name = pair->value; |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
628 else if (pair->key == 10) |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
629 state = strtol(pair->value, NULL, 10); |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
630 else if (pair->key == 13) |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
631 online = strtol(pair->value, NULL, 10); |
2681 | 632 l = l->next; |
633 } | |
634 | |
2682
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
635 if (id) |
db2b0b733732
[gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
636 show_got_added(gc, id, who, NULL, msg); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
637 if (name) { |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
638 if (state == YAHOO_STATUS_AVAILABLE) |
4732 | 639 serv_got_update(gc, name, 1, 0, 0, 0, 0); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
640 else if (state == YAHOO_STATUS_IDLE) |
5002 | 641 serv_got_update(gc, name, 1, 0, 0, -1, (state << 2)); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
642 else |
4732 | 643 serv_got_update(gc, name, 1, 0, 0, 0, (state << 2) | UC_UNAVAILABLE); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
644 if (state == YAHOO_STATUS_CUSTOM) { |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
645 gpointer val = g_hash_table_lookup(yd->hash, name); |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
646 if (val) { |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
647 g_free(val); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
648 g_hash_table_insert(yd->hash, name, |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
649 msg ? g_strdup(msg) : g_malloc0(1)); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
650 } else |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
651 g_hash_table_insert(yd->hash, g_strdup(name), |
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
652 msg ? g_strdup(msg) : g_malloc0(1)); |
2683
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
653 } |
4836eae8dd8c
[gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2682
diff
changeset
|
654 } |
2681 | 655 } |
656 | |
5583 | 657 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 658 { |
5583 | 659 GaimAccount *account = gaim_connection_get_account(gc); |
2681 | 660 char *who = NULL; |
661 char *email = NULL; | |
662 char *subj = NULL; | |
663 int count = 0; | |
664 GSList *l = pkt->hash; | |
665 | |
5583 | 666 if (!gaim_account_get_check_mail(account)) |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
667 return; |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
668 |
2681 | 669 while (l) { |
670 struct yahoo_pair *pair = l->data; | |
671 if (pair->key == 9) | |
672 count = strtol(pair->value, NULL, 10); | |
673 else if (pair->key == 43) | |
674 who = pair->value; | |
675 else if (pair->key == 42) | |
676 email = pair->value; | |
677 else if (pair->key == 18) | |
678 subj = pair->value; | |
679 l = l->next; | |
680 } | |
681 | |
4001 | 682 if (who && subj && email && *email) { |
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
683 char *from = g_strdup_printf("%s (%s)", who, email); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
684 |
5583 | 685 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
|
686 "http://mail.yahoo.com/", NULL, NULL); |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
687 |
2850
cbe6a1e63a72
[gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2813
diff
changeset
|
688 g_free(from); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
689 } else if (count > 0) { |
5583 | 690 const char *to = gaim_account_get_username(account); |
5521
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
691 const char *url = "http://mail.yahoo.com/"; |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
692 |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
693 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
694 NULL, NULL); |
76ec14ba51d7
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
695 } |
2681 | 696 } |
3147 | 697 /* This is the y64 alphabet... it's like base64, but has a . and a _ */ |
698 char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; | |
699 | |
700 /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function | |
701 * in util.c, but it has a bug I don't feel like finding right now ;) */ | |
702 void to_y64(unsigned char *out, const unsigned char *in, int inlen) | |
703 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ | |
704 { | |
705 for (; inlen >= 3; inlen -= 3) | |
706 { | |
707 *out++ = base64digits[in[0] >> 2]; | |
708 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | |
709 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; | |
710 *out++ = base64digits[in[2] & 0x3f]; | |
711 in += 3; | |
712 } | |
713 if (inlen > 0) | |
714 { | |
715 unsigned char fragment; | |
716 | |
717 *out++ = base64digits[in[0] >> 2]; | |
718 fragment = (in[0] << 4) & 0x30; | |
719 if (inlen > 1) | |
720 fragment |= in[1] >> 4; | |
721 *out++ = base64digits[fragment]; | |
722 *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c]; | |
723 *out++ = '-'; | |
724 } | |
725 *out = '\0'; | |
726 } | |
727 | |
5583 | 728 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt) |
3147 | 729 { |
730 char *seed = NULL; | |
731 char *sn = NULL; | |
732 GSList *l = pkt->hash; | |
733 struct yahoo_data *yd = gc->proto_data; | |
734 | |
735 while (l) { | |
736 struct yahoo_pair *pair = l->data; | |
737 if (pair->key == 94) | |
738 seed = pair->value; | |
739 if (pair->key == 1) | |
740 sn = pair->value; | |
741 l = l->next; | |
742 } | |
743 | |
744 if (seed) { | |
745 struct yahoo_packet *pack; | |
5583 | 746 GaimAccount *account = gaim_connection_get_account(gc); |
747 const char *name = gaim_account_get_username(account); | |
748 const char *pass = gaim_account_get_password(account); | |
749 | |
3147 | 750 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly |
751 * will soon do so in the rest of the world. | |
752 * | |
753 * The new clients use this authentication method. I warn you in advance, it's | |
754 * bizzare, convoluted, inordinately complicated. It's also no more secure than | |
755 * crypt() was. The only purpose this scheme could serve is to prevent third | |
756 * part clients from connecting to their servers. | |
757 * | |
758 * Sorry, Yahoo. | |
759 */ | |
760 | |
761 md5_byte_t result[16]; | |
762 md5_state_t ctx; | |
5583 | 763 |
3147 | 764 char *crypt_result; |
5583 | 765 char password_hash[25]; |
766 char crypt_hash[25]; | |
3147 | 767 char *hash_string_p = g_malloc(50 + strlen(sn)); |
768 char *hash_string_c = g_malloc(50 + strlen(sn)); | |
769 | |
770 char checksum; | |
771 | |
3157 | 772 int sv; |
3147 | 773 |
5583 | 774 char result6[25]; |
775 char result96[25]; | |
3147 | 776 |
777 sv = seed[15]; | |
3157 | 778 sv = sv % 8; |
3147 | 779 |
780 md5_init(&ctx); | |
5583 | 781 md5_append(&ctx, pass, strlen(pass)); |
3147 | 782 md5_finish(&ctx, result); |
783 to_y64(password_hash, result, 16); | |
784 | |
785 md5_init(&ctx); | |
5583 | 786 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
3147 | 787 md5_append(&ctx, crypt_result, strlen(crypt_result)); |
788 md5_finish(&ctx, result); | |
789 to_y64(crypt_hash, result, 16); | |
3157 | 790 |
791 switch (sv) { | |
3147 | 792 case 1: |
793 case 6: | |
3157 | 794 checksum = seed[seed[9] % 16]; |
3147 | 795 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 796 "%c%s%s%s", checksum, name, seed, password_hash); |
3157 | 797 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 798 "%c%s%s%s", checksum, name, seed, crypt_hash); |
3147 | 799 break; |
800 case 2: | |
801 case 7: | |
3157 | 802 checksum = seed[seed[15] % 16]; |
3147 | 803 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 804 "%c%s%s%s", checksum, seed, password_hash, name); |
3157 | 805 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 806 "%c%s%s%s", checksum, seed, crypt_hash, name); |
3157 | 807 break; |
3147 | 808 case 3: |
3157 | 809 checksum = seed[seed[1] % 16]; |
3147 | 810 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 811 "%c%s%s%s", checksum, name, password_hash, seed); |
3157 | 812 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 813 "%c%s%s%s", checksum, name, crypt_hash, seed); |
3157 | 814 break; |
815 case 4: | |
816 checksum = seed[seed[3] % 16]; | |
817 g_snprintf(hash_string_p, strlen(sn) + 50, | |
5583 | 818 "%c%s%s%s", checksum, password_hash, seed, name); |
3147 | 819 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 820 "%c%s%s%s", checksum, crypt_hash, seed, name); |
3157 | 821 break; |
3147 | 822 case 0: |
823 case 5: | |
3157 | 824 checksum = seed[seed[7] % 16]; |
3147 | 825 g_snprintf(hash_string_p, strlen(sn) + 50, |
5583 | 826 "%c%s%s%s", checksum, password_hash, name, seed); |
3157 | 827 g_snprintf(hash_string_c, strlen(sn) + 50, |
5583 | 828 "%c%s%s%s", checksum, crypt_hash, name, seed); |
3157 | 829 break; |
3147 | 830 } |
3157 | 831 |
3147 | 832 md5_init(&ctx); |
3157 | 833 md5_append(&ctx, hash_string_p, strlen(hash_string_p)); |
3147 | 834 md5_finish(&ctx, result); |
835 to_y64(result6, result, 16); | |
836 | |
837 md5_init(&ctx); | |
838 md5_append(&ctx, hash_string_c, strlen(hash_string_c)); | |
839 md5_finish(&ctx, result); | |
840 to_y64(result96, result, 16); | |
841 | |
842 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | |
5583 | 843 yahoo_packet_hash(pack, 0, name); |
3147 | 844 yahoo_packet_hash(pack, 6, result6); |
845 yahoo_packet_hash(pack, 96, result96); | |
5583 | 846 yahoo_packet_hash(pack, 1, name); |
3147 | 847 |
848 yahoo_send_packet(yd, pack); | |
849 | |
850 g_free(hash_string_p); | |
851 g_free(hash_string_c); | |
852 | |
853 yahoo_packet_free(pack); | |
854 } | |
855 } | |
2681 | 856 |
5583 | 857 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
2681 | 858 { |
859 switch (pkt->service) | |
860 { | |
861 case YAHOO_SERVICE_LOGON: | |
2771
450f4f9d2f23
[gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2741
diff
changeset
|
862 case YAHOO_SERVICE_LOGOFF: |
2681 | 863 case YAHOO_SERVICE_ISAWAY: |
2737
f61c1f3a6afa
[gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2724
diff
changeset
|
864 case YAHOO_SERVICE_ISBACK: |
3019 | 865 case YAHOO_SERVICE_GAMELOGON: |
866 case YAHOO_SERVICE_GAMELOGOFF: | |
2681 | 867 yahoo_process_status(gc, pkt); |
868 break; | |
3019 | 869 case YAHOO_SERVICE_NOTIFY: |
870 yahoo_process_notify(gc, pkt); | |
2993 | 871 break; |
2681 | 872 case YAHOO_SERVICE_MESSAGE: |
2786
318f846120e2
[gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2772
diff
changeset
|
873 case YAHOO_SERVICE_GAMEMSG: |
2681 | 874 yahoo_process_message(gc, pkt); |
875 break; | |
876 case YAHOO_SERVICE_NEWMAIL: | |
877 yahoo_process_mail(gc, pkt); | |
878 break; | |
879 case YAHOO_SERVICE_NEWCONTACT: | |
880 yahoo_process_contact(gc, pkt); | |
881 break; | |
882 case YAHOO_SERVICE_LIST: | |
883 yahoo_process_list(gc, pkt); | |
884 break; | |
3147 | 885 case YAHOO_SERVICE_AUTH: |
886 yahoo_process_auth(gc, pkt); | |
887 break; | |
2681 | 888 default: |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
889 gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
890 "Unhandled service 0x%02x\n", pkt->service); |
2681 | 891 break; |
892 } | |
893 } | |
894 | |
895 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
896 { | |
5583 | 897 GaimConnection *gc = data; |
2681 | 898 struct yahoo_data *yd = gc->proto_data; |
899 char buf[1024]; | |
900 int len; | |
901 | |
902 len = read(yd->fd, buf, sizeof(buf)); | |
903 | |
904 if (len <= 0) { | |
5583 | 905 gaim_connection_error(gc, "Unable to read"); |
2681 | 906 return; |
907 } | |
908 | |
909 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
910 memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
911 yd->rxlen += len; | |
912 | |
913 while (1) { | |
914 struct yahoo_packet *pkt; | |
915 int pos = 0; | |
916 int pktlen; | |
917 | |
918 if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
919 return; | |
920 | |
921 pos += 4; /* YMSG */ | |
922 pos += 2; | |
923 pos += 2; | |
924 | |
925 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
926 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
927 "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
2681 | 928 |
929 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
930 return; | |
931 | |
932 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
933 | |
934 pkt = yahoo_packet_new(0, 0, 0); | |
935 | |
936 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
3021 | 937 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
5220
7b9d78fa051e
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
938 gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
5216
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
939 "Yahoo Service: 0x%02x Status: %d\n", |
00bd3019749e
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
940 pkt->service, pkt->status); |
2681 | 941 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
942 | |
943 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
944 | |
945 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
946 if (yd->rxlen) { | |
947 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
948 g_free(yd->rxqueue); | |
949 yd->rxqueue = tmp; | |
950 } else { | |
951 g_free(yd->rxqueue); | |
952 yd->rxqueue = NULL; | |
953 } | |
954 | |
955 yahoo_packet_process(gc, pkt); | |
956 | |
957 yahoo_packet_free(pkt); | |
958 } | |
959 } | |
960 | |
961 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
962 { | |
5583 | 963 GaimConnection *gc = data; |
2681 | 964 struct yahoo_data *yd; |
965 struct yahoo_packet *pkt; | |
966 | |
5590
011a0a975060
[gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents:
5583
diff
changeset
|
967 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2681 | 968 close(source); |
969 return; | |
970 } | |
971 | |
972 if (source < 0) { | |
5583 | 973 gaim_connection_error(gc, "Unable to connect"); |
2681 | 974 return; |
975 } | |
976 | |
977 yd = gc->proto_data; | |
978 yd->fd = source; | |
979 | |
3147 | 980 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); |
2681 | 981 |
5583 | 982 yahoo_packet_hash(pkt, 1, gaim_account_get_username(gaim_connection_get_account(gc))); |
2681 | 983 yahoo_send_packet(yd, pkt); |
984 | |
985 yahoo_packet_free(pkt); | |
986 | |
987 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
988 } | |
989 | |
5583 | 990 static void yahoo_login(GaimAccount *account) { |
991 GaimConnection *gc = gaim_account_get_connection(account); | |
2681 | 992 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
993 | |
5583 | 994 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
2681 | 995 |
996 yd->fd = -1; | |
997 yd->hash = g_hash_table_new(g_str_hash, g_str_equal); | |
3019 | 998 yd->games = g_hash_table_new(g_str_hash, g_str_equal); |
2681 | 999 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
1000 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), |
5583 | 1001 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), |
1002 yahoo_got_connected, gc) != 0) { | |
1003 gaim_connection_error(gc, "Connection problem"); | |
2681 | 1004 return; |
1005 } | |
1006 | |
1007 } | |
1008 | |
1009 static gboolean yahoo_destroy_hash(gpointer key, gpointer val, gpointer data) | |
1010 { | |
1011 g_free(key); | |
1012 g_free(val); | |
1013 return TRUE; | |
1014 } | |
1015 | |
5583 | 1016 static void yahoo_close(GaimConnection *gc) { |
2681 | 1017 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
1018 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); | |
1019 g_hash_table_destroy(yd->hash); | |
3019 | 1020 g_hash_table_foreach_remove(yd->games, yahoo_destroy_hash, NULL); |
1021 g_hash_table_destroy(yd->games); | |
2681 | 1022 if (yd->fd >= 0) |
1023 close(yd->fd); | |
3720
34c95669952f
[gaim-migrate @ 3853]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3642
diff
changeset
|
1024 |
2681 | 1025 if (yd->rxqueue) |
1026 g_free(yd->rxqueue); | |
2687
2d544f48146d
[gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2686
diff
changeset
|
1027 yd->rxlen = 0; |
2681 | 1028 if (gc->inpa) |
1029 gaim_input_remove(gc->inpa); | |
1030 g_free(yd); | |
1031 } | |
1032 | |
5583 | 1033 static const char *yahoo_list_icon(GaimAccount *a, struct buddy *b) |
2681 | 1034 { |
4687 | 1035 return "yahoo"; |
2681 | 1036 } |
4916 | 1037 |
1038 static void yahoo_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) | |
1039 { | |
1040 int i = 0; | |
1041 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
5068 | 1042 if (b->present == GAIM_BUDDY_OFFLINE) { |
4916 | 1043 *se = "offline"; |
1044 return; | |
1045 } else { | |
1046 if (b->uc & UC_UNAVAILABLE) | |
1047 emblems[i++] = "away"; | |
1048 if (b->uc & YAHOO_STATUS_GAME) | |
1049 emblems[i++] = "game"; | |
1050 } | |
1051 *se = emblems[0]; | |
1052 *sw = emblems[1]; | |
1053 *nw = emblems[2]; | |
1054 *ne = emblems[3]; | |
1055 } | |
2681 | 1056 |
1057 static char *yahoo_get_status_string(enum yahoo_status a) | |
1058 { | |
1059 switch (a) { | |
1060 case YAHOO_STATUS_BRB: | |
4596 | 1061 return _("Be Right Back"); |
2681 | 1062 case YAHOO_STATUS_BUSY: |
4596 | 1063 return _("Busy"); |
2681 | 1064 case YAHOO_STATUS_NOTATHOME: |
4596 | 1065 return _("Not At Home"); |
2681 | 1066 case YAHOO_STATUS_NOTATDESK: |
4596 | 1067 return _("Not At Desk"); |
2681 | 1068 case YAHOO_STATUS_NOTINOFFICE: |
4596 | 1069 return _("Not In Office"); |
2681 | 1070 case YAHOO_STATUS_ONPHONE: |
4606 | 1071 return _("On The Phone"); |
2681 | 1072 case YAHOO_STATUS_ONVACATION: |
4596 | 1073 return _("On Vacation"); |
2681 | 1074 case YAHOO_STATUS_OUTTOLUNCH: |
4596 | 1075 return _("Out To Lunch"); |
2681 | 1076 case YAHOO_STATUS_STEPPEDOUT: |
4596 | 1077 return _("Stepped Out"); |
2873
26be84883f91
[gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
1078 case YAHOO_STATUS_INVISIBLE: |
4596 | 1079 return _("Invisible"); |
4730 | 1080 case YAHOO_STATUS_IDLE: |
1081 return _("Idle"); | |
2879
5fc5123b7098
[gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2878
diff
changeset
|
1082 default: |
4596 | 1083 return _("Online"); |
2681 | 1084 } |
1085 } | |
1086 | |
5583 | 1087 static void yahoo_game(GaimConnection *gc, const char *name) { |
3019 | 1088 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
1089 char *game = g_hash_table_lookup(yd->games, name); | |
1090 char *t; | |
1091 char url[256]; | |
1092 | |
1093 if (!game) | |
1094 return; | |
1095 t = game = g_strdup(strstr(game, "ante?room=")); | |
1096 while (*t != '\t') | |
1097 t++; | |
1098 *t = 0; | |
1099 g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game); | |
1100 open_url(NULL, url); | |
1101 g_free(game); | |
1102 } | |
4722 | 1103 |
4732 | 1104 static char *yahoo_status_text(struct buddy *b) |
4722 | 1105 { |
1106 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data; | |
4730 | 1107 if (b->uc & UC_UNAVAILABLE) { |
4732 | 1108 if ((b->uc >> 2) != YAHOO_STATUS_CUSTOM) |
1109 return g_strdup(yahoo_get_status_string(b->uc >> 2)); | |
4777 | 1110 else { |
1111 char *stripped = strip_html(g_hash_table_lookup(yd->hash, b->name)); | |
1112 if(stripped) { | |
1113 char *ret = g_markup_escape_text(stripped, strlen(stripped)); | |
1114 g_free(stripped); | |
1115 return ret; | |
1116 } | |
1117 } | |
4722 | 1118 } |
4729 | 1119 return NULL; |
4722 | 1120 } |
1121 | |
4724 | 1122 static char *yahoo_tooltip_text(struct buddy *b) |
1123 { | |
1124 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data; | |
4730 | 1125 if (b->uc & UC_UNAVAILABLE) { |
4745 | 1126 char *status; |
1127 char *ret; | |
4731 | 1128 if ((b->uc >> 2) != YAHOO_STATUS_CUSTOM) |
4745 | 1129 status = g_strdup(yahoo_get_status_string(b->uc >> 2)); |
4724 | 1130 else |
4745 | 1131 status = strip_html(g_hash_table_lookup(yd->hash, b->name)); |
1132 if(status) { | |
4777 | 1133 char *escaped = g_markup_escape_text(status, strlen(status)); |
1134 ret = g_strdup_printf(_("<b>Status:</b> %s"), escaped); | |
4745 | 1135 g_free(status); |
4777 | 1136 g_free(escaped); |
4745 | 1137 return ret; |
1138 } | |
4724 | 1139 } |
4729 | 1140 return NULL; |
1141 } | |
1142 | |
5583 | 1143 static GList *yahoo_buddy_menu(GaimConnection *gc, const char *who) |
2681 | 1144 { |
1145 GList *m = NULL; | |
1146 struct proto_buddy_menu *pbm; | |
1147 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
4687 | 1148 struct buddy *b = gaim_find_buddy(gc->account, who); /* this should never be null. if it is, |
2681 | 1149 segfault and get the bug report. */ |
3019 | 1150 static char buf2[1024]; |
4722 | 1151 |
3019 | 1152 if (b->uc | YAHOO_STATUS_GAME) { |
1153 char *game = g_hash_table_lookup(yd->games, b->name); | |
1154 char *room; | |
1155 if (!game) | |
1156 return m; | |
1157 if (game) { | |
1158 char *t; | |
1159 pbm = g_new0(struct proto_buddy_menu, 1); | |
1160 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */ | |
1161 return NULL; | |
1162 while (*room && *room != '\t') /* skip to the tab */ | |
1163 room++; | |
1164 t = room++; /* room as now at the name */ | |
1165 while (*t != '\n') | |
1166 t++; /* replace the \n with a space */ | |
1167 *t = ' '; | |
1168 g_snprintf(buf2, sizeof buf2, "%s", room); | |
1169 pbm->label = buf2; | |
1170 pbm->callback = yahoo_game; | |
1171 pbm->gc = gc; | |
1172 m = g_list_append(m, pbm); | |
1173 } | |
1174 } | |
4722 | 1175 |
2681 | 1176 return m; |
1177 } | |
1178 | |
5583 | 1179 static void yahoo_act_id(GaimConnection *gc, const char *entry) |
2681 | 1180 { |
1181 struct yahoo_data *yd = gc->proto_data; | |
1182 | |
1183 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
1184 yahoo_packet_hash(pkt, 3, entry); | |
1185 yahoo_send_packet(yd, pkt); | |
1186 yahoo_packet_free(pkt); | |
1187 | |
5583 | 1188 gaim_connection_set_display_name(gc, entry); |
2681 | 1189 } |
1190 | |
5583 | 1191 static void yahoo_show_act_id(GaimConnection *gc) |
2681 | 1192 { |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1193 gaim_request_input(gc, NULL, _("Active which ID?"), NULL, |
5583 | 1194 gaim_connection_get_display_name(gc), FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1195 _("OK"), G_CALLBACK(yahoo_act_id), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1196 _("Cancel"), NULL, gc); |
2681 | 1197 } |
1198 | |
5583 | 1199 static GList *yahoo_actions(GaimConnection *gc) { |
2681 | 1200 GList *m = NULL; |
4333 | 1201 struct proto_actions_menu *pam; |
2681 | 1202 |
4333 | 1203 pam = g_new0(struct proto_actions_menu, 1); |
1204 pam->label = _("Activate ID"); | |
1205 pam->callback = yahoo_show_act_id; | |
1206 pam->gc = gc; | |
1207 m = g_list_append(m, pam); | |
2681 | 1208 |
1209 return m; | |
1210 } | |
1211 | |
5583 | 1212 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, int len, int flags) |
2681 | 1213 { |
1214 struct yahoo_data *yd = gc->proto_data; | |
1215 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
3642 | 1216 char *msg = g_strdup(what); |
2681 | 1217 |
5583 | 1218 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1219 yahoo_packet_hash(pkt, 5, who); |
3493 | 1220 yahoo_packet_hash(pkt, 14, msg); |
2681 | 1221 |
1222 yahoo_send_packet(yd, pkt); | |
1223 | |
1224 yahoo_packet_free(pkt); | |
3493 | 1225 |
2681 | 1226 return 1; |
1227 } | |
1228 | |
5583 | 1229 int yahoo_send_typing(GaimConnection *gc, char *who, int typ) |
2993 | 1230 { |
1231 struct yahoo_data *yd = gc->proto_data; | |
3019 | 1232 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
2993 | 1233 yahoo_packet_hash(pkt, 49, "TYPING"); |
5583 | 1234 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2993 | 1235 yahoo_packet_hash(pkt, 14, " "); |
3596 | 1236 yahoo_packet_hash(pkt, 13, typ == TYPING ? "1" : "0"); |
2993 | 1237 yahoo_packet_hash(pkt, 5, who); |
1238 yahoo_packet_hash(pkt, 1002, "1"); | |
1239 | |
1240 yahoo_send_packet(yd, pkt); | |
1241 | |
1242 yahoo_packet_free(pkt); | |
1243 | |
3001 | 1244 return 0; |
2993 | 1245 } |
1246 | |
5583 | 1247 static void yahoo_set_away(GaimConnection *gc, char *state, char *msg) |
2681 | 1248 { |
1249 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1250 struct yahoo_packet *pkt; | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1251 int service; |
2681 | 1252 char s[4]; |
1253 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1254 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1255 g_free(gc->away); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1256 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1257 } |
2681 | 1258 |
1259 if (msg) { | |
1260 yd->current_status = YAHOO_STATUS_CUSTOM; | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1261 gc->away = g_strdup(msg); |
2681 | 1262 } else if (state) { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1263 gc->away = g_strdup(""); |
4596 | 1264 if (!strcmp(state, _("Available"))) { |
2681 | 1265 yd->current_status = YAHOO_STATUS_AVAILABLE; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1266 g_free(gc->away); |
2681 | 1267 gc->away = NULL; |
4596 | 1268 } else if (!strcmp(state, _("Be Right Back"))) { |
2681 | 1269 yd->current_status = YAHOO_STATUS_BRB; |
4596 | 1270 } else if (!strcmp(state, _("Busy"))) { |
2681 | 1271 yd->current_status = YAHOO_STATUS_BUSY; |
4596 | 1272 } else if (!strcmp(state, _("Not At Home"))) { |
2681 | 1273 yd->current_status = YAHOO_STATUS_NOTATHOME; |
4596 | 1274 } else if (!strcmp(state, _("Not At Desk"))) { |
2681 | 1275 yd->current_status = YAHOO_STATUS_NOTATDESK; |
4596 | 1276 } else if (!strcmp(state, _("Not In Office"))) { |
2681 | 1277 yd->current_status = YAHOO_STATUS_NOTINOFFICE; |
4606 | 1278 } else if (!strcmp(state, _("On The Phone"))) { |
2681 | 1279 yd->current_status = YAHOO_STATUS_ONPHONE; |
4596 | 1280 } else if (!strcmp(state, _("On Vacation"))) { |
2681 | 1281 yd->current_status = YAHOO_STATUS_ONVACATION; |
4596 | 1282 } else if (!strcmp(state, _("Out To Lunch"))) { |
2681 | 1283 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; |
4596 | 1284 } else if (!strcmp(state, _("Stepped Out"))) { |
2681 | 1285 yd->current_status = YAHOO_STATUS_STEPPEDOUT; |
4596 | 1286 } else if (!strcmp(state, _("Invisible"))) { |
2681 | 1287 yd->current_status = YAHOO_STATUS_INVISIBLE; |
1288 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { | |
1289 if (gc->is_idle) { | |
1290 yd->current_status = YAHOO_STATUS_IDLE; | |
1291 } else { | |
1292 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1293 } | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4044
diff
changeset
|
1294 g_free(gc->away); |
2681 | 1295 gc->away = NULL; |
1296 } | |
1297 } else if (gc->is_idle) { | |
1298 yd->current_status = YAHOO_STATUS_IDLE; | |
1299 } else { | |
1300 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1301 } | |
1302 | |
2772
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1303 if (yd->current_status == YAHOO_STATUS_AVAILABLE) |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1304 service = YAHOO_SERVICE_ISBACK; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1305 else |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1306 service = YAHOO_SERVICE_ISAWAY; |
f9227268db25
[gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2771
diff
changeset
|
1307 pkt = yahoo_packet_new(service, yd->current_status, 0); |
2681 | 1308 g_snprintf(s, sizeof(s), "%d", yd->current_status); |
1309 yahoo_packet_hash(pkt, 10, s); | |
1310 if (yd->current_status == YAHOO_STATUS_CUSTOM) | |
1311 yahoo_packet_hash(pkt, 19, msg); | |
1312 | |
1313 yahoo_send_packet(yd, pkt); | |
1314 yahoo_packet_free(pkt); | |
1315 } | |
1316 | |
5583 | 1317 static void yahoo_set_idle(GaimConnection *gc, int idle) |
2681 | 1318 { |
1319 struct yahoo_data *yd = gc->proto_data; | |
1320 struct yahoo_packet *pkt = NULL; | |
1321 | |
1322 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) { | |
1323 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0); | |
1324 yd->current_status = YAHOO_STATUS_IDLE; | |
1325 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | |
1326 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0); | |
1327 yd->current_status = YAHOO_STATUS_AVAILABLE; | |
1328 } | |
1329 | |
1330 if (pkt) { | |
1331 char buf[4]; | |
1332 g_snprintf(buf, sizeof(buf), "%d", yd->current_status); | |
1333 yahoo_packet_hash(pkt, 10, buf); | |
1334 yahoo_send_packet(yd, pkt); | |
1335 yahoo_packet_free(pkt); | |
1336 } | |
1337 } | |
1338 | |
5583 | 1339 static GList *yahoo_away_states(GaimConnection *gc) |
2681 | 1340 { |
1341 GList *m = NULL; | |
1342 | |
4596 | 1343 m = g_list_append(m, _("Available")); |
1344 m = g_list_append(m, _("Be Right Back")); | |
1345 m = g_list_append(m, _("Busy")); | |
1346 m = g_list_append(m, _("Not At Home")); | |
1347 m = g_list_append(m, _("Not At Desk")); | |
1348 m = g_list_append(m, _("Not In Office")); | |
4606 | 1349 m = g_list_append(m, _("On The Phone")); |
4596 | 1350 m = g_list_append(m, _("On Vacation")); |
1351 m = g_list_append(m, _("Out To Lunch")); | |
1352 m = g_list_append(m, _("Stepped Out")); | |
1353 m = g_list_append(m, _("Invisible")); | |
2681 | 1354 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
1355 | |
1356 return m; | |
1357 } | |
1358 | |
5583 | 1359 static void yahoo_keepalive(GaimConnection *gc) |
2681 | 1360 { |
1361 struct yahoo_data *yd = gc->proto_data; | |
1362 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
1363 yahoo_send_packet(yd, pkt); | |
1364 yahoo_packet_free(pkt); | |
1365 } | |
1366 | |
5583 | 1367 static void yahoo_add_buddy(GaimConnection *gc, const char *who) |
2681 | 1368 { |
1369 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1370 struct yahoo_packet *pkt; | |
1371 struct group *g; | |
1372 char *group = NULL; | |
1373 | |
1374 if (!yd->logged_in) | |
1375 return; | |
1376 | |
4687 | 1377 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, who)); |
2681 | 1378 if (g) |
1379 group = g->name; | |
1380 else | |
1381 group = "Buddies"; | |
1382 | |
1383 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
5583 | 1384 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1385 yahoo_packet_hash(pkt, 7, who); |
1386 yahoo_packet_hash(pkt, 65, group); | |
1387 yahoo_send_packet(yd, pkt); | |
1388 yahoo_packet_free(pkt); | |
1389 } | |
1390 | |
5583 | 1391 static void yahoo_remove_buddy(GaimConnection *gc, char *who, char *group) |
2681 | 1392 { |
1393 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
1394 | |
1395 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
5583 | 1396 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2681 | 1397 yahoo_packet_hash(pkt, 7, who); |
1398 yahoo_packet_hash(pkt, 65, group); | |
1399 yahoo_send_packet(yd, pkt); | |
1400 yahoo_packet_free(pkt); | |
1401 } | |
1402 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1403 static GaimPlugin *my_protocol = NULL; |
2681 | 1404 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1405 #if 0 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1406 G_MODULE_EXPORT void yahoo_init(GaimPlugin *ret) { |
3572 | 1407 struct proto_user_opt *puo; |
2681 | 1408 ret->protocol = PROTO_YAHOO; |
1409 ret->options = OPT_PROTO_MAIL_CHECK; | |
3572 | 1410 ret->name = g_strdup("Yahoo"); |
2681 | 1411 ret->login = yahoo_login; |
1412 ret->close = yahoo_close; | |
1413 ret->buddy_menu = yahoo_buddy_menu; | |
1414 ret->list_icon = yahoo_list_icon; | |
4916 | 1415 ret->list_emblems = yahoo_list_emblems; |
4722 | 1416 ret->status_text = yahoo_status_text; |
4724 | 1417 ret->tooltip_text = yahoo_tooltip_text; |
2681 | 1418 ret->actions = yahoo_actions; |
1419 ret->send_im = yahoo_send_im; | |
1420 ret->away_states = yahoo_away_states; | |
1421 ret->set_away = yahoo_set_away; | |
1422 ret->set_idle = yahoo_set_idle; | |
1423 ret->keepalive = yahoo_keepalive; | |
1424 ret->add_buddy = yahoo_add_buddy; | |
1425 ret->remove_buddy = yahoo_remove_buddy; | |
2993 | 1426 ret->send_typing = yahoo_send_typing; |
2681 | 1427 |
3572 | 1428 puo = g_new0(struct proto_user_opt, 1); |
4115 | 1429 puo->label = g_strdup(_("Pager Host:")); |
3572 | 1430 puo->def = g_strdup(YAHOO_PAGER_HOST); |
1431 puo->pos = USEROPT_PAGERHOST; | |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1432 ret->protocol_options = g_list_append(ret->protocol_options, puo); |
3572 | 1433 |
1434 puo = g_new0(struct proto_user_opt, 1); | |
4115 | 1435 puo->label = g_strdup(_("Pager Port:")); |
3572 | 1436 puo->def = g_strdup("5050"); |
1437 puo->pos = USEROPT_PAGERPORT; | |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1438 ret->protocol_options = g_list_append(ret->protocol_options, puo); |
3572 | 1439 |
2681 | 1440 my_protocol = ret; |
1441 } | |
1442 | |
1443 #ifndef STATIC | |
1444 | |
3630 | 1445 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2681 | 1446 { |
3572 | 1447 yahoo_init(prpl); |
1448 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2681 | 1449 } |
1450 | |
1451 #endif | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1452 #endif |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1453 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1454 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1455 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1456 GAIM_PROTO_YAHOO, |
5367 | 1457 OPT_PROTO_MAIL_CHECK | OPT_PROTO_USE_POINTSIZE, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1458 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1459 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1460 yahoo_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1461 yahoo_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1462 yahoo_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1463 yahoo_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1464 yahoo_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1465 yahoo_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1466 yahoo_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1467 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1468 yahoo_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1469 yahoo_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1470 yahoo_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1471 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1472 yahoo_send_typing, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1473 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1474 yahoo_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1475 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1476 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1477 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1478 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1479 yahoo_set_idle, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1480 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1481 yahoo_add_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1482 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1483 yahoo_remove_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1484 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1485 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1486 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1487 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1488 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1489 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1490 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1491 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1492 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1493 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1494 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1495 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1496 yahoo_keepalive, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1497 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1498 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1499 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1500 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1501 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1502 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1503 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1504 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1505 NULL |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1506 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1507 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1508 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1509 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1510 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1511 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1512 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1513 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1514 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1515 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1516 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1517 "prpl-yahoo", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1518 "Yahoo", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1519 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1520 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1521 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1522 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1523 N_("Yahoo Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1524 NULL, /**< author */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1525 WEBSITE, /**< homepage */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1526 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1527 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1528 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1529 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1530 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1531 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1532 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1533 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1534 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1535 static void |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1536 __init_plugin(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1537 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1538 GaimAccountOption *option; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1539 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1540 option = gaim_account_option_string_new(_("Pager host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1541 YAHOO_PAGER_HOST); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1542 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1543 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1544 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1545 option = gaim_account_option_int_new(_("Pager port"), "port", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1546 YAHOO_PAGER_PORT); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1547 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
1548 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1549 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1550 my_protocol = plugin; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1551 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1552 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1553 GAIM_INIT_PLUGIN(yahoo, __init_plugin, info); |