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