Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 13366:0758db6d46ac
[gaim-migrate @ 15739]
I don't like this null. It may not matter.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 01 Mar 2006 07:43:54 +0000 |
parents | 554575d1f9b5 |
children | d1b29fb3b6d0 |
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" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
37 #include "ft.h" |
6982 | 38 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
39 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
40 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
41 #include "privacy.h" |
2086 | 42 #include "prpl.h" |
4889 | 43 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 #include "util.h" |
9943 | 46 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
47 |
13234 | 48 #include "oscar.h" |
49 #include "peer.h" | |
2086 | 50 |
9976 | 51 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
52 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
9991 | 53 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 54 #define OSCAR_STATUS_ID_AWAY "away" |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
55 #define OSCAR_STATUS_ID_DND "dnd" |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
56 #define OSCAR_STATUS_ID_NA "na" |
9976 | 57 #define OSCAR_STATUS_ID_OCCUPIED "occupied" |
58 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
59 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 60 |
2086 | 61 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
62 | |
7283 | 63 #define OSCAR_CONNECT_STEPS 6 |
11338 | 64 #define OSCAR_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" |
65 #define OSCAR_DEFAULT_LOGIN_PORT 5190 | |
9830 | 66 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
10570 | 67 #define OSCAR_DEFAULT_AUTHORIZATION TRUE |
68 #define OSCAR_DEFAULT_HIDE_IP TRUE | |
69 #define OSCAR_DEFAULT_WEB_AWARE FALSE | |
13071 | 70 #define OSCAR_DEFAULT_USE_RV_PROXY TRUE |
7283 | 71 |
11369 | 72 /* Milliseconds each file transfer ip address will be given to make a connection. */ |
73 #define FT_CLIENTIP_TIMEOUT 1000 /* 5000 */ | |
74 #define FT_VERIFIEDIP_TIMEOUT 5000 /* 15000 */ | |
75 #define FT_REDIR_TIMEOUT 10000 /* 20000 */ /* Time to wait for redirected transfer */ | |
76 #define FT_PROXYIP_TIMEOUT 300000 /* 120000 */ /* Time to create a checksum for VERY large files */ | |
11084 | 77 |
7376 | 78 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
79 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 80 |
13234 | 81 static guint8 features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
82 static guint8 features_icq[] = {0x01, 0x06}; | |
83 static guint8 features_icq_offline[] = {0x01}; | |
84 static guint8 ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | |
2086 | 85 |
7283 | 86 typedef struct _OscarData OscarData; |
87 struct _OscarData { | |
13239 | 88 OscarSession *sess; |
89 OscarConnection *conn; | |
2086 | 90 |
91 guint cnpa; | |
92 guint paspa; | |
3694 | 93 guint emlpa; |
4804 | 94 guint icopa; |
2086 | 95 |
4823 | 96 gboolean iconconnecting; |
5842 | 97 gboolean set_icon; |
4823 | 98 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
99 GSList *create_rooms; |
2086 | 100 |
101 gboolean conf; | |
102 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
103 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
104 char *email; |
2979 | 105 gboolean setnick; |
106 char *newsn; | |
2086 | 107 gboolean chpass; |
108 char *oldp; | |
109 char *newp; | |
11651 | 110 |
2086 | 111 GSList *oscar_chats; |
112 GSList *direct_ims; | |
3630 | 113 GSList *file_transfers; |
4738 | 114 GHashTable *buddyinfo; |
4804 | 115 GSList *requesticon; |
2086 | 116 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
117 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
118 gboolean icq; |
4804 | 119 guint icontimer; |
5968 | 120 guint getblisttimer; |
8341 | 121 guint getinfotimer; |
10567 | 122 gint timeoffset; |
2993 | 123 |
124 struct { | |
4230 | 125 guint maxwatchers; /* max users who can watch you */ |
2993 | 126 guint maxbuddies; /* max users you can watch */ |
4230 | 127 guint maxgroups; /* max groups in server list */ |
2993 | 128 guint maxpermits; /* max users on permit list */ |
129 guint maxdenies; /* max users on deny list */ | |
130 guint maxsiglen; /* max size (bytes) of profile */ | |
131 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
132 } rights; | |
2086 | 133 }; |
134 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
135 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
136 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
137 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
138 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
139 |
2086 | 140 struct chat_connection { |
141 char *name; | |
142 char *show; /* AOL did something funny to us */ | |
13234 | 143 guint16 exchange; |
144 guint16 instance; | |
13239 | 145 OscarConnection *conn; |
2086 | 146 int inpa; |
147 int id; | |
5575 | 148 GaimConnection *gc; /* i hate this. */ |
8733 | 149 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
150 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
151 int maxvis; |
2086 | 152 }; |
153 | |
8971 | 154 struct oscar_direct_im { |
5575 | 155 GaimConnection *gc; |
2086 | 156 char name[80]; |
157 int watcher; | |
13239 | 158 OscarConnection *conn; |
3008 | 159 gboolean connected; |
8978 | 160 gboolean gpc_pend; |
161 gboolean killme; | |
8984 | 162 gboolean donttryagain; |
2086 | 163 }; |
164 | |
165 struct ask_direct { | |
5575 | 166 GaimConnection *gc; |
2086 | 167 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
168 char ip[64]; |
13234 | 169 guint8 cookie[8]; |
8984 | 170 gboolean donttryagain; |
2086 | 171 }; |
172 | |
7011 | 173 /* |
174 * Various PRPL-specific buddy info that we want to keep track of | |
11651 | 175 * Some other info is maintained by locate.c, and I'd like to move |
7011 | 176 * the rest of this to libfaim, mostly im.c |
11651 | 177 * |
178 * TODO: I think all of this should use the status API. | |
7011 | 179 */ |
4738 | 180 struct buddyinfo { |
181 gboolean typingnot; | |
13234 | 182 guint32 ipaddr; |
5836 | 183 |
184 unsigned long ico_me_len; | |
185 unsigned long ico_me_csum; | |
186 time_t ico_me_time; | |
187 gboolean ico_informed; | |
4738 | 188 |
189 unsigned long ico_len; | |
190 unsigned long ico_csum; | |
191 time_t ico_time; | |
192 gboolean ico_need; | |
7406 | 193 gboolean ico_sent; |
2086 | 194 }; |
195 | |
4230 | 196 struct name_data { |
5575 | 197 GaimConnection *gc; |
4230 | 198 gchar *name; |
3453 | 199 gchar *nick; |
3141 | 200 }; |
201 | |
5129 | 202 static char *msgerrreason[] = { |
203 N_("Invalid error"), | |
204 N_("Invalid SNAC"), | |
205 N_("Rate to host"), | |
206 N_("Rate to client"), | |
207 N_("Not logged in"), | |
208 N_("Service unavailable"), | |
209 N_("Service not defined"), | |
210 N_("Obsolete SNAC"), | |
211 N_("Not supported by host"), | |
212 N_("Not supported by client"), | |
213 N_("Refused by client"), | |
214 N_("Reply too big"), | |
215 N_("Responses lost"), | |
216 N_("Request denied"), | |
217 N_("Busted SNAC payload"), | |
218 N_("Insufficient rights"), | |
219 N_("In local permit/deny"), | |
220 N_("Too evil (sender)"), | |
221 N_("Too evil (receiver)"), | |
222 N_("User temporarily unavailable"), | |
223 N_("No match"), | |
224 N_("List overflow"), | |
225 N_("Request ambiguous"), | |
226 N_("Queue full"), | |
227 N_("Not while on AOL") | |
228 }; | |
229 static int msgerrreasonlen = 25; | |
230 | |
231 /* All the libfaim->gaim callback functions */ | |
13239 | 232 static int gaim_parse_auth_resp (OscarSession *, FlapFrame *, ...); |
233 static int gaim_parse_login (OscarSession *, FlapFrame *, ...); | |
234 static int gaim_parse_auth_securid_request(OscarSession *, FlapFrame *, ...); | |
235 static int gaim_handle_redirect (OscarSession *, FlapFrame *, ...); | |
236 static int gaim_info_change (OscarSession *, FlapFrame *, ...); | |
237 static int gaim_account_confirm (OscarSession *, FlapFrame *, ...); | |
238 static int gaim_parse_oncoming (OscarSession *, FlapFrame *, ...); | |
239 static int gaim_parse_offgoing (OscarSession *, FlapFrame *, ...); | |
240 static int gaim_parse_incoming_im(OscarSession *, FlapFrame *, ...); | |
241 static int gaim_parse_misses (OscarSession *, FlapFrame *, ...); | |
242 static int gaim_parse_clientauto (OscarSession *, FlapFrame *, ...); | |
243 static int gaim_parse_userinfo (OscarSession *, FlapFrame *, ...); | |
244 static int gaim_reqinfo_timeout (OscarSession *, FlapFrame *, ...); | |
245 static int gaim_got_infoblock (OscarSession *sess, FlapFrame *fr, ...); | |
246 static int gaim_parse_motd (OscarSession *, FlapFrame *, ...); | |
247 static int gaim_chatnav_info (OscarSession *, FlapFrame *, ...); | |
248 static int gaim_conv_chat_join (OscarSession *, FlapFrame *, ...); | |
249 static int gaim_conv_chat_leave (OscarSession *, FlapFrame *, ...); | |
250 static int gaim_conv_chat_info_update (OscarSession *, FlapFrame *, ...); | |
251 static int gaim_conv_chat_incoming_msg(OscarSession *, FlapFrame *, ...); | |
252 static int gaim_email_parseupdate(OscarSession *, FlapFrame *, ...); | |
253 static int gaim_icon_error (OscarSession *, FlapFrame *, ...); | |
254 static int gaim_icon_parseicon (OscarSession *, FlapFrame *, ...); | |
255 static int oscar_icon_req (OscarSession *, FlapFrame *, ...); | |
256 static int gaim_parse_msgack (OscarSession *, FlapFrame *, ...); | |
257 static int gaim_parse_ratechange (OscarSession *, FlapFrame *, ...); | |
258 static int gaim_parse_evilnotify (OscarSession *, FlapFrame *, ...); | |
259 static int gaim_parse_searcherror(OscarSession *, FlapFrame *, ...); | |
260 static int gaim_parse_searchreply(OscarSession *, FlapFrame *, ...); | |
261 static int gaim_bosrights (OscarSession *, FlapFrame *, ...); | |
262 static int gaim_connerr (OscarSession *, FlapFrame *, ...); | |
263 static int conninitdone_admin (OscarSession *, FlapFrame *, ...); | |
264 static int conninitdone_bos (OscarSession *, FlapFrame *, ...); | |
265 static int conninitdone_chatnav (OscarSession *, FlapFrame *, ...); | |
266 static int conninitdone_chat (OscarSession *, FlapFrame *, ...); | |
267 static int conninitdone_email (OscarSession *, FlapFrame *, ...); | |
268 static int conninitdone_icon (OscarSession *, FlapFrame *, ...); | |
269 static int gaim_parse_msgerr (OscarSession *, FlapFrame *, ...); | |
270 static int gaim_parse_mtn (OscarSession *, FlapFrame *, ...); | |
271 static int gaim_parse_locaterights(OscarSession *, FlapFrame *, ...); | |
272 static int gaim_parse_buddyrights(OscarSession *, FlapFrame *, ...); | |
273 static int gaim_parse_locerr (OscarSession *, FlapFrame *, ...); | |
274 static int gaim_icbm_param_info (OscarSession *, FlapFrame *, ...); | |
275 static int gaim_parse_genericerr (OscarSession *, FlapFrame *, ...); | |
276 static int gaim_memrequest (OscarSession *, FlapFrame *, ...); | |
277 static int gaim_selfinfo (OscarSession *, FlapFrame *, ...); | |
278 static int gaim_offlinemsg (OscarSession *, FlapFrame *, ...); | |
279 static int gaim_offlinemsgdone (OscarSession *, FlapFrame *, ...); | |
280 static int gaim_icqalias (OscarSession *, FlapFrame *, ...); | |
281 static int gaim_icqinfo (OscarSession *, FlapFrame *, ...); | |
282 static int gaim_popup (OscarSession *, FlapFrame *, ...); | |
283 | |
284 static int gaim_ssi_parseerr (OscarSession *, FlapFrame *, ...); | |
285 static int gaim_ssi_parserights (OscarSession *, FlapFrame *, ...); | |
286 static int gaim_ssi_parselist (OscarSession *, FlapFrame *, ...); | |
287 static int gaim_ssi_parseack (OscarSession *, FlapFrame *, ...); | |
288 static int gaim_ssi_parseadd (OscarSession *, FlapFrame *, ...); | |
289 static int gaim_ssi_authgiven (OscarSession *, FlapFrame *, ...); | |
290 static int gaim_ssi_authrequest (OscarSession *, FlapFrame *, ...); | |
291 static int gaim_ssi_authreply (OscarSession *, FlapFrame *, ...); | |
292 static int gaim_ssi_gotadded (OscarSession *, FlapFrame *, ...); | |
5129 | 293 |
294 /* for DirectIM/image transfer */ | |
13239 | 295 static int gaim_odc_initiate (OscarSession *, FlapFrame *, ...); |
296 static int gaim_odc_incoming (OscarSession *, FlapFrame *, ...); | |
297 static int gaim_odc_typing (OscarSession *, FlapFrame *, ...); | |
298 static int gaim_odc_update_ui (OscarSession *, FlapFrame *, ...); | |
5129 | 299 |
300 /* for file transfer */ | |
13239 | 301 static int oscar_sendfile_estblsh(OscarSession *, FlapFrame *, ...); |
302 static int oscar_sendfile_prompt (OscarSession *, FlapFrame *, ...); | |
303 static int oscar_sendfile_ack (OscarSession *, FlapFrame *, ...); | |
304 static int oscar_sendfile_done (OscarSession *, FlapFrame *, ...); | |
5129 | 305 |
306 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 307 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
11369 | 308 static void oscar_xfer_init_recv(GaimXfer *xfer); |
309 static void oscar_xfer_init_send(GaimXfer *xfer); | |
310 | |
11159 | 311 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie); |
12816 | 312 static void recent_buddies_cb(const char *name, GaimPrefType type, gconstpointer value, gpointer data); |
11347 | 313 static void oscar_set_info(GaimConnection *gc, const char *info); |
11965 | 314 static void oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo, gboolean setstatus, GaimStatus *status); |
12652 | 315 static void oscar_set_extendedstatus(GaimConnection *gc); |
12663 | 316 static gboolean gaim_ssi_rerequestdata(gpointer data); |
9935 | 317 |
5836 | 318 static void oscar_free_name_data(struct name_data *data) { |
4230 | 319 g_free(data->name); |
320 g_free(data->nick); | |
321 g_free(data); | |
322 } | |
323 | |
5836 | 324 static void oscar_free_buddyinfo(void *data) { |
325 struct buddyinfo *bi = data; | |
326 g_free(bi); | |
327 } | |
328 | |
13234 | 329 static guint32 oscar_charset_check(const char *utf8) |
5129 | 330 { |
331 int i = 0; | |
9826 | 332 int charset = AIM_CHARSET_ASCII; |
5129 | 333 |
13226 | 334 /* Determine how we can send this message. Per the warnings elsewhere |
335 * in this file, these little checks determine the simplest encoding | |
5129 | 336 * we can use for a given message send using it. */ |
337 while (utf8[i]) { | |
338 if ((unsigned char)utf8[i] > 0x7f) { | |
339 /* not ASCII! */ | |
9826 | 340 charset = AIM_CHARSET_CUSTOM; |
5129 | 341 break; |
342 } | |
343 i++; | |
344 } | |
345 while (utf8[i]) { | |
346 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
347 * followed by 0xc0-0xc3 in the second */ | |
348 if ((unsigned char)utf8[i] < 0x80) { | |
349 i++; | |
350 continue; | |
351 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
13226 | 352 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { |
5129 | 353 i += 2; |
354 continue; | |
355 } | |
9826 | 356 charset = AIM_CHARSET_UNICODE; |
5129 | 357 break; |
358 } | |
359 | |
9807 | 360 return charset; |
5129 | 361 } |
362 | |
8225 | 363 /* |
364 * Take a string of the form charset="bleh" where bleh is | |
13226 | 365 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and |
8225 | 366 * return a newly allocated string containing bleh. |
367 */ | |
368 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 369 { |
8225 | 370 gchar *ret = NULL; |
371 char *begin, *end; | |
372 | |
9933 | 373 g_return_val_if_fail(encoding != NULL, NULL); |
374 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
375 /* Make sure encoding begins with charset= */ |
10540 | 376 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
377 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
378 { | |
8225 | 379 return NULL; |
10540 | 380 } |
8225 | 381 |
382 begin = strchr(encoding, '"'); | |
383 end = strrchr(encoding, '"'); | |
384 | |
385 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
386 return NULL; | |
387 | |
388 ret = g_strndup(begin+1, (end-1) - begin); | |
389 | |
390 return ret; | |
391 } | |
392 | |
9830 | 393 static gchar * |
394 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 395 { |
396 gchar *utf8 = NULL; | |
9595 | 397 |
398 if ((encoding == NULL) || encoding[0] == '\0') { | |
399 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 400 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 401 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 402 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 403 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 404 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 405 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 406 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 407 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 408 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 409 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
410 } | |
411 | |
412 /* | |
413 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
414 * we have been unable to convert the text to utf-8 from the encoding | |
415 * that was specified. So we check if the text is valid utf-8 then | |
416 * just copy it. | |
417 */ | |
418 if (utf8 == NULL) { | |
9638 | 419 if (textlen != 0 && *text != '\0' |
13226 | 420 && !g_utf8_validate(text, textlen, NULL)) |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
421 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 422 else |
9481 | 423 utf8 = g_strndup(text, textlen); |
5129 | 424 } |
425 | |
426 return utf8; | |
427 } | |
428 | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
429 static gchar *oscar_utf8_try_convert(GaimAccount *account, const gchar *msg) |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
430 { |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
431 const char *charset = NULL; |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
432 char *ret = NULL; |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
433 |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
434 if(aim_sn_is_icq(gaim_account_get_username(account))) |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
435 charset = gaim_account_get_string(account, "encoding", NULL); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
436 |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
437 if(charset && *charset) |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
438 ret = g_convert(msg, -1, "UTF-8", charset, NULL, NULL, NULL); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
439 |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
440 if(!ret) |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
441 ret = gaim_utf8_try_convert(msg); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
442 |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
443 return ret; |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
444 } |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
445 |
9830 | 446 static gchar * |
11159 | 447 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback) |
9830 | 448 { |
449 gchar *ret = NULL; | |
450 GError *err = NULL; | |
451 | |
9908 | 452 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
453 return NULL; | |
454 | |
455 if (strcasecmp("UTF-8", charsetstr)) { | |
456 if (fallback) | |
457 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
458 else | |
459 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
460 if (err != NULL) { | |
461 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
462 charsetstr, err->message); | |
463 g_error_free(err); | |
464 } | |
465 } else { | |
466 if (g_utf8_validate(data, datalen, NULL)) | |
467 ret = g_strndup(data, datalen); | |
468 else | |
469 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
470 } | |
471 | |
472 return ret; | |
473 } | |
474 | |
475 /* | |
11081 | 476 * This attemps to decode an incoming IM into a UTF8 string. |
477 * | |
9908 | 478 * We try decoding using two different character sets. The charset |
479 * specified in the IM determines the order in which we attempt to | |
480 * decode. We do this because there are lots of broken ICQ clients | |
481 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
482 * able to deal with that crap, then people complain like banshees. | |
483 * charsetstr1 is always set to what the correct encoding should be. | |
484 */ | |
485 static gchar * | |
13234 | 486 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, guint16 charset, guint16 charsubset, const gchar *data, gsize datalen) |
9908 | 487 { |
488 gchar *ret = NULL; | |
489 const gchar *charsetstr1, *charsetstr2; | |
490 | |
491 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 492 |
493 if ((datalen == 0) || (data == NULL)) | |
494 return NULL; | |
495 | |
9908 | 496 if (charset == AIM_CHARSET_UNICODE) { |
497 charsetstr1 = "UCS-2BE"; | |
498 charsetstr2 = "UTF-8"; | |
499 } else if (charset == AIM_CHARSET_CUSTOM) { | |
11369 | 500 if ((sourcesn != NULL) && isdigit(sourcesn[0])) |
9908 | 501 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 502 else |
9908 | 503 charsetstr1 = "ISO-8859-1"; |
504 charsetstr2 = "UTF-8"; | |
505 } else if (charset == AIM_CHARSET_ASCII) { | |
506 /* Should just be "ASCII" */ | |
9914 | 507 charsetstr1 = "ASCII"; |
9908 | 508 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
509 } else if (charset == 0x000d) { | |
9830 | 510 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 511 charsetstr1 = "ISO-8859-1"; |
512 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
513 } else { | |
9830 | 514 /* Unknown, hope for valid UTF-8... */ |
9908 | 515 charsetstr1 = "UTF-8"; |
516 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
517 } | |
518 | |
519 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
520 if (ret == NULL) | |
521 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
522 if (ret == NULL) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
523 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9830 | 524 |
525 return ret; | |
526 } | |
527 | |
11081 | 528 /* |
529 * Figure out what encoding to use when sending a given outgoing message. | |
530 */ | |
9830 | 531 static void |
13226 | 532 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, |
533 const char *destsn, const gchar *from, | |
534 gchar **msg, int *msglen_int, | |
13234 | 535 guint16 *charset, guint16 *charsubset) |
9830 | 536 { |
537 OscarData *od = gc->proto_data; | |
538 GaimAccount *account = gaim_connection_get_account(gc); | |
539 GError *err = NULL; | |
540 aim_userinfo_t *userinfo = NULL; | |
541 const gchar *charsetstr; | |
10039 | 542 gsize msglen; |
9830 | 543 |
544 /* Attempt to send as ASCII */ | |
10098 | 545 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 546 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 547 *charset = AIM_CHARSET_ASCII; |
9830 | 548 *charsubset = 0x0000; |
10039 | 549 *msglen_int = msglen; |
9830 | 550 return; |
551 } | |
552 | |
553 /* | |
10565 | 554 * If we're sending to an ICQ user, and they are in our |
555 * buddy list, and they are advertising the Unicode | |
556 * capability, and they are online, then attempt to send | |
557 * as UCS-2BE. | |
9830 | 558 */ |
9975 | 559 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 560 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
561 | |
10565 | 562 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
563 { | |
564 GaimBuddy *b; | |
565 b = gaim_find_buddy(account, destsn); | |
566 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
567 { | |
568 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
569 if (*msg != NULL) | |
570 { | |
571 *charset = AIM_CHARSET_UNICODE; | |
572 *charsubset = 0x0000; | |
573 *msglen_int = msglen; | |
574 return; | |
575 } | |
9830 | 576 } |
577 } | |
578 | |
579 /* | |
580 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
581 * ICQ then attempt to send as the user specified character encoding. | |
582 */ | |
583 charsetstr = "ISO-8859-1"; | |
9975 | 584 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 585 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
586 | |
10097 | 587 /* |
588 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
589 * can be converted to "charsetstr" | |
590 */ | |
10039 | 591 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 592 if (*msg != NULL) { |
593 *charset = AIM_CHARSET_CUSTOM; | |
594 *charsubset = 0x0000; | |
10039 | 595 *msglen_int = msglen; |
9830 | 596 return; |
597 } | |
598 | |
599 /* | |
600 * Nothing else worked, so send as UCS-2BE. | |
601 */ | |
10039 | 602 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 603 if (*msg != NULL) { |
604 *charset = AIM_CHARSET_UNICODE; | |
605 *charsubset = 0x0000; | |
10039 | 606 *msglen_int = msglen; |
9830 | 607 return; |
608 } | |
609 | |
9908 | 610 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 611 g_error_free(err); |
612 | |
613 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
614 *msg = g_strdup(from); | |
10039 | 615 *msglen_int = strlen(*msg); |
9830 | 616 *charset = AIM_CHARSET_ASCII; |
617 *charsubset = 0x0000; | |
618 return; | |
619 } | |
620 | |
13356 | 621 /** |
622 * Looks for %n, %d, or %t in a string, and replaces them with the | |
623 * specified name, date, and time, respectively. | |
624 * | |
625 * @param str The string that may contain the special variables. | |
626 * @param name The sender name. | |
627 * | |
628 * @return A newly allocated string where the special variables are | |
629 * expanded. This should be g_free'd by the caller. | |
630 */ | |
631 static gchar * | |
632 gaim_str_sub_away_formatters(const char *str, const char *name) | |
633 { | |
634 char *c; | |
635 GString *cpy; | |
636 time_t t; | |
637 struct tm *tme; | |
638 | |
639 g_return_val_if_fail(str != NULL, NULL); | |
640 g_return_val_if_fail(name != NULL, NULL); | |
641 | |
642 /* Create an empty GString that is hopefully big enough for most messages */ | |
643 cpy = g_string_sized_new(1024); | |
644 | |
645 t = time(NULL); | |
646 tme = localtime(&t); | |
647 | |
648 c = (char *)str; | |
649 while (*c) { | |
650 switch (*c) { | |
651 case '%': | |
652 if (*(c + 1)) { | |
653 switch (*(c + 1)) { | |
654 case 'n': | |
655 /* append name */ | |
656 g_string_append(cpy, name); | |
657 c++; | |
658 break; | |
659 case 'd': | |
660 /* append date */ | |
661 g_string_append(cpy, gaim_date_format_short(tme)); | |
662 c++; | |
663 break; | |
664 case 't': | |
665 /* append time */ | |
666 g_string_append(cpy, gaim_time_format(tme)); | |
667 c++; | |
668 break; | |
669 default: | |
670 g_string_append_c(cpy, *c); | |
671 } | |
672 } else { | |
673 g_string_append_c(cpy, *c); | |
674 } | |
675 break; | |
676 default: | |
677 g_string_append_c(cpy, *c); | |
678 } | |
679 c++; | |
680 } | |
681 | |
682 return g_string_free(cpy, FALSE); | |
683 } | |
684 | |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
685 static gchar *oscar_caps_to_string(guint caps) |
8701 | 686 { |
9407 | 687 GString *str; |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
688 const gchar *tmp; |
8701 | 689 guint bit = 1; |
690 | |
9407 | 691 str = g_string_new(""); |
692 | |
8701 | 693 if (!caps) { |
694 return NULL; | |
695 } else while (bit <= AIM_CAPS_LAST) { | |
696 if (bit & caps) { | |
697 switch (bit) { | |
698 case AIM_CAPS_BUDDYICON: | |
699 tmp = _("Buddy Icon"); | |
700 break; | |
701 case AIM_CAPS_TALK: | |
702 tmp = _("Voice"); | |
703 break; | |
704 case AIM_CAPS_DIRECTIM: | |
705 tmp = _("AIM Direct IM"); | |
706 break; | |
707 case AIM_CAPS_CHAT: | |
708 tmp = _("Chat"); | |
709 break; | |
710 case AIM_CAPS_GETFILE: | |
711 tmp = _("Get File"); | |
712 break; | |
713 case AIM_CAPS_SENDFILE: | |
714 tmp = _("Send File"); | |
715 break; | |
716 case AIM_CAPS_GAMES: | |
717 case AIM_CAPS_GAMES2: | |
718 tmp = _("Games"); | |
719 break; | |
720 case AIM_CAPS_ADDINS: | |
721 tmp = _("Add-Ins"); | |
722 break; | |
723 case AIM_CAPS_SENDBUDDYLIST: | |
724 tmp = _("Send Buddy List"); | |
725 break; | |
726 case AIM_CAPS_ICQ_DIRECT: | |
727 tmp = _("ICQ Direct Connect"); | |
728 break; | |
729 case AIM_CAPS_APINFO: | |
730 tmp = _("AP User"); | |
731 break; | |
732 case AIM_CAPS_ICQRTF: | |
733 tmp = _("ICQ RTF"); | |
734 break; | |
735 case AIM_CAPS_EMPTY: | |
736 tmp = _("Nihilist"); | |
737 break; | |
738 case AIM_CAPS_ICQSERVERRELAY: | |
739 tmp = _("ICQ Server Relay"); | |
740 break; | |
741 case AIM_CAPS_ICQUTF8OLD: | |
742 tmp = _("Old ICQ UTF8"); | |
743 break; | |
744 case AIM_CAPS_TRILLIANCRYPT: | |
745 tmp = _("Trillian Encryption"); | |
746 break; | |
747 case AIM_CAPS_ICQUTF8: | |
748 tmp = _("ICQ UTF8"); | |
749 break; | |
750 case AIM_CAPS_HIPTOP: | |
751 tmp = _("Hiptop"); | |
752 break; | |
753 case AIM_CAPS_SECUREIM: | |
754 tmp = _("Security Enabled"); | |
755 break; | |
756 case AIM_CAPS_VIDEO: | |
757 tmp = _("Video Chat"); | |
758 break; | |
759 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
760 case AIM_CAPS_ICHATAV: | |
761 tmp = _("iChat AV"); | |
762 break; | |
763 case AIM_CAPS_LIVEVIDEO: | |
764 tmp = _("Live Video"); | |
765 break; | |
766 case AIM_CAPS_CAMERA: | |
767 tmp = _("Camera"); | |
768 break; | |
769 default: | |
770 tmp = NULL; | |
771 break; | |
772 } | |
773 if (tmp) | |
9532 | 774 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 775 } |
776 bit <<= 1; | |
777 } | |
9407 | 778 |
779 return g_string_free(str, FALSE); | |
8701 | 780 } |
781 | |
782 static char *oscar_icqstatus(int state) { | |
783 /* Make a cute little string that shows the status of the dude or dudet */ | |
784 if (state & AIM_ICQ_STATE_CHAT) | |
785 return g_strdup_printf(_("Free For Chat")); | |
786 else if (state & AIM_ICQ_STATE_DND) | |
787 return g_strdup_printf(_("Do Not Disturb")); | |
788 else if (state & AIM_ICQ_STATE_OUT) | |
789 return g_strdup_printf(_("Not Available")); | |
790 else if (state & AIM_ICQ_STATE_BUSY) | |
791 return g_strdup_printf(_("Occupied")); | |
792 else if (state & AIM_ICQ_STATE_AWAY) | |
793 return g_strdup_printf(_("Away")); | |
794 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
795 return g_strdup_printf(_("Web Aware")); | |
796 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
797 return g_strdup_printf(_("Invisible")); | |
798 else | |
799 return g_strdup_printf(_("Online")); | |
800 } | |
801 | |
9973 | 802 static void |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
803 oscar_string_append(GaimAccount *account, GString *str, const char *newline, |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
804 const char *name, const char *value) |
8700 | 805 { |
806 gchar *utf8; | |
807 | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
808 if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) { |
8701 | 809 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 810 g_free(utf8); |
811 } | |
812 } | |
813 | |
9973 | 814 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 815 { |
10042 | 816 OscarData *od; |
817 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
818 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
819 GaimStatus *status = NULL; |
8701 | 820 GaimGroup *g = NULL; |
821 struct buddyinfo *bi = NULL; | |
822 char *tmp; | |
823 | |
10042 | 824 od = gc->proto_data; |
825 account = gaim_connection_get_account(gc); | |
826 | |
827 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 828 return; |
829 | |
830 if (userinfo == NULL) | |
831 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
832 | |
833 if (b == NULL) | |
10042 | 834 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 835 |
11369 | 836 if (b != NULL) { |
12088 | 837 g = gaim_buddy_get_group(b); |
10498 | 838 presence = gaim_buddy_get_presence(b); |
839 status = gaim_presence_get_active_status(presence); | |
840 } | |
8701 | 841 |
842 if (userinfo != NULL) | |
843 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
844 | |
8733 | 845 if (b != NULL) { |
10498 | 846 if (gaim_presence_is_online(presence)) { |
9975 | 847 if (aim_sn_is_icq(b->name)) { |
11510 | 848 GaimStatus *status = gaim_presence_get_active_status(presence); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
849 oscar_string_append(gc->account, str, newline, _("Status"), |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
850 gaim_status_get_name(status)); |
8733 | 851 } |
852 } else { | |
9625 | 853 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 854 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
855 oscar_string_append(gc->account, str, newline, _("Status"), |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
856 _("Not Authorized")); |
8733 | 857 else |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
858 oscar_string_append(gc->account, str, newline, _("Status"), |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
859 _("Offline")); |
8701 | 860 } |
8733 | 861 } |
8701 | 862 |
863 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 864 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 865 (bi->ipaddr & 0xff000000) >> 24, |
866 (bi->ipaddr & 0x00ff0000) >> 16, | |
867 (bi->ipaddr & 0x0000ff00) >> 8, | |
868 (bi->ipaddr & 0x000000ff)); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
869 oscar_string_append(gc->account, str, newline, _("IP Address"), tmp); |
8701 | 870 g_free(tmp); |
871 } | |
872 | |
11257 | 873 |
874 if ((userinfo != NULL) && (userinfo->warnlevel != 0)) { | |
11285 | 875 tmp = g_strdup_printf("%d", (int)(userinfo->warnlevel/10.0 + .5)); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
876 oscar_string_append(gc->account, str, newline, _("Warning Level"), tmp); |
11257 | 877 g_free(tmp); |
878 } | |
879 | |
8701 | 880 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { |
881 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
882 if (tmp != NULL) { | |
9625 | 883 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 884 g_free(tmp); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
885 oscar_string_append(gc->account, str, newline, _("Buddy Comment"), tmp2); |
9625 | 886 g_free(tmp2); |
8701 | 887 } |
888 } | |
889 } | |
890 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
891 static char *extract_name(const char *name) { |
4121 | 892 char *tmp, *x; |
2086 | 893 int i, j; |
4120 | 894 |
895 if (!name) | |
4121 | 896 return NULL; |
11369 | 897 |
4120 | 898 x = strchr(name, '-'); |
4121 | 899 |
2086 | 900 if (!x) return NULL; |
901 x = strchr(++x, '-'); | |
902 if (!x) return NULL; | |
903 tmp = g_strdup(++x); | |
904 | |
905 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
906 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
907 if (x[i] != '%') { |
2086 | 908 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
909 continue; |
2086 | 910 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
911 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
912 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
913 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 914 } |
915 | |
916 tmp[j] = 0; | |
917 return tmp; | |
918 } | |
919 | |
10458 | 920 static struct chat_connection * |
921 find_oscar_chat(GaimConnection *gc, int id) | |
922 { | |
923 OscarData *od = (OscarData *)gc->proto_data; | |
924 GSList *cur; | |
925 struct chat_connection *cc; | |
926 | |
927 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
928 { | |
929 cc = (struct chat_connection *)cur->data; | |
930 if (cc->id == id) | |
931 return cc; | |
932 } | |
933 | |
934 return NULL; | |
935 } | |
936 | |
937 static struct chat_connection * | |
13239 | 938 find_oscar_chat_by_conn(GaimConnection *gc, OscarConnection *conn) |
10458 | 939 { |
940 OscarData *od = (OscarData *)gc->proto_data; | |
941 GSList *cur; | |
942 struct chat_connection *cc; | |
943 | |
944 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
945 { | |
946 cc = (struct chat_connection *)cur->data; | |
947 if (cc->conn == conn) | |
948 return cc; | |
949 } | |
950 | |
951 return NULL; | |
952 } | |
953 | |
954 static struct chat_connection * | |
955 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
956 { | |
957 OscarData *od = (OscarData *)gc->proto_data; | |
958 GSList *cur; | |
959 struct chat_connection *cc; | |
960 | |
961 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
962 { | |
963 cc = (struct chat_connection *)cur->data; | |
964 if (cc->conv == conv) | |
965 return cc; | |
966 } | |
967 | |
968 return NULL; | |
969 } | |
970 | |
971 static void | |
972 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
973 { | |
974 OscarData *od = (OscarData *)gc->proto_data; | |
975 | |
976 /* Notify the conversation window that we've left the chat */ | |
977 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
978 | |
979 /* Destroy the chat_connection */ | |
980 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
981 if (cc->inpa > 0) | |
982 gaim_input_remove(cc->inpa); | |
13262 | 983 oscar_connection_destroy(od->sess, cc->conn); |
10458 | 984 g_free(cc->name); |
985 g_free(cc->show); | |
986 g_free(cc); | |
8219 | 987 } |
988 | |
8971 | 989 /***************************************************************************** |
990 * Begin scary direct im stuff | |
991 *****************************************************************************/ | |
992 | |
993 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
994 GSList *d = od->direct_ims; | |
995 struct oscar_direct_im *m = NULL; | |
996 | |
997 while (d) { | |
998 m = (struct oscar_direct_im *)d->data; | |
999 if (!aim_sncmp(who, m->name)) | |
1000 return m; | |
1001 d = d->next; | |
1002 } | |
1003 | |
1004 return NULL; | |
1005 } | |
1006 | |
1007 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
1008 { | |
1009 gaim_debug_info("oscar", | |
13226 | 1010 "destroying Direct IM for %s.\n", dim->name); |
8971 | 1011 |
1012 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 1013 if (dim->gpc_pend) { |
1014 dim->killme = TRUE; | |
1015 return; | |
1016 } | |
8971 | 1017 if (dim->watcher) |
1018 gaim_input_remove(dim->watcher); | |
13262 | 1019 if (dim->conn) |
1020 oscar_connection_destroy(od->sess, dim->conn); | |
8971 | 1021 g_free(dim); |
1022 } | |
1023 | |
1024 /* the only difference between this and destroy is this writes a conv message */ | |
1025 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
1026 { | |
1027 GaimConversation *conv; | |
1028 char buf[256]; | |
1029 | |
1030 gaim_debug_info("oscar", | |
13226 | 1031 "%s disconnected Direct IM.\n", dim->name); |
8971 | 1032 |
1033 if (dim->connected) | |
1034 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 1035 else |
8971 | 1036 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
1037 | |
11338 | 1038 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, dim->name, |
11369 | 1039 gaim_connection_get_account(dim->gc)); |
13226 | 1040 |
8971 | 1041 if (conv) { |
1042 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1043 } else { | |
1044 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
1045 } | |
1046 | |
1047 oscar_direct_im_destroy(od, dim); | |
1048 | |
1049 return; | |
1050 } | |
1051 | |
1052 /* oops i made two of these. this one just calls the other one. */ | |
13239 | 1053 static void gaim_odc_disconnect(OscarSession *sess, OscarConnection *conn) |
8971 | 1054 { |
1055 GaimConnection *gc = sess->aux_data; | |
1056 OscarData *od = (OscarData *)gc->proto_data; | |
1057 struct oscar_direct_im *dim; | |
1058 char *sn; | |
1059 | |
1060 sn = g_strdup(aim_odc_getsn(conn)); | |
1061 dim = oscar_direct_im_find(od, sn); | |
1062 oscar_direct_im_disconnect(od, dim); | |
1063 g_free(sn); | |
1064 } | |
1065 | |
1066 static void destroy_direct_im_request(struct ask_direct *d) { | |
1067 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
1068 | |
1069 g_free(d->sn); | |
1070 g_free(d); | |
1071 } | |
1072 | |
1073 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
1074 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
1075 struct oscar_direct_im *dim = data; | |
1076 GaimConnection *gc = dim->gc; | |
1077 OscarData *od = gc->proto_data; | |
1078 GaimConversation *conv; | |
1079 char buf[256]; | |
1080 struct sockaddr name; | |
1081 socklen_t name_len = 1; | |
1082 | |
1083 g_return_if_fail(gc != NULL); | |
1084 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1085 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1086 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1087 |
8978 | 1088 dim->gpc_pend = FALSE; |
1089 if (dim->killme) { | |
1090 oscar_direct_im_destroy(od, dim); | |
1091 return; | |
1092 } | |
1093 | |
8971 | 1094 if (!g_list_find(gaim_connections_get_all(), gc)) { |
1095 oscar_direct_im_destroy(od, dim); | |
1096 return; | |
1097 } | |
1098 | |
1099 if (source < 0) { | |
8984 | 1100 if (dim->donttryagain) { |
1101 oscar_direct_im_disconnect(od, dim); | |
1102 return; | |
1103 } else { | |
11159 | 1104 guchar cookie[8]; |
8984 | 1105 char *who = g_strdup(dim->name); |
11159 | 1106 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1107 |
1108 memcpy(cookie, tmp, 8); | |
1109 oscar_direct_im_destroy(od, dim); | |
1110 oscar_direct_im_initiate(gc, who, cookie); | |
1111 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1112 g_free(who); | |
1113 return; | |
1114 } | |
8971 | 1115 } |
1116 | |
1117 dim->conn->fd = source; | |
1118 aim_conn_completeconnect(od->sess, dim->conn); | |
11338 | 1119 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); |
8971 | 1120 |
1121 /* This is the best way to see if we're connected or not */ | |
8983 | 1122 /* Is this really needed? */ |
8971 | 1123 if (getpeername(source, &name, &name_len) == 0) { |
1124 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1125 dim->connected = TRUE; | |
1126 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1127 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1128 } else { | |
8984 | 1129 if (dim->donttryagain) { |
1130 oscar_direct_im_disconnect(od, dim); | |
1131 return; | |
1132 } else { | |
11159 | 1133 guchar cookie[8]; |
8984 | 1134 char *who = g_strdup(dim->name); |
11159 | 1135 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1136 |
1137 memcpy(cookie, tmp, 8); | |
1138 oscar_direct_im_destroy(od, dim); | |
1139 oscar_direct_im_initiate(gc, who, cookie); | |
1140 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1141 g_free(who); | |
1142 return; | |
1143 } | |
8983 | 1144 } |
1145 | |
1146 | |
8971 | 1147 } |
1148 | |
1149 static void accept_direct_im_request(struct ask_direct *d) { | |
1150 GaimConnection *gc = d->gc; | |
1151 OscarData *od; | |
1152 struct oscar_direct_im *dim; | |
1153 char *host; int port = 5190; | |
1154 int i, rc; | |
8982 | 1155 char *tmp; |
1156 GaimConversation *conv; | |
8971 | 1157 |
1158 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1159 destroy_direct_im_request(d); | |
1160 return; | |
1161 } | |
1162 | |
1163 od = (OscarData *)gc->proto_data; | |
1164 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1165 | |
1166 dim = oscar_direct_im_find(od, d->sn); | |
1167 if (dim && dim->connected) { | |
1168 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1169 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1170 return; | |
1171 } | |
1172 dim = g_new0(struct oscar_direct_im, 1); | |
1173 dim->gc = d->gc; | |
8984 | 1174 dim->donttryagain = d->donttryagain; |
8971 | 1175 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1176 | |
1177 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1178 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1179 if (!dim->conn) { | |
1180 oscar_direct_im_disconnect(od, dim); | |
1181 destroy_direct_im_request(d); | |
1182 return; | |
1183 } | |
1184 | |
13226 | 1185 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, |
13239 | 1186 PEER_TYPE_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
13226 | 1187 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, |
13239 | 1188 PEER_TYPE_DIRECTIMTYPING, gaim_odc_typing, 0); |
13226 | 1189 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, |
1190 AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
8971 | 1191 |
1192 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1193 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1194 if (d->ip[i] == ':') { | |
1195 port = atoi(&(d->ip[i+1])); | |
1196 break; | |
1197 } | |
1198 } | |
1199 host = g_strndup(d->ip, i); | |
1200 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1201 dim->gpc_pend = TRUE; |
8971 | 1202 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1203 |
11338 | 1204 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, d->sn); |
13226 | 1205 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), |
1206 d->sn, host, port); | |
8982 | 1207 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
1208 g_free(tmp); | |
8983 | 1209 |
8971 | 1210 g_free(host); |
1211 if (rc < 0) { | |
8978 | 1212 dim->gpc_pend = FALSE; |
8971 | 1213 oscar_direct_im_disconnect(od, dim); |
1214 destroy_direct_im_request(d); | |
1215 return; | |
1216 } | |
1217 | |
1218 destroy_direct_im_request(d); | |
1219 | |
1220 return; | |
1221 } | |
1222 | |
1223 /* | |
1224 * We have just established a socket with the other dude, so set up some handlers. | |
1225 */ | |
13239 | 1226 static int gaim_odc_initiate(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 1227 GaimConnection *gc = sess->aux_data; |
7283 | 1228 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1229 GaimConversation *conv; |
8971 | 1230 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1231 char buf[256]; |
8971 | 1232 char *sn; |
1233 va_list ap; | |
13239 | 1234 OscarConnection *newconn, *listenerconn; |
8971 | 1235 |
1236 va_start(ap, fr); | |
13239 | 1237 newconn = va_arg(ap, OscarConnection *); |
1238 listenerconn = va_arg(ap, OscarConnection *); | |
8971 | 1239 va_end(ap); |
1240 | |
13262 | 1241 oscar_connection_destroy(sess, listenerconn); |
8971 | 1242 |
1243 sn = g_strdup(aim_odc_getsn(newconn)); | |
1244 | |
13226 | 1245 gaim_debug_info("oscar", "DirectIM: initiate success to %s\n", sn); |
8971 | 1246 dim = oscar_direct_im_find(od, sn); |
1247 | |
11338 | 1248 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, sn); |
8971 | 1249 gaim_input_remove(dim->watcher); |
1250 dim->conn = newconn; | |
1251 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1252 dim->connected = TRUE; | |
1253 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1254 g_free(sn); | |
1255 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1256 | |
13239 | 1257 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, PEER_TYPE_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
1258 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, PEER_TYPE_DIRECTIMTYPING, gaim_odc_typing, 0); | |
8971 | 1259 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); |
1260 | |
1261 return 1; | |
1262 } | |
1263 | |
1264 /* | |
1265 * This is called when each chunk of an image is received. It can be used to | |
1266 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1267 * nasty, you sicko. | |
1268 */ | |
13239 | 1269 static int gaim_odc_update_ui(OscarSession *sess, FlapFrame *fr, ...) { |
8971 | 1270 va_list ap; |
1271 char *sn; | |
1272 double percent; | |
1273 GaimConnection *gc = sess->aux_data; | |
1274 OscarData *od = (OscarData *)gc->proto_data; | |
1275 struct oscar_direct_im *dim; | |
1276 | |
1277 va_start(ap, fr); | |
1278 sn = va_arg(ap, char *); | |
1279 percent = va_arg(ap, double); | |
1280 va_end(ap); | |
1281 | |
1282 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1283 return 1; | |
1284 if (dim->watcher) { | |
13226 | 1285 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ |
8971 | 1286 /* The callback will callback? I don't get how that would happen here. */ |
1287 dim->watcher = 0; | |
1288 } | |
1289 | |
1290 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
13226 | 1291 oscar_callback, dim->conn); |
8971 | 1292 |
1293 return 1; | |
1294 } | |
1295 | |
1296 /* | |
1297 * This is called after a direct IM has been received in its entirety. This | |
1298 * function is passed a long chunk of data which contains the IM with any | |
1299 * data chunks (images) appended to it. | |
1300 * | |
1301 * This function rips out all the data chunks and creates an imgstore for | |
1302 * each one. In order to do this, it first goes through the IM and takes | |
1303 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1304 * with one compatible with the imgstore Gaim core code. For each one, we | |
1305 * then read in chunks of data from the end of the message and actually | |
1306 * create the img store using the given data. | |
1307 * | |
1308 * For somewhat easy reference, here's a sample message | |
1309 * (without the whitespace and asterisks): | |
1310 * | |
1311 * <HTML><BODY BGCOLOR="#ffffff"> | |
1312 * <FONT LANG="0"> | |
1313 * This is a really stupid picture:<BR> | |
1314 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1315 * Yeah it is<BR> | |
1316 * Here is another one:<BR> | |
1317 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1318 * </FONT> | |
1319 * </BODY></HTML> | |
1320 * <BINARY> | |
1321 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1322 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1323 * </BINARY> | |
1324 */ | |
13239 | 1325 static int gaim_odc_incoming(OscarSession *sess, FlapFrame *fr, ...) { |
8971 | 1326 GaimConnection *gc = sess->aux_data; |
12216 | 1327 GaimMessageFlags imflags = 0; |
8971 | 1328 gchar *utf8; |
1329 GString *newmsg = g_string_new(""); | |
1330 GSList *images = NULL; | |
1331 va_list ap; | |
1332 const char *sn, *msg, *msgend, *binary; | |
1333 size_t len; | |
1334 int encoding, isawaymsg; | |
1335 | |
1336 va_start(ap, fr); | |
1337 sn = va_arg(ap, const char *); | |
1338 msg = va_arg(ap, const char *); | |
1339 len = va_arg(ap, size_t); | |
1340 encoding = va_arg(ap, int); | |
1341 isawaymsg = va_arg(ap, int); | |
1342 va_end(ap); | |
1343 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1344 |
13226 | 1345 gaim_debug_info("oscar", "Got DirectIM message from %s\n", sn); |
8971 | 1346 |
1347 if (isawaymsg) | |
12216 | 1348 imflags |= GAIM_MESSAGE_AUTO_RESP; |
8971 | 1349 |
1350 /* message has a binary trailer */ | |
1351 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1352 GData *attribs; | |
1353 const char *tmp, *start, *end, *last = NULL; | |
1354 | |
1355 tmp = msg; | |
1356 | |
1357 /* for each valid image tag... */ | |
1358 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1359 const char *id, *src, *datasize; | |
10504 | 1360 const char *data = NULL; |
1361 char *tag = NULL; | |
8971 | 1362 size_t size; |
1363 int imgid = 0; | |
1364 | |
1365 /* update the location of the last img tag */ | |
1366 last = end; | |
1367 | |
1368 /* grab attributes */ | |
1369 id = g_datalist_get_data(&attribs, "id"); | |
1370 src = g_datalist_get_data(&attribs, "src"); | |
1371 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1372 | |
1373 /* if we have id & datasize, build the data tag */ | |
1374 if (id && datasize) | |
1375 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1376 | |
1377 /* if we have a tag, find the start of the data */ | |
1378 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1379 data += strlen(tag); | |
1380 | |
10504 | 1381 g_free(tag); |
1382 | |
8971 | 1383 /* check the data is here and store it */ |
1384 if (data + (size = atoi(datasize)) <= msgend) | |
1385 imgid = gaim_imgstore_add(data, size, src); | |
1386 | |
1387 /* | |
1388 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1389 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1390 */ | |
1391 /* if we have a stored image... */ | |
1392 if (imgid) { | |
1393 /* append the message up to the tag */ | |
1394 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1395 if (utf8 != NULL) { | |
1396 newmsg = g_string_append(newmsg, utf8); | |
1397 g_free(utf8); | |
1398 } | |
1399 | |
1400 /* write the new image tag */ | |
1401 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1402 | |
1403 /* and record the image number */ | |
1404 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1405 } else { | |
1406 /* otherwise, copy up to the end of the tag */ | |
1407 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1408 if (utf8 != NULL) { | |
1409 newmsg = g_string_append(newmsg, utf8); | |
1410 g_free(utf8); | |
1411 } | |
1412 } | |
1413 | |
1414 /* clear the attribute list */ | |
1415 g_datalist_clear(&attribs); | |
1416 | |
1417 /* continue from the end of the tag */ | |
1418 tmp = end + 1; | |
1419 } | |
1420 | |
1421 /* append any remaining message data (without the > :-) */ | |
1422 if (last++ && (last < binary)) | |
1423 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1424 | |
1425 /* set the flag if we caught any images */ | |
1426 if (images) | |
12216 | 1427 imflags |= GAIM_MESSAGE_IMAGES; |
8971 | 1428 } else { |
1429 g_string_append_len(newmsg, msg, len); | |
1430 } | |
1431 | |
10318 | 1432 /* Convert to UTF8 */ |
1433 /* (This hasn't been tested very much) */ | |
1434 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1435 if (utf8 != NULL) { | |
1436 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1437 g_free(utf8); | |
1438 } | |
1439 | |
1440 /* free the message */ | |
8971 | 1441 g_string_free(newmsg, TRUE); |
1442 | |
1443 /* unref any images we allocated */ | |
1444 if (images) { | |
1445 GSList *tmp; | |
1446 int id; | |
1447 | |
1448 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1449 id = GPOINTER_TO_INT(tmp->data); | |
1450 gaim_imgstore_unref(id); | |
1451 } | |
1452 | |
1453 g_slist_free(images); | |
1454 } | |
1455 | |
1456 return 1; | |
1457 } | |
1458 | |
13239 | 1459 static int gaim_odc_typing(OscarSession *sess, FlapFrame *fr, ...) { |
8971 | 1460 va_list ap; |
1461 char *sn; | |
1462 int typing; | |
1463 GaimConnection *gc = sess->aux_data; | |
1464 | |
1465 va_start(ap, fr); | |
1466 sn = va_arg(ap, char *); | |
1467 typing = va_arg(ap, int); | |
1468 va_end(ap); | |
1469 | |
1470 if (typing == 0x0002) { | |
1471 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1472 gaim_debug_info("oscar", | |
1473 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1474 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1475 } else if (typing == 0x0001) | |
1476 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1477 else | |
1478 serv_got_typing_stopped(gc, sn); | |
1479 return 1; | |
1480 } | |
1481 | |
13239 | 1482 static int gaim_odc_send_im(OscarSession *sess, OscarConnection *conn, const char *message, GaimMessageFlags imflags) { |
8971 | 1483 char *buf; |
1484 size_t len; | |
1485 int ret; | |
1486 GString *msg = g_string_new("<HTML><BODY>"); | |
1487 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1488 GData *attribs; | |
1489 const char *start, *end, *last; | |
1490 int oscar_id = 0; | |
1491 | |
1492 last = message; | |
1493 | |
1494 /* for each valid IMG tag... */ | |
1495 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1496 GaimStoredImage *image = NULL; | |
1497 const char *id; | |
1498 | |
1499 if (start - last) { | |
1500 g_string_append_len(msg, last, start - last); | |
1501 } | |
1502 | |
1503 id = g_datalist_get_data(&attribs, "id"); | |
1504 | |
1505 /* ... if it refers to a valid gaim image ... */ | |
1506 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1507 /* ... append the message from start to the tag ... */ | |
9126 | 1508 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1509 const char *filename = gaim_imgstore_get_filename(image); |
1510 gpointer imgdata = gaim_imgstore_get_data(image); | |
1511 | |
1512 oscar_id++; | |
1513 | |
1514 /* ... insert a new img tag with the oscar id ... */ | |
1515 if (filename) | |
1516 g_string_append_printf(msg, | |
9126 | 1517 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1518 filename, oscar_id, size); |
1519 else | |
1520 g_string_append_printf(msg, | |
9126 | 1521 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1522 oscar_id, size); |
1523 | |
1524 /* ... and append the data to the binary section ... */ | |
9126 | 1525 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1526 oscar_id, size); |
1527 data = g_string_append_len(data, imgdata, size); | |
1528 data = g_string_append(data, "</DATA>"); | |
1529 } | |
1530 /* If the tag is invalid, skip it, thus no else here */ | |
1531 | |
1532 g_datalist_clear(&attribs); | |
1533 | |
1534 /* continue from the end of the tag */ | |
1535 last = end + 1; | |
1536 } | |
1537 | |
1538 /* append any remaining message data (without the > :-) */ | |
1539 if (last && *last) | |
1540 msg = g_string_append(msg, last); | |
1541 | |
1542 /* if we inserted any images in the binary section, append it */ | |
1543 if (oscar_id) { | |
1544 msg = g_string_append_len(msg, data->str, data->len); | |
1545 msg = g_string_append(msg, "</BINARY>"); | |
1546 } | |
1547 | |
1548 len = msg->len; | |
1549 buf = msg->str; | |
1550 g_string_free(msg, FALSE); | |
1551 g_string_free(data, TRUE); | |
1552 | |
1553 | |
1554 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
12216 | 1555 if (imflags & GAIM_MESSAGE_AUTO_RESP) |
8971 | 1556 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); |
1557 else | |
1558 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1559 | |
1560 g_free(buf); | |
1561 | |
1562 return ret; | |
1563 } | |
1564 | |
1565 struct ask_do_dir_im { | |
1566 char *who; | |
1567 GaimConnection *gc; | |
1568 }; | |
1569 | |
1570 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1571 g_free(data->who); | |
1572 g_free(data); | |
1573 } | |
1574 | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1575 struct dir_im_listen { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1576 struct oscar_direct_im *dim; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1577 const guchar *cookie; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1578 }; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1579 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1580 static void |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1581 oscar_direct_im_listen_cb(int listenfd, gpointer data) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1582 struct dir_im_listen *dim_l = data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1583 const char *ip; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1584 OscarData *od; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1585 struct oscar_direct_im *dim = dim_l->dim; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1586 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1587 od = (OscarData *)dim->gc->proto_data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1588 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1589 /* XXX: shouldn't this be your public IP or something? */ |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1590 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1591 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1592 if (listenfd >= 0) |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1593 dim->conn = aim_odc_initiate(od->sess, dim->name, listenfd, |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1594 gaim_network_ip_atoi(ip), |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1595 gaim_network_get_port_from_fd(listenfd), dim_l->cookie); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1596 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1597 if (dim->conn != NULL) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1598 char *tmp; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1599 GaimConversation *conv; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1600 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1601 od->direct_ims = g_slist_append(od->direct_ims, dim); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1602 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1603 oscar_callback, dim->conn); |
13239 | 1604 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, PEER_TYPE_DIRECTIM_ESTABLISHED, |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1605 gaim_odc_initiate, 0); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1606 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1607 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); |
13226 | 1608 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), |
1609 dim->name, ip, gaim_network_get_port_from_fd(listenfd)); | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1610 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1611 g_free(tmp); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1612 } else { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1613 gaim_notify_error(dim->gc, NULL, _("Unable to open Direct IM"), NULL); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1614 oscar_direct_im_destroy(od, dim); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1615 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1616 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1617 g_free(dim_l); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1618 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1619 |
8983 | 1620 /* this function is used to initiate a direct im session with someone. |
1621 * we start listening on a port and send a request. they either connect | |
1622 * or send some kind of reply. If they can't connect, they ask us to | |
1623 * connect to them, and so we do that. | |
1624 * | |
1625 * this function will also get called if the other side initiate's a direct | |
1626 * im and we try to connect and fail. in that case cookie will not be null. | |
1627 * | |
1628 * note that cookie is an 8 byte string that isn't NULL terminated | |
1629 */ | |
11159 | 1630 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie) { |
8971 | 1631 OscarData *od; |
1632 struct oscar_direct_im *dim; | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1633 struct dir_im_listen *dim_l; |
8971 | 1634 |
1635 od = (OscarData *)gc->proto_data; | |
1636 | |
8983 | 1637 dim = oscar_direct_im_find(od, who); |
8971 | 1638 if (dim) { |
12918
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1639 /* TODO: we need to somehow not do this if we're waiting |
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1640 for the gaim_network_listen_range() call to finish */ |
8971 | 1641 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
1642 oscar_direct_im_disconnect(od, dim); | |
1643 gaim_debug_info("oscar", | |
1644 "Gave up on old direct IM, trying again\n"); | |
1645 } else { | |
1646 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1647 return; |
8971 | 1648 } |
1649 } | |
1650 dim = g_new0(struct oscar_direct_im, 1); | |
1651 dim->gc = gc; | |
8983 | 1652 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1653 |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1654 dim_l = g_new0(struct dir_im_listen, 1); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1655 dim_l->dim = dim; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1656 dim_l->cookie = cookie; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1657 |
12918
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1658 if(!gaim_network_listen_range(5190, 5199, SOCK_STREAM, |
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1659 oscar_direct_im_listen_cb, dim_l)) { |
8971 | 1660 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); |
1661 oscar_direct_im_destroy(od, dim); | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1662 g_free(dim_l); |
8971 | 1663 } |
8983 | 1664 } |
1665 | |
1666 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1667 GaimConnection *gc = data->gc; | |
1668 | |
1669 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1670 g_free(data->who); | |
1671 g_free(data); | |
1672 return; | |
1673 } | |
1674 | |
1675 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1676 g_free(data->who); |
1677 g_free(data); | |
1678 } | |
1679 | |
1680 /* this is the right click menu cb thingy */ | |
9030 | 1681 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1682 | |
1683 GaimBuddy *buddy; | |
1684 GaimConnection *gc; | |
8971 | 1685 gchar *buf; |
9030 | 1686 struct ask_do_dir_im *data; |
1687 | |
1688 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1689 | |
1690 buddy = (GaimBuddy *) node; | |
1691 gc = gaim_account_get_connection(buddy->account); | |
1692 | |
1693 data = g_new0(struct ask_do_dir_im, 1); | |
1694 data->who = g_strdup(buddy->name); | |
8971 | 1695 data->gc = gc; |
9030 | 1696 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1697 buddy->name); | |
8971 | 1698 |
1699 gaim_request_action(gc, NULL, buf, | |
9030 | 1700 _("Because this reveals your IP address, it " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1701 "may be considered a privacy risk. Do you " |
9030 | 1702 "wish to continue?"), |
1703 0, data, 2, | |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1704 _("_Connect"), G_CALLBACK(oscar_direct_im), |
9030 | 1705 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); |
8971 | 1706 g_free(buf); |
1707 } | |
1708 | |
1709 /***************************************************************************** | |
1710 * End scary direct im stuff | |
1711 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1712 |
13231 | 1713 static void |
1714 oscar_callback(gpointer data, gint source, GaimInputCondition condition) | |
1715 { | |
13239 | 1716 OscarConnection *conn; |
1717 OscarSession *sess; | |
13231 | 1718 GaimConnection *gc; |
7283 | 1719 OscarData *od; |
11369 | 1720 |
13239 | 1721 conn = (OscarConnection *)data; |
13231 | 1722 sess = aim_conn_getsess(conn); |
1723 gc = sess ? sess->aux_data : NULL; | |
1724 | |
1725 if (gc == NULL) | |
1726 { | |
1727 gaim_debug_info("oscar", "oscar callback for closed connection (1).\n"); | |
2086 | 1728 return; |
1729 } | |
13226 | 1730 |
13231 | 1731 od = gc->proto_data; |
1732 if (od == NULL) | |
1733 { | |
11369 | 1734 gaim_debug_warning("oscar","NULL od in oscar_callback; conn closed?\n"); |
1735 return; | |
1736 } | |
2086 | 1737 |
13231 | 1738 if (!g_list_find(gaim_connections_get_all(), gc)) |
1739 { | |
13226 | 1740 /* oh boy. this is probably bad. i guess the only thing we |
2086 | 1741 * can really do is return? */ |
8660 | 1742 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1743 "oscar callback for closed connection (2).\n"); |
8660 | 1744 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1745 return; |
1746 } | |
1747 | |
13231 | 1748 /* We only care about READ conditions */ |
1749 if (!(condition & GAIM_INPUT_READ)) | |
1750 return; | |
1751 | |
1752 if (conn->type == AIM_CONN_TYPE_LISTENER) { | |
1753 gaim_debug_info("oscar", | |
1754 "got information on rendezvous listener\n"); | |
1755 if (aim_handlerendconnect(od->sess, conn) < 0) { | |
1756 gaim_debug_error("oscar", | |
1757 "connection error (rendezvous listener)\n"); | |
13262 | 1758 oscar_connection_destroy(od->sess, conn); |
13231 | 1759 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
1760 } | |
1761 } else { | |
1762 if (aim_get_command(od->sess, conn) >= 0) { | |
1763 aim_rxdispatch(od->sess); | |
1764 if (od->killme) { | |
1765 gaim_debug_error("oscar", "Waiting to be destroyed\n"); | |
1766 return; | |
2086 | 1767 } |
1768 } else { | |
13231 | 1769 if ((conn->type == AIM_CONN_TYPE_BOS) || |
1770 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) | |
1771 { | |
1772 gaim_debug_error("oscar", "Major connection error " | |
1773 "(invalid data was received on the oscar TCP stream).\n"); | |
1774 gaim_connection_error(gc, _("Disconnected.")); | |
1775 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
1776 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); | |
1777 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
1778 char *buf; | |
1779 gaim_debug_info("oscar", "Lost connection " | |
1780 "to chat room %s\n", cc->name); | |
1781 | |
1782 buf = g_strdup_printf(_("You have lost your connection " | |
1783 "to chat room %s."), cc->name); | |
1784 if (conv != NULL) | |
1785 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1786 else | |
1787 gaim_notify_error(gc, NULL, buf, NULL); | |
1788 g_free(buf); | |
1789 | |
1790 oscar_chat_kill(gc, cc); | |
1791 | |
1792 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { | |
1793 if (od->cnpa > 0) | |
1794 gaim_input_remove(od->cnpa); | |
1795 od->cnpa = 0; | |
1796 gaim_debug_info("oscar", | |
1797 "removing chatnav input watcher\n"); | |
1798 while (od->create_rooms) { | |
1799 struct create_room *cr = od->create_rooms->data; | |
1800 g_free(cr->name); | |
1801 od->create_rooms = | |
1802 g_slist_remove(od->create_rooms, cr); | |
1803 g_free(cr); | |
1804 gaim_notify_error(gc, NULL, | |
1805 _("Chat is currently unavailable"), | |
1806 NULL); | |
6029 | 1807 } |
13231 | 1808 gaim_debug_info("oscar","killing rendezvous connection\n"); |
13262 | 1809 oscar_connection_destroy(od->sess, conn); |
13231 | 1810 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
1811 if (od->paspa > 0) | |
1812 gaim_input_remove(od->paspa); | |
1813 od->paspa = 0; | |
1814 gaim_debug_info("oscar", | |
1815 "removing authconn input watcher\n"); | |
13262 | 1816 oscar_connection_destroy(od->sess, conn); |
13231 | 1817 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
1818 if (od->emlpa > 0) | |
1819 gaim_input_remove(od->emlpa); | |
1820 od->emlpa = 0; | |
1821 gaim_debug_info("oscar", | |
1822 "removing email input watcher\n"); | |
13262 | 1823 oscar_connection_destroy(od->sess, conn); |
13231 | 1824 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1825 if (od->icopa > 0) | |
1826 gaim_input_remove(od->icopa); | |
1827 od->icopa = 0; | |
1828 gaim_debug_info("oscar", | |
1829 "removing icon input watcher\n"); | |
13262 | 1830 oscar_connection_destroy(od->sess, conn); |
13231 | 1831 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
1832 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) | |
1833 gaim_odc_disconnect(od->sess, conn); | |
1834 gaim_debug_info("oscar","killing rendezvous connection\n"); | |
13262 | 1835 oscar_connection_destroy(od->sess, conn); |
2086 | 1836 } else { |
13231 | 1837 gaim_debug_error("oscar", |
1838 "holy crap! generic connection error! %hu\n", | |
1839 conn->type); | |
13262 | 1840 oscar_connection_destroy(od->sess, conn); |
2086 | 1841 } |
1842 } | |
1843 } | |
1844 } | |
1845 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1846 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1847 { |
5575 | 1848 GaimConnection *gc = data; |
7283 | 1849 OscarData *od; |
13239 | 1850 OscarSession *sess; |
1851 OscarConnection *conn; | |
2086 | 1852 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1853 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1854 close(source); |
1855 return; | |
1856 } | |
1857 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1858 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1859 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1860 |
4617 | 1861 od = gc->proto_data; |
1862 sess = od->sess; | |
2086 | 1863 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1864 conn->fd = source; |
2086 | 1865 |
1866 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1867 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1868 return; |
1869 } | |
1870 | |
1871 aim_conn_completeconnect(sess, conn); | |
4617 | 1872 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1873 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1874 | |
8660 | 1875 gaim_debug_info("oscar", |
7282 | 1876 "Screen name sent, waiting for response\n"); |
7283 | 1877 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1878 ck[1] = 0x65; |
2086 | 1879 } |
1880 | |
10444 | 1881 static void |
11837 | 1882 oscar_login(GaimAccount *account) |
10444 | 1883 { |
13239 | 1884 OscarSession *sess; |
1885 OscarConnection *conn; | |
5575 | 1886 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1887 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1888 |
8660 | 1889 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1890 |
8437 | 1891 if (!aim_snvalid(gaim_account_get_username(account))) { |
1892 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1893 buf = g_strdup_printf(_("Unable to login: Could not sign on as %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), gaim_account_get_username(account)); |
8437 | 1894 gaim_connection_error(gc, buf); |
1895 g_free(buf); | |
1896 } | |
1897 | |
9975 | 1898 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1899 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1900 } else { |
6622 | 1901 gc->flags |= GAIM_CONNECTION_HTML; |
1902 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1903 } |
5836 | 1904 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1905 |
13253 | 1906 sess = oscar_session_new(); |
7282 | 1907 /* |
11837 | 1908 * We need an immediate queue because we don't use a while-loop |
7282 | 1909 * to see if things need to be sent. |
1910 */ | |
2086 | 1911 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1912 od->sess = sess; |
2086 | 1913 sess->aux_data = gc; |
1914 | |
9935 | 1915 /* Connect to core Gaim signals */ |
10087 | 1916 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1917 |
13254 | 1918 conn = oscar_connection_new(sess, AIM_CONN_TYPE_AUTH); |
2086 | 1919 if (conn == NULL) { |
10444 | 1920 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1921 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1922 return; |
1923 } | |
1924 | |
4649 | 1925 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1926 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1927 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
13234 | 1928 aim_conn_addhandler(sess, conn, OSCAR_FAMILY_AUTH, OSCAR_SUBTYPE_AUTH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1929 |
1930 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
11338 | 1931 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER), |
1932 gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), | |
5575 | 1933 oscar_login_connect, gc) < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1934 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1935 return; |
1936 } | |
7282 | 1937 |
7283 | 1938 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1939 ck[0] = 0x5a; |
5575 | 1940 } |
1941 | |
1942 static void oscar_close(GaimConnection *gc) { | |
7283 | 1943 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1944 |
1945 while (od->oscar_chats) { | |
1946 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1947 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1948 gaim_input_remove(n->inpa); |
2086 | 1949 g_free(n->name); |
1950 g_free(n->show); | |
4617 | 1951 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1952 g_free(n); |
1953 } | |
4617 | 1954 while (od->direct_ims) { |
8971 | 1955 struct oscar_direct_im *n = od->direct_ims->data; |
1956 oscar_direct_im_destroy(od, n); | |
2086 | 1957 } |
4617 | 1958 /* BBB */ |
1959 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1960 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1961 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1962 gaim_xfer_cancel_local(xfer); |
3630 | 1963 } |
4804 | 1964 while (od->requesticon) { |
1965 char *sn = od->requesticon->data; | |
1966 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1967 free(sn); | |
1968 } | |
4738 | 1969 g_hash_table_destroy(od->buddyinfo); |
4617 | 1970 while (od->create_rooms) { |
1971 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1972 g_free(cr->name); |
4617 | 1973 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1974 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1975 } |
4617 | 1976 if (od->email) |
1977 g_free(od->email); | |
1978 if (od->newp) | |
1979 g_free(od->newp); | |
1980 if (od->oldp) | |
1981 g_free(od->oldp); | |
2086 | 1982 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1983 gaim_input_remove(gc->inpa); |
4617 | 1984 if (od->cnpa > 0) |
1985 gaim_input_remove(od->cnpa); | |
1986 if (od->paspa > 0) | |
1987 gaim_input_remove(od->paspa); | |
1988 if (od->emlpa > 0) | |
1989 gaim_input_remove(od->emlpa); | |
4804 | 1990 if (od->icopa > 0) |
1991 gaim_input_remove(od->icopa); | |
6907 | 1992 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1993 gaim_timeout_remove(od->icontimer); |
8341 | 1994 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1995 gaim_timeout_remove(od->getblisttimer); |
8341 | 1996 if (od->getinfotimer > 0) |
1997 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1998 gaim_prefs_disconnect_by_handle(gc); |
12663 | 1999 |
13253 | 2000 oscar_session_destroy(od->sess); |
4617 | 2001 od->sess = NULL; |
2086 | 2002 g_free(gc->proto_data); |
2003 gc->proto_data = NULL; | |
8660 | 2004 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 2005 } |
2006 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2007 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2008 GaimConnection *gc = data; |
7283 | 2009 OscarData *od; |
13239 | 2010 OscarSession *sess; |
2011 OscarConnection *bosconn; | |
2086 | 2012 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2013 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2014 close(source); |
2015 return; | |
2016 } | |
2017 | |
4617 | 2018 od = gc->proto_data; |
2019 sess = od->sess; | |
12653 | 2020 bosconn = od->conn; |
4366 | 2021 bosconn->fd = source; |
2086 | 2022 |
2023 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2024 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2025 return; |
2026 } | |
2027 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2028 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2029 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2030 |
2086 | 2031 aim_conn_completeconnect(sess, bosconn); |
4617 | 2032 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 2033 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2034 gaim_connection_update_progress(gc, |
7283 | 2035 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 2036 ck[4] = 0x61; |
2086 | 2037 } |
2038 | |
4617 | 2039 /* BBB */ |
4656 | 2040 /* |
12653 | 2041 * This little area in oscar.c is the nexus of file transfer code, |
2042 * so I wrote a little explanation of what happens. I am such a | |
4656 | 2043 * ninja. |
2044 * | |
2045 * The series of events for a file send is: | |
2046 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
12653 | 2047 * -User chooses a file and oscar_xfer_init is called. It establishes a |
2048 * listening socket, then asks the remote user to connect to us (and | |
4656 | 2049 * gives them the file name, port, IP, etc.) |
13239 | 2050 * -They connect to us and we send them an PEER_TYPE_PROMPT (this happens |
4656 | 2051 * in oscar_sendfile_estblsh) |
13239 | 2052 * -They send us an PEER_TYPE_ACK and then we start sending data |
2053 * -When we finish, they send us an PEER_TYPE_DONE and they close the | |
4656 | 2054 * connection. |
2055 * -We get drunk because file transfer kicks ass. | |
2056 * | |
2057 * The series of events for a file receive is: | |
2058 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
12653 | 2059 * -Gaim user selects file to name and location to save file to and |
4656 | 2060 * oscar_xfer_init is called |
2061 * -It connects to the remote user using the IP they gave us earlier | |
13239 | 2062 * -After connecting, they send us an PEER_TYPE_PROMPT. In reply, we send |
2063 * them an PEER_TYPE_ACK. | |
4656 | 2064 * -They begin to send us lots of raw data. |
13239 | 2065 * -When they finish sending data we send an PEER_TYPE_DONE and then close |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
2066 * the connection. |
11369 | 2067 * |
2068 * Update August 2005: | |
2069 * The series of events for transfers has been seriously complicated by the addition | |
2070 * of transfer redirects and proxied connections. I could throw a whole lot of words | |
2071 * at trying to explain things here, but it probably wouldn't do much good. To get | |
2072 * a better idea of what happens, take a look at the diagrams and documentation | |
2073 * from my Summer of Code project. -- Jonathan Clark | |
4656 | 2074 */ |
2075 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
11369 | 2076 static void oscar_xfer_proxylogin(gpointer data, gint source, GaimInputCondition condition); |
2077 static void oscar_send_file_request(GaimXfer *xfer); | |
4656 | 2078 |
8446 | 2079 /* |
2080 * Miscellaneous xfer functions | |
2081 */ | |
13234 | 2082 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const guint8 *ck) |
4656 | 2083 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2084 GaimXfer *xfer; |
13252 | 2085 PeerConnection *peer_connection; |
4656 | 2086 |
2087 while (fts) { | |
2088 xfer = fts->data; | |
13252 | 2089 peer_connection = xfer->data; |
2090 | |
2091 if (peer_connection && !memcmp(ck, peer_connection->cookie, 8)) | |
4656 | 2092 return xfer; |
2093 | |
2094 fts = g_slist_next(fts); | |
2095 } | |
2096 | |
2097 return NULL; | |
2098 } | |
2099 | |
13239 | 2100 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, OscarConnection *conn) |
4656 | 2101 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2102 GaimXfer *xfer; |
13252 | 2103 PeerConnection *peer_connection; |
4656 | 2104 |
2105 while (fts) { | |
2106 xfer = fts->data; | |
13252 | 2107 peer_connection = xfer->data; |
2108 | |
2109 if (peer_connection && (conn == peer_connection->conn)) | |
4656 | 2110 return xfer; |
2111 | |
2112 fts = g_slist_next(fts); | |
2113 } | |
2114 | |
2115 return NULL; | |
2116 } | |
2117 | |
11369 | 2118 /* |
2119 * We're done sending/receiving raw data through the connection. | |
2120 * If we're the receiver, send an OFT header with the bytes received | |
2121 * filled in to indicate this party's over. | |
2122 */ | |
8446 | 2123 static void oscar_xfer_end(GaimXfer *xfer) |
2124 { | |
13252 | 2125 PeerConnection *peer_connection = xfer->data; |
2126 GaimConnection *gc = peer_connection->sess->aux_data; | |
8446 | 2127 OscarData *od = gc->proto_data; |
2128 | |
8660 | 2129 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 2130 |
2131 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
13252 | 2132 peer_connection->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); |
2133 aim_oft_sendheader(peer_connection->sess, PEER_TYPE_DONE, peer_connection); | |
2134 } | |
2135 | |
13262 | 2136 oscar_connection_destroy(peer_connection->sess, peer_connection->conn); |
13252 | 2137 aim_oft_destroyinfo(peer_connection); |
8446 | 2138 xfer->data = NULL; |
2139 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2140 } | |
2141 | |
2142 /* | |
2143 * xfer functions used when receiving files | |
2144 */ | |
2145 | |
11084 | 2146 /* |
11369 | 2147 * This is a gaim timeout callback called X milliseconds after a connection is attempted |
2148 * By this point, we've lost faith in the connection method we just tried and want to | |
2149 * try something new. Hopefully, that new connection method will be more successful, | |
2150 * otherwise, we'll end up here again and again until the connection is successful | |
2151 * or we've tried every method... if that happens we just throw our hands up | |
2152 * and inform the user of his bad karma. | |
2153 */ | |
2154 static gboolean oscar_xfer_ip_timeout(gpointer data) { | |
11084 | 2155 GaimXfer *xfer; |
13074 | 2156 GaimAccount *account; |
13252 | 2157 PeerConnection *peer_connection; |
11084 | 2158 char *msg = NULL; |
12653 | 2159 |
11369 | 2160 gaim_debug_info("oscar","AAA - in oscar_xfer_ip_timeout\n"); |
2161 | |
11084 | 2162 xfer = (GaimXfer*) data; |
13074 | 2163 account = gaim_xfer_get_account(xfer); |
11084 | 2164 if(xfer->data) { |
13252 | 2165 peer_connection = (PeerConnection*) xfer->data; |
12653 | 2166 |
11084 | 2167 /* Check to see if the clientip has produced any results */ |
13252 | 2168 if(!peer_connection->success) { |
11369 | 2169 /* This connection has worn out its welcome. Goodbye. */ |
13252 | 2170 if(peer_connection->conn) { |
2171 close(peer_connection->conn->fd); | |
13262 | 2172 oscar_connection_destroy(peer_connection->sess, peer_connection->conn); |
11369 | 2173 } |
12653 | 2174 |
13252 | 2175 if(peer_connection->method == AIM_XFER_DIRECT || peer_connection->method == AIM_XFER_REDIR) { |
11369 | 2176 /* If (we're currently using the verified ip) |
2177 * In case clientip & verifiedip are the same, | |
2178 * we must prevent an infinite loop */ | |
13252 | 2179 if(xfer->remote_ip && peer_connection->verifiedip |
2180 && g_ascii_strcasecmp(xfer->remote_ip, peer_connection->verifiedip) == 0 | |
2181 && g_ascii_strcasecmp(peer_connection->clientip, peer_connection->verifiedip) != 0 ) | |
11369 | 2182 { |
2183 /* The verifiedip timed out */ | |
13252 | 2184 if (peer_connection->method == AIM_XFER_DIRECT && !peer_connection->redir_attempted) |
13071 | 2185 { |
11369 | 2186 /* clientip & verifiedip failed, request a redirect |
13071 | 2187 * that is, we want the sender to connect to us |
2188 * | |
2189 * Above, we checked if we had previously attempted a connection | |
2190 * redirect to prevent a conflict with the joscar library | |
2191 */ | |
12653 | 2192 |
11369 | 2193 /* Let the user not to lose hope quite yet*/ |
2194 msg = g_strdup_printf(_("Attempting connection redirect...")); | |
2195 gaim_xfer_conversation_write(xfer, msg, FALSE); | |
2196 g_free(msg); | |
12653 | 2197 |
11369 | 2198 gaim_timeout_add(FT_REDIR_TIMEOUT, |
2199 oscar_xfer_ip_timeout, xfer); | |
13252 | 2200 peer_connection->method = AIM_XFER_REDIR; |
2201 peer_connection->redir_attempted = TRUE; | |
2202 g_free(peer_connection->proxyip); | |
2203 peer_connection->proxyip = NULL; | |
2204 peer_connection->clientip = g_strdup( gaim_network_get_my_ip( | |
2205 peer_connection->conn ? peer_connection->conn->fd : -1)); | |
11369 | 2206 oscar_xfer_init_send(xfer); |
2207 } else { | |
2208 /* clientip, verifiedip, and redirect all failed. */ | |
2209 gaim_debug_info("oscar", | |
2210 "redirect timed out. requesting stg3 proxy\n"); | |
12653 | 2211 |
11369 | 2212 /* Kill our listener */ |
2213 gaim_input_remove(xfer->watcher); | |
13262 | 2214 oscar_connection_destroy(peer_connection->sess, peer_connection->conn); |
12653 | 2215 |
11369 | 2216 /* Instead of failing here, request a stage 3 proxy */ |
13252 | 2217 g_free(peer_connection->clientip); |
2218 g_free(peer_connection->verifiedip); | |
2219 peer_connection->clientip = NULL; | |
2220 peer_connection->verifiedip = NULL; | |
2221 peer_connection->port = 0; | |
2222 peer_connection->conn->type = AIM_CONN_TYPE_RENDEZVOUS; | |
2223 peer_connection->method = AIM_XFER_PROXY; | |
2224 peer_connection->stage = AIM_XFER_PROXY_STG3; | |
2225 | |
2226 aim_im_sendch2_sendfile_ask(peer_connection->sess, peer_connection); | |
11369 | 2227 } |
2228 } else { | |
2229 /* clientip timed out, now try verifiedip */ | |
2230 g_free(xfer->remote_ip); | |
13252 | 2231 xfer->remote_ip = g_strdup(peer_connection->verifiedip); |
11369 | 2232 gaim_debug_info("oscar","attempting connection using verifiedip\n"); |
2233 oscar_xfer_init_recv(xfer); | |
2234 } | |
13252 | 2235 } else if(peer_connection->method == AIM_XFER_PROXY) { |
11369 | 2236 /* proxyip timed out |
2237 * Yes, it's a bit odd to ask the user to enable proxied file transfers | |
2238 * when it's a proxied transfer that timed out. It is possible that a | |
13071 | 2239 * stage 1 or 2 proxied transfer might work when a stage 3 will not. */ |
13074 | 2240 msg = g_strdup_printf(_("Transfer of file %s timed out.\n Try enabling proxy servers for file transfers in Accounts->%s->Edit Account->Advanced."), |
2241 gaim_xfer_get_filename(xfer), gaim_account_get_username(account)); | |
11369 | 2242 gaim_xfer_conversation_write(xfer, msg, TRUE); |
2243 g_free(msg); | |
2244 gaim_xfer_cancel_local(xfer); | |
13252 | 2245 if(peer_connection->xfer_reffed) { |
2246 peer_connection->xfer_reffed = FALSE; | |
11369 | 2247 gaim_xfer_unref(xfer); |
2248 } | |
2249 } else { | |
2250 gaim_debug_warning("oscar","unknown xfer method encountered in timout\n"); | |
2251 } | |
11214 | 2252 } else { |
13252 | 2253 if(peer_connection->xfer_reffed) { |
2254 peer_connection->xfer_reffed = FALSE; | |
11369 | 2255 gaim_xfer_unref(xfer); |
2256 } | |
2257 gaim_debug_info("oscar","connection successful; timeout off\n"); | |
11084 | 2258 } |
11369 | 2259 } else { |
2260 gaim_debug_info("oscar","transfer already done; nothing to do\n"); | |
11084 | 2261 } |
2262 return FALSE; | |
2263 } | |
2264 | |
2265 /* | |
11369 | 2266 * Connect to another client or a file transfer proxy server. |
2267 * Though this function has traditionally only been used during file receives, | |
2268 * it is now called to make any sort of file transfer connection via gaim_proxy_connect. | |
11084 | 2269 */ |
8446 | 2270 static void oscar_xfer_init_recv(GaimXfer *xfer) |
2271 { | |
13252 | 2272 PeerConnection *peer_connection; |
13239 | 2273 PeerProxyInfo *proxy_info; |
11369 | 2274 GaimConnection *gc; |
2275 OscarData *od; | |
2276 GaimInputFunction nextstop_cb; | |
2277 int rc; | |
2278 | |
2279 g_return_if_fail(xfer != NULL); | |
2280 g_return_if_fail(xfer->data != NULL); | |
2281 | |
13252 | 2282 peer_connection = xfer->data; |
2283 proxy_info = peer_connection->proxy_info; | |
2284 gc = peer_connection->sess->aux_data; | |
11369 | 2285 od = gc->proto_data; |
2286 | |
2287 gaim_debug_info("oscar", "AAA - in oscar_xfer_init_recv\n"); | |
13074 | 2288 |
11084 | 2289 /* Start a timer for this ip address |
11369 | 2290 * If the clientip fails, try the verifiedip |
2291 * If that fails, wait for the transfer to redirect | |
2292 * This xfer reference will be released in oscar_xfer_ip_timeout */ | |
13252 | 2293 if(!peer_connection->xfer_reffed) { |
2294 peer_connection->xfer_reffed = TRUE; | |
11084 | 2295 gaim_xfer_ref(xfer); |
11369 | 2296 } |
13074 | 2297 |
13252 | 2298 if(peer_connection->method != AIM_XFER_PROXY) { |
11369 | 2299 /* If (we're currently using the verified ip) |
2300 * In case clientip & verifiedip are the same, we must prevent an infinite loop */ | |
13252 | 2301 if(xfer->remote_ip && peer_connection->verifiedip |
2302 && g_ascii_strcasecmp(xfer->remote_ip, peer_connection->verifiedip) == 0 | |
2303 && g_ascii_strcasecmp(peer_connection->clientip, peer_connection->verifiedip) != 0 ) { | |
11369 | 2304 gaim_timeout_add(FT_VERIFIEDIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); |
11084 | 2305 } else { |
11369 | 2306 gaim_timeout_add(FT_CLIENTIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); |
11084 | 2307 } |
11369 | 2308 } else { |
2309 gaim_timeout_add(FT_PROXYIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); | |
2310 } | |
13254 | 2311 peer_connection->conn = oscar_connection_new(od->sess, AIM_CONN_TYPE_RENDEZVOUS); |
13074 | 2312 |
11369 | 2313 /* If we're routing this transfer through a AOL proxy server, do the special login |
2314 * before telling the other client we're ready for action. | |
2315 * Note, firststop_cb is the first function called after gaim has made a connection | |
2316 * Also, the connection type is changed until the proxy login is complete */ | |
13252 | 2317 if(peer_connection->method == AIM_XFER_PROXY) { |
11369 | 2318 if(proxy_info) |
13252 | 2319 proxy_info->conn = peer_connection->conn; |
11369 | 2320 else { |
2321 gaim_debug_warning("oscar","NULL proxy_info\n"); | |
2322 gaim_xfer_cancel_local(xfer); | |
2323 } | |
2324 nextstop_cb = oscar_xfer_proxylogin; | |
13252 | 2325 peer_connection->conn->type = AIM_CONN_TYPE_RENDEZVOUS_PROXY; |
11369 | 2326 } else { |
2327 nextstop_cb = oscar_sendfile_connected; | |
2328 } | |
13074 | 2329 |
13252 | 2330 if (peer_connection->conn) { |
2331 peer_connection->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2332 aim_conn_addhandler(od->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_PROMPT, | |
11369 | 2333 oscar_sendfile_prompt, 0); |
2334 rc = gaim_proxy_connect(gaim_connection_get_account(gc), | |
2335 xfer->remote_ip, xfer->remote_port, nextstop_cb, xfer); | |
2336 if (rc == -1) { | |
10654 | 2337 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2338 _("Unable to establish file descriptor.")); |
2339 gaim_xfer_cancel_local(xfer); | |
2340 } | |
2341 } else { | |
10654 | 2342 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2343 _("Unable to create new connection.")); |
2344 gaim_xfer_cancel_local(xfer); | |
2345 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2346 } | |
11369 | 2347 } |
2348 | |
2349 /* | |
2350 * "Never mind. This transfer wasn't such a great idea after all." | |
2351 */ | |
8446 | 2352 static void oscar_xfer_cancel_recv(GaimXfer *xfer) |
2353 { | |
13252 | 2354 PeerConnection *peer_connection = xfer->data; |
2355 GaimConnection *gc = peer_connection->sess->aux_data; | |
11369 | 2356 OscarData *od = gc->proto_data; |
8446 | 2357 |
8660 | 2358 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2359 |
9771 | 2360 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
13252 | 2361 aim_im_sendch2_sendfile_cancel(peer_connection->sess, peer_connection); |
2362 | |
13262 | 2363 oscar_connection_destroy(peer_connection->sess, peer_connection->conn); |
13252 | 2364 aim_oft_destroyinfo(peer_connection); |
8446 | 2365 xfer->data = NULL; |
2366 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2367 } | |
2368 | |
11369 | 2369 /* |
2370 * Called after every data packet we receive | |
2371 */ | |
11159 | 2372 static void oscar_xfer_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2373 { |
13252 | 2374 PeerConnection *peer_connection = xfer->data; |
8446 | 2375 |
2376 /* Update our rolling checksum. Like Walmart, yo. */ | |
13252 | 2377 peer_connection->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, peer_connection->fh.recvcsum); |
8446 | 2378 } |
2379 | |
2380 /* | |
11369 | 2381 * xfer functions used for proxied file transfers |
2382 */ | |
2383 | |
2384 /* | |
2385 * Called by oscar_send_proxylogin_cb when we receive a ready packet | |
2386 * BBB | |
2387 */ | |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
2388 static void oscar_xfer_proxylogin_ready(GaimXfer *xfer, gint fd) { |
13252 | 2389 PeerConnection *peer_connection; |
13239 | 2390 PeerProxyInfo *proxy_info; |
12653 | 2391 |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2392 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2393 fcntl(fd, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2394 |
11369 | 2395 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_ready\n"); |
13252 | 2396 if (!(peer_connection = xfer->data)) { |
2397 gaim_debug_warning("oscar","NULL peer_connection; aborting\n"); | |
11369 | 2398 gaim_xfer_cancel_local(xfer); |
2399 return; | |
2400 } | |
13252 | 2401 if (!(proxy_info = peer_connection->proxy_info)) { |
11369 | 2402 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); |
2403 gaim_xfer_cancel_local(xfer); | |
2404 return; | |
2405 } | |
12653 | 2406 |
11369 | 2407 /* Remove the rv proxy watcher and put the connection type back the way we found it */ |
2408 gaim_input_remove(xfer->watcher); | |
2409 xfer->watcher = 0; | |
13252 | 2410 peer_connection->conn->type = AIM_CONN_TYPE_RENDEZVOUS; |
2411 | |
2412 if(peer_connection->send_or_recv == AIM_XFER_SEND) { | |
2413 | |
2414 if(peer_connection->stage == AIM_XFER_PROXY_STG2) { | |
2415 aim_im_sendch2_sendfile_accept(peer_connection->sess, peer_connection); | |
12653 | 2416 |
11369 | 2417 /* For stage 2, both file headers are filled in */ |
13252 | 2418 memcpy(&peer_connection->fh.bcookie, peer_connection->cookie, 8); |
11369 | 2419 } |
12653 | 2420 |
11369 | 2421 /* The following is taken from oscar_sendfile_estblsh */ |
13252 | 2422 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_ACK, |
11369 | 2423 oscar_sendfile_ack, 0); |
13252 | 2424 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_DONE, |
11369 | 2425 oscar_sendfile_done, 0); |
13252 | 2426 xfer->watcher = gaim_input_add(peer_connection->conn->fd, GAIM_INPUT_READ, oscar_callback, |
2427 peer_connection->conn); | |
12653 | 2428 |
11369 | 2429 /* Inform the other user that we are connected and ready to transfer */ |
13252 | 2430 aim_oft_sendheader(peer_connection->sess, PEER_TYPE_PROMPT, peer_connection); |
2431 } else if(peer_connection->send_or_recv == AIM_XFER_RECV) { | |
11369 | 2432 oscar_sendfile_connected(xfer, fd, GAIM_INPUT_READ); |
2433 } else { | |
2434 gaim_debug_warning("oscar","no value for send_or_recv; aborting transfer\n"); | |
2435 gaim_xfer_cancel_local(xfer); | |
12653 | 2436 } |
11369 | 2437 } |
2438 | |
2439 /* | |
2440 * Called by oscar_sendfile_proxylogin_cb when we receive an ack packet in reply to an init_send | |
2441 * BBB | |
2442 */ | |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
2443 static void oscar_xfer_proxylogin_ack(GaimXfer *xfer) { |
13252 | 2444 PeerConnection *peer_connection; |
13239 | 2445 PeerProxyInfo *proxy_info; |
12653 | 2446 |
11369 | 2447 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_ack\n"); |
13252 | 2448 if (!(peer_connection = xfer->data)) { |
2449 gaim_debug_warning("oscar","NULL peer_connection; aborting\n"); | |
11369 | 2450 gaim_xfer_cancel_local(xfer); |
2451 return; | |
2452 } | |
13252 | 2453 if (!(proxy_info = peer_connection->proxy_info)) { |
11369 | 2454 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); |
2455 gaim_xfer_cancel_local(xfer); | |
2456 return; | |
2457 } | |
12653 | 2458 |
11369 | 2459 /* Use the proxy "port" we just ACK-quired (hah) so that the proxy will love us */ |
13252 | 2460 peer_connection->port = proxy_info->port; |
2461 peer_connection->proxyip = g_strdup(proxy_info->ip); | |
11369 | 2462 gaim_debug_info("oscar","received client ip and port: %s:%d\n", |
13252 | 2463 peer_connection->proxyip, peer_connection->port); |
2464 | |
2465 if(peer_connection->send_or_recv == AIM_XFER_SEND) { | |
11369 | 2466 oscar_send_file_request(xfer); |
13252 | 2467 } else if(peer_connection->send_or_recv == AIM_XFER_RECV) { |
2468 strncpy(peer_connection->fh.name, xfer->filename, 64); | |
2469 peer_connection->fh.name[63] = '\0'; | |
2470 peer_connection->fh.totsize = gaim_xfer_get_size(xfer); | |
2471 peer_connection->fh.size = gaim_xfer_get_size(xfer); | |
12653 | 2472 |
11369 | 2473 /* Calculating the checksum can take a very long time for large files */ |
2474 gaim_debug_info("oscar","calculating file checksum\n"); | |
13252 | 2475 peer_connection->fh.checksum = aim_oft_checksum_file(xfer->local_filename); |
11369 | 2476 gaim_debug_info("oscar","checksum calculated\n"); |
12653 | 2477 |
13252 | 2478 aim_im_sendch2_sendfile_ask(peer_connection->sess, peer_connection); |
11369 | 2479 } else { |
2480 gaim_debug_warning("oscar","no value for send_or_recv; aborting transfer\n"); | |
2481 gaim_xfer_cancel_local(xfer); | |
2482 } | |
2483 } | |
2484 | |
2485 /* | |
2486 * This is called whenever we receive data while negotiating a rendezvous proxy connection | |
2487 * BBB | |
2488 */ | |
2489 static void oscar_xfer_proxylogin_cb(gpointer data, gint source, GaimInputCondition condition) { | |
2490 GaimXfer *xfer; | |
13252 | 2491 PeerConnection *peer_connection; |
12653 | 2492 |
11369 | 2493 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_cb\n"); |
2494 if (!(xfer = data)) { | |
2495 gaim_debug_warning("oscar","NULL xfer; aborting\n"); | |
2496 gaim_xfer_cancel_local(xfer); | |
2497 return; | |
12653 | 2498 } |
13252 | 2499 if (!(peer_connection = xfer->data)) { |
2500 gaim_debug_warning("oscar","NULL peer_connection; aborting\n"); | |
11369 | 2501 gaim_xfer_cancel_local(xfer); |
2502 return; | |
2503 } | |
12653 | 2504 |
13252 | 2505 if( (peer_connection->proxy_info = aim_rv_proxy_read(peer_connection->sess, peer_connection->conn)) ) { |
2506 | |
2507 switch(peer_connection->proxy_info->cmd_type) { | |
11369 | 2508 case AIM_RV_PROXY_READY: |
2509 oscar_xfer_proxylogin_ready(xfer, source); | |
13252 | 2510 free(peer_connection->proxy_info); |
2511 peer_connection->proxy_info = NULL; | |
11369 | 2512 break; |
2513 case AIM_RV_PROXY_ACK: | |
2514 oscar_xfer_proxylogin_ack(xfer); | |
13252 | 2515 free(peer_connection->proxy_info); |
2516 peer_connection->proxy_info = NULL; | |
11369 | 2517 break; |
2518 case AIM_RV_PROXY_ERROR: | |
2519 gaim_debug_info("oscar","error logging into rendezvous proxy; err code is %x\n", | |
13252 | 2520 peer_connection->proxy_info->err_code); |
11369 | 2521 gaim_input_remove(xfer->watcher); |
2522 xfer->watcher = 0; | |
13252 | 2523 free(peer_connection->proxy_info); |
2524 peer_connection->proxy_info = NULL; | |
11369 | 2525 gaim_xfer_cancel_remote(xfer); |
2526 break; | |
2527 /* We should never get here */ | |
2528 default: | |
2529 gaim_debug_info("oscar","proxylogin switch defaulted unexpectedly\n"); | |
2530 } | |
2531 } else { | |
2532 gaim_debug_info("oscar","could not read rv proxy packet\n"); | |
2533 } | |
2534 } | |
2535 | |
2536 /* | |
2537 * Called to send necessary login data to a rendezvous proxy server once we're connected | |
2538 * Takes xfer is data and fd as source | |
2539 */ | |
2540 static void oscar_xfer_proxylogin(gpointer data, gint source, GaimInputCondition condition) | |
2541 { | |
2542 GaimXfer *xfer; | |
13252 | 2543 PeerConnection *peer_connection; |
13239 | 2544 PeerProxyInfo *proxy_info; |
11369 | 2545 int err; |
12653 | 2546 |
11369 | 2547 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin\n"); |
2548 if (!(xfer = data)) { | |
2549 gaim_debug_warning("oscar","NULL xfer; aborting\n"); | |
2550 gaim_xfer_cancel_local(xfer); | |
2551 return; | |
12653 | 2552 } |
13252 | 2553 if (!(peer_connection = xfer->data)) { |
2554 gaim_debug_warning("oscar","NULL peer_connection; aborting\n"); | |
11369 | 2555 gaim_xfer_cancel_local(xfer); |
2556 return; | |
2557 } | |
13252 | 2558 if (!(proxy_info = peer_connection->proxy_info)) { |
11369 | 2559 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); |
2560 gaim_xfer_cancel_local(xfer); | |
2561 return; | |
2562 } | |
13252 | 2563 if(peer_connection->success) { |
11369 | 2564 gaim_debug_info("oscar","connection already successful, ignoring 2nd conn\n"); |
2565 return; | |
2566 } | |
2567 | |
2568 xfer->fd = source; | |
13252 | 2569 peer_connection->conn->fd = source; |
2570 | |
2571 proxy_info->conn = peer_connection->conn; | |
11369 | 2572 proxy_info->flags = AIM_RV_PROXY_CLIENT_FLAGS; |
13252 | 2573 memcpy(proxy_info->cookie, peer_connection->cookie, 8); |
2574 | |
2575 if(peer_connection->send_or_recv == AIM_XFER_SEND) { | |
2576 if(peer_connection->stage == AIM_XFER_PROXY_STG1 || peer_connection->stage == AIM_XFER_PROXY_STG3) { | |
11369 | 2577 gaim_debug_info("oscar","sending INIT SEND for stage 1/3 rv proxied send\n"); |
2578 if( (err = aim_rv_proxy_init_send(proxy_info)) ) { | |
2579 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2580 _("Unable to log into file transfer proxy.")); | |
2581 gaim_debug_info("oscar", "error while sending INIT SEND rv proxy packet: %s\n", | |
2582 strerror(err)); | |
2583 gaim_xfer_cancel_local(xfer); | |
2584 } | |
13252 | 2585 } else if(peer_connection->stage == AIM_XFER_PROXY_STG2) { |
11369 | 2586 gaim_debug_info("oscar","sending INIT RECV for stage 2 rv proxied send\n"); |
2587 if( (err = aim_rv_proxy_init_recv(proxy_info)) ) { | |
2588 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2589 _("Unable to log into file transfer proxy.")); | |
2590 gaim_debug_info("oscar", "error while sending INIT RECV rv proxy packet: %s\n", | |
2591 strerror(err)); | |
2592 gaim_xfer_cancel_local(xfer); | |
2593 } | |
2594 } else { | |
2595 gaim_debug_warning("oscar","no proxy type specified; aborting transfer\n"); | |
2596 gaim_xfer_cancel_local(xfer); | |
2597 } | |
13252 | 2598 } else if(peer_connection->send_or_recv == AIM_XFER_RECV) { |
2599 if(peer_connection->stage == AIM_XFER_PROXY_STG2) { | |
11369 | 2600 gaim_debug_info("oscar","sending INIT SEND for stage 2 rv proxied receive\n"); |
2601 if( (err = aim_rv_proxy_init_send(proxy_info)) ) { | |
2602 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2603 _("Unable to log into file transfer proxy.")); | |
2604 gaim_debug_info("oscar", "error while sending INIT SEND rv proxy packet: %s\n", | |
2605 strerror(err)); | |
2606 gaim_xfer_cancel_local(xfer); | |
2607 } | |
13252 | 2608 } else if(peer_connection->stage == AIM_XFER_PROXY_STG1 |
2609 || peer_connection->stage == AIM_XFER_PROXY_STG3) { | |
11369 | 2610 gaim_debug_info("oscar","sending INIT RECV for stage 1/3 rv proxied receive\n"); |
2611 if( (err = aim_rv_proxy_init_recv(proxy_info)) ) { | |
2612 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2613 _("Unable to log into file transfer proxy.")); | |
2614 gaim_debug_info("oscar", "error while sending INIT RECV rv proxy packet: %s\n", | |
2615 strerror(err)); | |
2616 gaim_xfer_cancel_local(xfer); | |
2617 } | |
2618 } else { | |
2619 gaim_debug_warning("oscar","no proxy type specified; aborting transfer\n"); | |
2620 gaim_xfer_cancel_local(xfer); | |
2621 } | |
2622 } else { | |
2623 gaim_debug_warning("oscar","no send_or_recv value specified; aborting\n"); | |
2624 gaim_xfer_cancel_local(xfer); | |
2625 } | |
2626 free(proxy_info); | |
13252 | 2627 peer_connection->proxy_info = NULL; |
12653 | 2628 |
11369 | 2629 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_xfer_proxylogin_cb, xfer); |
2630 } | |
2631 | |
12653 | 2632 |
11369 | 2633 /* |
8446 | 2634 * xfer functions used when sending files |
2635 */ | |
2636 | |
11369 | 2637 /* |
2638 * Send a request to another client notifying them we want to sent a file | |
2639 */ | |
2640 static void oscar_send_file_request(GaimXfer *xfer) | |
2641 { | |
13252 | 2642 PeerConnection *peer_connection = xfer->data; |
2643 GaimConnection *gc = peer_connection->sess->aux_data; | |
12653 | 2644 OscarData *od = gc->proto_data; |
2645 | |
11369 | 2646 gaim_debug_info("oscar", "AAA - in oscar_send_file_request\n"); |
12653 | 2647 |
13252 | 2648 if (peer_connection->conn) { |
11369 | 2649 xfer->filename = g_path_get_basename(xfer->local_filename); |
13252 | 2650 strncpy(peer_connection->fh.name, xfer->filename, 64); |
2651 peer_connection->fh.name[63] = '\0'; | |
2652 peer_connection->fh.totsize = gaim_xfer_get_size(xfer); | |
2653 peer_connection->fh.size = gaim_xfer_get_size(xfer); | |
12653 | 2654 |
11369 | 2655 /* Calculating the checksum can take a very long time for large files */ |
2656 gaim_debug_info("oscar","calculating file checksum\n"); | |
13252 | 2657 peer_connection->fh.checksum = aim_oft_checksum_file(xfer->local_filename); |
11369 | 2658 gaim_debug_info("oscar","checksum calculated\n"); |
2659 | |
13252 | 2660 memcpy(&peer_connection->fh.bcookie, peer_connection->cookie, 8); |
2661 | |
2662 aim_im_sendch2_sendfile_ask(od->sess, peer_connection); | |
2663 aim_conn_addhandler(od->sess, peer_connection->conn, AIM_CB_FAM_OFT, | |
13239 | 2664 PEER_TYPE_ESTABLISHED, oscar_sendfile_estblsh, 0); |
11369 | 2665 } else { |
2666 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2667 _("Unable to establish listener socket or no AOL proxy connection present.")); | |
2668 gaim_xfer_cancel_local(xfer); | |
2669 } | |
2670 } | |
2671 | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2672 static void |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2673 oscar_xfer_init_listen_cb(int listenfd, gpointer data) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2674 GaimXfer *xfer = data; |
13252 | 2675 PeerConnection *peer_connection; |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2676 GaimConnection *gc; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2677 OscarData *od; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2678 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2679 /* If the ft was canceled before we get here, don't continue */ |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2680 if(gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2681 gaim_xfer_unref(xfer); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2682 return; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2683 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2684 |
13252 | 2685 peer_connection = xfer->data; |
2686 gc = peer_connection->sess->aux_data; | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2687 od = gc->proto_data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2688 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2689 if (listenfd < 0) { |
8446 | 2690 gaim_xfer_cancel_local(xfer); |
2691 return; | |
2692 } | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2693 |
8446 | 2694 xfer->local_port = gaim_network_get_port_from_fd(listenfd); |
13252 | 2695 peer_connection->port = xfer->local_port; |
2696 if (aim_sendfile_listen(od->sess, peer_connection, listenfd) != 0) { | |
8446 | 2697 gaim_xfer_cancel_local(xfer); |
2698 return; | |
2699 } | |
13226 | 2700 gaim_debug_misc("oscar", "port is %hu, ip is %s\n", |
13252 | 2701 xfer->local_port, peer_connection->clientip); |
2702 | |
2703 if(peer_connection->conn) | |
2704 xfer->watcher = gaim_input_add(peer_connection->conn->fd, GAIM_INPUT_READ, oscar_callback, | |
2705 peer_connection->conn); | |
11369 | 2706 else |
13252 | 2707 gaim_debug_info("oscar","NULL peer_connection->conn; not adding watcher\n"); |
12653 | 2708 |
11369 | 2709 oscar_send_file_request(xfer); |
2710 } | |
2711 | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2712 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2713 /* |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2714 * Opens a listener socket in preparation for sending a file |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2715 * This is not called if we are using a rendezvous proxy server |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2716 */ |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2717 static void oscar_xfer_init_send(GaimXfer *xfer) |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2718 { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2719 gaim_debug_info("oscar", "AAA - in oscar_xfer_init_send\n"); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2720 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2721 gaim_xfer_ref(xfer); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2722 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2723 /* Create a listening socket and an associated libfaim conn */ |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2724 if (!gaim_network_listen_range(5190, 5199, SOCK_STREAM, |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2725 oscar_xfer_init_listen_cb, xfer)) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2726 gaim_xfer_unref(xfer); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2727 gaim_xfer_cancel_local(xfer); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2728 return; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2729 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2730 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2731 |
11369 | 2732 /* |
2733 * "On second thought, you don't deserve this file." | |
2734 */ | |
8446 | 2735 static void oscar_xfer_cancel_send(GaimXfer *xfer) |
2736 { | |
13252 | 2737 PeerConnection *peer_connection = xfer->data; |
2738 GaimConnection *gc = peer_connection->sess->aux_data; | |
8446 | 2739 OscarData *od = gc->proto_data; |
2740 | |
8660 | 2741 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2742 |
9771 | 2743 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
13252 | 2744 aim_im_sendch2_sendfile_cancel(peer_connection->sess, peer_connection); |
8446 | 2745 |
11369 | 2746 /* Added a few sanity checks to prevent segfaulting */ |
13252 | 2747 if(peer_connection) { |
2748 if(peer_connection->sess && peer_connection->conn) | |
13262 | 2749 oscar_connection_destroy(peer_connection->sess, peer_connection->conn); |
13252 | 2750 aim_oft_destroyinfo(peer_connection); |
11369 | 2751 } |
8446 | 2752 xfer->data = NULL; |
2753 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2754 } | |
2755 | |
11369 | 2756 /* |
2757 * Called when we send some data to the other client | |
2758 */ | |
11159 | 2759 static void oscar_xfer_ack_send(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2760 { |
13252 | 2761 PeerConnection *peer_connection = xfer->data; |
8446 | 2762 |
2763 /* I'm not sure I like how we do this. --marv | |
2764 * I do. AIM file transfers aren't really meant to be thought | |
2765 * of as a transferring just a single file. The rendezvous | |
2766 * establishes a connection between two computers, and then | |
2767 * those computers can use the same connection for transferring | |
2768 * multiple files. So we don't want the Gaim core up and closing | |
2769 * the socket all willy-nilly. We want to do that in the oscar | |
2770 * prpl, whenever one side or the other says they're finished | |
2771 * using the connection. There might be a better way to intercept | |
2772 * the socket from the core, however... --KingAnt | |
2773 */ | |
2774 | |
2775 /* | |
2776 * If we're done sending, intercept the socket from the core ft code | |
2777 * and wait for the other guy to send the "done" OFT packet. | |
2778 */ | |
2779 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2780 gaim_input_remove(xfer->watcher); | |
13252 | 2781 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, peer_connection->conn); |
8446 | 2782 xfer->fd = 0; |
2783 gaim_xfer_set_completed(xfer, TRUE); | |
2784 } | |
2785 } | |
2786 | |
11369 | 2787 /* |
2788 * Called by the Gaim core to determine whether or not we're allowed to send a file | |
2789 * to this user. | |
2790 */ | |
9466 | 2791 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2792 OscarData *od = gc->proto_data; | |
2793 | |
11049 | 2794 if (od != NULL) { |
9466 | 2795 aim_userinfo_t *userinfo; |
2796 userinfo = aim_locate_finduserinfo(od->sess, who); | |
12714 | 2797 |
2798 /* | |
2799 * Don't allowing sending a file to a user that does not support | |
2800 * file transfer, and don't allow sending to ourselves. | |
2801 */ | |
2802 if (userinfo && (userinfo->capabilities & AIM_CAPS_SENDFILE) && | |
12723 | 2803 aim_sncmp(who, gaim_account_get_username(gaim_connection_get_account(gc)))) |
12714 | 2804 { |
2805 return TRUE; | |
2806 } | |
13071 | 2807 |
12714 | 2808 } |
2809 | |
2810 return FALSE; | |
9466 | 2811 } |
2812 | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2813 static GaimXfer* |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2814 oscar_new_xfer(GaimConnection *gc, const char *who) { |
9030 | 2815 OscarData *od; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2816 GaimXfer *xfer; |
13252 | 2817 PeerConnection *peer_connection; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2818 const char *ip; |
11369 | 2819 gboolean use_rv_proxy; |
2820 | |
13311
f6f465b8d1c0
[gaim-migrate @ 15677]
Richard Laager <rlaager@wiktel.com>
parents:
13296
diff
changeset
|
2821 use_rv_proxy = gaim_account_get_bool(gc->account, "use_rv_proxy", OSCAR_DEFAULT_USE_RV_PROXY); |
11401 | 2822 if(use_rv_proxy) |
11369 | 2823 gaim_debug_info("oscar","using stage 1 proxied transfer\n"); |
11401 | 2824 |
9030 | 2825 od = (OscarData *)gc->proto_data; |
2826 | |
4617 | 2827 /* You want to send a file to someone else, you're so generous */ |
2828 | |
2829 /* Build the file transfer handle */ | |
9466 | 2830 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2831 |
5146 | 2832 /* Create the oscar-specific data */ |
11369 | 2833 if (use_rv_proxy) { |
2834 /* This hostname will be resolved by gaim_proxy_connect */ | |
2835 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
2836 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
13252 | 2837 peer_connection = aim_oft_createinfo(od->sess, NULL /*cookie*/, who, 0 /*ip*/, 0, 0, 0, NULL, |
11369 | 2838 AIM_XFER_SEND, AIM_XFER_PROXY, AIM_XFER_PROXY_STG1); |
13252 | 2839 peer_connection->proxy_info = aim_rv_proxy_createinfo(peer_connection->sess, NULL, 0); |
11369 | 2840 /* We must create a cookie before the request is sent |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2841 * so that it can be sent to the proxy */ |
13252 | 2842 aim_icbm_makecookie(peer_connection->cookie); |
11369 | 2843 } else { |
2844 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); | |
13252 | 2845 peer_connection = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL, |
11369 | 2846 AIM_XFER_SEND, AIM_XFER_DIRECT, AIM_XFER_PROXY_NONE); |
2847 } | |
13252 | 2848 xfer->data = peer_connection; |
5146 | 2849 |
11369 | 2850 /* Setup our I/O op functions */ |
2851 if (use_rv_proxy) | |
11399 | 2852 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
11369 | 2853 else |
2854 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); | |
4617 | 2855 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2856 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2857 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2858 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2859 |
2860 /* Keep track of this transfer for later */ | |
2861 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2862 | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2863 return xfer; |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2864 } |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2865 |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2866 /* |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2867 * Called by the Gaim core when the user indicates that a file is to be sent to |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2868 * a special someone. |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2869 */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2870 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2871 GaimXfer *xfer = oscar_new_xfer(gc, who); |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2872 |
4617 | 2873 /* Now perform the request */ |
9466 | 2874 if (file) |
2875 gaim_xfer_request_accepted(xfer, file); | |
2876 else | |
2877 gaim_xfer_request(xfer); | |
3630 | 2878 } |
2879 | |
13239 | 2880 static int gaim_parse_auth_resp(OscarSession *sess, FlapFrame *fr, ...) { |
6029 | 2881 GaimConnection *gc = sess->aux_data; |
7283 | 2882 OscarData *od = gc->proto_data; |
6029 | 2883 GaimAccount *account = gc->account; |
13239 | 2884 OscarConnection *bosconn; |
6029 | 2885 char *host; int port; |
2886 int i, rc; | |
2086 | 2887 va_list ap; |
2704 | 2888 struct aim_authresp_info *info; |
6029 | 2889 |
11338 | 2890 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); |
2086 | 2891 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2892 va_start(ap, fr); |
2704 | 2893 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2894 va_end(ap); |
2895 | |
8660 | 2896 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2897 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2898 |
4293 | 2899 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2900 char buf[256]; |
2704 | 2901 switch (info->errorcode) { |
2086 | 2902 case 0x05: |
2903 /* Incorrect nick/password */ | |
6498 | 2904 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2905 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2906 break; |
2907 case 0x11: | |
2908 /* Suspended account */ | |
6498 | 2909 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2910 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2911 break; |
3498 | 2912 case 0x14: |
2913 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2914 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2915 break; |
2086 | 2916 case 0x18: |
2917 /* connecting too frequently */ | |
6498 | 2918 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2919 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 | 2920 break; |
2921 case 0x1c: | |
2922 /* client too old */ | |
6498 | 2923 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2924 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
|
2925 gaim_connection_error(gc, buf); |
2086 | 2926 break; |
2927 default: | |
6623 | 2928 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2929 break; |
2930 } | |
13226 | 2931 gaim_debug_error("oscar", "Login Error Code 0x%04hx\n", info->errorcode); |
2932 gaim_debug_error("oscar", "Error URL: %s\n", info->errorurl); | |
2086 | 2933 od->killme = TRUE; |
2934 return 1; | |
2935 } | |
2936 | |
2937 | |
9992 | 2938 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2939 |
2704 | 2940 if (info->email) { |
8660 | 2941 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2942 } else { |
8660 | 2943 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2944 } |
13226 | 2945 |
8660 | 2946 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
13226 | 2947 gaim_debug_info("oscar", "Closing auth connection...\n"); |
13262 | 2948 oscar_connection_destroy(sess, fr->conn); |
13254 | 2949 |
2950 bosconn = oscar_connection_new(sess, AIM_CONN_TYPE_BOS); | |
2086 | 2951 if (bosconn == NULL) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2952 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2953 od->killme = TRUE; |
2954 return 0; | |
2955 } | |
2956 | |
4649 | 2957 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2958 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2959 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
13234 | 2960 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_REDIRECT, gaim_handle_redirect, 0); |
2961 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_RIGHTSINFO, gaim_parse_locaterights, 0); | |
2962 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_BUDDY, OSCAR_SUBTYPE_BUDDY_RIGHTSINFO, gaim_parse_buddyrights, 0); | |
2963 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_BUDDY, OSCAR_SUBTYPE_BUDDY_ONCOMING, gaim_parse_oncoming, 0); | |
2964 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_BUDDY, OSCAR_SUBTYPE_BUDDY_OFFGOING, gaim_parse_offgoing, 0); | |
2965 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_INCOMING, gaim_parse_incoming_im, 0); | |
2966 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_ERROR, gaim_parse_locerr, 0); | |
2967 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_MISSEDCALL, gaim_parse_misses, 0); | |
2968 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_CLIENTAUTORESP, gaim_parse_clientauto, 0); | |
2969 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_RATECHANGE, gaim_parse_ratechange, 0); | |
2970 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_EVIL, gaim_parse_evilnotify, 0); | |
2971 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_USERLOOKUP, OSCAR_SUBTYPE_USERLOOKUP_ERROR, gaim_parse_searcherror, 0); | |
2972 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_USERLOOKUP, 0x0003, gaim_parse_searchreply, 0); | |
2973 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_ERROR, gaim_parse_msgerr, 0); | |
2974 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_MTN, gaim_parse_mtn, 0); | |
2975 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_USERINFO, gaim_parse_userinfo, 0); | |
2976 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); | |
2977 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_GOTINFOBLOCK, gaim_got_infoblock, 0); | |
2978 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_ACK, gaim_parse_msgack, 0); | |
2979 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_MOTD, gaim_parse_motd, 0); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2980 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2981 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2982 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2983 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2984 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2985 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2986 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0021, oscar_icon_req,0); |
13234 | 2987 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); |
2988 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); | |
2989 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_POPUP, 0x0002, gaim_popup, 0); | |
2990 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_ALIAS, gaim_icqalias, 0); | |
2991 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_INFO, gaim_icqinfo, 0); | |
2992 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_ERROR, gaim_ssi_parseerr, 0); | |
2993 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_RIGHTSINFO, gaim_ssi_parserights, 0); | |
2994 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_LIST, gaim_ssi_parselist, 0); | |
2995 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_NOLIST, gaim_ssi_parselist, 0); | |
2996 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_SRVACK, gaim_ssi_parseack, 0); | |
2997 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_ADD, gaim_ssi_parseadd, 0); | |
2998 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_RECVAUTH, gaim_ssi_authgiven, 0); | |
2999 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
3000 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_RECVAUTHREP, gaim_ssi_authreply, 0); | |
3001 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_ADDED, gaim_ssi_gotadded, 0); | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3002 |
7283 | 3003 od->conn = bosconn; |
2704 | 3004 for (i = 0; i < (int)strlen(info->bosip); i++) { |
3005 if (info->bosip[i] == ':') { | |
3006 port = atoi(&(info->bosip[i+1])); | |
2086 | 3007 break; |
3008 } | |
3009 } | |
2704 | 3010 host = g_strndup(info->bosip, i); |
2086 | 3011 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3012 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 3013 g_free(host); |
4366 | 3014 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
3015 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 3016 od->killme = TRUE; |
3017 return 0; | |
3018 } | |
4293 | 3019 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3020 gaim_input_remove(gc->inpa); |
2704 | 3021 |
7283 | 3022 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 3023 ck[3] = 0x64; |
7282 | 3024 |
2086 | 3025 return 1; |
3026 } | |
3027 | |
10464 | 3028 static void |
3029 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
3030 { | |
3031 GaimConnection *gc = user_data; | |
3032 OscarData *od = gc->proto_data; | |
13239 | 3033 OscarSession *sess = od->sess; |
10464 | 3034 |
3035 aim_auth_securid_send(sess, msg); | |
3036 } | |
3037 | |
3038 static void | |
3039 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
3040 { | |
3041 GaimConnection *gc = user_data; | |
3042 OscarData *od = gc->proto_data; | |
3043 | |
3044 /* Disconnect */ | |
3045 gc->wants_to_die = TRUE; | |
3046 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
3047 od->killme = TRUE; | |
3048 } | |
3049 | |
3050 static int | |
13239 | 3051 gaim_parse_auth_securid_request(OscarSession *sess, FlapFrame *fr, ...) |
10464 | 3052 { |
3053 GaimConnection *gc = sess->aux_data; | |
3054 GaimAccount *account = gaim_connection_get_account(gc); | |
3055 gchar *primary; | |
3056 | |
3057 gaim_debug_info("oscar", "Got SecurID request\n"); | |
3058 | |
3059 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
3060 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
3061 _("Enter the 6 digit number from the digital display."), | |
3062 FALSE, FALSE, NULL, | |
3063 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
3064 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
3065 gc); | |
3066 g_free(primary); | |
3067 | |
3068 return 1; | |
3069 } | |
3070 | |
7285 | 3071 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 3072 struct pieceofcrap { |
5575 | 3073 GaimConnection *gc; |
2086 | 3074 unsigned long offset; |
3075 unsigned long len; | |
3076 char *modname; | |
3077 int fd; | |
13239 | 3078 OscarConnection *conn; |
2086 | 3079 unsigned int inpa; |
3080 }; | |
3081 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3082 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 3083 { |
3084 struct pieceofcrap *pos = data; | |
7283 | 3085 OscarData *od = pos->gc->proto_data; |
2086 | 3086 char in = '\0'; |
3087 int x = 0; | |
3088 unsigned char m[17]; | |
3089 | |
3090 while (read(pos->fd, &in, 1) == 1) { | |
3091 if (in == '\n') | |
3092 x++; | |
3093 else if (in != '\r') | |
3094 x = 0; | |
3095 if (x == 2) | |
3096 break; | |
3097 in = '\0'; | |
3098 } | |
3099 if (in != '\n') { | |
4056 | 3100 char buf[256]; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3101 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
|
3102 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3103 gaim_notify_warning(pos->gc, NULL, |
7422 | 3104 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3105 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3106 gaim_input_remove(pos->inpa); |
2086 | 3107 close(pos->fd); |
3108 g_free(pos); | |
3109 return; | |
3110 } | |
3111 read(pos->fd, m, 16); | |
3112 m[16] = '\0'; | |
8660 | 3113 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 3114 for (x = 0; x < 16; x++) |
8660 | 3115 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
3116 | |
3117 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3118 gaim_input_remove(pos->inpa); |
2086 | 3119 close(pos->fd); |
3120 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
3121 g_free(pos); | |
3122 } | |
3123 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3124 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 3125 struct pieceofcrap *pos = data; |
5420 | 3126 gchar *buf; |
2086 | 3127 |
4366 | 3128 pos->fd = source; |
3129 | |
2086 | 3130 if (source < 0) { |
5420 | 3131 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
|
3132 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3133 gaim_notify_warning(pos->gc, NULL, |
7422 | 3134 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3135 buf); |
5420 | 3136 g_free(buf); |
2086 | 3137 if (pos->modname) |
3138 g_free(pos->modname); | |
3139 g_free(pos); | |
3140 return; | |
3141 } | |
3142 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3143 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3144 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3145 |
5420 | 3146 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 3147 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
3148 write(pos->fd, buf, strlen(buf)); | |
5420 | 3149 g_free(buf); |
2086 | 3150 if (pos->modname) |
3151 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3152 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 3153 return; |
3154 } | |
3155 | |
3156 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
3157 #define AIM_MAX_FILE_SIZE 98304 | |
3158 | |
13239 | 3159 int gaim_memrequest(OscarSession *sess, FlapFrame *fr, ...) { |
2086 | 3160 va_list ap; |
3161 struct pieceofcrap *pos; | |
13234 | 3162 guint32 offset, len; |
2086 | 3163 char *modname; |
3164 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3165 va_start(ap, fr); |
13234 | 3166 offset = va_arg(ap, guint32); |
3167 len = va_arg(ap, guint32); | |
2086 | 3168 modname = va_arg(ap, char *); |
3169 va_end(ap); | |
3170 | |
13226 | 3171 gaim_debug_misc("oscar", "offset: %u, len: %u, file: %s\n", |
3172 offset, len, (modname ? modname : "aim.exe")); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3173 |
2086 | 3174 if (len == 0) { |
8660 | 3175 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3176 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 3177 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
3178 return 1; | |
3179 } | |
9625 | 3180 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
3181 #if 0 | |
2086 | 3182 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
3183 char *buf; | |
3184 int i = 8; | |
3185 if (modname) | |
3186 i += strlen(modname); | |
3187 buf = g_malloc(i); | |
3188 i = 0; | |
3189 if (modname) { | |
3190 memcpy(buf, modname, strlen(modname)); | |
3191 i += strlen(modname); | |
3192 } | |
3193 buf[i++] = offset & 0xff; | |
3194 buf[i++] = (offset >> 8) & 0xff; | |
3195 buf[i++] = (offset >> 16) & 0xff; | |
3196 buf[i++] = (offset >> 24) & 0xff; | |
3197 buf[i++] = len & 0xff; | |
3198 buf[i++] = (len >> 8) & 0xff; | |
3199 buf[i++] = (len >> 16) & 0xff; | |
3200 buf[i++] = (len >> 24) & 0xff; | |
8660 | 3201 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3202 "hashing request\n"); |
2086 | 3203 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
3204 g_free(buf); | |
3205 return 1; | |
3206 } | |
9625 | 3207 #endif |
2086 | 3208 |
3209 pos = g_new0(struct pieceofcrap, 1); | |
3210 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3211 pos->conn = fr->conn; |
2086 | 3212 |
3213 pos->offset = offset; | |
3214 pos->len = len; | |
3215 pos->modname = modname ? g_strdup(modname) : NULL; | |
3216 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3217 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 3218 char buf[256]; |
2086 | 3219 if (pos->modname) |
3220 g_free(pos->modname); | |
3221 g_free(pos); | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3222 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3223 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3224 gaim_notify_warning(pos->gc, NULL, |
7422 | 3225 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3226 buf); |
2086 | 3227 } |
3228 | |
3229 return 1; | |
3230 } | |
3231 | |
13239 | 3232 static int gaim_parse_login(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 3233 GaimConnection *gc = sess->aux_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
3234 GaimAccount *account = gaim_connection_get_account(gc); |
13239 | 3235 ClientInfo info = CLIENTINFO_GAIM; |
7011 | 3236 va_list ap; |
3237 char *key; | |
2086 | 3238 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3239 va_start(ap, fr); |
2086 | 3240 key = va_arg(ap, char *); |
3241 va_end(ap); | |
3242 | |
12049 | 3243 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
3244 gaim_connection_get_password(gc), &info, key); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3245 |
7283 | 3246 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 3247 ck[2] = 0x6c; |
7282 | 3248 |
2086 | 3249 return 1; |
3250 } | |
3251 | |
13239 | 3252 static int conninitdone_chat(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 3253 GaimConnection *gc = sess->aux_data; |
2647 | 3254 struct chat_connection *chatcon; |
3255 static int id = 1; | |
3256 | |
13234 | 3257 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, 0x0001, gaim_parse_genericerr, 0); |
3258 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, OSCAR_SUBTYPE_CHAT_USERJOIN, gaim_conv_chat_join, 0); | |
3259 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, OSCAR_SUBTYPE_CHAT_USERLEAVE, gaim_conv_chat_leave, 0); | |
3260 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, OSCAR_SUBTYPE_CHAT_ROOMINFOUPDATE, gaim_conv_chat_info_update, 0); | |
3261 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, OSCAR_SUBTYPE_CHAT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); | |
2675 | 3262 |
2672 | 3263 aim_clientready(sess, fr->conn); |
2675 | 3264 |
2647 | 3265 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
3266 chatcon->id = id; | |
8733 | 3267 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 3268 |
3269 return 1; | |
3270 } | |
3271 | |
13239 | 3272 static int conninitdone_chatnav(OscarSession *sess, FlapFrame *fr, ...) { |
2675 | 3273 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3274 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
13234 | 3275 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHATNAV, OSCAR_SUBTYPE_CHATNAV_INFO, gaim_chatnav_info, 0); |
2675 | 3276 |
3277 aim_clientready(sess, fr->conn); | |
3278 | |
3279 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3280 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3281 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3282 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3283 |
13239 | 3284 static int conninitdone_email(OscarSession *sess, FlapFrame *fr, ...) { |
3694 | 3285 |
3286 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
13234 | 3287 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_ALERT, OSCAR_SUBTYPE_ALERT_MAILSTATUS, gaim_email_parseupdate, 0); |
3694 | 3288 |
7282 | 3289 aim_email_sendcookies(sess); |
3290 aim_email_activate(sess); | |
3694 | 3291 aim_clientready(sess, fr->conn); |
3292 | |
3293 return 1; | |
3294 } | |
3295 | |
13239 | 3296 static int conninitdone_icon(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 3297 GaimConnection *gc = sess->aux_data; |
7283 | 3298 OscarData *od = gc->proto_data; |
4804 | 3299 |
3300 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
13234 | 3301 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_BART, OSCAR_SUBTYPE_BART_ERROR, gaim_icon_error, 0); |
3302 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_BART, OSCAR_SUBTYPE_BART_RESPONSE, gaim_icon_parseicon, 0); | |
4804 | 3303 |
3304 aim_clientready(sess, fr->conn); | |
3305 | |
4823 | 3306 od->iconconnecting = FALSE; |
3307 | |
4804 | 3308 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3309 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3310 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 3311 |
3312 return 1; | |
3313 } | |
3314 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3315 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 3316 GaimConnection *gc = data; |
7283 | 3317 OscarData *od; |
13239 | 3318 OscarSession *sess; |
3319 OscarConnection *tstconn; | |
2086 | 3320 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3321 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 3322 close(source); |
3323 return; | |
3324 } | |
3325 | |
4617 | 3326 od = gc->proto_data; |
3327 sess = od->sess; | |
2086 | 3328 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 3329 tstconn->fd = source; |
2086 | 3330 |
3331 if (source < 0) { | |
13262 | 3332 oscar_connection_destroy(sess, tstconn); |
13226 | 3333 gaim_debug_error("oscar", "unable to connect to chatnav server\n"); |
2086 | 3334 return; |
3335 } | |
3336 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3337 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3338 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3339 |
2086 | 3340 aim_conn_completeconnect(sess, tstconn); |
4617 | 3341 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 3342 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 3343 } |
3344 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3345 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 3346 { |
5575 | 3347 GaimConnection *gc = data; |
7283 | 3348 OscarData *od; |
13239 | 3349 OscarSession *sess; |
3350 OscarConnection *tstconn; | |
2086 | 3351 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3352 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 3353 close(source); |
3354 return; | |
3355 } | |
3356 | |
4617 | 3357 od = gc->proto_data; |
3358 sess = od->sess; | |
2086 | 3359 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 3360 tstconn->fd = source; |
2086 | 3361 |
3362 if (source < 0) { | |
13262 | 3363 oscar_connection_destroy(sess, tstconn); |
13226 | 3364 gaim_debug_error("oscar", "unable to connect to authorizer\n"); |
2086 | 3365 return; |
3366 } | |
3367 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3368 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3369 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3370 |
2086 | 3371 aim_conn_completeconnect(sess, tstconn); |
4617 | 3372 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 3373 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 3374 } |
3375 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3376 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 3377 { |
3378 struct chat_connection *ccon = data; | |
5575 | 3379 GaimConnection *gc = ccon->gc; |
7283 | 3380 OscarData *od; |
13239 | 3381 OscarSession *sess; |
3382 OscarConnection *tstconn; | |
2086 | 3383 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3384 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 3385 close(source); |
3386 g_free(ccon->show); | |
3387 g_free(ccon->name); | |
3388 g_free(ccon); | |
3389 return; | |
3390 } | |
3391 | |
4617 | 3392 od = gc->proto_data; |
3393 sess = od->sess; | |
2086 | 3394 tstconn = ccon->conn; |
4366 | 3395 tstconn->fd = source; |
2086 | 3396 |
3397 if (source < 0) { | |
13262 | 3398 oscar_connection_destroy(sess, tstconn); |
2086 | 3399 g_free(ccon->show); |
3400 g_free(ccon->name); | |
3401 g_free(ccon); | |
3402 return; | |
3403 } | |
3404 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3405 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3406 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3407 |
2086 | 3408 aim_conn_completeconnect(sess, ccon->conn); |
4617 | 3409 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
3410 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 3411 } |
3412 | |
3694 | 3413 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 3414 GaimConnection *gc = data; |
7283 | 3415 OscarData *od; |
13239 | 3416 OscarSession *sess; |
3417 OscarConnection *tstconn; | |
3694 | 3418 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3419 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 3420 close(source); |
3421 return; | |
3422 } | |
3423 | |
4617 | 3424 od = gc->proto_data; |
3425 sess = od->sess; | |
3694 | 3426 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 3427 tstconn->fd = source; |
3694 | 3428 |
3429 if (source < 0) { | |
13262 | 3430 oscar_connection_destroy(sess, tstconn); |
13226 | 3431 gaim_debug_error("oscar", "unable to connect to email server\n"); |
3694 | 3432 return; |
3433 } | |
3434 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3435 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3436 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3437 |
3694 | 3438 aim_conn_completeconnect(sess, tstconn); |
4617 | 3439 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
13226 | 3440 gaim_debug_info("oscar", "email: connected\n"); |
3694 | 3441 } |
3442 | |
4804 | 3443 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 3444 GaimConnection *gc = data; |
7283 | 3445 OscarData *od; |
13239 | 3446 OscarSession *sess; |
3447 OscarConnection *tstconn; | |
4804 | 3448 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3449 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 3450 close(source); |
3451 return; | |
3452 } | |
3453 | |
3454 od = gc->proto_data; | |
3455 sess = od->sess; | |
3456 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
3457 tstconn->fd = source; | |
3458 | |
3459 if (source < 0) { | |
13262 | 3460 oscar_connection_destroy(sess, tstconn); |
13226 | 3461 gaim_debug_error("oscar", "unable to connect to icon server\n"); |
4804 | 3462 return; |
3463 } | |
3464 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3465 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3466 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3467 |
4804 | 3468 aim_conn_completeconnect(sess, tstconn); |
3469 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 3470 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 3471 } |
3472 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3473 /* Hrmph. I don't know how to make this look better. --mid */ |
13239 | 3474 static int gaim_handle_redirect(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 3475 GaimConnection *gc = sess->aux_data; |
3476 GaimAccount *account = gaim_connection_get_account(gc); | |
13239 | 3477 OscarConnection *tstconn; |
4452 | 3478 int i; |
2086 | 3479 char *host; |
3480 int port; | |
4821 | 3481 va_list ap; |
3482 struct aim_redirect_data *redir; | |
2086 | 3483 |
11338 | 3484 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); |
2086 | 3485 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3486 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3487 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3488 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3489 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3490 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3491 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3492 port = atoi(&(redir->ip[i+1])); |
2086 | 3493 break; |
3494 } | |
3495 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3496 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3497 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3498 switch(redir->group) { |
2086 | 3499 case 0x7: /* Authorizer */ |
13226 | 3500 gaim_debug_info("oscar", "Reconnecting with authorizor...\n"); |
13254 | 3501 tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_AUTH); |
2086 | 3502 if (tstconn == NULL) { |
8660 | 3503 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3504 "unable to reconnect with authorizer\n"); |
2086 | 3505 g_free(host); |
3506 return 1; | |
3507 } | |
4649 | 3508 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 3509 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 3510 |
3511 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3512 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
13262 | 3513 oscar_connection_destroy(sess, tstconn); |
8660 | 3514 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3515 "unable to reconnect with authorizer\n"); |
2086 | 3516 g_free(host); |
3517 return 1; | |
3518 } | |
4293 | 3519 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 3520 break; |
3521 | |
2086 | 3522 case 0xd: /* ChatNav */ |
13254 | 3523 tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_CHATNAV); |
2086 | 3524 if (tstconn == NULL) { |
8660 | 3525 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3526 "unable to connect to chatnav server\n"); |
2086 | 3527 g_free(host); |
3528 return 1; | |
3529 } | |
4649 | 3530 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 3531 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 3532 |
3533 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3534 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
13262 | 3535 oscar_connection_destroy(sess, tstconn); |
8660 | 3536 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3537 "unable to connect to chatnav server\n"); |
2086 | 3538 g_free(host); |
3539 return 1; | |
3540 } | |
4293 | 3541 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 3542 break; |
3543 | |
3544 case 0xe: { /* Chat */ | |
2086 | 3545 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3546 |
13254 | 3547 tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_CHAT); |
2086 | 3548 if (tstconn == NULL) { |
8660 | 3549 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3550 "unable to connect to chat server\n"); |
2086 | 3551 g_free(host); |
3552 return 1; | |
3553 } | |
3554 | |
4649 | 3555 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 3556 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
3557 | |
2086 | 3558 ccon = g_new0(struct chat_connection, 1); |
3559 ccon->conn = tstconn; | |
3560 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3561 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3562 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3563 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3564 ccon->show = extract_name(redir->chat.room); |
4634 | 3565 |
2086 | 3566 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3567 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
13262 | 3568 oscar_connection_destroy(sess, tstconn); |
8660 | 3569 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3570 "unable to connect to chat server\n"); |
2086 | 3571 g_free(host); |
3572 g_free(ccon->show); | |
3573 g_free(ccon->name); | |
3574 g_free(ccon); | |
3575 return 1; | |
3576 } | |
4293 | 3577 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 3578 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3579 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3580 ccon->name, ccon->exchange); |
4194 | 3581 } break; |
3694 | 3582 |
4804 | 3583 case 0x0010: { /* icon */ |
13254 | 3584 if (!(tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_ICON))) { |
8660 | 3585 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3586 "unable to connect to icon server\n"); |
4804 | 3587 g_free(host); |
3588 return 1; | |
3589 } | |
3590 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
3591 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
3592 | |
3593 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3594 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
13262 | 3595 oscar_connection_destroy(sess, tstconn); |
8660 | 3596 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3597 "unable to connect to icon server\n"); |
4804 | 3598 g_free(host); |
3599 return 1; | |
3600 } | |
3601 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
3602 } break; | |
3603 | |
3694 | 3604 case 0x0018: { /* email */ |
13254 | 3605 if (!(tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_EMAIL))) { |
8660 | 3606 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3607 "unable to connect to email server\n"); |
3694 | 3608 g_free(host); |
3609 return 1; | |
3610 } | |
4649 | 3611 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 3612 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
3613 | |
3614 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3615 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
13262 | 3616 oscar_connection_destroy(sess, tstconn); |
8660 | 3617 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3618 "unable to connect to email server\n"); |
3694 | 3619 g_free(host); |
3620 return 1; | |
3621 } | |
4293 | 3622 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 3623 } break; |
3624 | |
2086 | 3625 default: /* huh? */ |
8660 | 3626 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3627 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3628 redir->group); |
2086 | 3629 break; |
3630 } | |
3631 | |
3632 g_free(host); | |
3633 return 1; | |
3634 } | |
3635 | |
13239 | 3636 static int gaim_parse_oncoming(OscarSession *sess, FlapFrame *fr, ...) |
10042 | 3637 { |
3638 GaimConnection *gc; | |
3639 GaimAccount *account; | |
11973 | 3640 GaimPresence *presence; |
10042 | 3641 OscarData *od; |
4738 | 3642 struct buddyinfo *bi; |
2993 | 3643 time_t time_idle = 0, signon = 0; |
3644 int type = 0; | |
12349 | 3645 gboolean buddy_is_away = FALSE; |
3646 const char *status_id; | |
3647 gboolean have_status_message = FALSE; | |
3648 char *message = NULL; | |
2086 | 3649 va_list ap; |
4738 | 3650 aim_userinfo_t *info; |
10042 | 3651 |
3652 gc = sess->aux_data; | |
3653 account = gaim_connection_get_account(gc); | |
11973 | 3654 presence = gaim_account_get_presence(account); |
10042 | 3655 od = gc->proto_data; |
4194 | 3656 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3657 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3658 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3659 va_end(ap); |
11973 | 3660 |
10130 | 3661 g_return_val_if_fail(info != NULL, 1); |
3662 g_return_val_if_fail(info->sn != NULL, 1); | |
3663 | |
4766 | 3664 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
3665 if (info->flags & AIM_FLAG_AWAY) | |
11369 | 3666 buddy_is_away = TRUE; |
3667 } | |
2993 | 3668 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
11510 | 3669 type = info->icqinfo.status; |
3013 | 3670 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3671 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3672 buddy_is_away = TRUE; |
3013 | 3673 } |
2993 | 3674 } |
3675 | |
12349 | 3676 if (aim_sn_is_icq(info->sn)) { |
3677 if (type & AIM_ICQ_STATE_CHAT) | |
3678 status_id = OSCAR_STATUS_ID_FREE4CHAT; | |
3679 else if (type & AIM_ICQ_STATE_DND) | |
3680 status_id = OSCAR_STATUS_ID_DND; | |
3681 else if (type & AIM_ICQ_STATE_OUT) | |
3682 status_id = OSCAR_STATUS_ID_NA; | |
3683 else if (type & AIM_ICQ_STATE_BUSY) | |
3684 status_id = OSCAR_STATUS_ID_OCCUPIED; | |
3685 else if (type & AIM_ICQ_STATE_AWAY) | |
3686 status_id = OSCAR_STATUS_ID_AWAY; | |
3687 else if (type & AIM_ICQ_STATE_INVISIBLE) | |
3688 status_id = OSCAR_STATUS_ID_INVISIBLE; | |
3689 else | |
3690 status_id = OSCAR_STATUS_ID_AVAILABLE; | |
3691 } else { | |
12653 | 3692 if (buddy_is_away) |
12349 | 3693 status_id = OSCAR_STATUS_ID_AWAY; |
3694 else | |
3695 status_id = OSCAR_STATUS_ID_AVAILABLE; | |
3696 } | |
3697 | |
3698 /* | |
3699 * Handle the available message. If info->status is NULL then the user | |
3700 * may or may not have an available message, so don't do anything. If | |
3701 * info->status is set to the empty string, then the user's client DOES | |
3702 * support available messages and the user DOES NOT have one set. | |
3703 * Otherwise info->status contains the available message. | |
3704 */ | |
3705 if (info->status != NULL) | |
3706 { | |
3707 have_status_message = TRUE; | |
3708 if (info->status[0] != '\0') | |
3709 message = oscar_encoding_to_utf8(info->status_encoding, | |
3710 info->status, info->status_len); | |
3711 } | |
3712 | |
3713 if (have_status_message) | |
3714 { | |
3715 gaim_prpl_got_user_status(account, info->sn, status_id, | |
3716 "message", message, NULL); | |
3717 g_free(message); | |
3718 } | |
3719 else | |
3720 gaim_prpl_got_user_status(account, info->sn, status_id, NULL); | |
3721 | |
12350 | 3722 /* Login time stuff */ |
5836 | 3723 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3724 signon = info->onlinesince; | |
3725 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3726 signon = time(NULL) - info->sessionlen; |
10567 | 3727 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3728 gaim_connection_set_display_name(gc, info->sn); |
11973 | 3729 od->timeoffset = signon - gaim_presence_get_login_time(presence); |
10567 | 3730 } |
12350 | 3731 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
3732 | |
3733 /* Idle time stuff */ | |
3734 /* info->idletime is the number of minutes that this user has been idle */ | |
3735 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
3736 time_idle = time(NULL) - info->idletime * 60; | |
3737 | |
3738 if (time_idle > 0) | |
3739 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
3740 else | |
3741 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
3742 | |
3743 /* Server stored icon stuff */ | |
9982 | 3744 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3745 if (!bi) { |
3746 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3747 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3748 } |
4739 | 3749 bi->typingnot = FALSE; |
3750 bi->ico_informed = FALSE; | |
6857 | 3751 bi->ipaddr = info->icqinfo.ipaddr; |
3752 | |
4853 | 3753 if (info->iconcsumlen) { |
7125 | 3754 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3755 char *b16 = NULL, *filepath = NULL; |
7093 | 3756 GaimBuddy *b = NULL; |
4853 | 3757 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3758 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3759 b = gaim_find_buddy(account, info->sn); |
7093 | 3760 /* |
3761 * If for some reason the checksum is valid, but cached file is not.. | |
3762 * we want to know. | |
3763 */ | |
7693 | 3764 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3765 if (filename != NULL) { |
3766 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3767 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3768 "icon_checksum"); | |
9801 | 3769 else { |
3770 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3771 filename, NULL); | |
3772 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3773 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3774 "icon_checksum"); | |
3775 g_free(filepath); | |
3776 } | |
7093 | 3777 } else |
3778 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3779 |
4853 | 3780 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3781 GSList *cur = od->requesticon; | |
3782 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3783 cur = cur->next; | |
3784 if (!cur) { | |
9982 | 3785 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3786 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3787 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3788 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3789 } |
3790 } | |
6053 | 3791 g_free(b16); |
4853 | 3792 } |
3793 | |
2086 | 3794 return 1; |
3795 } | |
3796 | |
8341 | 3797 static void gaim_check_comment(OscarData *od, const char *str) { |
11159 | 3798 if ((str == NULL) || strcmp(str, (const char *)ck)) |
8341 | 3799 aim_locate_setcaps(od->sess, caps_aim); |
3800 else | |
3801 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3802 } | |
3803 | |
13239 | 3804 static int gaim_parse_offgoing(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 3805 GaimConnection *gc = sess->aux_data; |
7283 | 3806 OscarData *od = gc->proto_data; |
9982 | 3807 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3808 va_list ap; |
4739 | 3809 aim_userinfo_t *info; |
2086 | 3810 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3811 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3812 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3813 va_end(ap); |
3814 | |
12349 | 3815 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3816 |
7261 | 3817 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3818 |
2086 | 3819 return 1; |
3820 } | |
3821 | |
4617 | 3822 /* BBB */ |
3952 | 3823 /* |
11369 | 3824 * This is called after a remote AIM user has connected to us. |
3825 * If not using a rendezvous proxy, then we want to do some | |
3826 * voodoo with the socket file descriptors. Then we always | |
13239 | 3827 * add a callback or two, and then send the PEER_TYPE_PROMPT. |
3952 | 3828 */ |
13239 | 3829 static int oscar_sendfile_estblsh(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 3830 GaimConnection *gc = sess->aux_data; |
7283 | 3831 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3832 GaimXfer *xfer; |
13252 | 3833 PeerConnection *peer_connection; |
3630 | 3834 va_list ap; |
13239 | 3835 OscarConnection *conn, *listenerconn; |
4656 | 3836 |
11369 | 3837 gaim_debug_info("oscar", "AAA - in oscar_sendfile_estblsh\n"); |
13226 | 3838 |
3630 | 3839 va_start(ap, fr); |
13239 | 3840 conn = va_arg(ap, OscarConnection *); |
3841 listenerconn = va_arg(ap, OscarConnection *); | |
3630 | 3842 va_end(ap); |
3843 | |
11369 | 3844 /* Finding by conn will work for proxied connections only |
3845 * Finding by listenerconn will work for direct connections only */ | |
3846 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) { | |
3847 if(!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) { | |
3848 gaim_debug_warning("oscar","xfer not found via connection\n"); | |
3849 return 1; | |
3850 } | |
3851 } | |
13252 | 3852 if (!(peer_connection = xfer->data)) { |
11369 | 3853 gaim_debug_warning("oscar","NULL data\n"); |
4617 | 3854 return 1; |
11369 | 3855 } |
13226 | 3856 |
11369 | 3857 /* Mark connection as success so further connections aren't attempted |
3858 * This is important here since some receive file code paths pass through here */ | |
13252 | 3859 peer_connection->success = TRUE; |
3860 | |
3861 if(peer_connection->method != AIM_XFER_PROXY) { | |
11369 | 3862 /* Stop watching listener conn; watch transfer conn instead */ |
3863 gaim_input_remove(xfer->watcher); | |
13226 | 3864 |
13262 | 3865 oscar_connection_destroy(sess, listenerconn); |
13226 | 3866 |
13252 | 3867 peer_connection->conn = conn; |
3868 xfer->fd = peer_connection->conn->fd; | |
3869 } | |
3870 | |
3871 xfer->watcher = gaim_input_add(peer_connection->conn->fd, GAIM_INPUT_READ, oscar_callback, peer_connection->conn); | |
3872 | |
3873 if(peer_connection->send_or_recv == AIM_XFER_SEND) { | |
3874 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_ACK, | |
11369 | 3875 oscar_sendfile_ack, 0); |
13252 | 3876 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_DONE, |
11369 | 3877 oscar_sendfile_done, 0); |
3878 | |
3879 /* Inform the other user that we are connected and ready to transfer */ | |
13252 | 3880 aim_oft_sendheader(sess, PEER_TYPE_PROMPT, peer_connection); |
11369 | 3881 } |
13226 | 3882 |
11369 | 3883 /* For a file send, we'll hopefully end up in oscar_sendfile_ack next |
3884 * For a file receive, oscar_sendfile_prompt */ | |
13226 | 3885 |
3630 | 3886 return 0; |
3887 } | |
3888 | |
3952 | 3889 /* |
13226 | 3890 * This is the gaim callback passed to gaim_proxy_connect when |
3891 * connecting to another AIM user in order to transfer a file | |
3892 * Takes xfer as data and fd as source | |
11369 | 3893 * BBB |
3952 | 3894 */ |
4617 | 3895 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3896 GaimXfer *xfer; |
13252 | 3897 PeerConnection *peer_connection; |
4656 | 3898 |
13226 | 3899 gaim_debug_info("oscar", "AAA - in oscar_sendfile_connected\n"); |
4617 | 3900 if (!(xfer = data)) |
3901 return; | |
13252 | 3902 if (!(peer_connection = xfer->data)) |
3630 | 3903 return; |
13252 | 3904 if(peer_connection->success) { |
11369 | 3905 gaim_debug_info("oscar","connection already successful; ignoring 2nd conn\n"); |
3906 return; | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3907 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3908 |
8446 | 3909 if (source < 0) { |
11369 | 3910 gaim_debug_info("oscar","received fd of %d; aborting transfer\n", source); |
3911 gaim_xfer_cancel_remote(xfer); | |
3912 return; | |
3913 } | |
13252 | 3914 peer_connection->success = TRUE; /* Mark this connection as successful before it times out */ |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3915 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3916 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3917 fcntl(source, F_SETFL, 0); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3918 |
11369 | 3919 /* We might have already set these in oscar_sendfile_proxylogin, but it won't |
3920 * hurt to do it again since it is rather necessary */ | |
4617 | 3921 xfer->fd = source; |
13252 | 3922 peer_connection->conn->fd = source; |
3923 | |
3924 aim_conn_completeconnect(peer_connection->sess, peer_connection->conn); | |
3925 | |
3926 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, peer_connection->conn); | |
4617 | 3927 |
11369 | 3928 /* Inform the other user that we are connected and accept the transfer |
3929 * Except for a stage 2 receive, then we'll be the ones receiving this accept message */ | |
13252 | 3930 if(peer_connection->stage != AIM_XFER_PROXY_STG2) |
3931 aim_im_sendch2_sendfile_accept(peer_connection->sess, peer_connection); | |
13226 | 3932 |
11369 | 3933 /* Don't wait around if this is a redirected send */ |
13252 | 3934 if(peer_connection->send_or_recv == AIM_XFER_SEND) { |
11369 | 3935 /* We should only get here if this is a redirected file send */ |
13252 | 3936 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_ACK, |
11369 | 3937 oscar_sendfile_ack, 0); |
13252 | 3938 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_DONE, |
11369 | 3939 oscar_sendfile_done, 0); |
13226 | 3940 |
11369 | 3941 /* Inform the other user that we are ready to transfer */ |
13252 | 3942 aim_oft_sendheader(peer_connection->sess, PEER_TYPE_PROMPT, peer_connection); |
11369 | 3943 } |
3630 | 3944 } |
3945 | |
3952 | 3946 /* |
13226 | 3947 * This is called when a buddy sends us some file info. This happens when they |
4617 | 3948 * are sending a file to you, and you have just established a connection to them. |
13226 | 3949 * You should send them the exact same info except use the real cookie. We also |
4617 | 3950 * get like totally ready to like, receive the file, kay? |
3952 | 3951 */ |
13239 | 3952 static int oscar_sendfile_prompt(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 3953 GaimConnection *gc = sess->aux_data; |
7283 | 3954 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3955 GaimXfer *xfer; |
13252 | 3956 PeerConnection *peer_connection; |
4617 | 3957 va_list ap; |
13239 | 3958 OscarConnection *conn; |
13234 | 3959 guint8 *cookie; |
13239 | 3960 PeerFrame *fh; |
13226 | 3961 |
3962 gaim_debug_info("oscar", "AAA - in oscar_sendfile_prompt\n"); | |
3963 | |
4617 | 3964 va_start(ap, fr); |
13239 | 3965 conn = va_arg(ap, OscarConnection *); |
13234 | 3966 cookie = va_arg(ap, guint8 *); |
13239 | 3967 fh = va_arg(ap, PeerFrame *); |
4617 | 3968 va_end(ap); |
3969 | |
3970 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3971 return 1; | |
3972 | |
13252 | 3973 if (!(peer_connection = xfer->data)) |
4617 | 3974 return 1; |
3975 | |
3976 /* We want to stop listening with a normal thingy */ | |
3977 gaim_input_remove(xfer->watcher); | |
3978 xfer->watcher = 0; | |
3979 | |
5146 | 3980 /* They sent us some information about the file they're sending */ |
13252 | 3981 memcpy(&peer_connection->fh, fh, sizeof(*fh)); |
5146 | 3982 |
3983 /* Fill in the cookie */ | |
13252 | 3984 memcpy(&peer_connection->fh.bcookie, peer_connection->cookie, 8); |
5146 | 3985 |
4617 | 3986 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
13252 | 3987 aim_oft_sendheader(peer_connection->sess, PEER_TYPE_ACK, peer_connection); |
4617 | 3988 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3989 | |
3990 return 0; | |
3630 | 3991 } |
3992 | |
3952 | 3993 /* |
13226 | 3994 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3995 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3996 */ |
13239 | 3997 static int oscar_sendfile_ack(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 3998 GaimConnection *gc = sess->aux_data; |
7283 | 3999 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4000 GaimXfer *xfer; |
4617 | 4001 va_list ap; |
13239 | 4002 OscarConnection *conn; |
13234 | 4003 guint8 *cookie; |
13239 | 4004 PeerFrame *fh; |
4656 | 4005 |
8660 | 4006 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 4007 va_start(ap, fr); |
13239 | 4008 conn = va_arg(ap, OscarConnection *); |
13234 | 4009 cookie = va_arg(ap, guint8 *); |
13239 | 4010 fh = va_arg(ap, PeerFrame *); |
4617 | 4011 va_end(ap); |
4012 | |
4013 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
4014 return 1; | |
4015 | |
4656 | 4016 /* We want to stop listening with a normal thingy */ |
4017 gaim_input_remove(xfer->watcher); | |
4018 xfer->watcher = 0; | |
4019 | |
4617 | 4020 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
4021 | |
4022 return 0; | |
3630 | 4023 } |
4617 | 4024 |
4025 /* | |
13226 | 4026 * We just sent a file to someone. They said they got it and everything, |
4617 | 4027 * so we can close our direct connection and what not. |
4028 */ | |
13239 | 4029 static int oscar_sendfile_done(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 4030 GaimConnection *gc = sess->aux_data; |
7283 | 4031 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4032 GaimXfer *xfer; |
4617 | 4033 va_list ap; |
13239 | 4034 OscarConnection *conn; |
13234 | 4035 guint8 *cookie; |
13239 | 4036 PeerFrame *fh; |
13252 | 4037 PeerConnection *peer_connection; |
4656 | 4038 |
8660 | 4039 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 4040 va_start(ap, fr); |
13239 | 4041 conn = va_arg(ap, OscarConnection *); |
13234 | 4042 cookie = va_arg(ap, guint8 *); |
13239 | 4043 fh = va_arg(ap, PeerFrame *); |
4617 | 4044 va_end(ap); |
4045 | |
11369 | 4046 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) { |
4047 gaim_debug_warning("oscar","xfer not found\n"); | |
4617 | 4048 return 1; |
11369 | 4049 } |
13252 | 4050 if(!(peer_connection = xfer->data)) { |
4051 gaim_debug_warning("oscar","NULL peer_connection\n"); | |
11369 | 4052 return 1; |
4053 } | |
4054 if(fh->nrecvd == fh->size) | |
4055 gaim_xfer_set_completed(xfer, TRUE); | |
4617 | 4056 |
4656 | 4057 xfer->fd = conn->fd; |
4617 | 4058 gaim_xfer_end(xfer); |
4059 | |
4060 return 0; | |
4061 } | |
3630 | 4062 |
13239 | 4063 static int incomingim_chan1(OscarSession *sess, OscarConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 4064 GaimConnection *gc = sess->aux_data; |
7283 | 4065 OscarData *od = gc->proto_data; |
8708 | 4066 GaimAccount *account = gaim_connection_get_account(gc); |
12216 | 4067 GaimMessageFlags flags = 0; |
4738 | 4068 struct buddyinfo *bi; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4069 char *iconfile; |
9806 | 4070 GString *message; |
4071 gchar *tmp; | |
4072 aim_mpmsg_section_t *curpart; | |
12675 | 4073 const char *start; |
4074 const char *end; | |
4075 GData *attribs; | |
9806 | 4076 |
11537 | 4077 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 4078 userinfo->sn, args->mpmsg.numparts); |
4738 | 4079 |
10595 | 4080 if (args->mpmsg.numparts == 0) |
4081 return 1; | |
4082 | |
8708 | 4083 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 4084 if (!bi) { |
4085 bi = g_new0(struct buddyinfo, 1); | |
8708 | 4086 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 4087 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
4088 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
4089 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
12216 | 4090 flags |= GAIM_MESSAGE_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4091 |
4738 | 4092 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
4093 bi->typingnot = TRUE; | |
4094 else | |
4095 bi->typingnot = FALSE; | |
4096 | |
4380 | 4097 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
13226 | 4098 gaim_debug_misc("oscar", "%s has an icon\n", userinfo->sn); |
4738 | 4099 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
4100 bi->ico_need = TRUE; | |
4101 bi->ico_len = args->iconlen; | |
4102 bi->ico_csum = args->iconsum; | |
4103 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4104 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4105 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4106 |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4107 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
|
4108 if ((iconfile != NULL) && |
7406 | 4109 (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
|
4110 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4111 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4112 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4113 if (!g_stat(iconfile, &st)) { |
11159 | 4114 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4115 file = g_fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4116 if (file) { |
9532 | 4117 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
4118 int len = fread(buf, 1, st.st_size, file); |
8660 | 4119 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4120 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4121 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4122 userinfo->sn, len, st.st_size); |
4617 | 4123 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
4124 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4125 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
4126 } else |
13226 | 4127 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
|
4128 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
4129 } else |
13226 | 4130 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
|
4131 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4132 g_free(iconfile); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4133 |
9806 | 4134 message = g_string_new(""); |
4135 curpart = args->mpmsg.parts; | |
4136 while (curpart != NULL) { | |
11159 | 4137 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, |
12675 | 4138 curpart->charsubset, curpart->data, curpart->datalen); |
9806 | 4139 if (tmp != NULL) { |
4140 g_string_append(message, tmp); | |
4141 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4142 } |
9806 | 4143 |
4144 curpart = curpart->next; | |
4145 } | |
4146 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4147 |
8666 | 4148 /* |
10781 | 4149 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
9016 | 4150 * because HTML is not sent over ICQ as a means to format a message. |
10781 | 4151 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
4152 * replaced with <br> | |
8995 | 4153 * |
4154 * Note: There *may* be some clients which send messages as HTML formatted - | |
4155 * they need to be special-cased somehow. | |
8666 | 4156 */ |
9982 | 4157 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 4158 /* 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
|
4159 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
8493 | 4160 g_free(tmp); |
4161 tmp = tmp2; | |
10783 | 4162 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
10781 | 4163 g_free(tmp); |
4164 tmp = tmp2; | |
8493 | 4165 } |
4166 | |
12675 | 4167 /* |
4168 * Convert iChat color tags to normal font tags. | |
4169 */ | |
4170 if (gaim_markup_find_tag("body", tmp, &start, &end, &attribs)) | |
4171 { | |
4172 const char *ichattextcolor, *ichatballooncolor; | |
4173 | |
4174 ichattextcolor = g_datalist_get_data(&attribs, "ichattextcolor"); | |
4175 if (ichattextcolor != NULL) | |
4176 { | |
4177 gchar *tmp2; | |
4178 tmp2 = g_strdup_printf("<font color=\"%s\">%s</font>", ichattextcolor, tmp); | |
4179 g_free(tmp); | |
4180 tmp = tmp2; | |
4181 } | |
4182 | |
4183 ichatballooncolor = g_datalist_get_data(&attribs, "ichatballooncolor"); | |
4184 if (ichatballooncolor != NULL) | |
4185 { | |
4186 gchar *tmp2; | |
4187 tmp2 = g_strdup_printf("<font back=\"%s\">%s</font>", ichatballooncolor, tmp); | |
4188 g_free(tmp); | |
4189 tmp = tmp2; | |
4190 } | |
4191 | |
4192 g_datalist_clear(&attribs); | |
4193 } | |
4194 | |
6982 | 4195 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4196 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4197 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4198 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4199 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4200 |
13239 | 4201 static int incomingim_chan2(OscarSession *sess, OscarConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 4202 GaimConnection *gc; |
9933 | 4203 GaimAccount *account; |
9070 | 4204 OscarData *od; |
9933 | 4205 const char *username = NULL; |
4206 char *message = NULL; | |
9070 | 4207 |
4208 g_return_val_if_fail(sess != NULL, 0); | |
4209 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
4210 | |
4211 gc = sess->aux_data; | |
9933 | 4212 account = gaim_connection_get_account(gc); |
9070 | 4213 od = gc->proto_data; |
9933 | 4214 username = gaim_account_get_username(account); |
4215 | |
4216 if (args == NULL) | |
4121 | 4217 return 0; |
4194 | 4218 |
9933 | 4219 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
4220 userinfo->sn, args->status); | |
4221 | |
4222 if (args->msg != NULL) | |
4223 { | |
4224 if (args->encoding != NULL) | |
4225 { | |
4226 char *encoding = NULL; | |
4227 encoding = oscar_encoding_extract(args->encoding); | |
4228 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
4229 g_free(encoding); | |
4230 } else { | |
4231 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
4232 message = g_strdup(args->msg); | |
4233 } | |
4234 } | |
2869 | 4235 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4236 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 4237 char *name; |
5234 | 4238 GHashTable *components; |
4239 | |
9933 | 4240 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
4241 g_free(message); | |
4121 | 4242 return 1; |
9933 | 4243 } |
5234 | 4244 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
4245 g_free); | |
4121 | 4246 name = extract_name(args->info.chat.roominfo.name); |
5234 | 4247 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
4248 g_hash_table_replace(components, g_strdup("exchange"), g_strdup_printf("%d", args->info.chat.roominfo.exchange)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4249 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4250 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4251 userinfo->sn, |
9933 | 4252 message, |
5234 | 4253 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4254 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4255 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4256 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 4257 /* BBB */ |
11369 | 4258 /* This is the first sendfile request where we need to notify the user that someone |
4259 * wants to send a file */ | |
4260 if (args->status == AIM_RENDEZVOUS_PROPOSE | |
4261 && (args->info.sendfile.reqnum == 0x0001)) { | |
4617 | 4262 /* Someone wants to send a file (or files) to us */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4263 GaimXfer *xfer; |
13252 | 4264 PeerConnection *peer_connection; |
13239 | 4265 PeerProxyInfo *proxy_info = NULL; |
11369 | 4266 gboolean use_rv_proxy; |
4267 int proxy_stage; | |
4268 int xfer_method; | |
4269 const char *proxy_ip = NULL; | |
13073 | 4270 |
11369 | 4271 if (!args->cookie || !args->port || |
13073 | 4272 !args->info.sendfile.filename || !args->info.sendfile.totsize || |
4656 | 4273 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 4274 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4275 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4276 "information.\n", userinfo->sn); |
9933 | 4277 g_free(message); |
4617 | 4278 return 1; |
4656 | 4279 } |
4617 | 4280 |
4281 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
4282 /* last char of the ft req is a star, they are sending us a | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
4283 * directory -- remove the star and trailing slash so we don't save |
4617 | 4284 * directories that look like 'dirname\*' -- arl */ |
4285 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
4286 if (tmp && (tmp[1] == '*')) { | |
4287 tmp[0] = '\0'; | |
4288 } | |
8660 | 4289 gaim_debug_warning("oscar", |
8446 | 4290 "We're receiving a whole directory! What fun! " |
4291 "Especially since we don't support that!\n"); | |
4617 | 4292 } |
4293 | |
4294 /* Build the file transfer handle */ | |
4295 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
13073 | 4296 |
13311
f6f465b8d1c0
[gaim-migrate @ 15677]
Richard Laager <rlaager@wiktel.com>
parents:
13296
diff
changeset
|
4297 use_rv_proxy = gaim_account_get_bool(account, "use_rv_proxy", OSCAR_DEFAULT_USE_RV_PROXY); |
13073 | 4298 |
11369 | 4299 if(args->info.sendfile.use_proxy) { |
4300 /* The sender requested (stage 1) that we use a rendezvous proxy */ | |
4301 xfer_method = AIM_XFER_PROXY; | |
4302 proxy_stage = AIM_XFER_PROXY_STG1; | |
4303 gaim_debug_info("oscar","using stage 1 proxy with ip: %s\n", | |
4304 args->proxyip, args->port); | |
4305 xfer->remote_ip = g_strdup(args->proxyip); | |
4306 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4307 proxy_info = aim_rv_proxy_createinfo(od->sess, args->cookie, args->port); | |
4308 } else if(use_rv_proxy) { | |
4309 /* If the local user indicated that a rendezvous proxy is necessary | |
4310 * start a stage 2 proxied transfer */ | |
4311 gaim_debug_info("oscar","using stage 2 proxied transfer\n"); | |
4312 xfer_method = AIM_XFER_PROXY; | |
4313 proxy_stage = AIM_XFER_PROXY_STG2; | |
4314 /* This hostname will be resolved by gaim_proxy_connect */ | |
4315 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
4316 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4317 proxy_info = aim_rv_proxy_createinfo(od->sess, args->cookie, 0); | |
4318 } else { | |
4319 /* We are receiving a file directly with no rendezvous proxy */ | |
4320 xfer_method = AIM_XFER_DIRECT; | |
4321 proxy_stage = AIM_XFER_PROXY_NONE; | |
4322 xfer->remote_ip = g_strdup(args->clientip); | |
4323 xfer->remote_port = args->port; | |
4324 } | |
13226 | 4325 |
11369 | 4326 /* Use UTF8 so that the world will be a happier place */ |
11238 | 4327 if (g_utf8_validate(args->info.sendfile.filename, -1, |
4328 NULL)) { | |
4329 gaim_xfer_set_filename(xfer, | |
4330 args->info.sendfile.filename); | |
4331 } else { | |
4332 gchar * utf8_filename = gaim_utf8_salvage( | |
4333 args->info.sendfile.filename); | |
4334 gaim_xfer_set_filename(xfer, utf8_filename); | |
4335 g_free(utf8_filename); | |
4336 } | |
4337 | |
4617 | 4338 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); |
13226 | 4339 |
11369 | 4340 /* Ignore messages that start with <ICQ_COOL_FT> (XML that is sent along |
4341 * with ICQ sendfile requests) & <HTML> message that is sent with AOL file | |
4342 * transfers (Note: this latter message is ignored only if whole message | |
4343 * is <HTML>, but not if it starts with <HTML> */ | |
4344 if(message && ( g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13) < 0 | |
4345 || g_ascii_strcasecmp(message,"<HTML>") == 0) ) { | |
4346 gaim_debug_info("oscar","Ignoring file transfer message: %s\n", message); | |
11084 | 4347 g_free(message); |
4348 message = NULL; | |
4349 } | |
9933 | 4350 gaim_xfer_set_message(xfer, message); |
5146 | 4351 |
4352 /* Create the oscar-specific data */ | |
13252 | 4353 peer_connection = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, |
11369 | 4354 xfer->remote_port, 0, 0, NULL, AIM_XFER_RECV, xfer_method, proxy_stage); |
4355 if(proxy_stage == AIM_XFER_PROXY_STG2 && proxy_ip) { | |
13252 | 4356 peer_connection->proxyip = g_strdup(proxy_ip); |
11369 | 4357 } else { |
4358 if (args->proxyip) | |
13252 | 4359 peer_connection->proxyip = g_strdup(args->proxyip); |
11369 | 4360 if (args->verifiedip) |
13252 | 4361 peer_connection->verifiedip = g_strdup(args->verifiedip); |
11369 | 4362 } |
13252 | 4363 peer_connection->proxy_info = proxy_info; |
4364 xfer->data = peer_connection; | |
4617 | 4365 |
4366 /* Setup our I/O op functions */ | |
8446 | 4367 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 4368 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 4369 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_recv); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
4370 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 4371 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 4372 |
4373 /* Keep track of this transfer for later */ | |
4374 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
13226 | 4375 |
4617 | 4376 /* Now perform the request */ |
4377 gaim_xfer_request(xfer); | |
11369 | 4378 /* A secondary request has been sent to negotiate the connection method */ |
4379 } else if (args->status == AIM_RENDEZVOUS_PROPOSE && args->info.sendfile.reqnum == 0x0002) { | |
4380 /* We have asked to send a file to someone else, but they sent us a reply request | |
4381 * asking us to use an alternative method of connecting */ | |
4382 GaimXfer *xfer; | |
13252 | 4383 PeerConnection *peer_connection; |
13226 | 4384 |
11369 | 4385 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { |
13252 | 4386 peer_connection = xfer->data; |
13226 | 4387 |
11369 | 4388 /* Stop the listener connection */ |
4389 gaim_input_remove(xfer->watcher); | |
13262 | 4390 oscar_connection_destroy(sess, peer_connection->conn); /* This is currently the listener */ |
11369 | 4391 |
4392 if(args->info.sendfile.use_proxy) { | |
4393 gaim_debug_info("oscar", | |
4394 "received request for stage 2 rv proxy with ip: %s\n", | |
4395 args->proxyip); | |
13252 | 4396 peer_connection->method = AIM_XFER_PROXY; |
4397 peer_connection->stage = AIM_XFER_PROXY_STG2; | |
4398 | |
4399 peer_connection->proxy_info = aim_rv_proxy_createinfo(peer_connection->sess, | |
11369 | 4400 args->cookie, args->port); |
4401 if(args->proxyip) { | |
4402 if(xfer->remote_ip) | |
4403 g_free(xfer->remote_ip); | |
4404 xfer->remote_ip = g_strdup(args->proxyip); | |
4405 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4406 oscar_xfer_init_recv(xfer); | |
4407 } else { | |
4408 gaim_debug_warning("oscar", | |
4409 "stage 2 rv proxy file send: no proxy ip specified\n"); | |
4410 } | |
4411 } else if(args->clientip | |
4412 && g_ascii_strcasecmp(args->clientip,"0.0.0.0") == 0) | |
4413 { | |
4414 gaim_debug_warning("oscar", | |
4415 "other client wants us to send stage 3 proxy info\n"); | |
13252 | 4416 peer_connection->method = AIM_XFER_PROXY; |
4417 peer_connection->stage = AIM_XFER_PROXY_STG3; | |
4418 | |
4419 /* Clean useless data from peer_connection */ | |
4420 peer_connection->clientip = NULL; | |
4421 peer_connection->verifiedip = NULL; | |
13226 | 4422 |
11369 | 4423 /* This hostname will be resolved in gaim_proxy_connect */ |
4424 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
4425 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
13226 | 4426 |
13252 | 4427 peer_connection->proxy_info |
11369 | 4428 = aim_rv_proxy_createinfo(od->sess, args->cookie, 0); |
4429 oscar_xfer_init_recv(xfer); | |
4430 } else { | |
4431 gaim_debug_info("oscar","received request to redirect transfer; clientip/verifiedip: %s / %s\n", | |
4432 args->clientip, args->verifiedip); | |
13252 | 4433 peer_connection->method = AIM_XFER_REDIR; |
11369 | 4434 if (args->verifiedip) |
13252 | 4435 peer_connection->verifiedip = g_strdup(args->verifiedip); |
11369 | 4436 if (args->clientip) { |
13252 | 4437 peer_connection->clientip = g_strdup(args->clientip); |
11369 | 4438 xfer->remote_ip = g_strdup(args->clientip); |
4439 } | |
4440 xfer->remote_port = args->port; | |
13226 | 4441 |
11369 | 4442 /* This file send will briefly follow file receive codepaths */ |
4443 oscar_xfer_init_recv(xfer); | |
4444 } | |
4445 } else { | |
4446 gaim_debug_warning("oscar","received file tranfer reply request: xfer not found\n"); | |
4447 } | |
4448 /* A THIRD request has been sent trying to figure out what connection method will be used | |
4449 * to transfer this file */ | |
4450 } else if (args->status == AIM_RENDEZVOUS_PROPOSE && args->info.sendfile.reqnum == 0x0003) { | |
4451 /* We are receiving a file from someone. We sent a request to use a stage 3 | |
4452 * proxy. They did the initial proxy login and have sent us the info in a | |
4453 * third file transfer request. */ | |
4454 GaimXfer *xfer; | |
13252 | 4455 PeerConnection *peer_connection; |
13226 | 4456 |
11369 | 4457 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { |
13252 | 4458 peer_connection = xfer->data; |
11369 | 4459 |
4460 /* We are receiving a file */ | |
4461 gaim_debug_info("oscar", | |
4462 "other client sent us stage 3 proxy info\n"); | |
13226 | 4463 |
11369 | 4464 /* The following pieces of information should already have |
4465 * been set in oscar_xfer_ip_timeout, but we'll list them | |
4466 * again just for clarity. */ | |
13252 | 4467 peer_connection->method = AIM_XFER_PROXY; |
4468 peer_connection->stage = AIM_XFER_PROXY_STG3; | |
4469 | |
4470 peer_connection->proxy_info = aim_rv_proxy_createinfo(peer_connection->sess, | |
11369 | 4471 args->cookie, args->port); |
4472 if(args->proxyip) { | |
4473 if(xfer->remote_ip) | |
4474 g_free(xfer->remote_ip); | |
4475 xfer->remote_ip = g_strdup(args->proxyip); | |
4476 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4477 oscar_xfer_init_recv(xfer); | |
4478 } else { | |
4479 gaim_debug_warning("oscar", | |
4480 "stage 3 rv proxy file receive: no proxy ip specified\n"); | |
4481 } | |
4482 } else { | |
4483 gaim_debug_warning("oscar","received file tranfer reply request: xfer not found\n"); | |
4484 } | |
4617 | 4485 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { |
4486 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4487 GaimXfer *xfer; |
8660 | 4488 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4489 "AAA - File transfer canceled by remote user\n"); |
4617 | 4490 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
4491 gaim_xfer_cancel_remote(xfer); |
4617 | 4492 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
4493 /* | |
13226 | 4494 * This gets sent by the receiver of a file |
4495 * as they connect directly to us. If we don't | |
4496 * get this, then maybe a third party connected | |
4617 | 4497 * to us, and we shouldn't send them anything. |
4498 */ | |
11214 | 4499 gaim_debug_info("oscar", |
13226 | 4500 "AAA - received chan 2 AIM_RENDEZVOUS_ACCEPT; ignoring\n"); |
4617 | 4501 } else { |
8660 | 4502 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4503 "unknown rendezvous status!\n"); |
3630 | 4504 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4505 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 4506 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4507 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 4508 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
4509 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4510 args->info.icon.length); |
6871 | 4511 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 4512 /* Consider moving all this into a helper func in the direct im block way up there */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4513 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 4514 struct oscar_direct_im *dim = oscar_direct_im_find(od, userinfo->sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4515 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4516 |
4212 | 4517 if (!args->verifiedip) { |
8983 | 4518 /* TODO: do something about this, after figuring out what it means */ |
8660 | 4519 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4520 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 4521 g_free(message); |
4650 | 4522 return 1; |
4212 | 4523 } |
4524 | |
8660 | 4525 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4526 "%s received direct im request from %s (%s)\n", |
10594 | 4527 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4528 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4529 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4530 d->sn = g_strdup(userinfo->sn); |
8983 | 4531 /* Let's use the clientip here, because I think that's what AIM does. |
4532 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
4533 * and then ask them to connect to us. */ | |
10594 | 4534 /* |
4535 * I disagree, let's use the verifiedip. I think AIM tries the | |
4536 * verified IP first, then tries the client IP if that fails. In | |
4537 * any case, there's a better chance the verified IP will be correct. | |
4538 * The client IP is what the other person _thinks_ their IP address | |
4539 * is. The verified IP is the address that the AIM server sees the | |
4540 * other person using. | |
4541 */ | |
4542 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->verifiedip, args->port?args->port:5190); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4543 memcpy(d->cookie, args->cookie, 8); |
9070 | 4544 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
13226 | 4545 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { |
9070 | 4546 |
8971 | 4547 oscar_direct_im_destroy(od, dim); |
8984 | 4548 d->donttryagain = TRUE; |
8971 | 4549 accept_direct_im_request(d); |
4550 } else { | |
8983 | 4551 if (dim && !dim->connected) |
13226 | 4552 gaim_debug_warning("oscar", "DirectIM: received direct im request " |
4553 "while already connected to that buddy!"); | |
5575 | 4554 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, username); |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4555 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4556 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4557 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4558 "the two computers and is necessary for IM " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4559 "Images. Because your IP address will be " |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4560 "revealed, this may be considered a privacy " |
13226 | 4561 "risk."), |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4562 GAIM_DEFAULT_ACTION_NONE, d, 2, |
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4563 _("_Connect"), G_CALLBACK(accept_direct_im_request), |
8971 | 4564 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); |
4565 /* FIXME: we should actually send a packet on cancel */ | |
4566 } | |
8708 | 4567 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
4568 gaim_debug_error("oscar", "Got an ICQ Server Relay message of type %d\n", args->info.rtfmsg.msgtype); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4569 } else { |
8660 | 4570 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4571 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4572 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4573 |
9933 | 4574 g_free(message); |
4575 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4576 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4577 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4578 |
3453 | 4579 /* |
4230 | 4580 * Authorization Functions |
13226 | 4581 * Most of these are callbacks from dialogs. They're used by both |
4230 | 4582 * methods of authorization (SSI and old-school channel 4 ICBM) |
3453 | 4583 */ |
4269 | 4584 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4585 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 4586 GaimConnection *gc = data->gc; |
4244 | 4587 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4588 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 4589 OscarData *od = gc->proto_data; |
6695 | 4590 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
12088 | 4591 GaimGroup *group = gaim_buddy_get_group(buddy); |
4244 | 4592 if (buddy && group) { |
8660 | 4593 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4594 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4595 buddy->name, group->name); |
4889 | 4596 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 4597 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 4598 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 4599 } |
4230 | 4600 } |
4337 | 4601 } |
4602 | |
4603 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4604 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 4605 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4606 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 4607 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4608 data); |
4230 | 4609 } |
4610 | |
4611 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 4612 GaimConnection *gc = data->gc; |
4244 | 4613 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4614 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 4615 /* Remove from local list */ |
4616 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
4617 gaim_blist_remove_buddy(b); | |
4244 | 4618 } |
4619 | |
5836 | 4620 oscar_free_name_data(data); |
4230 | 4621 } |
4622 | |
9030 | 4623 |
4624 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
13262 | 4625 struct name_data *data = g_new0(struct name_data, 1); |
6695 | 4626 GaimBuddy *buddy; |
4269 | 4627 gchar *dialog_msg, *nombre; |
4628 | |
4687 | 4629 buddy = gaim_find_buddy(gc->account, name); |
9620 | 4630 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
4631 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 4632 else |
4830 | 4633 nombre = NULL; |
4634 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4635 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 | 4636 data->gc = gc; |
4637 data->name = g_strdup(name); | |
4638 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4639 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4640 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4641 0, data, 2, |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4642 _("_Request Authorization"), |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4643 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4644 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 4645 |
4646 g_free(dialog_msg); | |
4647 g_free(nombre); | |
4648 } | |
4649 | |
9030 | 4650 |
4651 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
4652 GaimBuddy *buddy; | |
4653 GaimConnection *gc; | |
4654 | |
4655 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
4656 | |
4657 buddy = (GaimBuddy *) node; | |
4658 gc = gaim_account_get_connection(buddy->account); | |
4659 gaim_auth_sendrequest(gc, buddy->name); | |
4660 } | |
4661 | |
4230 | 4662 /* When other people ask you for authorization */ |
4663 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 4664 GaimConnection *gc = data->gc; |
4244 | 4665 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4666 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 4667 OscarData *od = gc->proto_data; |
4889 | 4668 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4244 | 4669 } |
4670 | |
5836 | 4671 oscar_free_name_data(data); |
3141 | 4672 } |
4673 | |
4230 | 4674 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4675 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 4676 GaimConnection *gc = data->gc; |
4244 | 4677 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4678 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 4679 OscarData *od = gc->proto_data; |
4889 | 4680 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4244 | 4681 } |
4337 | 4682 } |
4683 | |
4684 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4685 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 4686 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4687 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 4688 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4689 data); |
3141 | 4690 } |
4691 | |
7023 | 4692 /* When someone sends you buddies */ |
4693 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 4694 GaimConnection *gc = data->gc; |
4244 | 4695 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4696 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
4697 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 4698 } |
4699 | |
5836 | 4700 oscar_free_name_data(data); |
3453 | 4701 } |
4702 | |
13239 | 4703 static int incomingim_chan4(OscarSession *sess, OscarConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) { |
5575 | 4704 GaimConnection *gc = sess->aux_data; |
9908 | 4705 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 4706 gchar **msg1, **msg2; |
6051 | 4707 int i, numtoks; |
4076 | 4708 |
4121 | 4709 if (!args->type || !args->msg || !args->uin) |
4710 return 1; | |
4194 | 4711 |
8660 | 4712 gaim_debug_info("oscar", |
9908 | 4713 "Received a channel 4 message of type 0x%02hhx.\n", |
4714 args->type); | |
4076 | 4715 |
9919 | 4716 /* |
4717 * Split up the message at the delimeter character, then convert each | |
4718 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
4719 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
4720 * character in whatever encoding the message was sent in. Type 1 | |
4721 * messages are always made up of only one part, so we can easily account | |
4722 * for this suck-ass part of the protocol by splitting the string into at | |
4723 * most 1 baby string. | |
4724 */ | |
4725 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 4726 for (numtoks=0; msg1[numtoks]; numtoks++); |
4727 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 4728 for (i=0; msg1[i]; i++) { |
11920 | 4729 gaim_str_strip_char(msg1[i], '\r'); |
9908 | 4730 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 4731 } |
4732 msg2[i] = NULL; | |
4733 | |
3952 | 4734 switch (args->type) { |
4173 | 4735 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 4736 if (i >= 1) { |
5556 | 4737 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 4738 gchar *tmp; |
4739 | |
4740 /* 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
|
4741 tmp = g_markup_escape_text(msg2[0], -1); |
8493 | 4742 |
4076 | 4743 if (t) { /* This is an offline message */ |
9680 | 4744 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 4745 #ifdef HAVE_TM_GMTOFF |
9724 | 4746 time_t now; |
4747 struct tm *tm; | |
4748 now = time(NULL); | |
4749 tm = localtime(&now); | |
4750 t += tm->tm_gmtoff; | |
9698 | 4751 #else |
4752 # ifdef HAVE_TIMEZONE | |
9680 | 4753 tzset(); |
4754 t -= timezone; | |
9698 | 4755 # endif |
4756 #endif | |
8514 | 4757 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 4758 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 4759 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 4760 } |
4761 g_free(uin); | |
8493 | 4762 g_free(tmp); |
4075 | 4763 } |
3316 | 4764 } break; |
4765 | |
4173 | 4766 case 0x04: { /* Someone sent you a URL */ |
4076 | 4767 if (i >= 2) { |
7385 | 4768 if (msg2[1] != NULL) { |
4769 gchar *uin = g_strdup_printf("%u", args->uin); | |
4770 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
4771 msg2[1], | |
4772 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
4773 serv_got_im(gc, uin, message, 0, time(NULL)); | |
4774 g_free(uin); | |
4775 g_free(message); | |
4776 } | |
3453 | 4777 } |
4778 } break; | |
4779 | |
4173 | 4780 case 0x06: { /* Someone requested authorization */ |
4076 | 4781 if (i >= 6) { |
4230 | 4782 struct name_data *data = g_new(struct name_data, 1); |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4783 gchar *sn = g_strdup_printf("%u", args->uin); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4784 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4785 gchar *dialog_msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4786 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4787 if (msg2[5] != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4788 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
|
4789 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4790 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4791 |
11369 | 4792 dialog_msg = g_strdup_printf(_("The user %u wants to add %s to their buddy list for the following reason:\n%s"), |
4793 args->uin, gaim_account_get_username(gc->account), reason); | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4794 g_free(reason); |
8660 | 4795 gaim_debug_info("oscar", |
5556 | 4796 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4797 args->uin); |
4076 | 4798 data->gc = gc; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4799 data->name = sn; |
4230 | 4800 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4801 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4802 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 4803 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4804 2, _("_Authorize"), |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4805 G_CALLBACK(gaim_auth_grant), |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4806 _("_Deny"), |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4807 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 4808 g_free(dialog_msg); |
4809 } | |
3141 | 4810 } break; |
4811 | |
4173 | 4812 case 0x07: { /* Someone has denied you authorization */ |
4076 | 4813 if (i >= 1) { |
7023 | 4814 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
|
4815 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4816 dialog_msg); |
4076 | 4817 g_free(dialog_msg); |
4818 } | |
3141 | 4819 } break; |
4820 | |
4173 | 4821 case 0x08: { /* Someone has granted you authorization */ |
7023 | 4822 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
|
4823 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4824 dialog_msg); |
3141 | 4825 g_free(dialog_msg); |
4826 } break; | |
4827 | |
4333 | 4828 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
4829 if (i >= 5) { | |
4830 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
|
4831 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 4832 g_free(dialog_msg); |
4833 } | |
4834 } break; | |
4835 | |
4173 | 4836 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 4837 if (i >= 6) { |
4194 | 4838 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
|
4839 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 4840 g_free(dialog_msg); |
4841 } | |
4075 | 4842 } break; |
4843 | |
4173 | 4844 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 4845 if (i >= 6) { |
4308 | 4846 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ email from %s [%s]\n\nMessage is:\n%s"), msg2[0], msg2[3], msg2[5]); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4847 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 4848 g_free(dialog_msg); |
4849 } | |
4075 | 4850 } break; |
4851 | |
4173 | 4852 case 0x12: { |
3141 | 4853 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 4854 /* Someone added you to their buddy list? */ |
3141 | 4855 } break; |
4856 | |
7023 | 4857 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 4858 guint i, num; |
3453 | 4859 gchar **text; |
4173 | 4860 text = g_strsplit(args->msg, "\376", 0); |
3453 | 4861 if (text) { |
4862 num = 0; | |
4863 for (i=0; i<strlen(text[0]); i++) | |
4864 num = num*10 + text[0][i]-48; | |
4865 for (i=0; i<num; i++) { | |
4230 | 4866 struct name_data *data = g_new(struct name_data, 1); |
7023 | 4867 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 | 4868 data->gc = gc; |
4790 | 4869 data->name = g_strdup(text[i*2+1]); |
4870 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4871 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4872 gaim_request_action(gc, NULL, message, |
7023 | 4873 _("Do you want to add this buddy " |
4874 "to your buddy list?"), | |
9972 | 4875 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 4876 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4877 _("_Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 4878 g_free(message); |
4879 } | |
4880 g_strfreev(text); | |
4881 } | |
4882 } break; | |
4883 | |
7023 | 4884 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 4885 /* This is boring and silly. */ |
4886 } break; | |
4887 | |
3141 | 4888 default: { |
8660 | 4889 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4890 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4891 "(type 0x%02hhx).\n", args->type); |
3141 | 4892 } break; |
4893 } | |
4894 | |
4076 | 4895 g_strfreev(msg1); |
4896 g_strfreev(msg2); | |
4897 | |
3141 | 4898 return 1; |
4899 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4900 |
13239 | 4901 static int gaim_parse_incoming_im(OscarSession *sess, FlapFrame *fr, ...) { |
13234 | 4902 guint16 channel; |
4200 | 4903 int ret = 0; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4904 aim_userinfo_t *userinfo; |
2086 | 4905 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4906 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4907 va_start(ap, fr); |
13234 | 4908 channel = (guint16)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4909 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4910 |
3141 | 4911 switch (channel) { |
4912 case 1: { /* standard message */ | |
4913 struct aim_incomingim_ch1_args *args; | |
4914 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
4915 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
4916 } break; | |
4917 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
4918 case 2: { /* rendezvous */ |
3141 | 4919 struct aim_incomingim_ch2_args *args; |
4920 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
4921 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
4922 } break; | |
4923 | |
4924 case 4: { /* ICQ */ | |
4925 struct aim_incomingim_ch4_args *args; | |
4926 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 4927 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 4928 } break; |
4929 | |
4930 default: { | |
8660 | 4931 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4932 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4933 "0x%04hx).", channel); |
3141 | 4934 } break; |
2086 | 4935 } |
4936 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4937 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4938 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4939 return ret; |
2086 | 4940 } |
4941 | |
13239 | 4942 static int gaim_parse_misses(OscarSession *sess, FlapFrame *fr, ...) { |
8733 | 4943 GaimConnection *gc = sess->aux_data; |
4944 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 4945 char *buf; |
2086 | 4946 va_list ap; |
13234 | 4947 guint16 chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4948 aim_userinfo_t *userinfo; |
2086 | 4949 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4950 va_start(ap, fr); |
13234 | 4951 chan = (guint16)va_arg(ap, unsigned int); |
4200 | 4952 userinfo = va_arg(ap, aim_userinfo_t *); |
13234 | 4953 nummissed = (guint16)va_arg(ap, unsigned int); |
4954 reason = (guint16)va_arg(ap, unsigned int); | |
2086 | 4955 va_end(ap); |
4956 | |
4957 switch(reason) { | |
5420 | 4958 case 0: /* Invalid (0) */ |
4959 buf = g_strdup_printf( | |
4960 ngettext( | |
4276 | 4961 "You missed %hu message from %s because it was invalid.", |
4962 "You missed %hu messages from %s because they were invalid.", | |
4963 nummissed), | |
4282 | 4964 nummissed, |
4965 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4966 break; |
5420 | 4967 case 1: /* Message too large */ |
4968 buf = g_strdup_printf( | |
4969 ngettext( | |
4276 | 4970 "You missed %hu message from %s because it was too large.", |
4971 "You missed %hu messages from %s because they were too large.", | |
4972 nummissed), | |
4282 | 4973 nummissed, |
4974 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4975 break; |
5420 | 4976 case 2: /* Rate exceeded */ |
4977 buf = g_strdup_printf( | |
4978 ngettext( | |
4276 | 4979 "You missed %hu message from %s because the rate limit has been exceeded.", |
4980 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
4981 nummissed), | |
4282 | 4982 nummissed, |
4983 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4984 break; |
5420 | 4985 case 3: /* Evil Sender */ |
4986 buf = g_strdup_printf( | |
4987 ngettext( | |
4276 | 4988 "You missed %hu message from %s because he/she was too evil.", |
4989 "You missed %hu messages from %s because he/she was too evil.", | |
4990 nummissed), | |
4282 | 4991 nummissed, |
4992 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4993 break; |
5420 | 4994 case 4: /* Evil Receiver */ |
4995 buf = g_strdup_printf( | |
4996 ngettext( | |
4276 | 4997 "You missed %hu message from %s because you are too evil.", |
4998 "You missed %hu messages from %s because you are too evil.", | |
4999 nummissed), | |
4282 | 5000 nummissed, |
5001 userinfo->sn); | |
2086 | 5002 break; |
5003 default: | |
5420 | 5004 buf = g_strdup_printf( |
5005 ngettext( | |
4276 | 5006 "You missed %hu message from %s for an unknown reason.", |
5007 "You missed %hu messages from %s for an unknown reason.", | |
5008 nummissed), | |
4282 | 5009 nummissed, |
5010 userinfo->sn); | |
2086 | 5011 break; |
5012 } | |
8733 | 5013 |
9627 | 5014 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 5015 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5016 g_free(buf); |
2086 | 5017 |
5018 return 1; | |
5019 } | |
5020 | |
13239 | 5021 static int gaim_parse_clientauto_ch2(OscarSession *sess, const char *who, guint16 reason, const guchar *cookie) { |
5575 | 5022 GaimConnection *gc = sess->aux_data; |
7283 | 5023 OscarData *od = gc->proto_data; |
4617 | 5024 |
5025 /* BBB */ | |
3630 | 5026 switch (reason) { |
4151 | 5027 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
5028 GaimXfer *xfer; |
8971 | 5029 struct oscar_direct_im *dim; |
5030 | |
8660 | 5031 gaim_debug_info("oscar", |
9070 | 5032 "AAA - Other user declined some sort of direct " |
8971 | 5033 "connect attempt (automaticly?)\n"); |
4617 | 5034 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
5035 gaim_xfer_cancel_remote(xfer); |
8971 | 5036 else if ((dim = oscar_direct_im_find(od, who))) { |
5037 /* AAA should use find by cookie or something here */ | |
5038 oscar_direct_im_disconnect(od, dim); | |
5039 } | |
4151 | 5040 } break; |
5041 | |
5042 default: { | |
8660 | 5043 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5044 "Received an unknown rendezvous client auto-response " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5045 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 5046 } |
3630 | 5047 |
5048 } | |
5049 | |
5050 return 0; | |
5051 } | |
5052 | |
13239 | 5053 static int gaim_parse_clientauto_ch4(OscarSession *sess, char *who, guint16 reason, guint32 state, char *msg) { |
5575 | 5054 GaimConnection *gc = sess->aux_data; |
4151 | 5055 |
5056 switch(reason) { | |
5057 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 5058 char *title, *statusmsg, **splitmsg, *dialogmsg; |
5059 | |
5060 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 5061 |
5062 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 5063 statusmsg = oscar_icqstatus(state); |
4151 | 5064 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 5065 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
5066 g_free(statusmsg); | |
4151 | 5067 g_strfreev(splitmsg); |
9244 | 5068 |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
5069 gaim_notify_userinfo(gc, who, dialogmsg, NULL, NULL); |
9244 | 5070 |
5071 g_free(title); | |
5072 g_free(dialogmsg); | |
4151 | 5073 } break; |
5074 | |
5075 default: { | |
8660 | 5076 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5077 "Received an unknown client auto-response from %s. " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5078 "Type 0x%04hx\n", who, reason); |
4151 | 5079 } break; |
5080 } /* end of switch */ | |
5081 | |
5082 return 0; | |
5083 } | |
5084 | |
13239 | 5085 static int gaim_parse_clientauto(OscarSession *sess, FlapFrame *fr, ...) { |
3212 | 5086 va_list ap; |
13234 | 5087 guint16 chan, reason; |
3212 | 5088 char *who; |
5089 | |
5090 va_start(ap, fr); | |
13234 | 5091 chan = (guint16)va_arg(ap, unsigned int); |
3212 | 5092 who = va_arg(ap, char *); |
13234 | 5093 reason = (guint16)va_arg(ap, unsigned int); |
3212 | 5094 |
3952 | 5095 if (chan == 0x0002) { /* File transfer declined */ |
11159 | 5096 guchar *cookie = va_arg(ap, guchar *); |
4151 | 5097 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 5098 } else if (chan == 0x0004) { /* ICQ message */ |
13234 | 5099 guint32 state = 0; |
4151 | 5100 char *msg = NULL; |
5101 if (reason == 0x0003) { | |
13234 | 5102 state = va_arg(ap, guint32); |
4151 | 5103 msg = va_arg(ap, char *); |
5104 } | |
5105 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
5106 } | |
3952 | 5107 |
3212 | 5108 va_end(ap); |
5109 | |
5110 return 1; | |
5111 } | |
5112 | |
13239 | 5113 static int gaim_parse_genericerr(OscarSession *sess, FlapFrame *fr, ...) { |
2086 | 5114 va_list ap; |
13234 | 5115 guint16 reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5116 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5117 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5118 va_start(ap, fr); |
13234 | 5119 reason = (guint16) va_arg(ap, unsigned int); |
2086 | 5120 va_end(ap); |
5121 | |
8660 | 5122 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5123 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5124 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 5125 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5126 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 5127 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5128 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5129 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5130 |
2086 | 5131 return 1; |
5132 } | |
5133 | |
13239 | 5134 static int gaim_parse_msgerr(OscarSession *sess, FlapFrame *fr, ...) { |
9627 | 5135 GaimConnection *gc = sess->aux_data; |
4617 | 5136 #if 0 |
7283 | 5137 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
5138 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5139 #endif |
4617 | 5140 va_list ap; |
13234 | 5141 guint16 reason; |
4617 | 5142 char *data, *buf; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5143 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5144 va_start(ap, fr); |
13234 | 5145 reason = (guint16)va_arg(ap, unsigned int); |
3752 | 5146 data = va_arg(ap, char *); |
2086 | 5147 va_end(ap); |
5148 | |
8660 | 5149 gaim_debug_error("oscar", |
10130 | 5150 "Message error with data %s and reason %hu\n", |
5151 (data != NULL ? data : ""), reason); | |
4617 | 5152 |
5153 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5154 #if 0 |
4617 | 5155 /* If this was a file transfer request, data is a cookie */ |
5156 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
|
5157 gaim_xfer_cancel_remote(xfer); |
3630 | 5158 return 1; |
5159 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5160 #endif |
3630 | 5161 |
4617 | 5162 /* Data is assumed to be the destination sn */ |
9826 | 5163 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
5164 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
5165 g_free(buf); | |
5166 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 5167 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 5168 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
5169 } | |
5170 g_free(buf); | |
5171 | |
2086 | 5172 return 1; |
5173 } | |
5174 | |
13239 | 5175 static int gaim_parse_mtn(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 5176 GaimConnection *gc = sess->aux_data; |
3595 | 5177 va_list ap; |
13234 | 5178 guint16 type1, type2; |
3595 | 5179 char *sn; |
5180 | |
5181 va_start(ap, fr); | |
13234 | 5182 type1 = (guint16) va_arg(ap, unsigned int); |
3595 | 5183 sn = va_arg(ap, char *); |
13234 | 5184 type2 = (guint16) va_arg(ap, unsigned int); |
3595 | 5185 va_end(ap); |
5186 | |
5187 switch (type2) { | |
5188 case 0x0000: { /* Text has been cleared */ | |
5189 serv_got_typing_stopped(gc, sn); | |
5190 } break; | |
5191 | |
5192 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5193 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 5194 } break; |
5195 | |
5196 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5197 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 5198 } break; |
5199 | |
5200 default: { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5201 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 | 5202 } break; |
5203 } | |
5204 | |
5205 return 1; | |
5206 } | |
5207 | |
7141 | 5208 /* |
5209 * We get this error when there was an error in the locate family. This | |
7259 | 5210 * happens when you request info of someone who is offline. |
7141 | 5211 */ |
13239 | 5212 static int gaim_parse_locerr(OscarSession *sess, FlapFrame *fr, ...) { |
9826 | 5213 gchar *buf; |
2086 | 5214 va_list ap; |
13234 | 5215 guint16 reason; |
2086 | 5216 char *destn; |
5217 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5218 va_start(ap, fr); |
13234 | 5219 reason = (guint16) va_arg(ap, unsigned int); |
2086 | 5220 destn = va_arg(ap, char *); |
5221 va_end(ap); | |
5222 | |
7781 | 5223 if (destn == NULL) |
7793 | 5224 return 1; |
12653 | 5225 |
9826 | 5226 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
5227 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
5228 g_free(buf); | |
9627 | 5229 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 5230 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
5231 } | |
5232 g_free(buf); | |
2086 | 5233 |
5234 return 1; | |
5235 } | |
5236 | |
13239 | 5237 static int gaim_parse_userinfo(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 5238 GaimConnection *gc = sess->aux_data; |
8700 | 5239 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 5240 OscarData *od = gc->proto_data; |
8700 | 5241 GString *str; |
11532
57439a383f4f
[gaim-migrate @ 13781]
Luke Schierer <lschiere@pidgin.im>
parents:
11531
diff
changeset
|
5242 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; |
4791 | 5243 va_list ap; |
7011 | 5244 aim_userinfo_t *userinfo; |
2086 | 5245 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5246 va_start(ap, fr); |
7011 | 5247 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 5248 va_end(ap); |
5249 | |
8700 | 5250 str = g_string_new(""); |
5251 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
5252 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 5253 |
10116 | 5254 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 5255 time_t t = userinfo->onlinesince - od->timeoffset; |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
5256 oscar_string_append(gc->account, str, "\n<br>", _("Online Since"), gaim_date_format_full(localtime(&t))); |
10116 | 5257 } |
5258 | |
5259 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 5260 time_t t = userinfo->membersince - od->timeoffset; |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
5261 oscar_string_append(gc->account, str, "\n<br>", _("Member Since"), gaim_date_format_full(localtime(&t))); |
10116 | 5262 } |
7011 | 5263 |
12430 | 5264 if (userinfo->capabilities != 0) { |
5265 tmp = oscar_caps_to_string(userinfo->capabilities); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
5266 oscar_string_append(gc->account, str, "\n<br>", _("Capabilities"), tmp); |
12430 | 5267 g_free(tmp); |
5268 } | |
5269 | |
7011 | 5270 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
8700 | 5271 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
5272 oscar_string_append(gc->account, str, "\n<br>", _("Idle"), tmp); |
8700 | 5273 g_free(tmp); |
5274 } | |
5275 | |
8701 | 5276 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 5277 |
13007 | 5278 /* Available message */ |
5279 if ((userinfo->status != NULL) && !(userinfo->flags & AIM_FLAG_AWAY)) | |
5280 { | |
5281 if (userinfo->status[0] != '\0') | |
5282 tmp = oscar_encoding_to_utf8(userinfo->status_encoding, | |
5283 userinfo->status, userinfo->status_len); | |
5284 oscar_string_append(gc->account, str, "\n<br>", _("Available Message"), tmp); | |
5285 g_free(tmp); | |
5286 } | |
5287 | |
5288 /* Away message */ | |
7011 | 5289 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { |
8700 | 5290 tmp = oscar_encoding_extract(userinfo->away_encoding); |
5291 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
5292 g_free(tmp); | |
7011 | 5293 if (away_utf8 != NULL) { |
12661 | 5294 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 5295 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5296 } |
7011 | 5297 } |
5298 | |
13007 | 5299 /* Info */ |
7011 | 5300 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { |
8700 | 5301 tmp = oscar_encoding_extract(userinfo->info_encoding); |
5302 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
5303 g_free(tmp); | |
7011 | 5304 if (info_utf8 != NULL) { |
12661 | 5305 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 5306 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5307 } |
7011 | 5308 } |
5309 | |
8701 | 5310 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 5311 g_string_free(str, TRUE); |
11920 | 5312 gaim_str_strip_char(tmp, '\r'); |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
5313 gaim_notify_userinfo(gc, userinfo->sn, tmp, NULL, NULL); |
8700 | 5314 g_free(tmp); |
4151 | 5315 |
2086 | 5316 return 1; |
5317 } | |
5318 | |
13239 | 5319 static int gaim_got_infoblock(OscarSession *sess, FlapFrame *fr, ...) |
12189 | 5320 { |
5321 GaimConnection *gc = sess->aux_data; | |
5322 GaimBuddy *b; | |
5323 GaimPresence *presence; | |
12349 | 5324 GaimStatus *status; |
12189 | 5325 gchar *message = NULL; |
5326 | |
5327 va_list ap; | |
5328 aim_userinfo_t *userinfo; | |
5329 | |
5330 va_start(ap, fr); | |
5331 userinfo = va_arg(ap, aim_userinfo_t *); | |
5332 va_end(ap); | |
5333 | |
5334 b = gaim_find_buddy(gaim_connection_get_account(gc), userinfo->sn); | |
5335 if (b == NULL) | |
5336 return 1; | |
5337 | |
5338 presence = gaim_buddy_get_presence(b); | |
12349 | 5339 status = gaim_presence_get_active_status(presence); |
5340 | |
12426 | 5341 if (!gaim_status_is_available(status) && gaim_status_is_online(status)) |
12271 | 5342 { |
12189 | 5343 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && |
5344 (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
5345 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); | |
5346 message = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); | |
5347 g_free(charset); | |
12393 | 5348 gaim_status_set_attr_string(status, "message", message); |
5349 g_free(message); | |
12189 | 5350 } |
12349 | 5351 |
5352 gaim_blist_update_buddy_status(b, status); | |
5353 } | |
12189 | 5354 |
5355 return 1; | |
5356 } | |
5357 | |
8341 | 5358 static gboolean gaim_reqinfo_timeout_cb(void *data) |
5359 { | |
13239 | 5360 OscarSession *sess = data; |
8341 | 5361 GaimConnection *gc = sess->aux_data; |
5362 OscarData *od = (OscarData *)gc->proto_data; | |
5363 | |
5364 aim_locate_dorequest(data); | |
5365 od->getinfotimer = 0; | |
5366 | |
5367 return FALSE; | |
5368 } | |
5369 | |
13239 | 5370 static int gaim_reqinfo_timeout(OscarSession *sess, FlapFrame *fr, ...) |
8341 | 5371 { |
5372 GaimConnection *gc = sess->aux_data; | |
5373 OscarData *od = (OscarData *)gc->proto_data; | |
5374 | |
5375 /* | |
5376 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
5377 * us from hitting the rate limit due to request away messages and info | |
5378 * too quickly. | |
5379 */ | |
5380 if (od->getinfotimer == 0) | |
11670 | 5381 od->getinfotimer = gaim_timeout_add(10000, gaim_reqinfo_timeout_cb, sess); |
8341 | 5382 |
5383 return 1; | |
5384 } | |
5385 | |
13239 | 5386 static int gaim_parse_motd(OscarSession *sess, FlapFrame *fr, ...) |
8341 | 5387 { |
2086 | 5388 char *msg; |
13234 | 5389 guint16 id; |
2086 | 5390 va_list ap; |
5391 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5392 va_start(ap, fr); |
13234 | 5393 id = (guint16) va_arg(ap, unsigned int); |
2086 | 5394 msg = va_arg(ap, char *); |
5395 va_end(ap); | |
5396 | |
8660 | 5397 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5398 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
5399 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5400 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5401 _("Your AIM connection may be lost."), NULL); |
2086 | 5402 |
5403 return 1; | |
5404 } | |
5405 | |
13239 | 5406 static int gaim_chatnav_info(OscarSession *sess, FlapFrame *fr, ...) { |
2086 | 5407 va_list ap; |
13234 | 5408 guint16 type; |
5575 | 5409 GaimConnection *gc = sess->aux_data; |
7283 | 5410 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 5411 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5412 va_start(ap, fr); |
13234 | 5413 type = (guint16) va_arg(ap, unsigned int); |
2086 | 5414 |
5415 switch(type) { | |
5416 case 0x0002: { | |
13234 | 5417 guint8 maxrooms; |
2086 | 5418 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5419 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5420 |
13234 | 5421 maxrooms = (guint8) va_arg(ap, unsigned int); |
2086 | 5422 exchangecount = va_arg(ap, int); |
5423 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
5424 | |
8660 | 5425 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5426 "chat info: Chat Rights:\n"); |
8660 | 5427 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5428 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 5429 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5430 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5431 for (i = 0; i < exchangecount; i++) |
8660 | 5432 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5433 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5434 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 5435 while (od->create_rooms) { |
5436 struct create_room *cr = od->create_rooms->data; | |
8660 | 5437 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5438 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5439 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5440 g_free(cr->name); |
4617 | 5441 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5442 g_free(cr); |
2086 | 5443 } |
5444 } | |
5445 break; | |
5446 case 0x0008: { | |
5447 char *fqcn, *name, *ck; | |
13234 | 5448 guint16 instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
5449 guint8 createperms; | |
5450 guint32 createtime; | |
2086 | 5451 |
5452 fqcn = va_arg(ap, char *); | |
13234 | 5453 instance = (guint16)va_arg(ap, unsigned int); |
5454 exchange = (guint16)va_arg(ap, unsigned int); | |
5455 flags = (guint16)va_arg(ap, unsigned int); | |
5456 createtime = va_arg(ap, guint32); | |
5457 maxmsglen = (guint16)va_arg(ap, unsigned int); | |
5458 maxoccupancy = (guint16)va_arg(ap, unsigned int); | |
5459 createperms = (guint8)va_arg(ap, unsigned int); | |
5460 unknown = (guint16)va_arg(ap, unsigned int); | |
4200 | 5461 name = va_arg(ap, char *); |
5462 ck = va_arg(ap, char *); | |
4194 | 5463 |
8660 | 5464 gaim_debug_misc("oscar", |
5556 | 5465 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 5466 fqcn, |
5467 exchange, instance, flags, | |
5468 createtime, | |
5469 maxmsglen, maxoccupancy, createperms, unknown, | |
5470 name, ck); | |
4617 | 5471 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 5472 } |
5473 break; | |
5474 default: | |
8660 | 5475 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5476 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 5477 break; |
5478 } | |
4194 | 5479 |
5480 va_end(ap); | |
5481 | |
2086 | 5482 return 1; |
5483 } | |
5484 | |
13239 | 5485 static int gaim_conv_chat_join(OscarSession *sess, FlapFrame *fr, ...) { |
2086 | 5486 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5487 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5488 aim_userinfo_t *info; |
5575 | 5489 GaimConnection *g = sess->aux_data; |
2086 | 5490 |
5491 struct chat_connection *c = NULL; | |
5492 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5493 va_start(ap, fr); |
2086 | 5494 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5495 info = va_arg(ap, aim_userinfo_t *); |
2086 | 5496 va_end(ap); |
5497 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5498 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 5499 if (!c) |
5500 return 1; | |
5501 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5502 for (i = 0; i < count; i++) |
9846 | 5503 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 5504 |
5505 return 1; | |
5506 } | |
5507 | |
13239 | 5508 static int gaim_conv_chat_leave(OscarSession *sess, FlapFrame *fr, ...) { |
2086 | 5509 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5510 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5511 aim_userinfo_t *info; |
5575 | 5512 GaimConnection *g = sess->aux_data; |
2086 | 5513 |
5514 struct chat_connection *c = NULL; | |
5515 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5516 va_start(ap, fr); |
2086 | 5517 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5518 info = va_arg(ap, aim_userinfo_t *); |
2086 | 5519 va_end(ap); |
5520 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5521 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 5522 if (!c) |
5523 return 1; | |
5524 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5525 for (i = 0; i < count; i++) |
8733 | 5526 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 5527 |
5528 return 1; | |
5529 } | |
5530 | |
13239 | 5531 static int gaim_conv_chat_info_update(OscarSession *sess, FlapFrame *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5532 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5533 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5534 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5535 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5536 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5537 char *roomdesc; |
13234 | 5538 guint16 unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
5539 guint32 creationtime; | |
5575 | 5540 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5541 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5542 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5543 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5544 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5545 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5546 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5547 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5548 roomdesc = va_arg(ap, char *); |
13234 | 5549 unknown_c9 = (guint16)va_arg(ap, unsigned int); |
5550 creationtime = va_arg(ap, guint32); | |
5551 maxmsglen = (guint16)va_arg(ap, unsigned int); | |
5552 unknown_d2 = (guint16)va_arg(ap, unsigned int); | |
5553 unknown_d5 = (guint16)va_arg(ap, unsigned int); | |
5554 maxvisiblemsglen = (guint16)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5555 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5556 |
8660 | 5557 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5558 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5559 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5560 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5561 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5562 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5563 |
2086 | 5564 return 1; |
5565 } | |
5566 | |
13239 | 5567 static int gaim_conv_chat_incoming_msg(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 5568 GaimConnection *gc = sess->aux_data; |
8225 | 5569 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
5570 gchar *utf8; | |
2086 | 5571 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5572 aim_userinfo_t *info; |
8225 | 5573 int len; |
2086 | 5574 char *msg; |
8219 | 5575 char *charset; |
2086 | 5576 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5577 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5578 info = va_arg(ap, aim_userinfo_t *); |
8219 | 5579 len = va_arg(ap, int); |
4194 | 5580 msg = va_arg(ap, char *); |
8219 | 5581 charset = va_arg(ap, char *); |
4194 | 5582 va_end(ap); |
2086 | 5583 |
8225 | 5584 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 5585 if (utf8 == NULL) |
5586 /* The conversion failed! */ | |
8668 | 5587 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 5588 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
5589 g_free(utf8); | |
2086 | 5590 |
5591 return 1; | |
5592 } | |
5593 | |
13239 | 5594 static int gaim_email_parseupdate(OscarSession *sess, FlapFrame *fr, ...) { |
3694 | 5595 va_list ap; |
5575 | 5596 GaimConnection *gc = sess->aux_data; |
3694 | 5597 struct aim_emailinfo *emailinfo; |
3725 | 5598 int havenewmail; |
7297 | 5599 char *alertitle, *alerturl; |
3694 | 5600 |
5601 va_start(ap, fr); | |
5602 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 5603 havenewmail = va_arg(ap, int); |
7301 | 5604 alertitle = va_arg(ap, char *); |
5605 alerturl = va_arg(ap, char *); | |
3694 | 5606 va_end(ap); |
5607 | |
9661 | 5608 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
5609 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
5610 emailinfo->domain ? "@" : "", | |
5611 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 5612 if (emailinfo->unread && havenewmail) |
5613 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 5614 g_free(to); |
3694 | 5615 } |
13226 | 5616 |
7301 | 5617 if (alertitle) |
8660 | 5618 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 5619 |
5620 return 1; | |
5621 } | |
5622 | |
13239 | 5623 static int gaim_icon_error(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 5624 GaimConnection *gc = sess->aux_data; |
7283 | 5625 OscarData *od = gc->proto_data; |
4804 | 5626 char *sn; |
5627 | |
5628 sn = od->requesticon->data; | |
8660 | 5629 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5630 "removing %s from hash table\n", sn); |
4804 | 5631 od->requesticon = g_slist_remove(od->requesticon, sn); |
5632 free(sn); | |
5633 | |
5634 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
5635 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5636 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 5637 |
5638 return 1; | |
5639 } | |
5640 | |
13239 | 5641 static int gaim_icon_parseicon(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 5642 GaimConnection *gc = sess->aux_data; |
7283 | 5643 OscarData *od = gc->proto_data; |
4804 | 5644 GSList *cur; |
5645 va_list ap; | |
5646 char *sn; | |
13234 | 5647 guint8 iconcsumtype, *iconcsum, *icon; |
5648 guint16 iconcsumlen, iconlen; | |
4804 | 5649 |
5650 va_start(ap, fr); | |
5651 sn = va_arg(ap, char *); | |
11024 | 5652 iconcsumtype = va_arg(ap, int); |
13234 | 5653 iconcsum = va_arg(ap, guint8 *); |
4853 | 5654 iconcsumlen = va_arg(ap, int); |
13234 | 5655 icon = va_arg(ap, guint8 *); |
4804 | 5656 iconlen = va_arg(ap, int); |
5657 va_end(ap); | |
5658 | |
11024 | 5659 /* |
5660 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
5661 * no icon is set. Ignore these. | |
5662 */ | |
5663 if ((iconlen > 0) && (iconlen != 90)) { | |
4853 | 5664 char *b16; |
6695 | 5665 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
5666 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
5667 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
5668 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 5669 if (b16) { |
7693 | 5670 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 5671 g_free(b16); |
5129 | 5672 } |
4853 | 5673 } |
4804 | 5674 |
5675 cur = od->requesticon; | |
5676 while (cur) { | |
5677 char *cursn = cur->data; | |
5678 if (!aim_sncmp(cursn, sn)) { | |
5679 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
5680 free(cursn); | |
5681 cur = od->requesticon; | |
5682 } else | |
5683 cur = cur->next; | |
5684 } | |
5685 | |
5686 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
5687 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5688 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 5689 |
5690 return 1; | |
5691 } | |
5692 | |
5693 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 5694 GaimConnection *gc = data; |
7283 | 5695 OscarData *od = gc->proto_data; |
7011 | 5696 aim_userinfo_t *userinfo; |
13239 | 5697 OscarConnection *conn; |
4804 | 5698 |
5699 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 5700 if (!conn) { |
5701 if (!od->iconconnecting) { | |
5702 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
5703 od->iconconnecting = TRUE; | |
5704 } | |
4804 | 5705 return FALSE; |
5706 } | |
5707 | |
5842 | 5708 if (od->set_icon) { |
6039 | 5709 struct stat st; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5710 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
6039 | 5711 if (iconfile == NULL) { |
8363 | 5712 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5713 } else if (!g_stat(iconfile, &st)) { |
11159 | 5714 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5715 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 5716 if (file) { |
9532 | 5717 /* XXX - Use g_file_get_contents()? */ |
6039 | 5718 fread(buf, 1, st.st_size, file); |
5719 fclose(file); | |
8660 | 5720 gaim_debug_info("oscar", |
6039 | 5721 "Uploading icon to icon server\n"); |
6879 | 5722 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 5723 } else |
8660 | 5724 gaim_debug_error("oscar", |
6039 | 5725 "Can't open buddy icon file!\n"); |
5726 g_free(buf); | |
5727 } else { | |
8660 | 5728 gaim_debug_error("oscar", |
6039 | 5729 "Can't stat buddy icon file!\n"); |
5842 | 5730 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5731 g_free(iconfile); |
5842 | 5732 od->set_icon = FALSE; |
5733 } | |
5734 | |
5735 if (!od->requesticon) { | |
8660 | 5736 gaim_debug_misc("oscar", |
5842 | 5737 "no more icons to request\n"); |
5738 return FALSE; | |
5739 } | |
5740 | |
7045 | 5741 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 5742 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
11024 | 5743 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
4804 | 5744 return FALSE; |
5745 } else { | |
5746 char *sn = od->requesticon->data; | |
5747 od->requesticon = g_slist_remove(od->requesticon, sn); | |
5748 free(sn); | |
5749 } | |
5750 | |
5751 return TRUE; | |
5752 } | |
5753 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5754 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5755 * 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
|
5756 */ |
13239 | 5757 static int gaim_parse_msgack(OscarSession *sess, FlapFrame *fr, ...) { |
2086 | 5758 va_list ap; |
13234 | 5759 guint16 type; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5760 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5761 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5762 va_start(ap, fr); |
13234 | 5763 type = (guint16) va_arg(ap, unsigned int); |
2086 | 5764 sn = va_arg(ap, char *); |
5765 va_end(ap); | |
5766 | |
8660 | 5767 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 5768 |
5769 return 1; | |
5770 } | |
5771 | |
13239 | 5772 static int gaim_parse_ratechange(OscarSession *sess, FlapFrame *fr, ...) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5773 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5774 "invalid", |
4194 | 5775 "change", |
5776 "warning", | |
5777 "limit", | |
5778 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5779 }; |
2086 | 5780 va_list ap; |
13234 | 5781 guint16 code, rateclass; |
5782 guint32 windowsize, clear, alert, limit, disconnect, currentavg, maxavg; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5783 |
13226 | 5784 va_start(ap, fr); |
13234 | 5785 code = (guint16)va_arg(ap, unsigned int); |
5786 rateclass= (guint16)va_arg(ap, unsigned int); | |
5787 windowsize = va_arg(ap, guint32); | |
5788 clear = va_arg(ap, guint32); | |
5789 alert = va_arg(ap, guint32); | |
5790 limit = va_arg(ap, guint32); | |
5791 disconnect = va_arg(ap, guint32); | |
5792 currentavg = va_arg(ap, guint32); | |
5793 maxavg = va_arg(ap, guint32); | |
2086 | 5794 va_end(ap); |
5795 | |
8660 | 5796 gaim_debug_misc("oscar", |
5556 | 5797 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
5798 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 5799 (code < 5) ? codes[code] : codes[0], |
5800 rateclass, | |
5801 currentavg, maxavg, | |
5802 alert, clear, | |
5803 limit, disconnect, | |
5804 windowsize); | |
5805 | |
13256 | 5806 if (code == AIM_RATE_CODE_LIMIT) |
5807 { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5808 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 5809 _("The last action you attempted could not be " |
5810 "performed because you are over the rate limit. " | |
5811 "Please wait 10 seconds and try again.")); | |
2086 | 5812 } |
5813 | |
5814 return 1; | |
5815 } | |
5816 | |
13239 | 5817 static int gaim_parse_evilnotify(OscarSession *sess, FlapFrame *fr, ...) { |
2086 | 5818 va_list ap; |
13234 | 5819 guint16 newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5820 aim_userinfo_t *userinfo; |
2086 | 5821 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5822 va_start(ap, fr); |
13234 | 5823 newevil = (guint16) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5824 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 5825 va_end(ap); |
5826 | |
11285 | 5827 #ifdef CRAZY_WARNING |
5828 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
5829 #endif | |
2086 | 5830 |
5831 return 1; | |
5832 } | |
5833 | |
13239 | 5834 static int gaim_selfinfo(OscarSession *sess, FlapFrame *fr, ...) { |
9982 | 5835 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5836 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5837 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5838 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5839 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5840 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5841 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5842 |
11285 | 5843 /* |
5844 * What's with the + 0.5? | |
5845 * The 0.5 is basically poor-man's rounding. Normally | |
5846 * casting "13.7" to an int will truncate to "13," but | |
5847 * with 13.7 + 0.5 = 14.2, which becomes "14" when | |
5848 * truncated. | |
5849 */ | |
9982 | 5850 warning_level = info->warnlevel/10.0 + 0.5; |
5851 | |
11285 | 5852 #ifdef CRAZY_WARNING |
5853 gaim_presence_set_warning_level(presence, warning_level); | |
5854 #endif | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5855 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5856 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5857 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5858 |
13239 | 5859 static int gaim_connerr(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 5860 GaimConnection *gc = sess->aux_data; |
7283 | 5861 OscarData *od = gc->proto_data; |
4649 | 5862 va_list ap; |
13234 | 5863 guint16 code; |
4649 | 5864 char *msg; |
5865 | |
5866 va_start(ap, fr); | |
13234 | 5867 code = (guint16)va_arg(ap, int); |
4649 | 5868 msg = va_arg(ap, char *); |
5869 va_end(ap); | |
5870 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5871 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
10458 | 5872 code, (msg != NULL ? msg : "")); |
5873 | |
5874 g_return_val_if_fail(fr != NULL, 1); | |
5875 g_return_val_if_fail(fr->conn != NULL, 1); | |
5876 | |
5877 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 5878 if (code == 0x0001) { |
6113 | 5879 gc->wants_to_die = TRUE; |
10715 | 5880 gaim_connection_error(gc, _("You have signed on from another location.")); |
4651 | 5881 } else { |
5579 | 5882 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 5883 } |
4666 | 5884 od->killme = TRUE; |
10458 | 5885 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
5886 struct chat_connection *cc; | |
5887 GaimConversation *conv; | |
5888 | |
5889 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
5890 conv = gaim_find_chat(gc, cc->id); | |
5891 | |
5892 if (conv != NULL) | |
5893 { | |
5894 gchar *buf; | |
5895 buf = g_strdup_printf(_("You have been disconnected from chat " | |
5896 "room %s."), cc->name); | |
5897 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
5898 g_free(buf); | |
5899 } | |
5900 oscar_chat_kill(gc, cc); | |
4649 | 5901 } |
5902 | |
5903 return 1; | |
5904 } | |
5905 | |
13239 | 5906 static int conninitdone_bos(OscarSession *sess, FlapFrame *fr, ...) { |
7283 | 5907 GaimConnection *gc = sess->aux_data; |
12663 | 5908 OscarData *od = gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5909 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5910 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 5911 |
8660 | 5912 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 5913 aim_ssi_reqrights(sess); |
6350 | 5914 aim_ssi_reqdata(sess); |
12663 | 5915 if (od->getblisttimer > 0) |
5916 gaim_timeout_remove(od->getblisttimer); | |
5917 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od->sess); | |
4230 | 5918 |
7011 | 5919 aim_locate_reqrights(sess); |
7285 | 5920 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 5921 aim_im_reqparams(sess); |
7334 | 5922 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 5923 |
7283 | 5924 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
5925 | |
2086 | 5926 return 1; |
5927 } | |
5928 | |
13239 | 5929 static int conninitdone_admin(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 5930 GaimConnection *gc = sess->aux_data; |
7283 | 5931 OscarData *od = gc->proto_data; |
2647 | 5932 |
13234 | 5933 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_ADMIN, 0x0003, gaim_info_change, 0); |
5934 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_ADMIN, 0x0005, gaim_info_change, 0); | |
5935 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_ADMIN, 0x0007, gaim_account_confirm, 0); | |
6905 | 5936 |
2672 | 5937 aim_clientready(sess, fr->conn); |
8660 | 5938 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5939 |
2647 | 5940 if (od->chpass) { |
8660 | 5941 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5942 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 5943 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5944 od->oldp = NULL; |
2647 | 5945 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5946 od->newp = NULL; |
2647 | 5947 od->chpass = FALSE; |
5948 } | |
2979 | 5949 if (od->setnick) { |
8660 | 5950 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 5951 aim_admin_setnick(sess, fr->conn, od->newsn); |
5952 g_free(od->newsn); | |
5953 od->newsn = NULL; | |
5954 od->setnick = FALSE; | |
5955 } | |
2647 | 5956 if (od->conf) { |
8660 | 5957 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5958 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 5959 od->conf = FALSE; |
5960 } | |
5961 if (od->reqemail) { | |
8660 | 5962 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5963 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 5964 od->reqemail = FALSE; |
5965 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5966 if (od->setemail) { |
8660 | 5967 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5968 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5969 g_free(od->email); |
5497 | 5970 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5971 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5972 } |
2647 | 5973 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5974 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5975 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5976 |
13239 | 5977 static int gaim_icbm_param_info(OscarSession *sess, FlapFrame *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5978 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5979 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5980 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5981 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5982 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5983 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5984 |
4194 | 5985 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 5986 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 5987 "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
|
5988 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5989 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5990 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
5991 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5992 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5993 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 5994 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5995 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5996 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5997 |
4617 | 5998 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5999 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6000 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6001 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6002 |
13239 | 6003 static int gaim_parse_locaterights(OscarSession *sess, FlapFrame *fr, ...) |
2993 | 6004 { |
5575 | 6005 GaimConnection *gc = sess->aux_data; |
11338 | 6006 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 6007 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 6008 va_list ap; |
13234 | 6009 guint16 maxsiglen; |
2993 | 6010 |
6011 va_start(ap, fr); | |
13234 | 6012 maxsiglen = (guint16) va_arg(ap, int); |
2993 | 6013 va_end(ap); |
6014 | |
8660 | 6015 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6016 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 6017 |
4617 | 6018 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
6019 | |
6020 if (od->icq) | |
7334 | 6021 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 6022 else |
7334 | 6023 aim_locate_setcaps(od->sess, caps_aim); |
11965 | 6024 oscar_set_info_and_status(account, TRUE, account->user_info, TRUE, |
6025 gaim_account_get_active_status(account)); | |
2993 | 6026 |
6027 return 1; | |
6028 } | |
6029 | |
13239 | 6030 static int gaim_parse_buddyrights(OscarSession *sess, FlapFrame *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6031 va_list ap; |
13234 | 6032 guint16 maxbuddies, maxwatchers; |
5575 | 6033 GaimConnection *gc = sess->aux_data; |
7283 | 6034 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6035 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6036 va_start(ap, fr); |
13234 | 6037 maxbuddies = (guint16) va_arg(ap, unsigned int); |
6038 maxwatchers = (guint16) va_arg(ap, unsigned int); | |
2086 | 6039 va_end(ap); |
6040 | |
8660 | 6041 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6042 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 6043 |
4617 | 6044 od->rights.maxbuddies = (guint)maxbuddies; |
6045 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 6046 |
2086 | 6047 return 1; |
6048 } | |
6049 | |
13239 | 6050 static int gaim_bosrights(OscarSession *sess, FlapFrame *fr, ...) { |
11808 | 6051 GaimConnection *gc; |
6052 OscarData *od; | |
6053 GaimAccount *account; | |
6054 GaimStatus *status; | |
6055 const char *message; | |
12344 | 6056 char *tmp; |
7334 | 6057 va_list ap; |
13234 | 6058 guint16 maxpermits, maxdenies; |
2086 | 6059 |
11808 | 6060 gc = sess->aux_data; |
6061 od = (OscarData *)gc->proto_data; | |
11809 | 6062 account = gaim_connection_get_account(gc); |
11808 | 6063 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6064 va_start(ap, fr); |
13234 | 6065 maxpermits = (guint16) va_arg(ap, unsigned int); |
6066 maxdenies = (guint16) va_arg(ap, unsigned int); | |
2086 | 6067 va_end(ap); |
6068 | |
8660 | 6069 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6070 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 6071 |
4617 | 6072 od->rights.maxpermits = (guint)maxpermits; |
6073 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 6074 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
6075 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 6076 |
8660 | 6077 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 6078 |
2672 | 6079 aim_clientready(sess, fr->conn); |
11808 | 6080 |
6081 /* Set our available message based on the current status */ | |
6082 status = gaim_account_get_active_status(account); | |
6083 if (gaim_status_is_available(status)) | |
6084 message = gaim_status_get_attr_string(status, "message"); | |
11810 | 6085 else |
6086 message = NULL; | |
12344 | 6087 tmp = gaim_markup_strip_html(message); |
12349 | 6088 aim_srv_setstatusmsg(sess, tmp); |
12344 | 6089 free(tmp); |
11808 | 6090 |
7474 | 6091 aim_srv_setidle(sess, 0); |
4617 | 6092 |
4664 | 6093 if (od->icq) { |
6094 aim_icq_reqofflinemsgs(sess); | |
12652 | 6095 oscar_set_extendedstatus(gc); |
10570 | 6096 aim_icq_setsecurity(sess, |
6097 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
12652 | 6098 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE)); |
4664 | 6099 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6100 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
6101 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 6102 if (sess->authinfo->email) |
6103 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 6104 |
6105 return 1; | |
6106 } | |
6107 | |
13239 | 6108 static int gaim_offlinemsg(OscarSession *sess, FlapFrame *fr, ...) { |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6109 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6110 struct aim_icq_offlinemsg *msg; |
4075 | 6111 struct aim_incomingim_ch4_args args; |
6112 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6113 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6114 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6115 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6116 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6117 |
8660 | 6118 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6119 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 6120 args.uin = msg->sender; |
6121 args.type = msg->type; | |
4173 | 6122 args.flags = msg->flags; |
4076 | 6123 args.msglen = msg->msglen; |
4075 | 6124 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
6125 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 6126 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6127 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6128 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6129 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6130 |
13239 | 6131 static int gaim_offlinemsgdone(OscarSession *sess, FlapFrame *fr, ...) |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6132 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6133 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6134 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6135 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6136 |
13239 | 6137 static int gaim_icqinfo(OscarSession *sess, FlapFrame *fr, ...) |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6138 { |
5575 | 6139 GaimConnection *gc = sess->aux_data; |
8670 | 6140 OscarData *od = (OscarData *)gc->proto_data; |
6141 GaimBuddy *buddy; | |
8853 | 6142 struct buddyinfo *bi = NULL; |
4624 | 6143 gchar who[16]; |
8670 | 6144 GString *str; |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
6145 gchar *utf8; |
9634 | 6146 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6147 va_list ap; |
4151 | 6148 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6149 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6150 va_start(ap, fr); |
4151 | 6151 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6152 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6153 |
4664 | 6154 if (!info->uin) |
6155 return 0; | |
6156 | |
8670 | 6157 str = g_string_sized_new(100); |
5556 | 6158 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 6159 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
6160 if (buddy != NULL) | |
6161 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
6162 | |
6163 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6164 oscar_string_append(gc->account, str, "\n<br>", _("Nick"), info->nick); |
8670 | 6165 if ((bi != NULL) && (bi->ipaddr != 0)) { |
6166 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
6167 (bi->ipaddr & 0xff000000) >> 24, | |
6168 (bi->ipaddr & 0x00ff0000) >> 16, | |
6169 (bi->ipaddr & 0x0000ff00) >> 8, | |
6170 (bi->ipaddr & 0x000000ff)); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6171 oscar_string_append(gc->account, str, "\n<br>", _("IP Address"), tstr); |
8670 | 6172 g_free(tstr); |
6173 } | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6174 oscar_string_append(gc->account, str, "\n<br>", _("First Name"), info->first); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6175 oscar_string_append(gc->account, str, "\n<br>", _("Last Name"), info->last); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6176 if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) { |
8670 | 6177 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
6178 g_free(utf8); | |
4625 | 6179 } |
6180 if (info->numaddresses && info->email2) { | |
6181 int i; | |
6182 for (i = 0; i < info->numaddresses; i++) { | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6183 if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) { |
10683 | 6184 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 6185 g_free(utf8); |
4643 | 6186 } |
4625 | 6187 } |
4624 | 6188 } |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6189 oscar_string_append(gc->account, str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 6190 if (info->gender != 0) |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6191 oscar_string_append(gc->account, str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); |
12491 | 6192 if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) { |
4627 | 6193 struct tm tm; |
6194 tm.tm_mday = (int)info->birthday; | |
6195 tm.tm_mon = (int)info->birthmonth-1; | |
6196 tm.tm_year = (int)info->birthyear-1900; | |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
6197 oscar_string_append(gc->account, str, "\n<br>", _("Birthday"), |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
6198 gaim_date_format_short(&tm)); |
4151 | 6199 } |
12491 | 6200 if ((info->age > 0) && (info->age < 255)) { |
4624 | 6201 char age[5]; |
6202 snprintf(age, sizeof(age), "%hhd", info->age); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6203 oscar_string_append(gc->account, str, "\n<br>", _("Age"), age); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6204 } |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6205 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) { |
8670 | 6206 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
6207 g_free(utf8); | |
4819 | 6208 } |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6209 if (info->info && info->info[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->info))) { |
8670 | 6210 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
6211 g_free(utf8); | |
6212 } | |
10683 | 6213 g_string_append_printf(str, "<hr>"); |
4641 | 6214 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 6215 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6216 oscar_string_append(gc->account, str, "\n<br>", _("Address"), info->homeaddr); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6217 oscar_string_append(gc->account, str, "\n<br>", _("City"), info->homecity); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6218 oscar_string_append(gc->account, str, "\n<br>", _("State"), info->homestate); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6219 oscar_string_append(gc->account, str, "\n<br>", _("Zip Code"), info->homezip); |
10683 | 6220 g_string_append_printf(str, "\n<hr>"); |
4151 | 6221 } |
4641 | 6222 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 6223 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6224 oscar_string_append(gc->account, str, "\n<br>", _("Address"), info->workaddr); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6225 oscar_string_append(gc->account, str, "\n<br>", _("City"), info->workcity); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6226 oscar_string_append(gc->account, str, "\n<br>", _("State"), info->workstate); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6227 oscar_string_append(gc->account, str, "\n<br>", _("Zip Code"), info->workzip); |
10683 | 6228 g_string_append_printf(str, "\n<hr>"); |
4624 | 6229 } |
4641 | 6230 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 6231 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6232 oscar_string_append(gc->account, str, "\n<br>", _("Company"), info->workcompany); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6233 oscar_string_append(gc->account, str, "\n<br>", _("Division"), info->workdivision); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6234 oscar_string_append(gc->account, str, "\n<br>", _("Position"), info->workposition); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6235 if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) { |
8670 | 6236 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
6237 g_free(utf8); | |
4624 | 6238 } |
10683 | 6239 g_string_append_printf(str, "\n<hr>"); |
8670 | 6240 } |
6241 | |
9634 | 6242 if (buddy != NULL) |
6243 alias = gaim_buddy_get_alias(buddy); | |
6244 else | |
6245 alias = who; | |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
6246 gaim_notify_userinfo(gc, who, str->str, NULL, NULL); |
8670 | 6247 g_string_free(str, TRUE); |
4151 | 6248 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6249 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6250 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6251 |
13239 | 6252 static int gaim_icqalias(OscarSession *sess, FlapFrame *fr, ...) |
4759 | 6253 { |
5575 | 6254 GaimConnection *gc = sess->aux_data; |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6255 GaimAccount *account = gaim_connection_get_account(gc); |
4820 | 6256 gchar who[16], *utf8; |
6695 | 6257 GaimBuddy *b; |
4759 | 6258 va_list ap; |
6259 struct aim_icq_info *info; | |
6260 | |
6261 va_start(ap, fr); | |
6262 info = va_arg(ap, struct aim_icq_info *); | |
6263 va_end(ap); | |
6264 | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6265 if (info->uin && info->nick && info->nick[0] && (utf8 = oscar_utf8_try_convert(account, info->nick))) { |
5556 | 6266 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 6267 serv_got_alias(gc, who, utf8); |
4759 | 6268 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 6269 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 6270 } |
4820 | 6271 g_free(utf8); |
4759 | 6272 } |
6273 | |
6274 return 1; | |
6275 } | |
6276 | |
13239 | 6277 static int gaim_popup(OscarSession *sess, FlapFrame *fr, ...) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6278 { |
7032 | 6279 GaimConnection *gc = sess->aux_data; |
6280 gchar *text; | |
6281 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6282 char *msg, *url; |
13234 | 6283 guint16 wid, hei, delay; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6284 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6285 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6286 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6287 url = va_arg(ap, char *); |
13234 | 6288 wid = (guint16) va_arg(ap, int); |
6289 hei = (guint16) va_arg(ap, int); | |
6290 delay = (guint16) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6291 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6292 |
7032 | 6293 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
6294 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
6295 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6296 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6297 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6298 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6299 |
11359 | 6300 static void oscar_searchresults_add_buddy_cb(GaimConnection *gc, GList *row) |
6301 { | |
6302 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), | |
6303 g_list_nth_data(row, 0), NULL, NULL); | |
6304 } | |
6305 | |
13239 | 6306 static int gaim_parse_searchreply(OscarSession *sess, FlapFrame *fr, ...) |
7032 | 6307 { |
6873 | 6308 GaimConnection *gc = sess->aux_data; |
11359 | 6309 GaimNotifySearchResults *results; |
6310 GaimNotifySearchColumn *column; | |
6873 | 6311 gchar *secondary; |
6312 int i, num; | |
2086 | 6313 va_list ap; |
6873 | 6314 char *email, *SNs; |
2086 | 6315 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6316 va_start(ap, fr); |
6873 | 6317 email = va_arg(ap, char *); |
2086 | 6318 num = va_arg(ap, int); |
6319 SNs = va_arg(ap, char *); | |
6320 va_end(ap); | |
6321 | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6322 results = gaim_notify_searchresults_new(); |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6323 |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6324 if (results == NULL) { |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6325 gaim_debug_error("oscar", "gaim_parse_searchreply: " |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6326 "Unable to display the search results.\n"); |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6327 gaim_notify_error(gc, NULL, |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6328 _("Unable to display the search results."), |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6329 NULL); |
12260 | 6330 return 1; |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6331 } |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6332 |
12254
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6333 secondary = g_strdup_printf( |
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6334 ngettext("The following screen name is associated with %s", |
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6335 "The following screen names are associated with %s", |
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6336 num), |
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6337 email); |
10439 | 6338 |
11359 | 6339 column = gaim_notify_searchresults_column_new("Screen name"); |
6340 gaim_notify_searchresults_column_add(results, column); | |
6341 | |
6342 for (i = 0; i < num; i++) { | |
6343 GList *row = NULL; | |
6344 row = g_list_append(row, g_strdup(&SNs[i * (MAXSNLEN + 1)])); | |
6345 gaim_notify_searchresults_row_add(results, row); | |
6346 } | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12617
diff
changeset
|
6347 gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD, |
11359 | 6348 oscar_searchresults_add_buddy_cb); |
6349 gaim_notify_searchresults(gc, NULL, NULL, secondary, results, NULL, NULL); | |
6873 | 6350 |
6351 g_free(secondary); | |
2086 | 6352 |
6353 return 1; | |
6354 } | |
6355 | |
13239 | 6356 static int gaim_parse_searcherror(OscarSession *sess, FlapFrame *fr, ...) { |
2086 | 6357 va_list ap; |
6873 | 6358 char *email; |
5420 | 6359 char *buf; |
2086 | 6360 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6361 va_start(ap, fr); |
6873 | 6362 email = va_arg(ap, char *); |
2086 | 6363 va_end(ap); |
6364 | |
6873 | 6365 buf = g_strdup_printf(_("No results found for email address %s"), email); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6366 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 6367 g_free(buf); |
2086 | 6368 |
6369 return 1; | |
6370 } | |
6371 | |
13239 | 6372 static int gaim_account_confirm(OscarSession *sess, FlapFrame *fr, ...) { |
6873 | 6373 GaimConnection *gc = sess->aux_data; |
13234 | 6374 guint16 status; |
2086 | 6375 va_list ap; |
6376 char msg[256]; | |
6377 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6378 va_start(ap, fr); |
13234 | 6379 status = (guint16) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 6380 va_end(ap); |
6381 | |
8660 | 6382 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6383 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 6384 status ? "unknown" : "email sent"); |
6385 if (!status) { | |
5302 | 6386 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 6387 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6388 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 6389 } |
6390 | |
6391 return 1; | |
6392 } | |
6393 | |
13239 | 6394 static int gaim_info_change(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 6395 GaimConnection *gc = sess->aux_data; |
2086 | 6396 va_list ap; |
13234 | 6397 guint16 perms, err; |
3912 | 6398 char *url, *sn, *email; |
6399 int change; | |
2086 | 6400 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6401 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6402 change = va_arg(ap, int); |
13234 | 6403 perms = (guint16) va_arg(ap, unsigned int); |
6404 err = (guint16) va_arg(ap, unsigned int); | |
3912 | 6405 url = va_arg(ap, char *); |
6406 sn = va_arg(ap, char *); | |
6407 email = va_arg(ap, char *); | |
2086 | 6408 va_end(ap); |
6409 | |
8660 | 6410 gaim_debug_misc("oscar", |
9626 | 6411 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
6412 change ? "change" : "request", perms, err, | |
6413 (url != NULL) ? url : "(null)", | |
6414 (sn != NULL) ? sn : "(null)", | |
6415 (email != NULL) ? email : "(null)"); | |
6416 | |
6417 if ((err > 0) && (url != NULL)) { | |
3912 | 6418 char *dialog_msg; |
6419 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
6420 switch (err) { | |
6421 case 0x0001: { | |
6422 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
6423 } break; | |
6424 case 0x0006: { | |
11399 | 6425 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because it is invalid."), err); |
3912 | 6426 } break; |
6427 case 0x000b: { | |
6428 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
6429 } break; | |
6430 case 0x001d: { | |
6431 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because there is already a request pending for this screen name."), err); | |
6432 } break; | |
6433 case 0x0021: { | |
6434 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address has too many screen names associated with it."), err); | |
6435 } break; | |
6436 case 0x0023: { | |
6437 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
6438 } break; | |
6439 default: { | |
6440 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
6441 } break; | |
6442 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6443 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 6444 g_free(dialog_top); |
6445 g_free(dialog_msg); | |
6446 return 1; | |
6447 } | |
6448 | |
9626 | 6449 if (sn != NULL) { |
4585 | 6450 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
|
6451 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 6452 g_free(dialog_msg); |
6453 } | |
6454 | |
9626 | 6455 if (email != NULL) { |
13226 | 6456 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5575 | 6457 gaim_account_get_username(gaim_connection_get_account(gc)), email); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6458 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 6459 g_free(dialog_msg); |
2086 | 6460 } |
6461 | |
6462 return 1; | |
6463 } | |
6464 | |
5575 | 6465 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 6466 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 6467 aim_flap_nop(od->sess, od->conn); |
2086 | 6468 } |
6469 | |
6059 | 6470 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 6471 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 6472 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
6473 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6474 if (typing == GAIM_TYPING) |
4870 | 6475 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6476 else if (typing == GAIM_TYPED) |
4870 | 6477 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
6478 else | |
6479 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 6480 else { |
5300 | 6481 /* Don't send if this turkey is in our deny list */ |
6482 GSList *list; | |
6483 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
6484 if (!list) { | |
7261 | 6485 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 6486 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6487 if (typing == GAIM_TYPING) |
5300 | 6488 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6489 else if (typing == GAIM_TYPED) |
5300 | 6490 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
6491 else | |
6492 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
6493 } | |
3595 | 6494 } |
6495 } | |
2993 | 6496 return 0; |
6497 } | |
9030 | 6498 |
13239 | 6499 static int gaim_odc_send_im(OscarSession *, OscarConnection *, const char *, GaimMessageFlags); |
12216 | 6500 |
6501 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimMessageFlags imflags) { | |
7283 | 6502 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 6503 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 6504 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6505 int ret = 0; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6506 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); |
12677 | 6507 char *tmp1, *tmp2; |
6508 | |
6509 if (imflags & GAIM_MESSAGE_AUTO_RESP) | |
13356 | 6510 /* |
6511 * TODO: Do this earlier in the IM-sending chain of events. | |
6512 * We should attach to an IM-sending signal and do it | |
6513 * there. As it is currently implemented, encrypted | |
6514 * messages are not substituted. | |
6515 */ | |
12677 | 6516 tmp1 = gaim_str_sub_away_formatters(message, name); |
6517 else | |
6518 tmp1 = g_strdup(message); | |
3458 | 6519 |
4838 | 6520 if (dim && dim->connected) { |
6521 /* If we're directly connected, send a direct IM */ | |
12677 | 6522 ret = gaim_odc_send_im(od->sess, dim->conn, tmp1, imflags); |
2086 | 6523 } else { |
4738 | 6524 struct buddyinfo *bi; |
3008 | 6525 struct aim_sendimext_args args; |
6526 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
6527 gsize len; |
10246 | 6528 GaimConversation *conv; |
6529 | |
11338 | 6530 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account); |
8962 | 6531 |
12677 | 6532 if (strstr(tmp1, "<IMG ")) |
8962 | 6533 gaim_conversation_write(conv, "", |
6534 _("Your IM Image was not sent. " | |
6535 "You must be Direct Connected to send IM Images."), | |
6536 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 6537 |
10246 | 6538 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 6539 if (!bi) { |
6540 bi = g_new0(struct buddyinfo, 1); | |
10246 | 6541 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 6542 } |
6543 | |
3008 | 6544 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 6545 if (od->icq) { |
11185 | 6546 /* We have to present different "features" (whose meaning |
11172 | 6547 is unclear and are merely a result of protocol inspection) |
6548 to offline ICQ buddies. Otherwise, the official | |
6549 ICQ client doesn't treat those messages as being "ANSI- | |
6550 encoded" (and instead, assumes them to be UTF-8). | |
6551 For more details, see SF issue 1179452. | |
6552 */ | |
6553 GaimBuddy *buddy = gaim_find_buddy(gc->account, name); | |
11910 | 6554 if (buddy && GAIM_BUDDY_IS_ONLINE(buddy)) { |
11172 | 6555 args.features = features_icq; |
6556 args.featureslen = sizeof(features_icq); | |
6557 } else { | |
6558 args.features = features_icq_offline; | |
6559 args.featureslen = sizeof(features_icq_offline); | |
6560 } | |
3008 | 6561 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 6562 } else { |
6563 args.features = features_aim; | |
6564 args.featureslen = sizeof(features_aim); | |
4972 | 6565 |
12216 | 6566 if (imflags & GAIM_MESSAGE_AUTO_RESP) |
4972 | 6567 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 6568 } |
4269 | 6569 |
4738 | 6570 if (bi->ico_need) { |
8660 | 6571 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6572 "Sending buddy icon request with message\n"); |
3008 | 6573 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 6574 bi->ico_need = FALSE; |
3008 | 6575 } |
4269 | 6576 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6577 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6578 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 6579 if (file) { |
11159 | 6580 guchar *buf = g_malloc(st.st_size); |
9532 | 6581 /* XXX - Use g_file_get_contents()? */ |
3008 | 6582 fread(buf, 1, st.st_size, file); |
6039 | 6583 fclose(file); |
4269 | 6584 |
3008 | 6585 args.iconlen = st.st_size; |
4617 | 6586 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 6587 args.iconstamp = st.st_mtime; |
6588 | |
7406 | 6589 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 6590 bi->ico_informed = FALSE; |
7406 | 6591 bi->ico_sent = FALSE; |
6592 } | |
4738 | 6593 |
6594 if (!bi->ico_informed) { | |
8660 | 6595 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6596 "Claiming to have a buddy icon\n"); |
4738 | 6597 args.flags |= AIM_IMFLAGS_HASICON; |
6598 bi->ico_me_len = args.iconlen; | |
6599 bi->ico_me_csum = args.iconsum; | |
6600 bi->ico_me_time = args.iconstamp; | |
6601 bi->ico_informed = TRUE; | |
6602 } | |
6603 | |
3008 | 6604 g_free(buf); |
2086 | 6605 } |
6606 } | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6607 g_free(iconfile); |
4269 | 6608 |
3008 | 6609 args.destsn = name; |
4269 | 6610 |
8985 | 6611 /* |
13165
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6612 * If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML. |
13226 | 6613 */ |
13168
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13165
diff
changeset
|
6614 if (aim_sn_is_sms(name)) { |
13165
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6615 /* Messaging an SMS (mobile) user */ |
13226 | 6616 tmp2 = gaim_unescape_html(tmp1); |
13165
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6617 } else if (aim_sn_is_icq(gaim_account_get_username(account))) { |
10781 | 6618 if (aim_sn_is_icq(name)) |
6619 /* From ICQ to ICQ */ | |
12677 | 6620 tmp2 = gaim_unescape_html(tmp1); |
10781 | 6621 else |
6622 /* From ICQ to AIM */ | |
12677 | 6623 tmp2 = g_strdup(tmp1); |
8995 | 6624 } else { |
10785 | 6625 /* From AIM to AIM and AIM to ICQ */ |
12677 | 6626 tmp2 = g_strdup(tmp1); |
8995 | 6627 } |
12677 | 6628 g_free(tmp1); |
6629 tmp1 = tmp2; | |
6630 len = strlen(tmp1); | |
6631 | |
6632 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmp1, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); | |
9830 | 6633 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", |
6634 args.charset, args.charsubset, args.msglen); | |
4617 | 6635 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 6636 g_free((char *)args.msg); |
2086 | 6637 } |
4838 | 6638 |
12677 | 6639 g_free(tmp1); |
6310 | 6640 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6641 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6642 return 1; |
6310 | 6643 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6644 return ret; |
2086 | 6645 } |
6646 | |
7011 | 6647 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 6648 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 6649 |
9975 | 6650 if (od->icq && aim_sn_is_icq(name)) |
4624 | 6651 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6652 else |
7235 | 6653 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 6654 } |
6655 | |
8950 | 6656 #if 0 |
7011 | 6657 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 6658 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 6659 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 6660 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 6661 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 6662 maiden, NULL, NULL, city, state, NULL, 0, web); |
6663 } | |
8950 | 6664 #endif |
2086 | 6665 |
5575 | 6666 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 6667 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 6668 aim_srv_setidle(od->sess, time); |
2086 | 6669 } |
6670 | |
11347 | 6671 static |
6672 gchar *gaim_prpl_oscar_convert_to_infotext(const gchar *str, gsize *ret_len, char **encoding) | |
6673 { | |
9807 | 6674 int charset = 0; |
11347 | 6675 char *encoded = NULL; |
6676 | |
6677 charset = oscar_charset_check(str); | |
6678 if (charset == AIM_CHARSET_UNICODE) { | |
6679 encoded = g_convert(str, strlen(str), "UCS-2BE", "UTF-8", NULL, ret_len, NULL); | |
6680 *encoding = "unicode-2-0"; | |
6681 } else if (charset == AIM_CHARSET_CUSTOM) { | |
6682 encoded = g_convert(str, strlen(str), "ISO-8859-1", "UTF-8", NULL, ret_len, NULL); | |
6683 *encoding = "iso-8859-1"; | |
6684 } else { | |
6685 encoded = g_strdup(str); | |
6686 *ret_len = strlen(str); | |
6687 *encoding = "us-ascii"; | |
6688 } | |
6689 | |
6690 return encoded; | |
6691 } | |
6692 | |
6693 static void | |
6694 oscar_set_info(GaimConnection *gc, const char *rawinfo) | |
6695 { | |
11965 | 6696 GaimAccount *account; |
11347 | 6697 GaimStatus *status; |
11965 | 6698 |
6699 account = gaim_connection_get_account(gc); | |
6700 status = gaim_account_get_active_status(account); | |
6701 oscar_set_info_and_status(account, TRUE, rawinfo, FALSE, status); | |
6702 } | |
6703 | |
6704 static void | |
6705 oscar_set_extendedstatus(GaimConnection *gc) | |
6706 { | |
6707 OscarData *od; | |
6708 GaimAccount *account; | |
12653 | 6709 GaimStatus *status; |
6710 const gchar *status_id; | |
13234 | 6711 guint32 data = 0x00000000; |
11965 | 6712 |
6713 od = gc->proto_data; | |
6714 account = gaim_connection_get_account(gc); | |
12653 | 6715 status = gaim_account_get_active_status(account); |
6716 status_id = gaim_status_get_id(status); | |
11965 | 6717 |
12652 | 6718 data |= AIM_ICQ_STATE_HIDEIP; |
6719 if (gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE)) | |
6720 data |= AIM_ICQ_STATE_WEBAWARE; | |
6721 | |
12653 | 6722 if (!strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE) || !strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE)) |
6723 data |= AIM_ICQ_STATE_NORMAL; | |
6724 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
6725 data |= AIM_ICQ_STATE_AWAY; | |
6726 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
6727 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY; | |
6728 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
6729 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY; | |
6730 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
6731 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY; | |
6732 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
6733 data |= AIM_ICQ_STATE_CHAT; | |
6734 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
12652 | 6735 data |= AIM_ICQ_STATE_INVISIBLE; |
12653 | 6736 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) |
6737 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY; | |
12652 | 6738 |
6739 aim_setextstatus(od->sess, data); | |
11965 | 6740 } |
6741 | |
6742 static void | |
6743 oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo, | |
6744 gboolean setstatus, GaimStatus *status) | |
6745 { | |
6746 GaimConnection *gc = gaim_account_get_connection(account); | |
6747 OscarData *od = gc->proto_data; | |
6748 GaimPresence *presence; | |
11347 | 6749 GaimStatusType *status_type; |
6750 GaimStatusPrimitive primitive; | |
11965 | 6751 gboolean invisible; |
11347 | 6752 |
6753 char *htmlinfo; | |
6754 char *info_encoding = NULL; | |
6755 char *info = NULL; | |
6756 gsize infolen = 0; | |
6757 | |
6758 const char *htmlaway; | |
6759 char *away_encoding = NULL; | |
6760 char *away = NULL; | |
6761 gsize awaylen = 0; | |
6762 | |
6763 status_type = gaim_status_get_type(status); | |
6764 primitive = gaim_status_type_get_primitive(status_type); | |
11965 | 6765 presence = gaim_account_get_presence(account); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
6766 invisible = gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE); |
11965 | 6767 |
6768 if (!setinfo) | |
6769 { | |
6770 /* Do nothing! */ | |
6771 } | |
6772 else if (od->rights.maxsiglen == 0) | |
6773 { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6774 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6775 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6776 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6777 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6778 "again when you are fully connected.")); |
11965 | 6779 } |
6780 else if (rawinfo != NULL) | |
11347 | 6781 { |
6782 htmlinfo = gaim_strdup_withhtml(rawinfo); | |
6783 info = gaim_prpl_oscar_convert_to_infotext(htmlinfo, &infolen, &info_encoding); | |
6784 g_free(htmlinfo); | |
6785 | |
6786 if (infolen > od->rights.maxsiglen) | |
6787 { | |
6788 gchar *errstr; | |
6789 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
6790 "has been exceeded. Gaim has truncated it for you.", | |
6791 "The maximum profile length of %d bytes " | |
6792 "has been exceeded. Gaim has truncated it for you.", | |
6793 od->rights.maxsiglen), od->rights.maxsiglen); | |
6794 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
6795 g_free(errstr); | |
6796 } | |
6797 } | |
6798 | |
11965 | 6799 if (!setstatus) |
6800 { | |
6801 /* Do nothing! */ | |
6802 } | |
6803 else if (primitive == GAIM_STATUS_AVAILABLE) | |
11347 | 6804 { |
12349 | 6805 const char *status_html; |
6806 char *status_text; | |
6807 | |
6808 status_html = gaim_status_get_attr_string(status, "message"); | |
6809 if (status_html != NULL) | |
11965 | 6810 { |
12349 | 6811 status_text = gaim_markup_strip_html(status_html); |
12617 | 6812 /* If the status_text is longer than 60 character then truncate it */ |
6813 if (strlen(status_text) > 60) | |
6814 { | |
6815 char *tmp = g_utf8_find_prev_char(status_text, &status_text[58]); | |
6816 strcpy(tmp, "..."); | |
6817 } | |
12349 | 6818 aim_srv_setstatusmsg(od->sess, status_text); |
6819 g_free(status_text); | |
11965 | 6820 } |
6821 | |
6822 /* This is needed for us to un-set any previous away message. */ | |
6823 away = g_strdup(""); | |
6824 } | |
6825 else if (primitive == GAIM_STATUS_AWAY) | |
6826 { | |
11347 | 6827 htmlaway = gaim_status_get_attr_string(status, "message"); |
11965 | 6828 if ((htmlaway == NULL) || (*htmlaway == '\0')) |
11347 | 6829 htmlaway = _("Away"); |
6830 away = gaim_prpl_oscar_convert_to_infotext(htmlaway, &awaylen, &away_encoding); | |
6831 | |
6832 if (awaylen > od->rights.maxawaymsglen) | |
6833 { | |
6834 gchar *errstr; | |
6835 | |
6836 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
6837 "has been exceeded. Gaim has truncated it for you.", | |
6838 "The maximum away message length of %d bytes " | |
6839 "has been exceeded. Gaim has truncated it for you.", | |
6840 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
6841 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
6842 g_free(errstr); | |
6843 } | |
6844 } | |
6845 | |
11965 | 6846 if (setstatus) |
6847 oscar_set_extendedstatus(gc); | |
6848 | |
11347 | 6849 aim_locate_setprofile(od->sess, info_encoding, info, MIN(infolen, od->rights.maxsiglen), |
6850 away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen)); | |
6851 g_free(info); | |
6852 g_free(away); | |
2086 | 6853 } |
6854 | |
9991 | 6855 static void |
6856 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 6857 { |
9991 | 6858 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 6859 OscarData *od = NULL; |
9991 | 6860 |
10646 | 6861 if (gc) |
6862 od = (OscarData *)gc->proto_data; | |
6863 if (!od) | |
6864 return; | |
6865 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
6866 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_INVISIBLE) |
11766 | 6867 account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; |
8265 | 6868 else |
11766 | 6869 account->perm_deny = GAIM_PRIVACY_DENY_USERS; |
9991 | 6870 |
8265 | 6871 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
6872 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 6873 |
12653 | 6874 oscar_set_extendedstatus(gc); |
2993 | 6875 } |
6876 | |
9991 | 6877 static void |
6878 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 6879 { |
10747 | 6880 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
6881 | |
10498 | 6882 if (!gaim_status_is_active(status)) |
10485 | 6883 return; |
6884 | |
11718 | 6885 if (!gaim_account_is_connected(account)) |
6886 return; | |
6887 | |
12653 | 6888 /* Set the AIM-style away message for both AIM and ICQ accounts */ |
6889 oscar_set_info_and_status(account, FALSE, NULL, TRUE, status); | |
6890 | |
6891 /* Set the ICQ status for ICQ accounts only */ | |
11718 | 6892 if (aim_sn_is_icq(gaim_account_get_username(account))) |
6893 oscar_set_status_icq(account, status); | |
2086 | 6894 } |
6895 | |
11285 | 6896 #ifdef CRAZY_WARN |
9991 | 6897 static void |
6898 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 6899 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 6900 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 6901 } |
11285 | 6902 #endif |
2086 | 6903 |
10747 | 6904 static void |
6905 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6906 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6907 |
6908 if (!aim_snvalid(buddy->name)) { | |
8092 | 6909 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6910 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 | 6911 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
6912 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 6913 g_free(buf); |
8150 | 6914 |
6915 /* Remove from local list */ | |
9285 | 6916 gaim_blist_remove_buddy(buddy); |
8150 | 6917 |
8092 | 6918 return; |
6919 } | |
6920 | |
9285 | 6921 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
6922 if (buddy && group) { | |
8660 | 6923 gaim_debug_info("oscar", |
9285 | 6924 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 6925 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 6926 } |
6927 } | |
8150 | 6928 |
10157 | 6929 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 6930 if (od->icq) |
9285 | 6931 aim_icq_getalias(od->sess, buddy->name); |
6932 } | |
6933 | |
6934 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6935 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6936 |
4230 | 6937 if (od->sess->ssi.received_data) { |
8660 | 6938 gaim_debug_info("oscar", |
9285 | 6939 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
6940 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 6941 } |
10866 | 6942 } |
6943 | |
5575 | 6944 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 6945 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 6946 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 6947 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6948 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 6949 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 6950 } |
6951 } | |
6952 | |
5575 | 6953 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 6954 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 6955 if (od->sess->ssi.received_data) { |
6956 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
6957 if (gname) { | |
8660 | 6958 gaim_debug_info("oscar", |
9586 | 6959 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 6960 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 6961 } |
6962 } | |
6963 } | |
6964 | |
11005 | 6965 /* |
6966 * FYI, the OSCAR SSI code removes empty groups automatically. | |
6967 */ | |
9285 | 6968 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 6969 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6970 |
6971 if (od->sess->ssi.received_data) { | |
9285 | 6972 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
6973 GList *cur, *groups = NULL; | |
11643 | 6974 GaimAccount *account = gaim_connection_get_account(gc); |
9285 | 6975 |
6976 /* Make a list of what the groups each buddy is in */ | |
6977 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
6978 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6979 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6980 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6981 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6982 node->parent->parent); |
9285 | 6983 } |
6984 | |
11643 | 6985 gaim_account_remove_buddies(account, moved_buddies, groups); |
6986 gaim_account_add_buddies(account, moved_buddies); | |
9285 | 6987 g_list_free(groups); |
8660 | 6988 gaim_debug_info("oscar", |
9285 | 6989 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 6990 } else { |
9285 | 6991 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 6992 gaim_debug_info("oscar", |
9285 | 6993 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 6994 } |
6995 } | |
6996 } | |
6997 | |
5968 | 6998 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
13239 | 6999 OscarSession *sess = data; |
12663 | 7000 |
6350 | 7001 aim_ssi_reqdata(sess); |
12663 | 7002 |
13060 | 7003 return TRUE; |
5968 | 7004 } |
7005 | |
13239 | 7006 static int gaim_ssi_parseerr(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 7007 GaimConnection *gc = sess->aux_data; |
7283 | 7008 OscarData *od = gc->proto_data; |
4642 | 7009 va_list ap; |
13234 | 7010 guint16 reason; |
4642 | 7011 |
7012 va_start(ap, fr); | |
13234 | 7013 reason = (guint16)va_arg(ap, unsigned int); |
4642 | 7014 va_end(ap); |
7015 | |
8660 | 7016 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 7017 |
7018 if (reason == 0x0005) { | |
5892 | 7019 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7020 _("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 | 7021 if (od->getblisttimer > 0) |
7022 gaim_timeout_remove(od->getblisttimer); | |
7023 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od->sess); | |
4642 | 7024 } |
7025 | |
11965 | 7026 oscar_set_extendedstatus(gc); |
7027 | |
4642 | 7028 /* Activate SSI */ |
7029 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
7030 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 7031 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 7032 aim_ssi_enable(od->sess); |
7033 | |
7034 return 1; | |
7035 } | |
7036 | |
13239 | 7037 static int gaim_ssi_parserights(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 7038 GaimConnection *gc = sess->aux_data; |
7283 | 7039 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 7040 int i; |
7041 va_list ap; | |
7042 int numtypes; | |
13234 | 7043 guint16 *maxitems; |
2991 | 7044 |
7045 va_start(ap, fr); | |
4230 | 7046 numtypes = va_arg(ap, int); |
13234 | 7047 maxitems = va_arg(ap, guint16 *); |
2991 | 7048 va_end(ap); |
7049 | |
8660 | 7050 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
7051 |
4230 | 7052 for (i=0; i<numtypes; i++) |
8660 | 7053 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
7054 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
7055 |
8660 | 7056 gaim_debug_misc(NULL, "\n"); |
4230 | 7057 |
7058 if (numtypes >= 0) | |
7059 od->rights.maxbuddies = maxitems[0]; | |
7060 if (numtypes >= 1) | |
7061 od->rights.maxgroups = maxitems[1]; | |
7062 if (numtypes >= 2) | |
7063 od->rights.maxpermits = maxitems[2]; | |
7064 if (numtypes >= 3) | |
7065 od->rights.maxdenies = maxitems[3]; | |
2991 | 7066 |
7067 return 1; | |
7068 } | |
7069 | |
13239 | 7070 static int gaim_ssi_parselist(OscarSession *sess, FlapFrame *fr, ...) |
11965 | 7071 { |
7072 GaimConnection *gc; | |
7073 OscarData *od; | |
7074 GaimAccount *account; | |
8150 | 7075 GaimGroup *g; |
7076 GaimBuddy *b; | |
2995 | 7077 struct aim_ssi_item *curitem; |
13234 | 7078 guint32 tmp; |
4230 | 7079 va_list ap; |
13234 | 7080 guint16 fmtver, numitems; |
8219 | 7081 struct aim_ssi_item *items; |
13234 | 7082 guint32 timestamp; |
4230 | 7083 |
11965 | 7084 gc = sess->aux_data; |
7085 od = gc->proto_data; | |
7086 account = gaim_connection_get_account(gc); | |
7087 | |
4230 | 7088 va_start(ap, fr); |
13234 | 7089 fmtver = (guint16)va_arg(ap, int); |
7090 numitems = (guint16)va_arg(ap, int); | |
8219 | 7091 items = va_arg(ap, struct aim_ssi_item *); |
13234 | 7092 timestamp = va_arg(ap, guint32); |
8219 | 7093 va_end(ap); |
2991 | 7094 |
12663 | 7095 /* Don't attempt to re-request our buddy list later */ |
7096 if (od->getblisttimer != 0) | |
7097 gaim_timeout_remove(od->getblisttimer); | |
7098 od->getblisttimer = 0; | |
7099 | |
8660 | 7100 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7101 "ssi: syncing local list and server list\n"); |
2991 | 7102 |
8219 | 7103 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7104 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 | 7105 return 1; |
7106 } | |
7107 | |
2991 | 7108 /* Clean the buddy list */ |
4889 | 7109 aim_ssi_cleanlist(sess); |
2991 | 7110 |
8150 | 7111 { /* If not in server list then prune from local list */ |
7112 GaimBlistNode *gnode, *cnode, *bnode; | |
7113 GaimBuddyList *blist; | |
9539 | 7114 GSList *cur, *next; |
8150 | 7115 |
7116 /* Buddies */ | |
7117 cur = NULL; | |
7118 if ((blist = gaim_get_blist()) != NULL) { | |
7119 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
7120 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
7121 continue; | |
7122 g = (GaimGroup *)gnode; | |
7123 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
7124 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
7125 continue; | |
7126 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
7127 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7128 continue; | |
7129 b = (GaimBuddy *)bnode; | |
7130 if (b->account == gc->account) { | |
7131 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
7132 /* If the buddy is an ICQ user then load his nickname */ | |
7133 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 7134 char *alias; |
8150 | 7135 if (servernick) |
7136 serv_got_alias(gc, b->name, servernick); | |
7137 | |
7138 /* Store local alias on server */ | |
8214 | 7139 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 7140 if (!alias && b->alias && strlen(b->alias)) |
7141 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
7142 free(alias); | |
7143 } else { | |
8660 | 7144 gaim_debug_info("oscar", |
8150 | 7145 "ssi: removing buddy %s from local list\n", b->name); |
7146 /* We can't actually remove now because it will screw up our looping */ | |
7147 cur = g_slist_prepend(cur, b); | |
7148 } | |
7149 } | |
7150 } | |
7151 } | |
7152 } | |
7153 } | |
8175 | 7154 |
8150 | 7155 while (cur != NULL) { |
7156 b = cur->data; | |
7157 cur = g_slist_remove(cur, b); | |
7158 gaim_blist_remove_buddy(b); | |
7159 } | |
7160 | |
7161 /* Permit list */ | |
7162 if (gc->account->permit) { | |
9539 | 7163 next = gc->account->permit; |
7164 while (next != NULL) { | |
7165 cur = next; | |
7166 next = next->next; | |
8150 | 7167 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 7168 gaim_debug_info("oscar", |
8150 | 7169 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
7170 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
7171 } | |
9539 | 7172 } |
8150 | 7173 } |
7174 | |
7175 /* Deny list */ | |
7176 if (gc->account->deny) { | |
9539 | 7177 next = gc->account->deny; |
7178 while (next != NULL) { | |
7179 cur = next; | |
7180 next = next->next; | |
8150 | 7181 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 7182 gaim_debug_info("oscar", |
8150 | 7183 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
7184 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
7185 } | |
9539 | 7186 } |
8150 | 7187 } |
7188 /* Presence settings (idle time visibility) */ | |
7189 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
7190 if (!(tmp & 0x400)) | |
7191 aim_ssi_setpresence(sess, tmp | 0x400); | |
7192 } /* end pruning buddies from local list */ | |
7193 | |
2991 | 7194 /* Add from server list to local list */ |
4230 | 7195 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 7196 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 7197 switch (curitem->type) { |
4230 | 7198 case 0x0000: { /* Buddy */ |
4251 | 7199 if (curitem->name) { |
4292 | 7200 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7201 char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL; |
4282 | 7202 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7203 char *alias_utf8 = alias ? oscar_utf8_try_convert(gc->account, alias) : NULL; |
8150 | 7204 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 7205 /* Should gname be freed here? -- elb */ |
4754 | 7206 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 7207 free(alias); |
8150 | 7208 if (b) { |
4292 | 7209 /* Get server stored alias */ |
4705 | 7210 if (alias_utf8) { |
8150 | 7211 g_free(b->alias); |
7212 b->alias = g_strdup(alias_utf8); | |
4705 | 7213 } |
4282 | 7214 } else { |
8150 | 7215 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 7216 |
4754 | 7217 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 7218 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 7219 gaim_blist_add_group(g, NULL); |
7220 } | |
5146 | 7221 |
8660 | 7222 gaim_debug_info("oscar", |
9285 | 7223 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 7224 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 7225 } |
8341 | 7226 if (!aim_sncmp(curitem->name, account->username)) { |
7227 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
7228 gaim_check_comment(od, comment); | |
7229 free(comment); | |
7230 } | |
7162 | 7231 g_free(gname_utf8); |
7232 g_free(alias_utf8); | |
2991 | 7233 } |
4230 | 7234 } break; |
7235 | |
7236 case 0x0001: { /* Group */ | |
4282 | 7237 /* Shouldn't add empty groups */ |
4230 | 7238 } break; |
7239 | |
7240 case 0x0002: { /* Permit buddy */ | |
2991 | 7241 if (curitem->name) { |
4230 | 7242 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 7243 GSList *list; |
5575 | 7244 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 7245 if (!list) { |
8660 | 7246 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7247 "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
|
7248 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 7249 } |
7250 } | |
4230 | 7251 } break; |
7252 | |
7253 case 0x0003: { /* Deny buddy */ | |
2991 | 7254 if (curitem->name) { |
7255 GSList *list; | |
5575 | 7256 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 7257 if (!list) { |
8660 | 7258 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7259 "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
|
7260 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 7261 } |
7262 } | |
4230 | 7263 } break; |
7264 | |
7265 case 0x0004: { /* Permit/deny setting */ | |
2991 | 7266 if (curitem->data) { |
13234 | 7267 guint8 permdeny; |
5575 | 7268 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 7269 gaim_debug_info("oscar", |
5575 | 7270 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
7271 account->perm_deny = permdeny; | |
11766 | 7272 if (od->icq && account->perm_deny == GAIM_PRIVACY_ALLOW_USERS) { |
7273 gaim_presence_set_status_active(account->presence, OSCAR_STATUS_ID_INVISIBLE, TRUE); | |
4342 | 7274 } |
2991 | 7275 } |
7276 } | |
4230 | 7277 } break; |
7278 | |
7279 case 0x0005: { /* Presence setting */ | |
3109 | 7280 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 7281 } break; |
2991 | 7282 } /* End of switch on curitem->type */ |
7283 } /* End of for loop */ | |
4230 | 7284 |
11965 | 7285 oscar_set_extendedstatus(gc); |
4901 | 7286 |
4342 | 7287 /* Activate SSI */ |
7288 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
7289 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 7290 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7291 "ssi: activating server-stored buddy list\n"); |
4642 | 7292 aim_ssi_enable(sess); |
4342 | 7293 |
2991 | 7294 return 1; |
2086 | 7295 } |
4230 | 7296 |
13239 | 7297 static int gaim_ssi_parseack(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 7298 GaimConnection *gc = sess->aux_data; |
4230 | 7299 va_list ap; |
7300 struct aim_ssi_tmp *retval; | |
7301 | |
7302 va_start(ap, fr); | |
7303 retval = va_arg(ap, struct aim_ssi_tmp *); | |
7304 va_end(ap); | |
7305 | |
7306 while (retval) { | |
8660 | 7307 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7308 "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 | 7309 |
7310 if (retval->ack != 0xffff) | |
7311 switch (retval->ack) { | |
7312 case 0x0000: { /* added successfully */ | |
7313 } break; | |
7314 | |
4829 | 7315 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
7316 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7317 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 | 7318 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 7319 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 7320 g_free(buf); |
7321 } | |
7322 | |
7023 | 7323 case 0x000e: { /* buddy requires authorization */ |
13234 | 7324 if ((retval->action == OSCAR_SUBTYPE_FEEDBAG_ADD) && (retval->name)) |
4269 | 7325 gaim_auth_sendrequest(gc, retval->name); |
4230 | 7326 } break; |
7327 | |
7328 default: { /* La la la */ | |
5197 | 7329 gchar *buf; |
8660 | 7330 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
|
7331 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 | 7332 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 7333 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 7334 g_free(buf); |
4230 | 7335 } break; |
7336 } | |
7337 | |
7338 retval = retval->next; | |
7339 } | |
7340 | |
7341 return 1; | |
7342 } | |
7343 | |
13239 | 7344 static int gaim_ssi_parseadd(OscarSession *sess, FlapFrame *fr, ...) { |
8227 | 7345 GaimConnection *gc = sess->aux_data; |
7346 char *gname, *gname_utf8, *alias, *alias_utf8; | |
7347 GaimBuddy *b; | |
7348 GaimGroup *g; | |
7349 va_list ap; | |
13234 | 7350 guint16 type; |
8227 | 7351 const char *name; |
7352 | |
7353 va_start(ap, fr); | |
13234 | 7354 type = (guint16)va_arg(ap, int); |
8227 | 7355 name = va_arg(ap, char *); |
7356 va_end(ap); | |
7357 | |
7358 if ((type != 0x0000) || (name == NULL)) | |
7359 return 1; | |
7360 | |
7361 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7362 gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL; |
8227 | 7363 alias = aim_ssi_getalias(sess->ssi.local, gname, name); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7364 alias_utf8 = alias ? oscar_utf8_try_convert(gc->account, alias) : NULL; |
8227 | 7365 b = gaim_find_buddy(gc->account, name); |
7366 free(alias); | |
7367 | |
7368 if (b) { | |
7369 /* Get server stored alias */ | |
7370 if (alias_utf8) { | |
7371 g_free(b->alias); | |
7372 b->alias = g_strdup(alias_utf8); | |
7373 } | |
7374 } else { | |
7375 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
7376 | |
7377 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
7378 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
7379 gaim_blist_add_group(g, NULL); | |
7380 } | |
7381 | |
8660 | 7382 gaim_debug_info("oscar", |
9285 | 7383 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 7384 gaim_blist_add_buddy(b, NULL, g, NULL); |
7385 } | |
7386 g_free(gname_utf8); | |
7387 g_free(alias_utf8); | |
7388 | |
7389 return 1; | |
7390 } | |
7391 | |
13239 | 7392 static int gaim_ssi_authgiven(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 7393 GaimConnection *gc = sess->aux_data; |
4230 | 7394 va_list ap; |
7395 char *sn, *msg; | |
4236 | 7396 gchar *dialog_msg, *nombre; |
4230 | 7397 struct name_data *data; |
6695 | 7398 GaimBuddy *buddy; |
4230 | 7399 |
7400 va_start(ap, fr); | |
7401 sn = va_arg(ap, char *); | |
7402 msg = va_arg(ap, char *); | |
7403 va_end(ap); | |
7404 | |
8660 | 7405 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7406 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 7407 |
4687 | 7408 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 7409 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
7410 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 7411 else |
7412 nombre = g_strdup(sn); | |
7413 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7414 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 | 7415 data = g_new(struct name_data, 1); |
7416 data->gc = gc; | |
7417 data->name = g_strdup(sn); | |
7418 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7419 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7420 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 7421 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 7422 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 7423 G_CALLBACK(oscar_free_name_data)); |
4236 | 7424 |
4230 | 7425 g_free(dialog_msg); |
4236 | 7426 g_free(nombre); |
4230 | 7427 |
7428 return 1; | |
7429 } | |
7430 | |
13239 | 7431 static int gaim_ssi_authrequest(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 7432 GaimConnection *gc = sess->aux_data; |
4230 | 7433 va_list ap; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7434 char *sn; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7435 char *msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7436 GaimAccount *account = gaim_connection_get_account(gc); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7437 gchar *nombre; |
11567
603a0e626332
[gaim-migrate @ 13834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11537
diff
changeset
|
7438 gchar *reason = NULL; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7439 gchar *dialog_msg; |
4230 | 7440 struct name_data *data; |
6695 | 7441 GaimBuddy *buddy; |
4230 | 7442 |
7443 va_start(ap, fr); | |
7444 sn = va_arg(ap, char *); | |
7445 msg = va_arg(ap, char *); | |
7446 va_end(ap); | |
7447 | |
8660 | 7448 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7449 "ssi: received authorization request from %s\n", sn); |
4230 | 7450 |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7451 buddy = gaim_find_buddy(account, sn); |
9620 | 7452 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
7453 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 7454 else |
7455 nombre = g_strdup(sn); | |
7456 | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7457 if (msg != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7458 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
|
7459 |
603a0e626332
[gaim-migrate @ 13834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11537
diff
changeset
|
7460 if (reason == NULL) |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7461 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7462 |
10949 | 7463 dialog_msg = g_strdup_printf( |
7464 _("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
|
7465 nombre, gaim_account_get_username(account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7466 g_free(reason); |
10949 | 7467 |
4230 | 7468 data = g_new(struct name_data, 1); |
7469 data->gc = gc; | |
7470 data->name = g_strdup(sn); | |
7471 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7472 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7473 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 7474 GAIM_DEFAULT_ACTION_NONE, data, 2, |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
7475 _("_Authorize"), G_CALLBACK(gaim_auth_grant), |
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
7476 _("_Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 7477 |
4230 | 7478 g_free(dialog_msg); |
4236 | 7479 g_free(nombre); |
4230 | 7480 |
7481 return 1; | |
7482 } | |
7483 | |
13239 | 7484 static int gaim_ssi_authreply(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 7485 GaimConnection *gc = sess->aux_data; |
4230 | 7486 va_list ap; |
7487 char *sn, *msg; | |
4236 | 7488 gchar *dialog_msg, *nombre; |
13234 | 7489 guint8 reply; |
6695 | 7490 GaimBuddy *buddy; |
4230 | 7491 |
7492 va_start(ap, fr); | |
7493 sn = va_arg(ap, char *); | |
13234 | 7494 reply = (guint8)va_arg(ap, int); |
4230 | 7495 msg = va_arg(ap, char *); |
7496 va_end(ap); | |
7497 | |
8660 | 7498 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7499 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 7500 |
4687 | 7501 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 7502 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
7503 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 7504 else |
7505 nombre = g_strdup(sn); | |
7506 | |
4230 | 7507 if (reply) { |
7508 /* Granted */ | |
7023 | 7509 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
|
7510 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 7511 } else { |
7512 /* Denied */ | |
7023 | 7513 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
|
7514 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 7515 } |
7516 g_free(dialog_msg); | |
4236 | 7517 g_free(nombre); |
4230 | 7518 |
7519 return 1; | |
7520 } | |
7521 | |
13239 | 7522 static int gaim_ssi_gotadded(OscarSession *sess, FlapFrame *fr, ...) { |
5575 | 7523 GaimConnection *gc = sess->aux_data; |
4230 | 7524 va_list ap; |
7525 char *sn; | |
6695 | 7526 GaimBuddy *buddy; |
4230 | 7527 |
7528 va_start(ap, fr); | |
7529 sn = va_arg(ap, char *); | |
7530 va_end(ap); | |
7531 | |
4687 | 7532 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 7533 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7534 "ssi: %s added you to their buddy list\n", sn); |
9620 | 7535 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 7536 |
7537 return 1; | |
7538 } | |
2086 | 7539 |
5575 | 7540 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7541 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7542 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7543 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7544 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 7545 pce->label = _("_Room:"); |
5234 | 7546 pce->identifier = "room"; |
10475 | 7547 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7548 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7549 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7550 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 7551 pce->label = _("_Exchange:"); |
5234 | 7552 pce->identifier = "exchange"; |
10475 | 7553 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7554 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7555 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7556 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7557 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7558 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7559 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7560 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7561 |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
7562 static GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
9754 | 7563 { |
7564 GHashTable *defaults; | |
7565 | |
7566 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
7567 | |
7568 if (chat_name != NULL) | |
7569 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
7570 | |
7571 return defaults; | |
7572 } | |
7573 | |
9917 | 7574 static char *oscar_get_chat_name(GHashTable *data) { |
7575 return g_strdup(g_hash_table_lookup(data, "room")); | |
7576 } | |
7577 | |
8308 | 7578 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
7579 OscarData *od = (OscarData *)gc->proto_data; | |
13239 | 7580 OscarConnection *cur; |
5234 | 7581 char *name, *exchange; |
7582 | |
7583 name = g_hash_table_lookup(data, "room"); | |
7584 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7585 |
8308 | 7586 if ((name == NULL) || (*name == '\0')) { |
7587 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
7588 return; | |
7589 } | |
7590 | |
11461
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7591 gaim_debug_info("oscar", |
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7592 "Attempting to join chat room %s.\n", name); |
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7593 |
4617 | 7594 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 7595 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7596 "chatnav exists, creating room\n"); |
5234 | 7597 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 7598 } else { |
7599 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
7600 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 7601 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7602 "chatnav does not exist, opening chatnav\n"); |
5234 | 7603 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
7604 cr->name = g_strdup(name); |
4617 | 7605 od->create_rooms = g_slist_append(od->create_rooms, cr); |
7606 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 7607 } |
7608 } | |
7609 | |
8308 | 7610 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
7611 OscarData *od = (OscarData *)gc->proto_data; | |
7612 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 7613 |
7614 if (ccon == NULL) | |
2086 | 7615 return; |
10404 | 7616 |
8225 | 7617 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 7618 ccon->exchange, ccon->name, 0x0); |
7619 } | |
7620 | |
10458 | 7621 static void |
7622 oscar_chat_leave(GaimConnection *gc, int id) | |
7623 { | |
7624 GaimConversation *conv; | |
7625 struct chat_connection *cc; | |
7626 | |
7627 conv = gaim_find_chat(gc, id); | |
7628 | |
7629 g_return_if_fail(conv != NULL); | |
7630 | |
7631 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
7632 | |
7633 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
7634 oscar_chat_kill(gc, cc); | |
2086 | 7635 } |
7636 | |
12216 | 7637 static int oscar_send_chat(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) { |
8219 | 7638 OscarData *od = (OscarData *)gc->proto_data; |
7639 GaimConversation *conv = NULL; | |
2086 | 7640 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7641 char *buf, *buf2; |
13234 | 7642 guint16 charset, charsubset; |
9807 | 7643 char *charsetstr = NULL; |
10111 | 7644 int len; |
8219 | 7645 |
7646 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7647 return -EINVAL; |
2086 | 7648 |
8219 | 7649 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7650 return -EINVAL; |
2086 | 7651 |
8219 | 7652 buf = gaim_strdup_withhtml(message); |
7653 len = strlen(buf); | |
7654 | |
8962 | 7655 if (strstr(buf, "<IMG ")) |
7656 gaim_conversation_write(conv, "", | |
13226 | 7657 _("Your IM Image was not sent. " |
7658 "You cannot send IM Images in AIM chats."), | |
7659 GAIM_MESSAGE_ERROR, time(NULL)); | |
8962 | 7660 |
9830 | 7661 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 7662 if ((len > c->maxlen) || (len > c->maxvis)) { |
7663 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7664 return -E2BIG; |
8359 | 7665 } |
7666 | |
9831 | 7667 if (charset == AIM_CHARSET_ASCII) |
7668 charsetstr = "us-ascii"; | |
7669 else if (charset == AIM_CHARSET_UNICODE) | |
7670 charsetstr = "unicode-2-0"; | |
7671 else if (charset == AIM_CHARSET_CUSTOM) | |
7672 charsetstr = "iso-8859-1"; | |
9807 | 7673 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 7674 g_free(buf2); |
8359 | 7675 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7676 return 0; |
2086 | 7677 } |
7678 | |
10042 | 7679 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
7680 { | |
4766 | 7681 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 7682 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 7683 return "icq"; |
7684 else | |
7685 return "aim"; | |
7686 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
7687 |
9975 | 7688 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 7689 return "icq"; |
7690 return "aim"; | |
7691 } | |
7692 | |
9972 | 7693 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 7694 { |
7334 | 7695 GaimConnection *gc = NULL; |
7696 OscarData *od = NULL; | |
10042 | 7697 GaimAccount *account = NULL; |
7698 GaimPresence *presence; | |
7699 GaimStatus *status; | |
7700 const char *status_id; | |
4687 | 7701 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
7702 int i = 0; | |
7334 | 7703 aim_userinfo_t *userinfo = NULL; |
7704 | |
7705 if (b != NULL) | |
7706 account = b->account; | |
7707 if (account != NULL) | |
7708 gc = account->gc; | |
7709 if (gc != NULL) | |
7710 od = gc->proto_data; | |
7945 | 7711 if (od != NULL) |
7712 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 7713 |
10042 | 7714 presence = gaim_buddy_get_presence(b); |
7715 status = gaim_presence_get_active_status(presence); | |
7716 status_id = gaim_status_get_id(status); | |
7717 | |
7718 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 7719 char *gname; |
13226 | 7720 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
7721 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && | |
5131 | 7722 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { |
7723 emblems[i++] = "notauthorized"; | |
7724 } else { | |
7725 emblems[i++] = "offline"; | |
7726 } | |
7727 } | |
4916 | 7728 |
10042 | 7729 if (b->name && aim_sn_is_icq(b->name)) { |
7730 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
7731 emblems[i++] = "invisible"; | |
7732 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 7733 emblems[i++] = "freeforchat"; |
10042 | 7734 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 7735 emblems[i++] = "dnd"; |
10042 | 7736 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7737 emblems[i++] = "unavailable"; |
10042 | 7738 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 7739 emblems[i++] = "occupied"; |
10042 | 7740 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 7741 emblems[i++] = "away"; |
10042 | 7742 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
7743 emblems[i++] = "away"; | |
7744 } | |
7745 | |
7746 if (userinfo != NULL ) { | |
7747 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
7748 emblems[i++] = "unconfirmed"; */ | |
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7749 if ((i < 4) && userinfo->flags & AIM_FLAG_ADMINISTRATOR) |
10042 | 7750 emblems[i++] = "admin"; |
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7751 if ((i < 4) && userinfo->flags & AIM_FLAG_AOL) |
10042 | 7752 emblems[i++] = "aol"; |
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7753 if ((i < 4) && userinfo->flags & AIM_FLAG_WIRELESS) |
10042 | 7754 emblems[i++] = "wireless"; |
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7755 if ((i < 4) && userinfo->flags & AIM_FLAG_ACTIVEBUDDY) |
10042 | 7756 emblems[i++] = "activebuddy"; |
7757 | |
7758 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 7759 emblems[i++] = "hiptop"; |
7760 | |
10042 | 7761 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 7762 emblems[i++] = "secure"; |
10042 | 7763 } |
7334 | 7764 |
4687 | 7765 *se = emblems[0]; |
7766 *sw = emblems[1]; | |
7767 *nw = emblems[2]; | |
7768 *ne = emblems[3]; | |
7769 } | |
7770 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
7771 static void oscar_tooltip_text(GaimBuddy *b, GString *str, gboolean full) { |
5575 | 7772 GaimConnection *gc = b->account->gc; |
7283 | 7773 OscarData *od = gc->proto_data; |
7045 | 7774 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
5131 | 7775 |
7776 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
12189 | 7777 GaimPresence *presence; |
7778 GaimStatus *status; | |
7779 const char *message; | |
7780 | |
12948
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12946
diff
changeset
|
7781 if (full) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12946
diff
changeset
|
7782 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 7783 |
12189 | 7784 presence = gaim_buddy_get_presence(b); |
7785 status = gaim_presence_get_active_status(presence); | |
7786 message = gaim_status_get_attr_string(status, "message"); | |
7787 | |
12433 | 7788 if (gaim_status_is_available(status)) |
7789 { | |
7790 if (message != NULL) | |
7791 { | |
12189 | 7792 /* Available status messages are plain text */ |
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7793 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), message); |
12433 | 7794 } |
7795 } | |
7796 else | |
7797 { | |
7798 if (message != NULL) | |
7799 { | |
12189 | 7800 /* Away messages are HTML */ |
7091 | 7801 gchar *tmp1, *tmp2; |
12189 | 7802 tmp2 = gaim_markup_strip_html(message); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
7803 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 7804 g_free(tmp2); |
8700 | 7805 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 7806 g_free(tmp1); |
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7807 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp2); |
8700 | 7808 g_free(tmp2); |
5836 | 7809 } |
12433 | 7810 else |
7811 { | |
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7812 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), _("<i>(retrieving)</i>")); |
12433 | 7813 } |
5131 | 7814 } |
8701 | 7815 } |
5131 | 7816 } |
7817 | |
10042 | 7818 static char *oscar_status_text(GaimBuddy *b) |
7819 { | |
7820 GaimConnection *gc; | |
12347 | 7821 GaimAccount *account; |
10042 | 7822 OscarData *od; |
12347 | 7823 const GaimPresence *presence; |
7824 const GaimStatus *status; | |
7825 const char *id; | |
7826 const char *message; | |
5167 | 7827 gchar *ret = NULL; |
7828 | |
10042 | 7829 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
12347 | 7830 account = gaim_connection_get_account(gc); |
10042 | 7831 od = gc->proto_data; |
11248 | 7832 presence = gaim_buddy_get_presence(b); |
12347 | 7833 status = gaim_presence_get_active_status(presence); |
7834 id = gaim_status_get_id(status); | |
11248 | 7835 |
7836 if (!gaim_presence_is_online(presence)) | |
7837 { | |
5167 | 7838 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
7839 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
7840 ret = g_strdup(_("Not Authorized")); | |
7841 else | |
7842 ret = g_strdup(_("Offline")); | |
7843 } | |
12365 | 7844 else if (gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AVAILABLE)) |
12347 | 7845 { |
12365 | 7846 /* Available */ |
12347 | 7847 message = gaim_status_get_attr_string(status, "message"); |
7848 if (message != NULL) | |
7849 { | |
7850 ret = g_markup_escape_text(message, -1); | |
7851 gaim_util_chrreplace(ret, '\n', ' '); | |
7852 } | |
7853 } | |
12365 | 7854 else if (!gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AWAY)) |
11248 | 7855 { |
12365 | 7856 /* Away */ |
12347 | 7857 message = gaim_status_get_attr_string(status, "message"); |
7858 if (message != NULL) | |
7859 { | |
7860 gchar *tmp1, *tmp2; | |
7861 tmp1 = gaim_markup_strip_html(message); | |
12361 | 7862 gaim_util_chrreplace(tmp1, '\n', ' '); |
12347 | 7863 tmp2 = g_markup_escape_text(tmp1, -1); |
7864 ret = gaim_str_sub_away_formatters(tmp2, gaim_account_get_username(account)); | |
7865 g_free(tmp1); | |
7866 g_free(tmp2); | |
7867 } | |
7868 else | |
7869 { | |
7870 ret = g_strdup(_("Away")); | |
11510 | 7871 } |
11248 | 7872 } |
7873 else | |
12347 | 7874 ret = g_strdup(gaim_status_get_name(status)); |
5167 | 7875 |
7876 return ret; | |
7877 } | |
7878 | |
5842 | 7879 |
13239 | 7880 static int oscar_icon_req(OscarSession *sess, FlapFrame *fr, ...) { |
5842 | 7881 GaimConnection *gc = sess->aux_data; |
7283 | 7882 OscarData *od = gc->proto_data; |
5892 | 7883 va_list ap; |
13234 | 7884 guint16 type; |
7885 guint8 flags = 0, length = 0; | |
11159 | 7886 guchar *md5 = NULL; |
5892 | 7887 |
5842 | 7888 va_start(ap, fr); |
7889 type = va_arg(ap, int); | |
5892 | 7890 |
7891 switch(type) { | |
7892 case 0x0000: | |
7893 case 0x0001: { | |
7894 flags = va_arg(ap, int); | |
7895 length = va_arg(ap, int); | |
11159 | 7896 md5 = va_arg(ap, guchar *); |
5892 | 7897 |
7898 if (flags == 0x41) { | |
7899 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
7900 od->iconconnecting = TRUE; | |
7901 od->set_icon = TRUE; | |
7902 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
7903 } else { | |
6039 | 7904 struct stat st; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7905 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
6039 | 7906 if (iconfile == NULL) { |
8363 | 7907 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7908 } else if (!g_stat(iconfile, &st)) { |
11159 | 7909 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7910 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 7911 if (file) { |
9532 | 7912 /* XXX - Use g_file_get_contents()? */ |
6039 | 7913 fread(buf, 1, st.st_size, file); |
7914 fclose(file); | |
8660 | 7915 gaim_debug_info("oscar", |
10042 | 7916 "Uploading icon to icon server\n"); |
6879 | 7917 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 7918 } else |
8660 | 7919 gaim_debug_error("oscar", |
10042 | 7920 "Can't open buddy icon file!\n"); |
6039 | 7921 g_free(buf); |
7922 } else { | |
8660 | 7923 gaim_debug_error("oscar", |
10042 | 7924 "Can't stat buddy icon file!\n"); |
5892 | 7925 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7926 g_free(iconfile); |
5892 | 7927 } |
8363 | 7928 } else if (flags == 0x81) { |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7929 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
8363 | 7930 if (iconfile == NULL) |
7931 aim_ssi_delicon(od->sess); | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7932 else { |
8363 | 7933 aim_ssi_seticon(od->sess, md5, length); |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7934 g_free(iconfile); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7935 } |
8363 | 7936 } |
5892 | 7937 } break; |
7938 | |
7939 case 0x0002: { /* We just set an "available" message? */ | |
7940 } break; | |
7941 } | |
7942 | |
5842 | 7943 va_end(ap); |
5844 | 7944 |
7945 return 0; | |
5842 | 7946 } |
5892 | 7947 |
5575 | 7948 static void oscar_set_permit_deny(GaimConnection *gc) { |
7949 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 7950 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 7951 |
8175 | 7952 if (od->sess->ssi.received_data) { |
7953 switch (account->perm_deny) { | |
7954 case GAIM_PRIVACY_ALLOW_ALL: | |
7955 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
7956 break; | |
7957 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
7958 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
7959 break; | |
7960 case GAIM_PRIVACY_ALLOW_USERS: | |
7961 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
7962 break; | |
7963 case GAIM_PRIVACY_DENY_ALL: | |
7964 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
7965 break; | |
7966 case GAIM_PRIVACY_DENY_USERS: | |
7967 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
7968 break; | |
7969 default: | |
7970 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
7971 break; | |
7972 } | |
7973 } | |
2086 | 7974 } |
7975 | |
5575 | 7976 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 7977 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7978 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 7979 if (od->sess->ssi.received_data) |
4889 | 7980 aim_ssi_addpermit(od->sess, who); |
2086 | 7981 } |
7982 | |
5575 | 7983 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 7984 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7985 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 7986 if (od->sess->ssi.received_data) |
4889 | 7987 aim_ssi_adddeny(od->sess, who); |
2086 | 7988 } |
7989 | |
5575 | 7990 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 7991 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7992 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 7993 if (od->sess->ssi.received_data) |
4889 | 7994 aim_ssi_delpermit(od->sess, who); |
2086 | 7995 } |
7996 | |
5575 | 7997 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 7998 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7999 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 8000 if (od->sess->ssi.received_data) |
4889 | 8001 aim_ssi_deldeny(od->sess, who); |
2086 | 8002 } |
8003 | |
9975 | 8004 static GList * |
8005 oscar_status_types(GaimAccount *account) | |
2086 | 8006 { |
12662 | 8007 gboolean is_icq; |
9975 | 8008 GList *status_types = NULL; |
8009 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
8010 |
9973 | 8011 g_return_val_if_fail(account != NULL, NULL); |
8012 | |
13007 | 8013 /* Used to flag some statuses as "user settable" or not */ |
12662 | 8014 is_icq = aim_sn_is_icq(gaim_account_get_username(account)); |
8015 | |
13007 | 8016 /* Common status types */ |
8017 /* Really the available message should only be settable for AIM accounts */ | |
8018 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, | |
8019 OSCAR_STATUS_ID_AVAILABLE, | |
8020 NULL, TRUE, TRUE, FALSE, | |
8021 "message", _("Message"), | |
8022 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
8023 status_types = g_list_append(status_types, type); | |
8024 | |
8025 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, | |
8026 OSCAR_STATUS_ID_FREE4CHAT, | |
8027 _("Free For Chat"), TRUE, is_icq, FALSE); | |
8028 status_types = g_list_append(status_types, type); | |
9976 | 8029 |
10195 | 8030 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
8031 OSCAR_STATUS_ID_AWAY, | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
8032 NULL, TRUE, TRUE, FALSE, |
10195 | 8033 "message", _("Message"), |
8034 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 8035 status_types = g_list_append(status_types, type); |
8036 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
8037 type = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, |
10042 | 8038 OSCAR_STATUS_ID_INVISIBLE, |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
8039 NULL, TRUE, TRUE, FALSE); |
10042 | 8040 status_types = g_list_append(status_types, type); |
8041 | |
8042 /* ICQ-specific status types */ | |
13007 | 8043 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
8044 OSCAR_STATUS_ID_OCCUPIED, | |
8045 _("Occupied"), TRUE, is_icq, FALSE); | |
8046 status_types = g_list_append(status_types, type); | |
8047 | |
8048 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, | |
8049 OSCAR_STATUS_ID_DND, | |
8050 _("Do Not Disturb"), TRUE, is_icq, FALSE); | |
8051 status_types = g_list_append(status_types, type); | |
8052 | |
8053 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, | |
8054 OSCAR_STATUS_ID_NA, | |
8055 _("Not Available"), TRUE, is_icq, FALSE); | |
8056 status_types = g_list_append(status_types, type); | |
12658 | 8057 |
8058 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, | |
8059 OSCAR_STATUS_ID_OFFLINE, | |
8060 NULL, TRUE, TRUE, FALSE); | |
9976 | 8061 status_types = g_list_append(status_types, type); |
9975 | 8062 |
8063 return status_types; | |
4333 | 8064 } |
8065 | |
7172 | 8066 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 8067 GaimConnection *gc = data->gc; |
8068 OscarData *od = gc->proto_data; | |
7172 | 8069 GaimBuddy *b; |
8070 GaimGroup *g; | |
8071 | |
8072 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
8073 oscar_free_name_data(data); | |
8074 return; | |
8075 } | |
8076 | |
12088 | 8077 if (!(g = gaim_buddy_get_group(b))) { |
7172 | 8078 oscar_free_name_data(data); |
8079 return; | |
8080 } | |
8081 | |
8082 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 8083 |
8084 if (!aim_sncmp(data->name, gc->account->username)) | |
8085 gaim_check_comment(od, text); | |
8086 | |
7172 | 8087 oscar_free_name_data(data); |
8088 } | |
8089 | |
9030 | 8090 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
8091 | |
8092 GaimBuddy *buddy; | |
8093 GaimConnection *gc; | |
8094 OscarData *od; | |
8095 struct name_data *data; | |
7172 | 8096 GaimGroup *g; |
8097 char *comment; | |
8098 gchar *comment_utf8; | |
9631 | 8099 gchar *title; |
7172 | 8100 |
9030 | 8101 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
8102 | |
8103 buddy = (GaimBuddy *) node; | |
8104 gc = gaim_account_get_connection(buddy->account); | |
8105 od = gc->proto_data; | |
8106 | |
8107 data = g_new(struct name_data, 1); | |
8108 | |
12088 | 8109 if (!(g = gaim_buddy_get_group(buddy))) |
7172 | 8110 return; |
9030 | 8111 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
8112 comment_utf8 = comment ? oscar_utf8_try_convert(gc->account, comment) : NULL; |
7172 | 8113 |
8114 data->gc = gc; | |
9030 | 8115 data->name = g_strdup(buddy->name); |
7172 | 8116 data->nick = NULL; |
8117 | |
9631 | 8118 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
8119 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 8120 comment_utf8, TRUE, FALSE, NULL, |
7172 | 8121 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
8122 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
8123 data); | |
9631 | 8124 g_free(title); |
7172 | 8125 |
8126 free(comment); | |
8127 g_free(comment_utf8); | |
8128 } | |
8129 | |
9030 | 8130 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
8131 | |
8132 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 8133 OscarData *od = gc->proto_data; |
9030 | 8134 |
4333 | 8135 GList *m = NULL; |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8136 GaimMenuAction *act; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8137 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8138 act = gaim_menu_action_new(_("Edit Buddy Comment"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8139 GAIM_CALLBACK(oscar_buddycb_edit_comment), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8140 NULL, NULL); |
9030 | 8141 m = g_list_append(m, act); |
7172 | 8142 |
4333 | 8143 if (od->icq) { |
4624 | 8144 #if 0 |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8145 act = gaim_menu_action_new(_("Get Status Msg"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8146 GAIM_CALLBACK(oscar_get_icqstatusmsg), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8147 NULL, NULL); |
9030 | 8148 m = g_list_append(m, act); |
4624 | 8149 #endif |
4333 | 8150 } else { |
7011 | 8151 aim_userinfo_t *userinfo; |
9030 | 8152 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
8153 | |
8154 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
8155 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
8156 | |
7011 | 8157 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8158 act = gaim_menu_action_new(_("Direct IM"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8159 GAIM_CALLBACK(oscar_ask_direct_im), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8160 NULL, NULL); |
9030 | 8161 m = g_list_append(m, act); |
5917 | 8162 } |
9466 | 8163 #if 0 |
7011 | 8164 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8165 act = gaim_menu_action_new(_("Get File"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8166 GAIM_CALLBACK(oscar_ask_getfile), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8167 NULL, NULL); |
9030 | 8168 m = g_list_append(m, act); |
5917 | 8169 } |
4826 | 8170 #endif |
4333 | 8171 } |
5131 | 8172 } |
5197 | 8173 |
5131 | 8174 if (od->sess->ssi.received_data) { |
9030 | 8175 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
8176 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8177 act = gaim_menu_action_new(_("Re-request Authorization"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8178 GAIM_CALLBACK(gaim_auth_sendrequest_menu), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8179 NULL, NULL); |
9030 | 8180 m = g_list_append(m, act); |
4333 | 8181 } |
4916 | 8182 } |
10157 | 8183 |
4333 | 8184 return m; |
8185 } | |
8186 | |
9030 | 8187 |
8188 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
8189 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
8190 return oscar_buddy_menu((GaimBuddy *) node); | |
8191 } else { | |
8192 return NULL; | |
8193 } | |
8194 } | |
8195 | |
10570 | 8196 static void |
8197 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
8198 { | |
8199 OscarData *od = gc->proto_data; | |
8200 GaimAccount *account = gaim_connection_get_account(gc); | |
8201 GaimRequestField *f; | |
12652 | 8202 gboolean auth, web_aware; |
10570 | 8203 |
8204 f = gaim_request_fields_get_field(fields, "authorization"); | |
8205 auth = gaim_request_field_bool_get_value(f); | |
8206 | |
8207 f = gaim_request_fields_get_field(fields, "web_aware"); | |
8208 web_aware = gaim_request_field_bool_get_value(f); | |
8209 | |
8210 gaim_account_set_bool(account, "authorization", auth); | |
8211 gaim_account_set_bool(account, "web_aware", web_aware); | |
8212 | |
12652 | 8213 oscar_set_extendedstatus(gc); |
8214 aim_icq_setsecurity(od->sess, auth, web_aware); | |
10570 | 8215 } |
8216 | |
8217 static void | |
8218 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
8219 { | |
8220 GaimConnection *gc = (GaimConnection *) action->context; | |
8221 GaimAccount *account = gaim_connection_get_account(gc); | |
8222 GaimRequestFields *fields; | |
8223 GaimRequestFieldGroup *g; | |
8224 GaimRequestField *f; | |
12652 | 8225 gboolean auth, web_aware; |
10570 | 8226 |
8227 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
8228 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
8229 | |
8230 fields = gaim_request_fields_new(); | |
8231 | |
8232 g = gaim_request_field_group_new(NULL); | |
8233 | |
8234 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
8235 gaim_request_field_group_add_field(g, f); | |
8236 | |
12617 | 8237 f = gaim_request_field_bool_new("web_aware", _("Web aware (enabling this will cause you to receive SPAM!)"), web_aware); |
10570 | 8238 gaim_request_field_group_add_field(g, f); |
8239 | |
8240 gaim_request_fields_add_group(fields, g); | |
8241 | |
8242 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
8243 NULL, fields, | |
8244 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
8245 _("Cancel"), NULL, gc); | |
8246 } | |
9030 | 8247 |
5575 | 8248 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 8249 OscarData *od = gc->proto_data; |
5575 | 8250 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 8251 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
8252 od->setnick = TRUE; | |
8253 od->newsn = g_strdup(nick); | |
8254 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
8255 } else { | |
8256 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
8257 } | |
8258 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
8259 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 8260 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 8261 } |
8262 } | |
8263 | |
9015 | 8264 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 8265 { |
9015 | 8266 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 8267 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 8268 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8269 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8270 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8271 gc); |
4333 | 8272 } |
8273 | |
9015 | 8274 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 8275 { |
9015 | 8276 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 8277 OscarData *od = gc->proto_data; |
13239 | 8278 OscarConnection *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
4333 | 8279 |
8280 if (conn) { | |
8281 aim_admin_reqconfirm(od->sess, conn); | |
8282 } else { | |
8283 od->conf = TRUE; | |
8284 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
8285 } | |
8286 } | |
8287 | |
9015 | 8288 static void oscar_show_email(GaimPluginAction *action) |
4333 | 8289 { |
9015 | 8290 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 8291 OscarData *od = gc->proto_data; |
13239 | 8292 OscarConnection *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
4333 | 8293 |
8294 if (conn) { | |
8295 aim_admin_getinfo(od->sess, conn, 0x11); | |
8296 } else { | |
8297 od->reqemail = TRUE; | |
8298 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
8299 } | |
8300 } | |
8301 | |
5575 | 8302 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8303 { |
7283 | 8304 OscarData *od = gc->proto_data; |
13239 | 8305 OscarConnection *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8306 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8307 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8308 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8309 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8310 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8311 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8312 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8313 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8314 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8315 |
9015 | 8316 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 8317 { |
9015 | 8318 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
8319 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 8320 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8321 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8322 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8323 gc); |
4333 | 8324 } |
8325 | |
9015 | 8326 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 8327 { |
9015 | 8328 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 8329 OscarData *od = gc->proto_data; |
4333 | 8330 gchar *nombre, *text, *tmp; |
6695 | 8331 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 8332 int num=0; |
8333 | |
6873 | 8334 text = g_strdup(""); |
4333 | 8335 |
4785 | 8336 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 8337 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 8338 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
8339 continue; | |
6695 | 8340 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
8341 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 8342 continue; |
6695 | 8343 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
8344 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
8345 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
8346 continue; | |
8347 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 8348 if (gaim_buddy_get_alias_only(buddy)) |
8349 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 8350 else |
8351 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 8352 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 8353 g_free(text); |
8354 text = tmp; | |
8355 g_free(nombre); | |
8356 num++; | |
8357 } | |
4333 | 8358 } |
2979 | 8359 } |
4333 | 8360 } |
8361 | |
8362 if (!num) { | |
8363 g_free(text); | |
6873 | 8364 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
8365 } | |
8366 | |
8367 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
8368 "the following buddies"), _("You can re-request " | |
8369 "authorization from these buddies by " | |
8370 "right-clicking on them and selecting " | |
8371 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 8372 g_free(text); |
2979 | 8373 } |
8374 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8375 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8376 { |
8950 | 8377 OscarData *od = (OscarData *)gc->proto_data; |
8378 | |
8379 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8380 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8381 |
9015 | 8382 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8383 { |
9015 | 8384 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8385 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8386 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8387 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8388 "searching for."), |
8697 | 8389 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8390 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8391 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8392 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8393 |
9015 | 8394 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8395 { |
9015 | 8396 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8397 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8398 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8399 |
9015 | 8400 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 8401 { |
9015 | 8402 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
8403 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 8404 } |
8405 | |
9015 | 8406 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8407 { |
9015 | 8408 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8409 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8410 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8411 |
9015 | 8412 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 8413 { |
9015 | 8414 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 8415 OscarData *od = gc->proto_data; |
5575 | 8416 gchar *substituted = gaim_strreplace(od->sess->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
|
8417 gaim_notify_uri(gc, substituted); |
5517 | 8418 g_free(substituted); |
4333 | 8419 } |
8420 | |
9015 | 8421 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 8422 { |
9015 | 8423 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
8424 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 8425 } |
8426 | |
5842 | 8427 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
8428 { | |
7283 | 8429 OscarData *od = gc->proto_data; |
13239 | 8430 OscarSession *sess = od->sess; |
5842 | 8431 FILE *file; |
8432 struct stat st; | |
5844 | 8433 |
6039 | 8434 if (iconfile == NULL) { |
8363 | 8435 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
8436 } else if (!g_stat(iconfile, &st)) { |
11159 | 8437 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
8438 file = g_fopen(iconfile, "rb"); |
11404 | 8439 if (file) |
8440 { | |
8441 GaimCipher *cipher; | |
8442 GaimCipherContext *context; | |
11159 | 8443 guchar md5[16]; |
11404 | 8444 int len; |
8445 | |
9532 | 8446 /* XXX - Use g_file_get_contents()? */ |
11404 | 8447 len = fread(buf, 1, st.st_size, file); |
6039 | 8448 fclose(file); |
11404 | 8449 |
8450 cipher = gaim_ciphers_find_cipher("md5"); | |
8451 context = gaim_cipher_context_new(cipher, NULL); | |
8452 gaim_cipher_context_append(context, buf, len); | |
8453 gaim_cipher_context_digest(context, 16, md5, NULL); | |
8454 gaim_cipher_context_destroy(context); | |
8455 | |
5842 | 8456 aim_ssi_seticon(sess, md5, 16); |
8457 } else | |
8660 | 8458 gaim_debug_error("oscar", |
5842 | 8459 "Can't open buddy icon file!\n"); |
8460 g_free(buf); | |
8461 } else | |
8660 | 8462 gaim_debug_error("oscar", |
5842 | 8463 "Can't stat buddy icon file!\n"); |
8464 } | |
8465 | |
8466 | |
9015 | 8467 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 8468 { |
9015 | 8469 GaimConnection *gc = (GaimConnection *) context; |
7283 | 8470 OscarData *od = gc->proto_data; |
4333 | 8471 GList *m = NULL; |
9015 | 8472 GaimPluginAction *act; |
8473 | |
8474 act = gaim_plugin_action_new(_("Set User Info..."), | |
8475 oscar_show_set_info); | |
8476 m = g_list_append(m, act); | |
4333 | 8477 |
10570 | 8478 if (od->icq) |
8479 { | |
9015 | 8480 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
8481 oscar_show_set_info_icqurl); | |
8482 m = g_list_append(m, act); | |
8576 | 8483 } |
8484 | |
9015 | 8485 act = gaim_plugin_action_new(_("Change Password..."), |
8486 oscar_change_pass); | |
8487 m = g_list_append(m, act); | |
4617 | 8488 |
10570 | 8489 if (od->sess->authinfo->chpassurl != NULL) |
8490 { | |
9015 | 8491 act = gaim_plugin_action_new(_("Change Password (URL)"), |
8492 oscar_show_chpassurl); | |
8493 m = g_list_append(m, act); | |
8494 | |
8495 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
8496 oscar_show_imforwardingurl); | |
8497 m = g_list_append(m, act); | |
7026 | 8498 } |
8499 | |
10570 | 8500 m = g_list_append(m, NULL); |
8501 | |
8502 if (od->icq) | |
8503 { | |
8504 /* ICQ actions */ | |
12652 | 8505 act = gaim_plugin_action_new(_("Set Privacy Options..."), |
10570 | 8506 oscar_show_icq_privacy_opts); |
8507 m = g_list_append(m, act); | |
8508 } | |
8509 else | |
8510 { | |
4617 | 8511 /* AIM actions */ |
9015 | 8512 act = gaim_plugin_action_new(_("Format Screen Name..."), |
8513 oscar_show_format_screenname); | |
8514 m = g_list_append(m, act); | |
8515 | |
8516 act = gaim_plugin_action_new(_("Confirm Account"), | |
8517 oscar_confirm_account); | |
8518 m = g_list_append(m, act); | |
8519 | |
8520 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
8521 oscar_show_email); | |
8522 m = g_list_append(m, act); | |
8523 | |
8524 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
8525 oscar_show_change_email); | |
8526 m = g_list_append(m, act); | |
2086 | 8527 } |
4333 | 8528 |
8529 m = g_list_append(m, NULL); | |
8530 | |
9015 | 8531 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
8532 oscar_show_awaitingauth); | |
8533 m = g_list_append(m, act); | |
4333 | 8534 |
2086 | 8535 m = g_list_append(m, NULL); |
4333 | 8536 |
9015 | 8537 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
8538 oscar_show_find_email); | |
8539 m = g_list_append(m, act); | |
4333 | 8540 |
8591 | 8541 #if 0 |
9015 | 8542 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
8543 show_find_info); | |
8544 m = g_list_append(m, act); | |
8591 | 8545 #endif |
2086 | 8546 |
8547 return m; | |
8548 } | |
8549 | |
5575 | 8550 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 8551 { |
7283 | 8552 OscarData *od = gc->proto_data; |
4617 | 8553 |
8554 if (od->icq) { | |
8555 aim_icq_changepasswd(od->sess, new); | |
2086 | 8556 } else { |
13239 | 8557 OscarConnection *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
4617 | 8558 if (conn) { |
8559 aim_admin_changepasswd(od->sess, conn, new, old); | |
8560 } else { | |
8561 od->chpass = TRUE; | |
8562 od->oldp = g_strdup(old); | |
8563 od->newp = g_strdup(new); | |
8564 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
8565 } | |
2086 | 8566 } |
8567 } | |
8568 | |
6059 | 8569 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8570 { |
7283 | 8571 OscarData *od = gc->proto_data; |
8971 | 8572 struct oscar_direct_im *dim = oscar_direct_im_find(od, who); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8573 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8574 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8575 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8576 |
8971 | 8577 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8578 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8579 |
9935 | 8580 static void |
12816 | 8581 recent_buddies_cb(const char *name, GaimPrefType type, |
8582 gconstpointer value, gpointer data) | |
9935 | 8583 { |
8584 GaimConnection *gc = data; | |
8585 OscarData *od = gc->proto_data; | |
13239 | 8586 OscarSession *sess = od->sess; |
13234 | 8587 guint32 presence; |
9935 | 8588 |
8589 presence = aim_ssi_getpresence(sess->ssi.local); | |
8590 | |
8591 if (value) { | |
12486 | 8592 presence &= ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES; |
9935 | 8593 aim_ssi_setpresence(sess, presence); |
8594 } else { | |
12486 | 8595 presence |= AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES; |
9935 | 8596 aim_ssi_setpresence(sess, presence); |
8597 } | |
8598 } | |
8599 | |
11153 | 8600 static const char * |
8601 oscar_normalize(const GaimAccount *account, const char *str) | |
8602 { | |
8603 static char buf[BUF_LEN]; | |
8604 char *tmp1, *tmp2; | |
8605 int i, j; | |
8606 | |
8607 g_return_val_if_fail(str != NULL, NULL); | |
8608 | |
8609 strncpy(buf, str, BUF_LEN); | |
8610 for (i=0, j=0; buf[j]; i++, j++) | |
8611 { | |
8612 while (buf[j] == ' ') | |
8613 j++; | |
8614 buf[i] = buf[j]; | |
8615 } | |
8616 buf[i] = '\0'; | |
8617 | |
8618 tmp1 = g_utf8_strdown(buf, -1); | |
8619 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
8620 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
8621 g_free(tmp2); | |
8622 g_free(tmp1); | |
8623 | |
8624 return buf; | |
8625 } | |
8626 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8627 static gboolean oscar_offline_message(const GaimBuddy *buddy) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8628 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8629 OscarData *od; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8630 GaimAccount *account; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8631 GaimConnection *gc; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8632 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8633 account = gaim_buddy_get_account(buddy); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8634 gc = gaim_account_get_connection(account); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8635 od = (OscarData *)gc->proto_data; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8636 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8637 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
|
8638 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8639 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8640 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8641 { |
9308 | 8642 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 8643 NULL, /* user_splits */ |
8644 NULL, /* protocol_options */ | |
10674 | 8645 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
8646 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 8647 oscar_list_icon, /* list_icon */ |
8648 oscar_list_emblems, /* list_emblems */ | |
8649 oscar_status_text, /* status_text */ | |
8650 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 8651 oscar_status_types, /* status_types */ |
9475 | 8652 oscar_blist_node_menu, /* blist_node_menu */ |
8653 oscar_chat_info, /* chat_info */ | |
9754 | 8654 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 8655 oscar_login, /* login */ |
8656 oscar_close, /* close */ | |
8657 oscar_send_im, /* send_im */ | |
8658 oscar_set_info, /* set_info */ | |
8659 oscar_send_typing, /* send_typing */ | |
8660 oscar_get_info, /* get_info */ | |
9973 | 8661 oscar_set_status, /* set_status */ |
9475 | 8662 oscar_set_idle, /* set_idle */ |
8663 oscar_change_passwd, /* change_passwd */ | |
8664 oscar_add_buddy, /* add_buddy */ | |
10866 | 8665 NULL, /* add_buddies */ |
9475 | 8666 oscar_remove_buddy, /* remove_buddy */ |
10866 | 8667 NULL, /* remove_buddies */ |
9475 | 8668 oscar_add_permit, /* add_permit */ |
8669 oscar_add_deny, /* add_deny */ | |
8670 oscar_rem_permit, /* rem_permit */ | |
8671 oscar_rem_deny, /* rem_deny */ | |
8672 oscar_set_permit_deny, /* set_permit_deny */ | |
8673 oscar_join_chat, /* join_chat */ | |
8674 NULL, /* reject_chat */ | |
9973 | 8675 oscar_get_chat_name, /* get_chat_name */ |
9475 | 8676 oscar_chat_invite, /* chat_invite */ |
8677 oscar_chat_leave, /* chat_leave */ | |
8678 NULL, /* chat_whisper */ | |
8679 oscar_send_chat, /* chat_send */ | |
8680 oscar_keepalive, /* keepalive */ | |
8681 NULL, /* register_user */ | |
8682 NULL, /* get_cb_info */ | |
8683 NULL, /* get_cb_away */ | |
8684 oscar_alias_buddy, /* alias_buddy */ | |
8685 oscar_move_buddy, /* group_buddy */ | |
8686 oscar_rename_group, /* rename_group */ | |
8687 NULL, /* buddy_free */ | |
8688 oscar_convo_closed, /* convo_closed */ | |
11153 | 8689 oscar_normalize, /* normalize */ |
9475 | 8690 oscar_set_icon, /* set_buddy_icon */ |
8691 NULL, /* remove_group */ | |
8692 NULL, /* get_cb_real_name */ | |
8693 NULL, /* set_chat_topic */ | |
8694 NULL, /* find_blist_chat */ | |
8695 NULL, /* roomlist_get_list */ | |
8696 NULL, /* roomlist_cancel */ | |
8697 NULL, /* roomlist_expand_category */ | |
8698 oscar_can_receive_file, /* can_receive_file */ | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
8699 oscar_send_file, /* send_file */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
8700 oscar_new_xfer, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8701 oscar_offline_message, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8702 NULL, /* whiteboard_prpl_ops */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8703 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8704 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8705 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8706 { |
9943 | 8707 GAIM_PLUGIN_MAGIC, |
8708 GAIM_MAJOR_VERSION, | |
8709 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8710 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8711 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8712 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8713 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8714 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8715 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8716 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8717 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8718 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8719 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8720 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8721 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8722 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8723 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
8724 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8725 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8726 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8727 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8728 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8729 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8730 NULL, /**< ui_info */ |
8993 | 8731 &prpl_info, /**< extra_info */ |
13311
f6f465b8d1c0
[gaim-migrate @ 15677]
Richard Laager <rlaager@wiktel.com>
parents:
13296
diff
changeset
|
8732 NULL, |
9015 | 8733 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8734 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8735 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8736 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
8737 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8738 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
8739 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
8740 |
11338 | 8741 option = gaim_account_option_string_new(_("Auth host"), "server", OSCAR_DEFAULT_LOGIN_SERVER); |
9830 | 8742 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
8743 | |
11338 | 8744 option = gaim_account_option_int_new(_("Auth port"), "port", OSCAR_DEFAULT_LOGIN_PORT); |
9830 | 8745 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
8746 | |
8747 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
8748 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
13073 | 8749 |
13071 | 8750 option = gaim_account_option_bool_new( |
13073 | 8751 _("Use AIM/ICQ proxy server\n(slower, but usually works)"), "use_rv_proxy", |
13071 | 8752 OSCAR_DEFAULT_USE_RV_PROXY); |
8753 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
11338 | 8754 |
11369 | 8755 /* Preferences */ |
9935 | 8756 gaim_prefs_add_none("/plugins/prpl/oscar"); |
8757 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 8758 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
13311
f6f465b8d1c0
[gaim-migrate @ 15677]
Richard Laager <rlaager@wiktel.com>
parents:
13296
diff
changeset
|
8759 |
f6f465b8d1c0
[gaim-migrate @ 15677]
Richard Laager <rlaager@wiktel.com>
parents:
13296
diff
changeset
|
8760 gaim_prefs_remove("/plugins/prpl/oscar/use_rv_proxy"); |
2086 | 8761 } |
8762 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
8763 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |