Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 5638:0bdfa28c678e
[gaim-migrate @ 6047]
We're slowly killing off multi.h. The proto_user_split and proto_user_opt
have been replaced with GaimAccountOption and GaimAccountUserSplit
structures, which of course have an API. The account dialog is being
rewritten as well, and will soon allow you to add and modify accounts again.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 01 Jun 2003 17:40:20 +0000 |
parents | 960fe32ea9b7 |
children | 48c63ee49961 |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
24 #include <config.h> |
2086 | 25 #endif |
26 | |
3664 | 27 #include <sys/types.h> |
4617 | 28 /* this must happen before sys/socket.h or freebsd won't compile */ |
3664 | 29 |
3630 | 30 #ifndef _WIN32 |
2086 | 31 #include <netdb.h> |
32 #include <netinet/in.h> | |
33 #include <arpa/inet.h> | |
3630 | 34 #include <sys/socket.h> |
35 #include <unistd.h> | |
36 #endif | |
37 | |
38 #include <errno.h> | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
39 #include <ctype.h> |
2086 | 40 #include <string.h> |
41 #include <stdlib.h> | |
42 #include <stdio.h> | |
43 #include <time.h> | |
44 #include <sys/stat.h> | |
3630 | 45 #include <signal.h> |
46 | |
4608 | 47 #include "gaim.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
48 #include "accountopt.h" |
2086 | 49 #include "multi.h" |
50 #include "prpl.h" | |
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4366
diff
changeset
|
51 #include "core.h" |
4889 | 52 #include "proxy.h" |
2086 | 53 #include "aim.h" |
54 | |
3630 | 55 #ifdef _WIN32 |
56 #include "win32dep.h" | |
57 #endif | |
58 | |
2086 | 59 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
60 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
61 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
62 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
63 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
64 #define UC_AB 0x20 |
3079 | 65 #define UC_WIRELESS 0x40 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
66 |
2086 | 67 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
68 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
69 static GaimPlugin *my_protocol = NULL; |
4249 | 70 |
4811 | 71 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_IMIMAGE | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE; |
72 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_IMIMAGE | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE; | |
3458 | 73 |
4665 | 74 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
75 static fu8_t features_icq[] = {0x01, 0x06}; | |
2086 | 76 |
77 struct oscar_data { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
78 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
79 aim_conn_t *conn; |
2086 | 80 |
81 guint cnpa; | |
82 guint paspa; | |
3694 | 83 guint emlpa; |
4804 | 84 guint icopa; |
2086 | 85 |
4823 | 86 gboolean iconconnecting; |
87 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
88 GSList *create_rooms; |
2086 | 89 |
90 gboolean conf; | |
91 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
92 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
93 char *email; |
2979 | 94 gboolean setnick; |
95 char *newsn; | |
2086 | 96 gboolean chpass; |
97 char *oldp; | |
98 char *newp; | |
99 | |
100 GSList *oscar_chats; | |
101 GSList *direct_ims; | |
3630 | 102 GSList *file_transfers; |
4738 | 103 GHashTable *buddyinfo; |
4804 | 104 GSList *requesticon; |
2086 | 105 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
106 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
107 gboolean icq; |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
108 GSList *evilhack; |
4804 | 109 guint icontimer; |
2993 | 110 |
111 struct { | |
4230 | 112 guint maxwatchers; /* max users who can watch you */ |
2993 | 113 guint maxbuddies; /* max users you can watch */ |
4230 | 114 guint maxgroups; /* max groups in server list */ |
2993 | 115 guint maxpermits; /* max users on permit list */ |
116 guint maxdenies; /* max users on deny list */ | |
117 guint maxsiglen; /* max size (bytes) of profile */ | |
118 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
119 } rights; | |
2086 | 120 }; |
121 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
122 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
123 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
124 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
125 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
126 |
2086 | 127 struct chat_connection { |
128 char *name; | |
129 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
130 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
131 fu16_t instance; |
2086 | 132 int fd; /* this is redundant since we have the conn below */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
133 aim_conn_t *conn; |
2086 | 134 int inpa; |
135 int id; | |
5575 | 136 GaimConnection *gc; /* i hate this. */ |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
137 struct gaim_conversation *cnv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
138 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
139 int maxvis; |
2086 | 140 }; |
141 | |
142 struct direct_im { | |
5575 | 143 GaimConnection *gc; |
2086 | 144 char name[80]; |
145 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
146 aim_conn_t *conn; |
3008 | 147 gboolean connected; |
2086 | 148 }; |
149 | |
150 struct ask_direct { | |
5575 | 151 GaimConnection *gc; |
2086 | 152 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
153 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
154 fu8_t cookie[8]; |
2086 | 155 }; |
156 | |
4738 | 157 /* Various PRPL-specific buddy info that we want to keep track of */ |
158 struct buddyinfo { | |
159 time_t signon; | |
160 int caps; | |
161 gboolean typingnot; | |
162 | |
163 unsigned long ico_len; | |
164 unsigned long ico_csum; | |
165 time_t ico_time; | |
166 gboolean ico_need; | |
167 | |
168 unsigned long ico_me_len; | |
169 unsigned long ico_me_csum; | |
170 time_t ico_me_time; | |
171 gboolean ico_informed; | |
4804 | 172 |
4853 | 173 fu16_t iconcsumlen; |
174 fu8_t iconcsum[30]; | |
2086 | 175 }; |
176 | |
4230 | 177 struct name_data { |
5575 | 178 GaimConnection *gc; |
4230 | 179 gchar *name; |
3453 | 180 gchar *nick; |
3141 | 181 }; |
182 | |
5129 | 183 static char *msgerrreason[] = { |
184 N_("Invalid error"), | |
185 N_("Invalid SNAC"), | |
186 N_("Rate to host"), | |
187 N_("Rate to client"), | |
188 N_("Not logged in"), | |
189 N_("Service unavailable"), | |
190 N_("Service not defined"), | |
191 N_("Obsolete SNAC"), | |
192 N_("Not supported by host"), | |
193 N_("Not supported by client"), | |
194 N_("Refused by client"), | |
195 N_("Reply too big"), | |
196 N_("Responses lost"), | |
197 N_("Request denied"), | |
198 N_("Busted SNAC payload"), | |
199 N_("Insufficient rights"), | |
200 N_("In local permit/deny"), | |
201 N_("Too evil (sender)"), | |
202 N_("Too evil (receiver)"), | |
203 N_("User temporarily unavailable"), | |
204 N_("No match"), | |
205 N_("List overflow"), | |
206 N_("Request ambiguous"), | |
207 N_("Queue full"), | |
208 N_("Not while on AOL") | |
209 }; | |
210 static int msgerrreasonlen = 25; | |
211 | |
212 /* All the libfaim->gaim callback functions */ | |
213 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
214 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
215 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
216 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
217 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
218 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
219 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
220 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
221 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_parse_user_info (aim_session_t *, aim_frame_t *, ...); | |
224 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); | |
225 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
226 static int gaim_chat_join (aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_chat_leave (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_chat_info_update (aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
237 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
238 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
240 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
241 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
242 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
243 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
244 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
245 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
260 #ifndef NOSSI | |
261 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
269 #endif | |
270 | |
271 /* for DirectIM/image transfer */ | |
272 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_update_ui (aim_session_t *, aim_frame_t *, ...); | |
276 | |
277 /* for file transfer */ | |
278 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
279 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
280 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
281 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
282 | |
283 /* for icons */ | |
284 static gboolean gaim_icon_timerfunc(gpointer data); | |
285 | |
5306 | 286 /* prpl actions - remove this at some point */ |
5575 | 287 static void oscar_set_info(GaimConnection *gc, char *text); |
5306 | 288 |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
289 static void gaim_free_name_data(struct name_data *data) { |
4230 | 290 g_free(data->name); |
291 g_free(data->nick); | |
292 g_free(data); | |
293 } | |
294 | |
5129 | 295 static fu32_t oscar_encoding_check(const char *utf8) |
296 { | |
297 int i = 0; | |
298 fu32_t encodingflag = 0; | |
299 | |
300 /* Determine how we can send this message. Per the warnings elsewhere | |
301 * in this file, these little checks determine the simplest encoding | |
302 * we can use for a given message send using it. */ | |
303 while (utf8[i]) { | |
304 if ((unsigned char)utf8[i] > 0x7f) { | |
305 /* not ASCII! */ | |
306 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
307 break; | |
308 } | |
309 i++; | |
310 } | |
311 while (utf8[i]) { | |
312 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
313 * followed by 0xc0-0xc3 in the second */ | |
314 if ((unsigned char)utf8[i] < 0x80) { | |
315 i++; | |
316 continue; | |
317 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
318 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
319 i += 2; | |
320 continue; | |
321 } | |
322 encodingflag = AIM_IMFLAGS_UNICODE; | |
323 break; | |
324 } | |
325 | |
326 return encodingflag; | |
327 } | |
328 | |
329 static fu32_t oscar_encoding_parse(const char *enc) | |
330 { | |
331 char *charset; | |
332 | |
333 /* If anything goes wrong, fall back on ASCII and print a message */ | |
334 if (enc == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
335 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
336 "Encoding was null, that's odd\n"); |
5129 | 337 return 0; |
338 } | |
339 charset = strstr(enc, "charset="); | |
340 if (charset == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
341 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
342 "No charset specified for info, assuming ASCII\n"); |
5129 | 343 return 0; |
344 } | |
345 charset += 8; | |
346 if (!strcmp(charset, "\"us-ascii\"") || !strcmp(charset, "\"utf-8\"")) { | |
347 /* UTF-8 is our native charset, ASCII is a proper subset */ | |
348 return 0; | |
349 } else if (!strcmp(charset, "\"iso-8859-1\"")) { | |
350 return AIM_IMFLAGS_ISO_8859_1; | |
351 } else if (!strcmp(charset, "\"unicode-2-0\"")) { | |
352 return AIM_IMFLAGS_UNICODE; | |
353 } else { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
354 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
355 "Unrecognized character set '%s', using ASCII\n", charset); |
5129 | 356 return 0; |
357 } | |
358 } | |
359 | |
360 gchar *oscar_encoding_to_utf8(const char *encoding, char *text, int textlen) | |
361 { | |
362 gchar *utf8 = NULL; | |
363 int flags = oscar_encoding_parse(encoding); | |
364 | |
365 switch (flags) { | |
366 case 0: | |
367 utf8 = g_strndup(text, textlen); | |
368 break; | |
369 case AIM_IMFLAGS_ISO_8859_1: | |
370 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
371 break; | |
372 case AIM_IMFLAGS_UNICODE: | |
373 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
374 break; | |
375 } | |
376 | |
377 return utf8; | |
378 } | |
379 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
380 static struct direct_im *find_direct_im(struct oscar_data *od, const char *who) { |
2086 | 381 GSList *d = od->direct_ims; |
382 struct direct_im *m = NULL; | |
383 | |
384 while (d) { | |
385 m = (struct direct_im *)d->data; | |
4355 | 386 if (!aim_sncmp(who, m->name)) |
4269 | 387 return m; |
2086 | 388 d = d->next; |
389 } | |
390 | |
4269 | 391 return NULL; |
2086 | 392 } |
393 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
394 static char *extract_name(const char *name) { |
4121 | 395 char *tmp, *x; |
2086 | 396 int i, j; |
4120 | 397 |
398 if (!name) | |
4121 | 399 return NULL; |
400 | |
4120 | 401 x = strchr(name, '-'); |
4121 | 402 |
2086 | 403 if (!x) return NULL; |
404 x = strchr(++x, '-'); | |
405 if (!x) return NULL; | |
406 tmp = g_strdup(++x); | |
407 | |
408 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
409 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
410 if (x[i] != '%') { |
2086 | 411 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
412 continue; |
2086 | 413 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
414 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
415 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
416 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 417 } |
418 | |
419 tmp[j] = 0; | |
420 return tmp; | |
421 } | |
422 | |
5575 | 423 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
2086 | 424 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
425 struct chat_connection *c = NULL; | |
426 | |
427 while (g) { | |
428 c = (struct chat_connection *)g->data; | |
429 if (c->id == id) | |
430 break; | |
431 g = g->next; | |
432 c = NULL; | |
433 } | |
434 | |
435 return c; | |
436 } | |
437 | |
5575 | 438 static struct chat_connection *find_oscar_chat_by_conn(GaimConnection *gc, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
439 aim_conn_t *conn) { |
2086 | 440 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
441 struct chat_connection *c = NULL; | |
442 | |
443 while (g) { | |
444 c = (struct chat_connection *)g->data; | |
445 if (c->conn == conn) | |
446 break; | |
447 g = g->next; | |
448 c = NULL; | |
449 } | |
450 | |
451 return c; | |
452 } | |
453 | |
4617 | 454 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) { |
5575 | 455 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
456 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
457 struct gaim_conversation *cnv; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
458 struct direct_im *dim; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
459 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
460 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
461 |
4617 | 462 sn = g_strdup(aim_odc_getsn(conn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
463 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
464 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
465 "%s disconnected Direct IM.\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
466 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
467 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
468 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
469 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
470 |
3008 | 471 if (dim->connected) |
472 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); | |
473 else | |
474 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), sn); | |
475 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
476 if ((cnv = gaim_find_conversation(sn))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
477 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
478 |
5579 | 479 gaim_conversation_update_progress(cnv, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
480 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
481 g_free(dim); /* I guess? I don't see it anywhere else... -- mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
482 g_free(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
483 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
484 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
485 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
486 |
4617 | 487 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
488 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
489 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 490 GaimConnection *gc = sess ? sess->aux_data : NULL; |
4617 | 491 struct oscar_data *od; |
2086 | 492 |
493 if (!gc) { | |
494 /* gc is null. we return, else we seg SIGSEG on next line. */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
495 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
496 "oscar callback for closed connection (1).\n"); |
2086 | 497 return; |
498 } | |
499 | |
4617 | 500 od = (struct oscar_data *)gc->proto_data; |
2086 | 501 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
502 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 503 /* oh boy. this is probably bad. i guess the only thing we |
504 * can really do is return? */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
505 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
506 "oscar callback for closed connection (2).\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
507 gaim_debug(GAIM_DEBUG_MISC, "oscar", "gc = %p\n", gc); |
2086 | 508 return; |
509 } | |
510 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
511 if (condition & GAIM_INPUT_READ) { |
4617 | 512 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
513 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
514 "got information on rendezvous listener\n"); |
4617 | 515 if (aim_handlerendconnect(od->sess, conn) < 0) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
516 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
517 "connection error (rendezvous listener)\n"); |
4617 | 518 aim_conn_kill(od->sess, &conn); |
2086 | 519 } |
520 } else { | |
4617 | 521 if (aim_get_command(od->sess, conn) >= 0) { |
522 aim_rxdispatch(od->sess); | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
523 if (od->killme) |
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
524 gaim_connection_destroy(gc); |
2086 | 525 } else { |
526 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 527 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
528 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
529 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
530 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 531 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
532 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
5420 | 533 char *buf; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
534 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
535 "disconnected from chat room %s\n", c->name); |
2086 | 536 c->conn = NULL; |
537 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
538 gaim_input_remove(c->inpa); |
2086 | 539 c->inpa = 0; |
540 c->fd = -1; | |
4617 | 541 aim_conn_kill(od->sess, &conn); |
5420 | 542 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
543 gaim_notify_error(gc, NULL, buf, NULL); |
5420 | 544 g_free(buf); |
2086 | 545 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 546 if (od->cnpa > 0) |
547 gaim_input_remove(od->cnpa); | |
548 od->cnpa = 0; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
549 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
550 "removing chatnav input watcher\n"); |
4617 | 551 while (od->create_rooms) { |
552 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
553 g_free(cr->name); |
4617 | 554 od->create_rooms = |
555 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
556 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
557 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
558 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
559 NULL); |
2086 | 560 } |
4617 | 561 aim_conn_kill(od->sess, &conn); |
2086 | 562 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 563 if (od->paspa > 0) |
564 gaim_input_remove(od->paspa); | |
565 od->paspa = 0; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
566 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
567 "removing authconn input watcher\n"); |
4617 | 568 aim_conn_kill(od->sess, &conn); |
3694 | 569 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 570 if (od->emlpa > 0) |
571 gaim_input_remove(od->emlpa); | |
572 od->emlpa = 0; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
573 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
574 "removing email input watcher\n"); |
4617 | 575 aim_conn_kill(od->sess, &conn); |
4804 | 576 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
577 if (od->icopa > 0) | |
578 gaim_input_remove(od->icopa); | |
579 od->icopa = 0; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
580 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
581 "removing icon input watcher\n"); |
4804 | 582 aim_conn_kill(od->sess, &conn); |
2086 | 583 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
584 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 585 gaim_odc_disconnect(od->sess, conn); |
586 aim_conn_kill(od->sess, &conn); | |
2086 | 587 } else { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
588 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
589 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
590 conn->type); |
4617 | 591 aim_conn_kill(od->sess, &conn); |
2086 | 592 } |
593 } | |
594 } | |
595 } | |
596 } | |
597 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
598 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
2086 | 599 char *s = g_strdup_vprintf(format, va); |
600 char buf[256]; | |
601 char *t; | |
5575 | 602 GaimConnection *gc = sess->aux_data; |
603 | |
604 g_snprintf(buf, sizeof(buf), "%s %d: ", gaim_account_get_username(gaim_connection_get_account(gc)), level); | |
2086 | 605 t = g_strconcat(buf, s, NULL); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
606 gaim_debug(GAIM_DEBUG_INFO, "oscar", t); |
2086 | 607 if (t[strlen(t)-1] != '\n') |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
608 gaim_debug(GAIM_DEBUG_INFO, NULL, "\n"); |
2086 | 609 g_free(t); |
610 g_free(s); | |
611 } | |
612 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
613 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 614 { |
5575 | 615 GaimConnection *gc = data; |
4617 | 616 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
617 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
618 aim_conn_t *conn; |
2086 | 619 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
620 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 621 close(source); |
622 return; | |
623 } | |
624 | |
4617 | 625 od = gc->proto_data; |
626 sess = od->sess; | |
2086 | 627 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 628 |
629 conn->fd = source; | |
2086 | 630 |
631 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
632 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 633 return; |
634 } | |
635 | |
636 aim_conn_completeconnect(sess, conn); | |
4617 | 637 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
638 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
639 "Password sent, waiting for response\n"); |
2086 | 640 } |
641 | |
5575 | 642 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
643 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
644 aim_conn_t *conn; |
2086 | 645 char buf[256]; |
5575 | 646 GaimConnection *gc = gaim_account_get_connection(account); |
4617 | 647 struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1); |
2086 | 648 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
649 gaim_debug(GAIM_DEBUG_MISC, "oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
650 |
5575 | 651 if (isdigit(*(gaim_account_get_username(account)))) { |
4617 | 652 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
653 } else { |
2918
4df759d607f3
[gaim-migrate @ 2931]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2916
diff
changeset
|
654 gc->flags |= OPT_CONN_HTML; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
655 gc->flags |= OPT_CONN_AUTO_RESP; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
656 } |
4738 | 657 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
2086 | 658 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
659 sess = g_new0(aim_session_t, 1); |
2086 | 660 |
661 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | |
662 aim_setdebuggingcb(sess, oscar_debug); | |
663 | |
664 /* we need an immediate queue because we don't use a while-loop to | |
665 * see if things need to be sent. */ | |
666 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); | |
4617 | 667 od->sess = sess; |
2086 | 668 sess->aux_data = gc; |
669 | |
670 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
671 if (conn == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
672 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
673 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
674 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 675 return; |
676 } | |
677 | |
5575 | 678 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(account)); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
679 gaim_connection_update_progress(gc, buf, 2, 5); |
2086 | 680 |
4649 | 681 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 682 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
683 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
684 | |
685 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5575 | 686 if (proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
687 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), | |
688 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
689 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 690 return; |
691 } | |
5575 | 692 aim_request_login(sess, conn, gaim_account_get_username(account)); |
693 } | |
694 | |
695 static void oscar_close(GaimConnection *gc) { | |
4617 | 696 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
697 | |
698 while (od->oscar_chats) { | |
699 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 700 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
701 gaim_input_remove(n->inpa); |
2086 | 702 g_free(n->name); |
703 g_free(n->show); | |
4617 | 704 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 705 g_free(n); |
706 } | |
4617 | 707 while (od->direct_ims) { |
708 struct direct_im *n = od->direct_ims->data; | |
2086 | 709 if (n->watcher > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
710 gaim_input_remove(n->watcher); |
4617 | 711 od->direct_ims = g_slist_remove(od->direct_ims, n); |
2086 | 712 g_free(n); |
713 } | |
4617 | 714 /* BBB */ |
715 while (od->file_transfers) { | |
716 struct gaim_xfer *xfer; | |
717 xfer = (struct gaim_xfer *)od->file_transfers->data; | |
718 gaim_xfer_destroy(xfer); | |
3630 | 719 } |
4804 | 720 while (od->requesticon) { |
721 char *sn = od->requesticon->data; | |
722 od->requesticon = g_slist_remove(od->requesticon, sn); | |
723 free(sn); | |
724 } | |
4738 | 725 g_hash_table_destroy(od->buddyinfo); |
4617 | 726 while (od->evilhack) { |
727 g_free(od->evilhack->data); | |
728 od->evilhack = g_slist_remove(od->evilhack, od->evilhack->data); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
729 } |
4617 | 730 while (od->create_rooms) { |
731 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
732 g_free(cr->name); |
4617 | 733 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
734 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
735 } |
4617 | 736 if (od->email) |
737 g_free(od->email); | |
738 if (od->newp) | |
739 g_free(od->newp); | |
740 if (od->oldp) | |
741 g_free(od->oldp); | |
2086 | 742 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
743 gaim_input_remove(gc->inpa); |
4617 | 744 if (od->cnpa > 0) |
745 gaim_input_remove(od->cnpa); | |
746 if (od->paspa > 0) | |
747 gaim_input_remove(od->paspa); | |
748 if (od->emlpa > 0) | |
749 gaim_input_remove(od->emlpa); | |
4804 | 750 if (od->icopa > 0) |
751 gaim_input_remove(od->icopa); | |
4832 | 752 if (od->icopa > 0) |
753 gaim_input_remove(od->icopa); | |
754 if (od->icontimer) | |
755 g_source_remove(od->icontimer); | |
4617 | 756 aim_session_kill(od->sess); |
757 g_free(od->sess); | |
758 od->sess = NULL; | |
2086 | 759 g_free(gc->proto_data); |
760 gc->proto_data = NULL; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
761 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Signed off.\n"); |
2086 | 762 } |
763 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
764 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 765 GaimConnection *gc = data; |
4617 | 766 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
767 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
768 aim_conn_t *bosconn; |
2086 | 769 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
770 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 771 close(source); |
772 return; | |
773 } | |
774 | |
4617 | 775 od = gc->proto_data; |
776 sess = od->sess; | |
777 bosconn = od->conn; | |
4366 | 778 bosconn->fd = source; |
2086 | 779 |
780 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
781 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 782 return; |
783 } | |
784 | |
785 aim_conn_completeconnect(sess, bosconn); | |
4617 | 786 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
787 gaim_connection_update_progress(gc, |
5577
7ed9999926af
[gaim-migrate @ 5981]
Christian Hammond <chipx86@chipx86.com>
parents:
5576
diff
changeset
|
788 _("Connection established, cookie sent"), 4, 5); |
2086 | 789 } |
790 | |
4617 | 791 /* BBB */ |
4656 | 792 /* |
793 * This little area in oscar.c is the nexus of file transfer code, | |
794 * so I wrote a little explanation of what happens. I am such a | |
795 * ninja. | |
796 * | |
797 * The series of events for a file send is: | |
798 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
799 * -User chooses a file and oscar_xfer_init is called. It establishs a | |
800 * listening socket, then asks the remote user to connect to us (and | |
801 * gives them the file name, port, IP, etc.) | |
802 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
803 * in oscar_sendfile_estblsh) | |
804 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
805 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
806 * connection. | |
807 * -We get drunk because file transfer kicks ass. | |
808 * | |
809 * The series of events for a file receive is: | |
810 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
811 * -Gaim user selects file to name and location to save file to and | |
812 * oscar_xfer_init is called | |
813 * -It connects to the remote user using the IP they gave us earlier | |
814 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
815 * them an AIM_CB_OFT_ACK. | |
816 * -They begin to send us lots of raw data. | |
817 * -When they finish sending data we send an AIM_CB_OFT_DONE and then close | |
818 * the connectionn. | |
819 */ | |
820 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
821 | |
822 /* XXX - This function is pretty ugly */ | |
5146 | 823 static void oscar_xfer_init(struct gaim_xfer *xfer) |
4656 | 824 { |
5146 | 825 struct aim_oft_info *oft_info = xfer->data; |
5575 | 826 GaimConnection *gc = oft_info->sess->aux_data; |
5146 | 827 struct oscar_data *od = gc->proto_data; |
4656 | 828 |
829 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { | |
830 int i; | |
831 | |
832 xfer->filename = g_path_get_basename(xfer->local_filename); | |
5146 | 833 strncpy(oft_info->fh.name, xfer->filename, 64); |
834 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
835 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
836 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
4656 | 837 |
838 /* | |
5146 | 839 * First try the port specified earlier (5190). If that fails, |
840 * increment by 1 and try again. | |
4656 | 841 */ |
5146 | 842 aim_sendfile_listen(od->sess, oft_info); |
843 for (i=0; (i<5 && !oft_info->conn); i++) { | |
844 xfer->local_port = oft_info->port = oft_info->port + 1; | |
845 aim_sendfile_listen(od->sess, oft_info); | |
4656 | 846 } |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
847 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
848 "port is %d, ip is %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
849 xfer->local_port, oft_info->clientip); |
5146 | 850 if (oft_info->conn) { |
851 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
852 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
853 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
4656 | 854 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
855 gaim_notify_error(gc, NULL, _("File Transfer Aborted"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
856 _("Unable to establish listener socket.")); |
4656 | 857 /* XXX - The below line causes a crash because the transfer is canceled before the "Ok" callback on the file selection thing exists, I think */ |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
858 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 859 } |
860 } else if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
5146 | 861 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); |
862 if (oft_info->conn) { | |
863 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
864 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
5575 | 865 oft_info->conn->fd = xfer->fd = proxy_connect(gaim_connection_get_account(gc), xfer->remote_ip, xfer->remote_port, |
866 oscar_sendfile_connected, xfer); | |
4656 | 867 if (xfer->fd == -1) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
868 gaim_notify_error(gc, NULL, _("File Transfer Aborted"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
869 _("Unable to establish file descriptor.")); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
870 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 871 } |
872 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
873 gaim_notify_error(gc, NULL, _("File Transfer Aborted"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
874 _("Unable to create new connection.")); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
875 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 876 /* Try a different port? Ask them to connect to us? */ |
877 } | |
878 | |
879 } | |
880 } | |
881 | |
5146 | 882 static void oscar_xfer_start(struct gaim_xfer *xfer) |
4656 | 883 { |
5146 | 884 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
885 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_start\n"); |
4656 | 886 /* I'm pretty sure we don't need to do jack here. Nor Jill. */ |
887 } | |
888 | |
5146 | 889 static void oscar_xfer_end(struct gaim_xfer *xfer) |
4656 | 890 { |
5146 | 891 struct aim_oft_info *oft_info = xfer->data; |
5575 | 892 GaimConnection *gc = oft_info->sess->aux_data; |
5146 | 893 struct oscar_data *od = gc->proto_data; |
4656 | 894 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
895 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_end\n"); |
5146 | 896 |
897 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
898 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
899 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
900 } | |
901 | |
902 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
903 aim_oft_destroyinfo(oft_info); | |
4656 | 904 xfer->data = NULL; |
5146 | 905 od->file_transfers = g_slist_remove(od->file_transfers, xfer); |
4656 | 906 } |
907 | |
5146 | 908 static void oscar_xfer_cancel_send(struct gaim_xfer *xfer) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
909 { |
5146 | 910 struct aim_oft_info *oft_info = xfer->data; |
5575 | 911 GaimConnection *gc = oft_info->sess->aux_data; |
5146 | 912 struct oscar_data *od = gc->proto_data; |
4763 | 913 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
914 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
915 "AAA - in oscar_xfer_cancel_send\n"); |
5146 | 916 |
917 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
918 | |
919 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
920 aim_oft_destroyinfo(oft_info); | |
4763 | 921 xfer->data = NULL; |
5146 | 922 od->file_transfers = g_slist_remove(od->file_transfers, xfer); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
923 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
924 |
5146 | 925 static void oscar_xfer_cancel_recv(struct gaim_xfer *xfer) |
4656 | 926 { |
5146 | 927 struct aim_oft_info *oft_info = xfer->data; |
5575 | 928 GaimConnection *gc = oft_info->sess->aux_data; |
5146 | 929 struct oscar_data *od = gc->proto_data; |
4656 | 930 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
931 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
932 "AAA - in oscar_xfer_cancel_recv\n"); |
5146 | 933 |
934 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
935 | |
936 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
937 aim_oft_destroyinfo(oft_info); | |
4656 | 938 xfer->data = NULL; |
5146 | 939 od->file_transfers = g_slist_remove(od->file_transfers, xfer); |
4656 | 940 } |
941 | |
5146 | 942 static void oscar_xfer_ack(struct gaim_xfer *xfer, const char *buffer, size_t size) |
4656 | 943 { |
5146 | 944 struct aim_oft_info *oft_info = xfer->data; |
4656 | 945 |
946 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { | |
947 /* | |
948 * If we're done sending, intercept the socket from the core ft code | |
949 * and wait for the other guy to send the "done" OFT packet. | |
950 */ | |
951 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
952 gaim_input_remove(xfer->watcher); | |
5146 | 953 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); |
4656 | 954 xfer->fd = 0; |
955 gaim_xfer_set_completed(xfer, TRUE); | |
956 } | |
957 } else if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
5146 | 958 /* Update our rolling checksum. Like Walmart, yo. */ |
959 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
4656 | 960 } |
961 } | |
962 | |
5146 | 963 static struct gaim_xfer *oscar_find_xfer_by_cookie(GSList *fts, const char *ck) |
4656 | 964 { |
965 struct gaim_xfer *xfer; | |
5146 | 966 struct aim_oft_info *oft_info; |
4656 | 967 |
968 while (fts) { | |
969 xfer = fts->data; | |
5146 | 970 oft_info = xfer->data; |
971 | |
972 if (oft_info && !strcmp(ck, oft_info->cookie)) | |
4656 | 973 return xfer; |
974 | |
975 fts = g_slist_next(fts); | |
976 } | |
977 | |
978 return NULL; | |
979 } | |
980 | |
5146 | 981 static struct gaim_xfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 982 { |
983 struct gaim_xfer *xfer; | |
5146 | 984 struct aim_oft_info *oft_info; |
4656 | 985 |
986 while (fts) { | |
987 xfer = fts->data; | |
5146 | 988 oft_info = xfer->data; |
989 | |
990 if (oft_info && (conn == oft_info->conn)) | |
4656 | 991 return xfer; |
992 | |
993 fts = g_slist_next(fts); | |
994 } | |
995 | |
996 return NULL; | |
997 } | |
998 | |
5575 | 999 static void oscar_ask_sendfile(GaimConnection *gc, const char *destsn) { |
3630 | 1000 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5146 | 1001 struct gaim_xfer *xfer; |
1002 struct aim_oft_info *oft_info; | |
1003 aim_conn_t *conn; | |
3752 | 1004 |
4617 | 1005 /* You want to send a file to someone else, you're so generous */ |
1006 | |
1007 /* Build the file transfer handle */ | |
5575 | 1008 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, destsn); |
5146 | 1009 if ((conn = aim_conn_findbygroup(od->sess, 0x0004))) |
1010 xfer->local_ip = gaim_getip_from_fd(conn->fd); | |
4617 | 1011 xfer->local_port = 5190; |
1012 | |
5146 | 1013 /* Create the oscar-specific data */ |
1014 oft_info = aim_oft_createinfo(od->sess, NULL, destsn, xfer->local_ip, xfer->local_port, 0, 0, NULL); | |
1015 xfer->data = oft_info; | |
1016 | |
4617 | 1017 /* Setup our I/O op functions */ |
1018 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); | |
1019 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); | |
1020 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1021 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1022 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
4656 | 1023 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack); |
4617 | 1024 |
1025 /* Keep track of this transfer for later */ | |
1026 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
1027 | |
1028 /* Now perform the request */ | |
1029 gaim_xfer_request(xfer); | |
3630 | 1030 } |
1031 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1032 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1033 va_list ap; |
2704 | 1034 struct aim_authresp_info *info; |
4452 | 1035 int i, rc; |
1036 char *host; int port; | |
5575 | 1037 GaimAccount *account; |
2704 | 1038 aim_conn_t *bosconn; |
2086 | 1039 |
5575 | 1040 GaimConnection *gc = sess->aux_data; |
2086 | 1041 struct oscar_data *od = gc->proto_data; |
4491 | 1042 account = gc->account; |
5575 | 1043 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 1044 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1045 va_start(ap, fr); |
2704 | 1046 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 1047 va_end(ap); |
1048 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1049 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1050 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 1051 |
4293 | 1052 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 1053 char buf[256]; |
2704 | 1054 switch (info->errorcode) { |
2086 | 1055 case 0x05: |
1056 /* Incorrect nick/password */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1057 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 1058 break; |
1059 case 0x11: | |
1060 /* Suspended account */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1061 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 1062 break; |
3498 | 1063 case 0x14: |
1064 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1065 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 1066 break; |
2086 | 1067 case 0x18: |
1068 /* connecting too frequently */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1069 gaim_connection_error(gc, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); |
2086 | 1070 break; |
1071 case 0x1c: | |
1072 /* client too old */ | |
4056 | 1073 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), WEBSITE); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1074 gaim_connection_error(gc, buf); |
2086 | 1075 break; |
1076 default: | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1077 gaim_connection_error(gc, _("Authentication Failed")); |
2086 | 1078 break; |
1079 } | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1080 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1081 "Login Error Code 0x%04hx\n", info->errorcode); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1082 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1083 "Error URL: %s\n", info->errorurl); |
2086 | 1084 od->killme = TRUE; |
1085 return 1; | |
1086 } | |
1087 | |
1088 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1089 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1090 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1091 |
2704 | 1092 if (info->email) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1093 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Email: %s\n", info->email); |
2086 | 1094 } else { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1095 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Email is NULL\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1096 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1097 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1098 gaim_debug(GAIM_DEBUG_MISC, "oscar", "BOSIP: %s\n", info->bosip); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1099 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1100 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1101 aim_conn_kill(sess, &fr->conn); |
2086 | 1102 |
1103 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
1104 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1105 gaim_connection_error(gc, _("Internal Error")); |
2086 | 1106 od->killme = TRUE; |
1107 return 0; | |
1108 } | |
1109 | |
4649 | 1110 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1111 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 1112 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
1113 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
1114 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 1115 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 1116 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
1117 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
1118 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
1119 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
1120 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
1121 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 1122 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 1123 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
1124 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
1125 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
1126 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
1127 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 1128 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
2086 | 1129 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_user_info, 0); |
1130 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); | |
1131 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1132 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 1133 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
1134 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
1135 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
1136 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
1137 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1138 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1139 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1140 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 1141 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 1142 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 1143 #ifndef NOSSI |
4642 | 1144 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 1145 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
1146 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
1147 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 1148 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
1149 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); | |
1150 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
1151 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
1152 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
1153 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1154 |
2086 | 1155 ((struct oscar_data *)gc->proto_data)->conn = bosconn; |
2704 | 1156 for (i = 0; i < (int)strlen(info->bosip); i++) { |
1157 if (info->bosip[i] == ':') { | |
1158 port = atoi(&(info->bosip[i+1])); | |
2086 | 1159 break; |
1160 } | |
1161 } | |
2704 | 1162 host = g_strndup(info->bosip, i); |
2086 | 1163 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
4634 | 1164 rc = proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 1165 g_free(host); |
4366 | 1166 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1167 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1168 od->killme = TRUE; |
1169 return 0; | |
1170 } | |
4293 | 1171 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1172 gaim_input_remove(gc->inpa); |
2704 | 1173 |
2086 | 1174 return 1; |
1175 } | |
1176 | |
1177 struct pieceofcrap { | |
5575 | 1178 GaimConnection *gc; |
2086 | 1179 unsigned long offset; |
1180 unsigned long len; | |
1181 char *modname; | |
1182 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1183 aim_conn_t *conn; |
2086 | 1184 unsigned int inpa; |
1185 }; | |
1186 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1187 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 1188 { |
1189 struct pieceofcrap *pos = data; | |
1190 struct oscar_data *od = pos->gc->proto_data; | |
1191 char in = '\0'; | |
1192 int x = 0; | |
1193 unsigned char m[17]; | |
1194 | |
1195 while (read(pos->fd, &in, 1) == 1) { | |
1196 if (in == '\n') | |
1197 x++; | |
1198 else if (in != '\r') | |
1199 x = 0; | |
1200 if (x == 2) | |
1201 break; | |
1202 in = '\0'; | |
1203 } | |
1204 if (in != '\n') { | |
4056 | 1205 char buf[256]; |
1206 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
1207 "this is fixed. Check %s for updates."), WEBSITE); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1208 gaim_notify_warning(pos->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1209 _("Gaim was Unable to get a valid AIM login hash."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1210 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1211 gaim_input_remove(pos->inpa); |
2086 | 1212 close(pos->fd); |
1213 g_free(pos); | |
1214 return; | |
1215 } | |
1216 read(pos->fd, m, 16); | |
1217 m[16] = '\0'; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1218 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Sending hash: "); |
2086 | 1219 for (x = 0; x < 16; x++) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1220 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02hhx ", (unsigned char)m[x]); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1221 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1222 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1223 gaim_input_remove(pos->inpa); |
2086 | 1224 close(pos->fd); |
1225 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
1226 g_free(pos); | |
1227 } | |
1228 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1229 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 1230 struct pieceofcrap *pos = data; |
5420 | 1231 gchar *buf; |
2086 | 1232 |
4366 | 1233 pos->fd = source; |
1234 | |
2086 | 1235 if (source < 0) { |
5420 | 1236 buf = g_strdup_printf(_("You may be disconnected shortly. You may want to use TOC until " |
4056 | 1237 "this is fixed. Check %s for updates."), WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1238 gaim_notify_warning(pos->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1239 _("Gaim was Unable to get a valid AIM login hash."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1240 buf); |
5420 | 1241 g_free(buf); |
2086 | 1242 if (pos->modname) |
1243 g_free(pos->modname); | |
1244 g_free(pos); | |
1245 return; | |
1246 } | |
1247 | |
5420 | 1248 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 1249 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
1250 write(pos->fd, buf, strlen(buf)); | |
5420 | 1251 g_free(buf); |
2086 | 1252 if (pos->modname) |
1253 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1254 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 1255 return; |
1256 } | |
1257 | |
1258 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
1259 #define AIM_MAX_FILE_SIZE 98304 | |
1260 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1261 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1262 va_list ap; |
1263 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1264 fu32_t offset, len; |
2086 | 1265 char *modname; |
1266 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1267 va_start(ap, fr); |
4200 | 1268 offset = va_arg(ap, fu32_t); |
1269 len = va_arg(ap, fu32_t); | |
2086 | 1270 modname = va_arg(ap, char *); |
1271 va_end(ap); | |
1272 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1273 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
5556 | 1274 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1275 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1276 |
2086 | 1277 if (len == 0) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1278 gaim_debug(GAIM_DEBUG_MISC, "oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1279 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 1280 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
1281 return 1; | |
1282 } | |
1283 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
1284 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
1285 char *buf; | |
1286 int i = 8; | |
1287 if (modname) | |
1288 i += strlen(modname); | |
1289 buf = g_malloc(i); | |
1290 i = 0; | |
1291 if (modname) { | |
1292 memcpy(buf, modname, strlen(modname)); | |
1293 i += strlen(modname); | |
1294 } | |
1295 buf[i++] = offset & 0xff; | |
1296 buf[i++] = (offset >> 8) & 0xff; | |
1297 buf[i++] = (offset >> 16) & 0xff; | |
1298 buf[i++] = (offset >> 24) & 0xff; | |
1299 buf[i++] = len & 0xff; | |
1300 buf[i++] = (len >> 8) & 0xff; | |
1301 buf[i++] = (len >> 16) & 0xff; | |
1302 buf[i++] = (len >> 24) & 0xff; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1303 gaim_debug(GAIM_DEBUG_MISC, "oscar", "len + offset is invalid, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1304 "hashing request\n"); |
2086 | 1305 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
1306 g_free(buf); | |
1307 return 1; | |
1308 } | |
1309 */ | |
1310 | |
1311 pos = g_new0(struct pieceofcrap, 1); | |
1312 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1313 pos->conn = fr->conn; |
2086 | 1314 |
1315 pos->offset = offset; | |
1316 pos->len = len; | |
1317 pos->modname = modname ? g_strdup(modname) : NULL; | |
1318 | |
4634 | 1319 if (proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 1320 char buf[256]; |
2086 | 1321 if (pos->modname) |
1322 g_free(pos->modname); | |
1323 g_free(pos); | |
4056 | 1324 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
1325 "this is fixed. Check %s for updates."), WEBSITE); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1326 gaim_notify_warning(pos->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1327 _("Gaim was Unable to get a valid login hash."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1328 buf); |
2086 | 1329 } |
1330 | |
1331 return 1; | |
1332 } | |
1333 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1334 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1335 char *key; |
1336 va_list ap; | |
5575 | 1337 GaimConnection *gc = sess->aux_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1338 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 1339 GaimAccount *ac = gaim_connection_get_account(gc); |
4617 | 1340 struct oscar_data *od = gc->proto_data; |
2086 | 1341 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1342 va_start(ap, fr); |
2086 | 1343 key = va_arg(ap, char *); |
1344 va_end(ap); | |
1345 | |
4617 | 1346 if (od->icq) { |
3458 | 1347 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1348 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1349 gaim_account_get_password(account), &info, key); |
3458 | 1350 } else { |
1351 #if 0 | |
1352 struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b}; | |
1353 #endif | |
1354 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1355 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1356 gaim_account_get_password(account), &info, key); |
3458 | 1357 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1358 |
2086 | 1359 return 1; |
1360 } | |
1361 | |
2675 | 1362 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1363 GaimConnection *gc = sess->aux_data; |
2647 | 1364 struct chat_connection *chatcon; |
1365 static int id = 1; | |
1366 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1367 aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, gaim_parse_genericerr, 0); |
2675 | 1368 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
1369 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
1370 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
1371 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
1372 | |
2672 | 1373 aim_clientready(sess, fr->conn); |
2675 | 1374 |
2647 | 1375 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
1376 chatcon->id = id; | |
1377 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); | |
1378 | |
1379 return 1; | |
1380 } | |
1381 | |
2675 | 1382 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
1383 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1384 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 1385 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 1386 |
1387 aim_clientready(sess, fr->conn); | |
1388 | |
1389 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1390 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1391 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1392 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1393 |
3694 | 1394 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
1395 | |
1396 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1397 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
1398 | |
1399 aim_email_sendcookies(sess, fr->conn); | |
1400 aim_email_activate(sess, fr->conn); | |
1401 aim_clientready(sess, fr->conn); | |
1402 | |
1403 return 1; | |
1404 } | |
1405 | |
4804 | 1406 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1407 GaimConnection *gc = sess->aux_data; |
4804 | 1408 struct oscar_data *od = gc->proto_data; |
1409 | |
1410 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1411 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
1412 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
1413 | |
1414 aim_clientready(sess, fr->conn); | |
1415 | |
4823 | 1416 od->iconconnecting = FALSE; |
1417 | |
4804 | 1418 if (od->icontimer) |
1419 g_source_remove(od->icontimer); | |
1420 od->icontimer = g_timeout_add(100, gaim_icon_timerfunc, gc); | |
1421 | |
1422 return 1; | |
1423 } | |
1424 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1425 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1426 GaimConnection *gc = data; |
4617 | 1427 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1428 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1429 aim_conn_t *tstconn; |
2086 | 1430 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1431 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1432 close(source); |
1433 return; | |
1434 } | |
1435 | |
4617 | 1436 od = gc->proto_data; |
1437 sess = od->sess; | |
2086 | 1438 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 1439 tstconn->fd = source; |
2086 | 1440 |
1441 if (source < 0) { | |
1442 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1443 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1444 "unable to connect to chatnav server\n"); |
2086 | 1445 return; |
1446 } | |
1447 | |
1448 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1449 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1450 gaim_debug(GAIM_DEBUG_INFO, "oscar", "chatnav: connected\n"); |
2086 | 1451 } |
1452 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1453 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1454 { |
5575 | 1455 GaimConnection *gc = data; |
4617 | 1456 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1457 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1458 aim_conn_t *tstconn; |
2086 | 1459 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1460 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1461 close(source); |
1462 return; | |
1463 } | |
1464 | |
4617 | 1465 od = gc->proto_data; |
1466 sess = od->sess; | |
2086 | 1467 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1468 tstconn->fd = source; |
2086 | 1469 |
1470 if (source < 0) { | |
1471 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1472 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1473 "unable to connect to authorizer\n"); |
2086 | 1474 return; |
1475 } | |
1476 | |
1477 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1478 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1479 gaim_debug(GAIM_DEBUG_INFO, "oscar", "chatnav: connected\n"); |
2086 | 1480 } |
1481 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1482 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1483 { |
1484 struct chat_connection *ccon = data; | |
5575 | 1485 GaimConnection *gc = ccon->gc; |
4617 | 1486 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1487 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1488 aim_conn_t *tstconn; |
2086 | 1489 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1490 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1491 close(source); |
1492 g_free(ccon->show); | |
1493 g_free(ccon->name); | |
1494 g_free(ccon); | |
1495 return; | |
1496 } | |
1497 | |
4617 | 1498 od = gc->proto_data; |
1499 sess = od->sess; | |
2086 | 1500 tstconn = ccon->conn; |
4366 | 1501 tstconn->fd = source; |
2086 | 1502 |
1503 if (source < 0) { | |
1504 aim_conn_kill(sess, &tstconn); | |
1505 g_free(ccon->show); | |
1506 g_free(ccon->name); | |
1507 g_free(ccon); | |
1508 return; | |
1509 } | |
1510 | |
1511 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 1512 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
1513 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 1514 } |
1515 | |
3694 | 1516 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1517 GaimConnection *gc = data; |
4617 | 1518 struct oscar_data *od; |
3694 | 1519 aim_session_t *sess; |
1520 aim_conn_t *tstconn; | |
1521 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1522 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 1523 close(source); |
1524 return; | |
1525 } | |
1526 | |
4617 | 1527 od = gc->proto_data; |
1528 sess = od->sess; | |
3694 | 1529 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 1530 tstconn->fd = source; |
3694 | 1531 |
1532 if (source < 0) { | |
1533 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1534 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1535 "unable to connect to email server\n"); |
3694 | 1536 return; |
1537 } | |
1538 | |
1539 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1540 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1541 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1542 "email: connected\n"); |
3694 | 1543 } |
1544 | |
4804 | 1545 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1546 GaimConnection *gc = data; |
4804 | 1547 struct oscar_data *od; |
1548 aim_session_t *sess; | |
1549 aim_conn_t *tstconn; | |
1550 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1551 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 1552 close(source); |
1553 return; | |
1554 } | |
1555 | |
1556 od = gc->proto_data; | |
1557 sess = od->sess; | |
1558 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
1559 tstconn->fd = source; | |
1560 | |
1561 if (source < 0) { | |
1562 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1563 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1564 "unable to connect to icon server\n"); |
4804 | 1565 return; |
1566 } | |
1567 | |
1568 aim_conn_completeconnect(sess, tstconn); | |
1569 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1570 gaim_debug(GAIM_DEBUG_INFO, "oscar", "icon: connected\n"); |
4804 | 1571 } |
1572 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1573 /* Hrmph. I don't know how to make this look better. --mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1574 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1575 GaimConnection *gc = sess->aux_data; |
1576 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1577 aim_conn_t *tstconn; |
4452 | 1578 int i; |
2086 | 1579 char *host; |
1580 int port; | |
4821 | 1581 va_list ap; |
1582 struct aim_redirect_data *redir; | |
2086 | 1583 |
5575 | 1584 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 1585 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1586 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1587 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1588 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1589 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1590 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1591 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1592 port = atoi(&(redir->ip[i+1])); |
2086 | 1593 break; |
1594 } | |
1595 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1596 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1597 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1598 switch(redir->group) { |
2086 | 1599 case 0x7: /* Authorizer */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1600 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1601 "Reconnecting with authorizor...\n"); |
2086 | 1602 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1603 if (tstconn == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1604 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1605 "unable to reconnect with authorizer\n"); |
2086 | 1606 g_free(host); |
1607 return 1; | |
1608 } | |
4649 | 1609 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1610 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 1611 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); |
1612 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); | |
1613 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | |
1614 | |
1615 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
4634 | 1616 if (proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 1617 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1618 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1619 "unable to reconnect with authorizer\n"); |
2086 | 1620 g_free(host); |
1621 return 1; | |
1622 } | |
4293 | 1623 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1624 break; |
1625 | |
2086 | 1626 case 0xd: /* ChatNav */ |
1627 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
1628 if (tstconn == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1629 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1630 "unable to connect to chatnav server\n"); |
2086 | 1631 g_free(host); |
1632 return 1; | |
1633 } | |
4649 | 1634 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1635 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 1636 |
1637 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
4634 | 1638 if (proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 1639 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1640 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1641 "unable to connect to chatnav server\n"); |
2086 | 1642 g_free(host); |
1643 return 1; | |
1644 } | |
4293 | 1645 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1646 break; |
1647 | |
1648 case 0xe: { /* Chat */ | |
2086 | 1649 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1650 |
2086 | 1651 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
1652 if (tstconn == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1653 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1654 "unable to connect to chat server\n"); |
2086 | 1655 g_free(host); |
1656 return 1; | |
1657 } | |
1658 | |
4649 | 1659 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1660 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
1661 | |
2086 | 1662 ccon = g_new0(struct chat_connection, 1); |
1663 ccon->conn = tstconn; | |
1664 ccon->gc = gc; | |
1665 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1666 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1667 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1668 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1669 ccon->show = extract_name(redir->chat.room); |
4634 | 1670 |
2086 | 1671 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
4634 | 1672 if (proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 1673 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1674 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1675 "unable to connect to chat server\n"); |
2086 | 1676 g_free(host); |
1677 g_free(ccon->show); | |
1678 g_free(ccon->name); | |
1679 g_free(ccon); | |
1680 return 1; | |
1681 } | |
4293 | 1682 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1683 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1684 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1685 ccon->name, ccon->exchange); |
4194 | 1686 } break; |
3694 | 1687 |
4804 | 1688 case 0x0010: { /* icon */ |
1689 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1690 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1691 "unable to connect to icon server\n"); |
4804 | 1692 g_free(host); |
1693 return 1; | |
1694 } | |
1695 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
1696 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
1697 | |
1698 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1699 if (proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { | |
1700 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1701 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1702 "unable to connect to icon server\n"); |
4804 | 1703 g_free(host); |
1704 return 1; | |
1705 } | |
1706 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
1707 } break; | |
1708 | |
3694 | 1709 case 0x0018: { /* email */ |
1710 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1711 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1712 "unable to connect to email server\n"); |
3694 | 1713 g_free(host); |
1714 return 1; | |
1715 } | |
4649 | 1716 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 1717 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
1718 | |
1719 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
4634 | 1720 if (proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 1721 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1722 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1723 "unable to connect to email server\n"); |
3694 | 1724 g_free(host); |
1725 return 1; | |
1726 } | |
4293 | 1727 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 1728 } break; |
1729 | |
2086 | 1730 default: /* huh? */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1731 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1732 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1733 redir->group); |
2086 | 1734 break; |
1735 } | |
1736 | |
1737 g_free(host); | |
1738 return 1; | |
1739 } | |
1740 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1741 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1742 GaimConnection *gc = sess->aux_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1743 struct oscar_data *od = gc->proto_data; |
4738 | 1744 struct buddyinfo *bi; |
2993 | 1745 time_t time_idle = 0, signon = 0; |
1746 int type = 0; | |
1747 int caps = 0; | |
2086 | 1748 va_list ap; |
4738 | 1749 aim_userinfo_t *info; |
4194 | 1750 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1751 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1752 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1753 va_end(ap); |
1754 | |
2993 | 1755 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
1756 caps = info->capabilities; | |
3267 | 1757 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
1758 type |= UC_AB; | |
1759 | |
4766 | 1760 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
1761 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
1762 type |= UC_UNCONFIRMED; | |
1763 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
1764 type |= UC_ADMIN; | |
1765 if (info->flags & AIM_FLAG_AOL) | |
1766 type |= UC_AOL; | |
1767 if (info->flags & AIM_FLAG_FREE) | |
1768 type |= UC_NORMAL; | |
1769 if (info->flags & AIM_FLAG_AWAY) | |
1770 type |= UC_UNAVAILABLE; | |
1771 if (info->flags & AIM_FLAG_WIRELESS) | |
1772 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1773 } |
2993 | 1774 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 1775 type = (info->icqinfo.status << 16); |
3013 | 1776 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
1777 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 1778 type |= UC_UNAVAILABLE; |
3013 | 1779 } |
2993 | 1780 } |
1781 | |
1782 if (caps & AIM_CAPS_ICQ) | |
1783 caps ^= AIM_CAPS_ICQ; | |
1784 | |
1785 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 1786 time(&time_idle); |
1787 time_idle -= info->idletime*60; | |
2993 | 1788 } |
1789 | |
1790 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
1791 signon = time(NULL) - info->sessionlen; | |
2086 | 1792 |
5575 | 1793 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
1794 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1795 |
4738 | 1796 bi = g_hash_table_lookup(od->buddyinfo, normalize(info->sn)); |
1797 if (!bi) { | |
1798 bi = g_new0(struct buddyinfo, 1); | |
1799 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(info->sn)), bi); | |
1800 } | |
1801 bi->signon = info->onlinesince ? info->onlinesince : (info->sessionlen + time(NULL)); | |
4829 | 1802 if (caps) |
1803 bi->caps = caps; | |
4739 | 1804 bi->typingnot = FALSE; |
1805 bi->ico_informed = FALSE; | |
4732 | 1806 |
4804 | 1807 /* Server stored icon stuff */ |
4853 | 1808 if (info->iconcsumlen) { |
1809 char *b16, *saved_b16; | |
1810 struct buddy *b; | |
1811 | |
1812 memcpy(bi->iconcsum, info->iconcsum, info->iconcsumlen); | |
1813 bi->iconcsumlen = info->iconcsumlen; | |
1814 b16 = tobase16(bi->iconcsum, bi->iconcsumlen); | |
1815 b = gaim_find_buddy(gc->account, info->sn); | |
1816 saved_b16 = gaim_buddy_get_setting(b, "icon_checksum"); | |
1817 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { | |
1818 GSList *cur = od->requesticon; | |
1819 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
1820 cur = cur->next; | |
1821 if (!cur) { | |
1822 od->requesticon = g_slist_append(od->requesticon, strdup(normalize(info->sn))); | |
1823 if (od->icontimer) | |
1824 g_source_remove(od->icontimer); | |
1825 od->icontimer = g_timeout_add(500, gaim_icon_timerfunc, gc); | |
1826 } | |
1827 } | |
1828 free(saved_b16); | |
1829 free(b16); | |
1830 } | |
1831 | |
5628 | 1832 serv_got_update(gc, info->sn, 1, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 1833 |
1834 return 1; | |
1835 } | |
1836 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1837 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1838 GaimConnection *gc = sess->aux_data; |
2086 | 1839 va_list ap; |
4739 | 1840 aim_userinfo_t *info; |
2086 | 1841 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1842 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1843 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1844 va_end(ap); |
1845 | |
4732 | 1846 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); |
2086 | 1847 |
1848 return 1; | |
1849 } | |
1850 | |
3730 | 1851 static void cancel_direct_im(struct ask_direct *d) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1852 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Freeing DirectIM prompts.\n"); |
2086 | 1853 |
1854 g_free(d->sn); | |
1855 g_free(d); | |
1856 } | |
1857 | |
4617 | 1858 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { |
2086 | 1859 struct direct_im *dim = data; |
5575 | 1860 GaimConnection *gc = dim->gc; |
2086 | 1861 struct oscar_data *od = gc->proto_data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
1862 struct gaim_conversation *cnv; |
2086 | 1863 char buf[256]; |
3008 | 1864 struct sockaddr name; |
1865 socklen_t name_len = 1; | |
1866 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1867 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1868 g_free(dim); |
1869 return; | |
1870 } | |
1871 | |
1872 if (source < 0) { | |
1873 g_free(dim); | |
1874 return; | |
1875 } | |
1876 | |
4366 | 1877 dim->conn->fd = source; |
2086 | 1878 aim_conn_completeconnect(od->sess, dim->conn); |
4491 | 1879 if (!(cnv = gaim_find_conversation(dim->name))) |
1880 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
3008 | 1881 |
1882 /* This is the best way to see if we're connected or not */ | |
1883 if (getpeername(source, &name, &name_len) == 0) { | |
1884 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1885 dim->connected = TRUE; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
1886 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
3008 | 1887 } |
2086 | 1888 od->direct_ims = g_slist_append(od->direct_ims, dim); |
3008 | 1889 |
4617 | 1890 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
2086 | 1891 } |
1892 | |
4617 | 1893 /* BBB */ |
3952 | 1894 /* |
4617 | 1895 * This is called after a remote AIM user has connected to us. We |
1896 * want to do some voodoo with the socket file descriptors, add a | |
1897 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 1898 */ |
4656 | 1899 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1900 GaimConnection *gc = sess->aux_data; |
3630 | 1901 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4617 | 1902 struct gaim_xfer *xfer; |
5146 | 1903 struct aim_oft_info *oft_info; |
3630 | 1904 va_list ap; |
1905 aim_conn_t *conn, *listenerconn; | |
4656 | 1906 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1907 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1908 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 1909 va_start(ap, fr); |
1910 conn = va_arg(ap, aim_conn_t *); | |
1911 listenerconn = va_arg(ap, aim_conn_t *); | |
1912 va_end(ap); | |
1913 | |
4617 | 1914 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
1915 return 1; | |
1916 | |
5146 | 1917 if (!(oft_info = xfer->data)) |
4617 | 1918 return 1; |
1919 | |
3630 | 1920 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 1921 gaim_input_remove(xfer->watcher); |
3630 | 1922 aim_conn_kill(sess, &listenerconn); |
1923 | |
5146 | 1924 oft_info->conn = conn; |
1925 xfer->fd = oft_info->conn->fd; | |
1926 | |
1927 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
1928 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
1929 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 1930 |
1931 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 1932 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 1933 |
1934 return 0; | |
1935 } | |
1936 | |
3952 | 1937 /* |
4617 | 1938 * This is the gaim callback passed to proxy_connect when connecting to another AIM |
1939 * user in order to transfer a file. | |
3952 | 1940 */ |
4617 | 1941 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { |
1942 struct gaim_xfer *xfer; | |
5146 | 1943 struct aim_oft_info *oft_info; |
4656 | 1944 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1945 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1946 "AAA - in oscar_sendfile_connected\n"); |
4617 | 1947 if (!(xfer = data)) |
1948 return; | |
5146 | 1949 if (!(oft_info = xfer->data)) |
3630 | 1950 return; |
4617 | 1951 if (source < 0) |
1952 return; | |
1953 | |
1954 xfer->fd = source; | |
5146 | 1955 oft_info->conn->fd = source; |
1956 | |
1957 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
1958 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 1959 |
1960 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 1961 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 1962 |
1963 return; | |
3630 | 1964 } |
1965 | |
3952 | 1966 /* |
4617 | 1967 * This is called when a buddy sends us some file info. This happens when they |
1968 * are sending a file to you, and you have just established a connection to them. | |
4650 | 1969 * You should send them the exact same info except use the real cookie. We also |
4617 | 1970 * get like totally ready to like, receive the file, kay? |
3952 | 1971 */ |
4617 | 1972 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1973 GaimConnection *gc = sess->aux_data; |
4617 | 1974 struct oscar_data *od = gc->proto_data; |
1975 struct gaim_xfer *xfer; | |
5146 | 1976 struct aim_oft_info *oft_info; |
4617 | 1977 va_list ap; |
1978 aim_conn_t *conn; | |
1979 fu8_t *cookie; | |
1980 struct aim_fileheader_t *fh; | |
4656 | 1981 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1982 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1983 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 1984 va_start(ap, fr); |
1985 conn = va_arg(ap, aim_conn_t *); | |
1986 cookie = va_arg(ap, fu8_t *); | |
1987 fh = va_arg(ap, struct aim_fileheader_t *); | |
1988 va_end(ap); | |
1989 | |
1990 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
1991 return 1; | |
1992 | |
5146 | 1993 if (!(oft_info = xfer->data)) |
4617 | 1994 return 1; |
1995 | |
1996 /* We want to stop listening with a normal thingy */ | |
1997 gaim_input_remove(xfer->watcher); | |
1998 xfer->watcher = 0; | |
1999 | |
5146 | 2000 /* They sent us some information about the file they're sending */ |
2001 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
2002 | |
2003 /* Fill in the cookie */ | |
2004 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
2005 | |
4617 | 2006 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 2007 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 2008 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2009 | |
2010 return 0; | |
3630 | 2011 } |
2012 | |
3952 | 2013 /* |
4657 | 2014 * We are sending a file to someone else. They have just acknowledged our |
4617 | 2015 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 2016 */ |
4617 | 2017 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2018 GaimConnection *gc = sess->aux_data; |
4617 | 2019 struct oscar_data *od = gc->proto_data; |
2020 struct gaim_xfer *xfer; | |
2021 va_list ap; | |
2022 aim_conn_t *conn; | |
2023 fu8_t *cookie; | |
2024 struct aim_fileheader_t *fh; | |
4656 | 2025 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2026 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 2027 va_start(ap, fr); |
2028 conn = va_arg(ap, aim_conn_t *); | |
2029 cookie = va_arg(ap, fu8_t *); | |
2030 fh = va_arg(ap, struct aim_fileheader_t *); | |
2031 va_end(ap); | |
2032 | |
2033 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
2034 return 1; | |
2035 | |
4656 | 2036 /* We want to stop listening with a normal thingy */ |
2037 gaim_input_remove(xfer->watcher); | |
2038 xfer->watcher = 0; | |
2039 | |
4617 | 2040 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2041 | |
2042 return 0; | |
3630 | 2043 } |
4617 | 2044 |
2045 /* | |
2046 * We just sent a file to someone. They said they got it and everything, | |
2047 * so we can close our direct connection and what not. | |
2048 */ | |
2049 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 2050 GaimConnection *gc = sess->aux_data; |
4617 | 2051 struct oscar_data *od = gc->proto_data; |
2052 struct gaim_xfer *xfer; | |
2053 va_list ap; | |
2054 aim_conn_t *conn; | |
2055 fu8_t *cookie; | |
2056 struct aim_fileheader_t *fh; | |
4656 | 2057 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2058 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 2059 va_start(ap, fr); |
2060 conn = va_arg(ap, aim_conn_t *); | |
2061 cookie = va_arg(ap, fu8_t *); | |
2062 fh = va_arg(ap, struct aim_fileheader_t *); | |
2063 va_end(ap); | |
2064 | |
2065 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
2066 return 1; | |
2067 | |
4656 | 2068 xfer->fd = conn->fd; |
4617 | 2069 gaim_xfer_end(xfer); |
2070 | |
2071 return 0; | |
2072 } | |
3630 | 2073 |
4244 | 2074 static void accept_direct_im(struct ask_direct *d) { |
5575 | 2075 GaimConnection *gc = d->gc; |
4244 | 2076 struct oscar_data *od; |
2086 | 2077 struct direct_im *dim; |
2945 | 2078 char *host; int port = 4443; |
4366 | 2079 int i, rc; |
2086 | 2080 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2081 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2082 cancel_direct_im(d); |
2083 return; | |
2084 } | |
2085 | |
2086 od = (struct oscar_data *)gc->proto_data; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2087 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Accepted DirectIM.\n"); |
2086 | 2088 |
2089 dim = find_direct_im(od, d->sn); | |
2090 if (dim) { | |
3730 | 2091 cancel_direct_im(d); /* 40 */ |
4244 | 2092 return; |
2086 | 2093 } |
2094 dim = g_new0(struct direct_im, 1); | |
2095 dim->gc = d->gc; | |
2096 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
2097 | |
4617 | 2098 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2099 if (!dim->conn) { |
2086 | 2100 g_free(dim); |
3730 | 2101 cancel_direct_im(d); |
4244 | 2102 return; |
2086 | 2103 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2104 |
2086 | 2105 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
4617 | 2106 gaim_odc_incoming, 0); |
2086 | 2107 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, |
4617 | 2108 gaim_odc_typing, 0); |
3033 | 2109 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, |
2993 | 2110 gaim_update_ui, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2111 for (i = 0; i < (int)strlen(d->ip); i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2112 if (d->ip[i] == ':') { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2113 port = atoi(&(d->ip[i+1])); |
2086 | 2114 break; |
2115 } | |
2116 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2117 host = g_strndup(d->ip, i); |
2086 | 2118 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
4634 | 2119 rc = proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
2086 | 2120 g_free(host); |
4366 | 2121 if (rc < 0) { |
2086 | 2122 aim_conn_kill(od->sess, &dim->conn); |
2123 g_free(dim); | |
3730 | 2124 cancel_direct_im(d); |
4244 | 2125 return; |
2086 | 2126 } |
2127 | |
3730 | 2128 cancel_direct_im(d); |
2086 | 2129 |
4244 | 2130 return; |
2086 | 2131 } |
2132 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2133 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 2134 GaimConnection *gc = sess->aux_data; |
3600 | 2135 struct oscar_data *od = gc->proto_data; |
4738 | 2136 char *tmp; |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2137 int flags = 0; |
3659 | 2138 int convlen; |
2139 GError *err = NULL; | |
4738 | 2140 struct buddyinfo *bi; |
5575 | 2141 const char *iconfile; |
4738 | 2142 |
2143 bi = g_hash_table_lookup(od->buddyinfo, normalize(userinfo->sn)); | |
2144 if (!bi) { | |
2145 bi = g_new0(struct buddyinfo, 1); | |
2146 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(userinfo->sn)), bi); | |
2147 } | |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2148 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2149 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2150 flags |= IM_FLAG_AWAY; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2151 |
4738 | 2152 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
2153 bi->typingnot = TRUE; | |
2154 else | |
2155 bi->typingnot = FALSE; | |
2156 | |
4380 | 2157 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2158 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2159 "%s has an icon\n", userinfo->sn); |
4738 | 2160 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
2161 bi->ico_need = TRUE; | |
2162 bi->ico_len = args->iconlen; | |
2163 bi->ico_csum = args->iconsum; | |
2164 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2165 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2166 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2167 |
5575 | 2168 if ((iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc))) && |
2169 (args->icbmflags & AIM_IMFLAGS_BUDDYREQ)) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2170 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2171 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2172 |
5575 | 2173 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2174 char *buf = g_malloc(st.st_size); |
5575 | 2175 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2176 if (file) { |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
2177 int len = fread(buf, 1, st.st_size, file); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2178 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2179 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2180 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2181 userinfo->sn, len, st.st_size); |
4617 | 2182 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
2183 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2184 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2185 } else |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2186 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2187 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2188 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2189 } else |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2190 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2191 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2192 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2193 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2194 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2195 "Character set is %hu %hu\n", args->charset, args->charsubset); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2196 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
3722 | 2197 /* This message is marked as UNICODE, so we have to |
2198 * convert it to utf-8 before handing it to the gaim core. | |
2199 * This conversion should *never* fail, if it does it | |
2200 * means that either the incoming ICBM is corrupted or | |
4662 | 2201 * there is something we don't understand about it. |
2202 * For the record, AIM Unicode is big-endian UCS-2 */ | |
2203 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2204 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Received UNICODE IM\n"); |
4121 | 2205 |
2206 if (!args->msg || !args->msglen) | |
2207 return 1; | |
4641 | 2208 |
3659 | 2209 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
2210 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2211 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2212 "Unicode IM conversion: %s\n", err->message); |
3659 | 2213 tmp = strdup(_("(There was an error receiving this message)")); |
4800 | 2214 g_error_free(err); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2215 } |
3722 | 2216 } else { |
3850 | 2217 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 2218 * unflagged messages, which are ASCII. That's OK because |
2219 * ASCII is a strict subset of ISO-8859-1; this should | |
2220 * help with compatibility with old, broken versions of | |
2221 * gaim (everything before 0.60) and other broken clients | |
2222 * that will happily send ISO-8859-1 without marking it as | |
2223 * such */ | |
4662 | 2224 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2225 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2226 "Received ISO-8859-1 IM\n"); |
4121 | 2227 |
2228 if (!args->msg || !args->msglen) | |
2229 return 1; | |
2230 | |
3659 | 2231 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
2232 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2233 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2234 "ISO-8859-1 IM conversion: %s\n", err->message); |
3659 | 2235 tmp = strdup(_("(There was an error receiving this message)")); |
4800 | 2236 g_error_free(err); |
3659 | 2237 } |
3642 | 2238 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2239 |
4333 | 2240 /* strip_linefeed(tmp); */ |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2833
diff
changeset
|
2241 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL), -1); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2242 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2243 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2244 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2245 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2246 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2247 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
5575 | 2248 GaimConnection *gc = sess->aux_data; |
4617 | 2249 struct oscar_data *od = gc->proto_data; |
5575 | 2250 const char *username = gaim_account_get_username(gaim_connection_get_account(gc)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2251 |
4121 | 2252 if (!args) |
2253 return 0; | |
4194 | 2254 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2255 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2256 "rendezvous with %s, status is %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2257 userinfo->sn, args->status); |
2869 | 2258 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2259 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 2260 char *name; |
5234 | 2261 GHashTable *components; |
2262 | |
4121 | 2263 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
2264 return 1; | |
5234 | 2265 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
2266 g_free); | |
4121 | 2267 name = extract_name(args->info.chat.roominfo.name); |
5234 | 2268 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
2269 g_hash_table_replace(components, g_strdup("exchange"), g_strdup_printf("%d", args->info.chat.roominfo.exchange)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2270 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2271 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2272 userinfo->sn, |
2869 | 2273 (char *)args->msg, |
5234 | 2274 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2275 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2276 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2277 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 2278 /* BBB */ |
2279 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
2280 /* Someone wants to send a file (or files) to us */ | |
2281 struct gaim_xfer *xfer; | |
5146 | 2282 struct aim_oft_info *oft_info; |
2283 | |
2284 if (!args->cookie || !args->port || !args->verifiedip || | |
2285 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 2286 !args->info.sendfile.totfiles || !args->reqclass) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2287 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2288 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2289 "information.\n", userinfo->sn); |
5146 | 2290 if (args->proxyip) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2291 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2292 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2293 "does not support this yet.\n"); |
4617 | 2294 return 1; |
4656 | 2295 } |
4617 | 2296 |
2297 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
2298 /* last char of the ft req is a star, they are sending us a | |
2299 * directory -- remove the star and trailing slash so we dont save | |
2300 * directories that look like 'dirname\*' -- arl */ | |
2301 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
2302 if (tmp && (tmp[1] == '*')) { | |
2303 tmp[0] = '\0'; | |
2304 } | |
2305 } | |
2306 | |
2307 /* Build the file transfer handle */ | |
2308 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 2309 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 2310 xfer->remote_port = args->port; |
4617 | 2311 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
2312 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
5146 | 2313 |
2314 /* Create the oscar-specific data */ | |
5163 | 2315 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 2316 if (args->proxyip) |
5146 | 2317 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 2318 if (args->verifiedip) |
5146 | 2319 oft_info->verifiedip = g_strdup(args->verifiedip); |
2320 xfer->data = oft_info; | |
4617 | 2321 |
2322 /* Setup our I/O op functions */ | |
2323 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); | |
2324 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); | |
2325 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2326 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2327 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
4617 | 2328 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack); |
2329 | |
2330 /* | |
2331 * XXX - Should do something with args->msg, args->encoding, and args->language | |
2332 * probably make it apply to all ch2 messages. | |
3752 | 2333 */ |
4617 | 2334 |
2335 /* Keep track of this transfer for later */ | |
2336 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2337 | |
2338 /* Now perform the request */ | |
2339 gaim_xfer_request(xfer); | |
2340 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
2341 /* The other user wants to cancel a file transfer */ | |
2342 struct gaim_xfer *xfer; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2343 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2344 "AAA - File transfer canceled by remote user\n"); |
4617 | 2345 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2346 gaim_xfer_cancel_remote(xfer); |
4617 | 2347 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
2348 /* | |
2349 * This gets sent by the receiver of a file | |
2350 * as they connect directly to us. If we don't | |
2351 * get this, then maybe a third party connected | |
2352 * to us, and we shouldn't send them anything. | |
2353 */ | |
2354 } else { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2355 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2356 "unknown rendezvous status!\n"); |
3630 | 2357 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2358 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2359 } else if (args->reqclass & AIM_CAPS_VOICE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2360 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
4799 | 2361 set_icon_data(gc, userinfo->sn, args->info.icon.icon, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2362 args->info.icon.length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2363 } else if (args->reqclass & AIM_CAPS_IMIMAGE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2364 struct ask_direct *d = g_new0(struct ask_direct, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2365 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2366 |
4212 | 2367 if (!args->verifiedip) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2368 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2369 "directim kill blocked (%s)\n", userinfo->sn); |
4650 | 2370 return 1; |
4212 | 2371 } |
2372 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2373 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2374 "%s received direct im request from %s (%s)\n", |
5575 | 2375 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2376 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2377 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2378 d->sn = g_strdup(userinfo->sn); |
2869 | 2379 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2380 memcpy(d->cookie, args->cookie, 8); |
5575 | 2381 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, username); |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2382 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2383 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2384 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2385 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2386 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2387 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2388 "risk."), 0, d, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2389 _("Connect"), G_CALLBACK(accept_direct_im), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2390 _("Cancel"), G_CALLBACK(cancel_direct_im)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2391 } else { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2392 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2393 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2394 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2395 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2396 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2397 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2398 |
3453 | 2399 /* |
4230 | 2400 * Authorization Functions |
2401 * Most of these are callbacks from dialogs. They're used by both | |
2402 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 2403 */ |
4269 | 2404 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2405 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 2406 GaimConnection *gc = data->gc; |
4244 | 2407 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2408 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2409 struct oscar_data *od = gc->proto_data; |
4687 | 2410 struct buddy *buddy = gaim_find_buddy(gc->account, data->name); |
2411 struct group *group = gaim_find_buddys_group(buddy); | |
4244 | 2412 if (buddy && group) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2413 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2414 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2415 buddy->name, group->name); |
4889 | 2416 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 2417 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
4889 | 2418 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 1); |
4244 | 2419 } |
4230 | 2420 } |
4337 | 2421 } |
2422 | |
2423 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2424 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2425 NULL, _("Please authorize me!"), TRUE, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2426 _("OK"), G_CALLBACK(gaim_auth_request), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2427 _("Cancel"), G_CALLBACK(gaim_free_name_data), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2428 data); |
4230 | 2429 } |
2430 | |
2431 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 2432 GaimConnection *gc = data->gc; |
4244 | 2433 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2434 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2435 /* struct oscar_data *od = gc->proto_data; */ |
2436 /* XXX - Take the buddy out of our buddy list */ | |
2437 } | |
2438 | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2439 gaim_free_name_data(data); |
4230 | 2440 } |
2441 | |
5575 | 2442 static void gaim_auth_sendrequest(GaimConnection *gc, const char *name) { |
4269 | 2443 struct name_data *data = g_new(struct name_data, 1); |
2444 struct buddy *buddy; | |
2445 gchar *dialog_msg, *nombre; | |
2446 | |
4687 | 2447 buddy = gaim_find_buddy(gc->account, name); |
2448 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
2449 nombre = g_strdup_printf("%s (%s)", name, gaim_get_buddy_alias_only(buddy)); | |
4269 | 2450 else |
4830 | 2451 nombre = NULL; |
2452 | |
2453 dialog_msg = g_strdup_printf(_("The user %s requires authorization before being added to a buddy list. Do you want to send an authorization request?"), (nombre ? nombre : name)); | |
4269 | 2454 data->gc = gc; |
2455 data->name = g_strdup(name); | |
2456 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2457 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2458 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2459 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2460 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2461 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2462 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 2463 |
2464 g_free(dialog_msg); | |
2465 g_free(nombre); | |
2466 } | |
2467 | |
4230 | 2468 /* When other people ask you for authorization */ |
2469 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 2470 GaimConnection *gc = data->gc; |
4244 | 2471 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2472 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2473 struct oscar_data *od = gc->proto_data; |
4236 | 2474 #ifdef NOSSI |
4244 | 2475 struct buddy *buddy; |
2476 gchar message; | |
2477 message = 0; | |
4687 | 2478 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 2479 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
4687 | 2480 show_got_added(gc, NULL, data->name, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 2481 #else |
4889 | 2482 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 2483 #endif |
4244 | 2484 } |
2485 | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2486 gaim_free_name_data(data); |
3141 | 2487 } |
2488 | |
4230 | 2489 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2490 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 2491 GaimConnection *gc = data->gc; |
4244 | 2492 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2493 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2494 struct oscar_data *od = gc->proto_data; |
4230 | 2495 #ifdef NOSSI |
4617 | 2496 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 2497 #else |
4889 | 2498 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 2499 #endif |
4244 | 2500 } |
4337 | 2501 } |
2502 | |
2503 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2504 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2505 NULL, _("No reason given."), TRUE, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2506 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2507 _("Cancel"), G_CALLBACK(gaim_free_name_data), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2508 data); |
3141 | 2509 } |
2510 | |
4230 | 2511 /* When someone sends you contacts */ |
2512 static void gaim_icq_contactadd(struct name_data *data) { | |
5575 | 2513 GaimConnection *gc = data->gc; |
4244 | 2514 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2515 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2516 show_add_buddy(gc, data->name, NULL, data->nick); |
2517 } | |
2518 | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2519 gaim_free_name_data(data); |
3453 | 2520 } |
2521 | |
4075 | 2522 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) { |
5575 | 2523 GaimConnection *gc = sess->aux_data; |
4076 | 2524 gchar **msg1, **msg2; |
2525 GError *err = NULL; | |
2526 int i; | |
2527 | |
4121 | 2528 if (!args->type || !args->msg || !args->uin) |
2529 return 1; | |
4194 | 2530 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2531 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2532 "Received a channel 4 message of type 0x%02hhx.\n", args->type); |
4076 | 2533 |
2534 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 2535 msg1 = g_strsplit(args->msg, "\376", 0); |
4194 | 2536 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* XXX - 10 is a guess */ |
4076 | 2537 for (i=0; msg1[i]; i++) { |
2538 strip_linefeed(msg1[i]); | |
2539 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); | |
4800 | 2540 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2541 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2542 "Error converting a string from ISO-8859-1 to " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2543 "UTF-8 in oscar ICBM channel 4 parsing\n"); |
4800 | 2544 g_error_free(err); |
2545 } | |
4076 | 2546 } |
2547 msg2[i] = NULL; | |
2548 | |
3952 | 2549 switch (args->type) { |
4173 | 2550 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 2551 if (i >= 1) { |
5556 | 2552 gchar *uin = g_strdup_printf("%u", args->uin); |
4076 | 2553 if (t) { /* This is an offline message */ |
2554 /* I think this timestamp is in UTC, or something */ | |
2555 serv_got_im(gc, uin, msg2[0], 0, t, -1); | |
2556 } else { /* This is a message from MacICQ/Miranda */ | |
2557 serv_got_im(gc, uin, msg2[0], 0, time(NULL), -1); | |
2558 } | |
2559 g_free(uin); | |
4075 | 2560 } |
3316 | 2561 } break; |
2562 | |
4173 | 2563 case 0x04: { /* Someone sent you a URL */ |
4076 | 2564 if (i >= 2) { |
5556 | 2565 gchar *uin = g_strdup_printf("%u", args->uin); |
4076 | 2566 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]); |
3453 | 2567 serv_got_im(gc, uin, message, 0, time(NULL), -1); |
2568 g_free(uin); | |
2569 g_free(message); | |
2570 } | |
2571 } break; | |
2572 | |
4173 | 2573 case 0x06: { /* Someone requested authorization */ |
4076 | 2574 if (i >= 6) { |
4230 | 2575 struct name_data *data = g_new(struct name_data, 1); |
5556 | 2576 gchar *dialog_msg = g_strdup_printf(_("The user %u wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2577 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
5556 | 2578 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2579 args->uin); |
4076 | 2580 data->gc = gc; |
5556 | 2581 data->name = g_strdup_printf("%u", args->uin); |
4230 | 2582 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2583 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2584 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2585 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2586 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2587 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2588 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2589 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 2590 g_free(dialog_msg); |
2591 } | |
3141 | 2592 } break; |
2593 | |
4173 | 2594 case 0x07: { /* Someone has denied you authorization */ |
4076 | 2595 if (i >= 1) { |
5556 | 2596 gchar *dialog_msg = g_strdup_printf(_("The user %u has denied your request to add them to your contact list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given.")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2597 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2598 dialog_msg); |
4076 | 2599 g_free(dialog_msg); |
2600 } | |
3141 | 2601 } break; |
2602 | |
4173 | 2603 case 0x08: { /* Someone has granted you authorization */ |
5556 | 2604 gchar *dialog_msg = g_strdup_printf(_("The user %u has granted your request to add them to your contact list."), args->uin); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2605 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2606 dialog_msg); |
3141 | 2607 g_free(dialog_msg); |
2608 } break; | |
2609 | |
4333 | 2610 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
2611 if (i >= 5) { | |
2612 gchar *dialog_msg = g_strdup_printf(_("You have received a special message\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2613 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 2614 g_free(dialog_msg); |
2615 } | |
2616 } break; | |
2617 | |
4173 | 2618 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 2619 if (i >= 6) { |
4194 | 2620 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2621 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 2622 g_free(dialog_msg); |
2623 } | |
4075 | 2624 } break; |
2625 | |
4173 | 2626 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 2627 if (i >= 6) { |
4308 | 2628 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ email from %s [%s]\n\nMessage is:\n%s"), msg2[0], msg2[3], msg2[5]); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2629 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 2630 g_free(dialog_msg); |
2631 } | |
4075 | 2632 } break; |
2633 | |
4173 | 2634 case 0x12: { |
3141 | 2635 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
4173 | 2636 /* Someone added you to their contact list? */ |
3141 | 2637 } break; |
2638 | |
4173 | 2639 case 0x13: { /* Someone has sent you some ICQ contacts */ |
3453 | 2640 int i, num; |
2641 gchar **text; | |
4173 | 2642 text = g_strsplit(args->msg, "\376", 0); |
3453 | 2643 if (text) { |
2644 num = 0; | |
2645 for (i=0; i<strlen(text[0]); i++) | |
2646 num = num*10 + text[0][i]-48; | |
2647 for (i=0; i<num; i++) { | |
4230 | 2648 struct name_data *data = g_new(struct name_data, 1); |
5556 | 2649 gchar *message = g_strdup_printf(_("ICQ user %u has sent you a contact: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]); |
3453 | 2650 data->gc = gc; |
4790 | 2651 data->name = g_strdup(text[i*2+1]); |
2652 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2653 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2654 gaim_request_action(gc, NULL, message, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2655 _("Do you want to add this contact " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2656 "to your Buddy List?"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2657 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2658 _("Add"), G_CALLBACK(gaim_icq_contactadd), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2659 _("Decline"), G_CALLBACK(gaim_free_name_data)); |
3453 | 2660 g_free(message); |
2661 } | |
2662 g_strfreev(text); | |
2663 } | |
2664 } break; | |
2665 | |
4173 | 2666 case 0x1a: { /* Someone has sent you a greeting card or requested contacts? */ |
3453 | 2667 /* This is boring and silly. */ |
2668 } break; | |
2669 | |
3141 | 2670 default: { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2671 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2672 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2673 "(type 0x%02hhx).\n", args->type); |
3141 | 2674 } break; |
2675 } | |
2676 | |
4076 | 2677 g_strfreev(msg1); |
2678 g_strfreev(msg2); | |
2679 | |
3141 | 2680 return 1; |
2681 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2682 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2683 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 2684 fu16_t channel; |
2685 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2686 aim_userinfo_t *userinfo; |
2086 | 2687 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2688 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2689 va_start(ap, fr); |
4200 | 2690 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2691 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 2692 |
3141 | 2693 switch (channel) { |
2694 case 1: { /* standard message */ | |
2695 struct aim_incomingim_ch1_args *args; | |
2696 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
2697 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
2698 } break; | |
2699 | |
2700 case 2: { /* rendevous */ | |
2701 struct aim_incomingim_ch2_args *args; | |
2702 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
2703 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
2704 } break; | |
2705 | |
2706 case 4: { /* ICQ */ | |
2707 struct aim_incomingim_ch4_args *args; | |
2708 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 2709 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 2710 } break; |
2711 | |
2712 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2713 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2714 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2715 "0x%04hx).", channel); |
3141 | 2716 } break; |
2086 | 2717 } |
2718 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2719 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2720 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2721 return ret; |
2086 | 2722 } |
2723 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2724 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
5420 | 2725 char *buf; |
2086 | 2726 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2727 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2728 aim_userinfo_t *userinfo; |
2086 | 2729 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2730 va_start(ap, fr); |
4200 | 2731 chan = (fu16_t)va_arg(ap, unsigned int); |
2732 userinfo = va_arg(ap, aim_userinfo_t *); | |
2733 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
2734 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 2735 va_end(ap); |
2736 | |
2737 switch(reason) { | |
5420 | 2738 case 0: /* Invalid (0) */ |
2739 buf = g_strdup_printf( | |
2740 ngettext( | |
4276 | 2741 "You missed %hu message from %s because it was invalid.", |
2742 "You missed %hu messages from %s because they were invalid.", | |
2743 nummissed), | |
4282 | 2744 nummissed, |
2745 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2746 break; |
5420 | 2747 case 1: /* Message too large */ |
2748 buf = g_strdup_printf( | |
2749 ngettext( | |
4276 | 2750 "You missed %hu message from %s because it was too large.", |
2751 "You missed %hu messages from %s because they were too large.", | |
2752 nummissed), | |
4282 | 2753 nummissed, |
2754 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2755 break; |
5420 | 2756 case 2: /* Rate exceeded */ |
2757 buf = g_strdup_printf( | |
2758 ngettext( | |
4276 | 2759 "You missed %hu message from %s because the rate limit has been exceeded.", |
2760 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
2761 nummissed), | |
4282 | 2762 nummissed, |
2763 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2764 break; |
5420 | 2765 case 3: /* Evil Sender */ |
2766 buf = g_strdup_printf( | |
2767 ngettext( | |
4276 | 2768 "You missed %hu message from %s because he/she was too evil.", |
2769 "You missed %hu messages from %s because he/she was too evil.", | |
2770 nummissed), | |
4282 | 2771 nummissed, |
2772 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2773 break; |
5420 | 2774 case 4: /* Evil Receiver */ |
2775 buf = g_strdup_printf( | |
2776 ngettext( | |
4276 | 2777 "You missed %hu message from %s because you are too evil.", |
2778 "You missed %hu messages from %s because you are too evil.", | |
2779 nummissed), | |
4282 | 2780 nummissed, |
2781 userinfo->sn); | |
2086 | 2782 break; |
2783 default: | |
5420 | 2784 buf = g_strdup_printf( |
2785 ngettext( | |
4276 | 2786 "You missed %hu message from %s for an unknown reason.", |
2787 "You missed %hu messages from %s for an unknown reason.", | |
2788 nummissed), | |
4282 | 2789 nummissed, |
2790 userinfo->sn); | |
2086 | 2791 break; |
2792 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2793 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 2794 g_free(buf); |
2086 | 2795 |
2796 return 1; | |
2797 } | |
2798 | |
3212 | 2799 static char *gaim_icq_status(int state) { |
2800 /* Make a cute little string that shows the status of the dude or dudet */ | |
2801 if (state & AIM_ICQ_STATE_CHAT) | |
4342 | 2802 return g_strdup_printf(_("Free For Chat")); |
3212 | 2803 else if (state & AIM_ICQ_STATE_DND) |
4342 | 2804 return g_strdup_printf(_("Do Not Disturb")); |
3212 | 2805 else if (state & AIM_ICQ_STATE_OUT) |
4342 | 2806 return g_strdup_printf(_("Not Available")); |
3212 | 2807 else if (state & AIM_ICQ_STATE_BUSY) |
4342 | 2808 return g_strdup_printf(_("Occupied")); |
3212 | 2809 else if (state & AIM_ICQ_STATE_AWAY) |
4342 | 2810 return g_strdup_printf(_("Away")); |
3212 | 2811 else if (state & AIM_ICQ_STATE_WEBAWARE) |
4342 | 2812 return g_strdup_printf(_("Web Aware")); |
3212 | 2813 else if (state & AIM_ICQ_STATE_INVISIBLE) |
4342 | 2814 return g_strdup_printf(_("Invisible")); |
3212 | 2815 else |
4342 | 2816 return g_strdup_printf(_("Online")); |
3212 | 2817 } |
2818 | |
4194 | 2819 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 2820 GaimConnection *gc = sess->aux_data; |
4617 | 2821 struct oscar_data *od = gc->proto_data; |
2822 | |
2823 /* BBB */ | |
3630 | 2824 switch (reason) { |
4151 | 2825 case 3: { /* Decline sendfile. */ |
4617 | 2826 struct gaim_xfer *xfer; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2827 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2828 "AAA - Other user declined file transfer\n"); |
4617 | 2829 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2830 gaim_xfer_cancel_remote(xfer); |
4151 | 2831 } break; |
2832 | |
2833 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2834 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2835 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2836 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 2837 } |
3630 | 2838 |
2839 } | |
2840 | |
2841 return 0; | |
2842 } | |
2843 | |
4194 | 2844 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 2845 GaimConnection *gc = sess->aux_data; |
4151 | 2846 |
2847 switch(reason) { | |
2848 case 0x0003: { /* Reply from an ICQ status message request */ | |
2849 char *status_msg = gaim_icq_status(state); | |
2850 char *dialog_msg, **splitmsg; | |
2851 struct oscar_data *od = gc->proto_data; | |
2852 GSList *l = od->evilhack; | |
2853 gboolean evilhack = FALSE; | |
2854 | |
2855 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
2856 splitmsg = g_strsplit(msg, "\r\n", 0); | |
2857 | |
2858 /* If who is in od->evilhack, then we're just getting the away message, otherwise this | |
2859 * will just get appended to the info box (which is already showing). */ | |
2860 while (l) { | |
2861 char *x = l->data; | |
2862 if (!strcmp(x, normalize(who))) { | |
2863 evilhack = TRUE; | |
2864 g_free(x); | |
2865 od->evilhack = g_slist_remove(od->evilhack, x); | |
2866 break; | |
2867 } | |
2868 l = l->next; | |
2869 } | |
2870 | |
2871 if (evilhack) | |
4344 | 2872 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, status_msg, g_strjoinv("<BR>", splitmsg)); |
4151 | 2873 else |
4344 | 2874 dialog_msg = g_strdup_printf(_("<B>Status:</B> %s<HR>%s"), status_msg, g_strjoinv("<BR>", splitmsg)); |
4151 | 2875 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
2876 | |
2877 g_free(status_msg); | |
2878 g_free(dialog_msg); | |
2879 g_strfreev(splitmsg); | |
2880 } break; | |
2881 | |
2882 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2883 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2884 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2885 "Type 0x%04hx\n", who, reason); |
4151 | 2886 } break; |
2887 } /* end of switch */ | |
2888 | |
2889 return 0; | |
2890 } | |
2891 | |
3212 | 2892 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
2893 va_list ap; | |
2894 fu16_t chan, reason; | |
2895 char *who; | |
2896 | |
2897 va_start(ap, fr); | |
4200 | 2898 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 2899 who = va_arg(ap, char *); |
4200 | 2900 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 2901 |
3952 | 2902 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 2903 char *cookie = va_arg(ap, char *); |
4151 | 2904 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 2905 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 2906 fu32_t state = 0; |
4151 | 2907 char *msg = NULL; |
2908 if (reason == 0x0003) { | |
4200 | 2909 state = va_arg(ap, fu32_t); |
4151 | 2910 msg = va_arg(ap, char *); |
2911 } | |
2912 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
2913 } | |
3952 | 2914 |
3212 | 2915 va_end(ap); |
2916 | |
2917 return 1; | |
2918 } | |
2919 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2920 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2921 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2922 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2923 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2924 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2925 va_start(ap, fr); |
4199 | 2926 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 2927 va_end(ap); |
2928 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2929 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2930 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2931 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 2932 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2933 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 2934 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2935 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2936 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2937 |
2086 | 2938 return 1; |
2939 } | |
2940 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2941 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
4617 | 2942 #if 0 |
5575 | 2943 GaimConnection *gc = sess->aux_data; |
4617 | 2944 struct oscar_data *od = gc->proto_data; |
2945 struct gaim_xfer *xfer; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2946 #endif |
4617 | 2947 va_list ap; |
2948 fu16_t reason; | |
2949 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2950 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2951 va_start(ap, fr); |
4617 | 2952 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 2953 data = va_arg(ap, char *); |
2086 | 2954 va_end(ap); |
2955 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2956 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2957 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 2958 |
2959 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2960 #if 0 |
4617 | 2961 /* If this was a file transfer request, data is a cookie */ |
2962 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, data))) { | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2963 gaim_xfer_cancel_remote(xfer); |
3630 | 2964 return 1; |
2965 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2966 #endif |
3630 | 2967 |
4617 | 2968 /* Data is assumed to be the destination sn */ |
2969 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2970 gaim_notify_error(sess->aux_data, NULL, buf, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2971 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); |
4617 | 2972 g_free(buf); |
2086 | 2973 |
2974 return 1; | |
2975 } | |
2976 | |
3595 | 2977 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2978 GaimConnection *gc = sess->aux_data; |
3595 | 2979 va_list ap; |
2980 fu16_t type1, type2; | |
2981 char *sn; | |
2982 | |
2983 va_start(ap, fr); | |
4199 | 2984 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 2985 sn = va_arg(ap, char *); |
4199 | 2986 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 2987 va_end(ap); |
2988 | |
2989 switch (type2) { | |
2990 case 0x0000: { /* Text has been cleared */ | |
2991 serv_got_typing_stopped(gc, sn); | |
2992 } break; | |
2993 | |
2994 case 0x0001: { /* Paused typing */ | |
3768 | 2995 serv_got_typing(gc, sn, 0, TYPED); |
3595 | 2996 } break; |
2997 | |
2998 case 0x0002: { /* Typing */ | |
3768 | 2999 serv_got_typing(gc, sn, 0, TYPING); |
3595 | 3000 } break; |
3001 | |
3002 default: { | |
5435 | 3003 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2); |
3595 | 3004 } break; |
3005 } | |
3006 | |
3007 return 1; | |
3008 } | |
3009 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3010 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5420 | 3011 char *buf; |
2086 | 3012 va_list ap; |
5420 | 3013 fu16_t reason; |
2086 | 3014 char *destn; |
3015 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3016 va_start(ap, fr); |
4199 | 3017 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3018 destn = va_arg(ap, char *); |
3019 va_end(ap); | |
3020 | |
5420 | 3021 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3022 gaim_notify_error(sess->aux_data, NULL, buf, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3023 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); |
5420 | 3024 g_free(buf); |
2086 | 3025 |
3026 return 1; | |
3027 } | |
3028 | |
3029 static char *images(int flags) { | |
3030 static char buf[1024]; | |
3101 | 3031 g_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s", |
2679 | 3032 (flags & AIM_FLAG_ACTIVEBUDDY) ? "<IMG SRC=\"ab_icon.gif\">" : "", |
2086 | 3033 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", |
3034 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
3101 | 3035 (flags & AIM_FLAG_ICQ) ? "<IMG SRC=\"icq_icon.gif\">" : "", |
2086 | 3036 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", |
3079 | 3037 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : "", |
3038 (flags & AIM_FLAG_WIRELESS) ? "<IMG SRC=\"wireless_icon.gif\">" : ""); | |
2086 | 3039 return buf; |
3040 } | |
3041 | |
3101 | 3042 |
2920 | 3043 static char *caps_string(guint caps) |
3044 { | |
3045 static char buf[512], *tmp; | |
3046 int count = 0, i = 0; | |
3047 guint bit = 1; | |
4742 | 3048 |
3049 if (!caps) { | |
4744 | 3050 return NULL; |
4743 | 3051 } else while (bit <= 0x20000) { |
2920 | 3052 if (bit & caps) { |
3053 switch (bit) { | |
3054 case 0x1: | |
3055 tmp = _("Buddy Icon"); | |
3056 break; | |
3057 case 0x2: | |
3058 tmp = _("Voice"); | |
3059 break; | |
3060 case 0x4: | |
4898 | 3061 tmp = _("Direct IM"); |
2920 | 3062 break; |
3063 case 0x8: | |
3064 tmp = _("Chat"); | |
3065 break; | |
3066 case 0x10: | |
3067 tmp = _("Get File"); | |
3068 break; | |
3069 case 0x20: | |
3070 tmp = _("Send File"); | |
3071 break; | |
3072 case 0x40: | |
3073 case 0x200: | |
3074 tmp = _("Games"); | |
3075 break; | |
3076 case 0x80: | |
4898 | 3077 tmp = _("Add-Ins"); |
2920 | 3078 break; |
3079 case 0x100: | |
3080 tmp = _("Send Buddy List"); | |
3081 break; | |
3082 case 0x400: | |
3083 tmp = _("EveryBuddy Bug"); | |
3084 break; | |
3085 case 0x800: | |
3086 tmp = _("AP User"); | |
3087 break; | |
3088 case 0x1000: | |
3089 tmp = _("ICQ RTF"); | |
3090 break; | |
3091 case 0x2000: | |
3092 tmp = _("Nihilist"); | |
3093 break; | |
3094 case 0x4000: | |
3095 tmp = _("ICQ Server Relay"); | |
3096 break; | |
3097 case 0x8000: | |
3098 tmp = _("ICQ Unknown"); | |
3099 break; | |
3100 case 0x10000: | |
3101 tmp = _("Trillian Encryption"); | |
3102 break; | |
4742 | 3103 case 0x20000: |
3104 tmp = _("ICQ UTF8"); | |
3105 break; | |
2920 | 3106 default: |
3107 tmp = NULL; | |
3108 break; | |
3109 } | |
3110 if (tmp) | |
3111 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
3112 tmp); | |
3113 count++; | |
3114 } | |
3115 bit <<= 1; | |
3116 } | |
4744 | 3117 return buf; |
2920 | 3118 } |
3119 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3120 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3121 GaimConnection *gc = sess->aux_data; |
4791 | 3122 struct oscar_data *od = gc->proto_data; |
5420 | 3123 gchar *header; |
4791 | 3124 GSList *l = od->evilhack; |
3125 gboolean evilhack = FALSE; | |
3126 gchar *membersince = NULL, *onlinesince = NULL, *idle = NULL; | |
3127 va_list ap; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3128 aim_userinfo_t *info; |
4791 | 3129 fu16_t infotype; |
4151 | 3130 char *text_enc = NULL, *text = NULL, *utf8 = NULL; |
3131 int text_len; | |
5575 | 3132 const char *username = gaim_account_get_username(gaim_connection_get_account(gc)); |
2086 | 3133 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3134 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3135 info = va_arg(ap, aim_userinfo_t *); |
4199 | 3136 infotype = (fu16_t) va_arg(ap, unsigned int); |
4151 | 3137 text_enc = va_arg(ap, char *); |
3138 text = va_arg(ap, char *); | |
3139 text_len = va_arg(ap, int); | |
2086 | 3140 va_end(ap); |
3141 | |
4151 | 3142 if (text_len > 0) { |
5129 | 3143 if (!(utf8 = oscar_encoding_to_utf8(text_enc, text, text_len))) { |
4791 | 3144 utf8 = g_strdup(_("<i>Unable to display information because it was sent in an unknown encoding.</i>")); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3145 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3146 "Encountered an unknown encoding while parsing userinfo\n"); |
4151 | 3147 } |
3148 } | |
3149 | |
2993 | 3150 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
4834 | 3151 onlinesince = g_strdup_printf(_("Online Since : <b>%s</b><br>\n"), |
5556 | 3152 asctime(localtime((time_t *)&info->onlinesince))); |
2993 | 3153 } |
3154 | |
3155 if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
4834 | 3156 membersince = g_strdup_printf(_("Member Since : <b>%s</b><br>\n"), |
5556 | 3157 asctime(localtime((time_t *)&info->membersince))); |
2993 | 3158 } |
3159 | |
3160 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
4426 | 3161 gchar *itime = sec_to_text(info->idletime*60); |
4834 | 3162 idle = g_strdup_printf(_("Idle : <b>%s</b>"), itime); |
4426 | 3163 g_free(itime); |
2993 | 3164 } else |
4834 | 3165 idle = g_strdup(_("Idle: <b>Active</b>")); |
2993 | 3166 |
5420 | 3167 header = g_strdup_printf(_("Username : <b>%s</b> %s <br>\n" |
4791 | 3168 "Warning Level : <b>%d %%</b><br>\n" |
2086 | 3169 "%s" |
2993 | 3170 "%s" |
4344 | 3171 "%s\n" |
4791 | 3172 "<hr>\n"), |
2086 | 3173 info->sn, images(info->flags), |
5630 | 3174 (int)((info->warnlevel/10.0) + 0.5), |
2993 | 3175 onlinesince ? onlinesince : "", |
3176 membersince ? membersince : "", | |
3177 idle ? idle : ""); | |
3178 | |
3179 g_free(onlinesince); | |
3180 g_free(membersince); | |
3181 g_free(idle); | |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
3182 |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3183 while (l) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3184 char *x = l->data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3185 if (!strcmp(x, normalize(info->sn))) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3186 evilhack = TRUE; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3187 g_free(x); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3188 od->evilhack = g_slist_remove(od->evilhack, x); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3189 break; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3190 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3191 l = l->next; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3192 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3193 |
2920 | 3194 if (infotype == AIM_GETINFO_AWAYMESSAGE) { |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3195 if (evilhack) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3196 g_show_info_text(gc, info->sn, 2, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3197 header, |
5575 | 3198 (utf8 && *utf8) ? away_subs(utf8, username) : |
4207 | 3199 _("<i>User has no away message</i>"), NULL); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3200 } else { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3201 g_show_info_text(gc, info->sn, 0, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3202 header, |
5575 | 3203 (utf8 && *utf8) ? away_subs(utf8, username) : NULL, |
4791 | 3204 (utf8 && *utf8) ? "<hr>" : NULL, |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3205 NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3206 } |
2920 | 3207 } else if (infotype == AIM_GETINFO_CAPABILITIES) { |
3208 g_show_info_text(gc, info->sn, 2, | |
3209 header, | |
3210 "<i>", _("Client Capabilities: "), | |
3211 caps_string(info->capabilities), | |
3212 "</i>", | |
3213 NULL); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3214 } else { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3215 g_show_info_text(gc, info->sn, 1, |
5575 | 3216 (utf8 && *utf8) ? away_subs(utf8, username) : _("<i>No Information Provided</i>"), |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3217 NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3218 } |
2086 | 3219 |
5420 | 3220 g_free(header); |
4151 | 3221 g_free(utf8); |
3222 | |
2086 | 3223 return 1; |
3224 } | |
3225 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3226 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3227 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3228 fu16_t id; |
2086 | 3229 va_list ap; |
3230 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3231 va_start(ap, fr); |
4199 | 3232 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3233 msg = va_arg(ap, char *); |
3234 va_end(ap); | |
3235 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3236 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3237 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
3238 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3239 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3240 _("Your AIM connection may be lost."), NULL); |
2086 | 3241 |
3242 return 1; | |
3243 } | |
3244 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3245 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3246 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3247 fu16_t type; |
5575 | 3248 GaimConnection *gc = sess->aux_data; |
4617 | 3249 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 3250 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3251 va_start(ap, fr); |
4199 | 3252 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3253 |
3254 switch(type) { | |
3255 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3256 fu8_t maxrooms; |
2086 | 3257 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3258 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3259 |
4199 | 3260 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 3261 exchangecount = va_arg(ap, int); |
3262 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
3263 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3264 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3265 "chat info: Chat Rights:\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3266 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3267 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3268 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3269 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3270 for (i = 0; i < exchangecount; i++) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3271 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3272 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3273 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 3274 while (od->create_rooms) { |
3275 struct create_room *cr = od->create_rooms->data; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3276 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3277 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3278 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3279 g_free(cr->name); |
4617 | 3280 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3281 g_free(cr); |
2086 | 3282 } |
3283 } | |
3284 break; | |
3285 case 0x0008: { | |
3286 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3287 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3288 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3289 fu32_t createtime; |
2086 | 3290 |
3291 fqcn = va_arg(ap, char *); | |
4200 | 3292 instance = (fu16_t)va_arg(ap, unsigned int); |
3293 exchange = (fu16_t)va_arg(ap, unsigned int); | |
3294 flags = (fu16_t)va_arg(ap, unsigned int); | |
3295 createtime = va_arg(ap, fu32_t); | |
3296 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3297 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
3298 createperms = (fu8_t)va_arg(ap, unsigned int); | |
3299 unknown = (fu16_t)va_arg(ap, unsigned int); | |
3300 name = va_arg(ap, char *); | |
3301 ck = va_arg(ap, char *); | |
4194 | 3302 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3303 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
5556 | 3304 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 3305 fqcn, |
3306 exchange, instance, flags, | |
3307 createtime, | |
3308 maxmsglen, maxoccupancy, createperms, unknown, | |
3309 name, ck); | |
4617 | 3310 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 3311 } |
3312 break; | |
3313 default: | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3314 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3315 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 3316 break; |
3317 } | |
4194 | 3318 |
3319 va_end(ap); | |
3320 | |
2086 | 3321 return 1; |
3322 } | |
3323 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3324 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3325 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3326 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3327 aim_userinfo_t *info; |
5575 | 3328 GaimConnection *g = sess->aux_data; |
2086 | 3329 |
3330 struct chat_connection *c = NULL; | |
3331 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3332 va_start(ap, fr); |
2086 | 3333 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3334 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3335 va_end(ap); |
3336 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3337 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3338 if (!c) |
3339 return 1; | |
3340 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3341 for (i = 0; i < count; i++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
3342 gaim_chat_add_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3343 |
3344 return 1; | |
3345 } | |
3346 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3347 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3348 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3349 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3350 aim_userinfo_t *info; |
5575 | 3351 GaimConnection *g = sess->aux_data; |
2086 | 3352 |
3353 struct chat_connection *c = NULL; | |
3354 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3355 va_start(ap, fr); |
2086 | 3356 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3357 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3358 va_end(ap); |
3359 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3360 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3361 if (!c) |
3362 return 1; | |
3363 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3364 for (i = 0; i < count; i++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
3365 gaim_chat_remove_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3366 |
3367 return 1; | |
3368 } | |
3369 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3370 static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3371 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3372 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3373 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3374 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3375 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3376 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3377 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3378 fu32_t creationtime; |
5575 | 3379 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3380 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3381 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3382 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3383 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3384 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3385 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3386 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3387 roomdesc = va_arg(ap, char *); |
4200 | 3388 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
3389 creationtime = va_arg(ap, fu32_t); | |
3390 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3391 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
3392 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
3393 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3394 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3395 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3396 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3397 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3398 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3399 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3400 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3401 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3402 |
2086 | 3403 return 1; |
3404 } | |
3405 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3406 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3407 GaimConnection *gc = sess->aux_data; |
2086 | 3408 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3409 aim_userinfo_t *info; |
2086 | 3410 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3411 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
2086 | 3412 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3413 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3414 info = va_arg(ap, aim_userinfo_t *); |
4194 | 3415 msg = va_arg(ap, char *); |
3416 va_end(ap); | |
2086 | 3417 |
4269 | 3418 serv_got_chat_in(gc, ccon->id, info->sn, 0, msg, time((time_t)NULL)); |
2086 | 3419 |
3420 return 1; | |
3421 } | |
3422 | |
3694 | 3423 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
3424 va_list ap; | |
5575 | 3425 GaimConnection *gc = sess->aux_data; |
3694 | 3426 struct aim_emailinfo *emailinfo; |
3725 | 3427 int havenewmail; |
3694 | 3428 |
3429 va_start(ap, fr); | |
3430 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 3431 havenewmail = va_arg(ap, int); |
3694 | 3432 va_end(ap); |
3433 | |
5628 | 3434 if (emailinfo && gaim_account_get_check_mail(gc->account)) { |
5575 | 3435 gchar *to = g_strdup_printf("%s@%s", gaim_account_get_username(gaim_connection_get_account(gc)), emailinfo->domain); |
5542 | 3436 if (emailinfo->unread && havenewmail) |
3437 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 3438 g_free(to); |
3694 | 3439 } |
3440 | |
3441 return 1; | |
3442 } | |
3443 | |
4804 | 3444 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3445 GaimConnection *gc = sess->aux_data; |
4804 | 3446 struct oscar_data *od = gc->proto_data; |
3447 char *sn; | |
3448 | |
3449 sn = od->requesticon->data; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3450 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3451 "removing %s from hash table\n", sn); |
4804 | 3452 od->requesticon = g_slist_remove(od->requesticon, sn); |
3453 free(sn); | |
3454 | |
3455 if (od->icontimer) | |
3456 g_source_remove(od->icontimer); | |
3457 od->icontimer = g_timeout_add(500, gaim_icon_timerfunc, gc); | |
3458 | |
3459 return 1; | |
3460 } | |
3461 | |
3462 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3463 GaimConnection *gc = sess->aux_data; |
4804 | 3464 struct oscar_data *od = gc->proto_data; |
3465 GSList *cur; | |
3466 va_list ap; | |
3467 char *sn; | |
4853 | 3468 fu8_t *iconcsum, *icon; |
3469 fu16_t iconcsumlen, iconlen; | |
4804 | 3470 |
3471 va_start(ap, fr); | |
3472 sn = va_arg(ap, char *); | |
4853 | 3473 iconcsum = va_arg(ap, fu8_t *); |
3474 iconcsumlen = va_arg(ap, int); | |
4804 | 3475 icon = va_arg(ap, fu8_t *); |
3476 iconlen = va_arg(ap, int); | |
3477 va_end(ap); | |
3478 | |
4853 | 3479 if (iconlen > 0) { |
3480 char *b16; | |
5129 | 3481 struct buddy *b = gaim_find_buddy(gc->account, sn); |
4804 | 3482 set_icon_data(gc, sn, icon, iconlen); |
4853 | 3483 b16 = tobase16(iconcsum, iconcsumlen); |
5129 | 3484 if (b16) { |
3485 gaim_buddy_set_setting(b, "icon_checksum", b16); | |
3486 gaim_blist_save(); | |
5125 | 3487 free(b16); |
5129 | 3488 } |
4853 | 3489 } |
4804 | 3490 |
3491 cur = od->requesticon; | |
3492 while (cur) { | |
3493 char *cursn = cur->data; | |
3494 if (!aim_sncmp(cursn, sn)) { | |
3495 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
3496 free(cursn); | |
3497 cur = od->requesticon; | |
3498 } else | |
3499 cur = cur->next; | |
3500 } | |
3501 | |
3502 if (od->icontimer) | |
3503 g_source_remove(od->icontimer); | |
3504 od->icontimer = g_timeout_add(250, gaim_icon_timerfunc, gc); | |
3505 | |
3506 return 1; | |
3507 } | |
3508 | |
3509 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 3510 GaimConnection *gc = data; |
4804 | 3511 struct oscar_data *od = gc->proto_data; |
3512 struct buddyinfo *bi; | |
3513 aim_conn_t *conn; | |
3514 | |
3515 if (!od->requesticon) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3516 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3517 "no more icons to request\n"); |
4804 | 3518 return FALSE; |
3519 } | |
3520 | |
3521 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
4823 | 3522 if (!conn && !od->iconconnecting) { |
4804 | 3523 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); |
4823 | 3524 od->iconconnecting = TRUE; |
4804 | 3525 return FALSE; |
3526 } | |
3527 | |
3528 bi = g_hash_table_lookup(od->buddyinfo, (char *)od->requesticon->data); | |
4853 | 3529 if (bi && (bi->iconcsumlen > 0)) { |
4889 | 3530 aim_icon_request(od->sess, od->requesticon->data, bi->iconcsum, bi->iconcsumlen); |
4804 | 3531 return FALSE; |
3532 } else { | |
3533 char *sn = od->requesticon->data; | |
3534 od->requesticon = g_slist_remove(od->requesticon, sn); | |
3535 free(sn); | |
3536 } | |
3537 | |
3538 return TRUE; | |
3539 } | |
3540 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3541 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3542 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3543 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3544 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3545 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3546 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3547 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3548 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3549 va_start(ap, fr); |
4199 | 3550 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3551 sn = va_arg(ap, char *); |
3552 va_end(ap); | |
3553 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3554 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sent message to %s.\n", sn); |
2086 | 3555 |
3556 return 1; | |
3557 } | |
3558 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3559 static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3560 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3561 "invalid", |
4194 | 3562 "change", |
3563 "warning", | |
3564 "limit", | |
3565 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3566 }; |
2086 | 3567 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3568 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3569 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3570 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3571 va_start(ap, fr); |
4200 | 3572 code = (fu16_t)va_arg(ap, unsigned int); |
3573 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
3574 windowsize = va_arg(ap, fu32_t); | |
3575 clear = va_arg(ap, fu32_t); | |
3576 alert = va_arg(ap, fu32_t); | |
3577 limit = va_arg(ap, fu32_t); | |
3578 disconnect = va_arg(ap, fu32_t); | |
3579 currentavg = va_arg(ap, fu32_t); | |
3580 maxavg = va_arg(ap, fu32_t); | |
2086 | 3581 va_end(ap); |
3582 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3583 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
5556 | 3584 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
3585 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 3586 (code < 5) ? codes[code] : codes[0], |
3587 rateclass, | |
3588 currentavg, maxavg, | |
3589 alert, clear, | |
3590 limit, disconnect, | |
3591 windowsize); | |
3592 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3593 /* XXX fix these values */ |
2086 | 3594 if (code == AIM_RATE_CODE_CHANGE) { |
3595 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3596 aim_conn_setlatency(fr->conn, 0); |
2086 | 3597 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3598 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
3599 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3600 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3601 _("The last message was not sent because you " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3602 "are over the rate limit. Please wait 10 " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3603 "seconds and try again.")); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3604 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 3605 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3606 aim_conn_setlatency(fr->conn, 0); |
2086 | 3607 } |
3608 | |
3609 return 1; | |
3610 } | |
3611 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3612 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3613 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3614 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3615 aim_userinfo_t *userinfo; |
5575 | 3616 GaimConnection *gc = sess->aux_data; |
2086 | 3617 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3618 va_start(ap, fr); |
4199 | 3619 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3620 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3621 va_end(ap); |
3622 | |
5628 | 3623 serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 3624 |
3625 return 1; | |
3626 } | |
3627 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3628 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3629 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3630 aim_userinfo_t *info; |
5575 | 3631 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3632 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3633 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3634 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3635 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3636 |
5628 | 3637 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 3638 |
3639 if (info->onlinesince) | |
3640 gc->login_time_official = info->onlinesince; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3641 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3642 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3643 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3644 |
4649 | 3645 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3646 GaimConnection *gc = sess->aux_data; |
4666 | 3647 struct oscar_data *od = gc->proto_data; |
4649 | 3648 va_list ap; |
3649 fu16_t code; | |
3650 char *msg; | |
3651 | |
3652 va_start(ap, fr); | |
3653 code = (fu16_t)va_arg(ap, int); | |
3654 msg = va_arg(ap, char *); | |
3655 va_end(ap); | |
3656 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3657 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3658 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 3659 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 3660 if (code == 0x0001) { |
5579 | 3661 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 3662 } else { |
5579 | 3663 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 3664 } |
4666 | 3665 od->killme = TRUE; |
4649 | 3666 } |
3667 | |
3668 return 1; | |
3669 } | |
3670 | |
2675 | 3671 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3672 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3673 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 3674 |
3675 #ifndef NOSSI | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3676 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: requesting ssi list\n"); |
4889 | 3677 aim_ssi_reqrights(sess); |
3678 aim_ssi_reqdata(sess, sess->ssi.timestamp, sess->ssi.numitems); | |
4230 | 3679 #endif |
3680 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3681 aim_bos_reqlocaterights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3682 aim_bos_reqbuddyrights(sess, fr->conn); |
4617 | 3683 aim_im_reqparams(sess); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3684 aim_bos_reqrights(sess, fr->conn); |
4230 | 3685 |
3686 #ifdef NOSSI | |
3687 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); | |
3688 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
3689 #endif | |
2086 | 3690 |
3691 return 1; | |
3692 } | |
3693 | |
2675 | 3694 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3695 GaimConnection *gc = sess->aux_data; |
2647 | 3696 struct oscar_data *od = gc->proto_data; |
3697 | |
2672 | 3698 aim_clientready(sess, fr->conn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3699 gaim_debug(GAIM_DEBUG_INFO, "oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3700 |
2647 | 3701 if (od->chpass) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3702 gaim_debug(GAIM_DEBUG_INFO, "oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3703 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 3704 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3705 od->oldp = NULL; |
2647 | 3706 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3707 od->newp = NULL; |
2647 | 3708 od->chpass = FALSE; |
3709 } | |
2979 | 3710 if (od->setnick) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3711 gaim_debug(GAIM_DEBUG_INFO, "oscar", "formatting screenname\n"); |
2979 | 3712 aim_admin_setnick(sess, fr->conn, od->newsn); |
3713 g_free(od->newsn); | |
3714 od->newsn = NULL; | |
3715 od->setnick = FALSE; | |
3716 } | |
2647 | 3717 if (od->conf) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3718 gaim_debug(GAIM_DEBUG_INFO, "oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3719 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 3720 od->conf = FALSE; |
3721 } | |
3722 if (od->reqemail) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3723 gaim_debug(GAIM_DEBUG_INFO, "oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3724 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 3725 od->reqemail = FALSE; |
3726 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3727 if (od->setemail) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3728 gaim_debug(GAIM_DEBUG_INFO, "oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3729 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3730 g_free(od->email); |
5497 | 3731 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3732 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3733 } |
2647 | 3734 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3735 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3736 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3737 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3738 static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3739 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3740 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3741 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3742 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3743 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3744 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3745 |
4194 | 3746 /* XXX - evidently this crashes on solaris. i have no clue why |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3747 gaim_debug(GAIM_DEBUG_MISC, "oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 3748 "max sender evil = %f, max receiver evil = %f, min msg interval = %u\n", |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3749 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3750 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3751 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3752 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3753 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3754 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 3755 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3756 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3757 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3758 |
4617 | 3759 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3760 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3761 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3762 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3763 |
2993 | 3764 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
3765 { | |
5575 | 3766 GaimConnection *gc = sess->aux_data; |
4617 | 3767 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5306 | 3768 va_list ap; |
3769 fu16_t maxsiglen; | |
2993 | 3770 |
3771 va_start(ap, fr); | |
4199 | 3772 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 3773 va_end(ap); |
3774 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3775 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3776 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 3777 |
4617 | 3778 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
3779 | |
3780 if (od->icq) | |
4151 | 3781 aim_bos_setprofile(sess, fr->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
5301 | 3782 else |
3783 oscar_set_info(gc, gc->account->user_info); | |
2993 | 3784 |
3785 return 1; | |
3786 } | |
3787 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3788 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3789 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3790 fu16_t maxbuddies, maxwatchers; |
5575 | 3791 GaimConnection *gc = sess->aux_data; |
4617 | 3792 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3793 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3794 va_start(ap, fr); |
4199 | 3795 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
3796 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3797 va_end(ap); |
3798 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3799 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3800 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 3801 |
4617 | 3802 od->rights.maxbuddies = (guint)maxbuddies; |
3803 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 3804 |
2086 | 3805 return 1; |
3806 } | |
3807 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3808 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3809 fu16_t maxpermits, maxdenies; |
2086 | 3810 va_list ap; |
5575 | 3811 GaimConnection *gc = sess->aux_data; |
4617 | 3812 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 3813 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3814 va_start(ap, fr); |
4199 | 3815 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
3816 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3817 va_end(ap); |
3818 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3819 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3820 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 3821 |
4617 | 3822 od->rights.maxpermits = (guint)maxpermits; |
3823 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 3824 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
3825 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 3826 serv_finish_login(gc); |
3827 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3828 gaim_debug(GAIM_DEBUG_INFO, "oscar", "buddy list loaded\n"); |
2993 | 3829 |
2672 | 3830 aim_clientready(sess, fr->conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3831 |
4617 | 3832 /* XXX - Should call aim_bos_setidle with 0x0000 */ |
3833 | |
4664 | 3834 if (od->icq) { |
3835 aim_icq_reqofflinemsgs(sess); | |
3836 aim_icq_hideip(sess); | |
3837 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3838 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3839 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 3840 if (sess->authinfo->email) |
3841 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 3842 |
3843 return 1; | |
3844 } | |
3845 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3846 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3847 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3848 struct aim_icq_offlinemsg *msg; |
4075 | 3849 struct aim_incomingim_ch4_args args; |
3850 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3851 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3852 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3853 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3854 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3855 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3856 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3857 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 3858 args.uin = msg->sender; |
3859 args.type = msg->type; | |
4173 | 3860 args.flags = msg->flags; |
4076 | 3861 args.msglen = msg->msglen; |
4075 | 3862 args.msg = msg->msg; |
3863 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); | |
3864 incomingim_chan4(sess, fr->conn, NULL, &args, t); | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3865 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3866 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3867 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3868 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3869 static int gaim_offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3870 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3871 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3872 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3873 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3874 |
4624 | 3875 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3876 { |
5575 | 3877 GaimConnection *gc = sess->aux_data; |
4819 | 3878 gchar *buf, *tmp, *utf8; |
4624 | 3879 gchar who[16]; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3880 va_list ap; |
4151 | 3881 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3882 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3883 va_start(ap, fr); |
4151 | 3884 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3885 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3886 |
4664 | 3887 if (!info->uin) |
3888 return 0; | |
3889 | |
5556 | 3890 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 3891 buf = g_strdup_printf("<b>%s</b> %s", _("UIN:"), who); |
4819 | 3892 if (info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) { |
3893 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Nick:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
3894 } | |
3895 if (info->first && info->first[0] && (utf8 = gaim_try_conv_to_utf8(info->first))) { | |
3896 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("First Name:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
3897 } | |
3898 if (info->last && info->last[0] && (utf8 = gaim_try_conv_to_utf8(info->last))) { | |
3899 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Last Name:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
3900 } | |
3901 if (info->email && info->email[0] && (utf8 = gaim_try_conv_to_utf8(info->email))) { | |
3902 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address:"), "</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | |
4625 | 3903 } |
3904 if (info->numaddresses && info->email2) { | |
3905 int i; | |
3906 for (i = 0; i < info->numaddresses; i++) { | |
4819 | 3907 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_try_conv_to_utf8(info->email2[i]))) { |
3908 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address:"), "</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | |
4643 | 3909 } |
4625 | 3910 } |
4624 | 3911 } |
4819 | 3912 if (info->mobile && info->mobile[0] && (utf8 = gaim_try_conv_to_utf8(info->mobile))) { |
3913 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Mobile Phone:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4625 | 3914 } |
3915 if (info->gender) { | |
4819 | 3916 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Gender:"), "</b> ", info->gender==1 ? _("Female") : _("Male"), NULL); g_free(tmp); |
4151 | 3917 } |
4624 | 3918 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 3919 char date[30]; |
3920 struct tm tm; | |
3921 tm.tm_mday = (int)info->birthday; | |
3922 tm.tm_mon = (int)info->birthmonth-1; | |
3923 tm.tm_year = (int)info->birthyear-1900; | |
4628 | 3924 strftime(date, sizeof(date), "%x", &tm); |
4819 | 3925 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Birthday:"), "</b> ", date, NULL); g_free(tmp); |
4151 | 3926 } |
4624 | 3927 if (info->age) { |
3928 char age[5]; | |
3929 snprintf(age, sizeof(age), "%hhd", info->age); | |
4819 | 3930 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Age:"), "</b> ", age, NULL); g_free(tmp); |
3931 } | |
3932 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->personalwebpage))) { | |
3933 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Personal Web Page:"), "</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | |
3934 } | |
3935 if (info->info && info->info[0] && (utf8 = gaim_try_conv_to_utf8(info->info))) { | |
3936 tmp = buf; buf = g_strconcat(tmp, "<hr><b>", _("Additional Information:"), "</b><br>", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3937 } |
3938 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp); | |
4641 | 3939 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
4819 | 3940 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Home Address:"), "</b>", NULL); g_free(tmp); |
3941 if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->homeaddr))) { | |
3942 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3943 } |
4819 | 3944 if (info->homecity && info->homecity[0] && (utf8 = gaim_try_conv_to_utf8(info->homecity))) { |
3945 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3946 } |
4819 | 3947 if (info->homestate && info->homestate[0] && (utf8 = gaim_try_conv_to_utf8(info->homestate))) { |
3948 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3949 } |
4819 | 3950 if (info->homezip && info->homezip[0] && (utf8 = gaim_try_conv_to_utf8(info->homezip))) { |
3951 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3952 } |
3953 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 3954 } |
4641 | 3955 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
4819 | 3956 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Address:"), "</b>", NULL); g_free(tmp); |
3957 if (info->workaddr && info->workaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->workaddr))) { | |
3958 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3959 } |
4819 | 3960 if (info->workcity && info->workcity[0] && (utf8 = gaim_try_conv_to_utf8(info->workcity))) { |
3961 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3962 } |
4819 | 3963 if (info->workstate && info->workstate[0] && (utf8 = gaim_try_conv_to_utf8(info->workstate))) { |
3964 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3965 } |
4819 | 3966 if (info->workzip && info->workzip[0] && (utf8 = gaim_try_conv_to_utf8(info->workzip))) { |
3967 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3968 } |
3969 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
3970 } | |
4641 | 3971 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
4819 | 3972 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Information:"), "</b>", NULL); g_free(tmp); |
3973 if (info->workcompany && info->workcompany[0] && (utf8 = gaim_try_conv_to_utf8(info->workcompany))) { | |
3974 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Company:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3975 } |
4819 | 3976 if (info->workdivision && info->workdivision[0] && (utf8 = gaim_try_conv_to_utf8(info->workdivision))) { |
3977 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Division:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3978 } |
4819 | 3979 if (info->workposition && info->workposition[0] && (utf8 = gaim_try_conv_to_utf8(info->workposition))) { |
3980 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Position:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3981 } |
4819 | 3982 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->workwebpage))) { |
3983 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Web Page:"), "</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | |
4624 | 3984 } |
3985 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 3986 } |
3987 | |
3988 g_show_info_text(gc, who, 2, buf, NULL); | |
3989 g_free(buf); | |
3990 | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3991 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3992 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3993 |
4759 | 3994 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
3995 { | |
5575 | 3996 GaimConnection *gc = sess->aux_data; |
4820 | 3997 gchar who[16], *utf8; |
4759 | 3998 struct buddy *b; |
3999 va_list ap; | |
4000 struct aim_icq_info *info; | |
4001 | |
4002 va_start(ap, fr); | |
4003 info = va_arg(ap, struct aim_icq_info *); | |
4004 va_end(ap); | |
4005 | |
4822 | 4006 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) { |
5556 | 4007 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 4008 serv_got_alias(gc, who, utf8); |
4759 | 4009 if ((b = gaim_find_buddy(gc->account, who))) { |
4820 | 4010 gaim_buddy_set_setting(b, "servernick", utf8); |
4759 | 4011 gaim_blist_save(); |
4012 } | |
4820 | 4013 g_free(utf8); |
4759 | 4014 } |
4015 | |
4016 return 1; | |
4017 } | |
4018 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4019 static int gaim_popup(aim_session_t *sess, aim_frame_t *fr, ...) |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4020 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4021 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4022 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4023 va_list ap; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4024 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4025 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4026 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4027 url = va_arg(ap, char *); |
4199 | 4028 wid = (fu16_t) va_arg(ap, int); |
4029 hei = (fu16_t) va_arg(ap, int); | |
4030 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4031 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4032 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4033 serv_got_popup(msg, url, wid, hei); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4034 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4035 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4036 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4037 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4038 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) { |
5420 | 4039 GString *buf; |
2086 | 4040 va_list ap; |
4041 char *address, *SNs; | |
4042 int i, num; | |
4043 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4044 va_start(ap, fr); |
2086 | 4045 address = va_arg(ap, char *); |
4046 num = va_arg(ap, int); | |
4047 SNs = va_arg(ap, char *); | |
4048 va_end(ap); | |
4049 | |
5420 | 4050 buf = g_string_new(""); |
4051 g_string_printf(buf, _("<B>%s has the following screen names:</B><BR>"), address); | |
2086 | 4052 for (i = 0; i < num; i++) |
5420 | 4053 g_string_append_printf(buf, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
4054 g_show_info_text(NULL, NULL, 2, buf->str, NULL); | |
4055 g_string_free(buf, TRUE); | |
2086 | 4056 |
4057 return 1; | |
4058 } | |
4059 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4060 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4061 va_list ap; |
4062 char *address; | |
5420 | 4063 char *buf; |
2086 | 4064 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4065 va_start(ap, fr); |
2086 | 4066 address = va_arg(ap, char *); |
4067 va_end(ap); | |
4068 | |
5420 | 4069 buf = g_strdup_printf(_("No results found for email address %s"), address); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4070 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4071 g_free(buf); |
2086 | 4072 |
4073 return 1; | |
4074 } | |
4075 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4076 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4077 fu16_t status; |
2086 | 4078 va_list ap; |
4079 char msg[256]; | |
5575 | 4080 GaimConnection *gc = sess->aux_data; |
2086 | 4081 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4082 va_start(ap, fr); |
4199 | 4083 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 4084 va_end(ap); |
4085 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4086 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4087 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 4088 status ? "unknown" : "email sent"); |
4089 if (!status) { | |
5302 | 4090 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 4091 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4092 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 4093 } |
4094 | |
4095 return 1; | |
4096 } | |
4097 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4098 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4099 GaimConnection *gc = sess->aux_data; |
2086 | 4100 va_list ap; |
3912 | 4101 fu16_t perms, err; |
4102 char *url, *sn, *email; | |
4103 int change; | |
2086 | 4104 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4105 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4106 change = va_arg(ap, int); |
4199 | 4107 perms = (fu16_t) va_arg(ap, unsigned int); |
4108 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 4109 url = va_arg(ap, char *); |
4110 sn = va_arg(ap, char *); | |
4111 email = va_arg(ap, char *); | |
2086 | 4112 va_end(ap); |
4113 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4114 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4115 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
3912 | 4116 change ? "change" : "request", perms, err, url, sn, email); |
4117 | |
4118 if (err && url) { | |
4119 char *dialog_msg; | |
4120 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
4121 switch (err) { | |
4122 case 0x0001: { | |
4123 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
4124 } break; | |
4125 case 0x0006: { | |
4126 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
4127 } break; | |
4128 case 0x000b: { | |
4129 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
4130 } break; | |
4131 case 0x001d: { | |
4132 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because there is already a request pending for this screen name."), err); | |
4133 } break; | |
4134 case 0x0021: { | |
4135 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address has too many screen names associated with it."), err); | |
4136 } break; | |
4137 case 0x0023: { | |
4138 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
4139 } break; | |
4140 default: { | |
4141 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
4142 } break; | |
4143 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4144 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 4145 g_free(dialog_top); |
4146 g_free(dialog_msg); | |
4147 return 1; | |
4148 } | |
4149 | |
4150 if (sn) { | |
4585 | 4151 char *dialog_msg = g_strdup_printf(_("Your screen name is currently formatted as follows:\n%s"), sn); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4152 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 4153 g_free(dialog_msg); |
4154 } | |
4155 | |
4156 if (email) { | |
5575 | 4157 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
4158 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4159 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 4160 g_free(dialog_msg); |
2086 | 4161 } |
4162 | |
4163 return 1; | |
4164 } | |
4165 | |
5575 | 4166 static void oscar_keepalive(GaimConnection *gc) { |
4617 | 4167 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4168 aim_flap_nop(od->sess, od->conn); | |
2086 | 4169 } |
4170 | |
5575 | 4171 static int oscar_send_typing(GaimConnection *gc, char *name, int typing) { |
4617 | 4172 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4173 struct direct_im *dim = find_direct_im(od, name); | |
3595 | 4174 if (dim) |
4870 | 4175 if (typing == TYPING) |
4176 aim_odc_send_typing(od->sess, dim->conn, 0x0002); | |
4177 else if (typing == TYPED) | |
4178 aim_odc_send_typing(od->sess, dim->conn, 0x0001); | |
4179 else | |
4180 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 4181 else { |
5300 | 4182 /* Don't send if this turkey is in our deny list */ |
4183 GSList *list; | |
4184 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
4185 if (!list) { | |
4186 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(name)); | |
4187 if (bi && bi->typingnot) { | |
4188 if (typing == TYPING) | |
4189 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); | |
4190 else if (typing == TYPED) | |
4191 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); | |
4192 else | |
4193 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
4194 } | |
3595 | 4195 } |
4196 } | |
2993 | 4197 return 0; |
4198 } | |
5575 | 4199 static void oscar_ask_direct_im(GaimConnection *gc, const char *name); |
4200 | |
4201 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, int len, int imflags) { | |
4617 | 4202 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4203 struct direct_im *dim = find_direct_im(od, name); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4204 int ret = 0; |
3659 | 4205 GError *err = NULL; |
5575 | 4206 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
3458 | 4207 |
4838 | 4208 if (dim && dim->connected) { |
4209 /* If we're directly connected, send a direct IM */ | |
4210 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
4870 | 4211 if (imflags & IM_FLAG_AWAY) |
4212 ret = aim_odc_send_im(od->sess, dim->conn, message, len == -1 ? strlen(message) : len, 0, 1); | |
4213 else | |
4214 ret = aim_odc_send_im(od->sess, dim->conn, message, len == -1 ? strlen(message) : len, 0, 0); | |
3044 | 4215 } else if (len != -1) { |
4216 /* Trying to send an IM image outside of a direct connection. */ | |
4217 oscar_ask_direct_im(gc, name); | |
4838 | 4218 ret = -ENOTCONN; |
2086 | 4219 } else { |
4738 | 4220 struct buddyinfo *bi; |
3008 | 4221 struct aim_sendimext_args args; |
4222 struct stat st; | |
4151 | 4223 int len; |
4269 | 4224 |
4738 | 4225 bi = g_hash_table_lookup(od->buddyinfo, normalize(name)); |
4226 if (!bi) { | |
4227 bi = g_new0(struct buddyinfo, 1); | |
4228 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(name)), bi); | |
4229 } | |
4230 | |
3008 | 4231 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 4232 if (od->icq) { |
4233 args.features = features_icq; | |
4234 args.featureslen = sizeof(features_icq); | |
3008 | 4235 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 4236 } else { |
4237 args.features = features_aim; | |
4238 args.featureslen = sizeof(features_aim); | |
4972 | 4239 |
4240 if (imflags & IM_FLAG_AWAY) | |
4241 args.flags |= AIM_IMFLAGS_AWAY; | |
4665 | 4242 } |
4269 | 4243 |
4738 | 4244 if (bi->ico_need) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4245 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4246 "Sending buddy icon request with message\n"); |
3008 | 4247 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 4248 bi->ico_need = FALSE; |
3008 | 4249 } |
4269 | 4250 |
5575 | 4251 if (iconfile && !stat(iconfile, &st)) { |
4252 FILE *file = fopen(iconfile, "r"); | |
3008 | 4253 if (file) { |
4254 char *buf = g_malloc(st.st_size); | |
4255 fread(buf, 1, st.st_size, file); | |
4269 | 4256 |
3008 | 4257 args.iconlen = st.st_size; |
4617 | 4258 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 4259 args.iconstamp = st.st_mtime; |
4260 | |
4738 | 4261 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) |
4262 bi->ico_informed = FALSE; | |
4263 | |
4264 if (!bi->ico_informed) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4265 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4266 "Claiming to have a buddy icon\n"); |
4738 | 4267 args.flags |= AIM_IMFLAGS_HASICON; |
4268 bi->ico_me_len = args.iconlen; | |
4269 bi->ico_me_csum = args.iconsum; | |
4270 bi->ico_me_time = args.iconstamp; | |
4271 bi->ico_informed = TRUE; | |
4272 } | |
4273 | |
3008 | 4274 fclose(file); |
4275 g_free(buf); | |
2086 | 4276 } |
4277 } | |
4269 | 4278 |
3008 | 4279 args.destsn = name; |
4269 | 4280 |
3642 | 4281 len = strlen(message); |
5129 | 4282 args.flags |= oscar_encoding_check(message); |
3642 | 4283 if (args.flags & AIM_IMFLAGS_UNICODE) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4284 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode IM\n"); |
4662 | 4285 args.charset = 0x0002; |
4665 | 4286 args.charsubset = 0x0000; |
3659 | 4287 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
4288 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4289 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4290 "Error converting a unicode message: %s\n", err->message); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4291 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4292 "This really shouldn't happen!\n"); |
3659 | 4293 /* We really shouldn't try to send the |
4294 * IM now, but I'm not sure what to do */ | |
4800 | 4295 g_error_free(err); |
3659 | 4296 } |
3850 | 4297 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4298 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4299 "Sending ISO-8859-1 IM\n"); |
4662 | 4300 args.charset = 0x0003; |
4665 | 4301 args.charsubset = 0x0000; |
3659 | 4302 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
4303 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4304 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4305 "conversion error: %s\n", err->message); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4306 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4307 "Someone tell Ethan his 8859-1 detection is wrong\n"); |
3642 | 4308 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
4309 len = strlen(message); | |
4800 | 4310 g_error_free(err); |
3659 | 4311 args.msg = g_convert(message, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
4312 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4313 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4314 "Error in unicode fallback: %s\n", err->message); |
4800 | 4315 g_error_free(err); |
3659 | 4316 } |
3642 | 4317 } |
4318 } else { | |
4662 | 4319 args.charset = 0x0000; |
4320 args.charsubset = 0x0000; | |
3642 | 4321 args.msg = message; |
4322 } | |
4323 args.msglen = len; | |
4269 | 4324 |
4617 | 4325 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 4326 } |
4838 | 4327 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4328 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4329 return 1; |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4330 return ret; |
2086 | 4331 } |
4332 | |
5575 | 4333 static void oscar_get_info(GaimConnection *g, const char *name) { |
4617 | 4334 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4335 if (od->icq) | |
4624 | 4336 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4337 else |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4338 /* people want the away message on the top, so we get the away message |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4339 * first and then get the regular info, since it's too difficult to |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4340 * insert in the middle. i hate people. */ |
4617 | 4341 aim_getinfo(od->sess, od->conn, name, AIM_GETINFO_AWAYMESSAGE); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4342 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4343 |
5575 | 4344 static void oscar_get_away(GaimConnection *g, const char *who) { |
4617 | 4345 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4346 if (od->icq) { | |
4687 | 4347 struct buddy *budlight = gaim_find_buddy(g->account, who); |
3212 | 4348 if (budlight) |
3595 | 4349 if ((budlight->uc & 0xffff0000) >> 16) |
4687 | 4350 aim_im_sendch2_geticqaway(od->sess, who, (budlight->uc & 0xffff0000) >> 16); |
3212 | 4351 else |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4352 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4353 "Error: The user %s has no status message, therefore not requesting.\n", who); |
3212 | 4354 else |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4355 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4356 "Error: Could not find %s in local contact list, therefore unable to request status message.\n", who); |
3212 | 4357 } else |
4617 | 4358 aim_getinfo(od->sess, od->conn, who, AIM_GETINFO_GENERALINFO); |
2086 | 4359 } |
4360 | |
5575 | 4361 static void oscar_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, |
3466 | 4362 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 4363 /* XXX - some of these things are wrong, but i'm lazy */ |
4364 struct oscar_data *od = (struct oscar_data *)g->proto_data; | |
4365 aim_setdirectoryinfo(od->sess, od->conn, first, middle, last, | |
2086 | 4366 maiden, NULL, NULL, city, state, NULL, 0, web); |
4367 } | |
4368 | |
5575 | 4369 static void oscar_set_idle(GaimConnection *gc, int time) { |
5129 | 4370 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4617 | 4371 aim_bos_setidle(od->sess, od->conn, time); |
2086 | 4372 } |
4373 | |
5575 | 4374 static void oscar_set_info(GaimConnection *gc, char *text) { |
5129 | 4375 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4376 fu32_t flags = 0; | |
4377 char *msg = NULL; | |
4378 int msglen = 0; | |
2993 | 4379 |
4617 | 4380 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4381 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4382 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4383 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4384 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4385 "again when you are fully connected.")); |
4617 | 4386 |
4387 if (od->icq) | |
4388 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); | |
4151 | 4389 else { |
5129 | 4390 if (!text) { |
4391 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, NULL, 0, caps_aim); | |
4392 return; | |
4393 } | |
4394 | |
4395 flags = oscar_encoding_check(text); | |
4396 if (flags & AIM_IMFLAGS_UNICODE) { | |
4397 msg = g_convert(text, strlen(text), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
4398 aim_bos_setprofile(od->sess, od->conn, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); | |
4399 g_free(msg); | |
4400 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
4401 msg = g_convert(text, strlen(text), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
4402 aim_bos_setprofile(od->sess, od->conn, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); | |
4403 g_free(msg); | |
4151 | 4404 } else { |
5129 | 4405 msglen = strlen(text); |
4406 aim_bos_setprofile(od->sess, od->conn, "us-ascii", text, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); | |
4151 | 4407 } |
5129 | 4408 |
4409 if (msglen > od->rights.maxsiglen) { | |
4410 gchar *errstr; | |
4411 errstr = g_strdup_printf(_("The maximum profile length of %d bytes has been exceeded. " | |
4412 "Gaim has truncated it for you."), od->rights.maxsiglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4413 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); |
5129 | 4414 g_free(errstr); |
4415 } | |
4416 | |
4417 } | |
2993 | 4418 |
4419 return; | |
2086 | 4420 } |
4421 | |
5575 | 4422 static void oscar_set_away_aim(GaimConnection *gc, struct oscar_data *od, const char *text) |
2993 | 4423 { |
5129 | 4424 fu32_t flags = 0; |
4425 char *msg = NULL; | |
4426 int msglen = 0; | |
2993 | 4427 |
4428 if (od->rights.maxawaymsglen == 0) | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4429 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4430 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4431 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4432 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4433 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4434 "fully connected.")); |
5129 | 4435 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4436 if (gc->away) { |
2993 | 4437 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4438 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4439 } |
2993 | 4440 |
5129 | 4441 if (!text) { |
4151 | 4442 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, "", 0, caps_aim); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4443 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4444 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4445 |
5129 | 4446 flags = oscar_encoding_check(text); |
4447 if (flags & AIM_IMFLAGS_UNICODE) { | |
4448 msg = g_convert(text, strlen(text), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
4449 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "unicode-2-0", msg, | |
4450 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); | |
4451 g_free(msg); | |
4452 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
4453 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
4454 msg = g_convert(text, strlen(text), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
4455 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "iso-8859-1", msg, | |
4456 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); | |
4457 g_free(msg); | |
4458 gc->away = g_strndup(text, od->rights.maxawaymsglen); | |
4459 } else { | |
4460 msglen = strlen(text); | |
4461 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "us-ascii", text, | |
4462 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); | |
4463 gc->away = g_strndup(text, od->rights.maxawaymsglen); | |
4464 } | |
4465 | |
4466 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 4467 gchar *errstr; |
4468 | |
5129 | 4469 errstr = g_strdup_printf(_("The maximum away message length of %d bytes has been exceeded. " |
3427 | 4470 "Gaim has truncated it and set you away."), od->rights.maxawaymsglen); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4471 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 4472 g_free(errstr); |
4473 } | |
4474 | |
4475 return; | |
4476 } | |
4477 | |
5575 | 4478 static void oscar_set_away_icq(GaimConnection *gc, struct oscar_data *od, const char *state, const char *message) |
2993 | 4479 { |
5575 | 4480 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4481 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4482 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4483 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4484 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4485 |
4342 | 4486 if (strcmp(state, _("Invisible"))) { |
5575 | 4487 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
4488 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4489 account->perm_deny = 4; | |
4342 | 4490 } else { |
5542 | 4491 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != 0x03)) |
4889 | 4492 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); |
5575 | 4493 account->perm_deny = 3; |
4342 | 4494 } |
4495 | |
4496 if (!strcmp(state, _("Online"))) | |
4901 | 4497 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 4498 else if (!strcmp(state, _("Away"))) { |
4901 | 4499 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4500 gc->away = g_strdup(""); |
4342 | 4501 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 4502 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4503 gc->away = g_strdup(""); |
4342 | 4504 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 4505 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4506 gc->away = g_strdup(""); |
4342 | 4507 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 4508 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4509 gc->away = g_strdup(""); |
4342 | 4510 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 4511 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4512 gc->away = g_strdup(""); |
4342 | 4513 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 4514 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4515 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4516 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 4517 if (message) { |
4901 | 4518 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4519 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4520 } else { |
4901 | 4521 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4522 } |
2086 | 4523 } |
2993 | 4524 |
4525 return; | |
4526 } | |
4527 | |
5575 | 4528 static void oscar_set_away(GaimConnection *gc, char *state, char *message) |
2993 | 4529 { |
4530 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4531 | |
4532 if (od->icq) | |
4533 oscar_set_away_icq(gc, od, state, message); | |
4534 else | |
4535 oscar_set_away_aim(gc, od, message); | |
4536 | |
4537 return; | |
2086 | 4538 } |
4539 | |
5575 | 4540 static void oscar_warn(GaimConnection *gc, char *name, int anon) { |
4617 | 4541 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4542 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); | |
2086 | 4543 } |
4544 | |
5575 | 4545 static void oscar_dir_search(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 4546 const char *maiden, const char *city, const char *state, const char *country, const char *email) { |
4617 | 4547 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 4548 if (strlen(email)) |
4617 | 4549 aim_usersearch_address(od->sess, od->conn, email); |
2086 | 4550 } |
4551 | |
5575 | 4552 static void oscar_add_buddy(GaimConnection *gc, const char *name) { |
4230 | 4553 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4554 #ifdef NOSSI | |
4555 aim_add_buddy(od->sess, od->conn, name); | |
4556 #else | |
4557 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_exists(od->sess->ssi.local, name))) { | |
4687 | 4558 struct buddy *buddy = gaim_find_buddy(gc->account, name); |
4559 struct group *group = gaim_find_buddys_group(buddy); | |
4230 | 4560 if (buddy && group) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4561 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4562 "ssi: adding buddy %s to group %s\n", name, group->name); |
4889 | 4563 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4230 | 4564 } |
4565 } | |
4566 #endif | |
4759 | 4567 if (od->icq) |
4568 aim_icq_getalias(od->sess, name); | |
4230 | 4569 } |
4570 | |
5575 | 4571 static void oscar_add_buddies(GaimConnection *gc, GList *buddies) { |
4230 | 4572 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4573 #ifdef NOSSI | |
4574 char buf[MSG_LEN]; | |
4575 int n=0; | |
4576 while (buddies) { | |
4577 if (n > MSG_LEN - 18) { | |
4578 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
4579 n = 0; | |
3092 | 4580 } |
4230 | 4581 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); |
4582 buddies = buddies->next; | |
4583 } | |
4584 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
4585 #else | |
4586 if (od->sess->ssi.received_data) { | |
4587 while (buddies) { | |
4687 | 4588 struct buddy *buddy = gaim_find_buddy(gc->account, (const char *)buddies->data); |
4589 struct group *group = gaim_find_buddys_group(buddy); | |
4230 | 4590 if (buddy && group) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4591 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4592 "ssi: adding buddy %s to group %s\n", (const char *)buddies->data, group->name); |
4889 | 4593 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4230 | 4594 } |
4595 buddies = buddies->next; | |
4596 } | |
4597 } | |
4598 #endif | |
4599 } | |
4600 | |
5575 | 4601 static void oscar_remove_buddy(GaimConnection *gc, char *name, char *group) { |
4230 | 4602 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4603 #ifdef NOSSI | |
4604 aim_remove_buddy(od->sess, od->conn, name); | |
4605 #else | |
4606 if (od->sess->ssi.received_data) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4607 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4608 "ssi: deleting buddy %s from group %s\n", name, group); |
4889 | 4609 aim_ssi_delbuddy(od->sess, name, group); |
4230 | 4610 } |
4611 #endif | |
4612 } | |
4613 | |
5575 | 4614 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) { |
4230 | 4615 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4616 #ifdef NOSSI | |
4617 GList *cur; | |
4618 for (cur=buddies; cur; cur=cur->next) | |
4619 aim_remove_buddy(od->sess, od->conn, cur->data); | |
4620 #else | |
4621 if (od->sess->ssi.received_data) { | |
3092 | 4622 while (buddies) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4623 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4624 "ssi: deleting buddy %s from group %s\n", (char *)buddies->data, group); |
4889 | 4625 aim_ssi_delbuddy(od->sess, buddies->data, group); |
3092 | 4626 buddies = buddies->next; |
4627 } | |
4230 | 4628 } |
4629 #endif | |
4630 } | |
4631 | |
4632 #ifndef NOSSI | |
5575 | 4633 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
4269 | 4634 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4303 | 4635 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4636 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4637 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 4638 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 4639 } |
4640 } | |
4641 | |
5575 | 4642 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
4269 | 4643 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4644 if (od->sess->ssi.received_data) { | |
4645 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
4646 if (gname) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4647 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4648 "ssi: changing the alias for buddy %s to %s\n", name, alias); |
4889 | 4649 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 4650 } |
4651 } | |
4652 } | |
4653 | |
5575 | 4654 static void oscar_rename_group(GaimConnection *g, const char *old_group, const char *new_group, GList *members) { |
4230 | 4655 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4656 | |
4657 if (od->sess->ssi.received_data) { | |
4658 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) { | |
4659 oscar_remove_buddies(g, members, old_group); | |
4660 oscar_add_buddies(g, members); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4661 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4662 "ssi: moved all buddies from group %s to %s\n", old_group, new_group); |
4230 | 4663 } else { |
4889 | 4664 aim_ssi_rename_group(od->sess, old_group, new_group); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4665 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4666 "ssi: renamed group %s to %s\n", old_group, new_group); |
2995 | 4667 } |
4668 } | |
4669 } | |
4670 | |
4642 | 4671 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4672 GaimConnection *gc = sess->aux_data; |
4642 | 4673 struct oscar_data *od = gc->proto_data; |
4674 va_list ap; | |
4675 fu16_t reason; | |
4676 | |
4677 va_start(ap, fr); | |
4678 reason = (fu16_t)va_arg(ap, unsigned int); | |
4679 va_end(ap); | |
4680 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4681 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 4682 |
4683 if (reason == 0x0005) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4684 gaim_notify_error(gc, NULL, _("Unable To Retrive Buddy List"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4685 _("Gaim was temporarily unable to retrive your buddy list from the AIM servers. Your buddy list is not lost, and will probably become available in a few hours.")); |
4642 | 4686 } |
4687 | |
4688 /* Activate SSI */ | |
4689 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4690 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4691 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4692 "ssi: activating server-stored buddy list\n"); |
4642 | 4693 aim_ssi_enable(od->sess); |
4694 | |
4695 return 1; | |
4696 } | |
4697 | |
2991 | 4698 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4699 GaimConnection *gc = sess->aux_data; |
4230 | 4700 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4701 int numtypes, i; | |
4702 fu16_t *maxitems; | |
2991 | 4703 va_list ap; |
4704 | |
4705 va_start(ap, fr); | |
4230 | 4706 numtypes = va_arg(ap, int); |
4707 maxitems = va_arg(ap, fu16_t *); | |
2991 | 4708 va_end(ap); |
4709 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4710 gaim_debug(GAIM_DEBUG_MISC, "oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4711 |
4230 | 4712 for (i=0; i<numtypes; i++) |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4713 gaim_debug(GAIM_DEBUG_MISC, NULL, " max type 0x%04x=%hd,", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4714 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4715 |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4716 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
4230 | 4717 |
4718 if (numtypes >= 0) | |
4719 od->rights.maxbuddies = maxitems[0]; | |
4720 if (numtypes >= 1) | |
4721 od->rights.maxgroups = maxitems[1]; | |
4722 if (numtypes >= 2) | |
4723 od->rights.maxpermits = maxitems[2]; | |
4724 if (numtypes >= 3) | |
4725 od->rights.maxdenies = maxitems[3]; | |
2991 | 4726 |
4727 return 1; | |
4728 } | |
4729 | |
4730 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4731 GaimConnection *gc = sess->aux_data; |
4732 GaimAccount *account = gaim_connection_get_account(gc); | |
4230 | 4733 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2995 | 4734 struct aim_ssi_item *curitem; |
2991 | 4735 int tmp; |
4778 | 4736 gboolean export = FALSE; |
4617 | 4737 /* XXX - use these? |
4230 | 4738 va_list ap; |
4739 | |
4740 va_start(ap, fr); | |
4741 fmtver = (fu16_t)va_arg(ap, int); | |
4742 numitems = (fu16_t)va_arg(ap, int); | |
4743 items = va_arg(ap, struct aim_ssi_item); | |
4744 timestamp = va_arg(ap, fu32_t); | |
4745 va_end(ap); */ | |
2991 | 4746 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4747 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4748 "ssi: syncing local list and server list\n"); |
2991 | 4749 |
4750 /* Clean the buddy list */ | |
4889 | 4751 aim_ssi_cleanlist(sess); |
2991 | 4752 |
4753 /* Add from server list to local list */ | |
4230 | 4754 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
2991 | 4755 switch (curitem->type) { |
4230 | 4756 case 0x0000: { /* Buddy */ |
4251 | 4757 if (curitem->name) { |
4292 | 4758 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
4458 | 4759 char *gname_utf8 = gaim_try_conv_to_utf8(gname); |
4282 | 4760 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
4458 | 4761 char *alias_utf8 = gaim_try_conv_to_utf8(alias); |
4687 | 4762 struct buddy *buddy = gaim_find_buddy(gc->account, curitem->name); |
4458 | 4763 /* Should gname be freed here? -- elb */ |
4754 | 4764 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 4765 free(alias); |
4282 | 4766 if (buddy) { |
4292 | 4767 /* Get server stored alias */ |
4705 | 4768 if (alias_utf8) { |
4769 g_free(buddy->alias); | |
4770 buddy->alias = g_strdup(alias_utf8); | |
4771 } | |
4282 | 4772 } else { |
4687 | 4773 struct group *g; |
4774 buddy = gaim_buddy_new(gc->account, curitem->name, alias_utf8); | |
5146 | 4775 |
4754 | 4776 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 4777 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 4778 gaim_blist_add_group(g, NULL); |
4779 } | |
5146 | 4780 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4781 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4782 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
4687 | 4783 gaim_blist_add_buddy(buddy, g, NULL); |
4778 | 4784 export = TRUE; |
4251 | 4785 } |
4458 | 4786 free(gname_utf8); |
4787 free(alias_utf8); | |
2991 | 4788 } |
4230 | 4789 } break; |
4790 | |
4791 case 0x0001: { /* Group */ | |
4282 | 4792 /* Shouldn't add empty groups */ |
4230 | 4793 } break; |
4794 | |
4795 case 0x0002: { /* Permit buddy */ | |
2991 | 4796 if (curitem->name) { |
4230 | 4797 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 4798 GSList *list; |
5575 | 4799 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 4800 if (!list) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4801 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4802 "ssi: adding permit buddy %s to local list\n", curitem->name); |
5575 | 4803 gaim_privacy_permit_add(account, curitem->name); |
2991 | 4804 build_allow_list(); |
4778 | 4805 export = TRUE; |
2991 | 4806 } |
4807 } | |
4230 | 4808 } break; |
4809 | |
4810 case 0x0003: { /* Deny buddy */ | |
2991 | 4811 if (curitem->name) { |
4812 GSList *list; | |
5575 | 4813 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 4814 if (!list) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4815 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4816 "ssi: adding deny buddy %s to local list\n", curitem->name); |
5575 | 4817 gaim_privacy_deny_add(account, curitem->name); |
2991 | 4818 build_block_list(); |
4778 | 4819 export = TRUE; |
2991 | 4820 } |
4821 } | |
4230 | 4822 } break; |
4823 | |
4824 case 0x0004: { /* Permit/deny setting */ | |
2991 | 4825 if (curitem->data) { |
4826 fu8_t permdeny; | |
5575 | 4827 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4828 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
5575 | 4829 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
4830 account->perm_deny = permdeny; | |
4831 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 4832 serv_set_away(gc, "Invisible", ""); |
4833 } | |
4778 | 4834 export = TRUE; |
2991 | 4835 } |
4836 } | |
4230 | 4837 } break; |
4838 | |
4839 case 0x0005: { /* Presence setting */ | |
3109 | 4840 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 4841 } break; |
2991 | 4842 } /* End of switch on curitem->type */ |
4843 } /* End of for loop */ | |
4230 | 4844 |
4845 /* If changes were made, then flush buddy list to file */ | |
4778 | 4846 if (export) |
4349 | 4847 gaim_blist_save(); |
2991 | 4848 |
4759 | 4849 { /* Add from local list to server list */ |
4850 GaimBlistNode *gnode, *bnode; | |
4851 struct group *group; | |
4852 struct buddy *buddy; | |
4853 struct gaim_buddy_list *blist; | |
3017 | 4854 GSList *cur; |
4855 | |
2991 | 4856 /* Buddies */ |
4759 | 4857 if ((blist = gaim_get_blist())) |
4858 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5234 | 4859 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
4860 continue; | |
4759 | 4861 group = (struct group *)gnode; |
4862 for (bnode = gnode->child; bnode; bnode = bnode->next) { | |
5234 | 4863 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
4864 continue; | |
4759 | 4865 buddy = (struct buddy *)bnode; |
4866 if (buddy->account == gc->account) { | |
4867 gchar *servernick = gaim_buddy_get_setting(buddy, "servernick"); | |
4868 if (servernick) { | |
4869 serv_got_alias(gc, buddy->name, servernick); | |
4870 g_free(servernick); | |
4871 } | |
4872 if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) { | |
4873 /* Store local alias on server */ | |
4874 char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name); | |
4783 | 4875 if (!alias && buddy->alias && strlen(buddy->alias)) |
4889 | 4876 aim_ssi_aliasbuddy(sess, group->name, buddy->name, buddy->alias); |
4759 | 4877 free(alias); |
4878 } else { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4879 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4880 "ssi: adding buddy %s from local list to server list\n", buddy->name); |
4889 | 4881 aim_ssi_addbuddy(sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4759 | 4882 } |
4349 | 4883 } |
4230 | 4884 } |
4292 | 4885 } |
2991 | 4886 /* Permit list */ |
4491 | 4887 if (gc->account->permit) { |
4888 for (cur=gc->account->permit; cur; cur=cur->next) | |
4230 | 4889 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4890 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4891 "ssi: adding permit %s from local list to server list\n", (char *)cur->data); |
4889 | 4892 aim_ssi_addpermit(sess, cur->data); |
4230 | 4893 } |
2991 | 4894 } |
4895 | |
4896 /* Deny list */ | |
4491 | 4897 if (gc->account->deny) { |
4898 for (cur=gc->account->deny; cur; cur=cur->next) | |
4230 | 4899 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4900 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4901 "ssi: adding deny %s from local list to server list\n", (char *)cur->data); |
4889 | 4902 aim_ssi_adddeny(sess, cur->data); |
4230 | 4903 } |
2991 | 4904 } |
3109 | 4905 /* Presence settings (idle time visibility) */ |
4230 | 4906 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) |
5631 | 4907 if (!(tmp & 0x400)) |
4889 | 4908 aim_ssi_setpresence(sess, tmp | 0x400); |
4778 | 4909 } /* end adding buddies from local list to server list */ |
4910 | |
4901 | 4911 /* Set our ICQ status */ |
4912 if (od->icq && !gc->away) { | |
4913 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); | |
4914 } | |
4915 | |
4342 | 4916 /* Activate SSI */ |
4917 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4918 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4919 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4920 "ssi: activating server-stored buddy list\n"); |
4642 | 4921 aim_ssi_enable(sess); |
4342 | 4922 |
2991 | 4923 return 1; |
2086 | 4924 } |
4230 | 4925 |
4926 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4927 GaimConnection *gc = sess->aux_data; |
4230 | 4928 va_list ap; |
4929 struct aim_ssi_tmp *retval; | |
4930 | |
4931 va_start(ap, fr); | |
4932 retval = va_arg(ap, struct aim_ssi_tmp *); | |
4933 va_end(ap); | |
4934 | |
4935 while (retval) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4936 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4937 "ssi: status is 0x%04hx for a 0x%04hx action with name %s\n", retval->ack, retval->action, retval->item ? (retval->item->name ? retval->item->name : "no name") : "no item"); |
4230 | 4938 |
4939 if (retval->ack != 0xffff) | |
4940 switch (retval->ack) { | |
4941 case 0x0000: { /* added successfully */ | |
4942 } break; | |
4943 | |
4829 | 4944 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
4945 gchar *buf; | |
4946 buf = g_strdup_printf(_("Could not add the buddy %s because you have too many buddies in your buddy list. Please remove one and try again."), (retval->name ? retval->name : _("(no name)"))); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4947 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 4948 g_free(buf); |
4949 } | |
4950 | |
4230 | 4951 case 0x000e: { /* contact requires authorization */ |
4828 | 4952 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 4953 gaim_auth_sendrequest(gc, retval->name); |
4230 | 4954 } break; |
4955 | |
4956 default: { /* La la la */ | |
5197 | 4957 gchar *buf; |
5402 | 4958 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
4959 buf = g_strdup_printf(_("Could not add the buddy %s for an unknown reason. The most common reason for this is that you have the maximum number of allowed buddies in your buddy list."), (retval->name ? retval->name : _("(no name)"))); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4960 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 4961 g_free(buf); |
5402 | 4962 /* XXX - Should remove buddy from local list */ |
4230 | 4963 } break; |
4964 } | |
4965 | |
4966 retval = retval->next; | |
4967 } | |
4968 | |
4969 return 1; | |
4970 } | |
4971 | |
4972 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4973 GaimConnection *gc = sess->aux_data; |
4230 | 4974 va_list ap; |
4975 char *sn, *msg; | |
4236 | 4976 gchar *dialog_msg, *nombre; |
4230 | 4977 struct name_data *data; |
4236 | 4978 struct buddy *buddy; |
4230 | 4979 |
4980 va_start(ap, fr); | |
4981 sn = va_arg(ap, char *); | |
4982 msg = va_arg(ap, char *); | |
4983 va_end(ap); | |
4984 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4985 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4986 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 4987 |
4687 | 4988 buddy = gaim_find_buddy(gc->account, sn); |
4989 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
4990 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 4991 else |
4992 nombre = g_strdup(sn); | |
4993 | |
4994 dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list. Do you want to add them?"), nombre); | |
4230 | 4995 data = g_new(struct name_data, 1); |
4996 data->gc = gc; | |
4997 data->name = g_strdup(sn); | |
4998 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4999 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5000 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5001 0, data, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5002 G_CALLBACK(gaim_icq_contactadd), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5003 G_CALLBACK(gaim_free_name_data)); |
4236 | 5004 |
4230 | 5005 g_free(dialog_msg); |
4236 | 5006 g_free(nombre); |
4230 | 5007 |
5008 return 1; | |
5009 } | |
5010 | |
5011 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5012 GaimConnection *gc = sess->aux_data; |
4230 | 5013 va_list ap; |
5014 char *sn, *msg; | |
4236 | 5015 gchar *dialog_msg, *nombre; |
4230 | 5016 struct name_data *data; |
4236 | 5017 struct buddy *buddy; |
4230 | 5018 |
5019 va_start(ap, fr); | |
5020 sn = va_arg(ap, char *); | |
5021 msg = va_arg(ap, char *); | |
5022 va_end(ap); | |
5023 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5024 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5025 "ssi: received authorization request from %s\n", sn); |
4230 | 5026 |
4687 | 5027 buddy = gaim_find_buddy(gc->account, sn); |
5028 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5029 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5030 else |
5031 nombre = g_strdup(sn); | |
5032 | |
4337 | 5033 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
4230 | 5034 data = g_new(struct name_data, 1); |
5035 data->gc = gc; | |
5036 data->name = g_strdup(sn); | |
5037 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5038 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5039 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5040 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5041 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5042 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 5043 |
4230 | 5044 g_free(dialog_msg); |
4236 | 5045 g_free(nombre); |
4230 | 5046 |
5047 return 1; | |
5048 } | |
5049 | |
5050 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5051 GaimConnection *gc = sess->aux_data; |
4230 | 5052 va_list ap; |
5053 char *sn, *msg; | |
4236 | 5054 gchar *dialog_msg, *nombre; |
4230 | 5055 fu8_t reply; |
4236 | 5056 struct buddy *buddy; |
4230 | 5057 |
5058 va_start(ap, fr); | |
5059 sn = va_arg(ap, char *); | |
5060 reply = (fu8_t)va_arg(ap, int); | |
5061 msg = va_arg(ap, char *); | |
5062 va_end(ap); | |
5063 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5064 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5065 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 5066 |
4687 | 5067 buddy = gaim_find_buddy(gc->account, sn); |
5068 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5069 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5070 else |
5071 nombre = g_strdup(sn); | |
5072 | |
4230 | 5073 if (reply) { |
5074 /* Granted */ | |
4236 | 5075 dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your contact list."), nombre); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5076 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 5077 } else { |
5078 /* Denied */ | |
4236 | 5079 dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your contact list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5080 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 5081 } |
5082 g_free(dialog_msg); | |
4236 | 5083 g_free(nombre); |
4230 | 5084 |
5085 return 1; | |
5086 } | |
5087 | |
5088 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5089 GaimConnection *gc = sess->aux_data; |
4230 | 5090 va_list ap; |
5091 char *sn; | |
4236 | 5092 struct buddy *buddy; |
4230 | 5093 |
5094 va_start(ap, fr); | |
5095 sn = va_arg(ap, char *); | |
5096 va_end(ap); | |
5097 | |
4687 | 5098 buddy = gaim_find_buddy(gc->account, sn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5099 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5100 "ssi: %s added you to their buddy list\n", sn); |
4687 | 5101 show_got_added(gc, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 5102 |
5103 return 1; | |
5104 } | |
4269 | 5105 #endif |
2086 | 5106 |
5575 | 5107 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5108 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5109 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5110 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5111 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5112 pce->label = _("Join what group:"); |
5234 | 5113 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5114 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5115 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5116 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5117 pce->label = _("Exchange:"); |
5234 | 5118 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5119 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5120 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5121 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5122 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5123 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5124 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5125 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5126 |
5575 | 5127 static void oscar_join_chat(GaimConnection *g, GHashTable *data) { |
4617 | 5128 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5129 aim_conn_t *cur; |
5234 | 5130 char *name, *exchange; |
5131 | |
5132 name = g_hash_table_lookup(data, "room"); | |
5133 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5134 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5135 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5136 "Attempting to join chat room %s.\n", name); |
4617 | 5137 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5138 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5139 "chatnav exists, creating room\n"); |
5234 | 5140 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 5141 } else { |
5142 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5143 struct create_room *cr = g_new0(struct create_room, 1); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5144 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5145 "chatnav does not exist, opening chatnav\n"); |
5234 | 5146 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5147 cr->name = g_strdup(name); |
4617 | 5148 od->create_rooms = g_slist_append(od->create_rooms, cr); |
5149 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 5150 } |
5151 } | |
5152 | |
5575 | 5153 static void oscar_chat_invite(GaimConnection *g, int id, const char *message, const char *name) { |
4617 | 5154 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2086 | 5155 struct chat_connection *ccon = find_oscar_chat(g, id); |
5156 | |
5157 if (!ccon) | |
5158 return; | |
5159 | |
4617 | 5160 aim_chat_invite(od->sess, od->conn, name, message ? message : "", |
2086 | 5161 ccon->exchange, ccon->name, 0x0); |
5162 } | |
5163 | |
5575 | 5164 static void oscar_chat_leave(GaimConnection *g, int id) { |
4617 | 5165 struct oscar_data *od = g ? (struct oscar_data *)g->proto_data : NULL; |
2086 | 5166 GSList *bcs = g->buddy_chats; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5167 struct gaim_conversation *b = NULL; |
2086 | 5168 struct chat_connection *c = NULL; |
5169 int count = 0; | |
5170 | |
5171 while (bcs) { | |
5172 count++; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5173 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5174 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 5175 break; |
5176 bcs = bcs->next; | |
5177 b = NULL; | |
5178 } | |
5179 | |
5180 if (!b) | |
5181 return; | |
5182 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5183 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5184 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 5185 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5186 c = find_oscar_chat(g, gaim_chat_get_id(GAIM_CHAT(b))); |
2086 | 5187 if (c != NULL) { |
4617 | 5188 if (od) |
5189 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 5190 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5191 gaim_input_remove(c->inpa); |
4617 | 5192 if (g && od->sess) |
5193 aim_conn_kill(od->sess, &c->conn); | |
2086 | 5194 g_free(c->name); |
5195 g_free(c->show); | |
5196 g_free(c); | |
5197 } | |
5198 /* we do this because with Oscar it doesn't tell us we left */ | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5199 serv_got_chat_left(g, gaim_chat_get_id(GAIM_CHAT(b))); |
2086 | 5200 } |
5201 | |
5575 | 5202 static int oscar_chat_send(GaimConnection *g, int id, char *message) { |
4617 | 5203 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2086 | 5204 GSList *bcs = g->buddy_chats; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5205 struct gaim_conversation *b = NULL; |
2086 | 5206 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5207 char *buf, *buf2; |
2086 | 5208 int i, j; |
5209 | |
5210 while (bcs) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5211 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5212 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 5213 break; |
5214 bcs = bcs->next; | |
5215 b = NULL; | |
5216 } | |
5217 if (!b) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5218 return -EINVAL; |
2086 | 5219 |
4617 | 5220 bcs = od->oscar_chats; |
2086 | 5221 while (bcs) { |
5222 c = (struct chat_connection *)bcs->data; | |
5223 if (b == c->cnv) | |
5224 break; | |
5225 bcs = bcs->next; | |
5226 c = NULL; | |
5227 } | |
5228 if (!c) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5229 return -EINVAL; |
2086 | 5230 |
5231 buf = g_malloc(strlen(message) * 4 + 1); | |
5232 for (i = 0, j = 0; i < strlen(message); i++) { | |
5233 if (message[i] == '\n') { | |
5234 buf[j++] = '<'; | |
5235 buf[j++] = 'B'; | |
5236 buf[j++] = 'R'; | |
5237 buf[j++] = '>'; | |
5238 } else { | |
5239 buf[j++] = message[i]; | |
5240 } | |
5241 } | |
5242 buf[j] = '\0'; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5243 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5244 if (strlen(buf) > c->maxlen) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5245 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5246 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5247 buf2 = strip_html(buf); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5248 if (strlen(buf2) > c->maxvis) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5249 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5250 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5251 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5252 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5253 |
4617 | 5254 aim_chat_send_im(od->sess, c->conn, 0, buf, strlen(buf)); |
2086 | 5255 g_free(buf); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5256 return 0; |
2086 | 5257 } |
5258 | |
5575 | 5259 static const char *oscar_list_icon(GaimAccount *a, struct buddy *b) { |
4766 | 5260 if (!b || (b && b->name && b->name[0] == '+')) { |
4687 | 5261 if (isdigit(a->username[0])) |
5262 return "icq"; | |
5263 else | |
5264 return "aim"; | |
5265 } | |
5266 | |
5267 if (isdigit(b->name[0])) | |
5268 return "icq"; | |
5269 return "aim"; | |
5270 } | |
5271 | |
4690 | 5272 static void oscar_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 5273 { |
5274 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
5275 int i = 0; | |
5276 | |
5131 | 5277 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
5575 | 5278 GaimAccount *account; |
5279 GaimConnection *gc; | |
5131 | 5280 struct oscar_data *od; |
5281 char *gname; | |
5282 if ((b->name) && (account = b->account) && (gc = account->gc) && | |
5283 (od = gc->proto_data) && (od->sess->ssi.received_data) && | |
5284 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && | |
5285 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
5286 emblems[i++] = "notauthorized"; | |
5287 } else { | |
5288 emblems[i++] = "offline"; | |
5289 } | |
5290 } | |
4916 | 5291 |
4766 | 5292 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 5293 int uc = b->uc >> 16; |
4766 | 5294 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 5295 emblems[i++] = "invisible"; |
4766 | 5296 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 5297 emblems[i++] = "freeforchat"; |
4766 | 5298 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 5299 emblems[i++] = "dnd"; |
4766 | 5300 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 5301 emblems[i++] = "na"; |
4766 | 5302 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 5303 emblems[i++] = "occupied"; |
4766 | 5304 else if (uc & AIM_ICQ_STATE_AWAY) |
5305 emblems[i++] = "away"; | |
5306 } else { | |
5307 if (b->uc & UC_UNAVAILABLE) | |
5308 emblems[i++] = "away"; | |
5309 } | |
4687 | 5310 if (b->uc & UC_WIRELESS) |
5311 emblems[i++] = "wireless"; | |
5312 if (b->uc & UC_AOL) | |
5313 emblems[i++] = "aol"; | |
5314 if (b->uc & UC_ADMIN) | |
5315 emblems[i++] = "admin"; | |
5316 if (b->uc & UC_AB && i < 4) | |
5317 emblems[i++] = "activebuddy"; | |
4766 | 5318 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
5319 emblems[i++] = "unconfirmed"; */ | |
4687 | 5320 *se = emblems[0]; |
5321 *sw = emblems[1]; | |
5322 *nw = emblems[2]; | |
5323 *ne = emblems[3]; | |
5324 } | |
5325 | |
5131 | 5326 static char *oscar_tooltip_text(struct buddy *b) { |
5575 | 5327 GaimConnection *gc = b->account->gc; |
5131 | 5328 struct oscar_data *od = gc->proto_data; |
5329 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name)); | |
5330 gchar *tmp, *yay = g_strdup(""); | |
5331 | |
5332 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
5333 if (isdigit(b->name[0])) { | |
5334 char *tmp, *status; | |
5335 status = gaim_icq_status((b->uc & 0xffff0000) >> 16); | |
5336 tmp = yay; | |
5337 yay = g_strconcat(tmp, _("<b>Status:</b> "), status, "\n", NULL); | |
5338 g_free(tmp); | |
5339 g_free(status); | |
5340 } | |
5341 | |
5342 if (bi) { | |
5343 char *tstr = sec_to_text(time(NULL) - bi->signon + | |
5344 (gc->login_time_official ? gc->login_time_official - gc->login_time : 0)); | |
5345 tmp = yay; | |
5346 yay = g_strconcat(tmp, _("<b>Logged In:</b> "), tstr, "\n", NULL); | |
5347 free(tmp); | |
5348 free(tstr); | |
5349 | |
5350 if (bi->caps) { | |
5351 char *caps = caps_string(bi->caps); | |
5352 tmp = yay; | |
5353 yay = g_strconcat(tmp, _("<b>Capabilities:</b> "), caps, "\n", NULL); | |
5354 free(tmp); | |
5355 } | |
5356 } | |
5357 } else { | |
5358 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | |
5359 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) { | |
5360 tmp = yay; | |
5361 yay = g_strconcat(tmp, _("<b>Status:</b> Not Authorized"), "\n", NULL); | |
5362 g_free(tmp); | |
5363 } else { | |
5364 tmp = yay; | |
5365 yay = g_strconcat(tmp, _("<b>Status:</b> Offline"), "\n", NULL); | |
5366 g_free(tmp); | |
5367 } | |
5368 } | |
5369 | |
5370 /* remove the trailing newline character */ | |
5371 if (yay) | |
5372 yay[strlen(yay)-1] = '\0'; | |
5373 return yay; | |
5374 } | |
5375 | |
5167 | 5376 static char *oscar_status_text(struct buddy *b) { |
5575 | 5377 GaimConnection *gc = b->account->gc; |
5167 | 5378 struct oscar_data *od = gc->proto_data; |
5379 gchar *ret = NULL; | |
5380 | |
5381 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
5382 if (isdigit(b->name[0])) | |
5383 ret = gaim_icq_status((b->uc & 0xffff0000) >> 16); | |
5384 else | |
5385 ret = g_strdup(_("Away")); | |
5386 } else if (!GAIM_BUDDY_IS_ONLINE(b)) { | |
5387 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | |
5388 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
5389 ret = g_strdup(_("Not Authorized")); | |
5390 else | |
5391 ret = g_strdup(_("Offline")); | |
5392 } | |
5393 | |
5394 return ret; | |
5395 } | |
5396 | |
3952 | 5397 /* |
4617 | 5398 * We have just established a socket with the other dude, so set up some handlers. |
3952 | 5399 */ |
4617 | 5400 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5401 GaimConnection *gc = sess->aux_data; |
2086 | 5402 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5403 struct gaim_conversation *cnv; |
2086 | 5404 struct direct_im *dim; |
5405 char buf[256]; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5406 char *sn; |
4617 | 5407 va_list ap; |
5408 aim_conn_t *newconn, *listenerconn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5409 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5410 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5411 newconn = va_arg(ap, aim_conn_t *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5412 listenerconn = va_arg(ap, aim_conn_t *); |
2086 | 5413 va_end(ap); |
5414 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5415 aim_conn_close(listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5416 aim_conn_kill(sess, &listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5417 |
4617 | 5418 sn = g_strdup(aim_odc_getsn(newconn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5419 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5420 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5421 "DirectIM: initiate success to %s\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5422 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5423 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5424 if (!(cnv = gaim_find_conversation(sn))) |
4491 | 5425 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5426 gaim_input_remove(dim->watcher); |
2086 | 5427 dim->conn = newconn; |
4617 | 5428 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
3008 | 5429 dim->connected = TRUE; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5430 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5431 g_free(sn); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5432 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
2086 | 5433 |
4617 | 5434 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
5435 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
5436 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_update_ui, 0); | |
5437 | |
2993 | 5438 return 1; |
5439 } | |
5440 | |
5441 static int gaim_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5442 va_list ap; | |
5443 char *sn; | |
5444 double percent; | |
5575 | 5445 GaimConnection *gc = sess->aux_data; |
2993 | 5446 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5447 struct gaim_conversation *c; |
2993 | 5448 struct direct_im *dim; |
5449 | |
5450 va_start(ap, fr); | |
5451 sn = va_arg(ap, char *); | |
5452 percent = va_arg(ap, double); | |
5453 va_end(ap); | |
5454 | |
2994 | 5455 if (!(dim = find_direct_im(od, sn))) |
5456 return 1; | |
3059 | 5457 if (dim->watcher) { |
5458 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
5459 dim->watcher = 0; | |
5460 } | |
3044 | 5461 while (gtk_events_pending()) |
5462 gtk_main_iteration(); | |
5463 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5464 if ((c = gaim_find_conversation(sn))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5465 gaim_conversation_update_progress(c, percent); |
2993 | 5466 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
5467 oscar_callback, dim->conn); | |
2086 | 5468 |
5469 return 1; | |
5470 } | |
5471 | |
4617 | 5472 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5473 GaimConnection *gc = sess->aux_data; |
4870 | 5474 int imflags = 0; |
2086 | 5475 va_list ap; |
4870 | 5476 char *sn, *msg; |
5477 int len, encoding, isawaymsg; | |
2086 | 5478 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5479 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5480 sn = va_arg(ap, char *); |
2086 | 5481 msg = va_arg(ap, char *); |
2993 | 5482 len = va_arg(ap, int); |
3952 | 5483 encoding = va_arg(ap, int); |
4870 | 5484 isawaymsg = va_arg(ap, int); |
2086 | 5485 va_end(ap); |
5486 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5487 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5488 "Got DirectIM message from %s\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5489 |
4870 | 5490 if (isawaymsg) |
5491 imflags |= IM_FLAG_AWAY; | |
5492 | |
4617 | 5493 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ |
4870 | 5494 serv_got_im(gc, sn, msg, imflags, time(NULL), len); |
2086 | 5495 |
5496 return 1; | |
5497 } | |
5498 | |
4617 | 5499 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5500 va_list ap; |
5501 char *sn; | |
2993 | 5502 int typing; |
5575 | 5503 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5504 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5505 va_start(ap, fr); |
2086 | 5506 sn = va_arg(ap, char *); |
2993 | 5507 typing = va_arg(ap, int); |
2086 | 5508 va_end(ap); |
5509 | |
4870 | 5510 if (typing == 0x0002) { |
2993 | 5511 /* I had to leave this. It's just too funny. It reminds me of my sister. */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5512 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5513 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); |
4342 | 5514 serv_got_typing(gc, sn, 0, TYPING); |
4870 | 5515 } else if (typing == 0x0001) |
5516 serv_got_typing(gc, sn, 0, TYPED); | |
5517 else | |
4342 | 5518 serv_got_typing_stopped(gc, sn); |
2086 | 5519 return 1; |
5520 } | |
5521 | |
5522 struct ask_do_dir_im { | |
5523 char *who; | |
5575 | 5524 GaimConnection *gc; |
2086 | 5525 }; |
5526 | |
3730 | 5527 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
5136 | 5528 g_free(data->who); |
2086 | 5529 g_free(data); |
5530 } | |
5531 | |
3730 | 5532 static void oscar_direct_im(struct ask_do_dir_im *data) { |
5575 | 5533 GaimConnection *gc = data->gc; |
4244 | 5534 struct oscar_data *od; |
2086 | 5535 struct direct_im *dim; |
5536 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
5537 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5136 | 5538 g_free(data->who); |
4244 | 5539 g_free(data); |
5540 return; | |
5541 } | |
5542 | |
5543 od = (struct oscar_data *)gc->proto_data; | |
5544 | |
2086 | 5545 dim = find_direct_im(od, data->who); |
5546 if (dim) { | |
3008 | 5547 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
5548 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
5549 gaim_input_remove(dim->watcher); | |
5550 g_free(dim); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5551 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5552 "Gave up on old direct IM, trying again\n"); |
3008 | 5553 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5554 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); |
5136 | 5555 g_free(data->who); |
4244 | 5556 g_free(data); |
3008 | 5557 return; |
5558 } | |
2086 | 5559 } |
5560 dim = g_new0(struct direct_im, 1); | |
5561 dim->gc = gc; | |
5562 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
5563 | |
4617 | 5564 dim->conn = aim_odc_initiate(od->sess, data->who); |
2086 | 5565 if (dim->conn != NULL) { |
5566 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5567 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 5568 oscar_callback, dim->conn); |
4617 | 5569 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
5570 gaim_odc_initiate, 0); | |
2086 | 5571 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5572 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); |
2086 | 5573 g_free(dim); |
5574 } | |
4244 | 5575 |
5136 | 5576 g_free(data->who); |
4244 | 5577 g_free(data); |
2086 | 5578 } |
5579 | |
5575 | 5580 static void oscar_ask_direct_im(GaimConnection *gc, const char *who) { |
5420 | 5581 gchar *buf; |
2086 | 5582 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); |
5136 | 5583 data->who = g_strdup(who); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
5584 data->gc = gc; |
5420 | 5585 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), who); |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5586 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5587 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5588 _("Because this reveals your IP address, it " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5589 "may be considered a privacy risk. Do you " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5590 "wish to continue?"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5591 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5592 _("Connect"), G_CALLBACK(oscar_direct_im), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5593 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); |
5420 | 5594 g_free(buf); |
2086 | 5595 } |
5596 | |
5575 | 5597 static void oscar_set_permit_deny(GaimConnection *gc) { |
5598 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 5599 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5600 #ifdef NOSSI |
4770 | 5601 GSList *list, *g = gaim_blist_groups(), *g1; |
4230 | 5602 char buf[MAXMSGLEN]; |
5603 int at; | |
5604 | |
5575 | 5605 switch(account->perm_deny) { |
4687 | 5606 case 1: |
5575 | 5607 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 5608 break; |
5609 case 2: | |
5575 | 5610 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 5611 break; |
5612 case 3: | |
5575 | 5613 list = account->permit; |
4230 | 5614 at = 0; |
5615 while (list) { | |
5616 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
5617 list = list->next; | |
5618 } | |
5619 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
5620 break; | |
5621 case 4: | |
5575 | 5622 list = account->deny; |
4230 | 5623 at = 0; |
5624 while (list) { | |
5625 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
5626 list = list->next; | |
5627 } | |
5628 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
5629 break; | |
5630 case 5: | |
4770 | 5631 g1 = g; |
4230 | 5632 at = 0; |
4770 | 5633 while (g1) { |
5634 list = gaim_blist_members((struct group *)g->data); | |
5635 GSList list1 = list; | |
5636 while (list1) { | |
5637 struct buddy *b = list1->data; | |
5575 | 5638 if(b->account == account) |
4349 | 5639 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", b->name); |
4770 | 5640 list1 = list1->next; |
2995 | 5641 } |
4770 | 5642 g_slist_free(list); |
5643 g1 = g1->next; | |
4349 | 5644 } |
4770 | 5645 g_slist_free(g); |
4230 | 5646 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); |
5647 break; | |
5648 default: | |
5649 break; | |
2086 | 5650 } |
4230 | 5651 signoff_blocked(gc); |
5652 #else | |
5653 if (od->sess->ssi.received_data) | |
5575 | 5654 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); |
4230 | 5655 #endif |
2086 | 5656 } |
5657 | |
5575 | 5658 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 5659 #ifdef NOSSI |
4491 | 5660 if (gc->account->permdeny == 3) |
4269 | 5661 oscar_set_permit_deny(gc); |
5662 #else | |
2991 | 5663 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5664 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to add a permit\n"); |
4230 | 5665 if (od->sess->ssi.received_data) |
4889 | 5666 aim_ssi_addpermit(od->sess, who); |
4230 | 5667 #endif |
2086 | 5668 } |
5669 | |
5575 | 5670 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 5671 #ifdef NOSSI |
4491 | 5672 if (gc->account->permdeny == 4) |
4269 | 5673 oscar_set_permit_deny(gc); |
5674 #else | |
2991 | 5675 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5676 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to add a deny\n"); |
4230 | 5677 if (od->sess->ssi.received_data) |
4889 | 5678 aim_ssi_adddeny(od->sess, who); |
4230 | 5679 #endif |
2086 | 5680 } |
5681 | |
5575 | 5682 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 5683 #ifdef NOSSI |
4491 | 5684 if (gc->account->permdeny == 3) |
4269 | 5685 oscar_set_permit_deny(gc); |
5686 #else | |
2991 | 5687 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5688 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to delete a permit\n"); |
4230 | 5689 if (od->sess->ssi.received_data) |
4889 | 5690 aim_ssi_delpermit(od->sess, who); |
4230 | 5691 #endif |
2086 | 5692 } |
5693 | |
5575 | 5694 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 5695 #ifdef NOSSI |
4491 | 5696 if (gc->account->permdeny == 4) |
4269 | 5697 oscar_set_permit_deny(gc); |
5698 #else | |
2991 | 5699 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5700 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to delete a deny\n"); |
4230 | 5701 if (od->sess->ssi.received_data) |
4889 | 5702 aim_ssi_deldeny(od->sess, who); |
4230 | 5703 #endif |
2086 | 5704 } |
5705 | |
5575 | 5706 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 5707 { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5708 struct oscar_data *od = gc->proto_data; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5709 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5710 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5711 if (!od->icq) |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5712 return g_list_append(m, GAIM_AWAY_CUSTOM); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5713 |
4333 | 5714 m = g_list_append(m, _("Online")); |
5715 m = g_list_append(m, _("Away")); | |
5716 m = g_list_append(m, _("Do Not Disturb")); | |
5717 m = g_list_append(m, _("Not Available")); | |
5718 m = g_list_append(m, _("Occupied")); | |
5719 m = g_list_append(m, _("Free For Chat")); | |
5720 m = g_list_append(m, _("Invisible")); | |
5721 | |
5722 return m; | |
5723 } | |
5724 | |
5575 | 5725 static GList *oscar_buddy_menu(GaimConnection *gc, const char *who) { |
4333 | 5726 struct oscar_data *od = gc->proto_data; |
5727 GList *m = NULL; | |
5728 struct proto_buddy_menu *pbm; | |
5729 | |
5730 if (od->icq) { | |
4624 | 5731 #if 0 |
4333 | 5732 pbm = g_new0(struct proto_buddy_menu, 1); |
5733 pbm->label = _("Get Status Msg"); | |
4969 | 5734 pbm->callback = oscar_get_icqstatusmsg; |
4333 | 5735 pbm->gc = gc; |
5736 m = g_list_append(m, pbm); | |
4624 | 5737 #endif |
4333 | 5738 } else { |
4687 | 5739 struct buddy *b = gaim_find_buddy(gc->account, who); |
4356 | 5740 |
5575 | 5741 if ((aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), who)) && GAIM_BUDDY_IS_ONLINE(b)) { |
4333 | 5742 pbm = g_new0(struct proto_buddy_menu, 1); |
5743 pbm->label = _("Direct IM"); | |
5744 pbm->callback = oscar_ask_direct_im; | |
5745 pbm->gc = gc; | |
5746 m = g_list_append(m, pbm); | |
4650 | 5747 |
4333 | 5748 pbm = g_new0(struct proto_buddy_menu, 1); |
5749 pbm->label = _("Send File"); | |
4617 | 5750 pbm->callback = oscar_ask_sendfile; |
4333 | 5751 pbm->gc = gc; |
5752 m = g_list_append(m, pbm); | |
4826 | 5753 #if 0 |
5754 pbm = g_new0(struct proto_buddy_menu, 1); | |
5755 pbm->label = _("Get File"); | |
5756 pbm->callback = oscar_ask_getfile; | |
5757 pbm->gc = gc; | |
5758 m = g_list_append(m, pbm); | |
5759 #endif | |
4333 | 5760 } |
5131 | 5761 } |
5197 | 5762 |
5131 | 5763 if (od->sess->ssi.received_data) { |
5764 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); | |
5765 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { | |
5766 pbm = g_new0(struct proto_buddy_menu, 1); | |
5767 pbm->label = _("Re-request Authorization"); | |
5768 pbm->callback = gaim_auth_sendrequest; | |
5769 pbm->gc = gc; | |
5770 m = g_list_append(m, pbm); | |
4333 | 5771 } |
4916 | 5772 } |
5773 | |
4333 | 5774 return m; |
5775 } | |
5776 | |
5575 | 5777 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
4333 | 5778 struct oscar_data *od = gc->proto_data; |
5575 | 5779 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 5780 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
5781 od->setnick = TRUE; | |
5782 od->newsn = g_strdup(nick); | |
5783 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5784 } else { | |
5785 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
5786 } | |
5787 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5788 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5789 _("Screenname formatting can change only capitalization and whitespace.")); |
4333 | 5790 } |
5791 } | |
5792 | |
5575 | 5793 static void oscar_show_format_screenname(GaimConnection *gc) |
4333 | 5794 { |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
5795 gaim_request_input(gc, NULL, _("New screenname formatting:"), NULL, |
5575 | 5796 gaim_connection_get_display_name(gc), FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
5797 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
5798 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
5799 gc); |
4333 | 5800 } |
5801 | |
5575 | 5802 static void oscar_confirm_account(GaimConnection *gc) |
4333 | 5803 { |
5804 struct oscar_data *od = gc->proto_data; | |
5805 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
5806 | |
5807 if (conn) { | |
5808 aim_admin_reqconfirm(od->sess, conn); | |
5809 } else { | |
5810 od->conf = TRUE; | |
5811 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5812 } | |
5813 } | |
5814 | |
5575 | 5815 static void oscar_show_email(GaimConnection *gc) |
4333 | 5816 { |
5817 struct oscar_data *od = gc->proto_data; | |
5818 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
5819 | |
5820 if (conn) { | |
5821 aim_admin_getinfo(od->sess, conn, 0x11); | |
5822 } else { | |
5823 od->reqemail = TRUE; | |
5824 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5825 } | |
5826 } | |
5827 | |
5575 | 5828 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5829 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5830 struct oscar_data *od = gc->proto_data; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5831 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5832 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5833 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5834 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5835 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5836 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5837 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5838 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5839 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5840 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5841 |
5575 | 5842 static void oscar_show_change_email(GaimConnection *gc) |
4333 | 5843 { |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
5844 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, FALSE, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
5845 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
5846 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
5847 gc); |
4333 | 5848 } |
5849 | |
5575 | 5850 static void oscar_show_awaitingauth(GaimConnection *gc) |
4333 | 5851 { |
2979 | 5852 struct oscar_data *od = gc->proto_data; |
4333 | 5853 gchar *nombre, *text, *tmp; |
4785 | 5854 GaimBlistNode *gnode,*bnode; |
4333 | 5855 int num=0; |
5856 | |
5857 text = g_strdup(_("You are awaiting authorization from the following buddies:<BR>")); | |
5858 | |
4785 | 5859 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
5860 struct group *group = (struct group *)gnode; | |
5861 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5862 continue; | |
5863 for (bnode = gnode->child; bnode; bnode = bnode->next) { | |
5864 struct buddy *buddy = (struct buddy *)bnode; | |
5865 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5866 continue; | |
4491 | 5867 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { |
4687 | 5868 if (gaim_get_buddy_alias_only(buddy)) |
5869 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_get_buddy_alias_only(buddy)); | |
4333 | 5870 else |
4337 | 5871 nombre = g_strdup_printf(" %s", buddy->name); |
4333 | 5872 tmp = g_strdup_printf("%s<BR>%s", text, nombre); |
5873 g_free(text); | |
5874 text = tmp; | |
5875 g_free(nombre); | |
5876 num++; | |
5877 } | |
2979 | 5878 } |
4333 | 5879 } |
5880 | |
5881 if (!num) { | |
5882 tmp = g_strdup_printf("%s<BR>%s", text, _("<i>you are not waiting for authorization</i>")); | |
5883 g_free(text); | |
5884 text = tmp; | |
2979 | 5885 } |
4333 | 5886 |
4959 | 5887 tmp = g_strdup_printf(_("%s<BR><BR>You can re-request authorization from these buddies by right-clicking on them and clicking \"Re-request authorization.\""), text); |
4333 | 5888 g_free(text); |
5889 text = tmp; | |
5575 | 5890 g_show_info_text(gc, gaim_account_get_username(gaim_connection_get_account(gc)), 2, text, NULL); |
4333 | 5891 g_free(text); |
2979 | 5892 } |
5893 | |
5575 | 5894 static void oscar_show_chpassurl(GaimConnection *gc) |
4333 | 5895 { |
5896 struct oscar_data *od = gc->proto_data; | |
5575 | 5897 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
5517 | 5898 open_url(NULL, substituted); |
5899 g_free(substituted); | |
4333 | 5900 } |
5901 | |
5575 | 5902 static GList *oscar_actions(GaimConnection *gc) |
2086 | 5903 { |
5904 struct oscar_data *od = gc->proto_data; | |
4333 | 5905 struct proto_actions_menu *pam; |
5906 GList *m = NULL; | |
5907 | |
5908 pam = g_new0(struct proto_actions_menu, 1); | |
5909 pam->label = _("Set User Info"); | |
5910 pam->callback = show_set_info; | |
5911 pam->gc = gc; | |
5912 m = g_list_append(m, pam); | |
5913 | |
5238 | 5914 pam = g_new0(struct proto_actions_menu, 1); |
5915 pam->label = _("Change Password"); | |
5916 pam->callback = show_change_passwd; | |
5917 pam->gc = gc; | |
5918 m = g_list_append(m, pam); | |
4617 | 5919 |
5920 if (od->sess->authinfo->chpassurl) { | |
5921 pam = g_new0(struct proto_actions_menu, 1); | |
5922 pam->label = _("Change Password (URL)"); | |
5923 pam->callback = oscar_show_chpassurl; | |
5924 pam->gc = gc; | |
5925 m = g_list_append(m, pam); | |
5926 } | |
5927 | |
5238 | 5928 if (!od->icq) { |
4617 | 5929 /* AIM actions */ |
5930 m = g_list_append(m, NULL); | |
4333 | 5931 |
5932 pam = g_new0(struct proto_actions_menu, 1); | |
5933 pam->label = _("Format Screenname"); | |
5934 pam->callback = oscar_show_format_screenname; | |
5935 pam->gc = gc; | |
5936 m = g_list_append(m, pam); | |
5937 | |
5938 pam = g_new0(struct proto_actions_menu, 1); | |
5939 pam->label = _("Confirm Account"); | |
5940 pam->callback = oscar_confirm_account; | |
5941 pam->gc = gc; | |
5942 m = g_list_append(m, pam); | |
5943 | |
5944 pam = g_new0(struct proto_actions_menu, 1); | |
5945 pam->label = _("Display Current Registered Address"); | |
5946 pam->callback = oscar_show_email; | |
5947 pam->gc = gc; | |
5948 m = g_list_append(m, pam); | |
5949 | |
5950 pam = g_new0(struct proto_actions_menu, 1); | |
5951 pam->label = _("Change Current Registered Address"); | |
5952 pam->callback = oscar_show_change_email; | |
5953 pam->gc = gc; | |
5954 m = g_list_append(m, pam); | |
2086 | 5955 } |
4333 | 5956 |
5957 m = g_list_append(m, NULL); | |
5958 | |
5959 pam = g_new0(struct proto_actions_menu, 1); | |
5960 pam->label = _("Show Buddies Awaiting Authorization"); | |
5961 pam->callback = oscar_show_awaitingauth; | |
5962 pam->gc = gc; | |
5963 m = g_list_append(m, pam); | |
5964 | |
2086 | 5965 m = g_list_append(m, NULL); |
4333 | 5966 |
5967 pam = g_new0(struct proto_actions_menu, 1); | |
5968 pam->label = _("Search for Buddy by Email"); | |
5969 pam->callback = show_find_email; | |
5970 pam->gc = gc; | |
5971 m = g_list_append(m, pam); | |
5972 | |
4336 | 5973 /* pam = g_new0(struct proto_actions_menu, 1); |
4333 | 5974 pam->label = _("Search for Buddy by Information"); |
5975 pam->callback = show_find_info; | |
5976 pam->gc = gc; | |
4336 | 5977 m = g_list_append(m, pam); */ |
2086 | 5978 |
5979 return m; | |
5980 } | |
5981 | |
5575 | 5982 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 5983 { |
5984 struct oscar_data *od = gc->proto_data; | |
4617 | 5985 |
5986 if (od->icq) { | |
5987 aim_icq_changepasswd(od->sess, new); | |
2086 | 5988 } else { |
4617 | 5989 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
5990 if (conn) { | |
5991 aim_admin_changepasswd(od->sess, conn, new, old); | |
5992 } else { | |
5993 od->chpass = TRUE; | |
5994 od->oldp = g_strdup(old); | |
5995 od->newp = g_strdup(new); | |
5996 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5997 } | |
2086 | 5998 } |
5999 } | |
6000 | |
5575 | 6001 static void oscar_convo_closed(GaimConnection *gc, char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6002 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6003 struct oscar_data *od = gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6004 struct direct_im *dim = find_direct_im(od, who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6005 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6006 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6007 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6008 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6009 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6010 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6011 aim_conn_kill(od->sess, &dim->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6012 g_free(dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6013 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6014 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6015 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6016 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6017 GAIM_PROTO_OSCAR, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6018 OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6019 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6020 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6021 oscar_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6022 oscar_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6023 oscar_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6024 oscar_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6025 oscar_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6026 oscar_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6027 oscar_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6028 oscar_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6029 oscar_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6030 oscar_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6031 oscar_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6032 oscar_set_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6033 oscar_send_typing, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6034 oscar_get_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6035 oscar_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6036 oscar_get_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6037 oscar_set_dir, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6038 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6039 oscar_dir_search, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6040 oscar_set_idle, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6041 oscar_change_passwd, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6042 oscar_add_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6043 oscar_add_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6044 oscar_remove_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6045 oscar_remove_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6046 oscar_add_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6047 oscar_add_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6048 oscar_rem_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6049 oscar_rem_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6050 oscar_set_permit_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6051 oscar_warn, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6052 oscar_join_chat, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6053 oscar_chat_invite, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6054 oscar_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6055 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6056 oscar_chat_send, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6057 oscar_keepalive, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6058 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6059 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6060 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6061 #ifndef NOSSI |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6062 oscar_alias_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6063 oscar_move_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6064 oscar_rename_group, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6065 #else |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6066 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6067 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6068 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6069 #endif |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6070 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6071 oscar_convo_closed, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6072 NULL |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6073 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6074 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6075 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6076 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6077 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6078 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6079 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6080 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6081 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6082 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6083 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6084 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6085 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6086 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6087 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6088 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6089 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6090 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6091 NULL, /**< author */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6092 WEBSITE, /**< homepage */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6093 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6094 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6095 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6096 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6097 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6098 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6099 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6100 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6101 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6102 static void |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6103 __init_plugin(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6104 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6105 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6106 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6107 option = gaim_account_option_string_new(_("Auth Host"), "server", |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6108 "login.oscar.aol.com"); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6109 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6110 option); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6111 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6112 option = gaim_account_option_int_new(_("Auth Port"), "port", 5190); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6113 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6114 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6115 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6116 my_protocol = plugin; |
2086 | 6117 } |
6118 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6119 GAIM_INIT_PLUGIN(oscar, __init_plugin, info); |