14192
|
1 /*
|
|
2 * gaim
|
|
3 *
|
|
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
|
|
5 * Some code copyright (C) 1999-2001, Eric Warmenhoven
|
|
6 * Some code copyright (C) 2001-2003, Sean Egan
|
|
7 * Some code copyright (C) 2001-2005, Mark Doliner <thekingant@users.sourceforge.net>
|
|
8 * Some code copyright (C) 2005, Jonathan Clark <ardentlygnarly@users.sourceforge.net>
|
|
9 *
|
|
10 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx>
|
|
11 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net>
|
|
12 *
|
|
13 * This program is free software; you can redistribute it and/or modify
|
|
14 * it under the terms of the GNU General Public License as published by
|
|
15 * the Free Software Foundation; either version 2 of the License, or
|
|
16 * (at your option) any later version.
|
|
17 *
|
|
18 * This program is distributed in the hope that it will be useful,
|
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 * GNU General Public License for more details.
|
|
22 *
|
|
23 * You should have received a copy of the GNU General Public License
|
|
24 * along with this program; if not, write to the Free Software
|
|
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
26 *
|
|
27 */
|
|
28 #include "internal.h"
|
|
29
|
|
30 #include "account.h"
|
|
31 #include "accountopt.h"
|
|
32 #include "buddyicon.h"
|
|
33 #include "cipher.h"
|
|
34 #include "conversation.h"
|
|
35 #include "core.h"
|
|
36 #include "debug.h"
|
|
37 #include "imgstore.h"
|
|
38 #include "network.h"
|
|
39 #include "notify.h"
|
|
40 #include "privacy.h"
|
|
41 #include "prpl.h"
|
|
42 #include "proxy.h"
|
|
43 #include "request.h"
|
|
44 #include "util.h"
|
|
45 #include "version.h"
|
|
46
|
|
47 #include "oscar.h"
|
|
48 #include "peer.h"
|
|
49
|
|
50 #define OSCAR_STATUS_ID_INVISIBLE "invisible"
|
|
51 #define OSCAR_STATUS_ID_OFFLINE "offline"
|
|
52 #define OSCAR_STATUS_ID_AVAILABLE "available"
|
|
53 #define OSCAR_STATUS_ID_AWAY "away"
|
|
54 #define OSCAR_STATUS_ID_DND "dnd"
|
|
55 #define OSCAR_STATUS_ID_NA "na"
|
|
56 #define OSCAR_STATUS_ID_OCCUPIED "occupied"
|
|
57 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat"
|
|
58 #define OSCAR_STATUS_ID_CUSTOM "custom"
|
|
59
|
|
60 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3"
|
|
61
|
|
62 #define OSCAR_CONNECT_STEPS 6
|
|
63 #define OSCAR_DEFAULT_LOGIN_SERVER "login.oscar.aol.com"
|
|
64 #define OSCAR_DEFAULT_LOGIN_PORT 5190
|
|
65 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1"
|
|
66 #define OSCAR_DEFAULT_AUTHORIZATION TRUE
|
|
67 #define OSCAR_DEFAULT_HIDE_IP TRUE
|
|
68 #define OSCAR_DEFAULT_WEB_AWARE FALSE
|
|
69 #define OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY FALSE
|
|
70
|
|
71 static int caps_aim = OSCAR_CAPABILITY_CHAT | OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM | OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_INTEROPERATE | OSCAR_CAPABILITY_ICHAT;
|
|
72 static int caps_icq = OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM | OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_ICQUTF8 | OSCAR_CAPABILITY_INTEROPERATE | OSCAR_CAPABILITY_ICHAT;
|
|
73
|
|
74 static guint8 features_aim[] = {0x01, 0x01, 0x01, 0x02};
|
|
75 static guint8 features_icq[] = {0x01, 0x06};
|
|
76 static guint8 features_icq_offline[] = {0x01};
|
|
77 static guint8 ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
78
|
|
79 struct create_room {
|
|
80 char *name;
|
|
81 int exchange;
|
|
82 };
|
|
83
|
|
84 struct oscar_ask_directim_data
|
|
85 {
|
|
86 OscarData *od;
|
|
87 char *who;
|
|
88 };
|
|
89
|
|
90 /*
|
|
91 * Various PRPL-specific buddy info that we want to keep track of
|
|
92 * Some other info is maintained by locate.c, and I'd like to move
|
|
93 * the rest of this to libfaim, mostly im.c
|
|
94 *
|
|
95 * TODO: More of this should use the status API.
|
|
96 */
|
|
97 struct buddyinfo {
|
|
98 gboolean typingnot;
|
|
99 guint32 ipaddr;
|
|
100
|
|
101 unsigned long ico_me_len;
|
|
102 unsigned long ico_me_csum;
|
|
103 time_t ico_me_time;
|
|
104 gboolean ico_informed;
|
|
105
|
|
106 unsigned long ico_len;
|
|
107 unsigned long ico_csum;
|
|
108 time_t ico_time;
|
|
109 gboolean ico_need;
|
|
110 gboolean ico_sent;
|
|
111 };
|
|
112
|
|
113 struct name_data {
|
|
114 GaimConnection *gc;
|
|
115 gchar *name;
|
|
116 gchar *nick;
|
|
117 };
|
|
118
|
|
119 static char *msgerrreason[] = {
|
|
120 N_("Invalid error"),
|
|
121 N_("Invalid SNAC"),
|
|
122 N_("Rate to host"),
|
|
123 N_("Rate to client"),
|
|
124 N_("Not logged in"),
|
|
125 N_("Service unavailable"),
|
|
126 N_("Service not defined"),
|
|
127 N_("Obsolete SNAC"),
|
|
128 N_("Not supported by host"),
|
|
129 N_("Not supported by client"),
|
|
130 N_("Refused by client"),
|
|
131 N_("Reply too big"),
|
|
132 N_("Responses lost"),
|
|
133 N_("Request denied"),
|
|
134 N_("Busted SNAC payload"),
|
|
135 N_("Insufficient rights"),
|
|
136 N_("In local permit/deny"),
|
|
137 N_("Too evil (sender)"),
|
|
138 N_("Too evil (receiver)"),
|
|
139 N_("User temporarily unavailable"),
|
|
140 N_("No match"),
|
|
141 N_("List overflow"),
|
|
142 N_("Request ambiguous"),
|
|
143 N_("Queue full"),
|
|
144 N_("Not while on AOL")
|
|
145 };
|
|
146 static int msgerrreasonlen = 25;
|
|
147
|
|
148 /* All the libfaim->gaim callback functions */
|
|
149 static int gaim_parse_auth_resp (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
150 static int gaim_parse_login (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
151 static int gaim_parse_auth_securid_request(OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
152 static int gaim_handle_redirect (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
153 static int gaim_info_change (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
154 static int gaim_account_confirm (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
155 static int gaim_parse_oncoming (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
156 static int gaim_parse_offgoing (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
157 static int gaim_parse_incoming_im(OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
158 static int gaim_parse_misses (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
159 static int gaim_parse_clientauto (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
160 static int gaim_parse_userinfo (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
161 static int gaim_got_infoblock (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
162 static int gaim_parse_motd (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
163 static int gaim_chatnav_info (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
164 static int gaim_conv_chat_join (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
165 static int gaim_conv_chat_leave (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
166 static int gaim_conv_chat_info_update (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
167 static int gaim_conv_chat_incoming_msg(OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
168 static int gaim_email_parseupdate(OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
169 static int gaim_icon_error (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
170 static int gaim_icon_parseicon (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
171 static int oscar_icon_req (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
172 static int gaim_parse_msgack (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
173 static int gaim_parse_ratechange (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
174 static int gaim_parse_evilnotify (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
175 static int gaim_parse_searcherror(OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
176 static int gaim_parse_searchreply(OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
177 static int gaim_bosrights (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
178 static int gaim_connerr (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
179 static int gaim_parse_msgerr (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
180 static int gaim_parse_mtn (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
181 static int gaim_parse_locaterights(OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
182 static int gaim_parse_buddyrights(OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
183 static int gaim_parse_locerr (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
184 static int gaim_icbm_param_info (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
185 static int gaim_parse_genericerr (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
186 static int gaim_memrequest (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
187 static int gaim_selfinfo (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
188 static int gaim_offlinemsg (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
189 static int gaim_offlinemsgdone (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
190 static int gaim_icqalias (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
191 static int gaim_icqinfo (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
192 static int gaim_popup (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
193 static int gaim_ssi_parseerr (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
194 static int gaim_ssi_parserights (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
195 static int gaim_ssi_parselist (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
196 static int gaim_ssi_parseack (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
197 static int gaim_ssi_parseadd (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
198 static int gaim_ssi_authgiven (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
199 static int gaim_ssi_authrequest (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
200 static int gaim_ssi_authreply (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
201 static int gaim_ssi_gotadded (OscarData *, FlapConnection *, FlapFrame *, ...);
|
|
202
|
|
203 static gboolean gaim_icon_timerfunc(gpointer data);
|
|
204
|
|
205 static void recent_buddies_cb(const char *name, GaimPrefType type, gconstpointer value, gpointer data);
|
|
206 static void oscar_set_info(GaimConnection *gc, const char *info);
|
|
207 static void oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo, gboolean setstatus, GaimStatus *status);
|
|
208 static void oscar_set_extendedstatus(GaimConnection *gc);
|
|
209 static gboolean gaim_ssi_rerequestdata(gpointer data);
|
|
210
|
|
211 static void oscar_free_name_data(struct name_data *data) {
|
|
212 g_free(data->name);
|
|
213 g_free(data->nick);
|
|
214 g_free(data);
|
|
215 }
|
|
216
|
|
217 /**
|
|
218 * Determine how we can send this message. Per the warnings elsewhere
|
|
219 * in this file, these little checks determine the simplest encoding
|
|
220 * we can use for a given message send using it.
|
|
221 */
|
|
222 static guint32
|
|
223 oscar_charset_check(const char *utf8)
|
|
224 {
|
|
225 int i = 0;
|
|
226 int charset = AIM_CHARSET_ASCII;
|
|
227
|
|
228 /*
|
|
229 * Can we get away with using our custom encoding?
|
|
230 */
|
|
231 while (utf8[i])
|
|
232 {
|
|
233 if ((unsigned char)utf8[i] > 0x7f) {
|
|
234 /* not ASCII! */
|
|
235 charset = AIM_CHARSET_CUSTOM;
|
|
236 break;
|
|
237 }
|
|
238 i++;
|
|
239 }
|
|
240
|
|
241 /*
|
|
242 * Must we send this message as UNICODE (in the UCS-2BE encoding)?
|
|
243 */
|
|
244 while (utf8[i])
|
|
245 {
|
|
246 /* ISO-8859-1 is 0x00-0xbf in the first byte
|
|
247 * followed by 0xc0-0xc3 in the second */
|
|
248 if ((unsigned char)utf8[i] < 0x80) {
|
|
249 i++;
|
|
250 continue;
|
|
251 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 &&
|
|
252 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) {
|
|
253 i += 2;
|
|
254 continue;
|
|
255 }
|
|
256 charset = AIM_CHARSET_UNICODE;
|
|
257 break;
|
|
258 }
|
|
259
|
|
260 return charset;
|
|
261 }
|
|
262
|
|
263 /**
|
|
264 * Take a string of the form charset="bleh" where bleh is
|
|
265 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and
|
|
266 * return a newly allocated string containing bleh.
|
|
267 */
|
|
268 static gchar *
|
|
269 oscar_encoding_extract(const char *encoding)
|
|
270 {
|
|
271 gchar *ret = NULL;
|
|
272 char *begin, *end;
|
|
273
|
|
274 g_return_val_if_fail(encoding != NULL, NULL);
|
|
275
|
|
276 /* Make sure encoding begins with charset= */
|
|
277 if (strncmp(encoding, "text/aolrtf; charset=", 21) &&
|
|
278 strncmp(encoding, "text/x-aolrtf; charset=", 23))
|
|
279 {
|
|
280 return NULL;
|
|
281 }
|
|
282
|
|
283 begin = strchr(encoding, '"');
|
|
284 end = strrchr(encoding, '"');
|
|
285
|
|
286 if ((begin == NULL) || (end == NULL) || (begin >= end))
|
|
287 return NULL;
|
|
288
|
|
289 ret = g_strndup(begin+1, (end-1) - begin);
|
|
290
|
|
291 return ret;
|
|
292 }
|
|
293
|
|
294 gchar *
|
|
295 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen)
|
|
296 {
|
|
297 gchar *utf8 = NULL;
|
|
298
|
|
299 if ((encoding == NULL) || encoding[0] == '\0') {
|
|
300 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n");
|
|
301 } else if (!strcasecmp(encoding, "iso-8859-1")) {
|
|
302 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL);
|
|
303 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) {
|
|
304 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL);
|
|
305 } else if (!strcasecmp(encoding, "unicode-2-0")) {
|
|
306 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL);
|
|
307 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) {
|
|
308 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", "
|
|
309 "attempting to convert to UTF-8 anyway\n", encoding);
|
|
310 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL);
|
|
311 }
|
|
312
|
|
313 /*
|
|
314 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or
|
|
315 * we have been unable to convert the text to utf-8 from the encoding
|
|
316 * that was specified. So we check if the text is valid utf-8 then
|
|
317 * just copy it.
|
|
318 */
|
|
319 if (utf8 == NULL) {
|
|
320 if (textlen != 0 && *text != '\0'
|
|
321 && !g_utf8_validate(text, textlen, NULL))
|
|
322 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking with is probably using a different encoding than expected. If you know what encoding he is using, you can specify it in the advanced account options for your AIM/ICQ account.)"));
|
|
323 else
|
|
324 utf8 = g_strndup(text, textlen);
|
|
325 }
|
|
326
|
|
327 return utf8;
|
|
328 }
|
|
329
|
|
330 static gchar *
|
|
331 oscar_utf8_try_convert(GaimAccount *account, const gchar *msg)
|
|
332 {
|
|
333 const char *charset = NULL;
|
|
334 char *ret = NULL;
|
|
335
|
|
336 if(aim_sn_is_icq(gaim_account_get_username(account)))
|
|
337 charset = gaim_account_get_string(account, "encoding", NULL);
|
|
338
|
|
339 if(charset && *charset)
|
|
340 ret = g_convert(msg, -1, "UTF-8", charset, NULL, NULL, NULL);
|
|
341
|
|
342 if(!ret)
|
|
343 ret = gaim_utf8_try_convert(msg);
|
|
344
|
|
345 return ret;
|
|
346 }
|
|
347
|
|
348 static gchar *
|
|
349 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback)
|
|
350 {
|
|
351 gchar *ret = NULL;
|
|
352 GError *err = NULL;
|
|
353
|
|
354 if ((charsetstr == NULL) || (*charsetstr == '\0'))
|
|
355 return NULL;
|
|
356
|
|
357 if (strcasecmp("UTF-8", charsetstr)) {
|
|
358 if (fallback)
|
|
359 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err);
|
|
360 else
|
|
361 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err);
|
|
362 if (err != NULL) {
|
|
363 gaim_debug_warning("oscar", "Conversion from %s failed: %s.\n",
|
|
364 charsetstr, err->message);
|
|
365 g_error_free(err);
|
|
366 }
|
|
367 } else {
|
|
368 if (g_utf8_validate(data, datalen, NULL))
|
|
369 ret = g_strndup(data, datalen);
|
|
370 else
|
|
371 gaim_debug_warning("oscar", "String is not valid UTF-8.\n");
|
|
372 }
|
|
373
|
|
374 return ret;
|
|
375 }
|
|
376
|
|
377 /**
|
|
378 * This attemps to decode an incoming IM into a UTF8 string.
|
|
379 *
|
|
380 * We try decoding using two different character sets. The charset
|
|
381 * specified in the IM determines the order in which we attempt to
|
|
382 * decode. We do this because there are lots of broken ICQ clients
|
|
383 * that don't correctly send non-ASCII messages. And if Gaim isn't
|
|
384 * able to deal with that crap, then people complain like banshees.
|
|
385 * charsetstr1 is always set to what the correct encoding should be.
|
|
386 */
|
|
387 gchar *
|
|
388 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, guint16 charset, guint16 charsubset, const gchar *data, gsize datalen)
|
|
389 {
|
|
390 gchar *ret = NULL;
|
|
391 const gchar *charsetstr1, *charsetstr2;
|
|
392
|
|
393 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen);
|
|
394
|
|
395 if ((datalen == 0) || (data == NULL))
|
|
396 return NULL;
|
|
397
|
|
398 if (charset == AIM_CHARSET_UNICODE) {
|
|
399 charsetstr1 = "UCS-2BE";
|
|
400 charsetstr2 = "UTF-8";
|
|
401 } else if (charset == AIM_CHARSET_CUSTOM) {
|
|
402 if ((sourcesn != NULL) && isdigit(sourcesn[0]))
|
|
403 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
|
|
404 else
|
|
405 charsetstr1 = "ISO-8859-1";
|
|
406 charsetstr2 = "UTF-8";
|
|
407 } else if (charset == AIM_CHARSET_ASCII) {
|
|
408 /* Should just be "ASCII" */
|
|
409 charsetstr1 = "ASCII";
|
|
410 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
|
|
411 } else if (charset == 0x000d) {
|
|
412 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */
|
|
413 charsetstr1 = "ISO-8859-1";
|
|
414 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
|
|
415 } else {
|
|
416 /* Unknown, hope for valid UTF-8... */
|
|
417 charsetstr1 = "UTF-8";
|
|
418 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
|
|
419 }
|
|
420
|
|
421 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE);
|
|
422 if (ret == NULL)
|
|
423 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE);
|
|
424 if (ret == NULL)
|
|
425 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)"));
|
|
426
|
|
427 return ret;
|
|
428 }
|
|
429
|
|
430 /**
|
|
431 * Figure out what encoding to use when sending a given outgoing message.
|
|
432 */
|
|
433 static void
|
|
434 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc,
|
|
435 const char *destsn, const gchar *from,
|
|
436 gchar **msg, int *msglen_int,
|
|
437 guint16 *charset, guint16 *charsubset)
|
|
438 {
|
|
439 OscarData *od = gc->proto_data;
|
|
440 GaimAccount *account = gaim_connection_get_account(gc);
|
|
441 GError *err = NULL;
|
|
442 aim_userinfo_t *userinfo = NULL;
|
|
443 const gchar *charsetstr;
|
|
444 gsize msglen;
|
|
445
|
|
446 /* Attempt to send as ASCII */
|
|
447 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) {
|
|
448 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL);
|
|
449 *charset = AIM_CHARSET_ASCII;
|
|
450 *charsubset = 0x0000;
|
|
451 *msglen_int = msglen;
|
|
452 return;
|
|
453 }
|
|
454
|
|
455 /*
|
|
456 * If we're sending to an ICQ user, and they are in our
|
|
457 * buddy list, and they are advertising the Unicode
|
|
458 * capability, and they are online, then attempt to send
|
|
459 * as UCS-2BE.
|
|
460 */
|
|
461 if ((destsn != NULL) && aim_sn_is_icq(destsn))
|
|
462 userinfo = aim_locate_finduserinfo(od, destsn);
|
|
463
|
|
464 if ((userinfo != NULL) && (userinfo->capabilities & OSCAR_CAPABILITY_ICQUTF8))
|
|
465 {
|
|
466 GaimBuddy *b;
|
|
467 b = gaim_find_buddy(account, destsn);
|
|
468 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b)))
|
|
469 {
|
|
470 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL);
|
|
471 if (*msg != NULL)
|
|
472 {
|
|
473 *charset = AIM_CHARSET_UNICODE;
|
|
474 *charsubset = 0x0000;
|
|
475 *msglen_int = msglen;
|
|
476 return;
|
|
477 }
|
|
478 }
|
|
479 }
|
|
480
|
|
481 /*
|
|
482 * If this is AIM then attempt to send as ISO-8859-1. If this is
|
|
483 * ICQ then attempt to send as the user specified character encoding.
|
|
484 */
|
|
485 charsetstr = "ISO-8859-1";
|
|
486 if ((destsn != NULL) && aim_sn_is_icq(destsn))
|
|
487 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
|
|
488
|
|
489 /*
|
|
490 * XXX - We need a way to only attempt to convert if we KNOW "from"
|
|
491 * can be converted to "charsetstr"
|
|
492 */
|
|
493 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL);
|
|
494 if (*msg != NULL) {
|
|
495 *charset = AIM_CHARSET_CUSTOM;
|
|
496 *charsubset = 0x0000;
|
|
497 *msglen_int = msglen;
|
|
498 return;
|
|
499 }
|
|
500
|
|
501 /*
|
|
502 * Nothing else worked, so send as UCS-2BE.
|
|
503 */
|
|
504 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err);
|
|
505 if (*msg != NULL) {
|
|
506 *charset = AIM_CHARSET_UNICODE;
|
|
507 *charsubset = 0x0000;
|
|
508 *msglen_int = msglen;
|
|
509 return;
|
|
510 }
|
|
511
|
|
512 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message);
|
|
513 g_error_free(err);
|
|
514
|
|
515 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n");
|
|
516 *msg = g_strdup(from);
|
|
517 *msglen_int = strlen(*msg);
|
|
518 *charset = AIM_CHARSET_ASCII;
|
|
519 *charsubset = 0x0000;
|
|
520 return;
|
|
521 }
|
|
522
|
|
523 /**
|
|
524 * Looks for %n, %d, or %t in a string, and replaces them with the
|
|
525 * specified name, date, and time, respectively.
|
|
526 *
|
|
527 * @param str The string that may contain the special variables.
|
|
528 * @param name The sender name.
|
|
529 *
|
|
530 * @return A newly allocated string where the special variables are
|
|
531 * expanded. This should be g_free'd by the caller.
|
|
532 */
|
|
533 static gchar *
|
|
534 gaim_str_sub_away_formatters(const char *str, const char *name)
|
|
535 {
|
|
536 char *c;
|
|
537 GString *cpy;
|
|
538 time_t t;
|
|
539 struct tm *tme;
|
|
540
|
|
541 g_return_val_if_fail(str != NULL, NULL);
|
|
542 g_return_val_if_fail(name != NULL, NULL);
|
|
543
|
|
544 /* Create an empty GString that is hopefully big enough for most messages */
|
|
545 cpy = g_string_sized_new(1024);
|
|
546
|
|
547 t = time(NULL);
|
|
548 tme = localtime(&t);
|
|
549
|
|
550 c = (char *)str;
|
|
551 while (*c) {
|
|
552 switch (*c) {
|
|
553 case '%':
|
|
554 if (*(c + 1)) {
|
|
555 switch (*(c + 1)) {
|
|
556 case 'n':
|
|
557 /* append name */
|
|
558 g_string_append(cpy, name);
|
|
559 c++;
|
|
560 break;
|
|
561 case 'd':
|
|
562 /* append date */
|
|
563 g_string_append(cpy, gaim_date_format_short(tme));
|
|
564 c++;
|
|
565 break;
|
|
566 case 't':
|
|
567 /* append time */
|
|
568 g_string_append(cpy, gaim_time_format(tme));
|
|
569 c++;
|
|
570 break;
|
|
571 default:
|
|
572 g_string_append_c(cpy, *c);
|
|
573 }
|
|
574 } else {
|
|
575 g_string_append_c(cpy, *c);
|
|
576 }
|
|
577 break;
|
|
578 default:
|
|
579 g_string_append_c(cpy, *c);
|
|
580 }
|
|
581 c++;
|
|
582 }
|
|
583
|
|
584 return g_string_free(cpy, FALSE);
|
|
585 }
|
|
586
|
|
587 static gchar *oscar_caps_to_string(guint caps)
|
|
588 {
|
|
589 GString *str;
|
|
590 const gchar *tmp;
|
|
591 guint bit = 1;
|
|
592
|
|
593 str = g_string_new("");
|
|
594
|
|
595 if (!caps) {
|
|
596 return NULL;
|
|
597 } else while (bit <= OSCAR_CAPABILITY_LAST) {
|
|
598 if (bit & caps) {
|
|
599 switch (bit) {
|
|
600 case OSCAR_CAPABILITY_BUDDYICON:
|
|
601 tmp = _("Buddy Icon");
|
|
602 break;
|
|
603 case OSCAR_CAPABILITY_TALK:
|
|
604 tmp = _("Voice");
|
|
605 break;
|
|
606 case OSCAR_CAPABILITY_DIRECTIM:
|
|
607 tmp = _("AIM Direct IM");
|
|
608 break;
|
|
609 case OSCAR_CAPABILITY_CHAT:
|
|
610 tmp = _("Chat");
|
|
611 break;
|
|
612 case OSCAR_CAPABILITY_GETFILE:
|
|
613 tmp = _("Get File");
|
|
614 break;
|
|
615 case OSCAR_CAPABILITY_SENDFILE:
|
|
616 tmp = _("Send File");
|
|
617 break;
|
|
618 case OSCAR_CAPABILITY_GAMES:
|
|
619 case OSCAR_CAPABILITY_GAMES2:
|
|
620 tmp = _("Games");
|
|
621 break;
|
|
622 case OSCAR_CAPABILITY_ADDINS:
|
|
623 tmp = _("Add-Ins");
|
|
624 break;
|
|
625 case OSCAR_CAPABILITY_SENDBUDDYLIST:
|
|
626 tmp = _("Send Buddy List");
|
|
627 break;
|
|
628 case OSCAR_CAPABILITY_ICQ_DIRECT:
|
|
629 tmp = _("ICQ Direct Connect");
|
|
630 break;
|
|
631 case OSCAR_CAPABILITY_APINFO:
|
|
632 tmp = _("AP User");
|
|
633 break;
|
|
634 case OSCAR_CAPABILITY_ICQRTF:
|
|
635 tmp = _("ICQ RTF");
|
|
636 break;
|
|
637 case OSCAR_CAPABILITY_EMPTY:
|
|
638 tmp = _("Nihilist");
|
|
639 break;
|
|
640 case OSCAR_CAPABILITY_ICQSERVERRELAY:
|
|
641 tmp = _("ICQ Server Relay");
|
|
642 break;
|
|
643 case OSCAR_CAPABILITY_ICQUTF8OLD:
|
|
644 tmp = _("Old ICQ UTF8");
|
|
645 break;
|
|
646 case OSCAR_CAPABILITY_TRILLIANCRYPT:
|
|
647 tmp = _("Trillian Encryption");
|
|
648 break;
|
|
649 case OSCAR_CAPABILITY_ICQUTF8:
|
|
650 tmp = _("ICQ UTF8");
|
|
651 break;
|
|
652 case OSCAR_CAPABILITY_HIPTOP:
|
|
653 tmp = _("Hiptop");
|
|
654 break;
|
|
655 case OSCAR_CAPABILITY_SECUREIM:
|
|
656 tmp = _("Security Enabled");
|
|
657 break;
|
|
658 case OSCAR_CAPABILITY_VIDEO:
|
|
659 tmp = _("Video Chat");
|
|
660 break;
|
|
661 /* Not actually sure about this one... WinAIM doesn't show anything */
|
|
662 case OSCAR_CAPABILITY_ICHATAV:
|
|
663 tmp = _("iChat AV");
|
|
664 break;
|
|
665 case OSCAR_CAPABILITY_LIVEVIDEO:
|
|
666 tmp = _("Live Video");
|
|
667 break;
|
|
668 case OSCAR_CAPABILITY_CAMERA:
|
|
669 tmp = _("Camera");
|
|
670 break;
|
|
671 default:
|
|
672 tmp = NULL;
|
|
673 break;
|
|
674 }
|
|
675 if (tmp)
|
|
676 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp);
|
|
677 }
|
|
678 bit <<= 1;
|
|
679 }
|
|
680
|
|
681 return g_string_free(str, FALSE);
|
|
682 }
|
|
683
|
|
684 static char *oscar_icqstatus(int state) {
|
|
685 /* Make a cute little string that shows the status of the dude or dudet */
|
|
686 if (state & AIM_ICQ_STATE_CHAT)
|
|
687 return g_strdup_printf(_("Free For Chat"));
|
|
688 else if (state & AIM_ICQ_STATE_DND)
|
|
689 return g_strdup_printf(_("Do Not Disturb"));
|
|
690 else if (state & AIM_ICQ_STATE_OUT)
|
|
691 return g_strdup_printf(_("Not Available"));
|
|
692 else if (state & AIM_ICQ_STATE_BUSY)
|
|
693 return g_strdup_printf(_("Occupied"));
|
|
694 else if (state & AIM_ICQ_STATE_AWAY)
|
|
695 return g_strdup_printf(_("Away"));
|
|
696 else if (state & AIM_ICQ_STATE_WEBAWARE)
|
|
697 return g_strdup_printf(_("Web Aware"));
|
|
698 else if (state & AIM_ICQ_STATE_INVISIBLE)
|
|
699 return g_strdup_printf(_("Invisible"));
|
|
700 else
|
|
701 return g_strdup_printf(_("Online"));
|
|
702 }
|
|
703
|
|
704 static void
|
|
705 oscar_string_append(GString *str, const char *newline,
|
|
706 const char *name, const char *value)
|
|
707 {
|
|
708 if (value && value[0]) {
|
|
709 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, value);
|
|
710 }
|
|
711 }
|
|
712
|
|
713 static void
|
|
714 oscar_string_convert_and_append(GaimAccount *account, GString *str, const char *newline,
|
|
715 const char *name, const char *value)
|
|
716 {
|
|
717 gchar *utf8;
|
|
718
|
|
719 if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) {
|
|
720 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8);
|
|
721 g_free(utf8);
|
|
722 }
|
|
723 }
|
|
724
|
|
725 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo)
|
|
726 {
|
|
727 OscarData *od;
|
|
728 GaimAccount *account;
|
|
729 GaimPresence *presence = NULL;
|
|
730 GaimStatus *status = NULL;
|
|
731 GaimGroup *g = NULL;
|
|
732 struct buddyinfo *bi = NULL;
|
|
733 char *tmp;
|
|
734
|
|
735 od = gc->proto_data;
|
|
736 account = gaim_connection_get_account(gc);
|
|
737
|
|
738 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL)))
|
|
739 return;
|
|
740
|
|
741 if (userinfo == NULL)
|
|
742 userinfo = aim_locate_finduserinfo(od, b->name);
|
|
743
|
|
744 if (b == NULL)
|
|
745 b = gaim_find_buddy(account, userinfo->sn);
|
|
746
|
|
747 if (b != NULL) {
|
|
748 g = gaim_buddy_get_group(b);
|
|
749 presence = gaim_buddy_get_presence(b);
|
|
750 status = gaim_presence_get_active_status(presence);
|
|
751 }
|
|
752
|
|
753 if (userinfo != NULL)
|
|
754 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn));
|
|
755
|
|
756 if (b != NULL) {
|
|
757 if (gaim_presence_is_online(presence)) {
|
|
758 if (aim_sn_is_icq(b->name)) {
|
|
759 GaimStatus *status = gaim_presence_get_active_status(presence);
|
|
760 oscar_string_append(str, newline, _("Status"),
|
|
761 gaim_status_get_name(status));
|
|
762 }
|
|
763 } else {
|
|
764 tmp = aim_ssi_itemlist_findparentname(od->ssi.local, b->name);
|
|
765 if (aim_ssi_waitingforauth(od->ssi.local, tmp, b->name))
|
|
766 oscar_string_append(str, newline, _("Status"),
|
|
767 _("Not Authorized"));
|
|
768 else
|
|
769 oscar_string_append(str, newline, _("Status"),
|
|
770 _("Offline"));
|
|
771 }
|
|
772 }
|
|
773
|
|
774 if ((bi != NULL) && (bi->ipaddr != 0)) {
|
|
775 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu",
|
|
776 (bi->ipaddr & 0xff000000) >> 24,
|
|
777 (bi->ipaddr & 0x00ff0000) >> 16,
|
|
778 (bi->ipaddr & 0x0000ff00) >> 8,
|
|
779 (bi->ipaddr & 0x000000ff));
|
|
780 oscar_string_append(str, newline, _("IP Address"), tmp);
|
|
781 g_free(tmp);
|
|
782 }
|
|
783
|
|
784
|
|
785 if ((userinfo != NULL) && (userinfo->warnlevel != 0)) {
|
|
786 tmp = g_strdup_printf("%d", (int)(userinfo->warnlevel/10.0 + .5));
|
|
787 oscar_string_append(str, newline, _("Warning Level"), tmp);
|
|
788 g_free(tmp);
|
|
789 }
|
|
790
|
|
791 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) {
|
|
792 tmp = aim_ssi_getcomment(od->ssi.local, g->name, b->name);
|
|
793 if (tmp != NULL) {
|
|
794 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp));
|
|
795 g_free(tmp);
|
|
796 oscar_string_convert_and_append(account, str, newline, _("Buddy Comment"), tmp2);
|
|
797 g_free(tmp2);
|
|
798 }
|
|
799 }
|
|
800 }
|
|
801
|
|
802 static char *extract_name(const char *name) {
|
|
803 char *tmp, *x;
|
|
804 int i, j;
|
|
805
|
|
806 if (!name)
|
|
807 return NULL;
|
|
808
|
|
809 x = strchr(name, '-');
|
|
810
|
|
811 if (!x) return NULL;
|
|
812 x = strchr(++x, '-');
|
|
813 if (!x) return NULL;
|
|
814 tmp = g_strdup(++x);
|
|
815
|
|
816 for (i = 0, j = 0; x[i]; i++) {
|
|
817 char hex[3];
|
|
818 if (x[i] != '%') {
|
|
819 tmp[j++] = x[i];
|
|
820 continue;
|
|
821 }
|
|
822 strncpy(hex, x + ++i, 2); hex[2] = 0;
|
|
823 i++;
|
|
824 tmp[j++] = strtol(hex, NULL, 16);
|
|
825 }
|
|
826
|
|
827 tmp[j] = 0;
|
|
828 return tmp;
|
|
829 }
|
|
830
|
|
831 static struct chat_connection *
|
|
832 find_oscar_chat(GaimConnection *gc, int id)
|
|
833 {
|
|
834 OscarData *od = (OscarData *)gc->proto_data;
|
|
835 GSList *cur;
|
|
836 struct chat_connection *cc;
|
|
837
|
|
838 for (cur = od->oscar_chats; cur != NULL; cur = cur->next)
|
|
839 {
|
|
840 cc = (struct chat_connection *)cur->data;
|
|
841 if (cc->id == id)
|
|
842 return cc;
|
|
843 }
|
|
844
|
|
845 return NULL;
|
|
846 }
|
|
847
|
|
848 static struct chat_connection *
|
|
849 find_oscar_chat_by_conn(GaimConnection *gc, FlapConnection *conn)
|
|
850 {
|
|
851 OscarData *od = (OscarData *)gc->proto_data;
|
|
852 GSList *cur;
|
|
853 struct chat_connection *cc;
|
|
854
|
|
855 for (cur = od->oscar_chats; cur != NULL; cur = cur->next)
|
|
856 {
|
|
857 cc = (struct chat_connection *)cur->data;
|
|
858 if (cc->conn == conn)
|
|
859 return cc;
|
|
860 }
|
|
861
|
|
862 return NULL;
|
|
863 }
|
|
864
|
|
865 static struct chat_connection *
|
|
866 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv)
|
|
867 {
|
|
868 OscarData *od = (OscarData *)gc->proto_data;
|
|
869 GSList *cur;
|
|
870 struct chat_connection *cc;
|
|
871
|
|
872 for (cur = od->oscar_chats; cur != NULL; cur = cur->next)
|
|
873 {
|
|
874 cc = (struct chat_connection *)cur->data;
|
|
875 if (cc->conv == conv)
|
|
876 return cc;
|
|
877 }
|
|
878
|
|
879 return NULL;
|
|
880 }
|
|
881
|
|
882 void
|
|
883 oscar_chat_destroy(struct chat_connection *cc)
|
|
884 {
|
|
885 g_free(cc->name);
|
|
886 g_free(cc->show);
|
|
887 g_free(cc);
|
|
888 }
|
|
889
|
|
890 static void
|
|
891 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc)
|
|
892 {
|
|
893 OscarData *od = (OscarData *)gc->proto_data;
|
|
894
|
|
895 /* Notify the conversation window that we've left the chat */
|
|
896 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv)));
|
|
897
|
|
898 /* Destroy the chat_connection */
|
|
899 od->oscar_chats = g_slist_remove(od->oscar_chats, cc);
|
|
900 flap_connection_schedule_destroy(cc->conn, OSCAR_DISCONNECT_DONE);
|
|
901 oscar_chat_destroy(cc);
|
|
902 }
|
|
903
|
|
904 /**
|
|
905 * This is the callback function anytime gaim_proxy_connect()
|
|
906 * establishes a new TCP connection with an oscar host. Depending
|
|
907 * on the type of host, we do a few different things here.
|
|
908 */
|
|
909 static void
|
|
910 connection_established_cb(gpointer data, gint source, const gchar *error_message)
|
|
911 {
|
|
912 GaimConnection *gc;
|
|
913 OscarData *od;
|
|
914 GaimAccount *account;
|
|
915 FlapConnection *conn;
|
|
916
|
|
917 conn = data;
|
|
918 od = conn->od;
|
|
919 gc = od->gc;
|
|
920 account = gaim_connection_get_account(gc);
|
|
921
|
14262
|
922 conn->connect_data = NULL;
|
14192
|
923 conn->fd = source;
|
|
924
|
|
925 if (source < 0)
|
|
926 {
|
|
927 gaim_debug_error("oscar", "unable to connect FLAP server "
|
|
928 "of type 0x%04hx\n", conn->type);
|
|
929 if (conn->type == SNAC_FAMILY_AUTH)
|
|
930 gaim_connection_error(gc, _("Could not connect to authentication server"));
|
|
931 if (conn->type == SNAC_FAMILY_LOCATE)
|
|
932 gaim_connection_error(gc, _("Could not connect to BOS server"));
|
|
933 else /* Maybe we should call this for BOS connections, too? */
|
|
934 flap_connection_schedule_destroy(conn,
|
|
935 OSCAR_DISCONNECT_COULD_NOT_CONNECT);
|
|
936 return;
|
|
937 }
|
|
938
|
|
939 gaim_debug_info("oscar", "connected to FLAP server of type 0x%04hx\n",
|
|
940 conn->type);
|
|
941 conn->watcher_incoming = gaim_input_add(conn->fd,
|
|
942 GAIM_INPUT_READ, flap_connection_recv_cb, conn);
|
|
943 if (conn->cookie == NULL)
|
|
944 {
|
|
945 if (!aim_sn_is_icq(gaim_account_get_username(account)))
|
|
946 /*
|
|
947 * We don't send this when authenticating an ICQ account
|
|
948 * because for some reason ICQ is still using the
|
|
949 * assy/insecure authentication procedure.
|
|
950 */
|
|
951 flap_connection_send_version(od, conn);
|
|
952 }
|
|
953 else
|
|
954 {
|
|
955 flap_connection_send_version_with_cookie(od, conn,
|
|
956 conn->cookielen, conn->cookie);
|
|
957 g_free(conn->cookie);
|
|
958 conn->cookie = NULL;
|
|
959 }
|
|
960
|
|
961 if (conn->type == SNAC_FAMILY_AUTH)
|
|
962 {
|
|
963 aim_request_login(od, conn, gaim_account_get_username(account));
|
|
964 gaim_debug_info("oscar", "Screen name sent, waiting for response\n");
|
|
965 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS);
|
|
966 ck[1] = 0x65;
|
|
967 }
|
|
968 else if (conn->type == SNAC_FAMILY_LOCATE)
|
|
969 {
|
|
970 gaim_connection_update_progress(gc, _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS);
|
|
971 ck[4] = 0x61;
|
|
972 }
|
|
973 else if (conn->type == SNAC_FAMILY_CHAT)
|
|
974 {
|
14348
|
975 od->oscar_chats = g_slist_prepend(od->oscar_chats, conn->new_conn_data);
|
14262
|
976 conn->new_conn_data = NULL;
|
14192
|
977 }
|
|
978 }
|
|
979
|
|
980 static void
|
|
981 flap_connection_established_bos(OscarData *od, FlapConnection *conn)
|
|
982 {
|
|
983 GaimConnection *gc = od->gc;
|
|
984
|
|
985 aim_reqpersonalinfo(od, conn);
|
|
986
|
|
987 gaim_debug_info("oscar", "ssi: requesting rights and list\n");
|
|
988 aim_ssi_reqrights(od);
|
|
989 aim_ssi_reqdata(od);
|
|
990 if (od->getblisttimer > 0)
|
|
991 gaim_timeout_remove(od->getblisttimer);
|
|
992 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od);
|
|
993
|
|
994 aim_locate_reqrights(od);
|
|
995 aim_buddylist_reqrights(od, conn);
|
|
996 aim_im_reqparams(od);
|
|
997 aim_bos_reqrights(od, conn); /* TODO: Don't call this with ssi */
|
|
998
|
|
999 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS);
|
|
1000 }
|
|
1001
|
|
1002 static void
|
|
1003 flap_connection_established_admin(OscarData *od, FlapConnection *conn)
|
|
1004 {
|
|
1005 aim_clientready(od, conn);
|
|
1006 gaim_debug_info("oscar", "connected to admin\n");
|
|
1007
|
|
1008 if (od->chpass) {
|
|
1009 gaim_debug_info("oscar", "changing password\n");
|
|
1010 aim_admin_changepasswd(od, conn, od->newp, od->oldp);
|
|
1011 g_free(od->oldp);
|
|
1012 od->oldp = NULL;
|
|
1013 g_free(od->newp);
|
|
1014 od->newp = NULL;
|
|
1015 od->chpass = FALSE;
|
|
1016 }
|
|
1017 if (od->setnick) {
|
|
1018 gaim_debug_info("oscar", "formatting screen name\n");
|
|
1019 aim_admin_setnick(od, conn, od->newsn);
|
|
1020 g_free(od->newsn);
|
|
1021 od->newsn = NULL;
|
|
1022 od->setnick = FALSE;
|
|
1023 }
|
|
1024 if (od->conf) {
|
|
1025 gaim_debug_info("oscar", "confirming account\n");
|
|
1026 aim_admin_reqconfirm(od, conn);
|
|
1027 od->conf = FALSE;
|
|
1028 }
|
|
1029 if (od->reqemail) {
|
|
1030 gaim_debug_info("oscar", "requesting e-mail address\n");
|
|
1031 aim_admin_getinfo(od, conn, 0x0011);
|
|
1032 od->reqemail = FALSE;
|
|
1033 }
|
|
1034 if (od->setemail) {
|
|
1035 gaim_debug_info("oscar", "setting e-mail address\n");
|
|
1036 aim_admin_setemail(od, conn, od->email);
|
|
1037 g_free(od->email);
|
|
1038 od->email = NULL;
|
|
1039 od->setemail = FALSE;
|
|
1040 }
|
|
1041 }
|
|
1042
|
|
1043 static void
|
|
1044 flap_connection_established_chat(OscarData *od, FlapConnection *conn)
|
|
1045 {
|
|
1046 GaimConnection *gc = od->gc;
|
|
1047 struct chat_connection *chatcon;
|
|
1048 static int id = 1;
|
|
1049
|
|
1050 aim_clientready(od, conn);
|
|
1051
|
|
1052 chatcon = find_oscar_chat_by_conn(gc, conn);
|
|
1053 chatcon->id = id;
|
|
1054 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show);
|
|
1055 }
|
|
1056
|
|
1057 static void
|
|
1058 flap_connection_established_chatnav(OscarData *od, FlapConnection *conn)
|
|
1059 {
|
|
1060 aim_clientready(od, conn);
|
|
1061 aim_chatnav_reqrights(od, conn);
|
|
1062 }
|
|
1063
|
|
1064 static void
|
|
1065 flap_connection_established_alert(OscarData *od, FlapConnection *conn)
|
|
1066 {
|
|
1067 aim_email_sendcookies(od);
|
|
1068 aim_email_activate(od);
|
|
1069 aim_clientready(od, conn);
|
|
1070 }
|
|
1071
|
|
1072 static void
|
|
1073 flap_connection_established_bart(OscarData *od, FlapConnection *conn)
|
|
1074 {
|
|
1075 GaimConnection *gc = od->gc;
|
|
1076
|
|
1077 aim_clientready(od, conn);
|
|
1078
|
|
1079 od->iconconnecting = FALSE;
|
|
1080
|
|
1081 if (od->icontimer == 0)
|
|
1082 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc);
|
|
1083 }
|
|
1084
|
|
1085 static int
|
|
1086 flap_connection_established(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
1087 {
|
|
1088 gaim_debug_info("oscar", "FLAP connection of type 0x%04hx is "
|
|
1089 "now fully connected\n", conn->type);
|
|
1090 if (conn->type == SNAC_FAMILY_LOCATE)
|
|
1091 flap_connection_established_bos(od, conn);
|
|
1092 else if (conn->type == SNAC_FAMILY_ADMIN)
|
|
1093 flap_connection_established_admin(od, conn);
|
|
1094 else if (conn->type == SNAC_FAMILY_CHAT)
|
|
1095 flap_connection_established_chat(od, conn);
|
|
1096 else if (conn->type == SNAC_FAMILY_CHATNAV)
|
|
1097 flap_connection_established_chatnav(od, conn);
|
|
1098 else if (conn->type == SNAC_FAMILY_ALERT)
|
|
1099 flap_connection_established_alert(od, conn);
|
|
1100 else if (conn->type == SNAC_FAMILY_BART)
|
|
1101 flap_connection_established_bart(od, conn);
|
|
1102
|
|
1103 return 1;
|
|
1104 }
|
|
1105
|
|
1106 static void
|
|
1107 oscar_login(GaimAccount *account)
|
|
1108 {
|
|
1109 GaimConnection *gc;
|
|
1110 OscarData *od;
|
|
1111 FlapConnection *newconn;
|
|
1112
|
|
1113 gc = gaim_account_get_connection(account);
|
|
1114 od = gc->proto_data = oscar_data_new();
|
|
1115 od->gc = gc;
|
|
1116
|
|
1117 oscar_data_addhandler(od, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0);
|
|
1118 oscar_data_addhandler(od, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, flap_connection_established, 0);
|
|
1119
|
|
1120 oscar_data_addhandler(od, SNAC_FAMILY_ADMIN, 0x0003, gaim_info_change, 0);
|
|
1121 oscar_data_addhandler(od, SNAC_FAMILY_ADMIN, 0x0005, gaim_info_change, 0);
|
|
1122 oscar_data_addhandler(od, SNAC_FAMILY_ADMIN, 0x0007, gaim_account_confirm, 0);
|
|
1123 oscar_data_addhandler(od, SNAC_FAMILY_ALERT, 0x0001, gaim_parse_genericerr, 0);
|
|
1124 oscar_data_addhandler(od, SNAC_FAMILY_ALERT, SNAC_SUBTYPE_ALERT_MAILSTATUS, gaim_email_parseupdate, 0);
|
|
1125 oscar_data_addhandler(od, SNAC_FAMILY_AUTH, 0x0003, gaim_parse_auth_resp, 0);
|
|
1126 oscar_data_addhandler(od, SNAC_FAMILY_AUTH, 0x0007, gaim_parse_login, 0);
|
|
1127 oscar_data_addhandler(od, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0);
|
|
1128 oscar_data_addhandler(od, SNAC_FAMILY_BART, SNAC_SUBTYPE_BART_ERROR, gaim_icon_error, 0);
|
|
1129 oscar_data_addhandler(od, SNAC_FAMILY_BART, SNAC_SUBTYPE_BART_RESPONSE, gaim_icon_parseicon, 0);
|
|
1130 oscar_data_addhandler(od, SNAC_FAMILY_BOS, 0x0001, gaim_parse_genericerr, 0);
|
|
1131 oscar_data_addhandler(od, SNAC_FAMILY_BOS, 0x0003, gaim_bosrights, 0);
|
|
1132 oscar_data_addhandler(od, SNAC_FAMILY_BUDDY, 0x0001, gaim_parse_genericerr, 0);
|
|
1133 oscar_data_addhandler(od, SNAC_FAMILY_BUDDY, SNAC_SUBTYPE_BUDDY_RIGHTSINFO, gaim_parse_buddyrights, 0);
|
|
1134 oscar_data_addhandler(od, SNAC_FAMILY_BUDDY, SNAC_SUBTYPE_BUDDY_ONCOMING, gaim_parse_oncoming, 0);
|
|
1135 oscar_data_addhandler(od, SNAC_FAMILY_BUDDY, SNAC_SUBTYPE_BUDDY_OFFGOING, gaim_parse_offgoing, 0);
|
|
1136 oscar_data_addhandler(od, SNAC_FAMILY_CHAT, 0x0001, gaim_parse_genericerr, 0);
|
|
1137 oscar_data_addhandler(od, SNAC_FAMILY_CHAT, SNAC_SUBTYPE_CHAT_USERJOIN, gaim_conv_chat_join, 0);
|
|
1138 oscar_data_addhandler(od, SNAC_FAMILY_CHAT, SNAC_SUBTYPE_CHAT_USERLEAVE, gaim_conv_chat_leave, 0);
|
|
1139 oscar_data_addhandler(od, SNAC_FAMILY_CHAT, SNAC_SUBTYPE_CHAT_ROOMINFOUPDATE, gaim_conv_chat_info_update, 0);
|
|
1140 oscar_data_addhandler(od, SNAC_FAMILY_CHAT, SNAC_SUBTYPE_CHAT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0);
|
|
1141 oscar_data_addhandler(od, SNAC_FAMILY_CHATNAV, 0x0001, gaim_parse_genericerr, 0);
|
|
1142 oscar_data_addhandler(od, SNAC_FAMILY_CHATNAV, SNAC_SUBTYPE_CHATNAV_INFO, gaim_chatnav_info, 0);
|
|
1143 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_ERROR, gaim_ssi_parseerr, 0);
|
|
1144 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RIGHTSINFO, gaim_ssi_parserights, 0);
|
|
1145 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_LIST, gaim_ssi_parselist, 0);
|
|
1146 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SRVACK, gaim_ssi_parseack, 0);
|
|
1147 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_ADD, gaim_ssi_parseadd, 0);
|
|
1148 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RECVAUTH, gaim_ssi_authgiven, 0);
|
|
1149 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RECVAUTHREQ, gaim_ssi_authrequest, 0);
|
|
1150 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RECVAUTHREP, gaim_ssi_authreply, 0);
|
|
1151 oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_ADDED, gaim_ssi_gotadded, 0);
|
|
1152 oscar_data_addhandler(od, SNAC_FAMILY_ICBM, 0x0005, gaim_icbm_param_info, 0);
|
|
1153 oscar_data_addhandler(od, SNAC_FAMILY_ICBM, SNAC_SUBTYPE_ICBM_INCOMING, gaim_parse_incoming_im, 0);
|
|
1154 oscar_data_addhandler(od, SNAC_FAMILY_ICBM, SNAC_SUBTYPE_ICBM_MISSEDCALL, gaim_parse_misses, 0);
|
|
1155 oscar_data_addhandler(od, SNAC_FAMILY_ICBM, SNAC_SUBTYPE_ICBM_CLIENTAUTORESP, gaim_parse_clientauto, 0);
|
|
1156 oscar_data_addhandler(od, SNAC_FAMILY_ICBM, SNAC_SUBTYPE_ICBM_ERROR, gaim_parse_msgerr, 0);
|
|
1157 oscar_data_addhandler(od, SNAC_FAMILY_ICBM, SNAC_SUBTYPE_ICBM_MTN, gaim_parse_mtn, 0);
|
|
1158 oscar_data_addhandler(od, SNAC_FAMILY_ICBM, SNAC_SUBTYPE_ICBM_ACK, gaim_parse_msgack, 0);
|
|
1159 oscar_data_addhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_OFFLINEMSG, gaim_offlinemsg, 0);
|
|
1160 oscar_data_addhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0);
|
|
1161 oscar_data_addhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_ALIAS, gaim_icqalias, 0);
|
|
1162 oscar_data_addhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_INFO, gaim_icqinfo, 0);
|
|
1163 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_RIGHTSINFO, gaim_parse_locaterights, 0);
|
|
1164 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_USERINFO, gaim_parse_userinfo, 0);
|
|
1165 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_ERROR, gaim_parse_locerr, 0);
|
|
1166 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_GOTINFOBLOCK, gaim_got_infoblock, 0);
|
|
1167 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0001, gaim_parse_genericerr, 0);
|
|
1168 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x000f, gaim_selfinfo, 0);
|
|
1169 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x001f, gaim_memrequest, 0);
|
|
1170 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0021, oscar_icon_req,0);
|
|
1171 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_RATECHANGE, gaim_parse_ratechange, 0);
|
|
1172 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_REDIRECT, gaim_handle_redirect, 0);
|
|
1173 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_MOTD, gaim_parse_motd, 0);
|
|
1174 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_EVIL, gaim_parse_evilnotify, 0);
|
|
1175 oscar_data_addhandler(od, SNAC_FAMILY_POPUP, 0x0002, gaim_popup, 0);
|
|
1176 oscar_data_addhandler(od, SNAC_FAMILY_USERLOOKUP, SNAC_SUBTYPE_USERLOOKUP_ERROR, gaim_parse_searcherror, 0);
|
|
1177 oscar_data_addhandler(od, SNAC_FAMILY_USERLOOKUP, 0x0003, gaim_parse_searchreply, 0);
|
|
1178
|
|
1179 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc);
|
|
1180
|
|
1181 if (!aim_snvalid(gaim_account_get_username(account))) {
|
|
1182 gchar *buf;
|
|
1183 buf = g_strdup_printf(_("Unable to login: Could not sign on as %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), gaim_account_get_username(account));
|
|
1184 gc->wants_to_die = TRUE;
|
|
1185 gaim_connection_error(gc, buf);
|
|
1186 g_free(buf);
|
|
1187 }
|
|
1188
|
|
1189 if (aim_sn_is_icq((gaim_account_get_username(account)))) {
|
|
1190 od->icq = TRUE;
|
|
1191 } else {
|
|
1192 gc->flags |= GAIM_CONNECTION_HTML;
|
|
1193 gc->flags |= GAIM_CONNECTION_AUTO_RESP;
|
|
1194 }
|
|
1195
|
|
1196 /* Connect to core Gaim signals */
|
|
1197 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc);
|
|
1198
|
|
1199 newconn = flap_connection_new(od, SNAC_FAMILY_AUTH);
|
14262
|
1200 newconn->connect_data = gaim_proxy_connect(account,
|
14192
|
1201 gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER),
|
|
1202 gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT),
|
|
1203 connection_established_cb, newconn);
|
14262
|
1204 if (newconn->connect_data == NULL)
|
14192
|
1205 {
|
|
1206 gaim_connection_error(gc, _("Couldn't connect to host"));
|
|
1207 return;
|
|
1208 }
|
|
1209
|
|
1210 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS);
|
|
1211 ck[0] = 0x5a;
|
|
1212 }
|
|
1213
|
|
1214 static void
|
|
1215 oscar_close(GaimConnection *gc)
|
|
1216 {
|
|
1217 OscarData *od;
|
|
1218
|
|
1219 od = (OscarData *)gc->proto_data;
|
|
1220
|
|
1221 while (od->oscar_chats)
|
|
1222 {
|
|
1223 struct chat_connection *cc = od->oscar_chats->data;
|
|
1224 od->oscar_chats = g_slist_remove(od->oscar_chats, cc);
|
|
1225 oscar_chat_destroy(cc);
|
|
1226 }
|
|
1227 while (od->create_rooms)
|
|
1228 {
|
|
1229 struct create_room *cr = od->create_rooms->data;
|
|
1230 g_free(cr->name);
|
|
1231 od->create_rooms = g_slist_remove(od->create_rooms, cr);
|
|
1232 g_free(cr);
|
|
1233 }
|
|
1234 oscar_data_destroy(od);
|
|
1235 gc->proto_data = NULL;
|
|
1236
|
|
1237 gaim_prefs_disconnect_by_handle(gc);
|
|
1238
|
|
1239 gaim_debug_info("oscar", "Signed off.\n");
|
|
1240 }
|
|
1241
|
|
1242 static int
|
|
1243 gaim_parse_auth_resp(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
1244 {
|
|
1245 GaimConnection *gc = od->gc;
|
|
1246 GaimAccount *account = gc->account;
|
|
1247 char *host; int port;
|
|
1248 int i;
|
|
1249 FlapConnection *newconn;
|
|
1250 va_list ap;
|
|
1251 struct aim_authresp_info *info;
|
|
1252
|
|
1253 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT);
|
|
1254
|
|
1255 va_start(ap, fr);
|
|
1256 info = va_arg(ap, struct aim_authresp_info *);
|
|
1257 va_end(ap);
|
|
1258
|
|
1259 gaim_debug_info("oscar",
|
|
1260 "inside auth_resp (Screen name: %s)\n", info->sn);
|
|
1261
|
|
1262 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) {
|
|
1263 char buf[256];
|
|
1264 switch (info->errorcode) {
|
|
1265 case 0x05:
|
|
1266 /* Incorrect nick/password */
|
|
1267 gc->wants_to_die = TRUE;
|
|
1268 gaim_connection_error(gc, _("Incorrect nickname or password."));
|
|
1269 break;
|
|
1270 case 0x11:
|
|
1271 /* Suspended account */
|
|
1272 gc->wants_to_die = TRUE;
|
|
1273 gaim_connection_error(gc, _("Your account is currently suspended."));
|
|
1274 break;
|
|
1275 case 0x14:
|
|
1276 /* service temporarily unavailable */
|
|
1277 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable."));
|
|
1278 break;
|
|
1279 case 0x18:
|
|
1280 /* connecting too frequently */
|
|
1281 gc->wants_to_die = TRUE;
|
|
1282 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."));
|
|
1283 break;
|
|
1284 case 0x1c:
|
|
1285 /* client too old */
|
|
1286 gc->wants_to_die = TRUE;
|
|
1287 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), GAIM_WEBSITE);
|
|
1288 gaim_connection_error(gc, buf);
|
|
1289 break;
|
|
1290 default:
|
|
1291 gaim_connection_error(gc, _("Authentication failed"));
|
|
1292 break;
|
|
1293 }
|
|
1294 gaim_debug_error("oscar", "Login Error Code 0x%04hx\n", info->errorcode);
|
|
1295 gaim_debug_error("oscar", "Error URL: %s\n", info->errorurl);
|
|
1296 od->killme = TRUE;
|
|
1297 return 1;
|
|
1298 }
|
|
1299
|
|
1300 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus);
|
|
1301 gaim_debug_misc("oscar", "E-mail: %s\n",
|
|
1302 (info->email != NULL) ? info->email : "null");
|
|
1303 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip);
|
|
1304 gaim_debug_info("oscar", "Closing auth connection...\n");
|
|
1305 flap_connection_schedule_destroy(conn, OSCAR_DISCONNECT_DONE);
|
|
1306
|
|
1307 for (i = 0; i < strlen(info->bosip); i++) {
|
|
1308 if (info->bosip[i] == ':') {
|
|
1309 port = atoi(&(info->bosip[i+1]));
|
|
1310 break;
|
|
1311 }
|
|
1312 }
|
|
1313 host = g_strndup(info->bosip, i);
|
|
1314 newconn = flap_connection_new(od, SNAC_FAMILY_LOCATE);
|
|
1315 newconn->cookielen = info->cookielen;
|
|
1316 newconn->cookie = g_memdup(info->cookie, info->cookielen);
|
14262
|
1317 newconn->connect_data = gaim_proxy_connect(account, host, port,
|
14192
|
1318 connection_established_cb, newconn);
|
|
1319 g_free(host);
|
14262
|
1320 if (newconn->connect_data == NULL)
|
14192
|
1321 {
|
|
1322 gaim_connection_error(gc, _("Could Not Connect"));
|
|
1323 od->killme = TRUE;
|
|
1324 return 0;
|
|
1325 }
|
|
1326
|
|
1327 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS);
|
|
1328 ck[3] = 0x64;
|
|
1329
|
|
1330 return 1;
|
|
1331 }
|
|
1332
|
|
1333 static void
|
|
1334 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg)
|
|
1335 {
|
|
1336 GaimConnection *gc = user_data;
|
|
1337 OscarData *od = gc->proto_data;
|
|
1338
|
|
1339 aim_auth_securid_send(od, msg);
|
|
1340 }
|
|
1341
|
|
1342 static void
|
|
1343 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value)
|
|
1344 {
|
|
1345 GaimConnection *gc = user_data;
|
|
1346 OscarData *od = gc->proto_data;
|
|
1347
|
|
1348 /* Disconnect */
|
|
1349 gc->wants_to_die = TRUE;
|
|
1350 gaim_connection_error(gc, _("The SecurID key entered is invalid."));
|
|
1351 od->killme = TRUE;
|
|
1352 }
|
|
1353
|
|
1354 static int
|
|
1355 gaim_parse_auth_securid_request(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
1356 {
|
|
1357 GaimConnection *gc = od->gc;
|
|
1358 GaimAccount *account = gaim_connection_get_account(gc);
|
|
1359 gchar *primary;
|
|
1360
|
|
1361 gaim_debug_info("oscar", "Got SecurID request\n");
|
|
1362
|
|
1363 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account));
|
|
1364 gaim_request_input(gc, NULL, _("Enter SecurID"), primary,
|
|
1365 _("Enter the 6 digit number from the digital display."),
|
|
1366 FALSE, FALSE, NULL,
|
|
1367 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb),
|
|
1368 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb),
|
|
1369 gc);
|
|
1370 g_free(primary);
|
|
1371
|
|
1372 return 1;
|
|
1373 }
|
|
1374
|
|
1375 /* XXX - Should use gaim_url_fetch for the below stuff */
|
|
1376 struct pieceofcrap {
|
|
1377 GaimConnection *gc;
|
|
1378 unsigned long offset;
|
|
1379 unsigned long len;
|
|
1380 char *modname;
|
|
1381 int fd;
|
|
1382 FlapConnection *conn;
|
|
1383 unsigned int inpa;
|
|
1384 };
|
|
1385
|
|
1386 static void damn_you(gpointer data, gint source, GaimInputCondition c)
|
|
1387 {
|
|
1388 struct pieceofcrap *pos = data;
|
|
1389 OscarData *od = pos->gc->proto_data;
|
|
1390 char in = '\0';
|
|
1391 int x = 0;
|
|
1392 unsigned char m[17];
|
|
1393
|
|
1394 while (read(pos->fd, &in, 1) == 1) {
|
|
1395 if (in == '\n')
|
|
1396 x++;
|
|
1397 else if (in != '\r')
|
|
1398 x = 0;
|
|
1399 if (x == 2)
|
|
1400 break;
|
|
1401 in = '\0';
|
|
1402 }
|
|
1403 if (in != '\n') {
|
|
1404 char buf[256];
|
|
1405 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until "
|
|
1406 "this is fixed. Check %s for updates."), GAIM_WEBSITE);
|
|
1407 gaim_notify_warning(pos->gc, NULL,
|
|
1408 _("Gaim was unable to get a valid AIM login hash."),
|
|
1409 buf);
|
|
1410 gaim_input_remove(pos->inpa);
|
|
1411 close(pos->fd);
|
|
1412 g_free(pos);
|
|
1413 return;
|
|
1414 }
|
|
1415 if (read(pos->fd, m, 16) != 16)
|
|
1416 {
|
|
1417 gaim_debug_warning("oscar", "Could not read full AIM login hash "
|
|
1418 "from " AIMHASHDATA "--that's bad.\n");
|
|
1419 }
|
|
1420 m[16] = '\0';
|
|
1421 gaim_debug_misc("oscar", "Sending hash: ");
|
|
1422 for (x = 0; x < 16; x++)
|
|
1423 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]);
|
|
1424
|
|
1425 gaim_debug_misc(NULL, "\n");
|
|
1426 gaim_input_remove(pos->inpa);
|
|
1427 close(pos->fd);
|
|
1428 aim_sendmemblock(od, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
|
|
1429 g_free(pos);
|
|
1430 }
|
|
1431
|
|
1432 static void
|
|
1433 straight_to_hell(gpointer data, gint source, const gchar *error_message)
|
|
1434 {
|
|
1435 struct pieceofcrap *pos = data;
|
|
1436 gchar *buf;
|
|
1437
|
|
1438 if (!GAIM_CONNECTION_IS_VALID(pos->gc))
|
|
1439 {
|
|
1440 g_free(pos->modname);
|
|
1441 g_free(pos);
|
|
1442 return;
|
|
1443 }
|
|
1444
|
|
1445 pos->fd = source;
|
|
1446
|
|
1447 if (source < 0) {
|
|
1448 buf = g_strdup_printf(_("You may be disconnected shortly. You may want to use TOC until "
|
|
1449 "this is fixed. Check %s for updates."), GAIM_WEBSITE);
|
|
1450 gaim_notify_warning(pos->gc, NULL,
|
|
1451 _("Gaim was unable to get a valid AIM login hash."),
|
|
1452 buf);
|
|
1453 g_free(buf);
|
|
1454 g_free(pos->modname);
|
|
1455 g_free(pos);
|
|
1456 return;
|
|
1457 }
|
|
1458
|
|
1459 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",
|
|
1460 pos->offset, pos->len, pos->modname ? pos->modname : "");
|
|
1461 write(pos->fd, buf, strlen(buf));
|
|
1462 g_free(buf);
|
|
1463 g_free(pos->modname);
|
|
1464 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
|
|
1465 return;
|
|
1466 }
|
|
1467
|
|
1468 /* size of icbmui.ocm, the largest module in AIM 3.5 */
|
|
1469 #define AIM_MAX_FILE_SIZE 98304
|
|
1470
|
|
1471 int gaim_memrequest(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
1472 va_list ap;
|
|
1473 struct pieceofcrap *pos;
|
|
1474 guint32 offset, len;
|
|
1475 char *modname;
|
|
1476
|
|
1477 va_start(ap, fr);
|
|
1478 offset = va_arg(ap, guint32);
|
|
1479 len = va_arg(ap, guint32);
|
|
1480 modname = va_arg(ap, char *);
|
|
1481 va_end(ap);
|
|
1482
|
|
1483 gaim_debug_misc("oscar", "offset: %u, len: %u, file: %s\n",
|
|
1484 offset, len, (modname ? modname : "aim.exe"));
|
|
1485
|
|
1486 if (len == 0) {
|
|
1487 gaim_debug_misc("oscar", "len is 0, hashing NULL\n");
|
|
1488 aim_sendmemblock(od, conn, offset, len, NULL,
|
|
1489 AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
|
|
1490 return 1;
|
|
1491 }
|
|
1492 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */
|
|
1493 #if 0
|
|
1494 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) {
|
|
1495 char *buf;
|
|
1496 int i = 8;
|
|
1497 if (modname)
|
|
1498 i += strlen(modname);
|
|
1499 buf = g_malloc(i);
|
|
1500 i = 0;
|
|
1501 if (modname) {
|
|
1502 memcpy(buf, modname, strlen(modname));
|
|
1503 i += strlen(modname);
|
|
1504 }
|
|
1505 buf[i++] = offset & 0xff;
|
|
1506 buf[i++] = (offset >> 8) & 0xff;
|
|
1507 buf[i++] = (offset >> 16) & 0xff;
|
|
1508 buf[i++] = (offset >> 24) & 0xff;
|
|
1509 buf[i++] = len & 0xff;
|
|
1510 buf[i++] = (len >> 8) & 0xff;
|
|
1511 buf[i++] = (len >> 16) & 0xff;
|
|
1512 buf[i++] = (len >> 24) & 0xff;
|
|
1513 gaim_debug_misc("oscar", "len + offset is invalid, "
|
|
1514 "hashing request\n");
|
|
1515 aim_sendmemblock(od, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
|
|
1516 g_free(buf);
|
|
1517 return 1;
|
|
1518 }
|
|
1519 #endif
|
|
1520
|
|
1521 pos = g_new0(struct pieceofcrap, 1);
|
|
1522 pos->gc = od->gc;
|
|
1523 pos->conn = conn;
|
|
1524
|
|
1525 pos->offset = offset;
|
|
1526 pos->len = len;
|
|
1527 pos->modname = g_strdup(modname);
|
|
1528
|
|
1529 /* TODO: Keep track of this return value. */
|
|
1530 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80,
|
|
1531 straight_to_hell, pos) == NULL)
|
|
1532 {
|
|
1533 char buf[256];
|
|
1534 if (pos->modname)
|
|
1535 g_free(pos->modname);
|
|
1536 g_free(pos);
|
|
1537 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. "
|
|
1538 "Check %s for updates."), GAIM_WEBSITE);
|
|
1539 gaim_notify_warning(pos->gc, NULL,
|
|
1540 _("Gaim was unable to get a valid login hash."),
|
|
1541 buf);
|
|
1542 }
|
|
1543
|
|
1544 return 1;
|
|
1545 }
|
|
1546
|
|
1547 static int
|
|
1548 gaim_parse_login(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
1549 {
|
|
1550 GaimConnection *gc;
|
|
1551 GaimAccount *account;
|
|
1552 ClientInfo info = CLIENTINFO_GAIM;
|
|
1553 va_list ap;
|
|
1554 char *key;
|
|
1555
|
|
1556 gc = od->gc;
|
|
1557 account = gaim_connection_get_account(gc);
|
|
1558
|
|
1559 va_start(ap, fr);
|
|
1560 key = va_arg(ap, char *);
|
|
1561 va_end(ap);
|
|
1562
|
|
1563 aim_send_login(od, conn, gaim_account_get_username(account),
|
|
1564 gaim_connection_get_password(gc), &info, key);
|
|
1565
|
|
1566 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS);
|
|
1567 ck[2] = 0x6c;
|
|
1568
|
|
1569 return 1;
|
|
1570 }
|
|
1571
|
|
1572 static int
|
|
1573 gaim_handle_redirect(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
1574 {
|
|
1575 GaimConnection *gc = od->gc;
|
|
1576 GaimAccount *account = gaim_connection_get_account(gc);
|
|
1577 char *host, *separator;
|
|
1578 int port;
|
|
1579 FlapConnection *newconn;
|
|
1580 va_list ap;
|
|
1581 struct aim_redirect_data *redir;
|
|
1582
|
|
1583 va_start(ap, fr);
|
|
1584 redir = va_arg(ap, struct aim_redirect_data *);
|
|
1585 va_end(ap);
|
|
1586
|
|
1587 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT);
|
|
1588 separator = strchr(redir->ip, ':');
|
|
1589 if (separator != NULL)
|
|
1590 {
|
|
1591 host = g_strndup(redir->ip, separator - redir->ip);
|
|
1592 port = atoi(separator + 1);
|
|
1593 }
|
|
1594 else
|
|
1595 host = g_strdup(redir->ip);
|
|
1596
|
|
1597 gaim_debug_info("oscar", "Connecting to FLAP server %s:%d of type 0x%04hx\n",
|
|
1598 host, port, redir->group);
|
|
1599 newconn = flap_connection_new(od, redir->group);
|
|
1600 newconn->cookielen = redir->cookielen;
|
|
1601 newconn->cookie = g_memdup(redir->cookie, redir->cookielen);
|
|
1602 if (newconn->type == SNAC_FAMILY_CHAT)
|
|
1603 {
|
|
1604 struct chat_connection *cc;
|
|
1605 cc = g_new0(struct chat_connection, 1);
|
|
1606 cc->conn = newconn;
|
|
1607 cc->gc = gc;
|
|
1608 cc->name = g_strdup(redir->chat.room);
|
|
1609 cc->exchange = redir->chat.exchange;
|
|
1610 cc->instance = redir->chat.instance;
|
|
1611 cc->show = extract_name(redir->chat.room);
|
14262
|
1612 newconn->new_conn_data = cc;
|
14192
|
1613 gaim_debug_info("oscar", "Connecting to chat room %s exchange %hu\n", cc->name, cc->exchange);
|
|
1614 }
|
|
1615
|
14262
|
1616 newconn->connect_data = gaim_proxy_connect(account, host, port,
|
14192
|
1617 connection_established_cb, newconn);
|
14262
|
1618 if (newconn->connect_data == NULL)
|
14192
|
1619 {
|
|
1620 flap_connection_schedule_destroy(newconn, OSCAR_DISCONNECT_COULD_NOT_CONNECT);
|
|
1621 gaim_debug_error("oscar", "Unable to connect to FLAP server "
|
|
1622 "of type 0x%04hx\n", redir->group);
|
|
1623 }
|
|
1624 g_free(host);
|
|
1625
|
|
1626 return 1;
|
|
1627 }
|
|
1628
|
|
1629 static int gaim_parse_oncoming(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
1630 {
|
|
1631 GaimConnection *gc;
|
|
1632 GaimAccount *account;
|
|
1633 GaimPresence *presence;
|
|
1634 struct buddyinfo *bi;
|
|
1635 time_t time_idle = 0, signon = 0;
|
|
1636 int type = 0;
|
|
1637 gboolean buddy_is_away = FALSE;
|
|
1638 const char *status_id;
|
|
1639 gboolean have_status_message = FALSE;
|
|
1640 char *message = NULL;
|
|
1641 va_list ap;
|
|
1642 aim_userinfo_t *info;
|
|
1643
|
|
1644 gc = od->gc;
|
|
1645 account = gaim_connection_get_account(gc);
|
|
1646 presence = gaim_account_get_presence(account);
|
|
1647
|
|
1648 va_start(ap, fr);
|
|
1649 info = va_arg(ap, aim_userinfo_t *);
|
|
1650 va_end(ap);
|
|
1651
|
|
1652 g_return_val_if_fail(info != NULL, 1);
|
|
1653 g_return_val_if_fail(info->sn != NULL, 1);
|
|
1654
|
|
1655 if (info->present & AIM_USERINFO_PRESENT_FLAGS) {
|
|
1656 if (info->flags & AIM_FLAG_AWAY)
|
|
1657 buddy_is_away = TRUE;
|
|
1658 }
|
|
1659 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) {
|
|
1660 type = info->icqinfo.status;
|
|
1661 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) &&
|
|
1662 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) {
|
|
1663 buddy_is_away = TRUE;
|
|
1664 }
|
|
1665 }
|
|
1666
|
|
1667 if (aim_sn_is_icq(info->sn)) {
|
|
1668 if (type & AIM_ICQ_STATE_CHAT)
|
|
1669 status_id = OSCAR_STATUS_ID_FREE4CHAT;
|
|
1670 else if (type & AIM_ICQ_STATE_DND)
|
|
1671 status_id = OSCAR_STATUS_ID_DND;
|
|
1672 else if (type & AIM_ICQ_STATE_OUT)
|
|
1673 status_id = OSCAR_STATUS_ID_NA;
|
|
1674 else if (type & AIM_ICQ_STATE_BUSY)
|
|
1675 status_id = OSCAR_STATUS_ID_OCCUPIED;
|
|
1676 else if (type & AIM_ICQ_STATE_AWAY)
|
|
1677 status_id = OSCAR_STATUS_ID_AWAY;
|
|
1678 else if (type & AIM_ICQ_STATE_INVISIBLE)
|
|
1679 status_id = OSCAR_STATUS_ID_INVISIBLE;
|
|
1680 else
|
|
1681 status_id = OSCAR_STATUS_ID_AVAILABLE;
|
|
1682 } else {
|
|
1683 if (buddy_is_away)
|
|
1684 status_id = OSCAR_STATUS_ID_AWAY;
|
|
1685 else
|
|
1686 status_id = OSCAR_STATUS_ID_AVAILABLE;
|
|
1687 }
|
|
1688
|
|
1689 /*
|
|
1690 * Handle the available message. If info->status is NULL then the user
|
|
1691 * may or may not have an available message, so don't do anything. If
|
|
1692 * info->status is set to the empty string, then the user's client DOES
|
|
1693 * support available messages and the user DOES NOT have one set.
|
|
1694 * Otherwise info->status contains the available message.
|
|
1695 */
|
|
1696 if (info->status != NULL)
|
|
1697 {
|
|
1698 have_status_message = TRUE;
|
|
1699 if (info->status[0] != '\0')
|
|
1700 message = oscar_encoding_to_utf8(info->status_encoding,
|
|
1701 info->status, info->status_len);
|
|
1702 }
|
|
1703
|
|
1704 if (have_status_message)
|
|
1705 {
|
|
1706 gaim_prpl_got_user_status(account, info->sn, status_id,
|
|
1707 "message", message, NULL);
|
|
1708 g_free(message);
|
|
1709 }
|
|
1710 else
|
|
1711 gaim_prpl_got_user_status(account, info->sn, status_id, NULL);
|
|
1712
|
|
1713 /* Login time stuff */
|
|
1714 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE)
|
|
1715 signon = info->onlinesince;
|
|
1716 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
|
|
1717 signon = time(NULL) - info->sessionlen;
|
|
1718 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) {
|
|
1719 gaim_connection_set_display_name(gc, info->sn);
|
|
1720 od->timeoffset = signon - gaim_presence_get_login_time(presence);
|
|
1721 }
|
|
1722 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset);
|
|
1723
|
|
1724 /* Idle time stuff */
|
|
1725 /* info->idletime is the number of minutes that this user has been idle */
|
|
1726 if (info->present & AIM_USERINFO_PRESENT_IDLE)
|
|
1727 time_idle = time(NULL) - info->idletime * 60;
|
|
1728
|
|
1729 if (time_idle > 0)
|
|
1730 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle);
|
|
1731 else
|
|
1732 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0);
|
|
1733
|
|
1734 /* Server stored icon stuff */
|
|
1735 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn));
|
|
1736 if (!bi) {
|
|
1737 bi = g_new0(struct buddyinfo, 1);
|
|
1738 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi);
|
|
1739 }
|
|
1740 bi->typingnot = FALSE;
|
|
1741 bi->ico_informed = FALSE;
|
|
1742 bi->ipaddr = info->icqinfo.ipaddr;
|
|
1743
|
|
1744 if (info->iconcsumlen) {
|
|
1745 const char *filename, *saved_b16 = NULL;
|
|
1746 char *b16 = NULL, *filepath = NULL;
|
|
1747 GaimBuddy *b = NULL;
|
|
1748
|
|
1749 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen);
|
|
1750 b = gaim_find_buddy(account, info->sn);
|
|
1751 /*
|
|
1752 * If for some reason the checksum is valid, but cached file is not..
|
|
1753 * we want to know.
|
|
1754 */
|
|
1755 if (b != NULL)
|
|
1756 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon");
|
|
1757 else
|
|
1758 filename = NULL;
|
|
1759 if (filename != NULL) {
|
|
1760 if (g_file_test(filename, G_FILE_TEST_EXISTS))
|
|
1761 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b,
|
|
1762 "icon_checksum");
|
|
1763 else {
|
|
1764 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(),
|
|
1765 filename, NULL);
|
|
1766 if (g_file_test(filepath, G_FILE_TEST_EXISTS))
|
|
1767 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b,
|
|
1768 "icon_checksum");
|
|
1769 g_free(filepath);
|
|
1770 }
|
|
1771 } else
|
|
1772 saved_b16 = NULL;
|
|
1773
|
|
1774 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) {
|
|
1775 GSList *cur = od->requesticon;
|
|
1776 while (cur && aim_sncmp((char *)cur->data, info->sn))
|
|
1777 cur = cur->next;
|
|
1778 if (!cur) {
|
|
1779 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn)));
|
|
1780 if (od->icontimer == 0)
|
|
1781 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc);
|
|
1782 }
|
|
1783 }
|
|
1784 g_free(b16);
|
|
1785 }
|
|
1786
|
|
1787 return 1;
|
|
1788 }
|
|
1789
|
|
1790 static void gaim_check_comment(OscarData *od, const char *str) {
|
|
1791 if ((str == NULL) || strcmp(str, (const char *)ck))
|
|
1792 aim_locate_setcaps(od, caps_aim);
|
|
1793 else
|
|
1794 aim_locate_setcaps(od, caps_aim | OSCAR_CAPABILITY_SECUREIM);
|
|
1795 }
|
|
1796
|
|
1797 static int gaim_parse_offgoing(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
1798 GaimConnection *gc = od->gc;
|
|
1799 GaimAccount *account = gaim_connection_get_account(gc);
|
|
1800 va_list ap;
|
|
1801 aim_userinfo_t *info;
|
|
1802
|
|
1803 va_start(ap, fr);
|
|
1804 info = va_arg(ap, aim_userinfo_t *);
|
|
1805 va_end(ap);
|
|
1806
|
|
1807 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL);
|
|
1808
|
|
1809 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn));
|
|
1810
|
|
1811 return 1;
|
|
1812 }
|
|
1813
|
|
1814 static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) {
|
|
1815 GaimConnection *gc = od->gc;
|
|
1816 GaimAccount *account = gaim_connection_get_account(gc);
|
|
1817 GaimMessageFlags flags = 0;
|
|
1818 struct buddyinfo *bi;
|
|
1819 char *iconfile;
|
|
1820 GString *message;
|
|
1821 gchar *tmp;
|
|
1822 aim_mpmsg_section_t *curpart;
|
|
1823 const char *start, *end;
|
|
1824 GData *attribs;
|
|
1825
|
|
1826 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n",
|
|
1827 userinfo->sn, args->mpmsg.numparts);
|
|
1828
|
|
1829 if (args->mpmsg.numparts == 0)
|
|
1830 return 1;
|
|
1831
|
|
1832 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn));
|
|
1833 if (!bi) {
|
|
1834 bi = g_new0(struct buddyinfo, 1);
|
|
1835 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi);
|
|
1836 }
|
|
1837
|
|
1838 if (args->icbmflags & AIM_IMFLAGS_AWAY)
|
|
1839 flags |= GAIM_MESSAGE_AUTO_RESP;
|
|
1840
|
|
1841 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT)
|
|
1842 bi->typingnot = TRUE;
|
|
1843 else
|
|
1844 bi->typingnot = FALSE;
|
|
1845
|
|
1846 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) {
|
|
1847 gaim_debug_misc("oscar", "%s has an icon\n", userinfo->sn);
|
|
1848 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) {
|
|
1849 bi->ico_need = TRUE;
|
|
1850 bi->ico_len = args->iconlen;
|
|
1851 bi->ico_csum = args->iconsum;
|
|
1852 bi->ico_time = args->iconstamp;
|
|
1853 }
|
|
1854 }
|
|
1855
|
|
1856 iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account));
|
|
1857 if ((iconfile != NULL) &&
|
|
1858 (args->icbmflags & AIM_IMFLAGS_BUDDYREQ) && !bi->ico_sent && bi->ico_informed) {
|
|
1859 FILE *file;
|
|
1860 struct stat st;
|
|
1861
|
|
1862 if (!g_stat(iconfile, &st)) {
|
|
1863 guchar *buf = g_malloc(st.st_size);
|
|
1864 file = g_fopen(iconfile, "rb");
|
|
1865 if (file) {
|
|
1866 /* XXX - Use g_file_get_contents() */
|
|
1867 /* g_file_get_contents(iconfile, &data, &len, NULL); */
|
|
1868 int len = fread(buf, 1, st.st_size, file);
|
|
1869 gaim_debug_info("oscar",
|
|
1870 "Sending buddy icon to %s (%d bytes, "
|
|
1871 "%lu reported)\n",
|
|
1872 userinfo->sn, len, st.st_size);
|
|
1873 aim_im_sendch2_icon(od, userinfo->sn, buf, st.st_size,
|
|
1874 st.st_mtime, aimutil_iconsum(buf, st.st_size));
|
|
1875 fclose(file);
|
|
1876 } else
|
|
1877 gaim_debug_error("oscar", "Can't open buddy icon file!\n");
|
|
1878 g_free(buf);
|
|
1879 } else
|
|
1880 gaim_debug_error("oscar", "Can't stat buddy icon file!\n");
|
|
1881 }
|
|
1882 g_free(iconfile);
|
|
1883
|
|
1884 message = g_string_new("");
|
|
1885 curpart = args->mpmsg.parts;
|
|
1886 while (curpart != NULL) {
|
|
1887 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset,
|
|
1888 curpart->charsubset, curpart->data, curpart->datalen);
|
|
1889 if (tmp != NULL) {
|
|
1890 g_string_append(message, tmp);
|
|
1891 g_free(tmp);
|
|
1892 }
|
|
1893
|
|
1894 curpart = curpart->next;
|
|
1895 }
|
|
1896 tmp = g_string_free(message, FALSE);
|
|
1897
|
|
1898 /*
|
|
1899 * If the message is from an ICQ user and to an ICQ user then escape any HTML,
|
|
1900 * because HTML is not sent over ICQ as a means to format a message.
|
|
1901 * So any HTML we receive is intended to be displayed. Also, \r\n must be
|
|
1902 * replaced with <br>
|
|
1903 *
|
|
1904 * Note: There *may* be some clients which send messages as HTML formatted -
|
|
1905 * they need to be special-cased somehow.
|
|
1906 */
|
|
1907 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) {
|
|
1908 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */
|
|
1909 gchar *tmp2 = g_markup_escape_text(tmp, -1);
|
|
1910 g_free(tmp);
|
|
1911 tmp = tmp2;
|
|
1912 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>");
|
|
1913 g_free(tmp);
|
|
1914 tmp = tmp2;
|
|
1915 }
|
|
1916
|
|
1917 /*
|
|
1918 * Convert iChat color tags to normal font tags.
|
|
1919 */
|
|
1920 if (gaim_markup_find_tag("body", tmp, &start, &end, &attribs))
|
|
1921 {
|
|
1922 const char *ichattextcolor, *ichatballooncolor;
|
|
1923
|
|
1924 ichattextcolor = g_datalist_get_data(&attribs, "ichattextcolor");
|
|
1925 if (ichattextcolor != NULL)
|
|
1926 {
|
|
1927 gchar *tmp2;
|
|
1928 tmp2 = g_strdup_printf("<font color=\"%s\">%s</font>", ichattextcolor, tmp);
|
|
1929 g_free(tmp);
|
|
1930 tmp = tmp2;
|
|
1931 }
|
|
1932
|
|
1933 ichatballooncolor = g_datalist_get_data(&attribs, "ichatballooncolor");
|
|
1934 if (ichatballooncolor != NULL)
|
|
1935 {
|
|
1936 gchar *tmp2;
|
|
1937 tmp2 = g_strdup_printf("<font back=\"%s\">%s</font>", ichatballooncolor, tmp);
|
|
1938 g_free(tmp);
|
|
1939 tmp = tmp2;
|
|
1940 }
|
|
1941
|
|
1942 g_datalist_clear(&attribs);
|
|
1943 }
|
|
1944
|
|
1945 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL));
|
|
1946 g_free(tmp);
|
|
1947
|
|
1948 return 1;
|
|
1949 }
|
|
1950
|
|
1951 static int
|
|
1952 incomingim_chan2(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo, IcbmArgsCh2 *args)
|
|
1953 {
|
|
1954 GaimConnection *gc;
|
|
1955 GaimAccount *account;
|
|
1956 char *message = NULL;
|
|
1957
|
|
1958 g_return_val_if_fail(od != NULL, 0);
|
|
1959 g_return_val_if_fail(od->gc != NULL, 0);
|
|
1960
|
|
1961 gc = od->gc;
|
|
1962 account = gaim_connection_get_account(gc);
|
|
1963 od = gc->proto_data;
|
|
1964
|
|
1965 if (args == NULL)
|
|
1966 return 0;
|
|
1967
|
|
1968 gaim_debug_misc("oscar", "Incoming rendezvous message of type %u, "
|
|
1969 "user %s, status %hu\n", args->type, userinfo->sn, args->status);
|
|
1970
|
|
1971 if (args->msg != NULL)
|
|
1972 {
|
|
1973 if (args->encoding != NULL)
|
|
1974 {
|
|
1975 char *encoding = NULL;
|
|
1976 encoding = oscar_encoding_extract(args->encoding);
|
|
1977 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen);
|
|
1978 g_free(encoding);
|
|
1979 } else {
|
|
1980 if (g_utf8_validate(args->msg, args->msglen, NULL))
|
|
1981 message = g_strdup(args->msg);
|
|
1982 }
|
|
1983 }
|
|
1984
|
|
1985 if (args->type & OSCAR_CAPABILITY_CHAT)
|
|
1986 {
|
|
1987 char *name;
|
|
1988 GHashTable *components;
|
|
1989
|
|
1990 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) {
|
|
1991 g_free(message);
|
|
1992 return 1;
|
|
1993 }
|
|
1994 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
|
|
1995 g_free);
|
|
1996 name = extract_name(args->info.chat.roominfo.name);
|
|
1997 g_hash_table_replace(components, g_strdup("room"),
|
|
1998 g_strdup(name ? name : args->info.chat.roominfo.name));
|
|
1999 g_hash_table_replace(components, g_strdup("exchange"),
|
|
2000 g_strdup_printf("%d", args->info.chat.roominfo.exchange));
|
|
2001 serv_got_chat_invite(gc,
|
|
2002 name ? name : args->info.chat.roominfo.name,
|
|
2003 userinfo->sn,
|
|
2004 message,
|
|
2005 components);
|
|
2006 if (name)
|
|
2007 g_free(name);
|
|
2008 }
|
|
2009
|
|
2010 else if ((args->type & OSCAR_CAPABILITY_SENDFILE) ||
|
|
2011 (args->type & OSCAR_CAPABILITY_DIRECTIM))
|
|
2012 {
|
|
2013 if (args->status == AIM_RENDEZVOUS_PROPOSE)
|
|
2014 {
|
|
2015 peer_connection_got_proposition(od, userinfo->sn, message, args);
|
|
2016 }
|
|
2017 else if (args->status == AIM_RENDEZVOUS_CANCEL)
|
|
2018 {
|
|
2019 /* The other user canceled a peer request */
|
|
2020 PeerConnection *conn;
|
|
2021
|
|
2022 conn = peer_connection_find_by_cookie(od, userinfo->sn, args->cookie);
|
|
2023 /*
|
|
2024 * If conn is NULL it means we haven't tried to create
|
|
2025 * a connection with that user. They may be trying to
|
|
2026 * do something malicious.
|
|
2027 */
|
|
2028 if (conn != NULL)
|
|
2029 {
|
|
2030 peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED);
|
|
2031 }
|
|
2032 }
|
|
2033 else if (args->status == AIM_RENDEZVOUS_CONNECTED)
|
|
2034 {
|
|
2035 /* Remote user has accepted our peer request */
|
|
2036 PeerConnection *conn;
|
|
2037
|
|
2038 conn = peer_connection_find_by_cookie(od, userinfo->sn, args->cookie);
|
|
2039 /*
|
|
2040 * If conn is NULL it means we haven't tried to create
|
|
2041 * a connection with that user. They may be trying to
|
|
2042 * do something malicious.
|
|
2043 */
|
|
2044 if (conn != NULL)
|
|
2045 {
|
|
2046 if (conn->listenerfd != -1)
|
|
2047 {
|
|
2048 /*
|
|
2049 * If they are connecting directly to us then
|
|
2050 * continue the peer negotiation by
|
|
2051 * accepting connections on our listener port.
|
|
2052 */
|
|
2053 conn->watcher_incoming = gaim_input_add(conn->listenerfd,
|
|
2054 GAIM_INPUT_READ, peer_connection_listen_cb, conn);
|
|
2055 }
|
|
2056 }
|
|
2057 }
|
|
2058 }
|
|
2059
|
|
2060 else if (args->type & OSCAR_CAPABILITY_GETFILE)
|
|
2061 {
|
|
2062 }
|
|
2063
|
|
2064 else if (args->type & OSCAR_CAPABILITY_TALK)
|
|
2065 {
|
|
2066 }
|
|
2067
|
|
2068 else if (args->type & OSCAR_CAPABILITY_BUDDYICON)
|
|
2069 {
|
|
2070 gaim_buddy_icons_set_for_user(account, userinfo->sn,
|
|
2071 args->info.icon.icon,
|
|
2072 args->info.icon.length);
|
|
2073 }
|
|
2074
|
|
2075 else if (args->type & OSCAR_CAPABILITY_ICQSERVERRELAY)
|
|
2076 {
|
|
2077 gaim_debug_error("oscar", "Got an ICQ Server Relay message of "
|
|
2078 "type %d\n", args->info.rtfmsg.msgtype);
|
|
2079 }
|
|
2080
|
|
2081 else
|
|
2082 {
|
|
2083 gaim_debug_error("oscar", "Unknown request class %hu\n",
|
|
2084 args->type);
|
|
2085 }
|
|
2086
|
|
2087 g_free(message);
|
|
2088
|
|
2089 return 1;
|
|
2090 }
|
|
2091
|
|
2092 /*
|
|
2093 * Authorization Functions
|
|
2094 * Most of these are callbacks from dialogs. They're used by both
|
|
2095 * methods of authorization (SSI and old-school channel 4 ICBM)
|
|
2096 */
|
|
2097 /* When you ask other people for authorization */
|
|
2098 static void
|
|
2099 gaim_auth_request(struct name_data *data, char *msg)
|
|
2100 {
|
|
2101 GaimConnection *gc;
|
|
2102 OscarData *od;
|
|
2103 GaimBuddy *buddy;
|
|
2104 GaimGroup *group;
|
|
2105
|
|
2106 gc = data->gc;
|
|
2107 od = gc->proto_data;
|
|
2108 buddy = gaim_find_buddy(gaim_connection_get_account(gc), data->name);
|
|
2109 if (buddy != NULL)
|
|
2110 group = gaim_buddy_get_group(buddy);
|
|
2111 else
|
|
2112 group = NULL;
|
|
2113
|
|
2114 if (group != NULL)
|
|
2115 {
|
|
2116 gaim_debug_info("oscar", "ssi: adding buddy %s to group %s\n",
|
|
2117 buddy->name, group->name);
|
|
2118 aim_ssi_sendauthrequest(od, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list."));
|
|
2119 if (!aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))
|
|
2120 aim_ssi_addbuddy(od, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1);
|
|
2121 }
|
|
2122 }
|
|
2123
|
|
2124 static void
|
|
2125 gaim_auth_request_msgprompt(struct name_data *data)
|
|
2126 {
|
|
2127 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"),
|
|
2128 NULL, _("Please authorize me!"), TRUE, FALSE, NULL,
|
|
2129 _("OK"), G_CALLBACK(gaim_auth_request),
|
|
2130 _("Cancel"), G_CALLBACK(oscar_free_name_data),
|
|
2131 data);
|
|
2132 }
|
|
2133
|
|
2134 static void
|
|
2135 gaim_auth_dontrequest(struct name_data *data)
|
|
2136 {
|
|
2137 GaimConnection *gc = data->gc;
|
|
2138 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name);
|
|
2139
|
|
2140 /* Remove from local list */
|
|
2141 gaim_blist_remove_buddy(b);
|
|
2142
|
|
2143 oscar_free_name_data(data);
|
|
2144 }
|
|
2145
|
|
2146
|
|
2147 static void
|
|
2148 gaim_auth_sendrequest(GaimConnection *gc, char *name)
|
|
2149 {
|
|
2150 struct name_data *data = g_new0(struct name_data, 1);
|
|
2151 GaimBuddy *buddy;
|
|
2152 gchar *dialog_msg, *nombre;
|
|
2153
|
|
2154 buddy = gaim_find_buddy(gc->account, name);
|
|
2155 if (buddy && (gaim_buddy_get_alias_only(buddy)))
|
|
2156 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy));
|
|
2157 else
|
|
2158 nombre = NULL;
|
|
2159
|
|
2160 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));
|
|
2161 data->gc = gc;
|
|
2162 data->name = g_strdup(name);
|
|
2163 data->nick = NULL;
|
|
2164
|
|
2165 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg,
|
|
2166 0, data, 2,
|
|
2167 _("_Request Authorization"),
|
|
2168 G_CALLBACK(gaim_auth_request_msgprompt),
|
|
2169 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest));
|
|
2170
|
|
2171 g_free(dialog_msg);
|
|
2172 g_free(nombre);
|
|
2173 }
|
|
2174
|
|
2175
|
|
2176 static void
|
|
2177 gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored)
|
|
2178 {
|
|
2179 GaimBuddy *buddy;
|
|
2180 GaimConnection *gc;
|
|
2181
|
|
2182 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
2183
|
|
2184 buddy = (GaimBuddy *) node;
|
|
2185 gc = gaim_account_get_connection(buddy->account);
|
|
2186 gaim_auth_sendrequest(gc, buddy->name);
|
|
2187 }
|
|
2188
|
|
2189 /* When other people ask you for authorization */
|
|
2190 static void
|
|
2191 gaim_auth_grant(struct name_data *data)
|
|
2192 {
|
|
2193 GaimConnection *gc = data->gc;
|
|
2194 OscarData *od = gc->proto_data;
|
|
2195
|
|
2196 aim_ssi_sendauthreply(od, data->name, 0x01, NULL);
|
|
2197
|
|
2198 oscar_free_name_data(data);
|
|
2199 }
|
|
2200
|
|
2201 /* When other people ask you for authorization */
|
|
2202 static void
|
|
2203 gaim_auth_dontgrant(struct name_data *data, char *msg)
|
|
2204 {
|
|
2205 GaimConnection *gc = data->gc;
|
|
2206 OscarData *od = gc->proto_data;
|
|
2207
|
|
2208 aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given."));
|
|
2209 }
|
|
2210
|
|
2211 static void
|
|
2212 gaim_auth_dontgrant_msgprompt(struct name_data *data)
|
|
2213 {
|
|
2214 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"),
|
|
2215 NULL, _("No reason given."), TRUE, FALSE, NULL,
|
|
2216 _("OK"), G_CALLBACK(gaim_auth_dontgrant),
|
|
2217 _("Cancel"), G_CALLBACK(oscar_free_name_data),
|
|
2218 data);
|
|
2219 }
|
|
2220
|
|
2221 /* When someone sends you buddies */
|
|
2222 static void
|
|
2223 gaim_icq_buddyadd(struct name_data *data)
|
|
2224 {
|
|
2225 GaimConnection *gc = data->gc;
|
|
2226
|
|
2227 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick);
|
|
2228
|
|
2229 oscar_free_name_data(data);
|
|
2230 }
|
|
2231
|
|
2232 static int
|
|
2233 incomingim_chan4(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t)
|
|
2234 {
|
|
2235 GaimConnection *gc = od->gc;
|
|
2236 GaimAccount *account = gaim_connection_get_account(gc);
|
|
2237 gchar **msg1, **msg2;
|
|
2238 int i, numtoks;
|
|
2239
|
|
2240 if (!args->type || !args->msg || !args->uin)
|
|
2241 return 1;
|
|
2242
|
|
2243 gaim_debug_info("oscar",
|
|
2244 "Received a channel 4 message of type 0x%02hx.\n",
|
|
2245 args->type);
|
|
2246
|
|
2247 /*
|
|
2248 * Split up the message at the delimeter character, then convert each
|
|
2249 * string to UTF-8. Unless, of course, this is a type 1 message. If
|
|
2250 * this is a type 1 message, then the delimiter 0xfe could be a valid
|
|
2251 * character in whatever encoding the message was sent in. Type 1
|
|
2252 * messages are always made up of only one part, so we can easily account
|
|
2253 * for this suck-ass part of the protocol by splitting the string into at
|
|
2254 * most 1 baby string.
|
|
2255 */
|
|
2256 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0));
|
|
2257 for (numtoks=0; msg1[numtoks]; numtoks++);
|
|
2258 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *));
|
|
2259 for (i=0; msg1[i]; i++) {
|
|
2260 gaim_str_strip_char(msg1[i], '\r');
|
|
2261 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i]));
|
|
2262 }
|
|
2263 msg2[i] = NULL;
|
|
2264
|
|
2265 switch (args->type) {
|
|
2266 case 0x01: { /* MacICQ message or basic offline message */
|
|
2267 if (i >= 1) {
|
|
2268 gchar *uin = g_strdup_printf("%u", args->uin);
|
|
2269 gchar *tmp;
|
|
2270
|
|
2271 /* If the message came from an ICQ user then escape any HTML */
|
|
2272 tmp = g_markup_escape_text(msg2[0], -1);
|
|
2273
|
|
2274 if (t) { /* This is an offline message */
|
|
2275 /* The timestamp is UTC-ish, so we need to get the offset */
|
|
2276 #ifdef HAVE_TM_GMTOFF
|
|
2277 time_t now;
|
|
2278 struct tm *tm;
|
|
2279 now = time(NULL);
|
|
2280 tm = localtime(&now);
|
|
2281 t += tm->tm_gmtoff;
|
|
2282 #else
|
|
2283 # ifdef HAVE_TIMEZONE
|
|
2284 tzset();
|
|
2285 t -= timezone;
|
|
2286 # endif
|
|
2287 #endif
|
|
2288 serv_got_im(gc, uin, tmp, 0, t);
|
|
2289 } else { /* This is a message from MacICQ/Miranda */
|
|
2290 serv_got_im(gc, uin, tmp, 0, time(NULL));
|
|
2291 }
|
|
2292 g_free(uin);
|
|
2293 g_free(tmp);
|
|
2294 }
|
|
2295 } break;
|
|
2296
|
|
2297 case 0x04: { /* Someone sent you a URL */
|
|
2298 if (i >= 2) {
|
|
2299 if (msg2[1] != NULL) {
|
|
2300 gchar *uin = g_strdup_printf("%u", args->uin);
|
|
2301 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>",
|
|
2302 msg2[1],
|
|
2303 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]);
|
|
2304 serv_got_im(gc, uin, message, 0, time(NULL));
|
|
2305 g_free(uin);
|
|
2306 g_free(message);
|
|
2307 }
|
|
2308 }
|
|
2309 } break;
|
|
2310
|
|
2311 case 0x06: { /* Someone requested authorization */
|
|
2312 if (i >= 6) {
|
|
2313 struct name_data *data = g_new(struct name_data, 1);
|
|
2314 gchar *sn = g_strdup_printf("%u", args->uin);
|
|
2315 gchar *reason;
|
|
2316 gchar *dialog_msg;
|
|
2317
|
|
2318 if (msg2[5] != NULL)
|
|
2319 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5]));
|
|
2320 else
|
|
2321 reason = g_strdup(_("No reason given."));
|
|
2322
|
|
2323 dialog_msg = g_strdup_printf(_("The user %u wants to add %s to their buddy list for the following reason:\n%s"),
|
|
2324 args->uin, gaim_account_get_username(gc->account), reason);
|
|
2325 g_free(reason);
|
|
2326 gaim_debug_info("oscar",
|
|
2327 "Received an authorization request from UIN %u\n",
|
|
2328 args->uin);
|
|
2329 data->gc = gc;
|
|
2330 data->name = sn;
|
|
2331 data->nick = NULL;
|
|
2332
|
|
2333 gaim_request_action(gc, NULL, _("Authorization Request"),
|
|
2334 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data,
|
|
2335 2, _("_Authorize"),
|
|
2336 G_CALLBACK(gaim_auth_grant),
|
|
2337 _("_Deny"),
|
|
2338 G_CALLBACK(gaim_auth_dontgrant_msgprompt));
|
|
2339 g_free(dialog_msg);
|
|
2340 }
|
|
2341 } break;
|
|
2342
|
|
2343 case 0x07: { /* Someone has denied you authorization */
|
|
2344 if (i >= 1) {
|
|
2345 gchar *dialog_msg = g_strdup_printf(_("The user %u has denied your request to add them to your buddy list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given."));
|
|
2346 gaim_notify_info(gc, NULL, _("ICQ authorization denied."),
|
|
2347 dialog_msg);
|
|
2348 g_free(dialog_msg);
|
|
2349 }
|
|
2350 } break;
|
|
2351
|
|
2352 case 0x08: { /* Someone has granted you authorization */
|
|
2353 gchar *dialog_msg = g_strdup_printf(_("The user %u has granted your request to add them to your buddy list."), args->uin);
|
|
2354 gaim_notify_info(gc, NULL, "ICQ authorization accepted.",
|
|
2355 dialog_msg);
|
|
2356 g_free(dialog_msg);
|
|
2357 } break;
|
|
2358
|
|
2359 case 0x09: { /* Message from the Godly ICQ server itself, I think */
|
|
2360 if (i >= 5) {
|
|
2361 gchar *dialog_msg = g_strdup_printf(_("You have received a special message\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]);
|
|
2362 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg);
|
|
2363 g_free(dialog_msg);
|
|
2364 }
|
|
2365 } break;
|
|
2366
|
|
2367 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */
|
|
2368 if (i >= 6) {
|
|
2369 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]);
|
|
2370 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg);
|
|
2371 g_free(dialog_msg);
|
|
2372 }
|
|
2373 } break;
|
|
2374
|
|
2375 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */
|
|
2376 if (i >= 6) {
|
|
2377 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ e-mail from %s [%s]\n\nMessage is:\n%s"), msg2[0], msg2[3], msg2[5]);
|
|
2378 gaim_notify_info(gc, NULL, "ICQ E-Mail", dialog_msg);
|
|
2379 g_free(dialog_msg);
|
|
2380 }
|
|
2381 } break;
|
|
2382
|
|
2383 case 0x12: {
|
|
2384 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
|
|
2385 /* Someone added you to their buddy list? */
|
|
2386 } break;
|
|
2387
|
|
2388 case 0x13: { /* Someone has sent you some ICQ buddies */
|
|
2389 guint i, num;
|
|
2390 gchar **text;
|
|
2391 text = g_strsplit(args->msg, "\376", 0);
|
|
2392 if (text) {
|
|
2393 num = 0;
|
|
2394 for (i=0; i<strlen(text[0]); i++)
|
|
2395 num = num*10 + text[0][i]-48;
|
|
2396 for (i=0; i<num; i++) {
|
|
2397 struct name_data *data = g_new(struct name_data, 1);
|
|
2398 gchar *message = g_strdup_printf(_("ICQ user %u has sent you a buddy: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]);
|
|
2399 data->gc = gc;
|
|
2400 data->name = g_strdup(text[i*2+1]);
|
|
2401 data->nick = g_strdup(text[i*2+2]);
|
|
2402
|
|
2403 gaim_request_action(gc, NULL, message,
|
|
2404 _("Do you want to add this buddy "
|
|
2405 "to your buddy list?"),
|
|
2406 GAIM_DEFAULT_ACTION_NONE, data, 2,
|
|
2407 _("Add"), G_CALLBACK(gaim_icq_buddyadd),
|
|
2408 _("_Decline"), G_CALLBACK(oscar_free_name_data));
|
|
2409 g_free(message);
|
|
2410 }
|
|
2411 g_strfreev(text);
|
|
2412 }
|
|
2413 } break;
|
|
2414
|
|
2415 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */
|
|
2416 /* This is boring and silly. */
|
|
2417 } break;
|
|
2418
|
|
2419 default: {
|
|
2420 gaim_debug_info("oscar",
|
|
2421 "Received a channel 4 message of unknown type "
|
|
2422 "(type 0x%02hhx).\n", args->type);
|
|
2423 } break;
|
|
2424 }
|
|
2425
|
|
2426 g_strfreev(msg1);
|
|
2427 g_strfreev(msg2);
|
|
2428
|
|
2429 return 1;
|
|
2430 }
|
|
2431
|
|
2432 static int gaim_parse_incoming_im(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2433 guint16 channel;
|
|
2434 int ret = 0;
|
|
2435 aim_userinfo_t *userinfo;
|
|
2436 va_list ap;
|
|
2437
|
|
2438 va_start(ap, fr);
|
|
2439 channel = (guint16)va_arg(ap, unsigned int);
|
|
2440 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
2441
|
|
2442 switch (channel) {
|
|
2443 case 1: { /* standard message */
|
|
2444 struct aim_incomingim_ch1_args *args;
|
|
2445 args = va_arg(ap, struct aim_incomingim_ch1_args *);
|
|
2446 ret = incomingim_chan1(od, conn, userinfo, args);
|
|
2447 } break;
|
|
2448
|
|
2449 case 2: { /* rendezvous */
|
|
2450 IcbmArgsCh2 *args;
|
|
2451 args = va_arg(ap, IcbmArgsCh2 *);
|
|
2452 ret = incomingim_chan2(od, conn, userinfo, args);
|
|
2453 } break;
|
|
2454
|
|
2455 case 4: { /* ICQ */
|
|
2456 struct aim_incomingim_ch4_args *args;
|
|
2457 args = va_arg(ap, struct aim_incomingim_ch4_args *);
|
|
2458 ret = incomingim_chan4(od, conn, userinfo, args, 0);
|
|
2459 } break;
|
|
2460
|
|
2461 default: {
|
|
2462 gaim_debug_warning("oscar",
|
|
2463 "ICBM received on unsupported channel (channel "
|
|
2464 "0x%04hx).", channel);
|
|
2465 } break;
|
|
2466 }
|
|
2467
|
|
2468 va_end(ap);
|
|
2469
|
|
2470 return ret;
|
|
2471 }
|
|
2472
|
|
2473 static int gaim_parse_misses(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2474 GaimConnection *gc = od->gc;
|
|
2475 GaimAccount *account = gaim_connection_get_account(gc);
|
|
2476 char *buf;
|
|
2477 va_list ap;
|
|
2478 guint16 chan, nummissed, reason;
|
|
2479 aim_userinfo_t *userinfo;
|
|
2480
|
|
2481 va_start(ap, fr);
|
|
2482 chan = (guint16)va_arg(ap, unsigned int);
|
|
2483 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
2484 nummissed = (guint16)va_arg(ap, unsigned int);
|
|
2485 reason = (guint16)va_arg(ap, unsigned int);
|
|
2486 va_end(ap);
|
|
2487
|
|
2488 switch(reason) {
|
|
2489 case 0: /* Invalid (0) */
|
|
2490 buf = g_strdup_printf(
|
|
2491 ngettext(
|
|
2492 "You missed %hu message from %s because it was invalid.",
|
|
2493 "You missed %hu messages from %s because they were invalid.",
|
|
2494 nummissed),
|
|
2495 nummissed,
|
|
2496 userinfo->sn);
|
|
2497 break;
|
|
2498 case 1: /* Message too large */
|
|
2499 buf = g_strdup_printf(
|
|
2500 ngettext(
|
|
2501 "You missed %hu message from %s because it was too large.",
|
|
2502 "You missed %hu messages from %s because they were too large.",
|
|
2503 nummissed),
|
|
2504 nummissed,
|
|
2505 userinfo->sn);
|
|
2506 break;
|
|
2507 case 2: /* Rate exceeded */
|
|
2508 buf = g_strdup_printf(
|
|
2509 ngettext(
|
|
2510 "You missed %hu message from %s because the rate limit has been exceeded.",
|
|
2511 "You missed %hu messages from %s because the rate limit has been exceeded.",
|
|
2512 nummissed),
|
|
2513 nummissed,
|
|
2514 userinfo->sn);
|
|
2515 break;
|
|
2516 case 3: /* Evil Sender */
|
|
2517 buf = g_strdup_printf(
|
|
2518 ngettext(
|
|
2519 "You missed %hu message from %s because he/she was too evil.",
|
|
2520 "You missed %hu messages from %s because he/she was too evil.",
|
|
2521 nummissed),
|
|
2522 nummissed,
|
|
2523 userinfo->sn);
|
|
2524 break;
|
|
2525 case 4: /* Evil Receiver */
|
|
2526 buf = g_strdup_printf(
|
|
2527 ngettext(
|
|
2528 "You missed %hu message from %s because you are too evil.",
|
|
2529 "You missed %hu messages from %s because you are too evil.",
|
|
2530 nummissed),
|
|
2531 nummissed,
|
|
2532 userinfo->sn);
|
|
2533 break;
|
|
2534 default:
|
|
2535 buf = g_strdup_printf(
|
|
2536 ngettext(
|
|
2537 "You missed %hu message from %s for an unknown reason.",
|
|
2538 "You missed %hu messages from %s for an unknown reason.",
|
|
2539 nummissed),
|
|
2540 nummissed,
|
|
2541 userinfo->sn);
|
|
2542 break;
|
|
2543 }
|
|
2544
|
|
2545 if (!gaim_conv_present_error(userinfo->sn, account, buf))
|
|
2546 gaim_notify_error(od->gc, NULL, buf, NULL);
|
|
2547 g_free(buf);
|
|
2548
|
|
2549 return 1;
|
|
2550 }
|
|
2551
|
|
2552 static int
|
|
2553 gaim_parse_clientauto_ch2(OscarData *od, const char *who, guint16 reason, const guchar *cookie)
|
|
2554 {
|
|
2555 if (reason == 0x0003)
|
|
2556 {
|
|
2557 /* Rendezvous was refused. */
|
|
2558 PeerConnection *conn;
|
|
2559
|
|
2560 conn = peer_connection_find_by_cookie(od, who, cookie);
|
|
2561
|
|
2562 if (conn == NULL)
|
|
2563 {
|
|
2564 gaim_debug_info("oscar", "Received a rendezvous cancel message "
|
|
2565 "for a nonexistant connection from %s.\n", who);
|
|
2566 }
|
|
2567 else
|
|
2568 {
|
|
2569 peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_REFUSED);
|
|
2570 }
|
|
2571 }
|
|
2572 else
|
|
2573 {
|
|
2574 gaim_debug_warning("oscar", "Received an unknown rendezvous "
|
|
2575 "message from %s. Type 0x%04hx\n", who, reason);
|
|
2576 }
|
|
2577
|
|
2578 return 0;
|
|
2579 }
|
|
2580
|
|
2581 static int gaim_parse_clientauto_ch4(OscarData *od, char *who, guint16 reason, guint32 state, char *msg) {
|
|
2582 GaimConnection *gc = od->gc;
|
|
2583
|
|
2584 switch(reason) {
|
|
2585 case 0x0003: { /* Reply from an ICQ status message request */
|
|
2586 char *title, *statusmsg, **splitmsg, *dialogmsg;
|
|
2587
|
|
2588 title = g_strdup_printf(_("Info for %s"), who);
|
|
2589
|
|
2590 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */
|
|
2591 statusmsg = oscar_icqstatus(state);
|
|
2592 splitmsg = g_strsplit(msg, "\r\n", 0);
|
|
2593 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg));
|
|
2594 g_free(statusmsg);
|
|
2595 g_strfreev(splitmsg);
|
|
2596
|
|
2597 gaim_notify_userinfo(gc, who, dialogmsg, NULL, NULL);
|
|
2598
|
|
2599 g_free(title);
|
|
2600 g_free(dialogmsg);
|
|
2601 } break;
|
|
2602
|
|
2603 default: {
|
|
2604 gaim_debug_warning("oscar",
|
|
2605 "Received an unknown client auto-response from %s. "
|
|
2606 "Type 0x%04hx\n", who, reason);
|
|
2607 } break;
|
|
2608 } /* end of switch */
|
|
2609
|
|
2610 return 0;
|
|
2611 }
|
|
2612
|
|
2613 static int gaim_parse_clientauto(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2614 va_list ap;
|
|
2615 guint16 chan, reason;
|
|
2616 char *who;
|
|
2617
|
|
2618 va_start(ap, fr);
|
|
2619 chan = (guint16)va_arg(ap, unsigned int);
|
|
2620 who = va_arg(ap, char *);
|
|
2621 reason = (guint16)va_arg(ap, unsigned int);
|
|
2622
|
|
2623 if (chan == 0x0002) { /* File transfer declined */
|
|
2624 guchar *cookie = va_arg(ap, guchar *);
|
|
2625 return gaim_parse_clientauto_ch2(od, who, reason, cookie);
|
|
2626 } else if (chan == 0x0004) { /* ICQ message */
|
|
2627 guint32 state = 0;
|
|
2628 char *msg = NULL;
|
|
2629 if (reason == 0x0003) {
|
|
2630 state = va_arg(ap, guint32);
|
|
2631 msg = va_arg(ap, char *);
|
|
2632 }
|
|
2633 return gaim_parse_clientauto_ch4(od, who, reason, state, msg);
|
|
2634 }
|
|
2635
|
|
2636 va_end(ap);
|
|
2637
|
|
2638 return 1;
|
|
2639 }
|
|
2640
|
|
2641 static int gaim_parse_genericerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2642 va_list ap;
|
|
2643 guint16 reason;
|
|
2644 char *m;
|
|
2645
|
|
2646 va_start(ap, fr);
|
|
2647 reason = (guint16) va_arg(ap, unsigned int);
|
|
2648 va_end(ap);
|
|
2649
|
|
2650 gaim_debug_error("oscar",
|
|
2651 "snac threw error (reason 0x%04hx: %s)\n", reason,
|
|
2652 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown");
|
|
2653
|
|
2654 m = g_strdup_printf(_("SNAC threw error: %s\n"),
|
|
2655 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error"));
|
|
2656 gaim_notify_error(od->gc, NULL, m, NULL);
|
|
2657 g_free(m);
|
|
2658
|
|
2659 return 1;
|
|
2660 }
|
|
2661
|
|
2662 static int gaim_parse_msgerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2663 GaimConnection *gc = od->gc;
|
|
2664 #ifdef TODOFT
|
|
2665 OscarData *od = gc->proto_data;
|
|
2666 GaimXfer *xfer;
|
|
2667 #endif
|
|
2668 va_list ap;
|
|
2669 guint16 reason;
|
|
2670 char *data, *buf;
|
|
2671
|
|
2672 va_start(ap, fr);
|
|
2673 reason = (guint16)va_arg(ap, unsigned int);
|
|
2674 data = va_arg(ap, char *);
|
|
2675 va_end(ap);
|
|
2676
|
|
2677 gaim_debug_error("oscar",
|
|
2678 "Message error with data %s and reason %hu\n",
|
|
2679 (data != NULL ? data : ""), reason);
|
|
2680
|
|
2681 #ifdef TODOFT
|
|
2682 /* If this was a file transfer request, data is a cookie */
|
|
2683 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, data))) {
|
|
2684 gaim_xfer_cancel_remote(xfer);
|
|
2685 return 1;
|
|
2686 }
|
|
2687 #endif
|
|
2688
|
|
2689 /* Data is assumed to be the destination sn */
|
|
2690 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason."));
|
|
2691 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) {
|
|
2692 g_free(buf);
|
|
2693 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)");
|
|
2694 gaim_notify_error(od->gc, NULL, buf,
|
|
2695 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
|
|
2696 }
|
|
2697 g_free(buf);
|
|
2698
|
|
2699 return 1;
|
|
2700 }
|
|
2701
|
|
2702 static int gaim_parse_mtn(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2703 GaimConnection *gc = od->gc;
|
|
2704 va_list ap;
|
|
2705 guint16 type1, type2;
|
|
2706 char *sn;
|
|
2707
|
|
2708 va_start(ap, fr);
|
|
2709 type1 = (guint16) va_arg(ap, unsigned int);
|
|
2710 sn = va_arg(ap, char *);
|
|
2711 type2 = (guint16) va_arg(ap, unsigned int);
|
|
2712 va_end(ap);
|
|
2713
|
|
2714 switch (type2) {
|
|
2715 case 0x0000: { /* Text has been cleared */
|
|
2716 serv_got_typing_stopped(gc, sn);
|
|
2717 } break;
|
|
2718
|
|
2719 case 0x0001: { /* Paused typing */
|
|
2720 serv_got_typing(gc, sn, 0, GAIM_TYPED);
|
|
2721 } break;
|
|
2722
|
|
2723 case 0x0002: { /* Typing */
|
|
2724 serv_got_typing(gc, sn, 0, GAIM_TYPING);
|
|
2725 } break;
|
|
2726
|
|
2727 default: {
|
|
2728 /*
|
|
2729 * It looks like iChat sometimes sends typing notification
|
|
2730 * with type1=0x0001 and type2=0x000f. Not sure why.
|
|
2731 */
|
|
2732 gaim_debug_info("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2);
|
|
2733 } break;
|
|
2734 }
|
|
2735
|
|
2736 return 1;
|
|
2737 }
|
|
2738
|
|
2739 /*
|
|
2740 * We get this error when there was an error in the locate family. This
|
|
2741 * happens when you request info of someone who is offline.
|
|
2742 */
|
|
2743 static int gaim_parse_locerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2744 gchar *buf;
|
|
2745 va_list ap;
|
|
2746 guint16 reason;
|
|
2747 char *destn;
|
|
2748
|
|
2749 va_start(ap, fr);
|
|
2750 reason = (guint16) va_arg(ap, unsigned int);
|
|
2751 destn = va_arg(ap, char *);
|
|
2752 va_end(ap);
|
|
2753
|
|
2754 if (destn == NULL)
|
|
2755 return 1;
|
|
2756
|
|
2757 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
|
|
2758 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)od->gc), buf)) {
|
|
2759 g_free(buf);
|
|
2760 buf = g_strdup_printf(_("User information for %s unavailable:"), destn);
|
|
2761 gaim_notify_error(od->gc, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
|
|
2762 }
|
|
2763 g_free(buf);
|
|
2764
|
|
2765 return 1;
|
|
2766 }
|
|
2767
|
|
2768 static int gaim_parse_userinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2769 GaimConnection *gc = od->gc;
|
|
2770 GaimAccount *account = gaim_connection_get_account(gc);
|
|
2771 GString *str;
|
|
2772 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL;
|
|
2773 va_list ap;
|
|
2774 aim_userinfo_t *userinfo;
|
|
2775
|
|
2776 va_start(ap, fr);
|
|
2777 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
2778 va_end(ap);
|
|
2779
|
|
2780 str = g_string_new("");
|
|
2781 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn);
|
|
2782 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5));
|
|
2783
|
|
2784 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) {
|
|
2785 time_t t = userinfo->onlinesince - od->timeoffset;
|
|
2786 oscar_string_append(str, "\n<br>", _("Online Since"), gaim_date_format_full(localtime(&t)));
|
|
2787 }
|
|
2788
|
|
2789 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) {
|
|
2790 time_t t = userinfo->membersince - od->timeoffset;
|
|
2791 oscar_string_append(str, "\n<br>", _("Member Since"), gaim_date_format_full(localtime(&t)));
|
|
2792 }
|
|
2793
|
|
2794 if (userinfo->capabilities != 0) {
|
|
2795 tmp = oscar_caps_to_string(userinfo->capabilities);
|
|
2796 oscar_string_append(str, "\n<br>", _("Capabilities"), tmp);
|
|
2797 g_free(tmp);
|
|
2798 }
|
|
2799
|
|
2800 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) {
|
|
2801 tmp = gaim_str_seconds_to_string(userinfo->idletime*60);
|
|
2802 oscar_string_append(str, "\n<br>", _("Idle"), tmp);
|
|
2803 g_free(tmp);
|
|
2804 }
|
|
2805
|
|
2806 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo);
|
|
2807
|
|
2808 /* Available message */
|
|
2809 if ((userinfo->status != NULL) && !(userinfo->flags & AIM_FLAG_AWAY))
|
|
2810 {
|
|
2811 if (userinfo->status[0] != '\0')
|
|
2812 tmp = oscar_encoding_to_utf8(userinfo->status_encoding,
|
|
2813 userinfo->status, userinfo->status_len);
|
|
2814 oscar_string_convert_and_append(account, str, "\n<br>", _("Available Message"), tmp);
|
|
2815 g_free(tmp);
|
|
2816 }
|
|
2817
|
|
2818 /* Away message */
|
|
2819 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) {
|
|
2820 tmp = oscar_encoding_extract(userinfo->away_encoding);
|
|
2821 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len);
|
|
2822 g_free(tmp);
|
|
2823 if (away_utf8 != NULL) {
|
|
2824 g_string_append_printf(str, "\n<hr>%s", away_utf8);
|
|
2825 g_free(away_utf8);
|
|
2826 }
|
|
2827 }
|
|
2828
|
|
2829 /* Info */
|
|
2830 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) {
|
|
2831 tmp = oscar_encoding_extract(userinfo->info_encoding);
|
|
2832 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len);
|
|
2833 g_free(tmp);
|
|
2834 if (info_utf8 != NULL) {
|
|
2835 g_string_append_printf(str, "\n<hr>%s", info_utf8);
|
|
2836 g_free(info_utf8);
|
|
2837 }
|
|
2838 }
|
|
2839
|
|
2840 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account));
|
|
2841 g_string_free(str, TRUE);
|
|
2842 gaim_str_strip_char(tmp, '\r');
|
|
2843 gaim_notify_userinfo(gc, userinfo->sn, tmp, NULL, NULL);
|
|
2844 g_free(tmp);
|
|
2845
|
|
2846 return 1;
|
|
2847 }
|
|
2848
|
|
2849 static int gaim_got_infoblock(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
2850 {
|
|
2851 GaimConnection *gc = od->gc;
|
|
2852 GaimBuddy *b;
|
|
2853 GaimPresence *presence;
|
|
2854 GaimStatus *status;
|
|
2855 gchar *message = NULL;
|
|
2856
|
|
2857 va_list ap;
|
|
2858 aim_userinfo_t *userinfo;
|
|
2859
|
|
2860 va_start(ap, fr);
|
|
2861 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
2862 va_end(ap);
|
|
2863
|
|
2864 b = gaim_find_buddy(gaim_connection_get_account(gc), userinfo->sn);
|
|
2865 if (b == NULL)
|
|
2866 return 1;
|
|
2867
|
|
2868 if (!aim_sn_is_icq(userinfo->sn))
|
|
2869 {
|
|
2870 if (strcmp(gaim_buddy_get_name(b), userinfo->sn))
|
|
2871 serv_got_alias(gc, gaim_buddy_get_name(b), userinfo->sn);
|
|
2872 else
|
|
2873 serv_got_alias(gc, gaim_buddy_get_name(b), NULL);
|
|
2874 }
|
|
2875
|
|
2876 presence = gaim_buddy_get_presence(b);
|
|
2877 status = gaim_presence_get_active_status(presence);
|
|
2878
|
|
2879 if (!gaim_status_is_available(status) && gaim_status_is_online(status))
|
|
2880 {
|
|
2881 if ((userinfo->flags & AIM_FLAG_AWAY) &&
|
|
2882 (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) {
|
|
2883 gchar *charset = oscar_encoding_extract(userinfo->away_encoding);
|
|
2884 message = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len);
|
|
2885 g_free(charset);
|
|
2886 gaim_status_set_attr_string(status, "message", message);
|
|
2887 g_free(message);
|
|
2888 }
|
|
2889 else
|
|
2890 /* Set an empty message so that we know not to show "pending" */
|
|
2891 gaim_status_set_attr_string(status, "message", "");
|
|
2892
|
|
2893 gaim_blist_update_buddy_status(b, status);
|
|
2894 }
|
|
2895
|
|
2896 return 1;
|
|
2897 }
|
|
2898
|
|
2899 static int gaim_parse_motd(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
2900 {
|
|
2901 char *msg;
|
|
2902 guint16 id;
|
|
2903 va_list ap;
|
|
2904
|
|
2905 va_start(ap, fr);
|
|
2906 id = (guint16) va_arg(ap, unsigned int);
|
|
2907 msg = va_arg(ap, char *);
|
|
2908 va_end(ap);
|
|
2909
|
|
2910 gaim_debug_misc("oscar",
|
|
2911 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id);
|
|
2912 if (id < 4)
|
|
2913 gaim_notify_warning(od->gc, NULL,
|
|
2914 _("Your AIM connection may be lost."), NULL);
|
|
2915
|
|
2916 return 1;
|
|
2917 }
|
|
2918
|
|
2919 static int gaim_chatnav_info(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2920 va_list ap;
|
|
2921 guint16 type;
|
|
2922
|
|
2923 va_start(ap, fr);
|
|
2924 type = (guint16) va_arg(ap, unsigned int);
|
|
2925
|
|
2926 switch(type) {
|
|
2927 case 0x0002: {
|
|
2928 guint8 maxrooms;
|
|
2929 struct aim_chat_exchangeinfo *exchanges;
|
|
2930 int exchangecount, i;
|
|
2931
|
|
2932 maxrooms = (guint8) va_arg(ap, unsigned int);
|
|
2933 exchangecount = va_arg(ap, int);
|
|
2934 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
|
|
2935
|
|
2936 gaim_debug_misc("oscar", "chat info: Chat Rights:\n");
|
|
2937 gaim_debug_misc("oscar",
|
|
2938 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms);
|
|
2939 gaim_debug_misc("oscar",
|
|
2940 "chat info: \tExchange List: (%d total)\n", exchangecount);
|
|
2941 for (i = 0; i < exchangecount; i++)
|
|
2942 gaim_debug_misc("oscar",
|
|
2943 "chat info: \t\t%hu %s\n",
|
|
2944 exchanges[i].number, exchanges[i].name ? exchanges[i].name : "");
|
|
2945 while (od->create_rooms) {
|
|
2946 struct create_room *cr = od->create_rooms->data;
|
|
2947 gaim_debug_info("oscar",
|
|
2948 "creating room %s\n", cr->name);
|
|
2949 aim_chatnav_createroom(od, conn, cr->name, cr->exchange);
|
|
2950 g_free(cr->name);
|
|
2951 od->create_rooms = g_slist_remove(od->create_rooms, cr);
|
|
2952 g_free(cr);
|
|
2953 }
|
|
2954 }
|
|
2955 break;
|
|
2956 case 0x0008: {
|
|
2957 char *fqcn, *name, *ck;
|
|
2958 guint16 instance, flags, maxmsglen, maxoccupancy, unknown, exchange;
|
|
2959 guint8 createperms;
|
|
2960 guint32 createtime;
|
|
2961
|
|
2962 fqcn = va_arg(ap, char *);
|
|
2963 instance = (guint16)va_arg(ap, unsigned int);
|
|
2964 exchange = (guint16)va_arg(ap, unsigned int);
|
|
2965 flags = (guint16)va_arg(ap, unsigned int);
|
|
2966 createtime = va_arg(ap, guint32);
|
|
2967 maxmsglen = (guint16)va_arg(ap, unsigned int);
|
|
2968 maxoccupancy = (guint16)va_arg(ap, unsigned int);
|
|
2969 createperms = (guint8)va_arg(ap, unsigned int);
|
|
2970 unknown = (guint16)va_arg(ap, unsigned int);
|
|
2971 name = va_arg(ap, char *);
|
|
2972 ck = va_arg(ap, char *);
|
|
2973
|
|
2974 gaim_debug_misc("oscar",
|
|
2975 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n",
|
|
2976 fqcn, exchange, instance, flags, createtime,
|
|
2977 maxmsglen, maxoccupancy, createperms, unknown,
|
|
2978 name, ck);
|
|
2979 aim_chat_join(od, exchange, ck, instance);
|
|
2980 }
|
|
2981 break;
|
|
2982 default:
|
|
2983 gaim_debug_warning("oscar",
|
|
2984 "chatnav info: unknown type (%04hx)\n", type);
|
|
2985 break;
|
|
2986 }
|
|
2987
|
|
2988 va_end(ap);
|
|
2989
|
|
2990 return 1;
|
|
2991 }
|
|
2992
|
|
2993 static int gaim_conv_chat_join(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2994 va_list ap;
|
|
2995 int count, i;
|
|
2996 aim_userinfo_t *info;
|
|
2997 GaimConnection *gc = od->gc;
|
|
2998
|
|
2999 struct chat_connection *c = NULL;
|
|
3000
|
|
3001 va_start(ap, fr);
|
|
3002 count = va_arg(ap, int);
|
|
3003 info = va_arg(ap, aim_userinfo_t *);
|
|
3004 va_end(ap);
|
|
3005
|
|
3006 c = find_oscar_chat_by_conn(gc, conn);
|
|
3007 if (!c)
|
|
3008 return 1;
|
|
3009
|
|
3010 for (i = 0; i < count; i++)
|
|
3011 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE);
|
|
3012
|
|
3013 return 1;
|
|
3014 }
|
|
3015
|
|
3016 static int gaim_conv_chat_leave(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3017 va_list ap;
|
|
3018 int count, i;
|
|
3019 aim_userinfo_t *info;
|
|
3020 GaimConnection *gc = od->gc;
|
|
3021
|
|
3022 struct chat_connection *c = NULL;
|
|
3023
|
|
3024 va_start(ap, fr);
|
|
3025 count = va_arg(ap, int);
|
|
3026 info = va_arg(ap, aim_userinfo_t *);
|
|
3027 va_end(ap);
|
|
3028
|
|
3029 c = find_oscar_chat_by_conn(gc, conn);
|
|
3030 if (!c)
|
|
3031 return 1;
|
|
3032
|
|
3033 for (i = 0; i < count; i++)
|
|
3034 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL);
|
|
3035
|
|
3036 return 1;
|
|
3037 }
|
|
3038
|
|
3039 static int gaim_conv_chat_info_update(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3040 va_list ap;
|
|
3041 aim_userinfo_t *userinfo;
|
|
3042 struct aim_chat_roominfo *roominfo;
|
|
3043 char *roomname;
|
|
3044 int usercount;
|
|
3045 char *roomdesc;
|
|
3046 guint16 unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen;
|
|
3047 guint32 creationtime;
|
|
3048 GaimConnection *gc = od->gc;
|
|
3049 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, conn);
|
|
3050
|
|
3051 va_start(ap, fr);
|
|
3052 roominfo = va_arg(ap, struct aim_chat_roominfo *);
|
|
3053 roomname = va_arg(ap, char *);
|
|
3054 usercount= va_arg(ap, int);
|
|
3055 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
3056 roomdesc = va_arg(ap, char *);
|
|
3057 unknown_c9 = (guint16)va_arg(ap, unsigned int);
|
|
3058 creationtime = va_arg(ap, guint32);
|
|
3059 maxmsglen = (guint16)va_arg(ap, unsigned int);
|
|
3060 unknown_d2 = (guint16)va_arg(ap, unsigned int);
|
|
3061 unknown_d5 = (guint16)va_arg(ap, unsigned int);
|
|
3062 maxvisiblemsglen = (guint16)va_arg(ap, unsigned int);
|
|
3063 va_end(ap);
|
|
3064
|
|
3065 gaim_debug_misc("oscar",
|
|
3066 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n",
|
|
3067 maxmsglen, maxvisiblemsglen);
|
|
3068
|
|
3069 ccon->maxlen = maxmsglen;
|
|
3070 ccon->maxvis = maxvisiblemsglen;
|
|
3071
|
|
3072 return 1;
|
|
3073 }
|
|
3074
|
|
3075 static int gaim_conv_chat_incoming_msg(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3076 GaimConnection *gc = od->gc;
|
|
3077 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, conn);
|
|
3078 gchar *utf8;
|
|
3079 va_list ap;
|
|
3080 aim_userinfo_t *info;
|
|
3081 int len;
|
|
3082 char *msg;
|
|
3083 char *charset;
|
|
3084
|
|
3085 va_start(ap, fr);
|
|
3086 info = va_arg(ap, aim_userinfo_t *);
|
|
3087 len = va_arg(ap, int);
|
|
3088 msg = va_arg(ap, char *);
|
|
3089 charset = va_arg(ap, char *);
|
|
3090 va_end(ap);
|
|
3091
|
|
3092 utf8 = oscar_encoding_to_utf8(charset, msg, len);
|
|
3093 if (utf8 == NULL)
|
|
3094 /* The conversion failed! */
|
|
3095 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]"));
|
|
3096 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL));
|
|
3097 g_free(utf8);
|
|
3098
|
|
3099 return 1;
|
|
3100 }
|
|
3101
|
|
3102 static int gaim_email_parseupdate(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3103 va_list ap;
|
|
3104 GaimConnection *gc = od->gc;
|
|
3105 struct aim_emailinfo *emailinfo;
|
|
3106 int havenewmail;
|
|
3107 char *alertitle, *alerturl;
|
|
3108
|
|
3109 va_start(ap, fr);
|
|
3110 emailinfo = va_arg(ap, struct aim_emailinfo *);
|
|
3111 havenewmail = va_arg(ap, int);
|
|
3112 alertitle = va_arg(ap, char *);
|
|
3113 alerturl = va_arg(ap, char *);
|
|
3114 va_end(ap);
|
|
3115
|
|
3116 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) {
|
|
3117 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)),
|
|
3118 emailinfo->domain ? "@" : "",
|
|
3119 emailinfo->domain ? emailinfo->domain : "");
|
|
3120 if (emailinfo->unread && havenewmail)
|
|
3121 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL);
|
|
3122 g_free(to);
|
|
3123 }
|
|
3124
|
|
3125 if (alertitle)
|
|
3126 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : "");
|
|
3127
|
|
3128 return 1;
|
|
3129 }
|
|
3130
|
|
3131 static int gaim_icon_error(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3132 GaimConnection *gc = od->gc;
|
|
3133 char *sn;
|
|
3134
|
|
3135 sn = od->requesticon->data;
|
|
3136 gaim_debug_misc("oscar", "removing %s from hash table\n", sn);
|
|
3137 od->requesticon = g_slist_remove(od->requesticon, sn);
|
|
3138 g_free(sn);
|
|
3139
|
|
3140 if (od->icontimer == 0)
|
|
3141 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc);
|
|
3142
|
|
3143 return 1;
|
|
3144 }
|
|
3145
|
|
3146 static int gaim_icon_parseicon(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3147 GaimConnection *gc = od->gc;
|
|
3148 GSList *cur;
|
|
3149 va_list ap;
|
|
3150 char *sn;
|
|
3151 guint8 iconcsumtype, *iconcsum, *icon;
|
|
3152 guint16 iconcsumlen, iconlen;
|
|
3153
|
|
3154 va_start(ap, fr);
|
|
3155 sn = va_arg(ap, char *);
|
|
3156 iconcsumtype = va_arg(ap, int);
|
|
3157 iconcsum = va_arg(ap, guint8 *);
|
|
3158 iconcsumlen = va_arg(ap, int);
|
|
3159 icon = va_arg(ap, guint8 *);
|
|
3160 iconlen = va_arg(ap, int);
|
|
3161 va_end(ap);
|
|
3162
|
|
3163 /*
|
|
3164 * Some AIM clients will send a blank GIF image with iconlen 90 when
|
|
3165 * no icon is set. Ignore these.
|
|
3166 */
|
|
3167 if ((iconlen > 0) && (iconlen != 90)) {
|
|
3168 char *b16;
|
|
3169 GaimBuddy *b;
|
|
3170 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc),
|
|
3171 sn, icon, iconlen);
|
|
3172 b16 = gaim_base16_encode(iconcsum, iconcsumlen);
|
|
3173 b = gaim_find_buddy(gc->account, sn);
|
|
3174 if ((b16 != NULL) && (b != NULL)) {
|
|
3175 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16);
|
|
3176 g_free(b16);
|
|
3177 }
|
|
3178 }
|
|
3179
|
|
3180 cur = od->requesticon;
|
|
3181 while (cur) {
|
|
3182 char *cursn = cur->data;
|
|
3183 if (!aim_sncmp(cursn, sn)) {
|
|
3184 od->requesticon = g_slist_remove(od->requesticon, cursn);
|
|
3185 g_free(cursn);
|
|
3186 cur = od->requesticon;
|
|
3187 } else
|
|
3188 cur = cur->next;
|
|
3189 }
|
|
3190
|
|
3191 if (od->icontimer == 0)
|
|
3192 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc);
|
|
3193
|
|
3194 return 1;
|
|
3195 }
|
|
3196
|
|
3197 static gboolean gaim_icon_timerfunc(gpointer data) {
|
|
3198 GaimConnection *gc = data;
|
|
3199 OscarData *od = gc->proto_data;
|
|
3200 aim_userinfo_t *userinfo;
|
|
3201 FlapConnection *conn;
|
|
3202
|
|
3203 od->icontimer = 0;
|
|
3204
|
|
3205 conn = flap_connection_getbytype(od, SNAC_FAMILY_BART);
|
|
3206 if (!conn) {
|
|
3207 if (!od->iconconnecting) {
|
|
3208 aim_reqservice(od, SNAC_FAMILY_BART);
|
|
3209 od->iconconnecting = TRUE;
|
|
3210 }
|
|
3211 return FALSE;
|
|
3212 }
|
|
3213
|
|
3214 if (od->set_icon) {
|
|
3215 struct stat st;
|
|
3216 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc)));
|
|
3217 if (iconfile == NULL) {
|
|
3218 aim_ssi_delicon(od);
|
|
3219 } else if (!g_stat(iconfile, &st)) {
|
|
3220 guchar *buf = g_malloc(st.st_size);
|
|
3221 FILE *file = g_fopen(iconfile, "rb");
|
|
3222 if (file) {
|
|
3223 /* XXX - Use g_file_get_contents()? */
|
|
3224 fread(buf, 1, st.st_size, file);
|
|
3225 fclose(file);
|
|
3226 gaim_debug_info("oscar",
|
|
3227 "Uploading icon to icon server\n");
|
|
3228 aim_bart_upload(od, buf, st.st_size);
|
|
3229 } else
|
|
3230 gaim_debug_error("oscar",
|
|
3231 "Can't open buddy icon file!\n");
|
|
3232 g_free(buf);
|
|
3233 } else {
|
|
3234 gaim_debug_error("oscar",
|
|
3235 "Can't stat buddy icon file!\n");
|
|
3236 }
|
|
3237 g_free(iconfile);
|
|
3238 od->set_icon = FALSE;
|
|
3239 }
|
|
3240
|
|
3241 if (!od->requesticon) {
|
|
3242 gaim_debug_misc("oscar",
|
|
3243 "no more icons to request\n");
|
|
3244 return FALSE;
|
|
3245 }
|
|
3246
|
|
3247 userinfo = aim_locate_finduserinfo(od, (char *)od->requesticon->data);
|
|
3248 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) {
|
|
3249 aim_bart_request(od, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen);
|
|
3250 return FALSE;
|
|
3251 } else {
|
|
3252 gchar *sn = od->requesticon->data;
|
|
3253 od->requesticon = g_slist_remove(od->requesticon, sn);
|
|
3254 g_free(sn);
|
|
3255 }
|
|
3256
|
|
3257 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc);
|
|
3258
|
|
3259 return FALSE;
|
|
3260 }
|
|
3261
|
|
3262 /*
|
|
3263 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option.
|
|
3264 */
|
|
3265 static int gaim_parse_msgack(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3266 va_list ap;
|
|
3267 guint16 type;
|
|
3268 char *sn;
|
|
3269
|
|
3270 va_start(ap, fr);
|
|
3271 type = (guint16) va_arg(ap, unsigned int);
|
|
3272 sn = va_arg(ap, char *);
|
|
3273 va_end(ap);
|
|
3274
|
|
3275 gaim_debug_info("oscar", "Sent message to %s.\n", sn);
|
|
3276
|
|
3277 return 1;
|
|
3278 }
|
|
3279
|
|
3280 static int gaim_parse_ratechange(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3281 static const char *codes[5] = {
|
|
3282 "invalid",
|
|
3283 "change",
|
|
3284 "warning",
|
|
3285 "limit",
|
|
3286 "limit cleared",
|
|
3287 };
|
|
3288 va_list ap;
|
|
3289 guint16 code, rateclass;
|
|
3290 guint32 windowsize, clear, alert, limit, disconnect, currentavg, maxavg;
|
|
3291
|
|
3292 va_start(ap, fr);
|
|
3293 code = (guint16)va_arg(ap, unsigned int);
|
|
3294 rateclass= (guint16)va_arg(ap, unsigned int);
|
|
3295 windowsize = va_arg(ap, guint32);
|
|
3296 clear = va_arg(ap, guint32);
|
|
3297 alert = va_arg(ap, guint32);
|
|
3298 limit = va_arg(ap, guint32);
|
|
3299 disconnect = va_arg(ap, guint32);
|
|
3300 currentavg = va_arg(ap, guint32);
|
|
3301 maxavg = va_arg(ap, guint32);
|
|
3302 va_end(ap);
|
|
3303
|
|
3304 gaim_debug_misc("oscar",
|
|
3305 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, "
|
|
3306 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n",
|
|
3307 (code < 5) ? codes[code] : codes[0],
|
|
3308 rateclass,
|
|
3309 currentavg, maxavg,
|
|
3310 alert, clear,
|
|
3311 limit, disconnect,
|
|
3312 windowsize);
|
|
3313
|
|
3314 if (code == AIM_RATE_CODE_LIMIT)
|
|
3315 {
|
|
3316 gaim_notify_error(od->gc, NULL, _("Rate limiting error."),
|
|
3317 _("The last action you attempted could not be "
|
|
3318 "performed because you are over the rate limit. "
|
|
3319 "Please wait 10 seconds and try again."));
|
|
3320 }
|
|
3321
|
|
3322 return 1;
|
|
3323 }
|
|
3324
|
|
3325 static int gaim_parse_evilnotify(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3326 #ifdef CRAZY_WARNING
|
|
3327 va_list ap;
|
|
3328 guint16 newevil;
|
|
3329 aim_userinfo_t *userinfo;
|
|
3330
|
|
3331 va_start(ap, fr);
|
|
3332 newevil = (guint16) va_arg(ap, unsigned int);
|
|
3333 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
3334 va_end(ap);
|
|
3335
|
|
3336 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5);
|
|
3337 #endif
|
|
3338
|
|
3339 return 1;
|
|
3340 }
|
|
3341
|
|
3342 static int gaim_selfinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3343 int warning_level;
|
|
3344 va_list ap;
|
|
3345 aim_userinfo_t *info;
|
|
3346
|
|
3347 va_start(ap, fr);
|
|
3348 info = va_arg(ap, aim_userinfo_t *);
|
|
3349 va_end(ap);
|
|
3350
|
|
3351 /*
|
|
3352 * What's with the + 0.5?
|
|
3353 * The 0.5 is basically poor-man's rounding. Normally
|
|
3354 * casting "13.7" to an int will truncate to "13," but
|
|
3355 * with 13.7 + 0.5 = 14.2, which becomes "14" when
|
|
3356 * truncated.
|
|
3357 */
|
|
3358 warning_level = info->warnlevel/10.0 + 0.5;
|
|
3359
|
|
3360 #ifdef CRAZY_WARNING
|
|
3361 gaim_presence_set_warning_level(presence, warning_level);
|
|
3362 #endif
|
|
3363
|
|
3364 return 1;
|
|
3365 }
|
|
3366
|
|
3367 static int gaim_connerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3368 GaimConnection *gc = od->gc;
|
|
3369 va_list ap;
|
|
3370 guint16 code;
|
|
3371 char *msg;
|
|
3372
|
|
3373 va_start(ap, fr);
|
|
3374 code = (guint16)va_arg(ap, int);
|
|
3375 msg = va_arg(ap, char *);
|
|
3376 va_end(ap);
|
|
3377
|
|
3378 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n",
|
|
3379 code, (msg != NULL ? msg : ""));
|
|
3380
|
|
3381 g_return_val_if_fail(fr != NULL, 1);
|
|
3382 g_return_val_if_fail(conn != NULL, 1);
|
|
3383
|
|
3384 if (conn->type == SNAC_FAMILY_LOCATE) {
|
|
3385 if (code == 0x0001) {
|
|
3386 gc->wants_to_die = TRUE;
|
|
3387 gaim_connection_error(gc, _("You have signed on from another location."));
|
|
3388 } else {
|
|
3389 gaim_connection_error(gc, _("You have been signed off for an unknown reason."));
|
|
3390 }
|
|
3391 od->killme = TRUE;
|
|
3392 } else if (conn->type == SNAC_FAMILY_CHAT) {
|
|
3393 struct chat_connection *cc;
|
|
3394 GaimConversation *conv;
|
|
3395
|
|
3396 cc = find_oscar_chat_by_conn(gc, conn);
|
|
3397 conv = gaim_find_chat(gc, cc->id);
|
|
3398
|
|
3399 if (conv != NULL)
|
|
3400 {
|
|
3401 gchar *buf;
|
|
3402 buf = g_strdup_printf(_("You have been disconnected from chat "
|
|
3403 "room %s."), cc->name);
|
|
3404 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL));
|
|
3405 g_free(buf);
|
|
3406 }
|
|
3407 oscar_chat_kill(gc, cc);
|
|
3408 }
|
|
3409
|
|
3410 return 1;
|
|
3411 }
|
|
3412
|
|
3413 static int gaim_icbm_param_info(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3414 struct aim_icbmparameters *params;
|
|
3415 va_list ap;
|
|
3416
|
|
3417 va_start(ap, fr);
|
|
3418 params = va_arg(ap, struct aim_icbmparameters *);
|
|
3419 va_end(ap);
|
|
3420
|
|
3421 /* XXX - evidently this crashes on solaris. i have no clue why
|
|
3422 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, "
|
|
3423 "max sender evil = %f, max receiver evil = %f, min msg interval = %u\n",
|
|
3424 params->maxchan, params->flags, params->maxmsglen,
|
|
3425 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0,
|
|
3426 params->minmsginterval);
|
|
3427 */
|
|
3428
|
|
3429 /* Maybe senderwarn and recverwarn should be user preferences... */
|
|
3430 params->flags = 0x0000000b;
|
|
3431 params->maxmsglen = 8000;
|
|
3432 params->minmsginterval = 0;
|
|
3433
|
|
3434 aim_im_setparams(od, params);
|
|
3435
|
|
3436 return 1;
|
|
3437 }
|
|
3438
|
|
3439 static int gaim_parse_locaterights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3440 {
|
|
3441 GaimConnection *gc = od->gc;
|
|
3442 GaimAccount *account = gaim_connection_get_account(gc);
|
|
3443 va_list ap;
|
|
3444 guint16 maxsiglen;
|
|
3445
|
|
3446 va_start(ap, fr);
|
|
3447 maxsiglen = (guint16) va_arg(ap, int);
|
|
3448 va_end(ap);
|
|
3449
|
|
3450 gaim_debug_misc("oscar",
|
|
3451 "locate rights: max sig len = %d\n", maxsiglen);
|
|
3452
|
|
3453 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen;
|
|
3454
|
|
3455 if (od->icq)
|
|
3456 aim_locate_setcaps(od, caps_icq);
|
|
3457 else
|
|
3458 aim_locate_setcaps(od, caps_aim);
|
|
3459 oscar_set_info_and_status(account, TRUE, account->user_info, TRUE,
|
|
3460 gaim_account_get_active_status(account));
|
|
3461
|
|
3462 return 1;
|
|
3463 }
|
|
3464
|
|
3465 static int gaim_parse_buddyrights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3466 va_list ap;
|
|
3467 guint16 maxbuddies, maxwatchers;
|
|
3468
|
|
3469 va_start(ap, fr);
|
|
3470 maxbuddies = (guint16) va_arg(ap, unsigned int);
|
|
3471 maxwatchers = (guint16) va_arg(ap, unsigned int);
|
|
3472 va_end(ap);
|
|
3473
|
|
3474 gaim_debug_misc("oscar",
|
|
3475 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers);
|
|
3476
|
|
3477 od->rights.maxbuddies = (guint)maxbuddies;
|
|
3478 od->rights.maxwatchers = (guint)maxwatchers;
|
|
3479
|
|
3480 return 1;
|
|
3481 }
|
|
3482
|
|
3483 static int gaim_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3484 GaimConnection *gc;
|
|
3485 GaimAccount *account;
|
|
3486 GaimStatus *status;
|
|
3487 const char *message;
|
|
3488 char *tmp;
|
|
3489 va_list ap;
|
|
3490 guint16 maxpermits, maxdenies;
|
|
3491
|
|
3492 gc = od->gc;
|
|
3493 od = (OscarData *)gc->proto_data;
|
|
3494 account = gaim_connection_get_account(gc);
|
|
3495
|
|
3496 va_start(ap, fr);
|
|
3497 maxpermits = (guint16) va_arg(ap, unsigned int);
|
|
3498 maxdenies = (guint16) va_arg(ap, unsigned int);
|
|
3499 va_end(ap);
|
|
3500
|
|
3501 gaim_debug_misc("oscar",
|
|
3502 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies);
|
|
3503
|
|
3504 od->rights.maxpermits = (guint)maxpermits;
|
|
3505 od->rights.maxdenies = (guint)maxdenies;
|
|
3506
|
|
3507 gaim_connection_set_state(gc, GAIM_CONNECTED);
|
|
3508
|
|
3509 gaim_debug_info("oscar", "buddy list loaded\n");
|
|
3510
|
|
3511 aim_clientready(od, conn);
|
|
3512
|
|
3513 /* Set our available message based on the current status */
|
|
3514 status = gaim_account_get_active_status(account);
|
|
3515 if (gaim_status_is_available(status))
|
|
3516 message = gaim_status_get_attr_string(status, "message");
|
|
3517 else
|
|
3518 message = NULL;
|
|
3519 tmp = gaim_markup_strip_html(message);
|
|
3520 aim_srv_setstatusmsg(od, tmp);
|
|
3521 g_free(tmp);
|
|
3522
|
|
3523 aim_srv_setidle(od, 0);
|
|
3524
|
|
3525 if (od->icq) {
|
|
3526 aim_icq_reqofflinemsgs(od);
|
|
3527 oscar_set_extendedstatus(gc);
|
|
3528 aim_icq_setsecurity(od,
|
|
3529 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION),
|
|
3530 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE));
|
|
3531 }
|
|
3532
|
|
3533 aim_reqservice(od, SNAC_FAMILY_CHATNAV);
|
|
3534 if (od->authinfo->email != NULL)
|
|
3535 aim_reqservice(od, SNAC_FAMILY_ALERT);
|
|
3536
|
|
3537 return 1;
|
|
3538 }
|
|
3539
|
|
3540 static int gaim_offlinemsg(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3541 va_list ap;
|
|
3542 struct aim_icq_offlinemsg *msg;
|
|
3543 struct aim_incomingim_ch4_args args;
|
|
3544 time_t t;
|
|
3545
|
|
3546 va_start(ap, fr);
|
|
3547 msg = va_arg(ap, struct aim_icq_offlinemsg *);
|
|
3548 va_end(ap);
|
|
3549
|
|
3550 gaim_debug_info("oscar",
|
|
3551 "Received offline message. Converting to channel 4 ICBM...\n");
|
|
3552 args.uin = msg->sender;
|
|
3553 args.type = msg->type;
|
|
3554 args.flags = msg->flags;
|
|
3555 args.msglen = msg->msglen;
|
|
3556 args.msg = msg->msg;
|
|
3557 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
|
|
3558 incomingim_chan4(od, conn, NULL, &args, t);
|
|
3559
|
|
3560 return 1;
|
|
3561 }
|
|
3562
|
|
3563 static int gaim_offlinemsgdone(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3564 {
|
|
3565 aim_icq_ackofflinemsgs(od);
|
|
3566 return 1;
|
|
3567 }
|
|
3568
|
|
3569 static int gaim_icqinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3570 {
|
|
3571 GaimConnection *gc;
|
|
3572 GaimAccount *account;
|
|
3573 GaimBuddy *buddy;
|
|
3574 struct buddyinfo *bi;
|
|
3575 gchar who[16];
|
|
3576 GString *str;
|
|
3577 gchar *utf8;
|
|
3578 const gchar *alias;
|
|
3579 va_list ap;
|
|
3580 struct aim_icq_info *info;
|
|
3581
|
|
3582 gc = od->gc;
|
|
3583 account = gaim_connection_get_account(gc);
|
|
3584
|
|
3585 va_start(ap, fr);
|
|
3586 info = va_arg(ap, struct aim_icq_info *);
|
|
3587 va_end(ap);
|
|
3588
|
|
3589 if (!info->uin)
|
|
3590 return 0;
|
|
3591
|
|
3592 str = g_string_sized_new(100);
|
|
3593 g_snprintf(who, sizeof(who), "%u", info->uin);
|
|
3594 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who);
|
|
3595 if (buddy != NULL)
|
|
3596 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name));
|
|
3597 else
|
|
3598 bi = NULL;
|
|
3599
|
|
3600 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who);
|
|
3601 oscar_string_convert_and_append(account, str, "\n<br>", _("Nick"), info->nick);
|
|
3602 if ((bi != NULL) && (bi->ipaddr != 0)) {
|
|
3603 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu",
|
|
3604 (bi->ipaddr & 0xff000000) >> 24,
|
|
3605 (bi->ipaddr & 0x00ff0000) >> 16,
|
|
3606 (bi->ipaddr & 0x0000ff00) >> 8,
|
|
3607 (bi->ipaddr & 0x000000ff));
|
|
3608 oscar_string_append(str, "\n<br>", _("IP Address"), tstr);
|
|
3609 g_free(tstr);
|
|
3610 }
|
|
3611 oscar_string_convert_and_append(account, str, "\n<br>", _("First Name"), info->first);
|
|
3612 oscar_string_convert_and_append(account, str, "\n<br>", _("Last Name"), info->last);
|
|
3613 if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) {
|
|
3614 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("E-Mail Address"), utf8, utf8);
|
|
3615 g_free(utf8);
|
|
3616 }
|
|
3617 if (info->numaddresses && info->email2) {
|
|
3618 int i;
|
|
3619 for (i = 0; i < info->numaddresses; i++) {
|
|
3620 if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) {
|
|
3621 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("E-Mail Address"), utf8, utf8);
|
|
3622 g_free(utf8);
|
|
3623 }
|
|
3624 }
|
|
3625 }
|
|
3626 oscar_string_convert_and_append(account, str, "\n<br>", _("Mobile Phone"), info->mobile);
|
|
3627 if (info->gender != 0)
|
|
3628 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male"));
|
|
3629 if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) {
|
|
3630 /* Initialize the struct properly or strftime() will crash
|
|
3631 * under some conditions (e.g. Debian sarge w/ LANG=en_HK). */
|
|
3632 time_t t = time(NULL);
|
|
3633 struct tm *tm = localtime(&t);
|
|
3634
|
|
3635 tm->tm_mday = (int)info->birthday;
|
|
3636 tm->tm_mon = (int)info->birthmonth - 1;
|
|
3637 tm->tm_year = (int)info->birthyear - 1900;
|
|
3638
|
|
3639 /* To be 100% sure that the fields are re-normalized.
|
|
3640 * If you're sure strftime() ALWAYS does this EVERYWHERE,
|
|
3641 * feel free to remove it. --rlaager */
|
|
3642 mktime(tm);
|
|
3643
|
|
3644 oscar_string_append(str, "\n<br>", _("Birthday"),
|
|
3645 gaim_date_format_short(tm));
|
|
3646 }
|
|
3647 if ((info->age > 0) && (info->age < 255)) {
|
|
3648 char age[5];
|
|
3649 snprintf(age, sizeof(age), "%hhd", info->age);
|
|
3650 oscar_string_append(str, "\n<br>", _("Age"), age);
|
|
3651 }
|
|
3652 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) {
|
|
3653 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8);
|
|
3654 g_free(utf8);
|
|
3655 }
|
|
3656 if (info->info && info->info[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->info))) {
|
|
3657 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8);
|
|
3658 g_free(utf8);
|
|
3659 }
|
|
3660 g_string_append_printf(str, "<hr>");
|
|
3661 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
|
|
3662 g_string_append_printf(str, "<b>%s:</b>", _("Home Address"));
|
|
3663 oscar_string_convert_and_append(account, str, "\n<br>", _("Address"), info->homeaddr);
|
|
3664 oscar_string_convert_and_append(account, str, "\n<br>", _("City"), info->homecity);
|
|
3665 oscar_string_convert_and_append(account, str, "\n<br>", _("State"), info->homestate);
|
|
3666 oscar_string_convert_and_append(account, str, "\n<br>", _("Zip Code"), info->homezip);
|
|
3667 g_string_append_printf(str, "\n<hr>");
|
|
3668 }
|
|
3669 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
|
|
3670 g_string_append_printf(str, "<b>%s:</b>", _("Work Address"));
|
|
3671 oscar_string_convert_and_append(account, str, "\n<br>", _("Address"), info->workaddr);
|
|
3672 oscar_string_convert_and_append(account, str, "\n<br>", _("City"), info->workcity);
|
|
3673 oscar_string_convert_and_append(account, str, "\n<br>", _("State"), info->workstate);
|
|
3674 oscar_string_convert_and_append(account, str, "\n<br>", _("Zip Code"), info->workzip);
|
|
3675 g_string_append_printf(str, "\n<hr>");
|
|
3676 }
|
|
3677 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
|
|
3678 g_string_append_printf(str, "<b>%s:</b>", _("Work Information"));
|
|
3679 oscar_string_convert_and_append(account, str, "\n<br>", _("Company"), info->workcompany);
|
|
3680 oscar_string_convert_and_append(account, str, "\n<br>", _("Division"), info->workdivision);
|
|
3681 oscar_string_convert_and_append(account, str, "\n<br>", _("Position"), info->workposition);
|
|
3682 if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) {
|
|
3683 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8);
|
|
3684 g_free(utf8);
|
|
3685 }
|
|
3686 g_string_append_printf(str, "\n<hr>");
|
|
3687 }
|
|
3688
|
|
3689 if (buddy != NULL)
|
|
3690 alias = gaim_buddy_get_alias(buddy);
|
|
3691 else
|
|
3692 alias = who;
|
|
3693 gaim_notify_userinfo(gc, who, str->str, NULL, NULL);
|
|
3694 g_string_free(str, TRUE);
|
|
3695
|
|
3696 return 1;
|
|
3697 }
|
|
3698
|
|
3699 static int gaim_icqalias(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3700 {
|
|
3701 GaimConnection *gc = od->gc;
|
|
3702 GaimAccount *account = gaim_connection_get_account(gc);
|
|
3703 gchar who[16], *utf8;
|
|
3704 GaimBuddy *b;
|
|
3705 va_list ap;
|
|
3706 struct aim_icq_info *info;
|
|
3707
|
|
3708 va_start(ap, fr);
|
|
3709 info = va_arg(ap, struct aim_icq_info *);
|
|
3710 va_end(ap);
|
|
3711
|
|
3712 if (info->uin && info->nick && info->nick[0] && (utf8 = oscar_utf8_try_convert(account, info->nick))) {
|
|
3713 g_snprintf(who, sizeof(who), "%u", info->uin);
|
|
3714 serv_got_alias(gc, who, utf8);
|
|
3715 if ((b = gaim_find_buddy(gc->account, who))) {
|
|
3716 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8);
|
|
3717 }
|
|
3718 g_free(utf8);
|
|
3719 }
|
|
3720
|
|
3721 return 1;
|
|
3722 }
|
|
3723
|
|
3724 static int gaim_popup(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3725 {
|
|
3726 GaimConnection *gc = od->gc;
|
|
3727 gchar *text;
|
|
3728 va_list ap;
|
|
3729 char *msg, *url;
|
|
3730 guint16 wid, hei, delay;
|
|
3731
|
|
3732 va_start(ap, fr);
|
|
3733 msg = va_arg(ap, char *);
|
|
3734 url = va_arg(ap, char *);
|
|
3735 wid = (guint16) va_arg(ap, int);
|
|
3736 hei = (guint16) va_arg(ap, int);
|
|
3737 delay = (guint16) va_arg(ap, int);
|
|
3738 va_end(ap);
|
|
3739
|
|
3740 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url);
|
|
3741 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL);
|
|
3742 g_free(text);
|
|
3743
|
|
3744 return 1;
|
|
3745 }
|
|
3746
|
|
3747 static void oscar_searchresults_add_buddy_cb(GaimConnection *gc, GList *row, void *user_data)
|
|
3748 {
|
|
3749 gaim_blist_request_add_buddy(gaim_connection_get_account(gc),
|
|
3750 g_list_nth_data(row, 0), NULL, NULL);
|
|
3751 }
|
|
3752
|
|
3753 static int gaim_parse_searchreply(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3754 {
|
|
3755 GaimConnection *gc = od->gc;
|
|
3756 GaimNotifySearchResults *results;
|
|
3757 GaimNotifySearchColumn *column;
|
|
3758 gchar *secondary;
|
|
3759 int i, num;
|
|
3760 va_list ap;
|
|
3761 char *email, *SNs;
|
|
3762
|
|
3763 va_start(ap, fr);
|
|
3764 email = va_arg(ap, char *);
|
|
3765 num = va_arg(ap, int);
|
|
3766 SNs = va_arg(ap, char *);
|
|
3767 va_end(ap);
|
|
3768
|
|
3769 results = gaim_notify_searchresults_new();
|
|
3770
|
|
3771 if (results == NULL) {
|
|
3772 gaim_debug_error("oscar", "gaim_parse_searchreply: "
|
|
3773 "Unable to display the search results.\n");
|
|
3774 gaim_notify_error(gc, NULL,
|
|
3775 _("Unable to display the search results."),
|
|
3776 NULL);
|
|
3777 return 1;
|
|
3778 }
|
|
3779
|
|
3780 secondary = g_strdup_printf(
|
|
3781 ngettext("The following screen name is associated with %s",
|
|
3782 "The following screen names are associated with %s",
|
|
3783 num),
|
|
3784 email);
|
|
3785
|
|
3786 column = gaim_notify_searchresults_column_new(_("Screen name"));
|
|
3787 gaim_notify_searchresults_column_add(results, column);
|
|
3788
|
|
3789 for (i = 0; i < num; i++) {
|
|
3790 GList *row = NULL;
|
|
3791 row = g_list_append(row, g_strdup(&SNs[i * (MAXSNLEN + 1)]));
|
|
3792 gaim_notify_searchresults_row_add(results, row);
|
|
3793 }
|
|
3794 gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD,
|
|
3795 oscar_searchresults_add_buddy_cb);
|
|
3796 gaim_notify_searchresults(gc, NULL, NULL, secondary, results, NULL, NULL);
|
|
3797
|
|
3798 g_free(secondary);
|
|
3799
|
|
3800 return 1;
|
|
3801 }
|
|
3802
|
|
3803 static int gaim_parse_searcherror(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3804 va_list ap;
|
|
3805 char *email;
|
|
3806 char *buf;
|
|
3807
|
|
3808 va_start(ap, fr);
|
|
3809 email = va_arg(ap, char *);
|
|
3810 va_end(ap);
|
|
3811
|
|
3812 buf = g_strdup_printf(_("No results found for e-mail address %s"), email);
|
|
3813 gaim_notify_error(od->gc, NULL, buf, NULL);
|
|
3814 g_free(buf);
|
|
3815
|
|
3816 return 1;
|
|
3817 }
|
|
3818
|
|
3819 static int gaim_account_confirm(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3820 GaimConnection *gc = od->gc;
|
|
3821 guint16 status;
|
|
3822 va_list ap;
|
|
3823 char msg[256];
|
|
3824
|
|
3825 va_start(ap, fr);
|
|
3826 status = (guint16) va_arg(ap, unsigned int); /* status code of confirmation request */
|
|
3827 va_end(ap);
|
|
3828
|
|
3829 gaim_debug_info("oscar",
|
|
3830 "account confirmation returned status 0x%04x (%s)\n", status,
|
|
3831 status ? "unknown" : "e-mail sent");
|
|
3832 if (!status) {
|
|
3833 g_snprintf(msg, sizeof(msg), _("You should receive an e-mail asking to confirm %s."),
|
|
3834 gaim_account_get_username(gaim_connection_get_account(gc)));
|
|
3835 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg);
|
|
3836 }
|
|
3837
|
|
3838 return 1;
|
|
3839 }
|
|
3840
|
|
3841 static int gaim_info_change(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3842 GaimConnection *gc = od->gc;
|
|
3843 va_list ap;
|
|
3844 guint16 perms, err;
|
|
3845 char *url, *sn, *email;
|
|
3846 int change;
|
|
3847
|
|
3848 va_start(ap, fr);
|
|
3849 change = va_arg(ap, int);
|
|
3850 perms = (guint16) va_arg(ap, unsigned int);
|
|
3851 err = (guint16) va_arg(ap, unsigned int);
|
|
3852 url = va_arg(ap, char *);
|
|
3853 sn = va_arg(ap, char *);
|
|
3854 email = va_arg(ap, char *);
|
|
3855 va_end(ap);
|
|
3856
|
|
3857 gaim_debug_misc("oscar",
|
|
3858 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n",
|
|
3859 change ? "change" : "request", perms, err,
|
|
3860 (url != NULL) ? url : "(null)",
|
|
3861 (sn != NULL) ? sn : "(null)",
|
|
3862 (email != NULL) ? email : "(null)");
|
|
3863
|
|
3864 if ((err > 0) && (url != NULL)) {
|
|
3865 char *dialog_msg;
|
|
3866 char *dialog_top = g_strdup_printf(_("Error Changing Account Info"));
|
|
3867 switch (err) {
|
|
3868 case 0x0001: {
|
|
3869 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err);
|
|
3870 } break;
|
|
3871 case 0x0006: {
|
|
3872 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because it is invalid."), err);
|
|
3873 } break;
|
|
3874 case 0x000b: {
|
|
3875 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err);
|
|
3876 } break;
|
|
3877 case 0x001d: {
|
|
3878 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because there is already a request pending for this screen name."), err);
|
|
3879 } break;
|
|
3880 case 0x0021: {
|
|
3881 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because the given address has too many screen names associated with it."), err);
|
|
3882 } break;
|
|
3883 case 0x0023: {
|
|
3884 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because the given address is invalid."), err);
|
|
3885 } break;
|
|
3886 default: {
|
|
3887 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err);
|
|
3888 } break;
|
|
3889 }
|
|
3890 gaim_notify_error(gc, NULL, dialog_top, dialog_msg);
|
|
3891 g_free(dialog_top);
|
|
3892 g_free(dialog_msg);
|
|
3893 return 1;
|
|
3894 }
|
|
3895
|
|
3896 if (sn != NULL) {
|
|
3897 char *dialog_msg = g_strdup_printf(_("Your screen name is currently formatted as follows:\n%s"), sn);
|
|
3898 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg);
|
|
3899 g_free(dialog_msg);
|
|
3900 }
|
|
3901
|
|
3902 if (email != NULL) {
|
|
3903 char *dialog_msg = g_strdup_printf(_("The e-mail address for %s is %s"),
|
|
3904 gaim_account_get_username(gaim_connection_get_account(gc)), email);
|
|
3905 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg);
|
|
3906 g_free(dialog_msg);
|
|
3907 }
|
|
3908
|
|
3909 return 1;
|
|
3910 }
|
|
3911
|
|
3912 static void
|
|
3913 oscar_keepalive(GaimConnection *gc)
|
|
3914 {
|
|
3915 OscarData *od;
|
|
3916 FlapConnection *conn;
|
|
3917
|
|
3918 od = (OscarData *)gc->proto_data;
|
|
3919 conn = flap_connection_getbytype(od, SNAC_FAMILY_LOCATE);
|
|
3920 if (conn != NULL)
|
|
3921 flap_connection_send_keepalive(od, conn);
|
|
3922 }
|
|
3923
|
|
3924 static unsigned int
|
|
3925 oscar_send_typing(GaimConnection *gc, const char *name, GaimTypingState state)
|
|
3926 {
|
|
3927 OscarData *od;
|
|
3928 PeerConnection *conn;
|
|
3929
|
|
3930 od = (OscarData *)gc->proto_data;
|
|
3931 conn = peer_connection_find_by_type(od, name, OSCAR_CAPABILITY_DIRECTIM);
|
|
3932
|
|
3933 if ((conn != NULL) && (conn->ready))
|
|
3934 {
|
|
3935 peer_odc_send_typing(conn, state);
|
|
3936 }
|
|
3937 else {
|
|
3938 /* Don't send if this turkey is in our deny list */
|
|
3939 GSList *list;
|
|
3940 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next);
|
|
3941 if (!list) {
|
|
3942 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name));
|
|
3943 if (bi && bi->typingnot) {
|
|
3944 if (state == GAIM_TYPING)
|
|
3945 aim_im_sendmtn(od, 0x0001, name, 0x0002);
|
|
3946 else if (state == GAIM_TYPED)
|
|
3947 aim_im_sendmtn(od, 0x0001, name, 0x0001);
|
|
3948 else
|
|
3949 aim_im_sendmtn(od, 0x0001, name, 0x0000);
|
|
3950 }
|
|
3951 }
|
|
3952 }
|
|
3953 return 0;
|
|
3954 }
|
|
3955
|
|
3956 /* TODO: Move this into odc.c! */
|
|
3957 static void
|
|
3958 gaim_odc_send_im(PeerConnection *conn, const char *message, GaimMessageFlags imflags)
|
|
3959 {
|
|
3960 GString *msg;
|
|
3961 GString *data;
|
|
3962 gchar *tmp;
|
|
3963 int tmplen;
|
|
3964 guint16 charset, charsubset;
|
|
3965 GData *attribs;
|
|
3966 const char *start, *end, *last;
|
|
3967 int oscar_id = 0;
|
|
3968
|
|
3969 msg = g_string_new("<HTML><BODY>");
|
|
3970 data = g_string_new("<BINARY>");
|
|
3971 last = message;
|
|
3972
|
|
3973 /* for each valid IMG tag... */
|
|
3974 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs))
|
|
3975 {
|
|
3976 GaimStoredImage *image = NULL;
|
|
3977 const char *id;
|
|
3978
|
|
3979 if (start - last) {
|
|
3980 g_string_append_len(msg, last, start - last);
|
|
3981 }
|
|
3982
|
|
3983 id = g_datalist_get_data(&attribs, "id");
|
|
3984
|
|
3985 /* ... if it refers to a valid gaim image ... */
|
|
3986 if (id && (image = gaim_imgstore_get(atoi(id)))) {
|
|
3987 /* ... append the message from start to the tag ... */
|
|
3988 unsigned long size = gaim_imgstore_get_size(image);
|
|
3989 const char *filename = gaim_imgstore_get_filename(image);
|
|
3990 gpointer imgdata = gaim_imgstore_get_data(image);
|
|
3991
|
|
3992 oscar_id++;
|
|
3993
|
|
3994 /* ... insert a new img tag with the oscar id ... */
|
|
3995 if (filename)
|
|
3996 g_string_append_printf(msg,
|
|
3997 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">",
|
|
3998 filename, oscar_id, size);
|
|
3999 else
|
|
4000 g_string_append_printf(msg,
|
|
4001 "<IMG ID=\"%d\" DATASIZE=\"%lu\">",
|
|
4002 oscar_id, size);
|
|
4003
|
|
4004 /* ... and append the data to the binary section ... */
|
|
4005 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">",
|
|
4006 oscar_id, size);
|
|
4007 g_string_append_len(data, imgdata, size);
|
|
4008 g_string_append(data, "</DATA>");
|
|
4009 }
|
|
4010 /* If the tag is invalid, skip it, thus no else here */
|
|
4011
|
|
4012 g_datalist_clear(&attribs);
|
|
4013
|
|
4014 /* continue from the end of the tag */
|
|
4015 last = end + 1;
|
|
4016 }
|
|
4017
|
|
4018 /* append any remaining message data */
|
|
4019 if (last && *last)
|
|
4020 g_string_append(msg, last);
|
|
4021
|
|
4022 g_string_append(msg, "</BODY></HTML>");
|
|
4023
|
|
4024 /* Convert the message to a good encoding */
|
|
4025 gaim_plugin_oscar_convert_to_best_encoding(conn->od->gc,
|
|
4026 conn->sn, msg->str, &tmp, &tmplen, &charset, &charsubset);
|
|
4027 g_string_free(msg, TRUE);
|
|
4028 msg = g_string_new_len(tmp, tmplen);
|
|
4029
|
|
4030 /* Append any binary data that we may have */
|
|
4031 if (oscar_id) {
|
|
4032 msg = g_string_append_len(msg, data->str, data->len);
|
|
4033 msg = g_string_append(msg, "</BINARY>");
|
|
4034 }
|
|
4035 g_string_free(data, TRUE);
|
|
4036
|
|
4037 peer_odc_send_im(conn, msg->str, msg->len, charset,
|
|
4038 imflags & GAIM_MESSAGE_AUTO_RESP);
|
|
4039 g_string_free(msg, TRUE);
|
|
4040 }
|
|
4041
|
|
4042 static int
|
|
4043 oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimMessageFlags imflags)
|
|
4044 {
|
|
4045 OscarData *od;
|
|
4046 GaimAccount *account;
|
|
4047 PeerConnection *conn;
|
|
4048 int ret;
|
|
4049 char *iconfile;
|
|
4050 char *tmp1, *tmp2;
|
|
4051
|
|
4052 od = (OscarData *)gc->proto_data;
|
|
4053 account = gaim_connection_get_account(gc);
|
|
4054 ret = 0;
|
|
4055 iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account));
|
|
4056
|
|
4057 if (imflags & GAIM_MESSAGE_AUTO_RESP)
|
|
4058 tmp1 = gaim_str_sub_away_formatters(message, name);
|
|
4059 else
|
|
4060 tmp1 = g_strdup(message);
|
|
4061
|
|
4062 conn = peer_connection_find_by_type(od, name, OSCAR_CAPABILITY_DIRECTIM);
|
|
4063 if ((conn != NULL) && (conn->ready))
|
|
4064 {
|
|
4065 /* If we're directly connected, send a direct IM */
|
|
4066 gaim_odc_send_im(conn, tmp1, imflags);
|
|
4067 } else {
|
|
4068 struct buddyinfo *bi;
|
|
4069 struct aim_sendimext_args args;
|
|
4070 struct stat st;
|
|
4071 gsize len;
|
|
4072 GaimConversation *conv;
|
|
4073
|
|
4074 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account);
|
|
4075
|
|
4076 if (strstr(tmp1, "<IMG "))
|
|
4077 gaim_conversation_write(conv, "",
|
|
4078 _("Your IM Image was not sent. "
|
|
4079 "You must be Direct Connected to send IM Images."),
|
|
4080 GAIM_MESSAGE_ERROR, time(NULL));
|
|
4081
|
|
4082 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name));
|
|
4083 if (!bi) {
|
|
4084 bi = g_new0(struct buddyinfo, 1);
|
|
4085 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi);
|
|
4086 }
|
|
4087
|
|
4088 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES;
|
|
4089 if (od->icq) {
|
|
4090 /* We have to present different "features" (whose meaning
|
|
4091 is unclear and are merely a result of protocol inspection)
|
|
4092 to offline ICQ buddies. Otherwise, the official
|
|
4093 ICQ client doesn't treat those messages as being "ANSI-
|
|
4094 encoded" (and instead, assumes them to be UTF-8).
|
|
4095 For more details, see SF issue 1179452.
|
|
4096 */
|
|
4097 GaimBuddy *buddy = gaim_find_buddy(gc->account, name);
|
|
4098 if (buddy && GAIM_BUDDY_IS_ONLINE(buddy)) {
|
|
4099 args.features = features_icq;
|
|
4100 args.featureslen = sizeof(features_icq);
|
|
4101 } else {
|
|
4102 args.features = features_icq_offline;
|
|
4103 args.featureslen = sizeof(features_icq_offline);
|
|
4104 }
|
|
4105 args.flags |= AIM_IMFLAGS_OFFLINE;
|
|
4106 } else {
|
|
4107 args.features = features_aim;
|
|
4108 args.featureslen = sizeof(features_aim);
|
|
4109
|
|
4110 if (imflags & GAIM_MESSAGE_AUTO_RESP)
|
|
4111 args.flags |= AIM_IMFLAGS_AWAY;
|
|
4112 }
|
|
4113
|
|
4114 if (bi->ico_need) {
|
|
4115 gaim_debug_info("oscar",
|
|
4116 "Sending buddy icon request with message\n");
|
|
4117 args.flags |= AIM_IMFLAGS_BUDDYREQ;
|
|
4118 bi->ico_need = FALSE;
|
|
4119 }
|
|
4120
|
|
4121 if (iconfile && !g_stat(iconfile, &st)) {
|
|
4122 FILE *file = g_fopen(iconfile, "rb");
|
|
4123 if (file) {
|
|
4124 guchar *buf = g_malloc(st.st_size);
|
|
4125 /* TODO: Use g_file_get_contents()? */
|
|
4126 fread(buf, 1, st.st_size, file);
|
|
4127 fclose(file);
|
|
4128
|
|
4129 args.iconlen = st.st_size;
|
|
4130 args.iconsum = aimutil_iconsum(buf, st.st_size);
|
|
4131 args.iconstamp = st.st_mtime;
|
|
4132
|
|
4133 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) {
|
|
4134 bi->ico_informed = FALSE;
|
|
4135 bi->ico_sent = FALSE;
|
|
4136 }
|
|
4137
|
14282
|
4138 /*
|
|
4139 * TODO:
|
|
4140 * For some reason sending our icon to people only works
|
|
4141 * when we're the ones who initiated the conversation. If
|
|
4142 * the other person sends the first IM then they never get
|
|
4143 * the icon. We should fix that.
|
|
4144 */
|
14192
|
4145 if (!bi->ico_informed) {
|
|
4146 gaim_debug_info("oscar",
|
|
4147 "Claiming to have a buddy icon\n");
|
|
4148 args.flags |= AIM_IMFLAGS_HASICON;
|
|
4149 bi->ico_me_len = args.iconlen;
|
|
4150 bi->ico_me_csum = args.iconsum;
|
|
4151 bi->ico_me_time = args.iconstamp;
|
|
4152 bi->ico_informed = TRUE;
|
|
4153 }
|
|
4154
|
|
4155 g_free(buf);
|
|
4156 }
|
|
4157 }
|
|
4158 g_free(iconfile);
|
|
4159
|
|
4160 args.destsn = name;
|
|
4161
|
|
4162 /*
|
|
4163 * If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML.
|
|
4164 */
|
|
4165 if (aim_sn_is_sms(name)) {
|
|
4166 /* Messaging an SMS (mobile) user */
|
|
4167 tmp2 = gaim_unescape_html(tmp1);
|
|
4168 } else if (aim_sn_is_icq(gaim_account_get_username(account))) {
|
|
4169 if (aim_sn_is_icq(name))
|
|
4170 /* From ICQ to ICQ */
|
|
4171 tmp2 = gaim_unescape_html(tmp1);
|
|
4172 else
|
|
4173 /* From ICQ to AIM */
|
|
4174 tmp2 = g_strdup(tmp1);
|
|
4175 } else {
|
|
4176 /* From AIM to AIM and AIM to ICQ */
|
|
4177 tmp2 = g_strdup(tmp1);
|
|
4178 }
|
|
4179 g_free(tmp1);
|
|
4180 tmp1 = tmp2;
|
|
4181 len = strlen(tmp1);
|
|
4182
|
|
4183 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmp1, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset);
|
|
4184 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n",
|
|
4185 args.charset, args.charsubset, args.msglen);
|
|
4186 ret = aim_im_sendch1_ext(od, &args);
|
|
4187 g_free((char *)args.msg);
|
|
4188 }
|
|
4189
|
|
4190 g_free(tmp1);
|
|
4191
|
|
4192 if (ret >= 0)
|
|
4193 return 1;
|
|
4194
|
|
4195 return ret;
|
|
4196 }
|
|
4197
|
|
4198 /*
|
|
4199 * As of 26 June 2006, ICQ users can request AIM info from
|
|
4200 * everyone, and can request ICQ info from ICQ users, and
|
|
4201 * AIM users can only request AIM info.
|
|
4202 */
|
|
4203 static void oscar_get_info(GaimConnection *gc, const char *name) {
|
|
4204 OscarData *od = (OscarData *)gc->proto_data;
|
|
4205
|
|
4206 if (od->icq && aim_sn_is_icq(name))
|
|
4207 aim_icq_getallinfo(od, name);
|
|
4208 else
|
|
4209 aim_locate_getinfoshort(od, name, 0x00000003);
|
|
4210 }
|
|
4211
|
|
4212 #if 0
|
|
4213 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last,
|
|
4214 const char *maiden, const char *city, const char *state, const char *country, int web) {
|
|
4215 /* XXX - some of these things are wrong, but i'm lazy */
|
|
4216 OscarData *od = (OscarData *)gc->proto_data;
|
|
4217 aim_locate_setdirinfo(od, first, middle, last,
|
|
4218 maiden, NULL, NULL, city, state, NULL, 0, web);
|
|
4219 }
|
|
4220 #endif
|
|
4221
|
|
4222 static void oscar_set_idle(GaimConnection *gc, int time) {
|
|
4223 OscarData *od = (OscarData *)gc->proto_data;
|
|
4224 aim_srv_setidle(od, time);
|
|
4225 }
|
|
4226
|
|
4227 static
|
|
4228 gchar *gaim_prpl_oscar_convert_to_infotext(const gchar *str, gsize *ret_len, char **encoding)
|
|
4229 {
|
|
4230 int charset = 0;
|
|
4231 char *encoded = NULL;
|
|
4232
|
|
4233 charset = oscar_charset_check(str);
|
|
4234 if (charset == AIM_CHARSET_UNICODE) {
|
|
4235 encoded = g_convert(str, strlen(str), "UCS-2BE", "UTF-8", NULL, ret_len, NULL);
|
|
4236 *encoding = "unicode-2-0";
|
|
4237 } else if (charset == AIM_CHARSET_CUSTOM) {
|
|
4238 encoded = g_convert(str, strlen(str), "ISO-8859-1", "UTF-8", NULL, ret_len, NULL);
|
|
4239 *encoding = "iso-8859-1";
|
|
4240 } else {
|
|
4241 encoded = g_strdup(str);
|
|
4242 *ret_len = strlen(str);
|
|
4243 *encoding = "us-ascii";
|
|
4244 }
|
|
4245
|
|
4246 return encoded;
|
|
4247 }
|
|
4248
|
|
4249 static void
|
|
4250 oscar_set_info(GaimConnection *gc, const char *rawinfo)
|
|
4251 {
|
|
4252 GaimAccount *account;
|
|
4253 GaimStatus *status;
|
|
4254
|
|
4255 account = gaim_connection_get_account(gc);
|
|
4256 status = gaim_account_get_active_status(account);
|
|
4257 oscar_set_info_and_status(account, TRUE, rawinfo, FALSE, status);
|
|
4258 }
|
|
4259
|
|
4260 static void
|
|
4261 oscar_set_extendedstatus(GaimConnection *gc)
|
|
4262 {
|
|
4263 OscarData *od;
|
|
4264 GaimAccount *account;
|
|
4265 GaimStatus *status;
|
|
4266 const gchar *status_id;
|
|
4267 guint32 data = 0x00000000;
|
|
4268
|
|
4269 od = gc->proto_data;
|
|
4270 account = gaim_connection_get_account(gc);
|
|
4271 status = gaim_account_get_active_status(account);
|
|
4272 status_id = gaim_status_get_id(status);
|
|
4273
|
|
4274 data |= AIM_ICQ_STATE_HIDEIP;
|
|
4275 if (gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE))
|
|
4276 data |= AIM_ICQ_STATE_WEBAWARE;
|
|
4277
|
|
4278 if (!strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE) || !strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE))
|
|
4279 data |= AIM_ICQ_STATE_NORMAL;
|
|
4280 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY))
|
|
4281 data |= AIM_ICQ_STATE_AWAY;
|
|
4282 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND))
|
|
4283 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY;
|
|
4284 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA))
|
|
4285 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY;
|
|
4286 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED))
|
|
4287 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY;
|
|
4288 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT))
|
|
4289 data |= AIM_ICQ_STATE_CHAT;
|
|
4290 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE))
|
|
4291 data |= AIM_ICQ_STATE_INVISIBLE;
|
|
4292 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM))
|
|
4293 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY;
|
|
4294
|
|
4295 aim_setextstatus(od, data);
|
|
4296 }
|
|
4297
|
|
4298 static void
|
|
4299 oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo,
|
|
4300 gboolean setstatus, GaimStatus *status)
|
|
4301 {
|
|
4302 GaimConnection *gc = gaim_account_get_connection(account);
|
|
4303 OscarData *od = gc->proto_data;
|
|
4304 GaimPresence *presence;
|
|
4305 GaimStatusType *status_type;
|
|
4306 GaimStatusPrimitive primitive;
|
|
4307 gboolean invisible;
|
|
4308
|
|
4309 char *htmlinfo;
|
|
4310 char *info_encoding = NULL;
|
|
4311 char *info = NULL;
|
|
4312 gsize infolen = 0;
|
|
4313
|
|
4314 const char *htmlaway;
|
|
4315 char *away_encoding = NULL;
|
|
4316 char *away = NULL;
|
|
4317 gsize awaylen = 0;
|
|
4318
|
|
4319 status_type = gaim_status_get_type(status);
|
|
4320 primitive = gaim_status_type_get_primitive(status_type);
|
|
4321 presence = gaim_account_get_presence(account);
|
|
4322 invisible = gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE);
|
|
4323
|
|
4324 if (!setinfo)
|
|
4325 {
|
|
4326 /* Do nothing! */
|
|
4327 }
|
|
4328 else if (od->rights.maxsiglen == 0)
|
|
4329 {
|
|
4330 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."),
|
|
4331 _("You have probably requested to set your "
|
|
4332 "profile before the login procedure completed. "
|
|
4333 "Your profile remains unset; try setting it "
|
|
4334 "again when you are fully connected."));
|
|
4335 }
|
|
4336 else if (rawinfo != NULL)
|
|
4337 {
|
|
4338 htmlinfo = gaim_strdup_withhtml(rawinfo);
|
|
4339 info = gaim_prpl_oscar_convert_to_infotext(htmlinfo, &infolen, &info_encoding);
|
|
4340 g_free(htmlinfo);
|
|
4341
|
|
4342 if (infolen > od->rights.maxsiglen)
|
|
4343 {
|
|
4344 gchar *errstr;
|
|
4345 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte "
|
|
4346 "has been exceeded. Gaim has truncated it for you.",
|
|
4347 "The maximum profile length of %d bytes "
|
|
4348 "has been exceeded. Gaim has truncated it for you.",
|
|
4349 od->rights.maxsiglen), od->rights.maxsiglen);
|
|
4350 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr);
|
|
4351 g_free(errstr);
|
|
4352 }
|
|
4353 }
|
|
4354
|
|
4355 if (!setstatus)
|
|
4356 {
|
|
4357 /* Do nothing! */
|
|
4358 }
|
|
4359 else if (primitive == GAIM_STATUS_AVAILABLE)
|
|
4360 {
|
|
4361 const char *status_html;
|
|
4362 char *status_text = NULL;
|
|
4363
|
|
4364 status_html = gaim_status_get_attr_string(status, "message");
|
|
4365 if (status_html != NULL)
|
|
4366 {
|
|
4367 status_text = gaim_markup_strip_html(status_html);
|
|
4368 /* If the status_text is longer than 60 character then truncate it */
|
|
4369 if (strlen(status_text) > 60)
|
|
4370 {
|
|
4371 char *tmp = g_utf8_find_prev_char(status_text, &status_text[58]);
|
|
4372 strcpy(tmp, "...");
|
|
4373 }
|
|
4374 }
|
|
4375
|
|
4376 aim_srv_setstatusmsg(od, status_text);
|
|
4377 g_free(status_text);
|
|
4378
|
|
4379 /* This is needed for us to un-set any previous away message. */
|
|
4380 away = g_strdup("");
|
|
4381 }
|
|
4382 else if ((primitive == GAIM_STATUS_AWAY) ||
|
|
4383 (primitive == GAIM_STATUS_EXTENDED_AWAY))
|
|
4384 {
|
|
4385 htmlaway = gaim_status_get_attr_string(status, "message");
|
|
4386 if ((htmlaway == NULL) || (*htmlaway == '\0'))
|
|
4387 htmlaway = _("Away");
|
|
4388 away = gaim_prpl_oscar_convert_to_infotext(htmlaway, &awaylen, &away_encoding);
|
|
4389
|
|
4390 if (awaylen > od->rights.maxawaymsglen)
|
|
4391 {
|
|
4392 gchar *errstr;
|
|
4393
|
|
4394 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte "
|
|
4395 "has been exceeded. Gaim has truncated it for you.",
|
|
4396 "The maximum away message length of %d bytes "
|
|
4397 "has been exceeded. Gaim has truncated it for you.",
|
|
4398 od->rights.maxawaymsglen), od->rights.maxawaymsglen);
|
|
4399 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr);
|
|
4400 g_free(errstr);
|
|
4401 }
|
|
4402 }
|
|
4403
|
|
4404 if (setstatus)
|
|
4405 oscar_set_extendedstatus(gc);
|
|
4406
|
|
4407 aim_locate_setprofile(od, info_encoding, info, MIN(infolen, od->rights.maxsiglen),
|
|
4408 away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen));
|
|
4409 g_free(info);
|
|
4410 g_free(away);
|
|
4411 }
|
|
4412
|
|
4413 static void
|
|
4414 oscar_set_status_icq(GaimAccount *account, GaimStatus *status)
|
|
4415 {
|
|
4416 GaimConnection *gc = gaim_account_get_connection(account);
|
|
4417 OscarData *od = NULL;
|
|
4418
|
|
4419 if (gc)
|
|
4420 od = (OscarData *)gc->proto_data;
|
|
4421 if (!od)
|
|
4422 return;
|
|
4423
|
|
4424 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_INVISIBLE)
|
|
4425 account->perm_deny = GAIM_PRIVACY_ALLOW_USERS;
|
|
4426 else
|
|
4427 account->perm_deny = GAIM_PRIVACY_DENY_USERS;
|
|
4428
|
|
4429 if ((od->ssi.received_data) && (aim_ssi_getpermdeny(od->ssi.local) != account->perm_deny))
|
|
4430 aim_ssi_setpermdeny(od, account->perm_deny, 0xffffffff);
|
|
4431
|
|
4432 oscar_set_extendedstatus(gc);
|
|
4433 }
|
|
4434
|
|
4435 static void
|
|
4436 oscar_set_status(GaimAccount *account, GaimStatus *status)
|
|
4437 {
|
|
4438 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status));
|
|
4439
|
|
4440 if (!gaim_status_is_active(status))
|
|
4441 return;
|
|
4442
|
|
4443 if (!gaim_account_is_connected(account))
|
|
4444 return;
|
|
4445
|
|
4446 /* Set the AIM-style away message for both AIM and ICQ accounts */
|
|
4447 oscar_set_info_and_status(account, FALSE, NULL, TRUE, status);
|
|
4448
|
|
4449 /* Set the ICQ status for ICQ accounts only */
|
|
4450 if (aim_sn_is_icq(gaim_account_get_username(account)))
|
|
4451 oscar_set_status_icq(account, status);
|
|
4452 }
|
|
4453
|
|
4454 #ifdef CRAZY_WARN
|
|
4455 static void
|
|
4456 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) {
|
|
4457 OscarData *od = (OscarData *)gc->proto_data;
|
|
4458 aim_im_warn(od, od->conn, name, anonymous ? AIM_WARN_ANON : 0);
|
|
4459 }
|
|
4460 #endif
|
|
4461
|
|
4462 static void
|
|
4463 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {
|
|
4464 OscarData *od = (OscarData *)gc->proto_data;
|
|
4465
|
|
4466 if (!aim_snvalid(buddy->name)) {
|
|
4467 gchar *buf;
|
|
4468 buf = g_strdup_printf(_("Could not add the buddy %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name);
|
|
4469 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf))
|
|
4470 gaim_notify_error(gc, NULL, _("Unable To Add"), buf);
|
|
4471 g_free(buf);
|
|
4472
|
|
4473 /* Remove from local list */
|
|
4474 gaim_blist_remove_buddy(buddy);
|
|
4475
|
|
4476 return;
|
|
4477 }
|
|
4478
|
|
4479 if ((od->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) {
|
|
4480 gaim_debug_info("oscar",
|
|
4481 "ssi: adding buddy %s to group %s\n", buddy->name, group->name);
|
|
4482 aim_ssi_addbuddy(od, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0);
|
|
4483 }
|
|
4484
|
|
4485 /* XXX - Should this be done from AIM accounts, as well? */
|
|
4486 if (od->icq)
|
|
4487 aim_icq_getalias(od, buddy->name);
|
|
4488 }
|
|
4489
|
|
4490 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {
|
|
4491 OscarData *od = (OscarData *)gc->proto_data;
|
|
4492
|
|
4493 if (od->ssi.received_data) {
|
|
4494 gaim_debug_info("oscar",
|
|
4495 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name);
|
|
4496 aim_ssi_delbuddy(od, buddy->name, group->name);
|
|
4497 }
|
|
4498 }
|
|
4499
|
|
4500 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) {
|
|
4501 OscarData *od = (OscarData *)gc->proto_data;
|
|
4502 if (od->ssi.received_data && strcmp(old_group, new_group)) {
|
|
4503 gaim_debug_info("oscar",
|
|
4504 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group);
|
|
4505 aim_ssi_movebuddy(od, old_group, new_group, name);
|
|
4506 }
|
|
4507 }
|
|
4508
|
|
4509 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) {
|
|
4510 OscarData *od = (OscarData *)gc->proto_data;
|
|
4511 if (od->ssi.received_data) {
|
|
4512 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, name);
|
|
4513 if (gname) {
|
|
4514 gaim_debug_info("oscar",
|
|
4515 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)");
|
|
4516 aim_ssi_aliasbuddy(od, gname, name, alias);
|
|
4517 }
|
|
4518 }
|
|
4519 }
|
|
4520
|
|
4521 /*
|
|
4522 * FYI, the OSCAR SSI code removes empty groups automatically.
|
|
4523 */
|
|
4524 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) {
|
|
4525 OscarData *od = (OscarData *)gc->proto_data;
|
|
4526
|
|
4527 if (od->ssi.received_data) {
|
|
4528 if (aim_ssi_itemlist_finditem(od->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) {
|
|
4529 GList *cur, *groups = NULL;
|
|
4530 GaimAccount *account = gaim_connection_get_account(gc);
|
|
4531
|
|
4532 /* Make a list of what the groups each buddy is in */
|
|
4533 for (cur = moved_buddies; cur != NULL; cur = cur->next) {
|
|
4534 GaimBlistNode *node = cur->data;
|
|
4535 /* node is GaimBuddy, parent is a GaimContact.
|
|
4536 * We must go two levels up to get the Group */
|
|
4537 groups = g_list_append(groups,
|
|
4538 node->parent->parent);
|
|
4539 }
|
|
4540
|
|
4541 gaim_account_remove_buddies(account, moved_buddies, groups);
|
|
4542 gaim_account_add_buddies(account, moved_buddies);
|
|
4543 g_list_free(groups);
|
|
4544 gaim_debug_info("oscar",
|
|
4545 "ssi: moved all buddies from group %s to %s\n", old_name, group->name);
|
|
4546 } else {
|
|
4547 aim_ssi_rename_group(od, old_name, group->name);
|
|
4548 gaim_debug_info("oscar",
|
|
4549 "ssi: renamed group %s to %s\n", old_name, group->name);
|
|
4550 }
|
|
4551 }
|
|
4552 }
|
|
4553
|
|
4554 static gboolean gaim_ssi_rerequestdata(gpointer data) {
|
|
4555 OscarData *od = data;
|
|
4556
|
|
4557 aim_ssi_reqdata(od);
|
|
4558
|
|
4559 return TRUE;
|
|
4560 }
|
|
4561
|
|
4562 static int gaim_ssi_parseerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4563 GaimConnection *gc = od->gc;
|
|
4564 va_list ap;
|
|
4565 guint16 reason;
|
|
4566
|
|
4567 va_start(ap, fr);
|
|
4568 reason = (guint16)va_arg(ap, unsigned int);
|
|
4569 va_end(ap);
|
|
4570
|
|
4571 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason);
|
|
4572
|
|
4573 if (reason == 0x0005) {
|
|
4574 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"),
|
|
4575 _("Gaim was temporarily unable to retrieve your buddy list from the AIM servers. Your buddy list is not lost, and will probably become available in a few hours."));
|
|
4576 if (od->getblisttimer > 0)
|
|
4577 gaim_timeout_remove(od->getblisttimer);
|
|
4578 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od);
|
|
4579 }
|
|
4580
|
|
4581 oscar_set_extendedstatus(gc);
|
|
4582
|
|
4583 /* Activate SSI */
|
|
4584 /* Sending the enable causes other people to be able to see you, and you to see them */
|
|
4585 /* Make sure your privacy setting/invisibility is set how you want it before this! */
|
|
4586 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n");
|
|
4587 aim_ssi_enable(od);
|
|
4588
|
|
4589 return 1;
|
|
4590 }
|
|
4591
|
|
4592 static int gaim_ssi_parserights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4593 int i;
|
|
4594 va_list ap;
|
|
4595 int numtypes;
|
|
4596 guint16 *maxitems;
|
|
4597
|
|
4598 va_start(ap, fr);
|
|
4599 numtypes = va_arg(ap, int);
|
|
4600 maxitems = va_arg(ap, guint16 *);
|
|
4601 va_end(ap);
|
|
4602
|
|
4603 gaim_debug_misc("oscar", "ssi rights:");
|
|
4604
|
|
4605 for (i=0; i<numtypes; i++)
|
|
4606 gaim_debug_misc(NULL, " max type 0x%04x=%hd,",
|
|
4607 i, maxitems[i]);
|
|
4608
|
|
4609 gaim_debug_misc(NULL, "\n");
|
|
4610
|
|
4611 if (numtypes >= 0)
|
|
4612 od->rights.maxbuddies = maxitems[0];
|
|
4613 if (numtypes >= 1)
|
|
4614 od->rights.maxgroups = maxitems[1];
|
|
4615 if (numtypes >= 2)
|
|
4616 od->rights.maxpermits = maxitems[2];
|
|
4617 if (numtypes >= 3)
|
|
4618 od->rights.maxdenies = maxitems[3];
|
|
4619
|
|
4620 return 1;
|
|
4621 }
|
|
4622
|
|
4623 static int gaim_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
4624 {
|
|
4625 GaimConnection *gc;
|
|
4626 GaimAccount *account;
|
|
4627 GaimGroup *g;
|
|
4628 GaimBuddy *b;
|
|
4629 struct aim_ssi_item *curitem;
|
|
4630 guint32 tmp;
|
|
4631 va_list ap;
|
|
4632 guint16 fmtver, numitems;
|
|
4633 guint32 timestamp;
|
|
4634
|
|
4635 gc = od->gc;
|
|
4636 od = gc->proto_data;
|
|
4637 account = gaim_connection_get_account(gc);
|
|
4638
|
|
4639 va_start(ap, fr);
|
|
4640 fmtver = (guint16)va_arg(ap, int);
|
|
4641 numitems = (guint16)va_arg(ap, int);
|
|
4642 timestamp = va_arg(ap, guint32);
|
|
4643 va_end(ap);
|
|
4644
|
|
4645 /* Don't attempt to re-request our buddy list later */
|
|
4646 if (od->getblisttimer != 0)
|
|
4647 gaim_timeout_remove(od->getblisttimer);
|
|
4648 od->getblisttimer = 0;
|
|
4649
|
|
4650 gaim_debug_info("oscar",
|
|
4651 "ssi: syncing local list and server list\n");
|
|
4652
|
|
4653 if ((timestamp == 0) || (numitems == 0)) {
|
|
4654 gaim_debug_info("oscar", "Got AIM SSI with a 0 timestamp or 0 numitems--not syncing. This probably means your buddy list is empty.", NULL);
|
|
4655 return 1;
|
|
4656 }
|
|
4657
|
|
4658 /* Clean the buddy list */
|
|
4659 aim_ssi_cleanlist(od);
|
|
4660
|
|
4661 { /* If not in server list then prune from local list */
|
|
4662 GaimBlistNode *gnode, *cnode, *bnode;
|
|
4663 GaimBuddyList *blist;
|
|
4664 GSList *cur, *next;
|
|
4665
|
|
4666 /* Buddies */
|
|
4667 cur = NULL;
|
|
4668 if ((blist = gaim_get_blist()) != NULL) {
|
|
4669 for (gnode = blist->root; gnode; gnode = gnode->next) {
|
|
4670 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
|
|
4671 continue;
|
|
4672 g = (GaimGroup *)gnode;
|
|
4673 for (cnode = gnode->child; cnode; cnode = cnode->next) {
|
|
4674 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))
|
|
4675 continue;
|
|
4676 for (bnode = cnode->child; bnode; bnode = bnode->next) {
|
|
4677 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
|
|
4678 continue;
|
|
4679 b = (GaimBuddy *)bnode;
|
|
4680 if (b->account == gc->account) {
|
|
4681 if (aim_ssi_itemlist_exists(od->ssi.local, b->name)) {
|
|
4682 /* If the buddy is an ICQ user then load his nickname */
|
|
4683 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick");
|
|
4684 char *alias;
|
|
4685 if (servernick)
|
|
4686 serv_got_alias(gc, b->name, servernick);
|
|
4687
|
|
4688 /* Store local alias on server */
|
|
4689 alias = aim_ssi_getalias(od->ssi.local, g->name, b->name);
|
|
4690 if (!alias && b->alias && strlen(b->alias))
|
|
4691 aim_ssi_aliasbuddy(od, g->name, b->name, b->alias);
|
|
4692 g_free(alias);
|
|
4693 } else {
|
|
4694 gaim_debug_info("oscar",
|
|
4695 "ssi: removing buddy %s from local list\n", b->name);
|
|
4696 /* We can't actually remove now because it will screw up our looping */
|
|
4697 cur = g_slist_prepend(cur, b);
|
|
4698 }
|
|
4699 }
|
|
4700 }
|
|
4701 }
|
|
4702 }
|
|
4703 }
|
|
4704
|
|
4705 while (cur != NULL) {
|
|
4706 b = cur->data;
|
|
4707 cur = g_slist_remove(cur, b);
|
|
4708 gaim_blist_remove_buddy(b);
|
|
4709 }
|
|
4710
|
|
4711 /* Permit list */
|
|
4712 if (gc->account->permit) {
|
|
4713 next = gc->account->permit;
|
|
4714 while (next != NULL) {
|
|
4715 cur = next;
|
|
4716 next = next->next;
|
|
4717 if (!aim_ssi_itemlist_finditem(od->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) {
|
|
4718 gaim_debug_info("oscar",
|
|
4719 "ssi: removing permit %s from local list\n", (const char *)cur->data);
|
|
4720 gaim_privacy_permit_remove(account, cur->data, TRUE);
|
|
4721 }
|
|
4722 }
|
|
4723 }
|
|
4724
|
|
4725 /* Deny list */
|
|
4726 if (gc->account->deny) {
|
|
4727 next = gc->account->deny;
|
|
4728 while (next != NULL) {
|
|
4729 cur = next;
|
|
4730 next = next->next;
|
|
4731 if (!aim_ssi_itemlist_finditem(od->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) {
|
|
4732 gaim_debug_info("oscar",
|
|
4733 "ssi: removing deny %s from local list\n", (const char *)cur->data);
|
|
4734 gaim_privacy_deny_remove(account, cur->data, TRUE);
|
|
4735 }
|
|
4736 }
|
|
4737 }
|
|
4738 /* Presence settings (idle time visibility) */
|
|
4739 if ((tmp = aim_ssi_getpresence(od->ssi.local)) != 0xFFFFFFFF)
|
|
4740 if (!(tmp & 0x400))
|
|
4741 aim_ssi_setpresence(od, tmp | 0x400);
|
|
4742 } /* end pruning buddies from local list */
|
|
4743
|
|
4744 /* Add from server list to local list */
|
|
4745 for (curitem=od->ssi.local; curitem; curitem=curitem->next) {
|
|
4746 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL)))
|
|
4747 switch (curitem->type) {
|
|
4748 case 0x0000: { /* Buddy */
|
|
4749 if (curitem->name) {
|
|
4750 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, curitem->name);
|
|
4751 char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
|
|
4752 char *alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name);
|
|
4753 char *alias_utf8;
|
|
4754
|
|
4755 if (alias != NULL)
|
|
4756 {
|
|
4757 if (g_utf8_validate(alias, -1, NULL))
|
|
4758 alias_utf8 = g_strdup(alias);
|
|
4759 else
|
|
4760 alias_utf8 = oscar_utf8_try_convert(account, alias);
|
|
4761 }
|
|
4762 else
|
|
4763 alias_utf8 = NULL;
|
|
4764
|
|
4765 b = gaim_find_buddy(gc->account, curitem->name);
|
|
4766 /* Should gname be freed here? -- elb */
|
|
4767 /* Not with the current code, but that might be cleaner -- med */
|
|
4768 g_free(alias);
|
|
4769 if (b) {
|
|
4770 /* Get server stored alias */
|
|
4771 if (alias_utf8) {
|
|
4772 g_free(b->alias);
|
|
4773 b->alias = g_strdup(alias_utf8);
|
|
4774 }
|
|
4775 } else {
|
|
4776 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8);
|
|
4777
|
|
4778 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
|
|
4779 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
|
|
4780 gaim_blist_add_group(g, NULL);
|
|
4781 }
|
|
4782
|
|
4783 gaim_debug_info("oscar",
|
|
4784 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans"));
|
|
4785 gaim_blist_add_buddy(b, NULL, g, NULL);
|
|
4786 }
|
|
4787 if (!aim_sncmp(curitem->name, account->username)) {
|
|
4788 char *comment = aim_ssi_getcomment(od->ssi.local, gname, curitem->name);
|
|
4789 gaim_check_comment(od, comment);
|
|
4790 g_free(comment);
|
|
4791 }
|
|
4792 g_free(gname_utf8);
|
|
4793 g_free(alias_utf8);
|
|
4794 }
|
|
4795 } break;
|
|
4796
|
|
4797 case 0x0001: { /* Group */
|
|
4798 /* Shouldn't add empty groups */
|
|
4799 } break;
|
|
4800
|
|
4801 case 0x0002: { /* Permit buddy */
|
|
4802 if (curitem->name) {
|
|
4803 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */
|
|
4804 GSList *list;
|
|
4805 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
|
|
4806 if (!list) {
|
|
4807 gaim_debug_info("oscar",
|
|
4808 "ssi: adding permit buddy %s to local list\n", curitem->name);
|
|
4809 gaim_privacy_permit_add(account, curitem->name, TRUE);
|
|
4810 }
|
|
4811 }
|
|
4812 } break;
|
|
4813
|
|
4814 case 0x0003: { /* Deny buddy */
|
|
4815 if (curitem->name) {
|
|
4816 GSList *list;
|
|
4817 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
|
|
4818 if (!list) {
|
|
4819 gaim_debug_info("oscar",
|
|
4820 "ssi: adding deny buddy %s to local list\n", curitem->name);
|
|
4821 gaim_privacy_deny_add(account, curitem->name, TRUE);
|
|
4822 }
|
|
4823 }
|
|
4824 } break;
|
|
4825
|
|
4826 case 0x0004: { /* Permit/deny setting */
|
|
4827 if (curitem->data) {
|
|
4828 guint8 permdeny;
|
|
4829 if ((permdeny = aim_ssi_getpermdeny(od->ssi.local)) && (permdeny != account->perm_deny)) {
|
|
4830 gaim_debug_info("oscar",
|
|
4831 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny);
|
|
4832 account->perm_deny = permdeny;
|
|
4833 if (od->icq && account->perm_deny == GAIM_PRIVACY_ALLOW_USERS) {
|
|
4834 gaim_presence_set_status_active(account->presence, OSCAR_STATUS_ID_INVISIBLE, TRUE);
|
|
4835 }
|
|
4836 }
|
|
4837 }
|
|
4838 } break;
|
|
4839
|
|
4840 case 0x0005: { /* Presence setting */
|
|
4841 /* We don't want to change Gaim's setting because it applies to all accounts */
|
|
4842 } break;
|
|
4843 } /* End of switch on curitem->type */
|
|
4844 } /* End of for loop */
|
|
4845
|
|
4846 oscar_set_extendedstatus(gc);
|
|
4847
|
|
4848 /* Activate SSI */
|
|
4849 /* Sending the enable causes other people to be able to see you, and you to see them */
|
|
4850 /* Make sure your privacy setting/invisibility is set how you want it before this! */
|
|
4851 gaim_debug_info("oscar",
|
|
4852 "ssi: activating server-stored buddy list\n");
|
|
4853 aim_ssi_enable(od);
|
|
4854
|
|
4855 return 1;
|
|
4856 }
|
|
4857
|
|
4858 static int gaim_ssi_parseack(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4859 GaimConnection *gc = od->gc;
|
|
4860 va_list ap;
|
|
4861 struct aim_ssi_tmp *retval;
|
|
4862
|
|
4863 va_start(ap, fr);
|
|
4864 retval = va_arg(ap, struct aim_ssi_tmp *);
|
|
4865 va_end(ap);
|
|
4866
|
|
4867 while (retval) {
|
|
4868 gaim_debug_misc("oscar",
|
|
4869 "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");
|
|
4870
|
|
4871 if (retval->ack != 0xffff)
|
|
4872 switch (retval->ack) {
|
|
4873 case 0x0000: { /* added successfully */
|
|
4874 } break;
|
|
4875
|
|
4876 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */
|
|
4877 gchar *buf;
|
|
4878 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)")));
|
|
4879 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf))
|
|
4880 gaim_notify_error(gc, NULL, _("Unable To Add"), buf);
|
|
4881 g_free(buf);
|
|
4882 }
|
|
4883
|
|
4884 case 0x000e: { /* buddy requires authorization */
|
|
4885 if ((retval->action == SNAC_SUBTYPE_FEEDBAG_ADD) && (retval->name))
|
|
4886 gaim_auth_sendrequest(gc, retval->name);
|
|
4887 } break;
|
|
4888
|
|
4889 default: { /* La la la */
|
|
4890 gchar *buf;
|
|
4891 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack);
|
|
4892 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)")));
|
|
4893 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf))
|
|
4894 gaim_notify_error(gc, NULL, _("Unable To Add"), buf);
|
|
4895 g_free(buf);
|
|
4896 } break;
|
|
4897 }
|
|
4898
|
|
4899 retval = retval->next;
|
|
4900 }
|
|
4901
|
|
4902 return 1;
|
|
4903 }
|
|
4904
|
|
4905 static int gaim_ssi_parseadd(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4906 GaimConnection *gc = od->gc;
|
|
4907 char *gname, *gname_utf8, *alias, *alias_utf8;
|
|
4908 GaimBuddy *b;
|
|
4909 GaimGroup *g;
|
|
4910 va_list ap;
|
|
4911 guint16 type;
|
|
4912 const char *name;
|
|
4913
|
|
4914 va_start(ap, fr);
|
|
4915 type = (guint16)va_arg(ap, int);
|
|
4916 name = va_arg(ap, char *);
|
|
4917 va_end(ap);
|
|
4918
|
|
4919 if ((type != 0x0000) || (name == NULL))
|
|
4920 return 1;
|
|
4921
|
|
4922 gname = aim_ssi_itemlist_findparentname(od->ssi.local, name);
|
|
4923 gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
|
|
4924
|
|
4925 alias = aim_ssi_getalias(od->ssi.local, gname, name);
|
|
4926 if (alias != NULL)
|
|
4927 {
|
|
4928 if (g_utf8_validate(alias, -1, NULL))
|
|
4929 alias_utf8 = g_strdup(alias);
|
|
4930 else
|
|
4931 alias_utf8 = oscar_utf8_try_convert(gaim_connection_get_account(gc), alias);
|
|
4932 }
|
|
4933 else
|
|
4934 alias_utf8 = NULL;
|
|
4935
|
|
4936 b = gaim_find_buddy(gc->account, name);
|
|
4937 g_free(alias);
|
|
4938
|
|
4939 if (b) {
|
|
4940 /* Get server stored alias */
|
|
4941 if (alias_utf8) {
|
|
4942 g_free(b->alias);
|
|
4943 b->alias = g_strdup(alias_utf8);
|
|
4944 }
|
|
4945 } else {
|
|
4946 b = gaim_buddy_new(gc->account, name, alias_utf8);
|
|
4947
|
|
4948 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
|
|
4949 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
|
|
4950 gaim_blist_add_group(g, NULL);
|
|
4951 }
|
|
4952
|
|
4953 gaim_debug_info("oscar",
|
|
4954 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans"));
|
|
4955 gaim_blist_add_buddy(b, NULL, g, NULL);
|
|
4956 }
|
|
4957 g_free(gname_utf8);
|
|
4958 g_free(alias_utf8);
|
|
4959
|
|
4960 return 1;
|
|
4961 }
|
|
4962
|
|
4963 static int gaim_ssi_authgiven(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4964 GaimConnection *gc = od->gc;
|
|
4965 va_list ap;
|
|
4966 char *sn, *msg;
|
|
4967 gchar *dialog_msg, *nombre;
|
|
4968 struct name_data *data;
|
|
4969 GaimBuddy *buddy;
|
|
4970
|
|
4971 va_start(ap, fr);
|
|
4972 sn = va_arg(ap, char *);
|
|
4973 msg = va_arg(ap, char *);
|
|
4974 va_end(ap);
|
|
4975
|
|
4976 gaim_debug_info("oscar",
|
|
4977 "ssi: %s has given you permission to add him to your buddy list\n", sn);
|
|
4978
|
|
4979 buddy = gaim_find_buddy(gc->account, sn);
|
|
4980 if (buddy && (gaim_buddy_get_alias_only(buddy)))
|
|
4981 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy));
|
|
4982 else
|
|
4983 nombre = g_strdup(sn);
|
|
4984
|
|
4985 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);
|
|
4986 data = g_new(struct name_data, 1);
|
|
4987 data->gc = gc;
|
|
4988 data->name = g_strdup(sn);
|
|
4989 data->nick = NULL;
|
|
4990
|
|
4991 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg,
|
|
4992 GAIM_DEFAULT_ACTION_NONE, data,
|
|
4993 G_CALLBACK(gaim_icq_buddyadd),
|
|
4994 G_CALLBACK(oscar_free_name_data));
|
|
4995
|
|
4996 g_free(dialog_msg);
|
|
4997 g_free(nombre);
|
|
4998
|
|
4999 return 1;
|
|
5000 }
|
|
5001
|
|
5002 static int gaim_ssi_authrequest(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
5003 GaimConnection *gc = od->gc;
|
|
5004 va_list ap;
|
|
5005 char *sn;
|
|
5006 char *msg;
|
|
5007 GaimAccount *account = gaim_connection_get_account(gc);
|
|
5008 gchar *nombre;
|
|
5009 gchar *reason = NULL;
|
|
5010 gchar *dialog_msg;
|
|
5011 struct name_data *data;
|
|
5012 GaimBuddy *buddy;
|
|
5013
|
|
5014 va_start(ap, fr);
|
|
5015 sn = va_arg(ap, char *);
|
|
5016 msg = va_arg(ap, char *);
|
|
5017 va_end(ap);
|
|
5018
|
|
5019 gaim_debug_info("oscar",
|
|
5020 "ssi: received authorization request from %s\n", sn);
|
|
5021
|
|
5022 buddy = gaim_find_buddy(account, sn);
|
|
5023 if (buddy && (gaim_buddy_get_alias_only(buddy)))
|
|
5024 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy));
|
|
5025 else
|
|
5026 nombre = g_strdup(sn);
|
|
5027
|
|
5028 if (msg != NULL)
|
|
5029 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg, strlen(msg));
|
|
5030
|
|
5031 if (reason == NULL)
|
|
5032 reason = g_strdup(_("No reason given."));
|
|
5033
|
|
5034 dialog_msg = g_strdup_printf(
|
|
5035 _("The user %s wants to add %s to their buddy list for the following reason:\n%s"),
|
|
5036 nombre, gaim_account_get_username(account), reason);
|
|
5037 g_free(reason);
|
|
5038
|
|
5039 data = g_new(struct name_data, 1);
|
|
5040 data->gc = gc;
|
|
5041 data->name = g_strdup(sn);
|
|
5042 data->nick = NULL;
|
|
5043
|
|
5044 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg,
|
|
5045 GAIM_DEFAULT_ACTION_NONE, data, 2,
|
|
5046 _("_Authorize"), G_CALLBACK(gaim_auth_grant),
|
|
5047 _("_Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt));
|
|
5048
|
|
5049 g_free(dialog_msg);
|
|
5050 g_free(nombre);
|
|
5051
|
|
5052 return 1;
|
|
5053 }
|
|
5054
|
|
5055 static int gaim_ssi_authreply(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
5056 GaimConnection *gc = od->gc;
|
|
5057 va_list ap;
|
|
5058 char *sn, *msg;
|
|
5059 gchar *dialog_msg, *nombre;
|
|
5060 guint8 reply;
|
|
5061 GaimBuddy *buddy;
|
|
5062
|
|
5063 va_start(ap, fr);
|
|
5064 sn = va_arg(ap, char *);
|
|
5065 reply = (guint8)va_arg(ap, int);
|
|
5066 msg = va_arg(ap, char *);
|
|
5067 va_end(ap);
|
|
5068
|
|
5069 gaim_debug_info("oscar",
|
|
5070 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply);
|
|
5071
|
|
5072 buddy = gaim_find_buddy(gc->account, sn);
|
|
5073 if (buddy && (gaim_buddy_get_alias_only(buddy)))
|
|
5074 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy));
|
|
5075 else
|
|
5076 nombre = g_strdup(sn);
|
|
5077
|
|
5078 if (reply) {
|
|
5079 /* Granted */
|
|
5080 dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your buddy list."), nombre);
|
|
5081 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg);
|
|
5082 } else {
|
|
5083 /* Denied */
|
|
5084 dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given."));
|
|
5085 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg);
|
|
5086 }
|
|
5087 g_free(dialog_msg);
|
|
5088 g_free(nombre);
|
|
5089
|
|
5090 return 1;
|
|
5091 }
|
|
5092
|
|
5093 static int gaim_ssi_gotadded(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
5094 GaimConnection *gc = od->gc;
|
|
5095 va_list ap;
|
|
5096 char *sn;
|
|
5097 GaimBuddy *buddy;
|
|
5098
|
|
5099 va_start(ap, fr);
|
|
5100 sn = va_arg(ap, char *);
|
|
5101 va_end(ap);
|
|
5102
|
|
5103 buddy = gaim_find_buddy(gc->account, sn);
|
|
5104 gaim_debug_info("oscar", "ssi: %s added you to their buddy list\n", sn);
|
|
5105 gaim_account_notify_added(gc->account, sn, NULL, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL);
|
|
5106
|
|
5107 return 1;
|
|
5108 }
|
|
5109
|
|
5110 static GList *oscar_chat_info(GaimConnection *gc) {
|
|
5111 GList *m = NULL;
|
|
5112 struct proto_chat_entry *pce;
|
|
5113
|
|
5114 pce = g_new0(struct proto_chat_entry, 1);
|
|
5115 pce->label = _("_Room:");
|
|
5116 pce->identifier = "room";
|
|
5117 pce->required = TRUE;
|
|
5118 m = g_list_append(m, pce);
|
|
5119
|
|
5120 pce = g_new0(struct proto_chat_entry, 1);
|
|
5121 pce->label = _("_Exchange:");
|
|
5122 pce->identifier = "exchange";
|
|
5123 pce->required = TRUE;
|
|
5124 pce->is_int = TRUE;
|
|
5125 pce->min = 4;
|
|
5126 pce->max = 20;
|
|
5127 m = g_list_append(m, pce);
|
|
5128
|
|
5129 return m;
|
|
5130 }
|
|
5131
|
|
5132 static GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name)
|
|
5133 {
|
|
5134 GHashTable *defaults;
|
|
5135
|
|
5136 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
|
|
5137
|
|
5138 if (chat_name != NULL)
|
|
5139 g_hash_table_insert(defaults, "room", g_strdup(chat_name));
|
|
5140
|
|
5141 return defaults;
|
|
5142 }
|
|
5143
|
|
5144 static char *
|
|
5145 oscar_get_chat_name(GHashTable *data)
|
|
5146 {
|
|
5147 return g_strdup(g_hash_table_lookup(data, "room"));
|
|
5148 }
|
|
5149
|
|
5150 static void
|
|
5151 oscar_join_chat(GaimConnection *gc, GHashTable *data)
|
|
5152 {
|
|
5153 OscarData *od = (OscarData *)gc->proto_data;
|
|
5154 FlapConnection *conn;
|
|
5155 char *name, *exchange;
|
|
5156
|
|
5157 name = g_hash_table_lookup(data, "room");
|
|
5158 exchange = g_hash_table_lookup(data, "exchange");
|
|
5159
|
|
5160 if ((name == NULL) || (*name == '\0')) {
|
|
5161 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL);
|
|
5162 return;
|
|
5163 }
|
|
5164
|
|
5165 gaim_debug_info("oscar", "Attempting to join chat room %s.\n", name);
|
|
5166
|
|
5167 if ((conn = flap_connection_getbytype(od, SNAC_FAMILY_CHATNAV)))
|
|
5168 {
|
|
5169 gaim_debug_info("oscar", "chatnav exists, creating room\n");
|
|
5170 aim_chatnav_createroom(od, conn, name, atoi(exchange));
|
|
5171 } else {
|
|
5172 /* this gets tricky */
|
|
5173 struct create_room *cr = g_new0(struct create_room, 1);
|
|
5174 gaim_debug_info("oscar", "chatnav does not exist, opening chatnav\n");
|
|
5175 cr->exchange = atoi(exchange);
|
|
5176 cr->name = g_strdup(name);
|
14348
|
5177 od->create_rooms = g_slist_prepend(od->create_rooms, cr);
|
14192
|
5178 aim_reqservice(od, SNAC_FAMILY_CHATNAV);
|
|
5179 }
|
|
5180 }
|
|
5181
|
|
5182 static void
|
|
5183 oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name)
|
|
5184 {
|
|
5185 OscarData *od = (OscarData *)gc->proto_data;
|
|
5186 struct chat_connection *ccon = find_oscar_chat(gc, id);
|
|
5187
|
|
5188 if (ccon == NULL)
|
|
5189 return;
|
|
5190
|
|
5191 aim_im_sendch2_chatinvite(od, name, message ? message : "",
|
|
5192 ccon->exchange, ccon->name, 0x0);
|
|
5193 }
|
|
5194
|
|
5195 static void
|
|
5196 oscar_chat_leave(GaimConnection *gc, int id)
|
|
5197 {
|
|
5198 GaimConversation *conv;
|
|
5199 struct chat_connection *cc;
|
|
5200
|
|
5201 conv = gaim_find_chat(gc, id);
|
|
5202
|
|
5203 g_return_if_fail(conv != NULL);
|
|
5204
|
|
5205 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name);
|
|
5206
|
|
5207 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)));
|
|
5208 oscar_chat_kill(gc, cc);
|
|
5209 }
|
|
5210
|
|
5211 static int oscar_send_chat(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) {
|
|
5212 OscarData *od = (OscarData *)gc->proto_data;
|
|
5213 GaimConversation *conv = NULL;
|
|
5214 struct chat_connection *c = NULL;
|
|
5215 char *buf, *buf2;
|
|
5216 guint16 charset, charsubset;
|
|
5217 char *charsetstr = NULL;
|
|
5218 int len;
|
|
5219
|
|
5220 if (!(conv = gaim_find_chat(gc, id)))
|
|
5221 return -EINVAL;
|
|
5222
|
|
5223 if (!(c = find_oscar_chat_by_conv(gc, conv)))
|
|
5224 return -EINVAL;
|
|
5225
|
|
5226 buf = gaim_strdup_withhtml(message);
|
|
5227 len = strlen(buf);
|
|
5228
|
|
5229 if (strstr(buf, "<IMG "))
|
|
5230 gaim_conversation_write(conv, "",
|
|
5231 _("Your IM Image was not sent. "
|
|
5232 "You cannot send IM Images in AIM chats."),
|
|
5233 GAIM_MESSAGE_ERROR, time(NULL));
|
|
5234
|
|
5235 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset);
|
|
5236 /*
|
|
5237 * Evan S. suggested that maxvis really does mean "number of
|
|
5238 * visible characters" and not "number of bytes"
|
|
5239 */
|
|
5240 if ((len > c->maxlen) || (len > c->maxvis)) {
|
|
5241 g_free(buf2);
|
|
5242 return -E2BIG;
|
|
5243 }
|
|
5244
|
|
5245 if (charset == AIM_CHARSET_ASCII)
|
|
5246 charsetstr = "us-ascii";
|
|
5247 else if (charset == AIM_CHARSET_UNICODE)
|
|
5248 charsetstr = "unicode-2-0";
|
|
5249 else if (charset == AIM_CHARSET_CUSTOM)
|
|
5250 charsetstr = "iso-8859-1";
|
|
5251 aim_chat_send_im(od, c->conn, 0, buf2, len, charsetstr, "en");
|
|
5252 g_free(buf2);
|
|
5253
|
|
5254 return 0;
|
|
5255 }
|
|
5256
|
|
5257 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b)
|
|
5258 {
|
|
5259 if ((b == NULL) || (b->name == NULL) || aim_sn_is_sms(b->name))
|
|
5260 {
|
|
5261 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a)))
|
|
5262 return "icq";
|
|
5263 else
|
|
5264 return "aim";
|
|
5265 }
|
|
5266
|
|
5267 if (aim_sn_is_icq(b->name))
|
|
5268 return "icq";
|
|
5269 return "aim";
|
|
5270 }
|
|
5271
|
|
5272 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne)
|
|
5273 {
|
|
5274 GaimConnection *gc = NULL;
|
|
5275 OscarData *od = NULL;
|
|
5276 GaimAccount *account = NULL;
|
|
5277 GaimPresence *presence;
|
|
5278 GaimStatus *status;
|
|
5279 const char *status_id;
|
|
5280 char *emblems[4] = {NULL,NULL,NULL,NULL};
|
|
5281 int i = 0;
|
|
5282 aim_userinfo_t *userinfo = NULL;
|
|
5283
|
|
5284 account = b->account;
|
|
5285 if (account != NULL)
|
|
5286 gc = account->gc;
|
|
5287 if (gc != NULL)
|
|
5288 od = gc->proto_data;
|
|
5289 if (od != NULL)
|
|
5290 userinfo = aim_locate_finduserinfo(od, b->name);
|
|
5291
|
|
5292 presence = gaim_buddy_get_presence(b);
|
|
5293 status = gaim_presence_get_active_status(presence);
|
|
5294 status_id = gaim_status_get_id(status);
|
|
5295
|
|
5296 if (gaim_presence_is_online(presence) == FALSE) {
|
|
5297 char *gname;
|
|
5298 if ((b->name) && (od) && (od->ssi.received_data) &&
|
|
5299 (gname = aim_ssi_itemlist_findparentname(od->ssi.local, b->name)) &&
|
|
5300 (aim_ssi_waitingforauth(od->ssi.local, gname, b->name))) {
|
|
5301 emblems[i++] = "notauthorized";
|
|
5302 } else {
|
|
5303 emblems[i++] = "offline";
|
|
5304 }
|
|
5305 }
|
|
5306
|
|
5307 if (b->name && aim_sn_is_icq(b->name)) {
|
|
5308 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE))
|
|
5309 emblems[i++] = "invisible";
|
|
5310 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT))
|
|
5311 emblems[i++] = "freeforchat";
|
|
5312 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND))
|
|
5313 emblems[i++] = "dnd";
|
|
5314 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA))
|
|
5315 emblems[i++] = "unavailable";
|
|
5316 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED))
|
|
5317 emblems[i++] = "occupied";
|
|
5318 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY))
|
|
5319 emblems[i++] = "away";
|
|
5320 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) {
|
|
5321 emblems[i++] = "away";
|
|
5322 }
|
|
5323
|
|
5324 if (userinfo != NULL ) {
|
|
5325 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED)
|
|
5326 emblems[i++] = "unconfirmed"; */
|
|
5327 if ((i < 4) && userinfo->flags & AIM_FLAG_ADMINISTRATOR)
|
|
5328 emblems[i++] = "admin";
|
|
5329 if ((i < 4) && userinfo->flags & AIM_FLAG_AOL)
|
|
5330 emblems[i++] = "aol";
|
|
5331 if ((i < 4) && userinfo->flags & AIM_FLAG_WIRELESS)
|
|
5332 emblems[i++] = "wireless";
|
|
5333 if ((i < 4) && userinfo->flags & AIM_FLAG_ACTIVEBUDDY)
|
|
5334 emblems[i++] = "activebuddy";
|
|
5335
|
|
5336 if ((i < 4) && (userinfo->capabilities & OSCAR_CAPABILITY_HIPTOP))
|
|
5337 emblems[i++] = "hiptop";
|
|
5338
|
|
5339 if ((i < 4) && (userinfo->capabilities & OSCAR_CAPABILITY_SECUREIM))
|
|
5340 emblems[i++] = "secure";
|
|
5341 }
|
|
5342
|
|
5343 *se = emblems[0];
|
|
5344 *sw = emblems[1];
|
|
5345 *nw = emblems[2];
|
|
5346 *ne = emblems[3];
|
|
5347 }
|
|
5348
|
|
5349 static void oscar_tooltip_text(GaimBuddy *b, GString *str, gboolean full) {
|
|
5350 GaimConnection *gc = b->account->gc;
|
|
5351 OscarData *od = gc->proto_data;
|
|
5352 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od, b->name);
|
|
5353
|
|
5354 if (GAIM_BUDDY_IS_ONLINE(b)) {
|
|
5355 GaimPresence *presence;
|
|
5356 GaimStatus *status;
|
|
5357 const char *message;
|
|
5358
|
|
5359 if (full)
|
|
5360 oscar_string_append_info(gc, str, "\n", b, userinfo);
|
|
5361
|
|
5362 presence = gaim_buddy_get_presence(b);
|
|
5363 status = gaim_presence_get_active_status(presence);
|
|
5364 message = gaim_status_get_attr_string(status, "message");
|
|
5365
|
|
5366 if (gaim_status_is_available(status))
|
|
5367 {
|
|
5368 if (message != NULL)
|
|
5369 {
|
|
5370 /* Available status messages are plain text */
|
|
5371 gchar *tmp;
|
|
5372 tmp = g_markup_escape_text(message, -1);
|
|
5373 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp);
|
|
5374 g_free(tmp);
|
|
5375 }
|
|
5376 }
|
|
5377 else
|
|
5378 {
|
|
5379 if (message != NULL)
|
|
5380 {
|
|
5381 /* Away messages are HTML */
|
|
5382 gchar *tmp1, *tmp2;
|
|
5383 tmp2 = gaim_markup_strip_html(message);
|
|
5384 tmp1 = g_markup_escape_text(tmp2, -1);
|
|
5385 g_free(tmp2);
|
|
5386 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc)));
|
|
5387 g_free(tmp1);
|
|
5388 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp2);
|
|
5389 g_free(tmp2);
|
|
5390 }
|
|
5391 else
|
|
5392 {
|
|
5393 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), _("<i>(retrieving)</i>"));
|
|
5394 }
|
|
5395 }
|
|
5396 }
|
|
5397 }
|
|
5398
|
|
5399 static char *oscar_status_text(GaimBuddy *b)
|
|
5400 {
|
|
5401 GaimConnection *gc;
|
|
5402 GaimAccount *account;
|
|
5403 OscarData *od;
|
|
5404 const GaimPresence *presence;
|
|
5405 const GaimStatus *status;
|
|
5406 const char *id;
|
|
5407 const char *message;
|
|
5408 gchar *ret = NULL;
|
|
5409
|
|
5410 gc = gaim_account_get_connection(gaim_buddy_get_account(b));
|
|
5411 account = gaim_connection_get_account(gc);
|
|
5412 od = gc->proto_data;
|
|
5413 presence = gaim_buddy_get_presence(b);
|
|
5414 status = gaim_presence_get_active_status(presence);
|
|
5415 id = gaim_status_get_id(status);
|
|
5416
|
|
5417 if (!gaim_presence_is_online(presence))
|
|
5418 {
|
|
5419 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, b->name);
|
|
5420 if (aim_ssi_waitingforauth(od->ssi.local, gname, b->name))
|
|
5421 ret = g_strdup(_("Not Authorized"));
|
|
5422 else
|
|
5423 ret = g_strdup(_("Offline"));
|
|
5424 }
|
|
5425 else if (gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AVAILABLE))
|
|
5426 {
|
|
5427 /* Available */
|
|
5428 message = gaim_status_get_attr_string(status, "message");
|
|
5429 if (message != NULL)
|
|
5430 {
|
|
5431 ret = g_markup_escape_text(message, -1);
|
|
5432 gaim_util_chrreplace(ret, '\n', ' ');
|
|
5433 }
|
|
5434 }
|
|
5435 else if (!gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AWAY))
|
|
5436 {
|
|
5437 /* Away */
|
|
5438 message = gaim_status_get_attr_string(status, "message");
|
|
5439 if (message != NULL)
|
|
5440 {
|
|
5441 gchar *tmp1, *tmp2;
|
|
5442 tmp1 = gaim_markup_strip_html(message);
|
|
5443 gaim_util_chrreplace(tmp1, '\n', ' ');
|
|
5444 tmp2 = g_markup_escape_text(tmp1, -1);
|
|
5445 ret = gaim_str_sub_away_formatters(tmp2, gaim_account_get_username(account));
|
|
5446 g_free(tmp1);
|
|
5447 g_free(tmp2);
|
|
5448 }
|
|
5449 else
|
|
5450 {
|
|
5451 ret = g_strdup(_("Away"));
|
|
5452 }
|
|
5453 }
|
|
5454 else
|
|
5455 ret = g_strdup(gaim_status_get_name(status));
|
|
5456
|
|
5457 return ret;
|
|
5458 }
|
|
5459
|
|
5460
|
|
5461 static int oscar_icon_req(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
5462 GaimConnection *gc = od->gc;
|
|
5463 va_list ap;
|
|
5464 guint16 type;
|
|
5465 guint8 flags = 0, length = 0;
|
|
5466 guchar *md5 = NULL;
|
|
5467
|
|
5468 va_start(ap, fr);
|
|
5469 type = va_arg(ap, int);
|
|
5470
|
|
5471 switch(type) {
|
|
5472 case 0x0000:
|
|
5473 case 0x0001: {
|
|
5474 flags = va_arg(ap, int);
|
|
5475 length = va_arg(ap, int);
|
|
5476 md5 = va_arg(ap, guchar *);
|
|
5477
|
|
5478 if (flags == 0x41) {
|
|
5479 if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) {
|
|
5480 od->iconconnecting = TRUE;
|
|
5481 od->set_icon = TRUE;
|
|
5482 aim_reqservice(od, SNAC_FAMILY_BART);
|
|
5483 } else {
|
|
5484 struct stat st;
|
|
5485 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc)));
|
|
5486 if (iconfile == NULL) {
|
|
5487 aim_ssi_delicon(od);
|
|
5488 } else if (!g_stat(iconfile, &st)) {
|
|
5489 guchar *buf = g_malloc(st.st_size);
|
|
5490 FILE *file = g_fopen(iconfile, "rb");
|
|
5491 if (file) {
|
|
5492 /* XXX - Use g_file_get_contents()? */
|
|
5493 fread(buf, 1, st.st_size, file);
|
|
5494 fclose(file);
|
|
5495 gaim_debug_info("oscar",
|
|
5496 "Uploading icon to icon server\n");
|
|
5497 aim_bart_upload(od, buf, st.st_size);
|
|
5498 } else
|
|
5499 gaim_debug_error("oscar",
|
|
5500 "Can't open buddy icon file!\n");
|
|
5501 g_free(buf);
|
|
5502 } else {
|
|
5503 gaim_debug_error("oscar",
|
|
5504 "Can't stat buddy icon file!\n");
|
|
5505 }
|
|
5506 g_free(iconfile);
|
|
5507 }
|
|
5508 } else if (flags == 0x81) {
|
|
5509 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc)));
|
|
5510 if (iconfile == NULL)
|
|
5511 aim_ssi_delicon(od);
|
|
5512 else {
|
|
5513 aim_ssi_seticon(od, md5, length);
|
|
5514 g_free(iconfile);
|
|
5515 }
|
|
5516 }
|
|
5517 } break;
|
|
5518
|
|
5519 case 0x0002: { /* We just set an "available" message? */
|
|
5520 } break;
|
|
5521 }
|
|
5522
|
|
5523 va_end(ap);
|
|
5524
|
|
5525 return 0;
|
|
5526 }
|
|
5527
|
|
5528 static void oscar_set_permit_deny(GaimConnection *gc) {
|
|
5529 GaimAccount *account = gaim_connection_get_account(gc);
|
|
5530 OscarData *od = (OscarData *)gc->proto_data;
|
|
5531
|
|
5532 if (od->ssi.received_data) {
|
|
5533 switch (account->perm_deny) {
|
|
5534 case GAIM_PRIVACY_ALLOW_ALL:
|
|
5535 aim_ssi_setpermdeny(od, 0x01, 0xffffffff);
|
|
5536 break;
|
|
5537 case GAIM_PRIVACY_ALLOW_BUDDYLIST:
|
|
5538 aim_ssi_setpermdeny(od, 0x05, 0xffffffff);
|
|
5539 break;
|
|
5540 case GAIM_PRIVACY_ALLOW_USERS:
|
|
5541 aim_ssi_setpermdeny(od, 0x03, 0xffffffff);
|
|
5542 break;
|
|
5543 case GAIM_PRIVACY_DENY_ALL:
|
|
5544 aim_ssi_setpermdeny(od, 0x02, 0xffffffff);
|
|
5545 break;
|
|
5546 case GAIM_PRIVACY_DENY_USERS:
|
|
5547 aim_ssi_setpermdeny(od, 0x04, 0xffffffff);
|
|
5548 break;
|
|
5549 default:
|
|
5550 aim_ssi_setpermdeny(od, 0x01, 0xffffffff);
|
|
5551 break;
|
|
5552 }
|
|
5553 }
|
|
5554 }
|
|
5555
|
|
5556 static void oscar_add_permit(GaimConnection *gc, const char *who) {
|
|
5557 OscarData *od = (OscarData *)gc->proto_data;
|
|
5558 gaim_debug_info("oscar", "ssi: About to add a permit\n");
|
|
5559 if (od->ssi.received_data)
|
|
5560 aim_ssi_addpermit(od, who);
|
|
5561 }
|
|
5562
|
|
5563 static void oscar_add_deny(GaimConnection *gc, const char *who) {
|
|
5564 OscarData *od = (OscarData *)gc->proto_data;
|
|
5565 gaim_debug_info("oscar", "ssi: About to add a deny\n");
|
|
5566 if (od->ssi.received_data)
|
|
5567 aim_ssi_adddeny(od, who);
|
|
5568 }
|
|
5569
|
|
5570 static void oscar_rem_permit(GaimConnection *gc, const char *who) {
|
|
5571 OscarData *od = (OscarData *)gc->proto_data;
|
|
5572 gaim_debug_info("oscar", "ssi: About to delete a permit\n");
|
|
5573 if (od->ssi.received_data)
|
|
5574 aim_ssi_delpermit(od, who);
|
|
5575 }
|
|
5576
|
|
5577 static void oscar_rem_deny(GaimConnection *gc, const char *who) {
|
|
5578 OscarData *od = (OscarData *)gc->proto_data;
|
|
5579 gaim_debug_info("oscar", "ssi: About to delete a deny\n");
|
|
5580 if (od->ssi.received_data)
|
|
5581 aim_ssi_deldeny(od, who);
|
|
5582 }
|
|
5583
|
|
5584 static GList *
|
|
5585 oscar_status_types(GaimAccount *account)
|
|
5586 {
|
|
5587 gboolean is_icq;
|
|
5588 GList *status_types = NULL;
|
|
5589 GaimStatusType *type;
|
|
5590
|
|
5591 g_return_val_if_fail(account != NULL, NULL);
|
|
5592
|
|
5593 /* Used to flag some statuses as "user settable" or not */
|
|
5594 is_icq = aim_sn_is_icq(gaim_account_get_username(account));
|
|
5595
|
|
5596 /* Common status types */
|
|
5597 /* Really the available message should only be settable for AIM accounts */
|
|
5598 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE,
|
|
5599 OSCAR_STATUS_ID_AVAILABLE,
|
|
5600 NULL, TRUE, TRUE, FALSE,
|
|
5601 "message", _("Message"),
|
|
5602 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5603 status_types = g_list_prepend(status_types, type);
|
14192
|
5604
|
|
5605 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE,
|
|
5606 OSCAR_STATUS_ID_FREE4CHAT,
|
|
5607 _("Free For Chat"), TRUE, is_icq, FALSE);
|
14348
|
5608 status_types = g_list_prepend(status_types, type);
|
14192
|
5609
|
|
5610 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY,
|
|
5611 OSCAR_STATUS_ID_AWAY,
|
|
5612 NULL, TRUE, TRUE, FALSE,
|
|
5613 "message", _("Message"),
|
|
5614 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5615 status_types = g_list_prepend(status_types, type);
|
14192
|
5616
|
|
5617 type = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE,
|
|
5618 OSCAR_STATUS_ID_INVISIBLE,
|
|
5619 NULL, TRUE, TRUE, FALSE);
|
14348
|
5620 status_types = g_list_prepend(status_types, type);
|
14192
|
5621
|
|
5622 /* ICQ-specific status types */
|
|
5623 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE,
|
|
5624 OSCAR_STATUS_ID_OCCUPIED,
|
|
5625 _("Occupied"), TRUE, is_icq, FALSE,
|
|
5626 "message", _("Message"),
|
|
5627 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5628 status_types = g_list_prepend(status_types, type);
|
14192
|
5629
|
|
5630 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY,
|
|
5631 OSCAR_STATUS_ID_DND,
|
|
5632 _("Do Not Disturb"), TRUE, is_icq, FALSE,
|
|
5633 "message", _("Message"),
|
|
5634 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5635 status_types = g_list_prepend(status_types, type);
|
14192
|
5636
|
|
5637 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY,
|
|
5638 OSCAR_STATUS_ID_NA,
|
|
5639 _("Not Available"), TRUE, is_icq, FALSE,
|
|
5640 "message", _("Message"),
|
|
5641 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5642 status_types = g_list_prepend(status_types, type);
|
14192
|
5643
|
|
5644 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE,
|
|
5645 OSCAR_STATUS_ID_OFFLINE,
|
|
5646 NULL, TRUE, TRUE, FALSE);
|
14348
|
5647 status_types = g_list_prepend(status_types, type);
|
|
5648
|
|
5649 status_types = g_list_reverse(status_types);
|
14192
|
5650
|
|
5651 return status_types;
|
|
5652 }
|
|
5653
|
|
5654 static void oscar_ssi_editcomment(struct name_data *data, const char *text) {
|
|
5655 GaimConnection *gc = data->gc;
|
|
5656 OscarData *od = gc->proto_data;
|
|
5657 GaimBuddy *b;
|
|
5658 GaimGroup *g;
|
|
5659
|
|
5660 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) {
|
|
5661 oscar_free_name_data(data);
|
|
5662 return;
|
|
5663 }
|
|
5664
|
|
5665 if (!(g = gaim_buddy_get_group(b))) {
|
|
5666 oscar_free_name_data(data);
|
|
5667 return;
|
|
5668 }
|
|
5669
|
|
5670 aim_ssi_editcomment(od, g->name, data->name, text);
|
|
5671
|
|
5672 if (!aim_sncmp(data->name, gc->account->username))
|
|
5673 gaim_check_comment(od, text);
|
|
5674
|
|
5675 oscar_free_name_data(data);
|
|
5676 }
|
|
5677
|
|
5678 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) {
|
|
5679
|
|
5680 GaimBuddy *buddy;
|
|
5681 GaimConnection *gc;
|
|
5682 OscarData *od;
|
|
5683 struct name_data *data;
|
|
5684 GaimGroup *g;
|
|
5685 char *comment;
|
|
5686 gchar *comment_utf8;
|
|
5687 gchar *title;
|
|
5688
|
|
5689 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
5690
|
|
5691 buddy = (GaimBuddy *) node;
|
|
5692 gc = gaim_account_get_connection(buddy->account);
|
|
5693 od = gc->proto_data;
|
|
5694
|
|
5695 data = g_new(struct name_data, 1);
|
|
5696
|
|
5697 if (!(g = gaim_buddy_get_group(buddy)))
|
|
5698 return;
|
|
5699 comment = aim_ssi_getcomment(od->ssi.local, g->name, buddy->name);
|
|
5700 comment_utf8 = comment ? oscar_utf8_try_convert(gc->account, comment) : NULL;
|
|
5701
|
|
5702 data->gc = gc;
|
|
5703 data->name = g_strdup(buddy->name);
|
|
5704 data->nick = NULL;
|
|
5705
|
|
5706 title = g_strdup_printf(_("Buddy Comment for %s"), data->name);
|
|
5707 gaim_request_input(gc, title, _("Buddy Comment:"), NULL,
|
|
5708 comment_utf8, TRUE, FALSE, NULL,
|
|
5709 _("OK"), G_CALLBACK(oscar_ssi_editcomment),
|
|
5710 _("Cancel"), G_CALLBACK(oscar_free_name_data),
|
|
5711 data);
|
|
5712 g_free(title);
|
|
5713
|
|
5714 g_free(comment);
|
|
5715 g_free(comment_utf8);
|
|
5716 }
|
|
5717
|
|
5718 static void
|
|
5719 oscar_ask_directim_yes_cb(struct oscar_ask_directim_data *data)
|
|
5720 {
|
|
5721 peer_connection_propose(data->od, OSCAR_CAPABILITY_DIRECTIM, data->who);
|
|
5722 g_free(data->who);
|
|
5723 g_free(data);
|
|
5724 }
|
|
5725
|
|
5726 static void
|
|
5727 oscar_ask_directim_no_cb(struct oscar_ask_directim_data *data)
|
|
5728 {
|
|
5729 g_free(data->who);
|
|
5730 g_free(data);
|
|
5731 }
|
|
5732
|
|
5733 /* This is called from right-click menu on a buddy node. */
|
|
5734 static void
|
|
5735 oscar_ask_directim(gpointer object, gpointer ignored)
|
|
5736 {
|
|
5737 GaimBlistNode *node;
|
|
5738 GaimBuddy *buddy;
|
|
5739 GaimConnection *gc;
|
|
5740 gchar *buf;
|
|
5741 struct oscar_ask_directim_data *data;
|
|
5742
|
|
5743 node = object;
|
|
5744
|
|
5745 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
5746
|
|
5747 buddy = (GaimBuddy *)node;
|
|
5748 gc = gaim_account_get_connection(buddy->account);
|
|
5749
|
|
5750 data = g_new0(struct oscar_ask_directim_data, 1);
|
|
5751 data->who = g_strdup(buddy->name);
|
|
5752 data->od = gc->proto_data;
|
|
5753 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."),
|
|
5754 buddy->name);
|
|
5755
|
|
5756 gaim_request_action(gc, NULL, buf,
|
|
5757 _("Because this reveals your IP address, it "
|
|
5758 "may be considered a security risk. Do you "
|
|
5759 "wish to continue?"),
|
|
5760 0, data, 2,
|
|
5761 _("_Connect"), G_CALLBACK(oscar_ask_directim_yes_cb),
|
|
5762 _("Cancel"), G_CALLBACK(oscar_ask_directim_no_cb));
|
|
5763 g_free(buf);
|
|
5764 }
|
|
5765
|
|
5766 static void
|
|
5767 oscar_get_aim_info_cb(GaimBlistNode *node, gpointer ignore)
|
|
5768 {
|
|
5769 GaimBuddy *buddy;
|
|
5770 GaimConnection *gc;
|
|
5771
|
|
5772 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
5773
|
|
5774 buddy = (GaimBuddy *)node;
|
|
5775 gc = gaim_account_get_connection(buddy->account);
|
|
5776
|
|
5777 aim_locate_getinfoshort(gc->proto_data, gaim_buddy_get_name(buddy), 0x00000003);
|
|
5778 }
|
|
5779
|
|
5780 static GList *oscar_buddy_menu(GaimBuddy *buddy) {
|
|
5781
|
|
5782 GaimConnection *gc;
|
|
5783 OscarData *od;
|
14348
|
5784 GList *menu;
|
14192
|
5785 GaimMenuAction *act;
|
|
5786 aim_userinfo_t *userinfo;
|
|
5787
|
|
5788 gc = gaim_account_get_connection(buddy->account);
|
|
5789 od = gc->proto_data;
|
|
5790 userinfo = aim_locate_finduserinfo(od, buddy->name);
|
14348
|
5791 menu = NULL;
|
14192
|
5792
|
|
5793 if (od->icq && aim_sn_is_icq(gaim_buddy_get_name(buddy)))
|
|
5794 {
|
|
5795 act = gaim_menu_action_new(_("Get AIM Info"),
|
|
5796 GAIM_CALLBACK(oscar_get_aim_info_cb),
|
|
5797 NULL, NULL);
|
14348
|
5798 menu = g_list_prepend(menu, act);
|
14192
|
5799 }
|
|
5800
|
|
5801 act = gaim_menu_action_new(_("Edit Buddy Comment"),
|
|
5802 GAIM_CALLBACK(oscar_buddycb_edit_comment),
|
|
5803 NULL, NULL);
|
14348
|
5804 menu = g_list_prepend(menu, act);
|
14192
|
5805
|
|
5806 #if 0
|
|
5807 if (od->icq)
|
|
5808 {
|
|
5809 act = gaim_menu_action_new(_("Get Status Msg"),
|
|
5810 GAIM_CALLBACK(oscar_get_icqstatusmsg),
|
|
5811 NULL, NULL);
|
14348
|
5812 menu = g_list_prepend(menu, act);
|
14192
|
5813 }
|
|
5814 #endif
|
|
5815
|
|
5816 if (userinfo &&
|
|
5817 aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) &&
|
|
5818 GAIM_BUDDY_IS_ONLINE(buddy))
|
|
5819 {
|
|
5820 if (userinfo->capabilities & OSCAR_CAPABILITY_DIRECTIM)
|
|
5821 {
|
|
5822 act = gaim_menu_action_new(_("Direct IM"),
|
|
5823 GAIM_CALLBACK(oscar_ask_directim),
|
|
5824 NULL, NULL);
|
14348
|
5825 menu = g_list_prepend(menu, act);
|
14192
|
5826 }
|
|
5827 #if 0
|
|
5828 /* TODO: This menu item should be added by the core */
|
|
5829 if (userinfo->capabilities & OSCAR_CAPABILITY_GETFILE) {
|
|
5830 act = gaim_menu_action_new(_("Get File"),
|
|
5831 GAIM_CALLBACK(oscar_ask_getfile),
|
|
5832 NULL, NULL);
|
14348
|
5833 menu = g_list_prepend(menu, act);
|
14192
|
5834 }
|
|
5835 #endif
|
|
5836 }
|
|
5837
|
|
5838 if (od->ssi.received_data)
|
|
5839 {
|
|
5840 char *gname;
|
|
5841 gname = aim_ssi_itemlist_findparentname(od->ssi.local, buddy->name);
|
|
5842 if (gname && aim_ssi_waitingforauth(od->ssi.local, gname, buddy->name))
|
|
5843 {
|
|
5844 act = gaim_menu_action_new(_("Re-request Authorization"),
|
|
5845 GAIM_CALLBACK(gaim_auth_sendrequest_menu),
|
|
5846 NULL, NULL);
|
14348
|
5847 menu = g_list_prepend(menu, act);
|
14192
|
5848 }
|
|
5849 }
|
|
5850
|
14348
|
5851 menu = g_list_reverse(menu);
|
|
5852
|
|
5853 return menu;
|
14192
|
5854 }
|
|
5855
|
|
5856
|
|
5857 static GList *oscar_blist_node_menu(GaimBlistNode *node) {
|
|
5858 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
|
|
5859 return oscar_buddy_menu((GaimBuddy *) node);
|
|
5860 } else {
|
|
5861 return NULL;
|
|
5862 }
|
|
5863 }
|
|
5864
|
|
5865 static void
|
|
5866 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields)
|
|
5867 {
|
|
5868 OscarData *od = gc->proto_data;
|
|
5869 GaimAccount *account = gaim_connection_get_account(gc);
|
|
5870 GaimRequestField *f;
|
|
5871 gboolean auth, web_aware;
|
|
5872
|
|
5873 f = gaim_request_fields_get_field(fields, "authorization");
|
|
5874 auth = gaim_request_field_bool_get_value(f);
|
|
5875
|
|
5876 f = gaim_request_fields_get_field(fields, "web_aware");
|
|
5877 web_aware = gaim_request_field_bool_get_value(f);
|
|
5878
|
|
5879 gaim_account_set_bool(account, "authorization", auth);
|
|
5880 gaim_account_set_bool(account, "web_aware", web_aware);
|
|
5881
|
|
5882 oscar_set_extendedstatus(gc);
|
|
5883 aim_icq_setsecurity(od, auth, web_aware);
|
|
5884 }
|
|
5885
|
|
5886 static void
|
|
5887 oscar_show_icq_privacy_opts(GaimPluginAction *action)
|
|
5888 {
|
|
5889 GaimConnection *gc = (GaimConnection *) action->context;
|
|
5890 GaimAccount *account = gaim_connection_get_account(gc);
|
|
5891 GaimRequestFields *fields;
|
|
5892 GaimRequestFieldGroup *g;
|
|
5893 GaimRequestField *f;
|
|
5894 gboolean auth, web_aware;
|
|
5895
|
|
5896 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION);
|
|
5897 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE);
|
|
5898
|
|
5899 fields = gaim_request_fields_new();
|
|
5900
|
|
5901 g = gaim_request_field_group_new(NULL);
|
|
5902
|
|
5903 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth);
|
|
5904 gaim_request_field_group_add_field(g, f);
|
|
5905
|
|
5906 f = gaim_request_field_bool_new("web_aware", _("Web aware (enabling this will cause you to receive SPAM!)"), web_aware);
|
|
5907 gaim_request_field_group_add_field(g, f);
|
|
5908
|
|
5909 gaim_request_fields_add_group(fields, g);
|
|
5910
|
|
5911 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"),
|
|
5912 NULL, fields,
|
|
5913 _("OK"), G_CALLBACK(oscar_icq_privacy_opts),
|
|
5914 _("Cancel"), NULL, gc);
|
|
5915 }
|
|
5916
|
|
5917 static void oscar_format_screenname(GaimConnection *gc, const char *nick) {
|
|
5918 OscarData *od = gc->proto_data;
|
|
5919 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) {
|
|
5920 if (!flap_connection_getbytype(od, SNAC_FAMILY_ADMIN)) {
|
|
5921 od->setnick = TRUE;
|
|
5922 od->newsn = g_strdup(nick);
|
|
5923 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
5924 } else {
|
|
5925 aim_admin_setnick(od, flap_connection_getbytype(od, SNAC_FAMILY_ADMIN), nick);
|
|
5926 }
|
|
5927 } else {
|
|
5928 gaim_notify_error(gc, NULL, _("The new formatting is invalid."),
|
|
5929 _("Screen name formatting can change only capitalization and whitespace."));
|
|
5930 }
|
|
5931 }
|
|
5932
|
|
5933 static void oscar_show_format_screenname(GaimPluginAction *action)
|
|
5934 {
|
|
5935 GaimConnection *gc = (GaimConnection *) action->context;
|
|
5936 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL,
|
|
5937 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL,
|
|
5938 _("OK"), G_CALLBACK(oscar_format_screenname),
|
|
5939 _("Cancel"), NULL,
|
|
5940 gc);
|
|
5941 }
|
|
5942
|
|
5943 static void oscar_confirm_account(GaimPluginAction *action)
|
|
5944 {
|
|
5945 GaimConnection *gc;
|
|
5946 OscarData *od;
|
|
5947 FlapConnection *conn;
|
|
5948
|
|
5949 gc = (GaimConnection *)action->context;
|
|
5950 od = gc->proto_data;
|
|
5951
|
|
5952 conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
|
|
5953 if (conn != NULL) {
|
|
5954 aim_admin_reqconfirm(od, conn);
|
|
5955 } else {
|
|
5956 od->conf = TRUE;
|
|
5957 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
5958 }
|
|
5959 }
|
|
5960
|
|
5961 static void oscar_show_email(GaimPluginAction *action)
|
|
5962 {
|
|
5963 GaimConnection *gc = (GaimConnection *) action->context;
|
|
5964 OscarData *od = gc->proto_data;
|
|
5965 FlapConnection *conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
|
|
5966
|
|
5967 if (conn) {
|
|
5968 aim_admin_getinfo(od, conn, 0x11);
|
|
5969 } else {
|
|
5970 od->reqemail = TRUE;
|
|
5971 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
5972 }
|
|
5973 }
|
|
5974
|
|
5975 static void oscar_change_email(GaimConnection *gc, const char *email)
|
|
5976 {
|
|
5977 OscarData *od = gc->proto_data;
|
|
5978 FlapConnection *conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
|
|
5979
|
|
5980 if (conn) {
|
|
5981 aim_admin_setemail(od, conn, email);
|
|
5982 } else {
|
|
5983 od->setemail = TRUE;
|
|
5984 od->email = g_strdup(email);
|
|
5985 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
5986 }
|
|
5987 }
|
|
5988
|
|
5989 static void oscar_show_change_email(GaimPluginAction *action)
|
|
5990 {
|
|
5991 GaimConnection *gc = (GaimConnection *) action->context;
|
|
5992 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL,
|
|
5993 FALSE, FALSE, NULL,
|
|
5994 _("OK"), G_CALLBACK(oscar_change_email),
|
|
5995 _("Cancel"), NULL,
|
|
5996 gc);
|
|
5997 }
|
|
5998
|
|
5999 static void oscar_show_awaitingauth(GaimPluginAction *action)
|
|
6000 {
|
|
6001 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6002 OscarData *od = gc->proto_data;
|
|
6003 gchar *nombre, *text, *tmp;
|
|
6004 GaimBlistNode *gnode, *cnode, *bnode;
|
|
6005 int num=0;
|
|
6006
|
|
6007 text = g_strdup("");
|
|
6008
|
|
6009 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
|
|
6010 GaimGroup *group = (GaimGroup *)gnode;
|
|
6011 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
|
|
6012 continue;
|
|
6013 for (cnode = gnode->child; cnode; cnode = cnode->next) {
|
|
6014 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))
|
|
6015 continue;
|
|
6016 for (bnode = cnode->child; bnode; bnode = bnode->next) {
|
|
6017 GaimBuddy *buddy = (GaimBuddy *)bnode;
|
|
6018 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
|
|
6019 continue;
|
|
6020 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->ssi.local, group->name, buddy->name)) {
|
|
6021 if (gaim_buddy_get_alias_only(buddy))
|
|
6022 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy));
|
|
6023 else
|
|
6024 nombre = g_strdup_printf(" %s", buddy->name);
|
|
6025 tmp = g_strdup_printf("%s%s<br>", text, nombre);
|
|
6026 g_free(text);
|
|
6027 text = tmp;
|
|
6028 g_free(nombre);
|
|
6029 num++;
|
|
6030 }
|
|
6031 }
|
|
6032 }
|
|
6033 }
|
|
6034
|
|
6035 if (!num) {
|
|
6036 g_free(text);
|
|
6037 text = g_strdup(_("<i>you are not waiting for authorization</i>"));
|
|
6038 }
|
|
6039
|
|
6040 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from "
|
|
6041 "the following buddies"), _("You can re-request "
|
|
6042 "authorization from these buddies by "
|
|
6043 "right-clicking on them and selecting "
|
|
6044 "\"Re-request Authorization.\""), text, NULL, NULL);
|
|
6045 g_free(text);
|
|
6046 }
|
|
6047
|
|
6048 static void search_by_email_cb(GaimConnection *gc, const char *email)
|
|
6049 {
|
|
6050 OscarData *od = (OscarData *)gc->proto_data;
|
|
6051
|
|
6052 aim_search_address(od, email);
|
|
6053 }
|
|
6054
|
|
6055 static void oscar_show_find_email(GaimPluginAction *action)
|
|
6056 {
|
|
6057 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6058 gaim_request_input(gc, _("Find Buddy by E-Mail"),
|
|
6059 _("Search for a buddy by e-mail address"),
|
|
6060 _("Type the e-mail address of the buddy you are "
|
|
6061 "searching for."),
|
|
6062 NULL, FALSE, FALSE, NULL,
|
|
6063 _("Search"), G_CALLBACK(search_by_email_cb),
|
|
6064 _("Cancel"), NULL, gc);
|
|
6065 }
|
|
6066
|
|
6067 static void oscar_show_set_info(GaimPluginAction *action)
|
|
6068 {
|
|
6069 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6070 gaim_account_request_change_user_info(gaim_connection_get_account(gc));
|
|
6071 }
|
|
6072
|
|
6073 static void oscar_show_set_info_icqurl(GaimPluginAction *action)
|
|
6074 {
|
|
6075 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6076 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php");
|
|
6077 }
|
|
6078
|
|
6079 static void oscar_change_pass(GaimPluginAction *action)
|
|
6080 {
|
|
6081 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6082 gaim_account_request_change_password(gaim_connection_get_account(gc));
|
|
6083 }
|
|
6084
|
|
6085 static void oscar_show_chpassurl(GaimPluginAction *action)
|
|
6086 {
|
|
6087 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6088 OscarData *od = gc->proto_data;
|
|
6089 gchar *substituted = gaim_strreplace(od->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc)));
|
|
6090 gaim_notify_uri(gc, substituted);
|
|
6091 g_free(substituted);
|
|
6092 }
|
|
6093
|
|
6094 static void oscar_show_imforwardingurl(GaimPluginAction *action)
|
|
6095 {
|
|
6096 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6097 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1");
|
|
6098 }
|
|
6099
|
|
6100 static void oscar_set_icon(GaimConnection *gc, const char *iconfile)
|
|
6101 {
|
|
6102 OscarData *od = gc->proto_data;
|
|
6103 FILE *file;
|
|
6104 struct stat st;
|
|
6105
|
|
6106 if (iconfile == NULL) {
|
|
6107 aim_ssi_delicon(od);
|
|
6108 } else if (!g_stat(iconfile, &st)) {
|
|
6109 guchar *buf = g_malloc(st.st_size);
|
|
6110 file = g_fopen(iconfile, "rb");
|
|
6111 if (file)
|
|
6112 {
|
|
6113 GaimCipher *cipher;
|
|
6114 GaimCipherContext *context;
|
|
6115 guchar md5[16];
|
|
6116 int len;
|
|
6117
|
|
6118 /* XXX - Use g_file_get_contents()? */
|
|
6119 len = fread(buf, 1, st.st_size, file);
|
|
6120 fclose(file);
|
|
6121
|
|
6122 cipher = gaim_ciphers_find_cipher("md5");
|
|
6123 context = gaim_cipher_context_new(cipher, NULL);
|
|
6124 gaim_cipher_context_append(context, buf, len);
|
|
6125 gaim_cipher_context_digest(context, 16, md5, NULL);
|
|
6126 gaim_cipher_context_destroy(context);
|
|
6127
|
|
6128 aim_ssi_seticon(od, md5, 16);
|
|
6129 } else
|
|
6130 gaim_debug_error("oscar",
|
|
6131 "Can't open buddy icon file!\n");
|
|
6132 g_free(buf);
|
|
6133 } else
|
|
6134 gaim_debug_error("oscar", "Can't stat buddy icon file!\n");
|
|
6135 }
|
|
6136
|
|
6137 /**
|
|
6138 * Called by the Gaim core to determine whether or not we're
|
|
6139 * allowed to send a file to this user.
|
|
6140 */
|
|
6141 static gboolean
|
|
6142 oscar_can_receive_file(GaimConnection *gc, const char *who)
|
|
6143 {
|
|
6144 OscarData *od;
|
|
6145 GaimAccount *account;
|
|
6146
|
|
6147 od = gc->proto_data;
|
|
6148 account = gaim_connection_get_account(gc);
|
|
6149
|
|
6150 if (od != NULL)
|
|
6151 {
|
|
6152 aim_userinfo_t *userinfo;
|
|
6153 userinfo = aim_locate_finduserinfo(od, who);
|
|
6154
|
|
6155 /*
|
|
6156 * Don't allowing sending a file to a user that does not support
|
|
6157 * file transfer, and don't allow sending to ourselves.
|
|
6158 */
|
|
6159 if (((userinfo == NULL) ||
|
|
6160 (userinfo->capabilities & OSCAR_CAPABILITY_SENDFILE)) &&
|
|
6161 aim_sncmp(who, gaim_account_get_username(account)))
|
|
6162 {
|
|
6163 return TRUE;
|
|
6164 }
|
|
6165 }
|
|
6166
|
|
6167 return FALSE;
|
|
6168 }
|
|
6169
|
|
6170 static GaimXfer *
|
|
6171 oscar_new_xfer(GaimConnection *gc, const char *who)
|
|
6172 {
|
|
6173 GaimXfer *xfer;
|
|
6174 OscarData *od;
|
|
6175 GaimAccount *account;
|
|
6176 PeerConnection *conn;
|
|
6177
|
|
6178 od = gc->proto_data;
|
|
6179 account = gaim_connection_get_account(gc);
|
|
6180
|
|
6181 xfer = gaim_xfer_new(account, GAIM_XFER_SEND, who);
|
|
6182 gaim_xfer_ref(xfer);
|
|
6183 gaim_xfer_set_init_fnc(xfer, peer_oft_sendcb_init);
|
|
6184 gaim_xfer_set_cancel_send_fnc(xfer, peer_oft_cb_generic_cancel);
|
|
6185 gaim_xfer_set_request_denied_fnc(xfer, peer_oft_cb_generic_cancel);
|
|
6186 gaim_xfer_set_ack_fnc(xfer, peer_oft_sendcb_ack);
|
|
6187
|
|
6188 conn = peer_connection_new(od, OSCAR_CAPABILITY_SENDFILE, who);
|
|
6189 conn->flags |= PEER_CONNECTION_FLAG_INITIATED_BY_ME;
|
|
6190 conn->flags |= PEER_CONNECTION_FLAG_APPROVED;
|
|
6191 aim_icbm_makecookie(conn->cookie);
|
|
6192 conn->xfer = xfer;
|
|
6193 xfer->data = conn;
|
|
6194
|
|
6195 return xfer;
|
|
6196 }
|
|
6197
|
|
6198 /*
|
|
6199 * Called by the Gaim core when the user indicates that a
|
|
6200 * file is to be sent to a special someone.
|
|
6201 */
|
|
6202 static void
|
|
6203 oscar_send_file(GaimConnection *gc, const char *who, const char *file)
|
|
6204 {
|
|
6205 GaimXfer *xfer;
|
|
6206
|
|
6207 xfer = oscar_new_xfer(gc, who);
|
|
6208
|
|
6209 if (file != NULL)
|
|
6210 gaim_xfer_request_accepted(xfer, file);
|
|
6211 else
|
|
6212 gaim_xfer_request(xfer);
|
|
6213 }
|
|
6214
|
|
6215 static GList *
|
|
6216 oscar_actions(GaimPlugin *plugin, gpointer context)
|
|
6217 {
|
|
6218 GaimConnection *gc = (GaimConnection *) context;
|
|
6219 OscarData *od = gc->proto_data;
|
14348
|
6220 GList *menu = NULL;
|
14192
|
6221 GaimPluginAction *act;
|
|
6222
|
|
6223 act = gaim_plugin_action_new(_("Set User Info..."),
|
|
6224 oscar_show_set_info);
|
14348
|
6225 menu = g_list_prepend(menu, act);
|
14192
|
6226
|
|
6227 if (od->icq)
|
|
6228 {
|
|
6229 act = gaim_plugin_action_new(_("Set User Info (URL)..."),
|
|
6230 oscar_show_set_info_icqurl);
|
14348
|
6231 menu = g_list_prepend(menu, act);
|
14192
|
6232 }
|
|
6233
|
|
6234 act = gaim_plugin_action_new(_("Change Password..."),
|
|
6235 oscar_change_pass);
|
14348
|
6236 menu = g_list_prepend(menu, act);
|
14192
|
6237
|
|
6238 if (od->authinfo->chpassurl != NULL)
|
|
6239 {
|
|
6240 act = gaim_plugin_action_new(_("Change Password (URL)"),
|
|
6241 oscar_show_chpassurl);
|
14348
|
6242 menu = g_list_prepend(menu, act);
|
14192
|
6243
|
|
6244 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"),
|
|
6245 oscar_show_imforwardingurl);
|
14348
|
6246 menu = g_list_prepend(menu, act);
|
|
6247 }
|
|
6248
|
|
6249 menu = g_list_prepend(menu, NULL);
|
14192
|
6250
|
|
6251 if (od->icq)
|
|
6252 {
|
|
6253 /* ICQ actions */
|
|
6254 act = gaim_plugin_action_new(_("Set Privacy Options..."),
|
|
6255 oscar_show_icq_privacy_opts);
|
14348
|
6256 menu = g_list_prepend(menu, act);
|
14192
|
6257 }
|
|
6258 else
|
|
6259 {
|
|
6260 /* AIM actions */
|
|
6261 act = gaim_plugin_action_new(_("Format Screen Name..."),
|
|
6262 oscar_show_format_screenname);
|
14348
|
6263 menu = g_list_prepend(menu, act);
|
14192
|
6264
|
|
6265 act = gaim_plugin_action_new(_("Confirm Account"),
|
|
6266 oscar_confirm_account);
|
14348
|
6267 menu = g_list_prepend(menu, act);
|
14192
|
6268
|
|
6269 act = gaim_plugin_action_new(_("Display Currently Registered E-Mail Address"),
|
|
6270 oscar_show_email);
|
14348
|
6271 menu = g_list_prepend(menu, act);
|
14192
|
6272
|
|
6273 act = gaim_plugin_action_new(_("Change Currently Registered E-Mail Address..."),
|
|
6274 oscar_show_change_email);
|
14348
|
6275 menu = g_list_prepend(menu, act);
|
|
6276 }
|
|
6277
|
|
6278 menu = g_list_prepend(menu, NULL);
|
14192
|
6279
|
|
6280 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"),
|
|
6281 oscar_show_awaitingauth);
|
14348
|
6282 menu = g_list_prepend(menu, act);
|
|
6283
|
|
6284 menu = g_list_prepend(menu, NULL);
|
14192
|
6285
|
|
6286 act = gaim_plugin_action_new(_("Search for Buddy by E-Mail Address..."),
|
|
6287 oscar_show_find_email);
|
14348
|
6288 menu = g_list_prepend(menu, act);
|
14192
|
6289
|
|
6290 #if 0
|
|
6291 act = gaim_plugin_action_new(_("Search for Buddy by Information"),
|
|
6292 show_find_info);
|
14348
|
6293 menu = g_list_prepend(menu, act);
|
14192
|
6294 #endif
|
|
6295
|
14348
|
6296 menu = g_list_reverse(menu);
|
|
6297
|
|
6298 return menu;
|
14192
|
6299 }
|
|
6300
|
|
6301 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new)
|
|
6302 {
|
|
6303 OscarData *od = gc->proto_data;
|
|
6304
|
|
6305 if (od->icq) {
|
|
6306 aim_icq_changepasswd(od, new);
|
|
6307 } else {
|
|
6308 FlapConnection *conn;
|
|
6309 conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
|
|
6310 if (conn) {
|
|
6311 aim_admin_changepasswd(od, conn, new, old);
|
|
6312 } else {
|
|
6313 od->chpass = TRUE;
|
|
6314 od->oldp = g_strdup(old);
|
|
6315 od->newp = g_strdup(new);
|
|
6316 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
6317 }
|
|
6318 }
|
|
6319 }
|
|
6320
|
|
6321 static void
|
|
6322 oscar_convo_closed(GaimConnection *gc, const char *who)
|
|
6323 {
|
|
6324 OscarData *od;
|
|
6325 PeerConnection *conn;
|
|
6326
|
|
6327 od = gc->proto_data;
|
|
6328 conn = peer_connection_find_by_type(od, who, OSCAR_CAPABILITY_DIRECTIM);
|
|
6329
|
|
6330 if (conn != NULL)
|
|
6331 {
|
|
6332 if (!conn->ready)
|
|
6333 aim_im_sendch2_cancel(conn);
|
|
6334
|
|
6335 peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED);
|
|
6336 }
|
|
6337 }
|
|
6338
|
|
6339 static void
|
|
6340 recent_buddies_cb(const char *name, GaimPrefType type,
|
|
6341 gconstpointer value, gpointer data)
|
|
6342 {
|
|
6343 GaimConnection *gc = data;
|
|
6344 OscarData *od = gc->proto_data;
|
|
6345 guint32 presence;
|
|
6346
|
|
6347 presence = aim_ssi_getpresence(od->ssi.local);
|
|
6348
|
|
6349 if (value) {
|
|
6350 presence &= ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES;
|
|
6351 aim_ssi_setpresence(od, presence);
|
|
6352 } else {
|
|
6353 presence |= AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES;
|
|
6354 aim_ssi_setpresence(od, presence);
|
|
6355 }
|
|
6356 }
|
|
6357
|
|
6358 #ifdef USE_PRPL_PREFERENCES
|
|
6359 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group"));
|
|
6360 gaim_plugin_pref_frame_add(frame, ppref);
|
|
6361
|
|
6362 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle"));
|
|
6363 gaim_plugin_pref_frame_add(frame, ppref);
|
|
6364 #endif
|
|
6365
|
|
6366 static const char *
|
|
6367 oscar_normalize(const GaimAccount *account, const char *str)
|
|
6368 {
|
|
6369 static char buf[BUF_LEN];
|
|
6370 char *tmp1, *tmp2;
|
|
6371 int i, j;
|
|
6372
|
|
6373 g_return_val_if_fail(str != NULL, NULL);
|
|
6374
|
|
6375 strncpy(buf, str, BUF_LEN);
|
|
6376 for (i=0, j=0; buf[j]; i++, j++)
|
|
6377 {
|
|
6378 while (buf[j] == ' ')
|
|
6379 j++;
|
|
6380 buf[i] = buf[j];
|
|
6381 }
|
|
6382 buf[i] = '\0';
|
|
6383
|
|
6384 tmp1 = g_utf8_strdown(buf, -1);
|
|
6385 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT);
|
|
6386 g_snprintf(buf, sizeof(buf), "%s", tmp2);
|
|
6387 g_free(tmp2);
|
|
6388 g_free(tmp1);
|
|
6389
|
|
6390 return buf;
|
|
6391 }
|
|
6392
|
|
6393 static gboolean
|
|
6394 oscar_offline_message(const GaimBuddy *buddy)
|
|
6395 {
|
|
6396 OscarData *od;
|
|
6397 GaimAccount *account;
|
|
6398 GaimConnection *gc;
|
|
6399
|
|
6400 account = gaim_buddy_get_account(buddy);
|
|
6401 gc = gaim_account_get_connection(account);
|
|
6402 od = (OscarData *)gc->proto_data;
|
|
6403
|
|
6404 return (od->icq && aim_sn_is_icq(gaim_account_get_username(account)));
|
|
6405 }
|
|
6406
|
|
6407 static GaimPluginProtocolInfo prpl_info =
|
|
6408 {
|
|
6409 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE,
|
|
6410 NULL, /* user_splits */
|
|
6411 NULL, /* protocol_options */
|
|
6412 {"jpeg,gif,bmp,ico", 48, 48, 50, 50,
|
|
6413 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */
|
|
6414 oscar_list_icon, /* list_icon */
|
|
6415 oscar_list_emblems, /* list_emblems */
|
|
6416 oscar_status_text, /* status_text */
|
|
6417 oscar_tooltip_text, /* tooltip_text */
|
|
6418 oscar_status_types, /* status_types */
|
|
6419 oscar_blist_node_menu, /* blist_node_menu */
|
|
6420 oscar_chat_info, /* chat_info */
|
|
6421 oscar_chat_info_defaults, /* chat_info_defaults */
|
|
6422 oscar_login, /* login */
|
|
6423 oscar_close, /* close */
|
|
6424 oscar_send_im, /* send_im */
|
|
6425 oscar_set_info, /* set_info */
|
|
6426 oscar_send_typing, /* send_typing */
|
|
6427 oscar_get_info, /* get_info */
|
|
6428 oscar_set_status, /* set_status */
|
|
6429 oscar_set_idle, /* set_idle */
|
|
6430 oscar_change_passwd, /* change_passwd */
|
|
6431 oscar_add_buddy, /* add_buddy */
|
|
6432 NULL, /* add_buddies */
|
|
6433 oscar_remove_buddy, /* remove_buddy */
|
|
6434 NULL, /* remove_buddies */
|
|
6435 oscar_add_permit, /* add_permit */
|
|
6436 oscar_add_deny, /* add_deny */
|
|
6437 oscar_rem_permit, /* rem_permit */
|
|
6438 oscar_rem_deny, /* rem_deny */
|
|
6439 oscar_set_permit_deny, /* set_permit_deny */
|
|
6440 oscar_join_chat, /* join_chat */
|
|
6441 NULL, /* reject_chat */
|
|
6442 oscar_get_chat_name, /* get_chat_name */
|
|
6443 oscar_chat_invite, /* chat_invite */
|
|
6444 oscar_chat_leave, /* chat_leave */
|
|
6445 NULL, /* chat_whisper */
|
|
6446 oscar_send_chat, /* chat_send */
|
|
6447 oscar_keepalive, /* keepalive */
|
|
6448 NULL, /* register_user */
|
|
6449 NULL, /* get_cb_info */
|
|
6450 NULL, /* get_cb_away */
|
|
6451 oscar_alias_buddy, /* alias_buddy */
|
|
6452 oscar_move_buddy, /* group_buddy */
|
|
6453 oscar_rename_group, /* rename_group */
|
|
6454 NULL, /* buddy_free */
|
|
6455 oscar_convo_closed, /* convo_closed */
|
|
6456 oscar_normalize, /* normalize */
|
|
6457 oscar_set_icon, /* set_buddy_icon */
|
|
6458 NULL, /* remove_group */
|
|
6459 NULL, /* get_cb_real_name */
|
|
6460 NULL, /* set_chat_topic */
|
|
6461 NULL, /* find_blist_chat */
|
|
6462 NULL, /* roomlist_get_list */
|
|
6463 NULL, /* roomlist_cancel */
|
|
6464 NULL, /* roomlist_expand_category */
|
|
6465 oscar_can_receive_file, /* can_receive_file */
|
|
6466 oscar_send_file, /* send_file */
|
|
6467 oscar_new_xfer, /* new_xfer */
|
|
6468 oscar_offline_message, /* offline_message */
|
|
6469 NULL, /* whiteboard_prpl_ops */
|
|
6470 };
|
|
6471
|
|
6472 static GaimPluginInfo info =
|
|
6473 {
|
|
6474 GAIM_PLUGIN_MAGIC,
|
|
6475 GAIM_MAJOR_VERSION,
|
|
6476 GAIM_MINOR_VERSION,
|
|
6477 GAIM_PLUGIN_PROTOCOL, /**< type */
|
|
6478 NULL, /**< ui_requirement */
|
|
6479 0, /**< flags */
|
|
6480 NULL, /**< dependencies */
|
|
6481 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
6482
|
|
6483 "prpl-oscar", /**< id */
|
|
6484 "AIM/ICQ", /**< name */
|
|
6485 VERSION, /**< version */
|
|
6486 /** summary */
|
|
6487 N_("AIM/ICQ Protocol Plugin"),
|
|
6488 /** description */
|
|
6489 N_("AIM/ICQ Protocol Plugin"),
|
|
6490 NULL, /**< author */
|
|
6491 GAIM_WEBSITE, /**< homepage */
|
|
6492
|
|
6493 NULL, /**< load */
|
|
6494 NULL, /**< unload */
|
|
6495 NULL, /**< destroy */
|
|
6496
|
|
6497 NULL, /**< ui_info */
|
|
6498 &prpl_info, /**< extra_info */
|
|
6499 NULL,
|
|
6500 oscar_actions
|
|
6501 };
|
|
6502
|
|
6503 static void
|
|
6504 init_plugin(GaimPlugin *plugin)
|
|
6505 {
|
|
6506 GaimAccountOption *option;
|
|
6507
|
|
6508 option = gaim_account_option_string_new(_("Server"), "server", OSCAR_DEFAULT_LOGIN_SERVER);
|
|
6509 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
6510
|
|
6511 option = gaim_account_option_int_new(_("Port"), "port", OSCAR_DEFAULT_LOGIN_PORT);
|
|
6512 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
6513
|
|
6514 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
|
|
6515 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
6516
|
|
6517 option = gaim_account_option_bool_new(
|
|
6518 _("Always use AIM/ICQ proxy server\n(slower, but does not reveal your IP address)"), "always_use_rv_proxy",
|
|
6519 OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY);
|
|
6520 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
6521
|
|
6522 /* Preferences */
|
|
6523 gaim_prefs_add_none("/plugins/prpl/oscar");
|
|
6524 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE);
|
|
6525 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE);
|
|
6526 gaim_prefs_remove("/plugins/prpl/oscar/always_use_rv_proxy");
|
|
6527 }
|
|
6528
|
|
6529 GAIM_INIT_PLUGIN(oscar, init_plugin, info);
|