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