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