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 {
|
14402
|
2047 peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL);
|
14192
|
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');
|
14402
|
2278 /* TODO: Should use an encoding other than ASCII? */
|
14192
|
2279 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i]));
|
|
2280 }
|
|
2281 msg2[i] = NULL;
|
|
2282
|
|
2283 switch (args->type) {
|
|
2284 case 0x01: { /* MacICQ message or basic offline message */
|
|
2285 if (i >= 1) {
|
|
2286 gchar *uin = g_strdup_printf("%u", args->uin);
|
|
2287 gchar *tmp;
|
|
2288
|
|
2289 /* If the message came from an ICQ user then escape any HTML */
|
|
2290 tmp = g_markup_escape_text(msg2[0], -1);
|
|
2291
|
|
2292 if (t) { /* This is an offline message */
|
|
2293 /* The timestamp is UTC-ish, so we need to get the offset */
|
|
2294 #ifdef HAVE_TM_GMTOFF
|
|
2295 time_t now;
|
|
2296 struct tm *tm;
|
|
2297 now = time(NULL);
|
|
2298 tm = localtime(&now);
|
|
2299 t += tm->tm_gmtoff;
|
|
2300 #else
|
|
2301 # ifdef HAVE_TIMEZONE
|
|
2302 tzset();
|
|
2303 t -= timezone;
|
|
2304 # endif
|
|
2305 #endif
|
|
2306 serv_got_im(gc, uin, tmp, 0, t);
|
|
2307 } else { /* This is a message from MacICQ/Miranda */
|
|
2308 serv_got_im(gc, uin, tmp, 0, time(NULL));
|
|
2309 }
|
|
2310 g_free(uin);
|
|
2311 g_free(tmp);
|
|
2312 }
|
|
2313 } break;
|
|
2314
|
|
2315 case 0x04: { /* Someone sent you a URL */
|
|
2316 if (i >= 2) {
|
|
2317 if (msg2[1] != NULL) {
|
|
2318 gchar *uin = g_strdup_printf("%u", args->uin);
|
|
2319 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>",
|
|
2320 msg2[1],
|
|
2321 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]);
|
|
2322 serv_got_im(gc, uin, message, 0, time(NULL));
|
|
2323 g_free(uin);
|
|
2324 g_free(message);
|
|
2325 }
|
|
2326 }
|
|
2327 } break;
|
|
2328
|
|
2329 case 0x06: { /* Someone requested authorization */
|
|
2330 if (i >= 6) {
|
|
2331 struct name_data *data = g_new(struct name_data, 1);
|
|
2332 gchar *sn = g_strdup_printf("%u", args->uin);
|
|
2333 gchar *reason;
|
|
2334 gchar *dialog_msg;
|
|
2335
|
|
2336 if (msg2[5] != NULL)
|
|
2337 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5]));
|
|
2338 else
|
|
2339 reason = g_strdup(_("No reason given."));
|
|
2340
|
|
2341 dialog_msg = g_strdup_printf(_("The user %u wants to add %s to their buddy list for the following reason:\n%s"),
|
|
2342 args->uin, gaim_account_get_username(gc->account), reason);
|
|
2343 g_free(reason);
|
|
2344 gaim_debug_info("oscar",
|
|
2345 "Received an authorization request from UIN %u\n",
|
|
2346 args->uin);
|
|
2347 data->gc = gc;
|
|
2348 data->name = sn;
|
|
2349 data->nick = NULL;
|
|
2350
|
|
2351 gaim_request_action(gc, NULL, _("Authorization Request"),
|
|
2352 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data,
|
|
2353 2, _("_Authorize"),
|
|
2354 G_CALLBACK(gaim_auth_grant),
|
|
2355 _("_Deny"),
|
|
2356 G_CALLBACK(gaim_auth_dontgrant_msgprompt));
|
|
2357 g_free(dialog_msg);
|
|
2358 }
|
|
2359 } break;
|
|
2360
|
|
2361 case 0x07: { /* Someone has denied you authorization */
|
|
2362 if (i >= 1) {
|
|
2363 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."));
|
|
2364 gaim_notify_info(gc, NULL, _("ICQ authorization denied."),
|
|
2365 dialog_msg);
|
|
2366 g_free(dialog_msg);
|
|
2367 }
|
|
2368 } break;
|
|
2369
|
|
2370 case 0x08: { /* Someone has granted you authorization */
|
|
2371 gchar *dialog_msg = g_strdup_printf(_("The user %u has granted your request to add them to your buddy list."), args->uin);
|
|
2372 gaim_notify_info(gc, NULL, "ICQ authorization accepted.",
|
|
2373 dialog_msg);
|
|
2374 g_free(dialog_msg);
|
|
2375 } break;
|
|
2376
|
|
2377 case 0x09: { /* Message from the Godly ICQ server itself, I think */
|
|
2378 if (i >= 5) {
|
|
2379 gchar *dialog_msg = g_strdup_printf(_("You have received a special message\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]);
|
|
2380 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg);
|
|
2381 g_free(dialog_msg);
|
|
2382 }
|
|
2383 } break;
|
|
2384
|
|
2385 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */
|
|
2386 if (i >= 6) {
|
|
2387 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]);
|
|
2388 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg);
|
|
2389 g_free(dialog_msg);
|
|
2390 }
|
|
2391 } break;
|
|
2392
|
|
2393 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */
|
|
2394 if (i >= 6) {
|
|
2395 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]);
|
|
2396 gaim_notify_info(gc, NULL, "ICQ E-Mail", dialog_msg);
|
|
2397 g_free(dialog_msg);
|
|
2398 }
|
|
2399 } break;
|
|
2400
|
|
2401 case 0x12: {
|
|
2402 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
|
|
2403 /* Someone added you to their buddy list? */
|
|
2404 } break;
|
|
2405
|
|
2406 case 0x13: { /* Someone has sent you some ICQ buddies */
|
|
2407 guint i, num;
|
|
2408 gchar **text;
|
|
2409 text = g_strsplit(args->msg, "\376", 0);
|
|
2410 if (text) {
|
|
2411 num = 0;
|
|
2412 for (i=0; i<strlen(text[0]); i++)
|
|
2413 num = num*10 + text[0][i]-48;
|
|
2414 for (i=0; i<num; i++) {
|
|
2415 struct name_data *data = g_new(struct name_data, 1);
|
|
2416 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]);
|
|
2417 data->gc = gc;
|
|
2418 data->name = g_strdup(text[i*2+1]);
|
|
2419 data->nick = g_strdup(text[i*2+2]);
|
|
2420
|
|
2421 gaim_request_action(gc, NULL, message,
|
|
2422 _("Do you want to add this buddy "
|
|
2423 "to your buddy list?"),
|
|
2424 GAIM_DEFAULT_ACTION_NONE, data, 2,
|
|
2425 _("Add"), G_CALLBACK(gaim_icq_buddyadd),
|
|
2426 _("_Decline"), G_CALLBACK(oscar_free_name_data));
|
|
2427 g_free(message);
|
|
2428 }
|
|
2429 g_strfreev(text);
|
|
2430 }
|
|
2431 } break;
|
|
2432
|
|
2433 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */
|
|
2434 /* This is boring and silly. */
|
|
2435 } break;
|
|
2436
|
|
2437 default: {
|
|
2438 gaim_debug_info("oscar",
|
|
2439 "Received a channel 4 message of unknown type "
|
|
2440 "(type 0x%02hhx).\n", args->type);
|
|
2441 } break;
|
|
2442 }
|
|
2443
|
|
2444 g_strfreev(msg1);
|
|
2445 g_strfreev(msg2);
|
|
2446
|
|
2447 return 1;
|
|
2448 }
|
|
2449
|
|
2450 static int gaim_parse_incoming_im(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2451 guint16 channel;
|
|
2452 int ret = 0;
|
|
2453 aim_userinfo_t *userinfo;
|
|
2454 va_list ap;
|
|
2455
|
|
2456 va_start(ap, fr);
|
|
2457 channel = (guint16)va_arg(ap, unsigned int);
|
|
2458 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
2459
|
|
2460 switch (channel) {
|
|
2461 case 1: { /* standard message */
|
|
2462 struct aim_incomingim_ch1_args *args;
|
|
2463 args = va_arg(ap, struct aim_incomingim_ch1_args *);
|
|
2464 ret = incomingim_chan1(od, conn, userinfo, args);
|
|
2465 } break;
|
|
2466
|
|
2467 case 2: { /* rendezvous */
|
|
2468 IcbmArgsCh2 *args;
|
|
2469 args = va_arg(ap, IcbmArgsCh2 *);
|
|
2470 ret = incomingim_chan2(od, conn, userinfo, args);
|
|
2471 } break;
|
|
2472
|
|
2473 case 4: { /* ICQ */
|
|
2474 struct aim_incomingim_ch4_args *args;
|
|
2475 args = va_arg(ap, struct aim_incomingim_ch4_args *);
|
|
2476 ret = incomingim_chan4(od, conn, userinfo, args, 0);
|
|
2477 } break;
|
|
2478
|
|
2479 default: {
|
|
2480 gaim_debug_warning("oscar",
|
|
2481 "ICBM received on unsupported channel (channel "
|
|
2482 "0x%04hx).", channel);
|
|
2483 } break;
|
|
2484 }
|
|
2485
|
|
2486 va_end(ap);
|
|
2487
|
|
2488 return ret;
|
|
2489 }
|
|
2490
|
|
2491 static int gaim_parse_misses(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2492 GaimConnection *gc = od->gc;
|
|
2493 GaimAccount *account = gaim_connection_get_account(gc);
|
|
2494 char *buf;
|
|
2495 va_list ap;
|
|
2496 guint16 chan, nummissed, reason;
|
|
2497 aim_userinfo_t *userinfo;
|
|
2498
|
|
2499 va_start(ap, fr);
|
|
2500 chan = (guint16)va_arg(ap, unsigned int);
|
|
2501 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
2502 nummissed = (guint16)va_arg(ap, unsigned int);
|
|
2503 reason = (guint16)va_arg(ap, unsigned int);
|
|
2504 va_end(ap);
|
|
2505
|
|
2506 switch(reason) {
|
|
2507 case 0: /* Invalid (0) */
|
|
2508 buf = g_strdup_printf(
|
|
2509 ngettext(
|
|
2510 "You missed %hu message from %s because it was invalid.",
|
|
2511 "You missed %hu messages from %s because they were invalid.",
|
|
2512 nummissed),
|
|
2513 nummissed,
|
|
2514 userinfo->sn);
|
|
2515 break;
|
|
2516 case 1: /* Message too large */
|
|
2517 buf = g_strdup_printf(
|
|
2518 ngettext(
|
|
2519 "You missed %hu message from %s because it was too large.",
|
|
2520 "You missed %hu messages from %s because they were too large.",
|
|
2521 nummissed),
|
|
2522 nummissed,
|
|
2523 userinfo->sn);
|
|
2524 break;
|
|
2525 case 2: /* Rate exceeded */
|
|
2526 buf = g_strdup_printf(
|
|
2527 ngettext(
|
|
2528 "You missed %hu message from %s because the rate limit has been exceeded.",
|
|
2529 "You missed %hu messages from %s because the rate limit has been exceeded.",
|
|
2530 nummissed),
|
|
2531 nummissed,
|
|
2532 userinfo->sn);
|
|
2533 break;
|
|
2534 case 3: /* Evil Sender */
|
|
2535 buf = g_strdup_printf(
|
|
2536 ngettext(
|
|
2537 "You missed %hu message from %s because he/she was too evil.",
|
|
2538 "You missed %hu messages from %s because he/she was too evil.",
|
|
2539 nummissed),
|
|
2540 nummissed,
|
|
2541 userinfo->sn);
|
|
2542 break;
|
|
2543 case 4: /* Evil Receiver */
|
|
2544 buf = g_strdup_printf(
|
|
2545 ngettext(
|
|
2546 "You missed %hu message from %s because you are too evil.",
|
|
2547 "You missed %hu messages from %s because you are too evil.",
|
|
2548 nummissed),
|
|
2549 nummissed,
|
|
2550 userinfo->sn);
|
|
2551 break;
|
|
2552 default:
|
|
2553 buf = g_strdup_printf(
|
|
2554 ngettext(
|
|
2555 "You missed %hu message from %s for an unknown reason.",
|
|
2556 "You missed %hu messages from %s for an unknown reason.",
|
|
2557 nummissed),
|
|
2558 nummissed,
|
|
2559 userinfo->sn);
|
|
2560 break;
|
|
2561 }
|
|
2562
|
|
2563 if (!gaim_conv_present_error(userinfo->sn, account, buf))
|
|
2564 gaim_notify_error(od->gc, NULL, buf, NULL);
|
|
2565 g_free(buf);
|
|
2566
|
|
2567 return 1;
|
|
2568 }
|
|
2569
|
|
2570 static int
|
|
2571 gaim_parse_clientauto_ch2(OscarData *od, const char *who, guint16 reason, const guchar *cookie)
|
|
2572 {
|
|
2573 if (reason == 0x0003)
|
|
2574 {
|
|
2575 /* Rendezvous was refused. */
|
|
2576 PeerConnection *conn;
|
|
2577
|
|
2578 conn = peer_connection_find_by_cookie(od, who, cookie);
|
|
2579
|
|
2580 if (conn == NULL)
|
|
2581 {
|
|
2582 gaim_debug_info("oscar", "Received a rendezvous cancel message "
|
|
2583 "for a nonexistant connection from %s.\n", who);
|
|
2584 }
|
|
2585 else
|
|
2586 {
|
14402
|
2587 peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_REFUSED, NULL);
|
14192
|
2588 }
|
|
2589 }
|
|
2590 else
|
|
2591 {
|
|
2592 gaim_debug_warning("oscar", "Received an unknown rendezvous "
|
|
2593 "message from %s. Type 0x%04hx\n", who, reason);
|
|
2594 }
|
|
2595
|
|
2596 return 0;
|
|
2597 }
|
|
2598
|
|
2599 static int gaim_parse_clientauto_ch4(OscarData *od, char *who, guint16 reason, guint32 state, char *msg) {
|
|
2600 GaimConnection *gc = od->gc;
|
|
2601
|
|
2602 switch(reason) {
|
|
2603 case 0x0003: { /* Reply from an ICQ status message request */
|
|
2604 char *title, *statusmsg, **splitmsg, *dialogmsg;
|
|
2605
|
|
2606 title = g_strdup_printf(_("Info for %s"), who);
|
|
2607
|
|
2608 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */
|
|
2609 statusmsg = oscar_icqstatus(state);
|
|
2610 splitmsg = g_strsplit(msg, "\r\n", 0);
|
|
2611 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg));
|
|
2612 g_free(statusmsg);
|
|
2613 g_strfreev(splitmsg);
|
|
2614
|
|
2615 gaim_notify_userinfo(gc, who, dialogmsg, NULL, NULL);
|
|
2616
|
|
2617 g_free(title);
|
|
2618 g_free(dialogmsg);
|
|
2619 } break;
|
|
2620
|
|
2621 default: {
|
|
2622 gaim_debug_warning("oscar",
|
|
2623 "Received an unknown client auto-response from %s. "
|
|
2624 "Type 0x%04hx\n", who, reason);
|
|
2625 } break;
|
|
2626 } /* end of switch */
|
|
2627
|
|
2628 return 0;
|
|
2629 }
|
|
2630
|
|
2631 static int gaim_parse_clientauto(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2632 va_list ap;
|
|
2633 guint16 chan, reason;
|
|
2634 char *who;
|
|
2635
|
|
2636 va_start(ap, fr);
|
|
2637 chan = (guint16)va_arg(ap, unsigned int);
|
|
2638 who = va_arg(ap, char *);
|
|
2639 reason = (guint16)va_arg(ap, unsigned int);
|
|
2640
|
|
2641 if (chan == 0x0002) { /* File transfer declined */
|
|
2642 guchar *cookie = va_arg(ap, guchar *);
|
|
2643 return gaim_parse_clientauto_ch2(od, who, reason, cookie);
|
|
2644 } else if (chan == 0x0004) { /* ICQ message */
|
|
2645 guint32 state = 0;
|
|
2646 char *msg = NULL;
|
|
2647 if (reason == 0x0003) {
|
|
2648 state = va_arg(ap, guint32);
|
|
2649 msg = va_arg(ap, char *);
|
|
2650 }
|
|
2651 return gaim_parse_clientauto_ch4(od, who, reason, state, msg);
|
|
2652 }
|
|
2653
|
|
2654 va_end(ap);
|
|
2655
|
|
2656 return 1;
|
|
2657 }
|
|
2658
|
|
2659 static int gaim_parse_genericerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2660 va_list ap;
|
|
2661 guint16 reason;
|
|
2662 char *m;
|
|
2663
|
|
2664 va_start(ap, fr);
|
|
2665 reason = (guint16) va_arg(ap, unsigned int);
|
|
2666 va_end(ap);
|
|
2667
|
|
2668 gaim_debug_error("oscar",
|
|
2669 "snac threw error (reason 0x%04hx: %s)\n", reason,
|
|
2670 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown");
|
|
2671
|
|
2672 m = g_strdup_printf(_("SNAC threw error: %s\n"),
|
|
2673 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error"));
|
|
2674 gaim_notify_error(od->gc, NULL, m, NULL);
|
|
2675 g_free(m);
|
|
2676
|
|
2677 return 1;
|
|
2678 }
|
|
2679
|
|
2680 static int gaim_parse_msgerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2681 GaimConnection *gc = od->gc;
|
|
2682 #ifdef TODOFT
|
|
2683 OscarData *od = gc->proto_data;
|
|
2684 GaimXfer *xfer;
|
|
2685 #endif
|
|
2686 va_list ap;
|
|
2687 guint16 reason;
|
|
2688 char *data, *buf;
|
|
2689
|
|
2690 va_start(ap, fr);
|
|
2691 reason = (guint16)va_arg(ap, unsigned int);
|
|
2692 data = va_arg(ap, char *);
|
|
2693 va_end(ap);
|
|
2694
|
|
2695 gaim_debug_error("oscar",
|
|
2696 "Message error with data %s and reason %hu\n",
|
|
2697 (data != NULL ? data : ""), reason);
|
|
2698
|
|
2699 #ifdef TODOFT
|
|
2700 /* If this was a file transfer request, data is a cookie */
|
|
2701 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, data))) {
|
|
2702 gaim_xfer_cancel_remote(xfer);
|
|
2703 return 1;
|
|
2704 }
|
|
2705 #endif
|
|
2706
|
|
2707 /* Data is assumed to be the destination sn */
|
|
2708 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason."));
|
|
2709 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) {
|
|
2710 g_free(buf);
|
|
2711 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)");
|
|
2712 gaim_notify_error(od->gc, NULL, buf,
|
|
2713 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
|
|
2714 }
|
|
2715 g_free(buf);
|
|
2716
|
|
2717 return 1;
|
|
2718 }
|
|
2719
|
|
2720 static int gaim_parse_mtn(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2721 GaimConnection *gc = od->gc;
|
|
2722 va_list ap;
|
|
2723 guint16 type1, type2;
|
|
2724 char *sn;
|
|
2725
|
|
2726 va_start(ap, fr);
|
|
2727 type1 = (guint16) va_arg(ap, unsigned int);
|
|
2728 sn = va_arg(ap, char *);
|
|
2729 type2 = (guint16) va_arg(ap, unsigned int);
|
|
2730 va_end(ap);
|
|
2731
|
|
2732 switch (type2) {
|
|
2733 case 0x0000: { /* Text has been cleared */
|
|
2734 serv_got_typing_stopped(gc, sn);
|
|
2735 } break;
|
|
2736
|
|
2737 case 0x0001: { /* Paused typing */
|
|
2738 serv_got_typing(gc, sn, 0, GAIM_TYPED);
|
|
2739 } break;
|
|
2740
|
|
2741 case 0x0002: { /* Typing */
|
|
2742 serv_got_typing(gc, sn, 0, GAIM_TYPING);
|
|
2743 } break;
|
|
2744
|
|
2745 default: {
|
|
2746 /*
|
|
2747 * It looks like iChat sometimes sends typing notification
|
|
2748 * with type1=0x0001 and type2=0x000f. Not sure why.
|
|
2749 */
|
|
2750 gaim_debug_info("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2);
|
|
2751 } break;
|
|
2752 }
|
|
2753
|
|
2754 return 1;
|
|
2755 }
|
|
2756
|
|
2757 /*
|
|
2758 * We get this error when there was an error in the locate family. This
|
|
2759 * happens when you request info of someone who is offline.
|
|
2760 */
|
|
2761 static int gaim_parse_locerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2762 gchar *buf;
|
|
2763 va_list ap;
|
|
2764 guint16 reason;
|
|
2765 char *destn;
|
|
2766
|
|
2767 va_start(ap, fr);
|
|
2768 reason = (guint16) va_arg(ap, unsigned int);
|
|
2769 destn = va_arg(ap, char *);
|
|
2770 va_end(ap);
|
|
2771
|
|
2772 if (destn == NULL)
|
|
2773 return 1;
|
|
2774
|
|
2775 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
|
|
2776 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)od->gc), buf)) {
|
|
2777 g_free(buf);
|
|
2778 buf = g_strdup_printf(_("User information for %s unavailable:"), destn);
|
|
2779 gaim_notify_error(od->gc, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
|
|
2780 }
|
|
2781 g_free(buf);
|
|
2782
|
|
2783 return 1;
|
|
2784 }
|
|
2785
|
|
2786 static int gaim_parse_userinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2787 GaimConnection *gc = od->gc;
|
|
2788 GaimAccount *account = gaim_connection_get_account(gc);
|
|
2789 GString *str;
|
|
2790 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL;
|
|
2791 va_list ap;
|
|
2792 aim_userinfo_t *userinfo;
|
|
2793
|
|
2794 va_start(ap, fr);
|
|
2795 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
2796 va_end(ap);
|
|
2797
|
|
2798 str = g_string_new("");
|
|
2799 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn);
|
|
2800 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5));
|
|
2801
|
|
2802 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) {
|
|
2803 time_t t = userinfo->onlinesince - od->timeoffset;
|
|
2804 oscar_string_append(str, "\n<br>", _("Online Since"), gaim_date_format_full(localtime(&t)));
|
|
2805 }
|
|
2806
|
|
2807 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) {
|
|
2808 time_t t = userinfo->membersince - od->timeoffset;
|
|
2809 oscar_string_append(str, "\n<br>", _("Member Since"), gaim_date_format_full(localtime(&t)));
|
|
2810 }
|
|
2811
|
|
2812 if (userinfo->capabilities != 0) {
|
|
2813 tmp = oscar_caps_to_string(userinfo->capabilities);
|
|
2814 oscar_string_append(str, "\n<br>", _("Capabilities"), tmp);
|
|
2815 g_free(tmp);
|
|
2816 }
|
|
2817
|
|
2818 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) {
|
|
2819 tmp = gaim_str_seconds_to_string(userinfo->idletime*60);
|
|
2820 oscar_string_append(str, "\n<br>", _("Idle"), tmp);
|
|
2821 g_free(tmp);
|
|
2822 }
|
|
2823
|
|
2824 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo);
|
|
2825
|
|
2826 /* Available message */
|
|
2827 if ((userinfo->status != NULL) && !(userinfo->flags & AIM_FLAG_AWAY))
|
|
2828 {
|
|
2829 if (userinfo->status[0] != '\0')
|
|
2830 tmp = oscar_encoding_to_utf8(userinfo->status_encoding,
|
|
2831 userinfo->status, userinfo->status_len);
|
|
2832 oscar_string_convert_and_append(account, str, "\n<br>", _("Available Message"), tmp);
|
|
2833 g_free(tmp);
|
|
2834 }
|
|
2835
|
|
2836 /* Away message */
|
|
2837 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) {
|
|
2838 tmp = oscar_encoding_extract(userinfo->away_encoding);
|
|
2839 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len);
|
|
2840 g_free(tmp);
|
|
2841 if (away_utf8 != NULL) {
|
|
2842 g_string_append_printf(str, "\n<hr>%s", away_utf8);
|
|
2843 g_free(away_utf8);
|
|
2844 }
|
|
2845 }
|
|
2846
|
|
2847 /* Info */
|
|
2848 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) {
|
|
2849 tmp = oscar_encoding_extract(userinfo->info_encoding);
|
|
2850 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len);
|
|
2851 g_free(tmp);
|
|
2852 if (info_utf8 != NULL) {
|
|
2853 g_string_append_printf(str, "\n<hr>%s", info_utf8);
|
|
2854 g_free(info_utf8);
|
|
2855 }
|
|
2856 }
|
|
2857
|
|
2858 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account));
|
|
2859 g_string_free(str, TRUE);
|
|
2860 gaim_str_strip_char(tmp, '\r');
|
|
2861 gaim_notify_userinfo(gc, userinfo->sn, tmp, NULL, NULL);
|
|
2862 g_free(tmp);
|
|
2863
|
|
2864 return 1;
|
|
2865 }
|
|
2866
|
|
2867 static int gaim_got_infoblock(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
2868 {
|
|
2869 GaimConnection *gc = od->gc;
|
|
2870 GaimBuddy *b;
|
|
2871 GaimPresence *presence;
|
|
2872 GaimStatus *status;
|
|
2873 gchar *message = NULL;
|
|
2874
|
|
2875 va_list ap;
|
|
2876 aim_userinfo_t *userinfo;
|
|
2877
|
|
2878 va_start(ap, fr);
|
|
2879 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
2880 va_end(ap);
|
|
2881
|
|
2882 b = gaim_find_buddy(gaim_connection_get_account(gc), userinfo->sn);
|
|
2883 if (b == NULL)
|
|
2884 return 1;
|
|
2885
|
|
2886 if (!aim_sn_is_icq(userinfo->sn))
|
|
2887 {
|
|
2888 if (strcmp(gaim_buddy_get_name(b), userinfo->sn))
|
|
2889 serv_got_alias(gc, gaim_buddy_get_name(b), userinfo->sn);
|
|
2890 else
|
|
2891 serv_got_alias(gc, gaim_buddy_get_name(b), NULL);
|
|
2892 }
|
|
2893
|
|
2894 presence = gaim_buddy_get_presence(b);
|
|
2895 status = gaim_presence_get_active_status(presence);
|
|
2896
|
|
2897 if (!gaim_status_is_available(status) && gaim_status_is_online(status))
|
|
2898 {
|
|
2899 if ((userinfo->flags & AIM_FLAG_AWAY) &&
|
|
2900 (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) {
|
|
2901 gchar *charset = oscar_encoding_extract(userinfo->away_encoding);
|
|
2902 message = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len);
|
|
2903 g_free(charset);
|
|
2904 gaim_status_set_attr_string(status, "message", message);
|
|
2905 g_free(message);
|
|
2906 }
|
|
2907 else
|
|
2908 /* Set an empty message so that we know not to show "pending" */
|
|
2909 gaim_status_set_attr_string(status, "message", "");
|
|
2910
|
|
2911 gaim_blist_update_buddy_status(b, status);
|
|
2912 }
|
|
2913
|
|
2914 return 1;
|
|
2915 }
|
|
2916
|
|
2917 static int gaim_parse_motd(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
2918 {
|
|
2919 char *msg;
|
|
2920 guint16 id;
|
|
2921 va_list ap;
|
|
2922
|
|
2923 va_start(ap, fr);
|
|
2924 id = (guint16) va_arg(ap, unsigned int);
|
|
2925 msg = va_arg(ap, char *);
|
|
2926 va_end(ap);
|
|
2927
|
|
2928 gaim_debug_misc("oscar",
|
|
2929 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id);
|
|
2930 if (id < 4)
|
|
2931 gaim_notify_warning(od->gc, NULL,
|
|
2932 _("Your AIM connection may be lost."), NULL);
|
|
2933
|
|
2934 return 1;
|
|
2935 }
|
|
2936
|
|
2937 static int gaim_chatnav_info(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
2938 va_list ap;
|
|
2939 guint16 type;
|
|
2940
|
|
2941 va_start(ap, fr);
|
|
2942 type = (guint16) va_arg(ap, unsigned int);
|
|
2943
|
|
2944 switch(type) {
|
|
2945 case 0x0002: {
|
|
2946 guint8 maxrooms;
|
|
2947 struct aim_chat_exchangeinfo *exchanges;
|
|
2948 int exchangecount, i;
|
|
2949
|
|
2950 maxrooms = (guint8) va_arg(ap, unsigned int);
|
|
2951 exchangecount = va_arg(ap, int);
|
|
2952 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
|
|
2953
|
|
2954 gaim_debug_misc("oscar", "chat info: Chat Rights:\n");
|
|
2955 gaim_debug_misc("oscar",
|
|
2956 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms);
|
|
2957 gaim_debug_misc("oscar",
|
|
2958 "chat info: \tExchange List: (%d total)\n", exchangecount);
|
|
2959 for (i = 0; i < exchangecount; i++)
|
|
2960 gaim_debug_misc("oscar",
|
|
2961 "chat info: \t\t%hu %s\n",
|
|
2962 exchanges[i].number, exchanges[i].name ? exchanges[i].name : "");
|
|
2963 while (od->create_rooms) {
|
|
2964 struct create_room *cr = od->create_rooms->data;
|
|
2965 gaim_debug_info("oscar",
|
|
2966 "creating room %s\n", cr->name);
|
|
2967 aim_chatnav_createroom(od, conn, cr->name, cr->exchange);
|
|
2968 g_free(cr->name);
|
|
2969 od->create_rooms = g_slist_remove(od->create_rooms, cr);
|
|
2970 g_free(cr);
|
|
2971 }
|
|
2972 }
|
|
2973 break;
|
|
2974 case 0x0008: {
|
|
2975 char *fqcn, *name, *ck;
|
|
2976 guint16 instance, flags, maxmsglen, maxoccupancy, unknown, exchange;
|
|
2977 guint8 createperms;
|
|
2978 guint32 createtime;
|
|
2979
|
|
2980 fqcn = va_arg(ap, char *);
|
|
2981 instance = (guint16)va_arg(ap, unsigned int);
|
|
2982 exchange = (guint16)va_arg(ap, unsigned int);
|
|
2983 flags = (guint16)va_arg(ap, unsigned int);
|
|
2984 createtime = va_arg(ap, guint32);
|
|
2985 maxmsglen = (guint16)va_arg(ap, unsigned int);
|
|
2986 maxoccupancy = (guint16)va_arg(ap, unsigned int);
|
|
2987 createperms = (guint8)va_arg(ap, unsigned int);
|
|
2988 unknown = (guint16)va_arg(ap, unsigned int);
|
|
2989 name = va_arg(ap, char *);
|
|
2990 ck = va_arg(ap, char *);
|
|
2991
|
|
2992 gaim_debug_misc("oscar",
|
|
2993 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n",
|
|
2994 fqcn, exchange, instance, flags, createtime,
|
|
2995 maxmsglen, maxoccupancy, createperms, unknown,
|
|
2996 name, ck);
|
|
2997 aim_chat_join(od, exchange, ck, instance);
|
|
2998 }
|
|
2999 break;
|
|
3000 default:
|
|
3001 gaim_debug_warning("oscar",
|
|
3002 "chatnav info: unknown type (%04hx)\n", type);
|
|
3003 break;
|
|
3004 }
|
|
3005
|
|
3006 va_end(ap);
|
|
3007
|
|
3008 return 1;
|
|
3009 }
|
|
3010
|
|
3011 static int gaim_conv_chat_join(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3012 va_list ap;
|
|
3013 int count, i;
|
|
3014 aim_userinfo_t *info;
|
|
3015 GaimConnection *gc = od->gc;
|
|
3016
|
|
3017 struct chat_connection *c = NULL;
|
|
3018
|
|
3019 va_start(ap, fr);
|
|
3020 count = va_arg(ap, int);
|
|
3021 info = va_arg(ap, aim_userinfo_t *);
|
|
3022 va_end(ap);
|
|
3023
|
|
3024 c = find_oscar_chat_by_conn(gc, conn);
|
|
3025 if (!c)
|
|
3026 return 1;
|
|
3027
|
|
3028 for (i = 0; i < count; i++)
|
|
3029 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE);
|
|
3030
|
|
3031 return 1;
|
|
3032 }
|
|
3033
|
|
3034 static int gaim_conv_chat_leave(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3035 va_list ap;
|
|
3036 int count, i;
|
|
3037 aim_userinfo_t *info;
|
|
3038 GaimConnection *gc = od->gc;
|
|
3039
|
|
3040 struct chat_connection *c = NULL;
|
|
3041
|
|
3042 va_start(ap, fr);
|
|
3043 count = va_arg(ap, int);
|
|
3044 info = va_arg(ap, aim_userinfo_t *);
|
|
3045 va_end(ap);
|
|
3046
|
|
3047 c = find_oscar_chat_by_conn(gc, conn);
|
|
3048 if (!c)
|
|
3049 return 1;
|
|
3050
|
|
3051 for (i = 0; i < count; i++)
|
|
3052 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL);
|
|
3053
|
|
3054 return 1;
|
|
3055 }
|
|
3056
|
|
3057 static int gaim_conv_chat_info_update(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3058 va_list ap;
|
|
3059 aim_userinfo_t *userinfo;
|
|
3060 struct aim_chat_roominfo *roominfo;
|
|
3061 char *roomname;
|
|
3062 int usercount;
|
|
3063 char *roomdesc;
|
|
3064 guint16 unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen;
|
|
3065 guint32 creationtime;
|
|
3066 GaimConnection *gc = od->gc;
|
|
3067 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, conn);
|
|
3068
|
|
3069 va_start(ap, fr);
|
|
3070 roominfo = va_arg(ap, struct aim_chat_roominfo *);
|
|
3071 roomname = va_arg(ap, char *);
|
|
3072 usercount= va_arg(ap, int);
|
|
3073 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
3074 roomdesc = va_arg(ap, char *);
|
|
3075 unknown_c9 = (guint16)va_arg(ap, unsigned int);
|
|
3076 creationtime = va_arg(ap, guint32);
|
|
3077 maxmsglen = (guint16)va_arg(ap, unsigned int);
|
|
3078 unknown_d2 = (guint16)va_arg(ap, unsigned int);
|
|
3079 unknown_d5 = (guint16)va_arg(ap, unsigned int);
|
|
3080 maxvisiblemsglen = (guint16)va_arg(ap, unsigned int);
|
|
3081 va_end(ap);
|
|
3082
|
|
3083 gaim_debug_misc("oscar",
|
|
3084 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n",
|
|
3085 maxmsglen, maxvisiblemsglen);
|
|
3086
|
|
3087 ccon->maxlen = maxmsglen;
|
|
3088 ccon->maxvis = maxvisiblemsglen;
|
|
3089
|
|
3090 return 1;
|
|
3091 }
|
|
3092
|
|
3093 static int gaim_conv_chat_incoming_msg(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3094 GaimConnection *gc = od->gc;
|
|
3095 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, conn);
|
|
3096 gchar *utf8;
|
|
3097 va_list ap;
|
|
3098 aim_userinfo_t *info;
|
|
3099 int len;
|
|
3100 char *msg;
|
|
3101 char *charset;
|
|
3102
|
|
3103 va_start(ap, fr);
|
|
3104 info = va_arg(ap, aim_userinfo_t *);
|
|
3105 len = va_arg(ap, int);
|
|
3106 msg = va_arg(ap, char *);
|
|
3107 charset = va_arg(ap, char *);
|
|
3108 va_end(ap);
|
|
3109
|
|
3110 utf8 = oscar_encoding_to_utf8(charset, msg, len);
|
|
3111 if (utf8 == NULL)
|
|
3112 /* The conversion failed! */
|
|
3113 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]"));
|
|
3114 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL));
|
|
3115 g_free(utf8);
|
|
3116
|
|
3117 return 1;
|
|
3118 }
|
|
3119
|
|
3120 static int gaim_email_parseupdate(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3121 va_list ap;
|
|
3122 GaimConnection *gc = od->gc;
|
|
3123 struct aim_emailinfo *emailinfo;
|
|
3124 int havenewmail;
|
|
3125 char *alertitle, *alerturl;
|
|
3126
|
|
3127 va_start(ap, fr);
|
|
3128 emailinfo = va_arg(ap, struct aim_emailinfo *);
|
|
3129 havenewmail = va_arg(ap, int);
|
|
3130 alertitle = va_arg(ap, char *);
|
|
3131 alerturl = va_arg(ap, char *);
|
|
3132 va_end(ap);
|
|
3133
|
|
3134 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) {
|
|
3135 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)),
|
|
3136 emailinfo->domain ? "@" : "",
|
|
3137 emailinfo->domain ? emailinfo->domain : "");
|
|
3138 if (emailinfo->unread && havenewmail)
|
|
3139 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL);
|
|
3140 g_free(to);
|
|
3141 }
|
|
3142
|
|
3143 if (alertitle)
|
|
3144 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : "");
|
|
3145
|
|
3146 return 1;
|
|
3147 }
|
|
3148
|
|
3149 static int gaim_icon_error(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3150 GaimConnection *gc = od->gc;
|
|
3151 char *sn;
|
|
3152
|
|
3153 sn = od->requesticon->data;
|
|
3154 gaim_debug_misc("oscar", "removing %s from hash table\n", sn);
|
|
3155 od->requesticon = g_slist_remove(od->requesticon, sn);
|
|
3156 g_free(sn);
|
|
3157
|
|
3158 if (od->icontimer == 0)
|
|
3159 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc);
|
|
3160
|
|
3161 return 1;
|
|
3162 }
|
|
3163
|
|
3164 static int gaim_icon_parseicon(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3165 GaimConnection *gc = od->gc;
|
|
3166 GSList *cur;
|
|
3167 va_list ap;
|
|
3168 char *sn;
|
|
3169 guint8 iconcsumtype, *iconcsum, *icon;
|
|
3170 guint16 iconcsumlen, iconlen;
|
|
3171
|
|
3172 va_start(ap, fr);
|
|
3173 sn = va_arg(ap, char *);
|
|
3174 iconcsumtype = va_arg(ap, int);
|
|
3175 iconcsum = va_arg(ap, guint8 *);
|
|
3176 iconcsumlen = va_arg(ap, int);
|
|
3177 icon = va_arg(ap, guint8 *);
|
|
3178 iconlen = va_arg(ap, int);
|
|
3179 va_end(ap);
|
|
3180
|
|
3181 /*
|
|
3182 * Some AIM clients will send a blank GIF image with iconlen 90 when
|
|
3183 * no icon is set. Ignore these.
|
|
3184 */
|
|
3185 if ((iconlen > 0) && (iconlen != 90)) {
|
|
3186 char *b16;
|
|
3187 GaimBuddy *b;
|
|
3188 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc),
|
|
3189 sn, icon, iconlen);
|
|
3190 b16 = gaim_base16_encode(iconcsum, iconcsumlen);
|
|
3191 b = gaim_find_buddy(gc->account, sn);
|
|
3192 if ((b16 != NULL) && (b != NULL)) {
|
|
3193 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16);
|
|
3194 g_free(b16);
|
|
3195 }
|
|
3196 }
|
|
3197
|
|
3198 cur = od->requesticon;
|
|
3199 while (cur) {
|
|
3200 char *cursn = cur->data;
|
|
3201 if (!aim_sncmp(cursn, sn)) {
|
|
3202 od->requesticon = g_slist_remove(od->requesticon, cursn);
|
|
3203 g_free(cursn);
|
|
3204 cur = od->requesticon;
|
|
3205 } else
|
|
3206 cur = cur->next;
|
|
3207 }
|
|
3208
|
|
3209 if (od->icontimer == 0)
|
|
3210 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc);
|
|
3211
|
|
3212 return 1;
|
|
3213 }
|
|
3214
|
|
3215 static gboolean gaim_icon_timerfunc(gpointer data) {
|
|
3216 GaimConnection *gc = data;
|
|
3217 OscarData *od = gc->proto_data;
|
|
3218 aim_userinfo_t *userinfo;
|
|
3219 FlapConnection *conn;
|
|
3220
|
|
3221 od->icontimer = 0;
|
|
3222
|
|
3223 conn = flap_connection_getbytype(od, SNAC_FAMILY_BART);
|
|
3224 if (!conn) {
|
|
3225 if (!od->iconconnecting) {
|
|
3226 aim_reqservice(od, SNAC_FAMILY_BART);
|
|
3227 od->iconconnecting = TRUE;
|
|
3228 }
|
|
3229 return FALSE;
|
|
3230 }
|
|
3231
|
|
3232 if (od->set_icon) {
|
|
3233 struct stat st;
|
|
3234 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc)));
|
|
3235 if (iconfile == NULL) {
|
|
3236 aim_ssi_delicon(od);
|
|
3237 } else if (!g_stat(iconfile, &st)) {
|
|
3238 guchar *buf = g_malloc(st.st_size);
|
|
3239 FILE *file = g_fopen(iconfile, "rb");
|
|
3240 if (file) {
|
|
3241 /* XXX - Use g_file_get_contents()? */
|
|
3242 fread(buf, 1, st.st_size, file);
|
|
3243 fclose(file);
|
|
3244 gaim_debug_info("oscar",
|
|
3245 "Uploading icon to icon server\n");
|
|
3246 aim_bart_upload(od, buf, st.st_size);
|
|
3247 } else
|
|
3248 gaim_debug_error("oscar",
|
|
3249 "Can't open buddy icon file!\n");
|
|
3250 g_free(buf);
|
|
3251 } else {
|
|
3252 gaim_debug_error("oscar",
|
|
3253 "Can't stat buddy icon file!\n");
|
|
3254 }
|
|
3255 g_free(iconfile);
|
|
3256 od->set_icon = FALSE;
|
|
3257 }
|
|
3258
|
|
3259 if (!od->requesticon) {
|
|
3260 gaim_debug_misc("oscar",
|
|
3261 "no more icons to request\n");
|
|
3262 return FALSE;
|
|
3263 }
|
|
3264
|
|
3265 userinfo = aim_locate_finduserinfo(od, (char *)od->requesticon->data);
|
|
3266 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) {
|
|
3267 aim_bart_request(od, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen);
|
|
3268 return FALSE;
|
|
3269 } else {
|
|
3270 gchar *sn = od->requesticon->data;
|
|
3271 od->requesticon = g_slist_remove(od->requesticon, sn);
|
|
3272 g_free(sn);
|
|
3273 }
|
|
3274
|
|
3275 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc);
|
|
3276
|
|
3277 return FALSE;
|
|
3278 }
|
|
3279
|
|
3280 /*
|
|
3281 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option.
|
|
3282 */
|
|
3283 static int gaim_parse_msgack(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3284 va_list ap;
|
|
3285 guint16 type;
|
|
3286 char *sn;
|
|
3287
|
|
3288 va_start(ap, fr);
|
|
3289 type = (guint16) va_arg(ap, unsigned int);
|
|
3290 sn = va_arg(ap, char *);
|
|
3291 va_end(ap);
|
|
3292
|
|
3293 gaim_debug_info("oscar", "Sent message to %s.\n", sn);
|
|
3294
|
|
3295 return 1;
|
|
3296 }
|
|
3297
|
|
3298 static int gaim_parse_ratechange(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3299 static const char *codes[5] = {
|
|
3300 "invalid",
|
|
3301 "change",
|
|
3302 "warning",
|
|
3303 "limit",
|
|
3304 "limit cleared",
|
|
3305 };
|
|
3306 va_list ap;
|
|
3307 guint16 code, rateclass;
|
|
3308 guint32 windowsize, clear, alert, limit, disconnect, currentavg, maxavg;
|
|
3309
|
|
3310 va_start(ap, fr);
|
|
3311 code = (guint16)va_arg(ap, unsigned int);
|
|
3312 rateclass= (guint16)va_arg(ap, unsigned int);
|
|
3313 windowsize = va_arg(ap, guint32);
|
|
3314 clear = va_arg(ap, guint32);
|
|
3315 alert = va_arg(ap, guint32);
|
|
3316 limit = va_arg(ap, guint32);
|
|
3317 disconnect = va_arg(ap, guint32);
|
|
3318 currentavg = va_arg(ap, guint32);
|
|
3319 maxavg = va_arg(ap, guint32);
|
|
3320 va_end(ap);
|
|
3321
|
|
3322 gaim_debug_misc("oscar",
|
|
3323 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, "
|
|
3324 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n",
|
|
3325 (code < 5) ? codes[code] : codes[0],
|
|
3326 rateclass,
|
|
3327 currentavg, maxavg,
|
|
3328 alert, clear,
|
|
3329 limit, disconnect,
|
|
3330 windowsize);
|
|
3331
|
|
3332 if (code == AIM_RATE_CODE_LIMIT)
|
|
3333 {
|
|
3334 gaim_notify_error(od->gc, NULL, _("Rate limiting error."),
|
|
3335 _("The last action you attempted could not be "
|
|
3336 "performed because you are over the rate limit. "
|
|
3337 "Please wait 10 seconds and try again."));
|
|
3338 }
|
|
3339
|
|
3340 return 1;
|
|
3341 }
|
|
3342
|
|
3343 static int gaim_parse_evilnotify(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3344 #ifdef CRAZY_WARNING
|
|
3345 va_list ap;
|
|
3346 guint16 newevil;
|
|
3347 aim_userinfo_t *userinfo;
|
|
3348
|
|
3349 va_start(ap, fr);
|
|
3350 newevil = (guint16) va_arg(ap, unsigned int);
|
|
3351 userinfo = va_arg(ap, aim_userinfo_t *);
|
|
3352 va_end(ap);
|
|
3353
|
|
3354 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5);
|
|
3355 #endif
|
|
3356
|
|
3357 return 1;
|
|
3358 }
|
|
3359
|
|
3360 static int gaim_selfinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3361 int warning_level;
|
|
3362 va_list ap;
|
|
3363 aim_userinfo_t *info;
|
|
3364
|
|
3365 va_start(ap, fr);
|
|
3366 info = va_arg(ap, aim_userinfo_t *);
|
|
3367 va_end(ap);
|
|
3368
|
|
3369 /*
|
|
3370 * What's with the + 0.5?
|
|
3371 * The 0.5 is basically poor-man's rounding. Normally
|
|
3372 * casting "13.7" to an int will truncate to "13," but
|
|
3373 * with 13.7 + 0.5 = 14.2, which becomes "14" when
|
|
3374 * truncated.
|
|
3375 */
|
|
3376 warning_level = info->warnlevel/10.0 + 0.5;
|
|
3377
|
|
3378 #ifdef CRAZY_WARNING
|
|
3379 gaim_presence_set_warning_level(presence, warning_level);
|
|
3380 #endif
|
|
3381
|
|
3382 return 1;
|
|
3383 }
|
|
3384
|
|
3385 static int gaim_connerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3386 GaimConnection *gc = od->gc;
|
|
3387 va_list ap;
|
|
3388 guint16 code;
|
|
3389 char *msg;
|
|
3390
|
|
3391 va_start(ap, fr);
|
|
3392 code = (guint16)va_arg(ap, int);
|
|
3393 msg = va_arg(ap, char *);
|
|
3394 va_end(ap);
|
|
3395
|
|
3396 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n",
|
|
3397 code, (msg != NULL ? msg : ""));
|
|
3398
|
|
3399 g_return_val_if_fail(fr != NULL, 1);
|
|
3400 g_return_val_if_fail(conn != NULL, 1);
|
|
3401
|
|
3402 if (conn->type == SNAC_FAMILY_LOCATE) {
|
|
3403 if (code == 0x0001) {
|
|
3404 gc->wants_to_die = TRUE;
|
|
3405 gaim_connection_error(gc, _("You have signed on from another location."));
|
|
3406 } else {
|
|
3407 gaim_connection_error(gc, _("You have been signed off for an unknown reason."));
|
|
3408 }
|
|
3409 od->killme = TRUE;
|
|
3410 } else if (conn->type == SNAC_FAMILY_CHAT) {
|
|
3411 struct chat_connection *cc;
|
|
3412 GaimConversation *conv;
|
|
3413
|
|
3414 cc = find_oscar_chat_by_conn(gc, conn);
|
|
3415 conv = gaim_find_chat(gc, cc->id);
|
|
3416
|
|
3417 if (conv != NULL)
|
|
3418 {
|
|
3419 gchar *buf;
|
|
3420 buf = g_strdup_printf(_("You have been disconnected from chat "
|
|
3421 "room %s."), cc->name);
|
|
3422 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL));
|
|
3423 g_free(buf);
|
|
3424 }
|
|
3425 oscar_chat_kill(gc, cc);
|
|
3426 }
|
|
3427
|
|
3428 return 1;
|
|
3429 }
|
|
3430
|
|
3431 static int gaim_icbm_param_info(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3432 struct aim_icbmparameters *params;
|
|
3433 va_list ap;
|
|
3434
|
|
3435 va_start(ap, fr);
|
|
3436 params = va_arg(ap, struct aim_icbmparameters *);
|
|
3437 va_end(ap);
|
|
3438
|
|
3439 /* XXX - evidently this crashes on solaris. i have no clue why
|
|
3440 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, "
|
|
3441 "max sender evil = %f, max receiver evil = %f, min msg interval = %u\n",
|
|
3442 params->maxchan, params->flags, params->maxmsglen,
|
|
3443 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0,
|
|
3444 params->minmsginterval);
|
|
3445 */
|
|
3446
|
|
3447 /* Maybe senderwarn and recverwarn should be user preferences... */
|
|
3448 params->flags = 0x0000000b;
|
|
3449 params->maxmsglen = 8000;
|
|
3450 params->minmsginterval = 0;
|
|
3451
|
|
3452 aim_im_setparams(od, params);
|
|
3453
|
|
3454 return 1;
|
|
3455 }
|
|
3456
|
|
3457 static int gaim_parse_locaterights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3458 {
|
|
3459 GaimConnection *gc = od->gc;
|
|
3460 GaimAccount *account = gaim_connection_get_account(gc);
|
|
3461 va_list ap;
|
|
3462 guint16 maxsiglen;
|
|
3463
|
|
3464 va_start(ap, fr);
|
|
3465 maxsiglen = (guint16) va_arg(ap, int);
|
|
3466 va_end(ap);
|
|
3467
|
|
3468 gaim_debug_misc("oscar",
|
|
3469 "locate rights: max sig len = %d\n", maxsiglen);
|
|
3470
|
|
3471 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen;
|
|
3472
|
|
3473 if (od->icq)
|
|
3474 aim_locate_setcaps(od, caps_icq);
|
|
3475 else
|
|
3476 aim_locate_setcaps(od, caps_aim);
|
|
3477 oscar_set_info_and_status(account, TRUE, account->user_info, TRUE,
|
|
3478 gaim_account_get_active_status(account));
|
|
3479
|
|
3480 return 1;
|
|
3481 }
|
|
3482
|
|
3483 static int gaim_parse_buddyrights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3484 va_list ap;
|
|
3485 guint16 maxbuddies, maxwatchers;
|
|
3486
|
|
3487 va_start(ap, fr);
|
|
3488 maxbuddies = (guint16) va_arg(ap, unsigned int);
|
|
3489 maxwatchers = (guint16) va_arg(ap, unsigned int);
|
|
3490 va_end(ap);
|
|
3491
|
|
3492 gaim_debug_misc("oscar",
|
|
3493 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers);
|
|
3494
|
|
3495 od->rights.maxbuddies = (guint)maxbuddies;
|
|
3496 od->rights.maxwatchers = (guint)maxwatchers;
|
|
3497
|
|
3498 return 1;
|
|
3499 }
|
|
3500
|
|
3501 static int gaim_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3502 GaimConnection *gc;
|
|
3503 GaimAccount *account;
|
|
3504 GaimStatus *status;
|
|
3505 const char *message;
|
|
3506 char *tmp;
|
|
3507 va_list ap;
|
|
3508 guint16 maxpermits, maxdenies;
|
|
3509
|
|
3510 gc = od->gc;
|
|
3511 od = (OscarData *)gc->proto_data;
|
|
3512 account = gaim_connection_get_account(gc);
|
|
3513
|
|
3514 va_start(ap, fr);
|
|
3515 maxpermits = (guint16) va_arg(ap, unsigned int);
|
|
3516 maxdenies = (guint16) va_arg(ap, unsigned int);
|
|
3517 va_end(ap);
|
|
3518
|
|
3519 gaim_debug_misc("oscar",
|
|
3520 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies);
|
|
3521
|
|
3522 od->rights.maxpermits = (guint)maxpermits;
|
|
3523 od->rights.maxdenies = (guint)maxdenies;
|
|
3524
|
|
3525 gaim_connection_set_state(gc, GAIM_CONNECTED);
|
|
3526
|
|
3527 gaim_debug_info("oscar", "buddy list loaded\n");
|
|
3528
|
|
3529 aim_clientready(od, conn);
|
|
3530
|
|
3531 /* Set our available message based on the current status */
|
|
3532 status = gaim_account_get_active_status(account);
|
|
3533 if (gaim_status_is_available(status))
|
|
3534 message = gaim_status_get_attr_string(status, "message");
|
|
3535 else
|
|
3536 message = NULL;
|
|
3537 tmp = gaim_markup_strip_html(message);
|
|
3538 aim_srv_setstatusmsg(od, tmp);
|
|
3539 g_free(tmp);
|
|
3540
|
|
3541 aim_srv_setidle(od, 0);
|
|
3542
|
|
3543 if (od->icq) {
|
|
3544 aim_icq_reqofflinemsgs(od);
|
|
3545 oscar_set_extendedstatus(gc);
|
|
3546 aim_icq_setsecurity(od,
|
|
3547 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION),
|
|
3548 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE));
|
|
3549 }
|
|
3550
|
|
3551 aim_reqservice(od, SNAC_FAMILY_CHATNAV);
|
|
3552 if (od->authinfo->email != NULL)
|
|
3553 aim_reqservice(od, SNAC_FAMILY_ALERT);
|
|
3554
|
|
3555 return 1;
|
|
3556 }
|
|
3557
|
|
3558 static int gaim_offlinemsg(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3559 va_list ap;
|
|
3560 struct aim_icq_offlinemsg *msg;
|
|
3561 struct aim_incomingim_ch4_args args;
|
|
3562 time_t t;
|
|
3563
|
|
3564 va_start(ap, fr);
|
|
3565 msg = va_arg(ap, struct aim_icq_offlinemsg *);
|
|
3566 va_end(ap);
|
|
3567
|
|
3568 gaim_debug_info("oscar",
|
|
3569 "Received offline message. Converting to channel 4 ICBM...\n");
|
|
3570 args.uin = msg->sender;
|
|
3571 args.type = msg->type;
|
|
3572 args.flags = msg->flags;
|
|
3573 args.msglen = msg->msglen;
|
|
3574 args.msg = msg->msg;
|
|
3575 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
|
|
3576 incomingim_chan4(od, conn, NULL, &args, t);
|
|
3577
|
|
3578 return 1;
|
|
3579 }
|
|
3580
|
|
3581 static int gaim_offlinemsgdone(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3582 {
|
|
3583 aim_icq_ackofflinemsgs(od);
|
|
3584 return 1;
|
|
3585 }
|
|
3586
|
|
3587 static int gaim_icqinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3588 {
|
|
3589 GaimConnection *gc;
|
|
3590 GaimAccount *account;
|
|
3591 GaimBuddy *buddy;
|
|
3592 struct buddyinfo *bi;
|
|
3593 gchar who[16];
|
|
3594 GString *str;
|
|
3595 gchar *utf8;
|
|
3596 const gchar *alias;
|
|
3597 va_list ap;
|
|
3598 struct aim_icq_info *info;
|
|
3599
|
|
3600 gc = od->gc;
|
|
3601 account = gaim_connection_get_account(gc);
|
|
3602
|
|
3603 va_start(ap, fr);
|
|
3604 info = va_arg(ap, struct aim_icq_info *);
|
|
3605 va_end(ap);
|
|
3606
|
|
3607 if (!info->uin)
|
|
3608 return 0;
|
|
3609
|
|
3610 str = g_string_sized_new(100);
|
|
3611 g_snprintf(who, sizeof(who), "%u", info->uin);
|
|
3612 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who);
|
|
3613 if (buddy != NULL)
|
|
3614 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name));
|
|
3615 else
|
|
3616 bi = NULL;
|
|
3617
|
|
3618 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who);
|
|
3619 oscar_string_convert_and_append(account, str, "\n<br>", _("Nick"), info->nick);
|
|
3620 if ((bi != NULL) && (bi->ipaddr != 0)) {
|
|
3621 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu",
|
|
3622 (bi->ipaddr & 0xff000000) >> 24,
|
|
3623 (bi->ipaddr & 0x00ff0000) >> 16,
|
|
3624 (bi->ipaddr & 0x0000ff00) >> 8,
|
|
3625 (bi->ipaddr & 0x000000ff));
|
|
3626 oscar_string_append(str, "\n<br>", _("IP Address"), tstr);
|
|
3627 g_free(tstr);
|
|
3628 }
|
|
3629 oscar_string_convert_and_append(account, str, "\n<br>", _("First Name"), info->first);
|
|
3630 oscar_string_convert_and_append(account, str, "\n<br>", _("Last Name"), info->last);
|
|
3631 if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) {
|
|
3632 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("E-Mail Address"), utf8, utf8);
|
|
3633 g_free(utf8);
|
|
3634 }
|
|
3635 if (info->numaddresses && info->email2) {
|
|
3636 int i;
|
|
3637 for (i = 0; i < info->numaddresses; i++) {
|
|
3638 if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) {
|
|
3639 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("E-Mail Address"), utf8, utf8);
|
|
3640 g_free(utf8);
|
|
3641 }
|
|
3642 }
|
|
3643 }
|
|
3644 oscar_string_convert_and_append(account, str, "\n<br>", _("Mobile Phone"), info->mobile);
|
|
3645 if (info->gender != 0)
|
|
3646 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male"));
|
|
3647 if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) {
|
|
3648 /* Initialize the struct properly or strftime() will crash
|
|
3649 * under some conditions (e.g. Debian sarge w/ LANG=en_HK). */
|
|
3650 time_t t = time(NULL);
|
|
3651 struct tm *tm = localtime(&t);
|
|
3652
|
|
3653 tm->tm_mday = (int)info->birthday;
|
|
3654 tm->tm_mon = (int)info->birthmonth - 1;
|
|
3655 tm->tm_year = (int)info->birthyear - 1900;
|
|
3656
|
|
3657 /* To be 100% sure that the fields are re-normalized.
|
|
3658 * If you're sure strftime() ALWAYS does this EVERYWHERE,
|
|
3659 * feel free to remove it. --rlaager */
|
|
3660 mktime(tm);
|
|
3661
|
|
3662 oscar_string_append(str, "\n<br>", _("Birthday"),
|
|
3663 gaim_date_format_short(tm));
|
|
3664 }
|
|
3665 if ((info->age > 0) && (info->age < 255)) {
|
|
3666 char age[5];
|
|
3667 snprintf(age, sizeof(age), "%hhd", info->age);
|
|
3668 oscar_string_append(str, "\n<br>", _("Age"), age);
|
|
3669 }
|
|
3670 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) {
|
|
3671 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8);
|
|
3672 g_free(utf8);
|
|
3673 }
|
|
3674 if (info->info && info->info[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->info))) {
|
|
3675 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8);
|
|
3676 g_free(utf8);
|
|
3677 }
|
|
3678 g_string_append_printf(str, "<hr>");
|
|
3679 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
|
|
3680 g_string_append_printf(str, "<b>%s:</b>", _("Home Address"));
|
|
3681 oscar_string_convert_and_append(account, str, "\n<br>", _("Address"), info->homeaddr);
|
|
3682 oscar_string_convert_and_append(account, str, "\n<br>", _("City"), info->homecity);
|
|
3683 oscar_string_convert_and_append(account, str, "\n<br>", _("State"), info->homestate);
|
|
3684 oscar_string_convert_and_append(account, str, "\n<br>", _("Zip Code"), info->homezip);
|
|
3685 g_string_append_printf(str, "\n<hr>");
|
|
3686 }
|
|
3687 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
|
|
3688 g_string_append_printf(str, "<b>%s:</b>", _("Work Address"));
|
|
3689 oscar_string_convert_and_append(account, str, "\n<br>", _("Address"), info->workaddr);
|
|
3690 oscar_string_convert_and_append(account, str, "\n<br>", _("City"), info->workcity);
|
|
3691 oscar_string_convert_and_append(account, str, "\n<br>", _("State"), info->workstate);
|
|
3692 oscar_string_convert_and_append(account, str, "\n<br>", _("Zip Code"), info->workzip);
|
|
3693 g_string_append_printf(str, "\n<hr>");
|
|
3694 }
|
|
3695 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
|
|
3696 g_string_append_printf(str, "<b>%s:</b>", _("Work Information"));
|
|
3697 oscar_string_convert_and_append(account, str, "\n<br>", _("Company"), info->workcompany);
|
|
3698 oscar_string_convert_and_append(account, str, "\n<br>", _("Division"), info->workdivision);
|
|
3699 oscar_string_convert_and_append(account, str, "\n<br>", _("Position"), info->workposition);
|
|
3700 if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) {
|
|
3701 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8);
|
|
3702 g_free(utf8);
|
|
3703 }
|
|
3704 g_string_append_printf(str, "\n<hr>");
|
|
3705 }
|
|
3706
|
|
3707 if (buddy != NULL)
|
|
3708 alias = gaim_buddy_get_alias(buddy);
|
|
3709 else
|
|
3710 alias = who;
|
|
3711 gaim_notify_userinfo(gc, who, str->str, NULL, NULL);
|
|
3712 g_string_free(str, TRUE);
|
|
3713
|
|
3714 return 1;
|
|
3715 }
|
|
3716
|
|
3717 static int gaim_icqalias(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3718 {
|
|
3719 GaimConnection *gc = od->gc;
|
|
3720 GaimAccount *account = gaim_connection_get_account(gc);
|
|
3721 gchar who[16], *utf8;
|
|
3722 GaimBuddy *b;
|
|
3723 va_list ap;
|
|
3724 struct aim_icq_info *info;
|
|
3725
|
|
3726 va_start(ap, fr);
|
|
3727 info = va_arg(ap, struct aim_icq_info *);
|
|
3728 va_end(ap);
|
|
3729
|
|
3730 if (info->uin && info->nick && info->nick[0] && (utf8 = oscar_utf8_try_convert(account, info->nick))) {
|
|
3731 g_snprintf(who, sizeof(who), "%u", info->uin);
|
|
3732 serv_got_alias(gc, who, utf8);
|
|
3733 if ((b = gaim_find_buddy(gc->account, who))) {
|
|
3734 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8);
|
|
3735 }
|
|
3736 g_free(utf8);
|
|
3737 }
|
|
3738
|
|
3739 return 1;
|
|
3740 }
|
|
3741
|
|
3742 static int gaim_popup(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3743 {
|
|
3744 GaimConnection *gc = od->gc;
|
|
3745 gchar *text;
|
|
3746 va_list ap;
|
|
3747 char *msg, *url;
|
|
3748 guint16 wid, hei, delay;
|
|
3749
|
|
3750 va_start(ap, fr);
|
|
3751 msg = va_arg(ap, char *);
|
|
3752 url = va_arg(ap, char *);
|
|
3753 wid = (guint16) va_arg(ap, int);
|
|
3754 hei = (guint16) va_arg(ap, int);
|
|
3755 delay = (guint16) va_arg(ap, int);
|
|
3756 va_end(ap);
|
|
3757
|
|
3758 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url);
|
|
3759 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL);
|
|
3760 g_free(text);
|
|
3761
|
|
3762 return 1;
|
|
3763 }
|
|
3764
|
|
3765 static void oscar_searchresults_add_buddy_cb(GaimConnection *gc, GList *row, void *user_data)
|
|
3766 {
|
|
3767 gaim_blist_request_add_buddy(gaim_connection_get_account(gc),
|
|
3768 g_list_nth_data(row, 0), NULL, NULL);
|
|
3769 }
|
|
3770
|
|
3771 static int gaim_parse_searchreply(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
3772 {
|
|
3773 GaimConnection *gc = od->gc;
|
|
3774 GaimNotifySearchResults *results;
|
|
3775 GaimNotifySearchColumn *column;
|
|
3776 gchar *secondary;
|
|
3777 int i, num;
|
|
3778 va_list ap;
|
|
3779 char *email, *SNs;
|
|
3780
|
|
3781 va_start(ap, fr);
|
|
3782 email = va_arg(ap, char *);
|
|
3783 num = va_arg(ap, int);
|
|
3784 SNs = va_arg(ap, char *);
|
|
3785 va_end(ap);
|
|
3786
|
|
3787 results = gaim_notify_searchresults_new();
|
|
3788
|
|
3789 if (results == NULL) {
|
|
3790 gaim_debug_error("oscar", "gaim_parse_searchreply: "
|
|
3791 "Unable to display the search results.\n");
|
|
3792 gaim_notify_error(gc, NULL,
|
|
3793 _("Unable to display the search results."),
|
|
3794 NULL);
|
|
3795 return 1;
|
|
3796 }
|
|
3797
|
|
3798 secondary = g_strdup_printf(
|
|
3799 ngettext("The following screen name is associated with %s",
|
|
3800 "The following screen names are associated with %s",
|
|
3801 num),
|
|
3802 email);
|
|
3803
|
|
3804 column = gaim_notify_searchresults_column_new(_("Screen name"));
|
|
3805 gaim_notify_searchresults_column_add(results, column);
|
|
3806
|
|
3807 for (i = 0; i < num; i++) {
|
|
3808 GList *row = NULL;
|
|
3809 row = g_list_append(row, g_strdup(&SNs[i * (MAXSNLEN + 1)]));
|
|
3810 gaim_notify_searchresults_row_add(results, row);
|
|
3811 }
|
|
3812 gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD,
|
|
3813 oscar_searchresults_add_buddy_cb);
|
|
3814 gaim_notify_searchresults(gc, NULL, NULL, secondary, results, NULL, NULL);
|
|
3815
|
|
3816 g_free(secondary);
|
|
3817
|
|
3818 return 1;
|
|
3819 }
|
|
3820
|
|
3821 static int gaim_parse_searcherror(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3822 va_list ap;
|
|
3823 char *email;
|
|
3824 char *buf;
|
|
3825
|
|
3826 va_start(ap, fr);
|
|
3827 email = va_arg(ap, char *);
|
|
3828 va_end(ap);
|
|
3829
|
|
3830 buf = g_strdup_printf(_("No results found for e-mail address %s"), email);
|
|
3831 gaim_notify_error(od->gc, NULL, buf, NULL);
|
|
3832 g_free(buf);
|
|
3833
|
|
3834 return 1;
|
|
3835 }
|
|
3836
|
|
3837 static int gaim_account_confirm(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3838 GaimConnection *gc = od->gc;
|
|
3839 guint16 status;
|
|
3840 va_list ap;
|
|
3841 char msg[256];
|
|
3842
|
|
3843 va_start(ap, fr);
|
|
3844 status = (guint16) va_arg(ap, unsigned int); /* status code of confirmation request */
|
|
3845 va_end(ap);
|
|
3846
|
|
3847 gaim_debug_info("oscar",
|
|
3848 "account confirmation returned status 0x%04x (%s)\n", status,
|
|
3849 status ? "unknown" : "e-mail sent");
|
|
3850 if (!status) {
|
|
3851 g_snprintf(msg, sizeof(msg), _("You should receive an e-mail asking to confirm %s."),
|
|
3852 gaim_account_get_username(gaim_connection_get_account(gc)));
|
|
3853 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg);
|
|
3854 }
|
|
3855
|
|
3856 return 1;
|
|
3857 }
|
|
3858
|
|
3859 static int gaim_info_change(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
3860 GaimConnection *gc = od->gc;
|
|
3861 va_list ap;
|
|
3862 guint16 perms, err;
|
|
3863 char *url, *sn, *email;
|
|
3864 int change;
|
|
3865
|
|
3866 va_start(ap, fr);
|
|
3867 change = va_arg(ap, int);
|
|
3868 perms = (guint16) va_arg(ap, unsigned int);
|
|
3869 err = (guint16) va_arg(ap, unsigned int);
|
|
3870 url = va_arg(ap, char *);
|
|
3871 sn = va_arg(ap, char *);
|
|
3872 email = va_arg(ap, char *);
|
|
3873 va_end(ap);
|
|
3874
|
|
3875 gaim_debug_misc("oscar",
|
|
3876 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n",
|
|
3877 change ? "change" : "request", perms, err,
|
|
3878 (url != NULL) ? url : "(null)",
|
|
3879 (sn != NULL) ? sn : "(null)",
|
|
3880 (email != NULL) ? email : "(null)");
|
|
3881
|
|
3882 if ((err > 0) && (url != NULL)) {
|
|
3883 char *dialog_msg;
|
|
3884 char *dialog_top = g_strdup_printf(_("Error Changing Account Info"));
|
|
3885 switch (err) {
|
|
3886 case 0x0001: {
|
|
3887 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err);
|
|
3888 } break;
|
|
3889 case 0x0006: {
|
|
3890 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because it is invalid."), err);
|
|
3891 } break;
|
|
3892 case 0x000b: {
|
|
3893 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err);
|
|
3894 } break;
|
|
3895 case 0x001d: {
|
|
3896 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);
|
|
3897 } break;
|
|
3898 case 0x0021: {
|
|
3899 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);
|
|
3900 } break;
|
|
3901 case 0x0023: {
|
|
3902 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change e-mail address because the given address is invalid."), err);
|
|
3903 } break;
|
|
3904 default: {
|
|
3905 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err);
|
|
3906 } break;
|
|
3907 }
|
|
3908 gaim_notify_error(gc, NULL, dialog_top, dialog_msg);
|
|
3909 g_free(dialog_top);
|
|
3910 g_free(dialog_msg);
|
|
3911 return 1;
|
|
3912 }
|
|
3913
|
|
3914 if (sn != NULL) {
|
|
3915 char *dialog_msg = g_strdup_printf(_("Your screen name is currently formatted as follows:\n%s"), sn);
|
|
3916 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg);
|
|
3917 g_free(dialog_msg);
|
|
3918 }
|
|
3919
|
|
3920 if (email != NULL) {
|
|
3921 char *dialog_msg = g_strdup_printf(_("The e-mail address for %s is %s"),
|
|
3922 gaim_account_get_username(gaim_connection_get_account(gc)), email);
|
|
3923 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg);
|
|
3924 g_free(dialog_msg);
|
|
3925 }
|
|
3926
|
|
3927 return 1;
|
|
3928 }
|
|
3929
|
|
3930 static void
|
|
3931 oscar_keepalive(GaimConnection *gc)
|
|
3932 {
|
|
3933 OscarData *od;
|
|
3934 FlapConnection *conn;
|
|
3935
|
|
3936 od = (OscarData *)gc->proto_data;
|
|
3937 conn = flap_connection_getbytype(od, SNAC_FAMILY_LOCATE);
|
|
3938 if (conn != NULL)
|
|
3939 flap_connection_send_keepalive(od, conn);
|
|
3940 }
|
|
3941
|
|
3942 static unsigned int
|
|
3943 oscar_send_typing(GaimConnection *gc, const char *name, GaimTypingState state)
|
|
3944 {
|
|
3945 OscarData *od;
|
|
3946 PeerConnection *conn;
|
|
3947
|
|
3948 od = (OscarData *)gc->proto_data;
|
|
3949 conn = peer_connection_find_by_type(od, name, OSCAR_CAPABILITY_DIRECTIM);
|
|
3950
|
|
3951 if ((conn != NULL) && (conn->ready))
|
|
3952 {
|
|
3953 peer_odc_send_typing(conn, state);
|
|
3954 }
|
|
3955 else {
|
|
3956 /* Don't send if this turkey is in our deny list */
|
|
3957 GSList *list;
|
|
3958 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next);
|
|
3959 if (!list) {
|
|
3960 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name));
|
|
3961 if (bi && bi->typingnot) {
|
|
3962 if (state == GAIM_TYPING)
|
|
3963 aim_im_sendmtn(od, 0x0001, name, 0x0002);
|
|
3964 else if (state == GAIM_TYPED)
|
|
3965 aim_im_sendmtn(od, 0x0001, name, 0x0001);
|
|
3966 else
|
|
3967 aim_im_sendmtn(od, 0x0001, name, 0x0000);
|
|
3968 }
|
|
3969 }
|
|
3970 }
|
|
3971 return 0;
|
|
3972 }
|
|
3973
|
|
3974 /* TODO: Move this into odc.c! */
|
|
3975 static void
|
|
3976 gaim_odc_send_im(PeerConnection *conn, const char *message, GaimMessageFlags imflags)
|
|
3977 {
|
|
3978 GString *msg;
|
|
3979 GString *data;
|
|
3980 gchar *tmp;
|
|
3981 int tmplen;
|
|
3982 guint16 charset, charsubset;
|
|
3983 GData *attribs;
|
|
3984 const char *start, *end, *last;
|
|
3985 int oscar_id = 0;
|
|
3986
|
|
3987 msg = g_string_new("<HTML><BODY>");
|
|
3988 data = g_string_new("<BINARY>");
|
|
3989 last = message;
|
|
3990
|
|
3991 /* for each valid IMG tag... */
|
|
3992 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs))
|
|
3993 {
|
|
3994 GaimStoredImage *image = NULL;
|
|
3995 const char *id;
|
|
3996
|
|
3997 if (start - last) {
|
|
3998 g_string_append_len(msg, last, start - last);
|
|
3999 }
|
|
4000
|
|
4001 id = g_datalist_get_data(&attribs, "id");
|
|
4002
|
|
4003 /* ... if it refers to a valid gaim image ... */
|
|
4004 if (id && (image = gaim_imgstore_get(atoi(id)))) {
|
|
4005 /* ... append the message from start to the tag ... */
|
|
4006 unsigned long size = gaim_imgstore_get_size(image);
|
|
4007 const char *filename = gaim_imgstore_get_filename(image);
|
|
4008 gpointer imgdata = gaim_imgstore_get_data(image);
|
|
4009
|
|
4010 oscar_id++;
|
|
4011
|
|
4012 /* ... insert a new img tag with the oscar id ... */
|
|
4013 if (filename)
|
|
4014 g_string_append_printf(msg,
|
|
4015 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">",
|
|
4016 filename, oscar_id, size);
|
|
4017 else
|
|
4018 g_string_append_printf(msg,
|
|
4019 "<IMG ID=\"%d\" DATASIZE=\"%lu\">",
|
|
4020 oscar_id, size);
|
|
4021
|
|
4022 /* ... and append the data to the binary section ... */
|
|
4023 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">",
|
|
4024 oscar_id, size);
|
|
4025 g_string_append_len(data, imgdata, size);
|
|
4026 g_string_append(data, "</DATA>");
|
|
4027 }
|
|
4028 /* If the tag is invalid, skip it, thus no else here */
|
|
4029
|
|
4030 g_datalist_clear(&attribs);
|
|
4031
|
|
4032 /* continue from the end of the tag */
|
|
4033 last = end + 1;
|
|
4034 }
|
|
4035
|
|
4036 /* append any remaining message data */
|
|
4037 if (last && *last)
|
|
4038 g_string_append(msg, last);
|
|
4039
|
|
4040 g_string_append(msg, "</BODY></HTML>");
|
|
4041
|
|
4042 /* Convert the message to a good encoding */
|
|
4043 gaim_plugin_oscar_convert_to_best_encoding(conn->od->gc,
|
|
4044 conn->sn, msg->str, &tmp, &tmplen, &charset, &charsubset);
|
|
4045 g_string_free(msg, TRUE);
|
|
4046 msg = g_string_new_len(tmp, tmplen);
|
|
4047
|
|
4048 /* Append any binary data that we may have */
|
|
4049 if (oscar_id) {
|
|
4050 msg = g_string_append_len(msg, data->str, data->len);
|
|
4051 msg = g_string_append(msg, "</BINARY>");
|
|
4052 }
|
|
4053 g_string_free(data, TRUE);
|
|
4054
|
|
4055 peer_odc_send_im(conn, msg->str, msg->len, charset,
|
|
4056 imflags & GAIM_MESSAGE_AUTO_RESP);
|
|
4057 g_string_free(msg, TRUE);
|
|
4058 }
|
|
4059
|
|
4060 static int
|
|
4061 oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimMessageFlags imflags)
|
|
4062 {
|
|
4063 OscarData *od;
|
|
4064 GaimAccount *account;
|
|
4065 PeerConnection *conn;
|
|
4066 int ret;
|
|
4067 char *iconfile;
|
|
4068 char *tmp1, *tmp2;
|
|
4069
|
|
4070 od = (OscarData *)gc->proto_data;
|
|
4071 account = gaim_connection_get_account(gc);
|
|
4072 ret = 0;
|
|
4073 iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account));
|
|
4074
|
|
4075 if (imflags & GAIM_MESSAGE_AUTO_RESP)
|
|
4076 tmp1 = gaim_str_sub_away_formatters(message, name);
|
|
4077 else
|
|
4078 tmp1 = g_strdup(message);
|
|
4079
|
|
4080 conn = peer_connection_find_by_type(od, name, OSCAR_CAPABILITY_DIRECTIM);
|
|
4081 if ((conn != NULL) && (conn->ready))
|
|
4082 {
|
|
4083 /* If we're directly connected, send a direct IM */
|
|
4084 gaim_odc_send_im(conn, tmp1, imflags);
|
|
4085 } else {
|
|
4086 struct buddyinfo *bi;
|
|
4087 struct aim_sendimext_args args;
|
|
4088 struct stat st;
|
|
4089 gsize len;
|
|
4090 GaimConversation *conv;
|
|
4091
|
|
4092 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account);
|
|
4093
|
|
4094 if (strstr(tmp1, "<IMG "))
|
|
4095 gaim_conversation_write(conv, "",
|
|
4096 _("Your IM Image was not sent. "
|
|
4097 "You must be Direct Connected to send IM Images."),
|
|
4098 GAIM_MESSAGE_ERROR, time(NULL));
|
|
4099
|
|
4100 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name));
|
|
4101 if (!bi) {
|
|
4102 bi = g_new0(struct buddyinfo, 1);
|
|
4103 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi);
|
|
4104 }
|
|
4105
|
|
4106 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES;
|
|
4107 if (od->icq) {
|
|
4108 /* We have to present different "features" (whose meaning
|
|
4109 is unclear and are merely a result of protocol inspection)
|
|
4110 to offline ICQ buddies. Otherwise, the official
|
|
4111 ICQ client doesn't treat those messages as being "ANSI-
|
|
4112 encoded" (and instead, assumes them to be UTF-8).
|
|
4113 For more details, see SF issue 1179452.
|
|
4114 */
|
|
4115 GaimBuddy *buddy = gaim_find_buddy(gc->account, name);
|
|
4116 if (buddy && GAIM_BUDDY_IS_ONLINE(buddy)) {
|
|
4117 args.features = features_icq;
|
|
4118 args.featureslen = sizeof(features_icq);
|
|
4119 } else {
|
|
4120 args.features = features_icq_offline;
|
|
4121 args.featureslen = sizeof(features_icq_offline);
|
|
4122 }
|
|
4123 args.flags |= AIM_IMFLAGS_OFFLINE;
|
|
4124 } else {
|
|
4125 args.features = features_aim;
|
|
4126 args.featureslen = sizeof(features_aim);
|
|
4127
|
|
4128 if (imflags & GAIM_MESSAGE_AUTO_RESP)
|
|
4129 args.flags |= AIM_IMFLAGS_AWAY;
|
|
4130 }
|
|
4131
|
|
4132 if (bi->ico_need) {
|
|
4133 gaim_debug_info("oscar",
|
|
4134 "Sending buddy icon request with message\n");
|
|
4135 args.flags |= AIM_IMFLAGS_BUDDYREQ;
|
|
4136 bi->ico_need = FALSE;
|
|
4137 }
|
|
4138
|
|
4139 if (iconfile && !g_stat(iconfile, &st)) {
|
|
4140 FILE *file = g_fopen(iconfile, "rb");
|
|
4141 if (file) {
|
|
4142 guchar *buf = g_malloc(st.st_size);
|
|
4143 /* TODO: Use g_file_get_contents()? */
|
|
4144 fread(buf, 1, st.st_size, file);
|
|
4145 fclose(file);
|
|
4146
|
|
4147 args.iconlen = st.st_size;
|
|
4148 args.iconsum = aimutil_iconsum(buf, st.st_size);
|
|
4149 args.iconstamp = st.st_mtime;
|
|
4150
|
|
4151 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) {
|
|
4152 bi->ico_informed = FALSE;
|
|
4153 bi->ico_sent = FALSE;
|
|
4154 }
|
|
4155
|
14282
|
4156 /*
|
|
4157 * TODO:
|
|
4158 * For some reason sending our icon to people only works
|
|
4159 * when we're the ones who initiated the conversation. If
|
|
4160 * the other person sends the first IM then they never get
|
|
4161 * the icon. We should fix that.
|
|
4162 */
|
14192
|
4163 if (!bi->ico_informed) {
|
|
4164 gaim_debug_info("oscar",
|
|
4165 "Claiming to have a buddy icon\n");
|
|
4166 args.flags |= AIM_IMFLAGS_HASICON;
|
|
4167 bi->ico_me_len = args.iconlen;
|
|
4168 bi->ico_me_csum = args.iconsum;
|
|
4169 bi->ico_me_time = args.iconstamp;
|
|
4170 bi->ico_informed = TRUE;
|
|
4171 }
|
|
4172
|
|
4173 g_free(buf);
|
|
4174 }
|
|
4175 }
|
|
4176 g_free(iconfile);
|
|
4177
|
|
4178 args.destsn = name;
|
|
4179
|
|
4180 /*
|
|
4181 * If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML.
|
|
4182 */
|
|
4183 if (aim_sn_is_sms(name)) {
|
|
4184 /* Messaging an SMS (mobile) user */
|
|
4185 tmp2 = gaim_unescape_html(tmp1);
|
|
4186 } else if (aim_sn_is_icq(gaim_account_get_username(account))) {
|
|
4187 if (aim_sn_is_icq(name))
|
|
4188 /* From ICQ to ICQ */
|
|
4189 tmp2 = gaim_unescape_html(tmp1);
|
|
4190 else
|
|
4191 /* From ICQ to AIM */
|
|
4192 tmp2 = g_strdup(tmp1);
|
|
4193 } else {
|
|
4194 /* From AIM to AIM and AIM to ICQ */
|
|
4195 tmp2 = g_strdup(tmp1);
|
|
4196 }
|
|
4197 g_free(tmp1);
|
|
4198 tmp1 = tmp2;
|
|
4199 len = strlen(tmp1);
|
|
4200
|
|
4201 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmp1, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset);
|
|
4202 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n",
|
|
4203 args.charset, args.charsubset, args.msglen);
|
|
4204 ret = aim_im_sendch1_ext(od, &args);
|
|
4205 g_free((char *)args.msg);
|
|
4206 }
|
|
4207
|
|
4208 g_free(tmp1);
|
|
4209
|
|
4210 if (ret >= 0)
|
|
4211 return 1;
|
|
4212
|
|
4213 return ret;
|
|
4214 }
|
|
4215
|
|
4216 /*
|
|
4217 * As of 26 June 2006, ICQ users can request AIM info from
|
|
4218 * everyone, and can request ICQ info from ICQ users, and
|
|
4219 * AIM users can only request AIM info.
|
|
4220 */
|
|
4221 static void oscar_get_info(GaimConnection *gc, const char *name) {
|
|
4222 OscarData *od = (OscarData *)gc->proto_data;
|
|
4223
|
|
4224 if (od->icq && aim_sn_is_icq(name))
|
|
4225 aim_icq_getallinfo(od, name);
|
|
4226 else
|
|
4227 aim_locate_getinfoshort(od, name, 0x00000003);
|
|
4228 }
|
|
4229
|
|
4230 #if 0
|
|
4231 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last,
|
|
4232 const char *maiden, const char *city, const char *state, const char *country, int web) {
|
|
4233 /* XXX - some of these things are wrong, but i'm lazy */
|
|
4234 OscarData *od = (OscarData *)gc->proto_data;
|
|
4235 aim_locate_setdirinfo(od, first, middle, last,
|
|
4236 maiden, NULL, NULL, city, state, NULL, 0, web);
|
|
4237 }
|
|
4238 #endif
|
|
4239
|
|
4240 static void oscar_set_idle(GaimConnection *gc, int time) {
|
|
4241 OscarData *od = (OscarData *)gc->proto_data;
|
|
4242 aim_srv_setidle(od, time);
|
|
4243 }
|
|
4244
|
|
4245 static
|
|
4246 gchar *gaim_prpl_oscar_convert_to_infotext(const gchar *str, gsize *ret_len, char **encoding)
|
|
4247 {
|
|
4248 int charset = 0;
|
|
4249 char *encoded = NULL;
|
|
4250
|
|
4251 charset = oscar_charset_check(str);
|
|
4252 if (charset == AIM_CHARSET_UNICODE) {
|
|
4253 encoded = g_convert(str, strlen(str), "UCS-2BE", "UTF-8", NULL, ret_len, NULL);
|
|
4254 *encoding = "unicode-2-0";
|
|
4255 } else if (charset == AIM_CHARSET_CUSTOM) {
|
|
4256 encoded = g_convert(str, strlen(str), "ISO-8859-1", "UTF-8", NULL, ret_len, NULL);
|
|
4257 *encoding = "iso-8859-1";
|
|
4258 } else {
|
|
4259 encoded = g_strdup(str);
|
|
4260 *ret_len = strlen(str);
|
|
4261 *encoding = "us-ascii";
|
|
4262 }
|
|
4263
|
|
4264 return encoded;
|
|
4265 }
|
|
4266
|
|
4267 static void
|
|
4268 oscar_set_info(GaimConnection *gc, const char *rawinfo)
|
|
4269 {
|
|
4270 GaimAccount *account;
|
|
4271 GaimStatus *status;
|
|
4272
|
|
4273 account = gaim_connection_get_account(gc);
|
|
4274 status = gaim_account_get_active_status(account);
|
|
4275 oscar_set_info_and_status(account, TRUE, rawinfo, FALSE, status);
|
|
4276 }
|
|
4277
|
|
4278 static void
|
|
4279 oscar_set_extendedstatus(GaimConnection *gc)
|
|
4280 {
|
|
4281 OscarData *od;
|
|
4282 GaimAccount *account;
|
|
4283 GaimStatus *status;
|
|
4284 const gchar *status_id;
|
|
4285 guint32 data = 0x00000000;
|
|
4286
|
|
4287 od = gc->proto_data;
|
|
4288 account = gaim_connection_get_account(gc);
|
|
4289 status = gaim_account_get_active_status(account);
|
|
4290 status_id = gaim_status_get_id(status);
|
|
4291
|
|
4292 data |= AIM_ICQ_STATE_HIDEIP;
|
|
4293 if (gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE))
|
|
4294 data |= AIM_ICQ_STATE_WEBAWARE;
|
|
4295
|
|
4296 if (!strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE) || !strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE))
|
|
4297 data |= AIM_ICQ_STATE_NORMAL;
|
|
4298 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY))
|
|
4299 data |= AIM_ICQ_STATE_AWAY;
|
|
4300 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND))
|
|
4301 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY;
|
|
4302 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA))
|
|
4303 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY;
|
|
4304 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED))
|
|
4305 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY;
|
|
4306 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT))
|
|
4307 data |= AIM_ICQ_STATE_CHAT;
|
|
4308 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE))
|
|
4309 data |= AIM_ICQ_STATE_INVISIBLE;
|
|
4310 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM))
|
|
4311 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY;
|
|
4312
|
|
4313 aim_setextstatus(od, data);
|
|
4314 }
|
|
4315
|
|
4316 static void
|
|
4317 oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo,
|
|
4318 gboolean setstatus, GaimStatus *status)
|
|
4319 {
|
|
4320 GaimConnection *gc = gaim_account_get_connection(account);
|
|
4321 OscarData *od = gc->proto_data;
|
|
4322 GaimPresence *presence;
|
|
4323 GaimStatusType *status_type;
|
|
4324 GaimStatusPrimitive primitive;
|
|
4325 gboolean invisible;
|
|
4326
|
|
4327 char *htmlinfo;
|
|
4328 char *info_encoding = NULL;
|
|
4329 char *info = NULL;
|
|
4330 gsize infolen = 0;
|
|
4331
|
|
4332 const char *htmlaway;
|
|
4333 char *away_encoding = NULL;
|
|
4334 char *away = NULL;
|
|
4335 gsize awaylen = 0;
|
|
4336
|
|
4337 status_type = gaim_status_get_type(status);
|
|
4338 primitive = gaim_status_type_get_primitive(status_type);
|
|
4339 presence = gaim_account_get_presence(account);
|
|
4340 invisible = gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE);
|
|
4341
|
|
4342 if (!setinfo)
|
|
4343 {
|
|
4344 /* Do nothing! */
|
|
4345 }
|
|
4346 else if (od->rights.maxsiglen == 0)
|
|
4347 {
|
|
4348 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."),
|
|
4349 _("You have probably requested to set your "
|
|
4350 "profile before the login procedure completed. "
|
|
4351 "Your profile remains unset; try setting it "
|
|
4352 "again when you are fully connected."));
|
|
4353 }
|
|
4354 else if (rawinfo != NULL)
|
|
4355 {
|
|
4356 htmlinfo = gaim_strdup_withhtml(rawinfo);
|
|
4357 info = gaim_prpl_oscar_convert_to_infotext(htmlinfo, &infolen, &info_encoding);
|
|
4358 g_free(htmlinfo);
|
|
4359
|
|
4360 if (infolen > od->rights.maxsiglen)
|
|
4361 {
|
|
4362 gchar *errstr;
|
|
4363 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte "
|
|
4364 "has been exceeded. Gaim has truncated it for you.",
|
|
4365 "The maximum profile length of %d bytes "
|
|
4366 "has been exceeded. Gaim has truncated it for you.",
|
|
4367 od->rights.maxsiglen), od->rights.maxsiglen);
|
|
4368 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr);
|
|
4369 g_free(errstr);
|
|
4370 }
|
|
4371 }
|
|
4372
|
|
4373 if (!setstatus)
|
|
4374 {
|
|
4375 /* Do nothing! */
|
|
4376 }
|
|
4377 else if (primitive == GAIM_STATUS_AVAILABLE)
|
|
4378 {
|
|
4379 const char *status_html;
|
|
4380 char *status_text = NULL;
|
|
4381
|
|
4382 status_html = gaim_status_get_attr_string(status, "message");
|
|
4383 if (status_html != NULL)
|
|
4384 {
|
|
4385 status_text = gaim_markup_strip_html(status_html);
|
|
4386 /* If the status_text is longer than 60 character then truncate it */
|
|
4387 if (strlen(status_text) > 60)
|
|
4388 {
|
|
4389 char *tmp = g_utf8_find_prev_char(status_text, &status_text[58]);
|
|
4390 strcpy(tmp, "...");
|
|
4391 }
|
|
4392 }
|
|
4393
|
|
4394 aim_srv_setstatusmsg(od, status_text);
|
|
4395 g_free(status_text);
|
|
4396
|
|
4397 /* This is needed for us to un-set any previous away message. */
|
|
4398 away = g_strdup("");
|
|
4399 }
|
|
4400 else if ((primitive == GAIM_STATUS_AWAY) ||
|
|
4401 (primitive == GAIM_STATUS_EXTENDED_AWAY))
|
|
4402 {
|
|
4403 htmlaway = gaim_status_get_attr_string(status, "message");
|
|
4404 if ((htmlaway == NULL) || (*htmlaway == '\0'))
|
|
4405 htmlaway = _("Away");
|
|
4406 away = gaim_prpl_oscar_convert_to_infotext(htmlaway, &awaylen, &away_encoding);
|
|
4407
|
|
4408 if (awaylen > od->rights.maxawaymsglen)
|
|
4409 {
|
|
4410 gchar *errstr;
|
|
4411
|
|
4412 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte "
|
|
4413 "has been exceeded. Gaim has truncated it for you.",
|
|
4414 "The maximum away message length of %d bytes "
|
|
4415 "has been exceeded. Gaim has truncated it for you.",
|
|
4416 od->rights.maxawaymsglen), od->rights.maxawaymsglen);
|
|
4417 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr);
|
|
4418 g_free(errstr);
|
|
4419 }
|
|
4420 }
|
|
4421
|
|
4422 if (setstatus)
|
|
4423 oscar_set_extendedstatus(gc);
|
|
4424
|
|
4425 aim_locate_setprofile(od, info_encoding, info, MIN(infolen, od->rights.maxsiglen),
|
|
4426 away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen));
|
|
4427 g_free(info);
|
|
4428 g_free(away);
|
|
4429 }
|
|
4430
|
|
4431 static void
|
|
4432 oscar_set_status_icq(GaimAccount *account, GaimStatus *status)
|
|
4433 {
|
|
4434 GaimConnection *gc = gaim_account_get_connection(account);
|
|
4435 OscarData *od = NULL;
|
|
4436
|
|
4437 if (gc)
|
|
4438 od = (OscarData *)gc->proto_data;
|
|
4439 if (!od)
|
|
4440 return;
|
|
4441
|
|
4442 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_INVISIBLE)
|
|
4443 account->perm_deny = GAIM_PRIVACY_ALLOW_USERS;
|
|
4444 else
|
|
4445 account->perm_deny = GAIM_PRIVACY_DENY_USERS;
|
|
4446
|
|
4447 if ((od->ssi.received_data) && (aim_ssi_getpermdeny(od->ssi.local) != account->perm_deny))
|
|
4448 aim_ssi_setpermdeny(od, account->perm_deny, 0xffffffff);
|
|
4449
|
|
4450 oscar_set_extendedstatus(gc);
|
|
4451 }
|
|
4452
|
|
4453 static void
|
|
4454 oscar_set_status(GaimAccount *account, GaimStatus *status)
|
|
4455 {
|
|
4456 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status));
|
|
4457
|
|
4458 if (!gaim_status_is_active(status))
|
|
4459 return;
|
|
4460
|
|
4461 if (!gaim_account_is_connected(account))
|
|
4462 return;
|
|
4463
|
|
4464 /* Set the AIM-style away message for both AIM and ICQ accounts */
|
|
4465 oscar_set_info_and_status(account, FALSE, NULL, TRUE, status);
|
|
4466
|
|
4467 /* Set the ICQ status for ICQ accounts only */
|
|
4468 if (aim_sn_is_icq(gaim_account_get_username(account)))
|
|
4469 oscar_set_status_icq(account, status);
|
|
4470 }
|
|
4471
|
|
4472 #ifdef CRAZY_WARN
|
|
4473 static void
|
|
4474 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) {
|
|
4475 OscarData *od = (OscarData *)gc->proto_data;
|
|
4476 aim_im_warn(od, od->conn, name, anonymous ? AIM_WARN_ANON : 0);
|
|
4477 }
|
|
4478 #endif
|
|
4479
|
|
4480 static void
|
|
4481 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {
|
|
4482 OscarData *od = (OscarData *)gc->proto_data;
|
|
4483
|
|
4484 if (!aim_snvalid(buddy->name)) {
|
|
4485 gchar *buf;
|
|
4486 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);
|
|
4487 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf))
|
|
4488 gaim_notify_error(gc, NULL, _("Unable To Add"), buf);
|
|
4489 g_free(buf);
|
|
4490
|
|
4491 /* Remove from local list */
|
|
4492 gaim_blist_remove_buddy(buddy);
|
|
4493
|
|
4494 return;
|
|
4495 }
|
|
4496
|
|
4497 if ((od->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) {
|
|
4498 gaim_debug_info("oscar",
|
|
4499 "ssi: adding buddy %s to group %s\n", buddy->name, group->name);
|
|
4500 aim_ssi_addbuddy(od, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0);
|
|
4501 }
|
|
4502
|
|
4503 /* XXX - Should this be done from AIM accounts, as well? */
|
|
4504 if (od->icq)
|
|
4505 aim_icq_getalias(od, buddy->name);
|
|
4506 }
|
|
4507
|
|
4508 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) {
|
|
4509 OscarData *od = (OscarData *)gc->proto_data;
|
|
4510
|
|
4511 if (od->ssi.received_data) {
|
|
4512 gaim_debug_info("oscar",
|
|
4513 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name);
|
|
4514 aim_ssi_delbuddy(od, buddy->name, group->name);
|
|
4515 }
|
|
4516 }
|
|
4517
|
|
4518 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) {
|
|
4519 OscarData *od = (OscarData *)gc->proto_data;
|
|
4520 if (od->ssi.received_data && strcmp(old_group, new_group)) {
|
|
4521 gaim_debug_info("oscar",
|
|
4522 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group);
|
|
4523 aim_ssi_movebuddy(od, old_group, new_group, name);
|
|
4524 }
|
|
4525 }
|
|
4526
|
|
4527 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) {
|
|
4528 OscarData *od = (OscarData *)gc->proto_data;
|
|
4529 if (od->ssi.received_data) {
|
|
4530 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, name);
|
|
4531 if (gname) {
|
|
4532 gaim_debug_info("oscar",
|
|
4533 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)");
|
|
4534 aim_ssi_aliasbuddy(od, gname, name, alias);
|
|
4535 }
|
|
4536 }
|
|
4537 }
|
|
4538
|
|
4539 /*
|
|
4540 * FYI, the OSCAR SSI code removes empty groups automatically.
|
|
4541 */
|
|
4542 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) {
|
|
4543 OscarData *od = (OscarData *)gc->proto_data;
|
|
4544
|
|
4545 if (od->ssi.received_data) {
|
|
4546 if (aim_ssi_itemlist_finditem(od->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) {
|
|
4547 GList *cur, *groups = NULL;
|
|
4548 GaimAccount *account = gaim_connection_get_account(gc);
|
|
4549
|
|
4550 /* Make a list of what the groups each buddy is in */
|
|
4551 for (cur = moved_buddies; cur != NULL; cur = cur->next) {
|
|
4552 GaimBlistNode *node = cur->data;
|
|
4553 /* node is GaimBuddy, parent is a GaimContact.
|
|
4554 * We must go two levels up to get the Group */
|
|
4555 groups = g_list_append(groups,
|
|
4556 node->parent->parent);
|
|
4557 }
|
|
4558
|
|
4559 gaim_account_remove_buddies(account, moved_buddies, groups);
|
|
4560 gaim_account_add_buddies(account, moved_buddies);
|
|
4561 g_list_free(groups);
|
|
4562 gaim_debug_info("oscar",
|
|
4563 "ssi: moved all buddies from group %s to %s\n", old_name, group->name);
|
|
4564 } else {
|
|
4565 aim_ssi_rename_group(od, old_name, group->name);
|
|
4566 gaim_debug_info("oscar",
|
|
4567 "ssi: renamed group %s to %s\n", old_name, group->name);
|
|
4568 }
|
|
4569 }
|
|
4570 }
|
|
4571
|
|
4572 static gboolean gaim_ssi_rerequestdata(gpointer data) {
|
|
4573 OscarData *od = data;
|
|
4574
|
|
4575 aim_ssi_reqdata(od);
|
|
4576
|
|
4577 return TRUE;
|
|
4578 }
|
|
4579
|
|
4580 static int gaim_ssi_parseerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4581 GaimConnection *gc = od->gc;
|
|
4582 va_list ap;
|
|
4583 guint16 reason;
|
|
4584
|
|
4585 va_start(ap, fr);
|
|
4586 reason = (guint16)va_arg(ap, unsigned int);
|
|
4587 va_end(ap);
|
|
4588
|
|
4589 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason);
|
|
4590
|
|
4591 if (reason == 0x0005) {
|
|
4592 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"),
|
|
4593 _("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."));
|
|
4594 if (od->getblisttimer > 0)
|
|
4595 gaim_timeout_remove(od->getblisttimer);
|
|
4596 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od);
|
|
4597 }
|
|
4598
|
|
4599 oscar_set_extendedstatus(gc);
|
|
4600
|
|
4601 /* Activate SSI */
|
|
4602 /* Sending the enable causes other people to be able to see you, and you to see them */
|
|
4603 /* Make sure your privacy setting/invisibility is set how you want it before this! */
|
|
4604 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n");
|
|
4605 aim_ssi_enable(od);
|
|
4606
|
|
4607 return 1;
|
|
4608 }
|
|
4609
|
|
4610 static int gaim_ssi_parserights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4611 int i;
|
|
4612 va_list ap;
|
|
4613 int numtypes;
|
|
4614 guint16 *maxitems;
|
|
4615
|
|
4616 va_start(ap, fr);
|
|
4617 numtypes = va_arg(ap, int);
|
|
4618 maxitems = va_arg(ap, guint16 *);
|
|
4619 va_end(ap);
|
|
4620
|
|
4621 gaim_debug_misc("oscar", "ssi rights:");
|
|
4622
|
|
4623 for (i=0; i<numtypes; i++)
|
|
4624 gaim_debug_misc(NULL, " max type 0x%04x=%hd,",
|
|
4625 i, maxitems[i]);
|
|
4626
|
|
4627 gaim_debug_misc(NULL, "\n");
|
|
4628
|
|
4629 if (numtypes >= 0)
|
|
4630 od->rights.maxbuddies = maxitems[0];
|
|
4631 if (numtypes >= 1)
|
|
4632 od->rights.maxgroups = maxitems[1];
|
|
4633 if (numtypes >= 2)
|
|
4634 od->rights.maxpermits = maxitems[2];
|
|
4635 if (numtypes >= 3)
|
|
4636 od->rights.maxdenies = maxitems[3];
|
|
4637
|
|
4638 return 1;
|
|
4639 }
|
|
4640
|
|
4641 static int gaim_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
|
|
4642 {
|
|
4643 GaimConnection *gc;
|
|
4644 GaimAccount *account;
|
|
4645 GaimGroup *g;
|
|
4646 GaimBuddy *b;
|
|
4647 struct aim_ssi_item *curitem;
|
|
4648 guint32 tmp;
|
|
4649 va_list ap;
|
|
4650 guint16 fmtver, numitems;
|
|
4651 guint32 timestamp;
|
|
4652
|
|
4653 gc = od->gc;
|
|
4654 od = gc->proto_data;
|
|
4655 account = gaim_connection_get_account(gc);
|
|
4656
|
|
4657 va_start(ap, fr);
|
|
4658 fmtver = (guint16)va_arg(ap, int);
|
|
4659 numitems = (guint16)va_arg(ap, int);
|
|
4660 timestamp = va_arg(ap, guint32);
|
|
4661 va_end(ap);
|
|
4662
|
|
4663 /* Don't attempt to re-request our buddy list later */
|
|
4664 if (od->getblisttimer != 0)
|
|
4665 gaim_timeout_remove(od->getblisttimer);
|
|
4666 od->getblisttimer = 0;
|
|
4667
|
|
4668 gaim_debug_info("oscar",
|
|
4669 "ssi: syncing local list and server list\n");
|
|
4670
|
|
4671 if ((timestamp == 0) || (numitems == 0)) {
|
|
4672 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);
|
|
4673 return 1;
|
|
4674 }
|
|
4675
|
|
4676 /* Clean the buddy list */
|
|
4677 aim_ssi_cleanlist(od);
|
|
4678
|
|
4679 { /* If not in server list then prune from local list */
|
|
4680 GaimBlistNode *gnode, *cnode, *bnode;
|
|
4681 GaimBuddyList *blist;
|
|
4682 GSList *cur, *next;
|
|
4683
|
|
4684 /* Buddies */
|
|
4685 cur = NULL;
|
|
4686 if ((blist = gaim_get_blist()) != NULL) {
|
|
4687 for (gnode = blist->root; gnode; gnode = gnode->next) {
|
|
4688 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
|
|
4689 continue;
|
|
4690 g = (GaimGroup *)gnode;
|
|
4691 for (cnode = gnode->child; cnode; cnode = cnode->next) {
|
|
4692 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))
|
|
4693 continue;
|
|
4694 for (bnode = cnode->child; bnode; bnode = bnode->next) {
|
|
4695 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
|
|
4696 continue;
|
|
4697 b = (GaimBuddy *)bnode;
|
|
4698 if (b->account == gc->account) {
|
|
4699 if (aim_ssi_itemlist_exists(od->ssi.local, b->name)) {
|
|
4700 /* If the buddy is an ICQ user then load his nickname */
|
|
4701 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick");
|
|
4702 char *alias;
|
|
4703 if (servernick)
|
|
4704 serv_got_alias(gc, b->name, servernick);
|
|
4705
|
|
4706 /* Store local alias on server */
|
|
4707 alias = aim_ssi_getalias(od->ssi.local, g->name, b->name);
|
|
4708 if (!alias && b->alias && strlen(b->alias))
|
|
4709 aim_ssi_aliasbuddy(od, g->name, b->name, b->alias);
|
|
4710 g_free(alias);
|
|
4711 } else {
|
|
4712 gaim_debug_info("oscar",
|
|
4713 "ssi: removing buddy %s from local list\n", b->name);
|
|
4714 /* We can't actually remove now because it will screw up our looping */
|
|
4715 cur = g_slist_prepend(cur, b);
|
|
4716 }
|
|
4717 }
|
|
4718 }
|
|
4719 }
|
|
4720 }
|
|
4721 }
|
|
4722
|
|
4723 while (cur != NULL) {
|
|
4724 b = cur->data;
|
|
4725 cur = g_slist_remove(cur, b);
|
|
4726 gaim_blist_remove_buddy(b);
|
|
4727 }
|
|
4728
|
|
4729 /* Permit list */
|
|
4730 if (gc->account->permit) {
|
|
4731 next = gc->account->permit;
|
|
4732 while (next != NULL) {
|
|
4733 cur = next;
|
|
4734 next = next->next;
|
|
4735 if (!aim_ssi_itemlist_finditem(od->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) {
|
|
4736 gaim_debug_info("oscar",
|
|
4737 "ssi: removing permit %s from local list\n", (const char *)cur->data);
|
|
4738 gaim_privacy_permit_remove(account, cur->data, TRUE);
|
|
4739 }
|
|
4740 }
|
|
4741 }
|
|
4742
|
|
4743 /* Deny list */
|
|
4744 if (gc->account->deny) {
|
|
4745 next = gc->account->deny;
|
|
4746 while (next != NULL) {
|
|
4747 cur = next;
|
|
4748 next = next->next;
|
|
4749 if (!aim_ssi_itemlist_finditem(od->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) {
|
|
4750 gaim_debug_info("oscar",
|
|
4751 "ssi: removing deny %s from local list\n", (const char *)cur->data);
|
|
4752 gaim_privacy_deny_remove(account, cur->data, TRUE);
|
|
4753 }
|
|
4754 }
|
|
4755 }
|
|
4756 /* Presence settings (idle time visibility) */
|
|
4757 if ((tmp = aim_ssi_getpresence(od->ssi.local)) != 0xFFFFFFFF)
|
|
4758 if (!(tmp & 0x400))
|
|
4759 aim_ssi_setpresence(od, tmp | 0x400);
|
|
4760 } /* end pruning buddies from local list */
|
|
4761
|
|
4762 /* Add from server list to local list */
|
|
4763 for (curitem=od->ssi.local; curitem; curitem=curitem->next) {
|
|
4764 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL)))
|
|
4765 switch (curitem->type) {
|
|
4766 case 0x0000: { /* Buddy */
|
|
4767 if (curitem->name) {
|
|
4768 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, curitem->name);
|
|
4769 char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
|
|
4770 char *alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name);
|
|
4771 char *alias_utf8;
|
|
4772
|
|
4773 if (alias != NULL)
|
|
4774 {
|
|
4775 if (g_utf8_validate(alias, -1, NULL))
|
|
4776 alias_utf8 = g_strdup(alias);
|
|
4777 else
|
|
4778 alias_utf8 = oscar_utf8_try_convert(account, alias);
|
|
4779 }
|
|
4780 else
|
|
4781 alias_utf8 = NULL;
|
|
4782
|
|
4783 b = gaim_find_buddy(gc->account, curitem->name);
|
|
4784 /* Should gname be freed here? -- elb */
|
|
4785 /* Not with the current code, but that might be cleaner -- med */
|
|
4786 g_free(alias);
|
|
4787 if (b) {
|
|
4788 /* Get server stored alias */
|
|
4789 if (alias_utf8) {
|
|
4790 g_free(b->alias);
|
|
4791 b->alias = g_strdup(alias_utf8);
|
|
4792 }
|
|
4793 } else {
|
|
4794 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8);
|
|
4795
|
|
4796 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
|
|
4797 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
|
|
4798 gaim_blist_add_group(g, NULL);
|
|
4799 }
|
|
4800
|
|
4801 gaim_debug_info("oscar",
|
|
4802 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans"));
|
|
4803 gaim_blist_add_buddy(b, NULL, g, NULL);
|
|
4804 }
|
|
4805 if (!aim_sncmp(curitem->name, account->username)) {
|
|
4806 char *comment = aim_ssi_getcomment(od->ssi.local, gname, curitem->name);
|
|
4807 gaim_check_comment(od, comment);
|
|
4808 g_free(comment);
|
|
4809 }
|
|
4810 g_free(gname_utf8);
|
|
4811 g_free(alias_utf8);
|
|
4812 }
|
|
4813 } break;
|
|
4814
|
|
4815 case 0x0001: { /* Group */
|
|
4816 /* Shouldn't add empty groups */
|
|
4817 } break;
|
|
4818
|
|
4819 case 0x0002: { /* Permit buddy */
|
|
4820 if (curitem->name) {
|
|
4821 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */
|
|
4822 GSList *list;
|
|
4823 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
|
|
4824 if (!list) {
|
|
4825 gaim_debug_info("oscar",
|
|
4826 "ssi: adding permit buddy %s to local list\n", curitem->name);
|
|
4827 gaim_privacy_permit_add(account, curitem->name, TRUE);
|
|
4828 }
|
|
4829 }
|
|
4830 } break;
|
|
4831
|
|
4832 case 0x0003: { /* Deny buddy */
|
|
4833 if (curitem->name) {
|
|
4834 GSList *list;
|
|
4835 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
|
|
4836 if (!list) {
|
|
4837 gaim_debug_info("oscar",
|
|
4838 "ssi: adding deny buddy %s to local list\n", curitem->name);
|
|
4839 gaim_privacy_deny_add(account, curitem->name, TRUE);
|
|
4840 }
|
|
4841 }
|
|
4842 } break;
|
|
4843
|
|
4844 case 0x0004: { /* Permit/deny setting */
|
|
4845 if (curitem->data) {
|
|
4846 guint8 permdeny;
|
|
4847 if ((permdeny = aim_ssi_getpermdeny(od->ssi.local)) && (permdeny != account->perm_deny)) {
|
|
4848 gaim_debug_info("oscar",
|
|
4849 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny);
|
|
4850 account->perm_deny = permdeny;
|
|
4851 if (od->icq && account->perm_deny == GAIM_PRIVACY_ALLOW_USERS) {
|
|
4852 gaim_presence_set_status_active(account->presence, OSCAR_STATUS_ID_INVISIBLE, TRUE);
|
|
4853 }
|
|
4854 }
|
|
4855 }
|
|
4856 } break;
|
|
4857
|
|
4858 case 0x0005: { /* Presence setting */
|
|
4859 /* We don't want to change Gaim's setting because it applies to all accounts */
|
|
4860 } break;
|
|
4861 } /* End of switch on curitem->type */
|
|
4862 } /* End of for loop */
|
|
4863
|
|
4864 oscar_set_extendedstatus(gc);
|
|
4865
|
|
4866 /* Activate SSI */
|
|
4867 /* Sending the enable causes other people to be able to see you, and you to see them */
|
|
4868 /* Make sure your privacy setting/invisibility is set how you want it before this! */
|
|
4869 gaim_debug_info("oscar",
|
|
4870 "ssi: activating server-stored buddy list\n");
|
|
4871 aim_ssi_enable(od);
|
|
4872
|
|
4873 return 1;
|
|
4874 }
|
|
4875
|
|
4876 static int gaim_ssi_parseack(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4877 GaimConnection *gc = od->gc;
|
|
4878 va_list ap;
|
|
4879 struct aim_ssi_tmp *retval;
|
|
4880
|
|
4881 va_start(ap, fr);
|
|
4882 retval = va_arg(ap, struct aim_ssi_tmp *);
|
|
4883 va_end(ap);
|
|
4884
|
|
4885 while (retval) {
|
|
4886 gaim_debug_misc("oscar",
|
|
4887 "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");
|
|
4888
|
|
4889 if (retval->ack != 0xffff)
|
|
4890 switch (retval->ack) {
|
|
4891 case 0x0000: { /* added successfully */
|
|
4892 } break;
|
|
4893
|
|
4894 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */
|
|
4895 gchar *buf;
|
|
4896 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)")));
|
|
4897 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf))
|
|
4898 gaim_notify_error(gc, NULL, _("Unable To Add"), buf);
|
|
4899 g_free(buf);
|
|
4900 }
|
|
4901
|
|
4902 case 0x000e: { /* buddy requires authorization */
|
|
4903 if ((retval->action == SNAC_SUBTYPE_FEEDBAG_ADD) && (retval->name))
|
|
4904 gaim_auth_sendrequest(gc, retval->name);
|
|
4905 } break;
|
|
4906
|
|
4907 default: { /* La la la */
|
|
4908 gchar *buf;
|
|
4909 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack);
|
|
4910 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)")));
|
|
4911 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf))
|
|
4912 gaim_notify_error(gc, NULL, _("Unable To Add"), buf);
|
|
4913 g_free(buf);
|
|
4914 } break;
|
|
4915 }
|
|
4916
|
|
4917 retval = retval->next;
|
|
4918 }
|
|
4919
|
|
4920 return 1;
|
|
4921 }
|
|
4922
|
|
4923 static int gaim_ssi_parseadd(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4924 GaimConnection *gc = od->gc;
|
|
4925 char *gname, *gname_utf8, *alias, *alias_utf8;
|
|
4926 GaimBuddy *b;
|
|
4927 GaimGroup *g;
|
|
4928 va_list ap;
|
|
4929 guint16 type;
|
|
4930 const char *name;
|
|
4931
|
|
4932 va_start(ap, fr);
|
|
4933 type = (guint16)va_arg(ap, int);
|
|
4934 name = va_arg(ap, char *);
|
|
4935 va_end(ap);
|
|
4936
|
|
4937 if ((type != 0x0000) || (name == NULL))
|
|
4938 return 1;
|
|
4939
|
|
4940 gname = aim_ssi_itemlist_findparentname(od->ssi.local, name);
|
|
4941 gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
|
|
4942
|
|
4943 alias = aim_ssi_getalias(od->ssi.local, gname, name);
|
|
4944 if (alias != NULL)
|
|
4945 {
|
|
4946 if (g_utf8_validate(alias, -1, NULL))
|
|
4947 alias_utf8 = g_strdup(alias);
|
|
4948 else
|
|
4949 alias_utf8 = oscar_utf8_try_convert(gaim_connection_get_account(gc), alias);
|
|
4950 }
|
|
4951 else
|
|
4952 alias_utf8 = NULL;
|
|
4953
|
|
4954 b = gaim_find_buddy(gc->account, name);
|
|
4955 g_free(alias);
|
|
4956
|
|
4957 if (b) {
|
|
4958 /* Get server stored alias */
|
|
4959 if (alias_utf8) {
|
|
4960 g_free(b->alias);
|
|
4961 b->alias = g_strdup(alias_utf8);
|
|
4962 }
|
|
4963 } else {
|
|
4964 b = gaim_buddy_new(gc->account, name, alias_utf8);
|
|
4965
|
|
4966 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
|
|
4967 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
|
|
4968 gaim_blist_add_group(g, NULL);
|
|
4969 }
|
|
4970
|
|
4971 gaim_debug_info("oscar",
|
|
4972 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans"));
|
|
4973 gaim_blist_add_buddy(b, NULL, g, NULL);
|
|
4974 }
|
|
4975 g_free(gname_utf8);
|
|
4976 g_free(alias_utf8);
|
|
4977
|
|
4978 return 1;
|
|
4979 }
|
|
4980
|
|
4981 static int gaim_ssi_authgiven(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
4982 GaimConnection *gc = od->gc;
|
|
4983 va_list ap;
|
|
4984 char *sn, *msg;
|
|
4985 gchar *dialog_msg, *nombre;
|
|
4986 struct name_data *data;
|
|
4987 GaimBuddy *buddy;
|
|
4988
|
|
4989 va_start(ap, fr);
|
|
4990 sn = va_arg(ap, char *);
|
|
4991 msg = va_arg(ap, char *);
|
|
4992 va_end(ap);
|
|
4993
|
|
4994 gaim_debug_info("oscar",
|
|
4995 "ssi: %s has given you permission to add him to your buddy list\n", sn);
|
|
4996
|
|
4997 buddy = gaim_find_buddy(gc->account, sn);
|
|
4998 if (buddy && (gaim_buddy_get_alias_only(buddy)))
|
|
4999 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy));
|
|
5000 else
|
|
5001 nombre = g_strdup(sn);
|
|
5002
|
|
5003 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);
|
|
5004 data = g_new(struct name_data, 1);
|
|
5005 data->gc = gc;
|
|
5006 data->name = g_strdup(sn);
|
|
5007 data->nick = NULL;
|
|
5008
|
|
5009 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg,
|
|
5010 GAIM_DEFAULT_ACTION_NONE, data,
|
|
5011 G_CALLBACK(gaim_icq_buddyadd),
|
|
5012 G_CALLBACK(oscar_free_name_data));
|
|
5013
|
|
5014 g_free(dialog_msg);
|
|
5015 g_free(nombre);
|
|
5016
|
|
5017 return 1;
|
|
5018 }
|
|
5019
|
|
5020 static int gaim_ssi_authrequest(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
5021 GaimConnection *gc = od->gc;
|
|
5022 va_list ap;
|
|
5023 char *sn;
|
|
5024 char *msg;
|
|
5025 GaimAccount *account = gaim_connection_get_account(gc);
|
|
5026 gchar *nombre;
|
|
5027 gchar *reason = NULL;
|
|
5028 gchar *dialog_msg;
|
|
5029 struct name_data *data;
|
|
5030 GaimBuddy *buddy;
|
|
5031
|
|
5032 va_start(ap, fr);
|
|
5033 sn = va_arg(ap, char *);
|
|
5034 msg = va_arg(ap, char *);
|
|
5035 va_end(ap);
|
|
5036
|
|
5037 gaim_debug_info("oscar",
|
|
5038 "ssi: received authorization request from %s\n", sn);
|
|
5039
|
|
5040 buddy = gaim_find_buddy(account, sn);
|
|
5041 if (buddy && (gaim_buddy_get_alias_only(buddy)))
|
|
5042 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy));
|
|
5043 else
|
|
5044 nombre = g_strdup(sn);
|
|
5045
|
|
5046 if (msg != NULL)
|
|
5047 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg, strlen(msg));
|
|
5048
|
|
5049 if (reason == NULL)
|
|
5050 reason = g_strdup(_("No reason given."));
|
|
5051
|
|
5052 dialog_msg = g_strdup_printf(
|
|
5053 _("The user %s wants to add %s to their buddy list for the following reason:\n%s"),
|
|
5054 nombre, gaim_account_get_username(account), reason);
|
|
5055 g_free(reason);
|
|
5056
|
|
5057 data = g_new(struct name_data, 1);
|
|
5058 data->gc = gc;
|
|
5059 data->name = g_strdup(sn);
|
|
5060 data->nick = NULL;
|
|
5061
|
|
5062 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg,
|
|
5063 GAIM_DEFAULT_ACTION_NONE, data, 2,
|
|
5064 _("_Authorize"), G_CALLBACK(gaim_auth_grant),
|
|
5065 _("_Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt));
|
|
5066
|
|
5067 g_free(dialog_msg);
|
|
5068 g_free(nombre);
|
|
5069
|
|
5070 return 1;
|
|
5071 }
|
|
5072
|
|
5073 static int gaim_ssi_authreply(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
5074 GaimConnection *gc = od->gc;
|
|
5075 va_list ap;
|
|
5076 char *sn, *msg;
|
|
5077 gchar *dialog_msg, *nombre;
|
|
5078 guint8 reply;
|
|
5079 GaimBuddy *buddy;
|
|
5080
|
|
5081 va_start(ap, fr);
|
|
5082 sn = va_arg(ap, char *);
|
|
5083 reply = (guint8)va_arg(ap, int);
|
|
5084 msg = va_arg(ap, char *);
|
|
5085 va_end(ap);
|
|
5086
|
|
5087 gaim_debug_info("oscar",
|
|
5088 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply);
|
|
5089
|
|
5090 buddy = gaim_find_buddy(gc->account, sn);
|
|
5091 if (buddy && (gaim_buddy_get_alias_only(buddy)))
|
|
5092 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy));
|
|
5093 else
|
|
5094 nombre = g_strdup(sn);
|
|
5095
|
|
5096 if (reply) {
|
|
5097 /* Granted */
|
|
5098 dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your buddy list."), nombre);
|
|
5099 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg);
|
|
5100 } else {
|
|
5101 /* Denied */
|
|
5102 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."));
|
|
5103 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg);
|
|
5104 }
|
|
5105 g_free(dialog_msg);
|
|
5106 g_free(nombre);
|
|
5107
|
|
5108 return 1;
|
|
5109 }
|
|
5110
|
|
5111 static int gaim_ssi_gotadded(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
5112 GaimConnection *gc = od->gc;
|
|
5113 va_list ap;
|
|
5114 char *sn;
|
|
5115 GaimBuddy *buddy;
|
|
5116
|
|
5117 va_start(ap, fr);
|
|
5118 sn = va_arg(ap, char *);
|
|
5119 va_end(ap);
|
|
5120
|
|
5121 buddy = gaim_find_buddy(gc->account, sn);
|
|
5122 gaim_debug_info("oscar", "ssi: %s added you to their buddy list\n", sn);
|
|
5123 gaim_account_notify_added(gc->account, sn, NULL, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL);
|
|
5124
|
|
5125 return 1;
|
|
5126 }
|
|
5127
|
|
5128 static GList *oscar_chat_info(GaimConnection *gc) {
|
|
5129 GList *m = NULL;
|
|
5130 struct proto_chat_entry *pce;
|
|
5131
|
|
5132 pce = g_new0(struct proto_chat_entry, 1);
|
|
5133 pce->label = _("_Room:");
|
|
5134 pce->identifier = "room";
|
|
5135 pce->required = TRUE;
|
|
5136 m = g_list_append(m, pce);
|
|
5137
|
|
5138 pce = g_new0(struct proto_chat_entry, 1);
|
|
5139 pce->label = _("_Exchange:");
|
|
5140 pce->identifier = "exchange";
|
|
5141 pce->required = TRUE;
|
|
5142 pce->is_int = TRUE;
|
|
5143 pce->min = 4;
|
|
5144 pce->max = 20;
|
|
5145 m = g_list_append(m, pce);
|
|
5146
|
|
5147 return m;
|
|
5148 }
|
|
5149
|
|
5150 static GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name)
|
|
5151 {
|
|
5152 GHashTable *defaults;
|
|
5153
|
|
5154 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
|
|
5155
|
|
5156 if (chat_name != NULL)
|
|
5157 g_hash_table_insert(defaults, "room", g_strdup(chat_name));
|
|
5158
|
|
5159 return defaults;
|
|
5160 }
|
|
5161
|
|
5162 static char *
|
|
5163 oscar_get_chat_name(GHashTable *data)
|
|
5164 {
|
|
5165 return g_strdup(g_hash_table_lookup(data, "room"));
|
|
5166 }
|
|
5167
|
|
5168 static void
|
|
5169 oscar_join_chat(GaimConnection *gc, GHashTable *data)
|
|
5170 {
|
|
5171 OscarData *od = (OscarData *)gc->proto_data;
|
|
5172 FlapConnection *conn;
|
|
5173 char *name, *exchange;
|
|
5174
|
|
5175 name = g_hash_table_lookup(data, "room");
|
|
5176 exchange = g_hash_table_lookup(data, "exchange");
|
|
5177
|
|
5178 if ((name == NULL) || (*name == '\0')) {
|
|
5179 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL);
|
|
5180 return;
|
|
5181 }
|
|
5182
|
|
5183 gaim_debug_info("oscar", "Attempting to join chat room %s.\n", name);
|
|
5184
|
|
5185 if ((conn = flap_connection_getbytype(od, SNAC_FAMILY_CHATNAV)))
|
|
5186 {
|
|
5187 gaim_debug_info("oscar", "chatnav exists, creating room\n");
|
|
5188 aim_chatnav_createroom(od, conn, name, atoi(exchange));
|
|
5189 } else {
|
|
5190 /* this gets tricky */
|
|
5191 struct create_room *cr = g_new0(struct create_room, 1);
|
|
5192 gaim_debug_info("oscar", "chatnav does not exist, opening chatnav\n");
|
|
5193 cr->exchange = atoi(exchange);
|
|
5194 cr->name = g_strdup(name);
|
14348
|
5195 od->create_rooms = g_slist_prepend(od->create_rooms, cr);
|
14192
|
5196 aim_reqservice(od, SNAC_FAMILY_CHATNAV);
|
|
5197 }
|
|
5198 }
|
|
5199
|
|
5200 static void
|
|
5201 oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name)
|
|
5202 {
|
|
5203 OscarData *od = (OscarData *)gc->proto_data;
|
|
5204 struct chat_connection *ccon = find_oscar_chat(gc, id);
|
|
5205
|
|
5206 if (ccon == NULL)
|
|
5207 return;
|
|
5208
|
|
5209 aim_im_sendch2_chatinvite(od, name, message ? message : "",
|
|
5210 ccon->exchange, ccon->name, 0x0);
|
|
5211 }
|
|
5212
|
|
5213 static void
|
|
5214 oscar_chat_leave(GaimConnection *gc, int id)
|
|
5215 {
|
|
5216 GaimConversation *conv;
|
|
5217 struct chat_connection *cc;
|
|
5218
|
|
5219 conv = gaim_find_chat(gc, id);
|
|
5220
|
|
5221 g_return_if_fail(conv != NULL);
|
|
5222
|
|
5223 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name);
|
|
5224
|
|
5225 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)));
|
|
5226 oscar_chat_kill(gc, cc);
|
|
5227 }
|
|
5228
|
|
5229 static int oscar_send_chat(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) {
|
|
5230 OscarData *od = (OscarData *)gc->proto_data;
|
|
5231 GaimConversation *conv = NULL;
|
|
5232 struct chat_connection *c = NULL;
|
|
5233 char *buf, *buf2;
|
|
5234 guint16 charset, charsubset;
|
|
5235 char *charsetstr = NULL;
|
|
5236 int len;
|
|
5237
|
|
5238 if (!(conv = gaim_find_chat(gc, id)))
|
|
5239 return -EINVAL;
|
|
5240
|
|
5241 if (!(c = find_oscar_chat_by_conv(gc, conv)))
|
|
5242 return -EINVAL;
|
|
5243
|
|
5244 buf = gaim_strdup_withhtml(message);
|
|
5245 len = strlen(buf);
|
|
5246
|
|
5247 if (strstr(buf, "<IMG "))
|
|
5248 gaim_conversation_write(conv, "",
|
|
5249 _("Your IM Image was not sent. "
|
|
5250 "You cannot send IM Images in AIM chats."),
|
|
5251 GAIM_MESSAGE_ERROR, time(NULL));
|
|
5252
|
|
5253 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset);
|
|
5254 /*
|
|
5255 * Evan S. suggested that maxvis really does mean "number of
|
|
5256 * visible characters" and not "number of bytes"
|
|
5257 */
|
|
5258 if ((len > c->maxlen) || (len > c->maxvis)) {
|
|
5259 g_free(buf2);
|
|
5260 return -E2BIG;
|
|
5261 }
|
|
5262
|
|
5263 if (charset == AIM_CHARSET_ASCII)
|
|
5264 charsetstr = "us-ascii";
|
|
5265 else if (charset == AIM_CHARSET_UNICODE)
|
|
5266 charsetstr = "unicode-2-0";
|
|
5267 else if (charset == AIM_CHARSET_CUSTOM)
|
|
5268 charsetstr = "iso-8859-1";
|
|
5269 aim_chat_send_im(od, c->conn, 0, buf2, len, charsetstr, "en");
|
|
5270 g_free(buf2);
|
|
5271
|
|
5272 return 0;
|
|
5273 }
|
|
5274
|
|
5275 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b)
|
|
5276 {
|
|
5277 if ((b == NULL) || (b->name == NULL) || aim_sn_is_sms(b->name))
|
|
5278 {
|
|
5279 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a)))
|
|
5280 return "icq";
|
|
5281 else
|
|
5282 return "aim";
|
|
5283 }
|
|
5284
|
|
5285 if (aim_sn_is_icq(b->name))
|
|
5286 return "icq";
|
|
5287 return "aim";
|
|
5288 }
|
|
5289
|
|
5290 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne)
|
|
5291 {
|
|
5292 GaimConnection *gc = NULL;
|
|
5293 OscarData *od = NULL;
|
|
5294 GaimAccount *account = NULL;
|
|
5295 GaimPresence *presence;
|
|
5296 GaimStatus *status;
|
|
5297 const char *status_id;
|
|
5298 char *emblems[4] = {NULL,NULL,NULL,NULL};
|
|
5299 int i = 0;
|
|
5300 aim_userinfo_t *userinfo = NULL;
|
|
5301
|
|
5302 account = b->account;
|
|
5303 if (account != NULL)
|
|
5304 gc = account->gc;
|
|
5305 if (gc != NULL)
|
|
5306 od = gc->proto_data;
|
|
5307 if (od != NULL)
|
|
5308 userinfo = aim_locate_finduserinfo(od, b->name);
|
|
5309
|
|
5310 presence = gaim_buddy_get_presence(b);
|
|
5311 status = gaim_presence_get_active_status(presence);
|
|
5312 status_id = gaim_status_get_id(status);
|
|
5313
|
|
5314 if (gaim_presence_is_online(presence) == FALSE) {
|
|
5315 char *gname;
|
|
5316 if ((b->name) && (od) && (od->ssi.received_data) &&
|
|
5317 (gname = aim_ssi_itemlist_findparentname(od->ssi.local, b->name)) &&
|
|
5318 (aim_ssi_waitingforauth(od->ssi.local, gname, b->name))) {
|
|
5319 emblems[i++] = "notauthorized";
|
|
5320 } else {
|
|
5321 emblems[i++] = "offline";
|
|
5322 }
|
|
5323 }
|
|
5324
|
|
5325 if (b->name && aim_sn_is_icq(b->name)) {
|
|
5326 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE))
|
|
5327 emblems[i++] = "invisible";
|
|
5328 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT))
|
|
5329 emblems[i++] = "freeforchat";
|
|
5330 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND))
|
|
5331 emblems[i++] = "dnd";
|
|
5332 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA))
|
|
5333 emblems[i++] = "unavailable";
|
|
5334 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED))
|
|
5335 emblems[i++] = "occupied";
|
|
5336 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY))
|
|
5337 emblems[i++] = "away";
|
|
5338 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) {
|
|
5339 emblems[i++] = "away";
|
|
5340 }
|
|
5341
|
|
5342 if (userinfo != NULL ) {
|
|
5343 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED)
|
|
5344 emblems[i++] = "unconfirmed"; */
|
|
5345 if ((i < 4) && userinfo->flags & AIM_FLAG_ADMINISTRATOR)
|
|
5346 emblems[i++] = "admin";
|
|
5347 if ((i < 4) && userinfo->flags & AIM_FLAG_AOL)
|
|
5348 emblems[i++] = "aol";
|
|
5349 if ((i < 4) && userinfo->flags & AIM_FLAG_WIRELESS)
|
|
5350 emblems[i++] = "wireless";
|
|
5351 if ((i < 4) && userinfo->flags & AIM_FLAG_ACTIVEBUDDY)
|
|
5352 emblems[i++] = "activebuddy";
|
|
5353
|
|
5354 if ((i < 4) && (userinfo->capabilities & OSCAR_CAPABILITY_HIPTOP))
|
|
5355 emblems[i++] = "hiptop";
|
|
5356
|
|
5357 if ((i < 4) && (userinfo->capabilities & OSCAR_CAPABILITY_SECUREIM))
|
|
5358 emblems[i++] = "secure";
|
|
5359 }
|
|
5360
|
|
5361 *se = emblems[0];
|
|
5362 *sw = emblems[1];
|
|
5363 *nw = emblems[2];
|
|
5364 *ne = emblems[3];
|
|
5365 }
|
|
5366
|
|
5367 static void oscar_tooltip_text(GaimBuddy *b, GString *str, gboolean full) {
|
|
5368 GaimConnection *gc = b->account->gc;
|
|
5369 OscarData *od = gc->proto_data;
|
|
5370 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od, b->name);
|
|
5371
|
|
5372 if (GAIM_BUDDY_IS_ONLINE(b)) {
|
|
5373 GaimPresence *presence;
|
|
5374 GaimStatus *status;
|
|
5375 const char *message;
|
|
5376
|
|
5377 if (full)
|
|
5378 oscar_string_append_info(gc, str, "\n", b, userinfo);
|
|
5379
|
|
5380 presence = gaim_buddy_get_presence(b);
|
|
5381 status = gaim_presence_get_active_status(presence);
|
|
5382 message = gaim_status_get_attr_string(status, "message");
|
|
5383
|
|
5384 if (gaim_status_is_available(status))
|
|
5385 {
|
|
5386 if (message != NULL)
|
|
5387 {
|
|
5388 /* Available status messages are plain text */
|
|
5389 gchar *tmp;
|
|
5390 tmp = g_markup_escape_text(message, -1);
|
|
5391 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp);
|
|
5392 g_free(tmp);
|
|
5393 }
|
|
5394 }
|
|
5395 else
|
|
5396 {
|
|
5397 if (message != NULL)
|
|
5398 {
|
|
5399 /* Away messages are HTML */
|
|
5400 gchar *tmp1, *tmp2;
|
|
5401 tmp2 = gaim_markup_strip_html(message);
|
|
5402 tmp1 = g_markup_escape_text(tmp2, -1);
|
|
5403 g_free(tmp2);
|
|
5404 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc)));
|
|
5405 g_free(tmp1);
|
|
5406 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp2);
|
|
5407 g_free(tmp2);
|
|
5408 }
|
|
5409 else
|
|
5410 {
|
|
5411 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), _("<i>(retrieving)</i>"));
|
|
5412 }
|
|
5413 }
|
|
5414 }
|
|
5415 }
|
|
5416
|
|
5417 static char *oscar_status_text(GaimBuddy *b)
|
|
5418 {
|
|
5419 GaimConnection *gc;
|
|
5420 GaimAccount *account;
|
|
5421 OscarData *od;
|
|
5422 const GaimPresence *presence;
|
|
5423 const GaimStatus *status;
|
|
5424 const char *id;
|
|
5425 const char *message;
|
|
5426 gchar *ret = NULL;
|
|
5427
|
|
5428 gc = gaim_account_get_connection(gaim_buddy_get_account(b));
|
|
5429 account = gaim_connection_get_account(gc);
|
|
5430 od = gc->proto_data;
|
|
5431 presence = gaim_buddy_get_presence(b);
|
|
5432 status = gaim_presence_get_active_status(presence);
|
|
5433 id = gaim_status_get_id(status);
|
|
5434
|
|
5435 if (!gaim_presence_is_online(presence))
|
|
5436 {
|
|
5437 char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, b->name);
|
|
5438 if (aim_ssi_waitingforauth(od->ssi.local, gname, b->name))
|
|
5439 ret = g_strdup(_("Not Authorized"));
|
|
5440 else
|
|
5441 ret = g_strdup(_("Offline"));
|
|
5442 }
|
|
5443 else if (gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AVAILABLE))
|
|
5444 {
|
|
5445 /* Available */
|
|
5446 message = gaim_status_get_attr_string(status, "message");
|
|
5447 if (message != NULL)
|
|
5448 {
|
|
5449 ret = g_markup_escape_text(message, -1);
|
|
5450 gaim_util_chrreplace(ret, '\n', ' ');
|
|
5451 }
|
|
5452 }
|
|
5453 else if (!gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AWAY))
|
|
5454 {
|
|
5455 /* Away */
|
|
5456 message = gaim_status_get_attr_string(status, "message");
|
|
5457 if (message != NULL)
|
|
5458 {
|
|
5459 gchar *tmp1, *tmp2;
|
|
5460 tmp1 = gaim_markup_strip_html(message);
|
|
5461 gaim_util_chrreplace(tmp1, '\n', ' ');
|
|
5462 tmp2 = g_markup_escape_text(tmp1, -1);
|
|
5463 ret = gaim_str_sub_away_formatters(tmp2, gaim_account_get_username(account));
|
|
5464 g_free(tmp1);
|
|
5465 g_free(tmp2);
|
|
5466 }
|
|
5467 else
|
|
5468 {
|
|
5469 ret = g_strdup(_("Away"));
|
|
5470 }
|
|
5471 }
|
|
5472 else
|
|
5473 ret = g_strdup(gaim_status_get_name(status));
|
|
5474
|
|
5475 return ret;
|
|
5476 }
|
|
5477
|
|
5478
|
|
5479 static int oscar_icon_req(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
|
|
5480 GaimConnection *gc = od->gc;
|
|
5481 va_list ap;
|
|
5482 guint16 type;
|
|
5483 guint8 flags = 0, length = 0;
|
|
5484 guchar *md5 = NULL;
|
|
5485
|
|
5486 va_start(ap, fr);
|
|
5487 type = va_arg(ap, int);
|
|
5488
|
|
5489 switch(type) {
|
|
5490 case 0x0000:
|
|
5491 case 0x0001: {
|
|
5492 flags = va_arg(ap, int);
|
|
5493 length = va_arg(ap, int);
|
|
5494 md5 = va_arg(ap, guchar *);
|
|
5495
|
|
5496 if (flags == 0x41) {
|
|
5497 if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) {
|
|
5498 od->iconconnecting = TRUE;
|
|
5499 od->set_icon = TRUE;
|
|
5500 aim_reqservice(od, SNAC_FAMILY_BART);
|
|
5501 } else {
|
|
5502 struct stat st;
|
|
5503 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc)));
|
|
5504 if (iconfile == NULL) {
|
|
5505 aim_ssi_delicon(od);
|
|
5506 } else if (!g_stat(iconfile, &st)) {
|
|
5507 guchar *buf = g_malloc(st.st_size);
|
|
5508 FILE *file = g_fopen(iconfile, "rb");
|
|
5509 if (file) {
|
|
5510 /* XXX - Use g_file_get_contents()? */
|
|
5511 fread(buf, 1, st.st_size, file);
|
|
5512 fclose(file);
|
|
5513 gaim_debug_info("oscar",
|
|
5514 "Uploading icon to icon server\n");
|
|
5515 aim_bart_upload(od, buf, st.st_size);
|
|
5516 } else
|
|
5517 gaim_debug_error("oscar",
|
|
5518 "Can't open buddy icon file!\n");
|
|
5519 g_free(buf);
|
|
5520 } else {
|
|
5521 gaim_debug_error("oscar",
|
|
5522 "Can't stat buddy icon file!\n");
|
|
5523 }
|
|
5524 g_free(iconfile);
|
|
5525 }
|
|
5526 } else if (flags == 0x81) {
|
|
5527 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc)));
|
|
5528 if (iconfile == NULL)
|
|
5529 aim_ssi_delicon(od);
|
|
5530 else {
|
|
5531 aim_ssi_seticon(od, md5, length);
|
|
5532 g_free(iconfile);
|
|
5533 }
|
|
5534 }
|
|
5535 } break;
|
|
5536
|
|
5537 case 0x0002: { /* We just set an "available" message? */
|
|
5538 } break;
|
|
5539 }
|
|
5540
|
|
5541 va_end(ap);
|
|
5542
|
|
5543 return 0;
|
|
5544 }
|
|
5545
|
|
5546 static void oscar_set_permit_deny(GaimConnection *gc) {
|
|
5547 GaimAccount *account = gaim_connection_get_account(gc);
|
|
5548 OscarData *od = (OscarData *)gc->proto_data;
|
|
5549
|
|
5550 if (od->ssi.received_data) {
|
|
5551 switch (account->perm_deny) {
|
|
5552 case GAIM_PRIVACY_ALLOW_ALL:
|
|
5553 aim_ssi_setpermdeny(od, 0x01, 0xffffffff);
|
|
5554 break;
|
|
5555 case GAIM_PRIVACY_ALLOW_BUDDYLIST:
|
|
5556 aim_ssi_setpermdeny(od, 0x05, 0xffffffff);
|
|
5557 break;
|
|
5558 case GAIM_PRIVACY_ALLOW_USERS:
|
|
5559 aim_ssi_setpermdeny(od, 0x03, 0xffffffff);
|
|
5560 break;
|
|
5561 case GAIM_PRIVACY_DENY_ALL:
|
|
5562 aim_ssi_setpermdeny(od, 0x02, 0xffffffff);
|
|
5563 break;
|
|
5564 case GAIM_PRIVACY_DENY_USERS:
|
|
5565 aim_ssi_setpermdeny(od, 0x04, 0xffffffff);
|
|
5566 break;
|
|
5567 default:
|
|
5568 aim_ssi_setpermdeny(od, 0x01, 0xffffffff);
|
|
5569 break;
|
|
5570 }
|
|
5571 }
|
|
5572 }
|
|
5573
|
|
5574 static void oscar_add_permit(GaimConnection *gc, const char *who) {
|
|
5575 OscarData *od = (OscarData *)gc->proto_data;
|
|
5576 gaim_debug_info("oscar", "ssi: About to add a permit\n");
|
|
5577 if (od->ssi.received_data)
|
|
5578 aim_ssi_addpermit(od, who);
|
|
5579 }
|
|
5580
|
|
5581 static void oscar_add_deny(GaimConnection *gc, const char *who) {
|
|
5582 OscarData *od = (OscarData *)gc->proto_data;
|
|
5583 gaim_debug_info("oscar", "ssi: About to add a deny\n");
|
|
5584 if (od->ssi.received_data)
|
|
5585 aim_ssi_adddeny(od, who);
|
|
5586 }
|
|
5587
|
|
5588 static void oscar_rem_permit(GaimConnection *gc, const char *who) {
|
|
5589 OscarData *od = (OscarData *)gc->proto_data;
|
|
5590 gaim_debug_info("oscar", "ssi: About to delete a permit\n");
|
|
5591 if (od->ssi.received_data)
|
|
5592 aim_ssi_delpermit(od, who);
|
|
5593 }
|
|
5594
|
|
5595 static void oscar_rem_deny(GaimConnection *gc, const char *who) {
|
|
5596 OscarData *od = (OscarData *)gc->proto_data;
|
|
5597 gaim_debug_info("oscar", "ssi: About to delete a deny\n");
|
|
5598 if (od->ssi.received_data)
|
|
5599 aim_ssi_deldeny(od, who);
|
|
5600 }
|
|
5601
|
|
5602 static GList *
|
|
5603 oscar_status_types(GaimAccount *account)
|
|
5604 {
|
|
5605 gboolean is_icq;
|
|
5606 GList *status_types = NULL;
|
|
5607 GaimStatusType *type;
|
|
5608
|
|
5609 g_return_val_if_fail(account != NULL, NULL);
|
|
5610
|
|
5611 /* Used to flag some statuses as "user settable" or not */
|
|
5612 is_icq = aim_sn_is_icq(gaim_account_get_username(account));
|
|
5613
|
|
5614 /* Common status types */
|
|
5615 /* Really the available message should only be settable for AIM accounts */
|
|
5616 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE,
|
|
5617 OSCAR_STATUS_ID_AVAILABLE,
|
|
5618 NULL, TRUE, TRUE, FALSE,
|
|
5619 "message", _("Message"),
|
|
5620 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5621 status_types = g_list_prepend(status_types, type);
|
14192
|
5622
|
|
5623 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE,
|
|
5624 OSCAR_STATUS_ID_FREE4CHAT,
|
|
5625 _("Free For Chat"), TRUE, is_icq, FALSE);
|
14348
|
5626 status_types = g_list_prepend(status_types, type);
|
14192
|
5627
|
|
5628 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY,
|
|
5629 OSCAR_STATUS_ID_AWAY,
|
|
5630 NULL, TRUE, TRUE, FALSE,
|
|
5631 "message", _("Message"),
|
|
5632 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5633 status_types = g_list_prepend(status_types, type);
|
14192
|
5634
|
|
5635 type = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE,
|
|
5636 OSCAR_STATUS_ID_INVISIBLE,
|
|
5637 NULL, TRUE, TRUE, FALSE);
|
14348
|
5638 status_types = g_list_prepend(status_types, type);
|
14192
|
5639
|
|
5640 /* ICQ-specific status types */
|
|
5641 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE,
|
|
5642 OSCAR_STATUS_ID_OCCUPIED,
|
|
5643 _("Occupied"), TRUE, is_icq, FALSE,
|
|
5644 "message", _("Message"),
|
|
5645 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5646 status_types = g_list_prepend(status_types, type);
|
14192
|
5647
|
|
5648 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY,
|
|
5649 OSCAR_STATUS_ID_DND,
|
|
5650 _("Do Not Disturb"), TRUE, is_icq, FALSE,
|
|
5651 "message", _("Message"),
|
|
5652 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5653 status_types = g_list_prepend(status_types, type);
|
14192
|
5654
|
|
5655 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY,
|
|
5656 OSCAR_STATUS_ID_NA,
|
|
5657 _("Not Available"), TRUE, is_icq, FALSE,
|
|
5658 "message", _("Message"),
|
|
5659 gaim_value_new(GAIM_TYPE_STRING), NULL);
|
14348
|
5660 status_types = g_list_prepend(status_types, type);
|
14192
|
5661
|
|
5662 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE,
|
|
5663 OSCAR_STATUS_ID_OFFLINE,
|
|
5664 NULL, TRUE, TRUE, FALSE);
|
14348
|
5665 status_types = g_list_prepend(status_types, type);
|
|
5666
|
|
5667 status_types = g_list_reverse(status_types);
|
14192
|
5668
|
|
5669 return status_types;
|
|
5670 }
|
|
5671
|
|
5672 static void oscar_ssi_editcomment(struct name_data *data, const char *text) {
|
|
5673 GaimConnection *gc = data->gc;
|
|
5674 OscarData *od = gc->proto_data;
|
|
5675 GaimBuddy *b;
|
|
5676 GaimGroup *g;
|
|
5677
|
|
5678 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) {
|
|
5679 oscar_free_name_data(data);
|
|
5680 return;
|
|
5681 }
|
|
5682
|
|
5683 if (!(g = gaim_buddy_get_group(b))) {
|
|
5684 oscar_free_name_data(data);
|
|
5685 return;
|
|
5686 }
|
|
5687
|
|
5688 aim_ssi_editcomment(od, g->name, data->name, text);
|
|
5689
|
|
5690 if (!aim_sncmp(data->name, gc->account->username))
|
|
5691 gaim_check_comment(od, text);
|
|
5692
|
|
5693 oscar_free_name_data(data);
|
|
5694 }
|
|
5695
|
|
5696 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) {
|
|
5697
|
|
5698 GaimBuddy *buddy;
|
|
5699 GaimConnection *gc;
|
|
5700 OscarData *od;
|
|
5701 struct name_data *data;
|
|
5702 GaimGroup *g;
|
|
5703 char *comment;
|
|
5704 gchar *comment_utf8;
|
|
5705 gchar *title;
|
|
5706
|
|
5707 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
5708
|
|
5709 buddy = (GaimBuddy *) node;
|
|
5710 gc = gaim_account_get_connection(buddy->account);
|
|
5711 od = gc->proto_data;
|
|
5712
|
|
5713 data = g_new(struct name_data, 1);
|
|
5714
|
|
5715 if (!(g = gaim_buddy_get_group(buddy)))
|
|
5716 return;
|
|
5717 comment = aim_ssi_getcomment(od->ssi.local, g->name, buddy->name);
|
|
5718 comment_utf8 = comment ? oscar_utf8_try_convert(gc->account, comment) : NULL;
|
|
5719
|
|
5720 data->gc = gc;
|
|
5721 data->name = g_strdup(buddy->name);
|
|
5722 data->nick = NULL;
|
|
5723
|
|
5724 title = g_strdup_printf(_("Buddy Comment for %s"), data->name);
|
|
5725 gaim_request_input(gc, title, _("Buddy Comment:"), NULL,
|
|
5726 comment_utf8, TRUE, FALSE, NULL,
|
|
5727 _("OK"), G_CALLBACK(oscar_ssi_editcomment),
|
|
5728 _("Cancel"), G_CALLBACK(oscar_free_name_data),
|
|
5729 data);
|
|
5730 g_free(title);
|
|
5731
|
|
5732 g_free(comment);
|
|
5733 g_free(comment_utf8);
|
|
5734 }
|
|
5735
|
|
5736 static void
|
|
5737 oscar_ask_directim_yes_cb(struct oscar_ask_directim_data *data)
|
|
5738 {
|
|
5739 peer_connection_propose(data->od, OSCAR_CAPABILITY_DIRECTIM, data->who);
|
|
5740 g_free(data->who);
|
|
5741 g_free(data);
|
|
5742 }
|
|
5743
|
|
5744 static void
|
|
5745 oscar_ask_directim_no_cb(struct oscar_ask_directim_data *data)
|
|
5746 {
|
|
5747 g_free(data->who);
|
|
5748 g_free(data);
|
|
5749 }
|
|
5750
|
|
5751 /* This is called from right-click menu on a buddy node. */
|
|
5752 static void
|
|
5753 oscar_ask_directim(gpointer object, gpointer ignored)
|
|
5754 {
|
|
5755 GaimBlistNode *node;
|
|
5756 GaimBuddy *buddy;
|
|
5757 GaimConnection *gc;
|
|
5758 gchar *buf;
|
|
5759 struct oscar_ask_directim_data *data;
|
|
5760
|
|
5761 node = object;
|
|
5762
|
|
5763 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
5764
|
|
5765 buddy = (GaimBuddy *)node;
|
|
5766 gc = gaim_account_get_connection(buddy->account);
|
|
5767
|
|
5768 data = g_new0(struct oscar_ask_directim_data, 1);
|
|
5769 data->who = g_strdup(buddy->name);
|
|
5770 data->od = gc->proto_data;
|
|
5771 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."),
|
|
5772 buddy->name);
|
|
5773
|
|
5774 gaim_request_action(gc, NULL, buf,
|
|
5775 _("Because this reveals your IP address, it "
|
|
5776 "may be considered a security risk. Do you "
|
|
5777 "wish to continue?"),
|
|
5778 0, data, 2,
|
|
5779 _("_Connect"), G_CALLBACK(oscar_ask_directim_yes_cb),
|
|
5780 _("Cancel"), G_CALLBACK(oscar_ask_directim_no_cb));
|
|
5781 g_free(buf);
|
|
5782 }
|
|
5783
|
|
5784 static void
|
|
5785 oscar_get_aim_info_cb(GaimBlistNode *node, gpointer ignore)
|
|
5786 {
|
|
5787 GaimBuddy *buddy;
|
|
5788 GaimConnection *gc;
|
|
5789
|
|
5790 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
5791
|
|
5792 buddy = (GaimBuddy *)node;
|
|
5793 gc = gaim_account_get_connection(buddy->account);
|
|
5794
|
|
5795 aim_locate_getinfoshort(gc->proto_data, gaim_buddy_get_name(buddy), 0x00000003);
|
|
5796 }
|
|
5797
|
|
5798 static GList *oscar_buddy_menu(GaimBuddy *buddy) {
|
|
5799
|
|
5800 GaimConnection *gc;
|
|
5801 OscarData *od;
|
14348
|
5802 GList *menu;
|
14192
|
5803 GaimMenuAction *act;
|
|
5804 aim_userinfo_t *userinfo;
|
|
5805
|
|
5806 gc = gaim_account_get_connection(buddy->account);
|
|
5807 od = gc->proto_data;
|
|
5808 userinfo = aim_locate_finduserinfo(od, buddy->name);
|
14348
|
5809 menu = NULL;
|
14192
|
5810
|
|
5811 if (od->icq && aim_sn_is_icq(gaim_buddy_get_name(buddy)))
|
|
5812 {
|
|
5813 act = gaim_menu_action_new(_("Get AIM Info"),
|
|
5814 GAIM_CALLBACK(oscar_get_aim_info_cb),
|
|
5815 NULL, NULL);
|
14348
|
5816 menu = g_list_prepend(menu, act);
|
14192
|
5817 }
|
|
5818
|
|
5819 act = gaim_menu_action_new(_("Edit Buddy Comment"),
|
|
5820 GAIM_CALLBACK(oscar_buddycb_edit_comment),
|
|
5821 NULL, NULL);
|
14348
|
5822 menu = g_list_prepend(menu, act);
|
14192
|
5823
|
|
5824 #if 0
|
|
5825 if (od->icq)
|
|
5826 {
|
|
5827 act = gaim_menu_action_new(_("Get Status Msg"),
|
|
5828 GAIM_CALLBACK(oscar_get_icqstatusmsg),
|
|
5829 NULL, NULL);
|
14348
|
5830 menu = g_list_prepend(menu, act);
|
14192
|
5831 }
|
|
5832 #endif
|
|
5833
|
|
5834 if (userinfo &&
|
|
5835 aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) &&
|
|
5836 GAIM_BUDDY_IS_ONLINE(buddy))
|
|
5837 {
|
|
5838 if (userinfo->capabilities & OSCAR_CAPABILITY_DIRECTIM)
|
|
5839 {
|
|
5840 act = gaim_menu_action_new(_("Direct IM"),
|
|
5841 GAIM_CALLBACK(oscar_ask_directim),
|
|
5842 NULL, NULL);
|
14348
|
5843 menu = g_list_prepend(menu, act);
|
14192
|
5844 }
|
|
5845 #if 0
|
|
5846 /* TODO: This menu item should be added by the core */
|
|
5847 if (userinfo->capabilities & OSCAR_CAPABILITY_GETFILE) {
|
|
5848 act = gaim_menu_action_new(_("Get File"),
|
|
5849 GAIM_CALLBACK(oscar_ask_getfile),
|
|
5850 NULL, NULL);
|
14348
|
5851 menu = g_list_prepend(menu, act);
|
14192
|
5852 }
|
|
5853 #endif
|
|
5854 }
|
|
5855
|
|
5856 if (od->ssi.received_data)
|
|
5857 {
|
|
5858 char *gname;
|
|
5859 gname = aim_ssi_itemlist_findparentname(od->ssi.local, buddy->name);
|
|
5860 if (gname && aim_ssi_waitingforauth(od->ssi.local, gname, buddy->name))
|
|
5861 {
|
|
5862 act = gaim_menu_action_new(_("Re-request Authorization"),
|
|
5863 GAIM_CALLBACK(gaim_auth_sendrequest_menu),
|
|
5864 NULL, NULL);
|
14348
|
5865 menu = g_list_prepend(menu, act);
|
14192
|
5866 }
|
|
5867 }
|
|
5868
|
14348
|
5869 menu = g_list_reverse(menu);
|
|
5870
|
|
5871 return menu;
|
14192
|
5872 }
|
|
5873
|
|
5874
|
|
5875 static GList *oscar_blist_node_menu(GaimBlistNode *node) {
|
|
5876 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
|
|
5877 return oscar_buddy_menu((GaimBuddy *) node);
|
|
5878 } else {
|
|
5879 return NULL;
|
|
5880 }
|
|
5881 }
|
|
5882
|
|
5883 static void
|
|
5884 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields)
|
|
5885 {
|
|
5886 OscarData *od = gc->proto_data;
|
|
5887 GaimAccount *account = gaim_connection_get_account(gc);
|
|
5888 GaimRequestField *f;
|
|
5889 gboolean auth, web_aware;
|
|
5890
|
|
5891 f = gaim_request_fields_get_field(fields, "authorization");
|
|
5892 auth = gaim_request_field_bool_get_value(f);
|
|
5893
|
|
5894 f = gaim_request_fields_get_field(fields, "web_aware");
|
|
5895 web_aware = gaim_request_field_bool_get_value(f);
|
|
5896
|
|
5897 gaim_account_set_bool(account, "authorization", auth);
|
|
5898 gaim_account_set_bool(account, "web_aware", web_aware);
|
|
5899
|
|
5900 oscar_set_extendedstatus(gc);
|
|
5901 aim_icq_setsecurity(od, auth, web_aware);
|
|
5902 }
|
|
5903
|
|
5904 static void
|
|
5905 oscar_show_icq_privacy_opts(GaimPluginAction *action)
|
|
5906 {
|
|
5907 GaimConnection *gc = (GaimConnection *) action->context;
|
|
5908 GaimAccount *account = gaim_connection_get_account(gc);
|
|
5909 GaimRequestFields *fields;
|
|
5910 GaimRequestFieldGroup *g;
|
|
5911 GaimRequestField *f;
|
|
5912 gboolean auth, web_aware;
|
|
5913
|
|
5914 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION);
|
|
5915 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE);
|
|
5916
|
|
5917 fields = gaim_request_fields_new();
|
|
5918
|
|
5919 g = gaim_request_field_group_new(NULL);
|
|
5920
|
|
5921 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth);
|
|
5922 gaim_request_field_group_add_field(g, f);
|
|
5923
|
|
5924 f = gaim_request_field_bool_new("web_aware", _("Web aware (enabling this will cause you to receive SPAM!)"), web_aware);
|
|
5925 gaim_request_field_group_add_field(g, f);
|
|
5926
|
|
5927 gaim_request_fields_add_group(fields, g);
|
|
5928
|
|
5929 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"),
|
|
5930 NULL, fields,
|
|
5931 _("OK"), G_CALLBACK(oscar_icq_privacy_opts),
|
|
5932 _("Cancel"), NULL, gc);
|
|
5933 }
|
|
5934
|
|
5935 static void oscar_format_screenname(GaimConnection *gc, const char *nick) {
|
|
5936 OscarData *od = gc->proto_data;
|
|
5937 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) {
|
|
5938 if (!flap_connection_getbytype(od, SNAC_FAMILY_ADMIN)) {
|
|
5939 od->setnick = TRUE;
|
|
5940 od->newsn = g_strdup(nick);
|
|
5941 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
5942 } else {
|
|
5943 aim_admin_setnick(od, flap_connection_getbytype(od, SNAC_FAMILY_ADMIN), nick);
|
|
5944 }
|
|
5945 } else {
|
|
5946 gaim_notify_error(gc, NULL, _("The new formatting is invalid."),
|
|
5947 _("Screen name formatting can change only capitalization and whitespace."));
|
|
5948 }
|
|
5949 }
|
|
5950
|
|
5951 static void oscar_show_format_screenname(GaimPluginAction *action)
|
|
5952 {
|
|
5953 GaimConnection *gc = (GaimConnection *) action->context;
|
|
5954 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL,
|
|
5955 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL,
|
|
5956 _("OK"), G_CALLBACK(oscar_format_screenname),
|
|
5957 _("Cancel"), NULL,
|
|
5958 gc);
|
|
5959 }
|
|
5960
|
|
5961 static void oscar_confirm_account(GaimPluginAction *action)
|
|
5962 {
|
|
5963 GaimConnection *gc;
|
|
5964 OscarData *od;
|
|
5965 FlapConnection *conn;
|
|
5966
|
|
5967 gc = (GaimConnection *)action->context;
|
|
5968 od = gc->proto_data;
|
|
5969
|
|
5970 conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
|
|
5971 if (conn != NULL) {
|
|
5972 aim_admin_reqconfirm(od, conn);
|
|
5973 } else {
|
|
5974 od->conf = TRUE;
|
|
5975 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
5976 }
|
|
5977 }
|
|
5978
|
|
5979 static void oscar_show_email(GaimPluginAction *action)
|
|
5980 {
|
|
5981 GaimConnection *gc = (GaimConnection *) action->context;
|
|
5982 OscarData *od = gc->proto_data;
|
|
5983 FlapConnection *conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
|
|
5984
|
|
5985 if (conn) {
|
|
5986 aim_admin_getinfo(od, conn, 0x11);
|
|
5987 } else {
|
|
5988 od->reqemail = TRUE;
|
|
5989 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
5990 }
|
|
5991 }
|
|
5992
|
|
5993 static void oscar_change_email(GaimConnection *gc, const char *email)
|
|
5994 {
|
|
5995 OscarData *od = gc->proto_data;
|
|
5996 FlapConnection *conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
|
|
5997
|
|
5998 if (conn) {
|
|
5999 aim_admin_setemail(od, conn, email);
|
|
6000 } else {
|
|
6001 od->setemail = TRUE;
|
|
6002 od->email = g_strdup(email);
|
|
6003 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
6004 }
|
|
6005 }
|
|
6006
|
|
6007 static void oscar_show_change_email(GaimPluginAction *action)
|
|
6008 {
|
|
6009 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6010 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL,
|
|
6011 FALSE, FALSE, NULL,
|
|
6012 _("OK"), G_CALLBACK(oscar_change_email),
|
|
6013 _("Cancel"), NULL,
|
|
6014 gc);
|
|
6015 }
|
|
6016
|
|
6017 static void oscar_show_awaitingauth(GaimPluginAction *action)
|
|
6018 {
|
|
6019 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6020 OscarData *od = gc->proto_data;
|
|
6021 gchar *nombre, *text, *tmp;
|
|
6022 GaimBlistNode *gnode, *cnode, *bnode;
|
|
6023 int num=0;
|
|
6024
|
|
6025 text = g_strdup("");
|
|
6026
|
|
6027 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
|
|
6028 GaimGroup *group = (GaimGroup *)gnode;
|
|
6029 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
|
|
6030 continue;
|
|
6031 for (cnode = gnode->child; cnode; cnode = cnode->next) {
|
|
6032 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))
|
|
6033 continue;
|
|
6034 for (bnode = cnode->child; bnode; bnode = bnode->next) {
|
|
6035 GaimBuddy *buddy = (GaimBuddy *)bnode;
|
|
6036 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
|
|
6037 continue;
|
|
6038 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->ssi.local, group->name, buddy->name)) {
|
|
6039 if (gaim_buddy_get_alias_only(buddy))
|
|
6040 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy));
|
|
6041 else
|
|
6042 nombre = g_strdup_printf(" %s", buddy->name);
|
|
6043 tmp = g_strdup_printf("%s%s<br>", text, nombre);
|
|
6044 g_free(text);
|
|
6045 text = tmp;
|
|
6046 g_free(nombre);
|
|
6047 num++;
|
|
6048 }
|
|
6049 }
|
|
6050 }
|
|
6051 }
|
|
6052
|
|
6053 if (!num) {
|
|
6054 g_free(text);
|
|
6055 text = g_strdup(_("<i>you are not waiting for authorization</i>"));
|
|
6056 }
|
|
6057
|
|
6058 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from "
|
|
6059 "the following buddies"), _("You can re-request "
|
|
6060 "authorization from these buddies by "
|
|
6061 "right-clicking on them and selecting "
|
|
6062 "\"Re-request Authorization.\""), text, NULL, NULL);
|
|
6063 g_free(text);
|
|
6064 }
|
|
6065
|
|
6066 static void search_by_email_cb(GaimConnection *gc, const char *email)
|
|
6067 {
|
|
6068 OscarData *od = (OscarData *)gc->proto_data;
|
|
6069
|
|
6070 aim_search_address(od, email);
|
|
6071 }
|
|
6072
|
|
6073 static void oscar_show_find_email(GaimPluginAction *action)
|
|
6074 {
|
|
6075 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6076 gaim_request_input(gc, _("Find Buddy by E-Mail"),
|
|
6077 _("Search for a buddy by e-mail address"),
|
|
6078 _("Type the e-mail address of the buddy you are "
|
|
6079 "searching for."),
|
|
6080 NULL, FALSE, FALSE, NULL,
|
|
6081 _("Search"), G_CALLBACK(search_by_email_cb),
|
|
6082 _("Cancel"), NULL, gc);
|
|
6083 }
|
|
6084
|
|
6085 static void oscar_show_set_info(GaimPluginAction *action)
|
|
6086 {
|
|
6087 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6088 gaim_account_request_change_user_info(gaim_connection_get_account(gc));
|
|
6089 }
|
|
6090
|
|
6091 static void oscar_show_set_info_icqurl(GaimPluginAction *action)
|
|
6092 {
|
|
6093 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6094 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php");
|
|
6095 }
|
|
6096
|
|
6097 static void oscar_change_pass(GaimPluginAction *action)
|
|
6098 {
|
|
6099 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6100 gaim_account_request_change_password(gaim_connection_get_account(gc));
|
|
6101 }
|
|
6102
|
|
6103 static void oscar_show_chpassurl(GaimPluginAction *action)
|
|
6104 {
|
|
6105 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6106 OscarData *od = gc->proto_data;
|
|
6107 gchar *substituted = gaim_strreplace(od->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc)));
|
|
6108 gaim_notify_uri(gc, substituted);
|
|
6109 g_free(substituted);
|
|
6110 }
|
|
6111
|
|
6112 static void oscar_show_imforwardingurl(GaimPluginAction *action)
|
|
6113 {
|
|
6114 GaimConnection *gc = (GaimConnection *) action->context;
|
|
6115 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1");
|
|
6116 }
|
|
6117
|
|
6118 static void oscar_set_icon(GaimConnection *gc, const char *iconfile)
|
|
6119 {
|
|
6120 OscarData *od = gc->proto_data;
|
|
6121 FILE *file;
|
|
6122 struct stat st;
|
|
6123
|
|
6124 if (iconfile == NULL) {
|
|
6125 aim_ssi_delicon(od);
|
|
6126 } else if (!g_stat(iconfile, &st)) {
|
|
6127 guchar *buf = g_malloc(st.st_size);
|
|
6128 file = g_fopen(iconfile, "rb");
|
|
6129 if (file)
|
|
6130 {
|
|
6131 GaimCipher *cipher;
|
|
6132 GaimCipherContext *context;
|
|
6133 guchar md5[16];
|
|
6134 int len;
|
|
6135
|
|
6136 /* XXX - Use g_file_get_contents()? */
|
|
6137 len = fread(buf, 1, st.st_size, file);
|
|
6138 fclose(file);
|
|
6139
|
|
6140 cipher = gaim_ciphers_find_cipher("md5");
|
|
6141 context = gaim_cipher_context_new(cipher, NULL);
|
|
6142 gaim_cipher_context_append(context, buf, len);
|
|
6143 gaim_cipher_context_digest(context, 16, md5, NULL);
|
|
6144 gaim_cipher_context_destroy(context);
|
|
6145
|
|
6146 aim_ssi_seticon(od, md5, 16);
|
|
6147 } else
|
|
6148 gaim_debug_error("oscar",
|
|
6149 "Can't open buddy icon file!\n");
|
|
6150 g_free(buf);
|
|
6151 } else
|
|
6152 gaim_debug_error("oscar", "Can't stat buddy icon file!\n");
|
|
6153 }
|
|
6154
|
|
6155 /**
|
|
6156 * Called by the Gaim core to determine whether or not we're
|
|
6157 * allowed to send a file to this user.
|
|
6158 */
|
|
6159 static gboolean
|
|
6160 oscar_can_receive_file(GaimConnection *gc, const char *who)
|
|
6161 {
|
|
6162 OscarData *od;
|
|
6163 GaimAccount *account;
|
|
6164
|
|
6165 od = gc->proto_data;
|
|
6166 account = gaim_connection_get_account(gc);
|
|
6167
|
|
6168 if (od != NULL)
|
|
6169 {
|
|
6170 aim_userinfo_t *userinfo;
|
|
6171 userinfo = aim_locate_finduserinfo(od, who);
|
|
6172
|
|
6173 /*
|
|
6174 * Don't allowing sending a file to a user that does not support
|
|
6175 * file transfer, and don't allow sending to ourselves.
|
|
6176 */
|
|
6177 if (((userinfo == NULL) ||
|
|
6178 (userinfo->capabilities & OSCAR_CAPABILITY_SENDFILE)) &&
|
|
6179 aim_sncmp(who, gaim_account_get_username(account)))
|
|
6180 {
|
|
6181 return TRUE;
|
|
6182 }
|
|
6183 }
|
|
6184
|
|
6185 return FALSE;
|
|
6186 }
|
|
6187
|
|
6188 static GaimXfer *
|
|
6189 oscar_new_xfer(GaimConnection *gc, const char *who)
|
|
6190 {
|
|
6191 GaimXfer *xfer;
|
|
6192 OscarData *od;
|
|
6193 GaimAccount *account;
|
|
6194 PeerConnection *conn;
|
|
6195
|
|
6196 od = gc->proto_data;
|
|
6197 account = gaim_connection_get_account(gc);
|
|
6198
|
|
6199 xfer = gaim_xfer_new(account, GAIM_XFER_SEND, who);
|
|
6200 gaim_xfer_ref(xfer);
|
|
6201 gaim_xfer_set_init_fnc(xfer, peer_oft_sendcb_init);
|
|
6202 gaim_xfer_set_cancel_send_fnc(xfer, peer_oft_cb_generic_cancel);
|
|
6203 gaim_xfer_set_request_denied_fnc(xfer, peer_oft_cb_generic_cancel);
|
|
6204 gaim_xfer_set_ack_fnc(xfer, peer_oft_sendcb_ack);
|
|
6205
|
|
6206 conn = peer_connection_new(od, OSCAR_CAPABILITY_SENDFILE, who);
|
|
6207 conn->flags |= PEER_CONNECTION_FLAG_INITIATED_BY_ME;
|
|
6208 conn->flags |= PEER_CONNECTION_FLAG_APPROVED;
|
|
6209 aim_icbm_makecookie(conn->cookie);
|
|
6210 conn->xfer = xfer;
|
|
6211 xfer->data = conn;
|
|
6212
|
|
6213 return xfer;
|
|
6214 }
|
|
6215
|
|
6216 /*
|
|
6217 * Called by the Gaim core when the user indicates that a
|
|
6218 * file is to be sent to a special someone.
|
|
6219 */
|
|
6220 static void
|
|
6221 oscar_send_file(GaimConnection *gc, const char *who, const char *file)
|
|
6222 {
|
|
6223 GaimXfer *xfer;
|
|
6224
|
|
6225 xfer = oscar_new_xfer(gc, who);
|
|
6226
|
|
6227 if (file != NULL)
|
|
6228 gaim_xfer_request_accepted(xfer, file);
|
|
6229 else
|
|
6230 gaim_xfer_request(xfer);
|
|
6231 }
|
|
6232
|
|
6233 static GList *
|
|
6234 oscar_actions(GaimPlugin *plugin, gpointer context)
|
|
6235 {
|
|
6236 GaimConnection *gc = (GaimConnection *) context;
|
|
6237 OscarData *od = gc->proto_data;
|
14348
|
6238 GList *menu = NULL;
|
14192
|
6239 GaimPluginAction *act;
|
|
6240
|
|
6241 act = gaim_plugin_action_new(_("Set User Info..."),
|
|
6242 oscar_show_set_info);
|
14348
|
6243 menu = g_list_prepend(menu, act);
|
14192
|
6244
|
|
6245 if (od->icq)
|
|
6246 {
|
|
6247 act = gaim_plugin_action_new(_("Set User Info (URL)..."),
|
|
6248 oscar_show_set_info_icqurl);
|
14348
|
6249 menu = g_list_prepend(menu, act);
|
14192
|
6250 }
|
|
6251
|
|
6252 act = gaim_plugin_action_new(_("Change Password..."),
|
|
6253 oscar_change_pass);
|
14348
|
6254 menu = g_list_prepend(menu, act);
|
14192
|
6255
|
|
6256 if (od->authinfo->chpassurl != NULL)
|
|
6257 {
|
|
6258 act = gaim_plugin_action_new(_("Change Password (URL)"),
|
|
6259 oscar_show_chpassurl);
|
14348
|
6260 menu = g_list_prepend(menu, act);
|
14192
|
6261
|
|
6262 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"),
|
|
6263 oscar_show_imforwardingurl);
|
14348
|
6264 menu = g_list_prepend(menu, act);
|
|
6265 }
|
|
6266
|
|
6267 menu = g_list_prepend(menu, NULL);
|
14192
|
6268
|
|
6269 if (od->icq)
|
|
6270 {
|
|
6271 /* ICQ actions */
|
|
6272 act = gaim_plugin_action_new(_("Set Privacy Options..."),
|
|
6273 oscar_show_icq_privacy_opts);
|
14348
|
6274 menu = g_list_prepend(menu, act);
|
14192
|
6275 }
|
|
6276 else
|
|
6277 {
|
|
6278 /* AIM actions */
|
|
6279 act = gaim_plugin_action_new(_("Format Screen Name..."),
|
|
6280 oscar_show_format_screenname);
|
14348
|
6281 menu = g_list_prepend(menu, act);
|
14192
|
6282
|
|
6283 act = gaim_plugin_action_new(_("Confirm Account"),
|
|
6284 oscar_confirm_account);
|
14348
|
6285 menu = g_list_prepend(menu, act);
|
14192
|
6286
|
|
6287 act = gaim_plugin_action_new(_("Display Currently Registered E-Mail Address"),
|
|
6288 oscar_show_email);
|
14348
|
6289 menu = g_list_prepend(menu, act);
|
14192
|
6290
|
|
6291 act = gaim_plugin_action_new(_("Change Currently Registered E-Mail Address..."),
|
|
6292 oscar_show_change_email);
|
14348
|
6293 menu = g_list_prepend(menu, act);
|
|
6294 }
|
|
6295
|
|
6296 menu = g_list_prepend(menu, NULL);
|
14192
|
6297
|
|
6298 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"),
|
|
6299 oscar_show_awaitingauth);
|
14348
|
6300 menu = g_list_prepend(menu, act);
|
|
6301
|
|
6302 menu = g_list_prepend(menu, NULL);
|
14192
|
6303
|
|
6304 act = gaim_plugin_action_new(_("Search for Buddy by E-Mail Address..."),
|
|
6305 oscar_show_find_email);
|
14348
|
6306 menu = g_list_prepend(menu, act);
|
14192
|
6307
|
|
6308 #if 0
|
|
6309 act = gaim_plugin_action_new(_("Search for Buddy by Information"),
|
|
6310 show_find_info);
|
14348
|
6311 menu = g_list_prepend(menu, act);
|
14192
|
6312 #endif
|
|
6313
|
14348
|
6314 menu = g_list_reverse(menu);
|
|
6315
|
|
6316 return menu;
|
14192
|
6317 }
|
|
6318
|
|
6319 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new)
|
|
6320 {
|
|
6321 OscarData *od = gc->proto_data;
|
|
6322
|
|
6323 if (od->icq) {
|
|
6324 aim_icq_changepasswd(od, new);
|
|
6325 } else {
|
|
6326 FlapConnection *conn;
|
|
6327 conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
|
|
6328 if (conn) {
|
|
6329 aim_admin_changepasswd(od, conn, new, old);
|
|
6330 } else {
|
|
6331 od->chpass = TRUE;
|
|
6332 od->oldp = g_strdup(old);
|
|
6333 od->newp = g_strdup(new);
|
|
6334 aim_reqservice(od, SNAC_FAMILY_ADMIN);
|
|
6335 }
|
|
6336 }
|
|
6337 }
|
|
6338
|
|
6339 static void
|
|
6340 oscar_convo_closed(GaimConnection *gc, const char *who)
|
|
6341 {
|
|
6342 OscarData *od;
|
|
6343 PeerConnection *conn;
|
|
6344
|
|
6345 od = gc->proto_data;
|
|
6346 conn = peer_connection_find_by_type(od, who, OSCAR_CAPABILITY_DIRECTIM);
|
|
6347
|
|
6348 if (conn != NULL)
|
|
6349 {
|
|
6350 if (!conn->ready)
|
|
6351 aim_im_sendch2_cancel(conn);
|
|
6352
|
14402
|
6353 peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL);
|
14192
|
6354 }
|
|
6355 }
|
|
6356
|
|
6357 static void
|
|
6358 recent_buddies_cb(const char *name, GaimPrefType type,
|
|
6359 gconstpointer value, gpointer data)
|
|
6360 {
|
|
6361 GaimConnection *gc = data;
|
|
6362 OscarData *od = gc->proto_data;
|
|
6363 guint32 presence;
|
|
6364
|
|
6365 presence = aim_ssi_getpresence(od->ssi.local);
|
|
6366
|
|
6367 if (value) {
|
|
6368 presence &= ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES;
|
|
6369 aim_ssi_setpresence(od, presence);
|
|
6370 } else {
|
|
6371 presence |= AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES;
|
|
6372 aim_ssi_setpresence(od, presence);
|
|
6373 }
|
|
6374 }
|
|
6375
|
|
6376 #ifdef USE_PRPL_PREFERENCES
|
|
6377 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group"));
|
|
6378 gaim_plugin_pref_frame_add(frame, ppref);
|
|
6379
|
|
6380 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle"));
|
|
6381 gaim_plugin_pref_frame_add(frame, ppref);
|
|
6382 #endif
|
|
6383
|
|
6384 static const char *
|
|
6385 oscar_normalize(const GaimAccount *account, const char *str)
|
|
6386 {
|
|
6387 static char buf[BUF_LEN];
|
|
6388 char *tmp1, *tmp2;
|
|
6389 int i, j;
|
|
6390
|
|
6391 g_return_val_if_fail(str != NULL, NULL);
|
|
6392
|
|
6393 strncpy(buf, str, BUF_LEN);
|
|
6394 for (i=0, j=0; buf[j]; i++, j++)
|
|
6395 {
|
|
6396 while (buf[j] == ' ')
|
|
6397 j++;
|
|
6398 buf[i] = buf[j];
|
|
6399 }
|
|
6400 buf[i] = '\0';
|
|
6401
|
|
6402 tmp1 = g_utf8_strdown(buf, -1);
|
|
6403 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT);
|
|
6404 g_snprintf(buf, sizeof(buf), "%s", tmp2);
|
|
6405 g_free(tmp2);
|
|
6406 g_free(tmp1);
|
|
6407
|
|
6408 return buf;
|
|
6409 }
|
|
6410
|
|
6411 static gboolean
|
|
6412 oscar_offline_message(const GaimBuddy *buddy)
|
|
6413 {
|
|
6414 OscarData *od;
|
|
6415 GaimAccount *account;
|
|
6416 GaimConnection *gc;
|
|
6417
|
|
6418 account = gaim_buddy_get_account(buddy);
|
|
6419 gc = gaim_account_get_connection(account);
|
|
6420 od = (OscarData *)gc->proto_data;
|
|
6421
|
|
6422 return (od->icq && aim_sn_is_icq(gaim_account_get_username(account)));
|
|
6423 }
|
|
6424
|
|
6425 static GaimPluginProtocolInfo prpl_info =
|
|
6426 {
|
|
6427 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE,
|
|
6428 NULL, /* user_splits */
|
|
6429 NULL, /* protocol_options */
|
14413
|
6430 {"gif,jpg,bmp,ico", 48, 48, 50, 50,
|
14192
|
6431 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */
|
|
6432 oscar_list_icon, /* list_icon */
|
|
6433 oscar_list_emblems, /* list_emblems */
|
|
6434 oscar_status_text, /* status_text */
|
|
6435 oscar_tooltip_text, /* tooltip_text */
|
|
6436 oscar_status_types, /* status_types */
|
|
6437 oscar_blist_node_menu, /* blist_node_menu */
|
|
6438 oscar_chat_info, /* chat_info */
|
|
6439 oscar_chat_info_defaults, /* chat_info_defaults */
|
|
6440 oscar_login, /* login */
|
|
6441 oscar_close, /* close */
|
|
6442 oscar_send_im, /* send_im */
|
|
6443 oscar_set_info, /* set_info */
|
|
6444 oscar_send_typing, /* send_typing */
|
|
6445 oscar_get_info, /* get_info */
|
|
6446 oscar_set_status, /* set_status */
|
|
6447 oscar_set_idle, /* set_idle */
|
|
6448 oscar_change_passwd, /* change_passwd */
|
|
6449 oscar_add_buddy, /* add_buddy */
|
|
6450 NULL, /* add_buddies */
|
|
6451 oscar_remove_buddy, /* remove_buddy */
|
|
6452 NULL, /* remove_buddies */
|
|
6453 oscar_add_permit, /* add_permit */
|
|
6454 oscar_add_deny, /* add_deny */
|
|
6455 oscar_rem_permit, /* rem_permit */
|
|
6456 oscar_rem_deny, /* rem_deny */
|
|
6457 oscar_set_permit_deny, /* set_permit_deny */
|
|
6458 oscar_join_chat, /* join_chat */
|
|
6459 NULL, /* reject_chat */
|
|
6460 oscar_get_chat_name, /* get_chat_name */
|
|
6461 oscar_chat_invite, /* chat_invite */
|
|
6462 oscar_chat_leave, /* chat_leave */
|
|
6463 NULL, /* chat_whisper */
|
|
6464 oscar_send_chat, /* chat_send */
|
|
6465 oscar_keepalive, /* keepalive */
|
|
6466 NULL, /* register_user */
|
|
6467 NULL, /* get_cb_info */
|
|
6468 NULL, /* get_cb_away */
|
|
6469 oscar_alias_buddy, /* alias_buddy */
|
|
6470 oscar_move_buddy, /* group_buddy */
|
|
6471 oscar_rename_group, /* rename_group */
|
|
6472 NULL, /* buddy_free */
|
|
6473 oscar_convo_closed, /* convo_closed */
|
|
6474 oscar_normalize, /* normalize */
|
|
6475 oscar_set_icon, /* set_buddy_icon */
|
|
6476 NULL, /* remove_group */
|
|
6477 NULL, /* get_cb_real_name */
|
|
6478 NULL, /* set_chat_topic */
|
|
6479 NULL, /* find_blist_chat */
|
|
6480 NULL, /* roomlist_get_list */
|
|
6481 NULL, /* roomlist_cancel */
|
|
6482 NULL, /* roomlist_expand_category */
|
|
6483 oscar_can_receive_file, /* can_receive_file */
|
|
6484 oscar_send_file, /* send_file */
|
|
6485 oscar_new_xfer, /* new_xfer */
|
|
6486 oscar_offline_message, /* offline_message */
|
|
6487 NULL, /* whiteboard_prpl_ops */
|
|
6488 };
|
|
6489
|
|
6490 static GaimPluginInfo info =
|
|
6491 {
|
|
6492 GAIM_PLUGIN_MAGIC,
|
|
6493 GAIM_MAJOR_VERSION,
|
|
6494 GAIM_MINOR_VERSION,
|
|
6495 GAIM_PLUGIN_PROTOCOL, /**< type */
|
|
6496 NULL, /**< ui_requirement */
|
|
6497 0, /**< flags */
|
|
6498 NULL, /**< dependencies */
|
|
6499 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
6500
|
|
6501 "prpl-oscar", /**< id */
|
|
6502 "AIM/ICQ", /**< name */
|
|
6503 VERSION, /**< version */
|
|
6504 /** summary */
|
|
6505 N_("AIM/ICQ Protocol Plugin"),
|
|
6506 /** description */
|
|
6507 N_("AIM/ICQ Protocol Plugin"),
|
|
6508 NULL, /**< author */
|
|
6509 GAIM_WEBSITE, /**< homepage */
|
|
6510
|
|
6511 NULL, /**< load */
|
|
6512 NULL, /**< unload */
|
|
6513 NULL, /**< destroy */
|
|
6514
|
|
6515 NULL, /**< ui_info */
|
|
6516 &prpl_info, /**< extra_info */
|
|
6517 NULL,
|
|
6518 oscar_actions
|
|
6519 };
|
|
6520
|
|
6521 static void
|
|
6522 init_plugin(GaimPlugin *plugin)
|
|
6523 {
|
|
6524 GaimAccountOption *option;
|
|
6525
|
|
6526 option = gaim_account_option_string_new(_("Server"), "server", OSCAR_DEFAULT_LOGIN_SERVER);
|
|
6527 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
6528
|
|
6529 option = gaim_account_option_int_new(_("Port"), "port", OSCAR_DEFAULT_LOGIN_PORT);
|
|
6530 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
6531
|
|
6532 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
|
|
6533 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
6534
|
|
6535 option = gaim_account_option_bool_new(
|
14392
|
6536 _("Always use AIM/ICQ proxy server for file transfers\n(slower, but does not reveal your IP address)"), "always_use_rv_proxy",
|
14192
|
6537 OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY);
|
|
6538 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
6539
|
|
6540 /* Preferences */
|
|
6541 gaim_prefs_add_none("/plugins/prpl/oscar");
|
|
6542 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE);
|
|
6543 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE);
|
|
6544 gaim_prefs_remove("/plugins/prpl/oscar/always_use_rv_proxy");
|
|
6545 }
|
|
6546
|
|
6547 GAIM_INIT_PLUGIN(oscar, init_plugin, info);
|