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