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