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