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