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