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