Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 9914:3df9ffcb9b06
[gaim-migrate @ 10806]
Small tweak
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 30 Aug 2004 03:34:54 +0000 |
parents | e46e63a96f07 |
children | e74eb0d11f86 |
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 | |
8151 | 7 * Some code copyright (C) 2001-2004, Mark Doliner <thekingant@users.sourceforge.net> |
6302 | 8 * |
9 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 10 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 11 * |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 * | |
26 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
31 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
32 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
33 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "ft.h" |
6982 | 36 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
37 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
38 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "privacy.h" |
2086 | 40 #include "prpl.h" |
4889 | 41 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
42 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 |
2086 | 45 #include "aim.h" |
5842 | 46 #include "md5.h" |
2086 | 47 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
48 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
49 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
50 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
51 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
52 #define UC_AB 0x20 |
3079 | 53 #define UC_WIRELESS 0x40 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
54 |
2086 | 55 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
56 | |
7283 | 57 #define OSCAR_CONNECT_STEPS 6 |
9830 | 58 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 59 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
60 static GaimPlugin *my_protocol = NULL; |
4249 | 61 |
7376 | 62 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
63 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 64 |
4665 | 65 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
66 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 67 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 68 |
7283 | 69 typedef struct _OscarData OscarData; |
70 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
71 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
72 aim_conn_t *conn; |
2086 | 73 |
74 guint cnpa; | |
75 guint paspa; | |
3694 | 76 guint emlpa; |
4804 | 77 guint icopa; |
2086 | 78 |
4823 | 79 gboolean iconconnecting; |
5842 | 80 gboolean set_icon; |
4823 | 81 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
82 GSList *create_rooms; |
2086 | 83 |
84 gboolean conf; | |
85 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
86 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
87 char *email; |
2979 | 88 gboolean setnick; |
89 char *newsn; | |
2086 | 90 gboolean chpass; |
91 char *oldp; | |
92 char *newp; | |
5842 | 93 |
2086 | 94 GSList *oscar_chats; |
95 GSList *direct_ims; | |
3630 | 96 GSList *file_transfers; |
4738 | 97 GHashTable *buddyinfo; |
4804 | 98 GSList *requesticon; |
2086 | 99 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
100 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
101 gboolean icq; |
4804 | 102 guint icontimer; |
5968 | 103 guint getblisttimer; |
8341 | 104 guint getinfotimer; |
2993 | 105 |
106 struct { | |
4230 | 107 guint maxwatchers; /* max users who can watch you */ |
2993 | 108 guint maxbuddies; /* max users you can watch */ |
4230 | 109 guint maxgroups; /* max groups in server list */ |
2993 | 110 guint maxpermits; /* max users on permit list */ |
111 guint maxdenies; /* max users on deny list */ | |
112 guint maxsiglen; /* max size (bytes) of profile */ | |
113 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
114 } rights; | |
2086 | 115 }; |
116 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
117 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
118 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
119 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
120 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
121 |
2086 | 122 struct chat_connection { |
123 char *name; | |
124 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
125 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
126 fu16_t instance; |
2086 | 127 int fd; /* this is redundant since we have the conn below */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
128 aim_conn_t *conn; |
2086 | 129 int inpa; |
130 int id; | |
5575 | 131 GaimConnection *gc; /* i hate this. */ |
8733 | 132 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
133 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
134 int maxvis; |
2086 | 135 }; |
136 | |
8971 | 137 struct oscar_direct_im { |
5575 | 138 GaimConnection *gc; |
2086 | 139 char name[80]; |
140 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
141 aim_conn_t *conn; |
3008 | 142 gboolean connected; |
8978 | 143 gboolean gpc_pend; |
144 gboolean killme; | |
8984 | 145 gboolean donttryagain; |
2086 | 146 }; |
147 | |
148 struct ask_direct { | |
5575 | 149 GaimConnection *gc; |
2086 | 150 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
151 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
152 fu8_t cookie[8]; |
8984 | 153 gboolean donttryagain; |
2086 | 154 }; |
155 | |
7011 | 156 /* |
157 * Various PRPL-specific buddy info that we want to keep track of | |
158 * Some other info is maintained by locate.c, and I'd like to move | |
159 * the rest of this to libfaim, mostly im.c | |
160 */ | |
4738 | 161 struct buddyinfo { |
162 gboolean typingnot; | |
6292 | 163 gchar *availmsg; |
6857 | 164 fu32_t ipaddr; |
5836 | 165 |
166 unsigned long ico_me_len; | |
167 unsigned long ico_me_csum; | |
168 time_t ico_me_time; | |
169 gboolean ico_informed; | |
4738 | 170 |
171 unsigned long ico_len; | |
172 unsigned long ico_csum; | |
173 time_t ico_time; | |
174 gboolean ico_need; | |
7406 | 175 gboolean ico_sent; |
2086 | 176 }; |
177 | |
4230 | 178 struct name_data { |
5575 | 179 GaimConnection *gc; |
4230 | 180 gchar *name; |
3453 | 181 gchar *nick; |
3141 | 182 }; |
183 | |
5129 | 184 static char *msgerrreason[] = { |
185 N_("Invalid error"), | |
186 N_("Invalid SNAC"), | |
187 N_("Rate to host"), | |
188 N_("Rate to client"), | |
189 N_("Not logged in"), | |
190 N_("Service unavailable"), | |
191 N_("Service not defined"), | |
192 N_("Obsolete SNAC"), | |
193 N_("Not supported by host"), | |
194 N_("Not supported by client"), | |
195 N_("Refused by client"), | |
196 N_("Reply too big"), | |
197 N_("Responses lost"), | |
198 N_("Request denied"), | |
199 N_("Busted SNAC payload"), | |
200 N_("Insufficient rights"), | |
201 N_("In local permit/deny"), | |
202 N_("Too evil (sender)"), | |
203 N_("Too evil (receiver)"), | |
204 N_("User temporarily unavailable"), | |
205 N_("No match"), | |
206 N_("List overflow"), | |
207 N_("Request ambiguous"), | |
208 N_("Queue full"), | |
209 N_("Not while on AOL") | |
210 }; | |
211 static int msgerrreasonlen = 25; | |
212 | |
213 /* All the libfaim->gaim callback functions */ | |
214 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
215 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
216 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
217 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
218 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
219 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
220 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
221 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 224 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 225 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 226 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
227 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
228 static int gaim_conv_chat_join (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
229 static int gaim_conv_chat_leave (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
230 static int gaim_conv_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
231 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 232 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
233 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 235 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 236 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
237 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
238 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
240 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
241 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
242 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
243 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
244 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
245 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
246 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
247 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
248 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
263 #ifndef NOSSI | |
264 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 268 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 269 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
270 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
273 #endif | |
274 | |
275 /* for DirectIM/image transfer */ | |
276 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 279 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 280 |
281 /* for file transfer */ | |
282 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
283 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
284 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
285 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
286 | |
287 /* for icons */ | |
288 static gboolean gaim_icon_timerfunc(gpointer data); | |
289 | |
8971 | 290 /* just because */ |
291 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); | |
8983 | 292 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
8971 | 293 |
8076 | 294 /* remove these at some point? */ |
7282 | 295 /* Because I don't like forward declarations? I think that was why... */ |
5954 | 296 static void oscar_set_info(GaimConnection *gc, const char *text); |
8076 | 297 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message); |
5306 | 298 |
5836 | 299 static void oscar_free_name_data(struct name_data *data) { |
4230 | 300 g_free(data->name); |
301 g_free(data->nick); | |
302 g_free(data); | |
303 } | |
304 | |
5836 | 305 static void oscar_free_buddyinfo(void *data) { |
306 struct buddyinfo *bi = data; | |
6292 | 307 g_free(bi->availmsg); |
5836 | 308 g_free(bi); |
309 } | |
310 | |
9807 | 311 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 312 { |
313 int i = 0; | |
9826 | 314 int charset = AIM_CHARSET_ASCII; |
5129 | 315 |
316 /* Determine how we can send this message. Per the warnings elsewhere | |
317 * in this file, these little checks determine the simplest encoding | |
318 * we can use for a given message send using it. */ | |
319 while (utf8[i]) { | |
320 if ((unsigned char)utf8[i] > 0x7f) { | |
321 /* not ASCII! */ | |
9826 | 322 charset = AIM_CHARSET_CUSTOM; |
5129 | 323 break; |
324 } | |
325 i++; | |
326 } | |
327 while (utf8[i]) { | |
328 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
329 * followed by 0xc0-0xc3 in the second */ | |
330 if ((unsigned char)utf8[i] < 0x80) { | |
331 i++; | |
332 continue; | |
333 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
334 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
335 i += 2; | |
336 continue; | |
337 } | |
9826 | 338 charset = AIM_CHARSET_UNICODE; |
5129 | 339 break; |
340 } | |
341 | |
9807 | 342 return charset; |
5129 | 343 } |
344 | |
8225 | 345 /* |
346 * Take a string of the form charset="bleh" where bleh is | |
347 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
348 * return a newly allocated string containing bleh. | |
349 */ | |
350 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 351 { |
8225 | 352 gchar *ret = NULL; |
353 char *begin, *end; | |
354 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
355 /* Make sure encoding begins with charset= */ |
8225 | 356 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
357 return NULL; | |
358 | |
359 begin = strchr(encoding, '"'); | |
360 end = strrchr(encoding, '"'); | |
361 | |
362 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
363 return NULL; | |
364 | |
365 ret = g_strndup(begin+1, (end-1) - begin); | |
366 | |
367 return ret; | |
368 } | |
369 | |
9830 | 370 static gchar * |
371 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 372 { |
373 gchar *utf8 = NULL; | |
9595 | 374 |
375 if ((encoding == NULL) || encoding[0] == '\0') { | |
376 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
377 | |
9639 | 378 } else if (!strcmp(encoding, "iso-8859-1") |
379 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 380 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
381 | |
382 } else if (!strcmp(encoding, "unicode-2-0")) { | |
383 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
384 | |
385 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
386 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
387 "attempting to convert to UTF-8 anyway\n"); | |
388 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
389 } | |
390 | |
391 /* | |
392 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
393 * we have been unable to convert the text to utf-8 from the encoding | |
394 * that was specified. So we check if the text is valid utf-8 then | |
395 * just copy it. | |
396 */ | |
397 if (utf8 == NULL) { | |
9638 | 398 if (textlen != 0 && *text != '\0' |
399 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 400 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 401 else |
9481 | 402 utf8 = g_strndup(text, textlen); |
5129 | 403 } |
404 | |
405 return utf8; | |
406 } | |
407 | |
9830 | 408 static gchar * |
9908 | 409 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 410 { |
411 gchar *ret = NULL; | |
412 GError *err = NULL; | |
413 | |
9908 | 414 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
415 return NULL; | |
416 | |
417 if (strcasecmp("UTF-8", charsetstr)) { | |
418 if (fallback) | |
419 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
420 else | |
421 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
422 if (err != NULL) { | |
423 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
424 charsetstr, err->message); | |
425 g_error_free(err); | |
426 } | |
427 } else { | |
428 if (g_utf8_validate(data, datalen, NULL)) | |
429 ret = g_strndup(data, datalen); | |
430 else | |
431 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
432 } | |
433 | |
434 return ret; | |
435 } | |
436 | |
437 /* | |
438 * We try decoding using two different character sets. The charset | |
439 * specified in the IM determines the order in which we attempt to | |
440 * decode. We do this because there are lots of broken ICQ clients | |
441 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
442 * able to deal with that crap, then people complain like banshees. | |
443 * charsetstr1 is always set to what the correct encoding should be. | |
444 */ | |
445 static gchar * | |
446 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
447 { | |
448 gchar *ret = NULL; | |
449 const gchar *charsetstr1, *charsetstr2; | |
450 | |
451 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 452 |
453 if ((datalen == 0) || (data == NULL)) | |
454 return NULL; | |
455 | |
9908 | 456 if (charset == AIM_CHARSET_UNICODE) { |
457 charsetstr1 = "UCS-2BE"; | |
458 charsetstr2 = "UTF-8"; | |
459 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9830 | 460 if ((sourcesn != NULL) && isdigit(sourcesn[0])) |
9908 | 461 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 462 else |
9908 | 463 charsetstr1 = "ISO-8859-1"; |
464 charsetstr2 = "UTF-8"; | |
465 } else if (charset == AIM_CHARSET_ASCII) { | |
466 /* Should just be "ASCII" */ | |
9914 | 467 charsetstr1 = "ASCII"; |
9908 | 468 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
469 } else if (charset == 0x000d) { | |
9830 | 470 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 471 charsetstr1 = "ISO-8859-1"; |
472 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
473 } else { | |
9830 | 474 /* Unknown, hope for valid UTF-8... */ |
9908 | 475 charsetstr1 = "UTF-8"; |
476 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
477 } | |
478 | |
479 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
480 if (ret == NULL) | |
481 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
482 if (ret == NULL) | |
483 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 484 |
485 return ret; | |
486 } | |
487 | |
488 static void | |
489 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
490 gchar **msg, int *msglen, | |
491 fu16_t *charset, fu16_t *charsubset) | |
492 { | |
493 OscarData *od = gc->proto_data; | |
494 GaimAccount *account = gaim_connection_get_account(gc); | |
495 GError *err = NULL; | |
496 aim_userinfo_t *userinfo = NULL; | |
497 const gchar *charsetstr; | |
498 | |
499 /* Attempt to send as ASCII */ | |
500 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, msglen, NULL); | |
501 if (*msg != NULL) { | |
502 *charset = AIM_CHARSET_ASCII; | |
503 *charsubset = 0x0000; | |
504 return; | |
505 } | |
506 | |
507 /* | |
9908 | 508 * If we're sending to an ICQ user, and they are advertising the |
509 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 510 */ |
511 if ((destsn != NULL) && isdigit(destsn[0])) | |
512 userinfo = aim_locate_finduserinfo(od->sess, destsn); | |
513 | |
514 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
9908 | 515 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, NULL); |
9830 | 516 if (*msg != NULL) { |
517 *charset = AIM_CHARSET_UNICODE; | |
518 *charsubset = 0x0000; | |
519 return; | |
520 } | |
521 } | |
522 | |
523 /* | |
524 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
525 * ICQ then attempt to send as the user specified character encoding. | |
526 */ | |
527 charsetstr = "ISO-8859-1"; | |
528 if ((destsn != NULL) && isdigit(destsn[0])) | |
529 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
530 | |
531 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, msglen, NULL); | |
532 if (*msg != NULL) { | |
533 *charset = AIM_CHARSET_CUSTOM; | |
534 *charsubset = 0x0000; | |
535 return; | |
536 } | |
537 | |
538 /* | |
539 * Nothing else worked, so send as UCS-2BE. | |
540 */ | |
541 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, &err); | |
542 if (*msg != NULL) { | |
543 *charset = AIM_CHARSET_UNICODE; | |
544 *charsubset = 0x0000; | |
545 return; | |
546 } | |
547 | |
9908 | 548 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 549 g_error_free(err); |
550 | |
551 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
552 *msg = g_strdup(from); | |
553 *msglen = strlen(*msg); | |
554 *charset = AIM_CHARSET_ASCII; | |
555 *charsubset = 0x0000; | |
556 return; | |
557 } | |
558 | |
9407 | 559 gchar *oscar_caps_to_string(guint caps) |
8701 | 560 { |
9407 | 561 GString *str; |
562 gchar *tmp; | |
8701 | 563 guint bit = 1; |
564 | |
9407 | 565 str = g_string_new(""); |
566 | |
8701 | 567 if (!caps) { |
568 return NULL; | |
569 } else while (bit <= AIM_CAPS_LAST) { | |
570 if (bit & caps) { | |
571 switch (bit) { | |
572 case AIM_CAPS_BUDDYICON: | |
573 tmp = _("Buddy Icon"); | |
574 break; | |
575 case AIM_CAPS_TALK: | |
576 tmp = _("Voice"); | |
577 break; | |
578 case AIM_CAPS_DIRECTIM: | |
579 tmp = _("AIM Direct IM"); | |
580 break; | |
581 case AIM_CAPS_CHAT: | |
582 tmp = _("Chat"); | |
583 break; | |
584 case AIM_CAPS_GETFILE: | |
585 tmp = _("Get File"); | |
586 break; | |
587 case AIM_CAPS_SENDFILE: | |
588 tmp = _("Send File"); | |
589 break; | |
590 case AIM_CAPS_GAMES: | |
591 case AIM_CAPS_GAMES2: | |
592 tmp = _("Games"); | |
593 break; | |
594 case AIM_CAPS_ADDINS: | |
595 tmp = _("Add-Ins"); | |
596 break; | |
597 case AIM_CAPS_SENDBUDDYLIST: | |
598 tmp = _("Send Buddy List"); | |
599 break; | |
600 case AIM_CAPS_ICQ_DIRECT: | |
601 tmp = _("ICQ Direct Connect"); | |
602 break; | |
603 case AIM_CAPS_APINFO: | |
604 tmp = _("AP User"); | |
605 break; | |
606 case AIM_CAPS_ICQRTF: | |
607 tmp = _("ICQ RTF"); | |
608 break; | |
609 case AIM_CAPS_EMPTY: | |
610 tmp = _("Nihilist"); | |
611 break; | |
612 case AIM_CAPS_ICQSERVERRELAY: | |
613 tmp = _("ICQ Server Relay"); | |
614 break; | |
615 case AIM_CAPS_ICQUTF8OLD: | |
616 tmp = _("Old ICQ UTF8"); | |
617 break; | |
618 case AIM_CAPS_TRILLIANCRYPT: | |
619 tmp = _("Trillian Encryption"); | |
620 break; | |
621 case AIM_CAPS_ICQUTF8: | |
622 tmp = _("ICQ UTF8"); | |
623 break; | |
624 case AIM_CAPS_HIPTOP: | |
625 tmp = _("Hiptop"); | |
626 break; | |
627 case AIM_CAPS_SECUREIM: | |
628 tmp = _("Security Enabled"); | |
629 break; | |
630 case AIM_CAPS_VIDEO: | |
631 tmp = _("Video Chat"); | |
632 break; | |
633 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
634 case AIM_CAPS_ICHATAV: | |
635 tmp = _("iChat AV"); | |
636 break; | |
637 case AIM_CAPS_LIVEVIDEO: | |
638 tmp = _("Live Video"); | |
639 break; | |
640 case AIM_CAPS_CAMERA: | |
641 tmp = _("Camera"); | |
642 break; | |
643 default: | |
644 tmp = NULL; | |
645 break; | |
646 } | |
647 if (tmp) | |
9532 | 648 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 649 } |
650 bit <<= 1; | |
651 } | |
9407 | 652 |
653 return g_string_free(str, FALSE); | |
8701 | 654 } |
655 | |
656 static char *oscar_icqstatus(int state) { | |
657 /* Make a cute little string that shows the status of the dude or dudet */ | |
658 if (state & AIM_ICQ_STATE_CHAT) | |
659 return g_strdup_printf(_("Free For Chat")); | |
660 else if (state & AIM_ICQ_STATE_DND) | |
661 return g_strdup_printf(_("Do Not Disturb")); | |
662 else if (state & AIM_ICQ_STATE_OUT) | |
663 return g_strdup_printf(_("Not Available")); | |
664 else if (state & AIM_ICQ_STATE_BUSY) | |
665 return g_strdup_printf(_("Occupied")); | |
666 else if (state & AIM_ICQ_STATE_AWAY) | |
667 return g_strdup_printf(_("Away")); | |
668 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
669 return g_strdup_printf(_("Web Aware")); | |
670 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
671 return g_strdup_printf(_("Invisible")); | |
672 else | |
673 return g_strdup_printf(_("Online")); | |
674 } | |
675 | |
676 static void oscar_string_append(GString *str, char *newline, char *name, char *value) | |
8700 | 677 { |
678 gchar *utf8; | |
679 | |
680 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 681 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 682 g_free(utf8); |
683 } | |
684 } | |
685 | |
8701 | 686 static void oscar_string_append_info(GaimConnection *gc, GString *str, char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
687 { | |
688 OscarData *od = gc->proto_data; | |
689 GaimAccount *account = gaim_connection_get_account(gc); | |
690 GaimGroup *g = NULL; | |
691 struct buddyinfo *bi = NULL; | |
692 char *tmp; | |
693 | |
694 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
695 return; | |
696 | |
697 if (userinfo == NULL) | |
698 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
699 | |
700 if (b == NULL) | |
701 b = gaim_find_buddy(gc->account, userinfo->sn); | |
702 | |
703 if (b != NULL) | |
704 g = gaim_find_buddys_group(b); | |
705 | |
706 if (userinfo != NULL) | |
707 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
708 | |
8733 | 709 if (b != NULL) { |
710 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
711 if (isdigit(b->name[0])) { | |
712 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
713 oscar_string_append(str, newline, _("Status"), tmp); | |
714 g_free(tmp); | |
715 } | |
716 } else { | |
9625 | 717 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 718 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
719 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
720 else | |
721 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 722 } |
8733 | 723 } |
8701 | 724 |
725 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 726 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 727 (bi->ipaddr & 0xff000000) >> 24, |
728 (bi->ipaddr & 0x00ff0000) >> 16, | |
729 (bi->ipaddr & 0x0000ff00) >> 8, | |
730 (bi->ipaddr & 0x000000ff)); | |
731 oscar_string_append(str, newline, _("IP Address"), tmp); | |
732 g_free(tmp); | |
733 } | |
734 | |
735 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
736 tmp = oscar_caps_to_string(userinfo->capabilities); | |
737 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 738 g_free(tmp); |
8701 | 739 } |
740 | |
741 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
742 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
743 if (tmp != NULL) { | |
9625 | 744 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 745 g_free(tmp); |
9625 | 746 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
747 g_free(tmp2); | |
8701 | 748 } |
749 } | |
750 | |
751 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
752 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
753 oscar_string_append(str, newline, _("Available"), tmp); | |
754 g_free(tmp); | |
755 } | |
756 } | |
757 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
758 static char *extract_name(const char *name) { |
4121 | 759 char *tmp, *x; |
2086 | 760 int i, j; |
4120 | 761 |
762 if (!name) | |
4121 | 763 return NULL; |
764 | |
4120 | 765 x = strchr(name, '-'); |
4121 | 766 |
2086 | 767 if (!x) return NULL; |
768 x = strchr(++x, '-'); | |
769 if (!x) return NULL; | |
770 tmp = g_strdup(++x); | |
771 | |
772 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
773 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
774 if (x[i] != '%') { |
2086 | 775 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
776 continue; |
2086 | 777 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
778 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
779 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
780 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 781 } |
782 | |
783 tmp[j] = 0; | |
784 return tmp; | |
785 } | |
786 | |
5575 | 787 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 788 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 789 struct chat_connection *c = NULL; |
790 | |
791 while (g) { | |
792 c = (struct chat_connection *)g->data; | |
793 if (c->id == id) | |
794 break; | |
795 g = g->next; | |
796 c = NULL; | |
797 } | |
798 | |
799 return c; | |
800 } | |
801 | |
5575 | 802 static struct chat_connection *find_oscar_chat_by_conn(GaimConnection *gc, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
803 aim_conn_t *conn) { |
7283 | 804 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 805 struct chat_connection *c = NULL; |
806 | |
807 while (g) { | |
808 c = (struct chat_connection *)g->data; | |
809 if (c->conn == conn) | |
810 break; | |
811 g = g->next; | |
812 c = NULL; | |
813 } | |
814 | |
815 return c; | |
816 } | |
817 | |
8219 | 818 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
819 GaimConversation *conv) { | |
820 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
821 struct chat_connection *c = NULL; | |
822 | |
823 while (g) { | |
824 c = (struct chat_connection *)g->data; | |
8733 | 825 if (c->conv == conv) |
8219 | 826 break; |
827 g = g->next; | |
828 c = NULL; | |
829 } | |
830 | |
831 return c; | |
832 } | |
833 | |
8971 | 834 /***************************************************************************** |
835 * Begin scary direct im stuff | |
836 *****************************************************************************/ | |
837 | |
838 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
839 GSList *d = od->direct_ims; | |
840 struct oscar_direct_im *m = NULL; | |
841 | |
842 while (d) { | |
843 m = (struct oscar_direct_im *)d->data; | |
844 if (!aim_sncmp(who, m->name)) | |
845 return m; | |
846 d = d->next; | |
847 } | |
848 | |
849 return NULL; | |
850 } | |
851 | |
852 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
853 { | |
854 gaim_debug_info("oscar", | |
855 "destroying Direct IM for %s.\n", dim->name); | |
856 | |
857 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 858 if (dim->gpc_pend) { |
859 dim->killme = TRUE; | |
860 return; | |
861 } | |
8971 | 862 if (dim->watcher) |
863 gaim_input_remove(dim->watcher); | |
864 if (dim->conn) { | |
865 aim_conn_close(dim->conn); | |
866 aim_conn_kill(od->sess, &dim->conn); | |
867 } | |
868 g_free(dim); | |
869 } | |
870 | |
871 /* the only difference between this and destroy is this writes a conv message */ | |
872 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
873 { | |
874 GaimConversation *conv; | |
875 char buf[256]; | |
876 | |
877 gaim_debug_info("oscar", | |
878 "%s disconnected Direct IM.\n", dim->name); | |
879 | |
880 if (dim->connected) | |
881 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 882 else |
8971 | 883 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
884 | |
885 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
886 if (conv) { | |
887 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 888 gaim_conversation_update_progress(conv, 0); |
8971 | 889 } else { |
890 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
891 } | |
892 | |
893 oscar_direct_im_destroy(od, dim); | |
894 | |
895 return; | |
896 } | |
897 | |
898 /* oops i made two of these. this one just calls the other one. */ | |
899 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
900 { | |
901 GaimConnection *gc = sess->aux_data; | |
902 OscarData *od = (OscarData *)gc->proto_data; | |
903 struct oscar_direct_im *dim; | |
904 char *sn; | |
905 | |
906 sn = g_strdup(aim_odc_getsn(conn)); | |
907 dim = oscar_direct_im_find(od, sn); | |
908 oscar_direct_im_disconnect(od, dim); | |
909 g_free(sn); | |
910 } | |
911 | |
912 static void destroy_direct_im_request(struct ask_direct *d) { | |
913 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
914 | |
915 g_free(d->sn); | |
916 g_free(d); | |
917 } | |
918 | |
919 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
920 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
921 struct oscar_direct_im *dim = data; | |
922 GaimConnection *gc = dim->gc; | |
923 OscarData *od = gc->proto_data; | |
924 GaimConversation *conv; | |
925 char buf[256]; | |
926 struct sockaddr name; | |
927 socklen_t name_len = 1; | |
928 | |
929 g_return_if_fail(gc != NULL); | |
930 | |
8978 | 931 dim->gpc_pend = FALSE; |
932 if (dim->killme) { | |
933 oscar_direct_im_destroy(od, dim); | |
934 return; | |
935 } | |
936 | |
8971 | 937 if (!g_list_find(gaim_connections_get_all(), gc)) { |
938 oscar_direct_im_destroy(od, dim); | |
939 return; | |
940 } | |
941 | |
942 if (source < 0) { | |
8984 | 943 if (dim->donttryagain) { |
944 oscar_direct_im_disconnect(od, dim); | |
945 return; | |
946 } else { | |
947 fu8_t cookie[8]; | |
948 char *who = g_strdup(dim->name); | |
949 const char *tmp = aim_odc_getcookie(dim->conn); | |
950 | |
951 memcpy(cookie, tmp, 8); | |
952 oscar_direct_im_destroy(od, dim); | |
953 oscar_direct_im_initiate(gc, who, cookie); | |
954 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
955 g_free(who); | |
956 return; | |
957 } | |
8971 | 958 } |
959 | |
960 dim->conn->fd = source; | |
961 aim_conn_completeconnect(od->sess, dim->conn); | |
962 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
963 | |
964 /* This is the best way to see if we're connected or not */ | |
8983 | 965 /* Is this really needed? */ |
8971 | 966 if (getpeername(source, &name, &name_len) == 0) { |
967 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
968 dim->connected = TRUE; | |
969 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 970 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
971 } else { | |
8984 | 972 if (dim->donttryagain) { |
973 oscar_direct_im_disconnect(od, dim); | |
974 return; | |
975 } else { | |
976 fu8_t cookie[8]; | |
977 char *who = g_strdup(dim->name); | |
978 const char *tmp = aim_odc_getcookie(dim->conn); | |
979 | |
980 memcpy(cookie, tmp, 8); | |
981 oscar_direct_im_destroy(od, dim); | |
982 oscar_direct_im_initiate(gc, who, cookie); | |
983 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
984 g_free(who); | |
985 return; | |
986 } | |
8983 | 987 } |
988 | |
989 | |
8971 | 990 } |
991 | |
992 static void accept_direct_im_request(struct ask_direct *d) { | |
993 GaimConnection *gc = d->gc; | |
994 OscarData *od; | |
995 struct oscar_direct_im *dim; | |
996 char *host; int port = 5190; | |
997 int i, rc; | |
8982 | 998 char *tmp; |
999 GaimConversation *conv; | |
8971 | 1000 |
1001 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1002 destroy_direct_im_request(d); | |
1003 return; | |
1004 } | |
1005 | |
1006 od = (OscarData *)gc->proto_data; | |
1007 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1008 | |
1009 dim = oscar_direct_im_find(od, d->sn); | |
1010 if (dim && dim->connected) { | |
1011 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1012 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1013 return; | |
1014 } | |
1015 dim = g_new0(struct oscar_direct_im, 1); | |
1016 dim->gc = d->gc; | |
8984 | 1017 dim->donttryagain = d->donttryagain; |
8971 | 1018 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1019 | |
1020 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1021 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1022 if (!dim->conn) { | |
1023 oscar_direct_im_disconnect(od, dim); | |
1024 destroy_direct_im_request(d); | |
1025 return; | |
1026 } | |
1027 | |
1028 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1029 gaim_odc_incoming, 0); | |
1030 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1031 gaim_odc_typing, 0); | |
1032 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1033 gaim_odc_update_ui, 0); | |
1034 | |
1035 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1036 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1037 if (d->ip[i] == ':') { | |
1038 port = atoi(&(d->ip[i+1])); | |
1039 break; | |
1040 } | |
1041 } | |
1042 host = g_strndup(d->ip, i); | |
1043 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1044 dim->gpc_pend = TRUE; |
8971 | 1045 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1046 |
1047 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1048 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1049 port); | |
1050 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1051 g_free(tmp); | |
8983 | 1052 |
8971 | 1053 g_free(host); |
1054 if (rc < 0) { | |
8978 | 1055 dim->gpc_pend = FALSE; |
8971 | 1056 oscar_direct_im_disconnect(od, dim); |
1057 destroy_direct_im_request(d); | |
1058 return; | |
1059 } | |
1060 | |
1061 destroy_direct_im_request(d); | |
1062 | |
1063 return; | |
1064 } | |
1065 | |
1066 /* | |
1067 * We have just established a socket with the other dude, so set up some handlers. | |
1068 */ | |
1069 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1070 GaimConnection *gc = sess->aux_data; |
7283 | 1071 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1072 GaimConversation *conv; |
8971 | 1073 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1074 char buf[256]; |
8971 | 1075 char *sn; |
1076 va_list ap; | |
1077 aim_conn_t *newconn, *listenerconn; | |
1078 | |
1079 va_start(ap, fr); | |
1080 newconn = va_arg(ap, aim_conn_t *); | |
1081 listenerconn = va_arg(ap, aim_conn_t *); | |
1082 va_end(ap); | |
1083 | |
1084 aim_conn_close(listenerconn); | |
1085 aim_conn_kill(sess, &listenerconn); | |
1086 | |
1087 sn = g_strdup(aim_odc_getsn(newconn)); | |
1088 | |
1089 gaim_debug_info("oscar", | |
1090 "DirectIM: initiate success to %s\n", sn); | |
1091 dim = oscar_direct_im_find(od, sn); | |
1092 | |
1093 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1094 gaim_input_remove(dim->watcher); | |
1095 dim->conn = newconn; | |
1096 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1097 dim->connected = TRUE; | |
1098 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1099 g_free(sn); | |
1100 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1101 | |
1102 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1103 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1104 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1105 | |
1106 return 1; | |
1107 } | |
1108 | |
1109 /* | |
1110 * This is called when each chunk of an image is received. It can be used to | |
1111 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1112 * nasty, you sicko. | |
1113 */ | |
1114 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1115 va_list ap; | |
1116 char *sn; | |
1117 double percent; | |
1118 GaimConnection *gc = sess->aux_data; | |
1119 OscarData *od = (OscarData *)gc->proto_data; | |
1120 GaimConversation *c; | |
1121 struct oscar_direct_im *dim; | |
1122 | |
1123 va_start(ap, fr); | |
1124 sn = va_arg(ap, char *); | |
1125 percent = va_arg(ap, double); | |
1126 va_end(ap); | |
1127 | |
1128 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1129 return 1; | |
1130 if (dim->watcher) { | |
1131 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1132 /* The callback will callback? I don't get how that would happen here. */ | |
1133 dim->watcher = 0; | |
1134 } | |
1135 | |
1136 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
1137 if (c != NULL) | |
1138 gaim_conversation_update_progress(c, percent); | |
1139 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1140 oscar_callback, dim->conn); | |
1141 | |
1142 return 1; | |
1143 } | |
1144 | |
1145 /* | |
1146 * This is called after a direct IM has been received in its entirety. This | |
1147 * function is passed a long chunk of data which contains the IM with any | |
1148 * data chunks (images) appended to it. | |
1149 * | |
1150 * This function rips out all the data chunks and creates an imgstore for | |
1151 * each one. In order to do this, it first goes through the IM and takes | |
1152 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1153 * with one compatible with the imgstore Gaim core code. For each one, we | |
1154 * then read in chunks of data from the end of the message and actually | |
1155 * create the img store using the given data. | |
1156 * | |
1157 * For somewhat easy reference, here's a sample message | |
1158 * (without the whitespace and asterisks): | |
1159 * | |
1160 * <HTML><BODY BGCOLOR="#ffffff"> | |
1161 * <FONT LANG="0"> | |
1162 * This is a really stupid picture:<BR> | |
1163 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1164 * Yeah it is<BR> | |
1165 * Here is another one:<BR> | |
1166 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1167 * </FONT> | |
1168 * </BODY></HTML> | |
1169 * <BINARY> | |
1170 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1171 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1172 * </BINARY> | |
1173 */ | |
1174 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1175 GaimConnection *gc = sess->aux_data; | |
1176 GaimConvImFlags imflags = 0; | |
1177 gchar *utf8; | |
1178 GString *newmsg = g_string_new(""); | |
1179 GSList *images = NULL; | |
1180 va_list ap; | |
1181 const char *sn, *msg, *msgend, *binary; | |
1182 size_t len; | |
1183 int encoding, isawaymsg; | |
1184 | |
1185 va_start(ap, fr); | |
1186 sn = va_arg(ap, const char *); | |
1187 msg = va_arg(ap, const char *); | |
1188 len = va_arg(ap, size_t); | |
1189 encoding = va_arg(ap, int); | |
1190 isawaymsg = va_arg(ap, int); | |
1191 va_end(ap); | |
1192 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1193 |
8660 | 1194 gaim_debug_info("oscar", |
8971 | 1195 "Got DirectIM message from %s\n", sn); |
1196 | |
1197 if (isawaymsg) | |
1198 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1199 | |
1200 /* message has a binary trailer */ | |
1201 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1202 GData *attribs; | |
1203 const char *tmp, *start, *end, *last = NULL; | |
1204 | |
1205 tmp = msg; | |
1206 | |
1207 /* for each valid image tag... */ | |
1208 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1209 const char *id, *src, *datasize; | |
1210 const char *tag = NULL, *data = NULL; | |
1211 size_t size; | |
1212 int imgid = 0; | |
1213 | |
1214 /* update the location of the last img tag */ | |
1215 last = end; | |
1216 | |
1217 /* grab attributes */ | |
1218 id = g_datalist_get_data(&attribs, "id"); | |
1219 src = g_datalist_get_data(&attribs, "src"); | |
1220 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1221 | |
1222 /* if we have id & datasize, build the data tag */ | |
1223 if (id && datasize) | |
1224 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1225 | |
1226 /* if we have a tag, find the start of the data */ | |
1227 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1228 data += strlen(tag); | |
1229 | |
1230 /* check the data is here and store it */ | |
1231 if (data + (size = atoi(datasize)) <= msgend) | |
1232 imgid = gaim_imgstore_add(data, size, src); | |
1233 | |
1234 /* | |
1235 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1236 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1237 */ | |
1238 /* if we have a stored image... */ | |
1239 if (imgid) { | |
1240 /* append the message up to the tag */ | |
1241 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1242 if (utf8 != NULL) { | |
1243 newmsg = g_string_append(newmsg, utf8); | |
1244 g_free(utf8); | |
1245 } | |
1246 | |
1247 /* write the new image tag */ | |
1248 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1249 | |
1250 /* and record the image number */ | |
1251 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1252 } else { | |
1253 /* otherwise, copy up to the end of the tag */ | |
1254 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1255 if (utf8 != NULL) { | |
1256 newmsg = g_string_append(newmsg, utf8); | |
1257 g_free(utf8); | |
1258 } | |
1259 } | |
1260 | |
1261 /* clear the attribute list */ | |
1262 g_datalist_clear(&attribs); | |
1263 | |
1264 /* continue from the end of the tag */ | |
1265 tmp = end + 1; | |
1266 } | |
1267 | |
1268 /* append any remaining message data (without the > :-) */ | |
1269 if (last++ && (last < binary)) | |
1270 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1271 | |
1272 /* set the flag if we caught any images */ | |
1273 if (images) | |
1274 imflags |= GAIM_CONV_IM_IMAGES; | |
1275 } else { | |
1276 g_string_append_len(newmsg, msg, len); | |
1277 } | |
1278 | |
1279 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1280 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1281 | |
1282 /* free up the message */ | |
1283 g_string_free(newmsg, TRUE); | |
1284 | |
1285 /* unref any images we allocated */ | |
1286 if (images) { | |
1287 GSList *tmp; | |
1288 int id; | |
1289 | |
1290 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1291 id = GPOINTER_TO_INT(tmp->data); | |
1292 gaim_imgstore_unref(id); | |
1293 } | |
1294 | |
1295 g_slist_free(images); | |
1296 } | |
1297 | |
1298 return 1; | |
1299 } | |
1300 | |
1301 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1302 va_list ap; | |
1303 char *sn; | |
1304 int typing; | |
1305 GaimConnection *gc = sess->aux_data; | |
1306 | |
1307 va_start(ap, fr); | |
1308 sn = va_arg(ap, char *); | |
1309 typing = va_arg(ap, int); | |
1310 va_end(ap); | |
1311 | |
1312 if (typing == 0x0002) { | |
1313 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1314 gaim_debug_info("oscar", | |
1315 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1316 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1317 } else if (typing == 0x0001) | |
1318 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1319 else | |
1320 serv_got_typing_stopped(gc, sn); | |
1321 return 1; | |
1322 } | |
1323 | |
1324 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1325 char *buf; | |
1326 size_t len; | |
1327 int ret; | |
1328 GString *msg = g_string_new("<HTML><BODY>"); | |
1329 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1330 GData *attribs; | |
1331 const char *start, *end, *last; | |
1332 int oscar_id = 0; | |
1333 | |
1334 last = message; | |
1335 | |
1336 /* for each valid IMG tag... */ | |
1337 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1338 GaimStoredImage *image = NULL; | |
1339 const char *id; | |
1340 | |
1341 if (start - last) { | |
1342 g_string_append_len(msg, last, start - last); | |
1343 } | |
1344 | |
1345 id = g_datalist_get_data(&attribs, "id"); | |
1346 | |
1347 /* ... if it refers to a valid gaim image ... */ | |
1348 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1349 /* ... append the message from start to the tag ... */ | |
9126 | 1350 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1351 const char *filename = gaim_imgstore_get_filename(image); |
1352 gpointer imgdata = gaim_imgstore_get_data(image); | |
1353 | |
1354 oscar_id++; | |
1355 | |
1356 /* ... insert a new img tag with the oscar id ... */ | |
1357 if (filename) | |
1358 g_string_append_printf(msg, | |
9126 | 1359 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1360 filename, oscar_id, size); |
1361 else | |
1362 g_string_append_printf(msg, | |
9126 | 1363 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1364 oscar_id, size); |
1365 | |
1366 /* ... and append the data to the binary section ... */ | |
9126 | 1367 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1368 oscar_id, size); |
1369 data = g_string_append_len(data, imgdata, size); | |
1370 data = g_string_append(data, "</DATA>"); | |
1371 } | |
1372 /* If the tag is invalid, skip it, thus no else here */ | |
1373 | |
1374 g_datalist_clear(&attribs); | |
1375 | |
1376 /* continue from the end of the tag */ | |
1377 last = end + 1; | |
1378 } | |
1379 | |
1380 /* append any remaining message data (without the > :-) */ | |
1381 if (last && *last) | |
1382 msg = g_string_append(msg, last); | |
1383 | |
1384 /* if we inserted any images in the binary section, append it */ | |
1385 if (oscar_id) { | |
1386 msg = g_string_append_len(msg, data->str, data->len); | |
1387 msg = g_string_append(msg, "</BINARY>"); | |
1388 } | |
1389 | |
1390 len = msg->len; | |
1391 buf = msg->str; | |
1392 g_string_free(msg, FALSE); | |
1393 g_string_free(data, TRUE); | |
1394 | |
1395 | |
1396 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1397 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1398 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1399 else | |
1400 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1401 | |
1402 g_free(buf); | |
1403 | |
1404 return ret; | |
1405 } | |
1406 | |
1407 struct ask_do_dir_im { | |
1408 char *who; | |
1409 GaimConnection *gc; | |
1410 }; | |
1411 | |
1412 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1413 g_free(data->who); | |
1414 g_free(data); | |
1415 } | |
1416 | |
8983 | 1417 /* this function is used to initiate a direct im session with someone. |
1418 * we start listening on a port and send a request. they either connect | |
1419 * or send some kind of reply. If they can't connect, they ask us to | |
1420 * connect to them, and so we do that. | |
1421 * | |
1422 * this function will also get called if the other side initiate's a direct | |
1423 * im and we try to connect and fail. in that case cookie will not be null. | |
1424 * | |
1425 * note that cookie is an 8 byte string that isn't NULL terminated | |
1426 */ | |
1427 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1428 OscarData *od; |
1429 struct oscar_direct_im *dim; | |
1430 int listenfd; | |
8982 | 1431 const char *ip; |
8971 | 1432 |
1433 od = (OscarData *)gc->proto_data; | |
1434 | |
8983 | 1435 dim = oscar_direct_im_find(od, who); |
8971 | 1436 if (dim) { |
1437 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1438 oscar_direct_im_disconnect(od, dim); | |
1439 gaim_debug_info("oscar", | |
1440 "Gave up on old direct IM, trying again\n"); | |
1441 } else { | |
1442 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1443 return; |
8971 | 1444 } |
1445 } | |
1446 dim = g_new0(struct oscar_direct_im, 1); | |
1447 dim->gc = gc; | |
8983 | 1448 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1449 |
1450 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1451 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1452 if (listenfd >= 0) |
1453 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1454 if (dim->conn != NULL) { |
8982 | 1455 char *tmp; |
1456 GaimConversation *conv; | |
1457 | |
8971 | 1458 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1459 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1460 oscar_callback, dim->conn); | |
1461 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1462 gaim_odc_initiate, 0); | |
8982 | 1463 |
8983 | 1464 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1465 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1466 gaim_network_get_port_from_fd(listenfd)); |
1467 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1468 g_free(tmp); | |
8971 | 1469 } else { |
1470 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1471 oscar_direct_im_destroy(od, dim); | |
1472 } | |
8983 | 1473 } |
1474 | |
1475 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1476 GaimConnection *gc = data->gc; | |
1477 | |
1478 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1479 g_free(data->who); | |
1480 g_free(data); | |
1481 return; | |
1482 } | |
1483 | |
1484 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1485 g_free(data->who); |
1486 g_free(data); | |
1487 } | |
1488 | |
1489 /* this is the right click menu cb thingy */ | |
9030 | 1490 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1491 | |
1492 GaimBuddy *buddy; | |
1493 GaimConnection *gc; | |
8971 | 1494 gchar *buf; |
9030 | 1495 struct ask_do_dir_im *data; |
1496 | |
1497 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1498 | |
1499 buddy = (GaimBuddy *) node; | |
1500 gc = gaim_account_get_connection(buddy->account); | |
1501 | |
1502 data = g_new0(struct ask_do_dir_im, 1); | |
1503 data->who = g_strdup(buddy->name); | |
8971 | 1504 data->gc = gc; |
9030 | 1505 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1506 buddy->name); | |
8971 | 1507 |
1508 gaim_request_action(gc, NULL, buf, | |
9030 | 1509 _("Because this reveals your IP address, it " |
1510 "may be considered a privacy risk. Do you " | |
1511 "wish to continue?"), | |
1512 0, data, 2, | |
1513 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1514 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1515 g_free(buf); |
1516 } | |
1517 | |
1518 /***************************************************************************** | |
1519 * End scary direct im stuff | |
1520 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1521 |
4617 | 1522 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1523 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1524 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1525 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1526 OscarData *od; |
2086 | 1527 |
1528 if (!gc) { | |
8660 | 1529 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1530 "oscar callback for closed connection (1).\n"); |
2086 | 1531 return; |
1532 } | |
1533 | |
7283 | 1534 od = (OscarData *)gc->proto_data; |
2086 | 1535 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1536 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1537 /* oh boy. this is probably bad. i guess the only thing we |
1538 * can really do is return? */ | |
8660 | 1539 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1540 "oscar callback for closed connection (2).\n"); |
8660 | 1541 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1542 return; |
1543 } | |
1544 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1545 if (condition & GAIM_INPUT_READ) { |
4617 | 1546 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1547 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1548 "got information on rendezvous listener\n"); |
4617 | 1549 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1550 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1551 "connection error (rendezvous listener)\n"); |
4617 | 1552 aim_conn_kill(od->sess, &conn); |
8446 | 1553 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1554 } |
1555 } else { | |
4617 | 1556 if (aim_get_command(od->sess, conn) >= 0) { |
1557 aim_rxdispatch(od->sess); | |
6029 | 1558 if (od->killme) { |
8660 | 1559 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1560 return; |
1561 } | |
2086 | 1562 } else { |
1563 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1564 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1565 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1566 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1567 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1568 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1569 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1570 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1571 char *buf; |
8660 | 1572 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1573 "disconnected from chat room %s\n", c->name); |
2086 | 1574 c->conn = NULL; |
1575 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1576 gaim_input_remove(c->inpa); |
2086 | 1577 c->inpa = 0; |
1578 c->fd = -1; | |
4617 | 1579 aim_conn_kill(od->sess, &conn); |
5420 | 1580 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1581 if (conv) |
1582 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1583 else | |
1584 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1585 g_free(buf); |
2086 | 1586 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1587 if (od->cnpa > 0) |
1588 gaim_input_remove(od->cnpa); | |
1589 od->cnpa = 0; | |
8660 | 1590 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1591 "removing chatnav input watcher\n"); |
4617 | 1592 while (od->create_rooms) { |
1593 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1594 g_free(cr->name); |
4617 | 1595 od->create_rooms = |
1596 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1597 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1598 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1599 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1600 NULL); |
2086 | 1601 } |
4617 | 1602 aim_conn_kill(od->sess, &conn); |
2086 | 1603 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1604 if (od->paspa > 0) |
1605 gaim_input_remove(od->paspa); | |
1606 od->paspa = 0; | |
8660 | 1607 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1608 "removing authconn input watcher\n"); |
4617 | 1609 aim_conn_kill(od->sess, &conn); |
3694 | 1610 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1611 if (od->emlpa > 0) |
1612 gaim_input_remove(od->emlpa); | |
1613 od->emlpa = 0; | |
8660 | 1614 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1615 "removing email input watcher\n"); |
4617 | 1616 aim_conn_kill(od->sess, &conn); |
4804 | 1617 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1618 if (od->icopa > 0) | |
1619 gaim_input_remove(od->icopa); | |
1620 od->icopa = 0; | |
8660 | 1621 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1622 "removing icon input watcher\n"); |
4804 | 1623 aim_conn_kill(od->sess, &conn); |
2086 | 1624 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1625 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1626 gaim_odc_disconnect(od->sess, conn); |
1627 aim_conn_kill(od->sess, &conn); | |
2086 | 1628 } else { |
8660 | 1629 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1630 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1631 conn->type); |
4617 | 1632 aim_conn_kill(od->sess, &conn); |
2086 | 1633 } |
1634 } | |
1635 } | |
1636 } | |
1637 } | |
1638 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1639 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1640 GaimConnection *gc = sess->aux_data; |
7285 | 1641 gchar *s = g_strdup_vprintf(format, va); |
1642 gchar *buf; | |
1643 | |
1644 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1645 gaim_debug_info("oscar", buf); |
7285 | 1646 if (buf[strlen(buf)-1] != '\n') |
8660 | 1647 gaim_debug_info(NULL, "\n"); |
7285 | 1648 g_free(buf); |
2086 | 1649 g_free(s); |
1650 } | |
1651 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1652 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1653 { |
5575 | 1654 GaimConnection *gc = data; |
7283 | 1655 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1656 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1657 aim_conn_t *conn; |
2086 | 1658 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1659 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1660 close(source); |
1661 return; | |
1662 } | |
1663 | |
4617 | 1664 od = gc->proto_data; |
1665 sess = od->sess; | |
2086 | 1666 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1667 conn->fd = source; |
2086 | 1668 |
1669 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1670 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1671 return; |
1672 } | |
1673 | |
1674 aim_conn_completeconnect(sess, conn); | |
4617 | 1675 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1676 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1677 | |
8660 | 1678 gaim_debug_info("oscar", |
7282 | 1679 "Screen name sent, waiting for response\n"); |
7283 | 1680 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1681 ck[1] = 0x65; |
2086 | 1682 } |
1683 | |
5575 | 1684 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1685 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1686 aim_conn_t *conn; |
5575 | 1687 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1688 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1689 |
8660 | 1690 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1691 |
8437 | 1692 if (!aim_snvalid(gaim_account_get_username(account))) { |
1693 gchar *buf; | |
8590 | 1694 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 | 1695 gaim_connection_error(gc, buf); |
1696 g_free(buf); | |
1697 } | |
1698 | |
5575 | 1699 if (isdigit(*(gaim_account_get_username(account)))) { |
4617 | 1700 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1701 } else { |
6622 | 1702 gc->flags |= GAIM_CONNECTION_HTML; |
1703 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1704 } |
5836 | 1705 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1706 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1707 sess = g_new0(aim_session_t, 1); |
7285 | 1708 aim_session_init(sess, TRUE, 0); |
2086 | 1709 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1710 /* |
1711 * We need an immediate queue because we don't use a while-loop | |
1712 * to see if things need to be sent. | |
1713 */ | |
2086 | 1714 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1715 od->sess = sess; |
2086 | 1716 sess->aux_data = gc; |
1717 | |
1718 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
1719 if (conn == NULL) { | |
8660 | 1720 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1721 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1722 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1723 return; |
1724 } | |
1725 | |
4649 | 1726 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1727 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1728 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1729 | |
1730 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1731 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1732 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1733 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1734 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1735 return; |
1736 } | |
7282 | 1737 |
7283 | 1738 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1739 ck[0] = 0x5a; |
5575 | 1740 } |
1741 | |
1742 static void oscar_close(GaimConnection *gc) { | |
7283 | 1743 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1744 |
1745 while (od->oscar_chats) { | |
1746 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1747 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1748 gaim_input_remove(n->inpa); |
2086 | 1749 g_free(n->name); |
1750 g_free(n->show); | |
4617 | 1751 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1752 g_free(n); |
1753 } | |
4617 | 1754 while (od->direct_ims) { |
8971 | 1755 struct oscar_direct_im *n = od->direct_ims->data; |
1756 oscar_direct_im_destroy(od, n); | |
2086 | 1757 } |
4617 | 1758 /* BBB */ |
1759 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1760 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1761 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1762 gaim_xfer_cancel_local(xfer); |
3630 | 1763 } |
4804 | 1764 while (od->requesticon) { |
1765 char *sn = od->requesticon->data; | |
1766 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1767 free(sn); | |
1768 } | |
4738 | 1769 g_hash_table_destroy(od->buddyinfo); |
4617 | 1770 while (od->create_rooms) { |
1771 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1772 g_free(cr->name); |
4617 | 1773 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1774 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1775 } |
4617 | 1776 if (od->email) |
1777 g_free(od->email); | |
1778 if (od->newp) | |
1779 g_free(od->newp); | |
1780 if (od->oldp) | |
1781 g_free(od->oldp); | |
2086 | 1782 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1783 gaim_input_remove(gc->inpa); |
4617 | 1784 if (od->cnpa > 0) |
1785 gaim_input_remove(od->cnpa); | |
1786 if (od->paspa > 0) | |
1787 gaim_input_remove(od->paspa); | |
1788 if (od->emlpa > 0) | |
1789 gaim_input_remove(od->emlpa); | |
4804 | 1790 if (od->icopa > 0) |
1791 gaim_input_remove(od->icopa); | |
6907 | 1792 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1793 gaim_timeout_remove(od->icontimer); |
8341 | 1794 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1795 gaim_timeout_remove(od->getblisttimer); |
8341 | 1796 if (od->getinfotimer > 0) |
1797 gaim_timeout_remove(od->getinfotimer); | |
4617 | 1798 aim_session_kill(od->sess); |
1799 g_free(od->sess); | |
1800 od->sess = NULL; | |
2086 | 1801 g_free(gc->proto_data); |
1802 gc->proto_data = NULL; | |
8660 | 1803 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1804 } |
1805 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1806 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1807 GaimConnection *gc = data; |
7283 | 1808 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1809 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1810 aim_conn_t *bosconn; |
2086 | 1811 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1812 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1813 close(source); |
1814 return; | |
1815 } | |
1816 | |
4617 | 1817 od = gc->proto_data; |
1818 sess = od->sess; | |
1819 bosconn = od->conn; | |
4366 | 1820 bosconn->fd = source; |
2086 | 1821 |
1822 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1823 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1824 return; |
1825 } | |
1826 | |
1827 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1828 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1829 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1830 gaim_connection_update_progress(gc, |
7283 | 1831 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1832 ck[4] = 0x61; |
2086 | 1833 } |
1834 | |
4617 | 1835 /* BBB */ |
4656 | 1836 /* |
1837 * This little area in oscar.c is the nexus of file transfer code, | |
1838 * so I wrote a little explanation of what happens. I am such a | |
1839 * ninja. | |
1840 * | |
1841 * The series of events for a file send is: | |
1842 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
1843 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1844 * listening socket, then asks the remote user to connect to us (and |
1845 * gives them the file name, port, IP, etc.) | |
1846 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1847 * in oscar_sendfile_estblsh) | |
1848 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1849 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1850 * connection. | |
1851 * -We get drunk because file transfer kicks ass. | |
1852 * | |
1853 * The series of events for a file receive is: | |
1854 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1855 * -Gaim user selects file to name and location to save file to and | |
1856 * oscar_xfer_init is called | |
1857 * -It connects to the remote user using the IP they gave us earlier | |
1858 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1859 * them an AIM_CB_OFT_ACK. | |
1860 * -They begin to send us lots of raw data. | |
1861 * -When they finish sending data we send an AIM_CB_OFT_DONE and then close | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
1862 * the connection. |
4656 | 1863 */ |
1864 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1865 | |
8446 | 1866 /* |
1867 * Miscellaneous xfer functions | |
1868 */ | |
1869 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1870 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1871 GaimXfer *xfer; |
5146 | 1872 struct aim_oft_info *oft_info; |
4656 | 1873 |
1874 while (fts) { | |
1875 xfer = fts->data; | |
5146 | 1876 oft_info = xfer->data; |
1877 | |
8446 | 1878 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1879 return xfer; |
1880 | |
1881 fts = g_slist_next(fts); | |
1882 } | |
1883 | |
1884 return NULL; | |
1885 } | |
1886 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1887 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1888 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1889 GaimXfer *xfer; |
5146 | 1890 struct aim_oft_info *oft_info; |
4656 | 1891 |
1892 while (fts) { | |
1893 xfer = fts->data; | |
5146 | 1894 oft_info = xfer->data; |
1895 | |
1896 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1897 return xfer; |
1898 | |
1899 fts = g_slist_next(fts); | |
1900 } | |
1901 | |
1902 return NULL; | |
1903 } | |
1904 | |
8446 | 1905 static void oscar_xfer_end(GaimXfer *xfer) |
1906 { | |
1907 struct aim_oft_info *oft_info = xfer->data; | |
1908 GaimConnection *gc = oft_info->sess->aux_data; | |
1909 OscarData *od = gc->proto_data; | |
1910 | |
8660 | 1911 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1912 |
1913 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1914 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1915 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1916 } | |
1917 | |
1918 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1919 aim_oft_destroyinfo(oft_info); | |
1920 xfer->data = NULL; | |
1921 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1922 } | |
1923 | |
1924 /* | |
1925 * xfer functions used when receiving files | |
1926 */ | |
1927 | |
1928 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1929 { | |
1930 struct aim_oft_info *oft_info = xfer->data; | |
1931 GaimConnection *gc = oft_info->sess->aux_data; | |
1932 OscarData *od = gc->proto_data; | |
1933 | |
8660 | 1934 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1935 |
1936 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1937 if (oft_info->conn) { | |
1938 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1939 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1940 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1941 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1942 if (xfer->fd == -1) { | |
1943 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1944 _("Unable to establish file descriptor.")); | |
1945 gaim_xfer_cancel_local(xfer); | |
1946 } | |
1947 } else { | |
1948 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1949 _("Unable to create new connection.")); | |
1950 gaim_xfer_cancel_local(xfer); | |
1951 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1952 } | |
1953 | |
1954 } | |
1955 | |
1956 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1957 { | |
1958 struct aim_oft_info *oft_info = xfer->data; | |
1959 GaimConnection *gc = oft_info->sess->aux_data; | |
1960 OscarData *od = gc->proto_data; | |
1961 | |
8660 | 1962 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1963 |
9771 | 1964 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1965 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1966 |
1967 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1968 aim_oft_destroyinfo(oft_info); | |
1969 xfer->data = NULL; | |
1970 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1971 } | |
1972 | |
1973 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1974 { | |
1975 struct aim_oft_info *oft_info = xfer->data; | |
1976 | |
1977 /* Update our rolling checksum. Like Walmart, yo. */ | |
1978 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
1979 } | |
1980 | |
1981 /* | |
1982 * xfer functions used when sending files | |
1983 */ | |
1984 | |
1985 static void oscar_xfer_init_send(GaimXfer *xfer) | |
1986 { | |
1987 struct aim_oft_info *oft_info = xfer->data; | |
1988 GaimConnection *gc = oft_info->sess->aux_data; | |
1989 OscarData *od = gc->proto_data; | |
1990 int listenfd; | |
1991 | |
8660 | 1992 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 1993 |
1994 xfer->filename = g_path_get_basename(xfer->local_filename); | |
1995 strncpy(oft_info->fh.name, xfer->filename, 64); | |
1996 oft_info->fh.name[63] = '\0'; | |
1997 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
1998 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
1999 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2000 | |
2001 /* Create a listening socket and an associated libfaim conn */ | |
2002 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2003 gaim_xfer_cancel_local(xfer); | |
2004 return; | |
2005 } | |
2006 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2007 oft_info->port = xfer->local_port; | |
2008 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2009 gaim_xfer_cancel_local(xfer); | |
2010 return; | |
2011 } | |
8660 | 2012 gaim_debug_misc("oscar", |
8446 | 2013 "port is %hu, ip is %s\n", |
2014 xfer->local_port, oft_info->clientip); | |
2015 if (oft_info->conn) { | |
2016 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2017 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2018 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2019 } else { | |
2020 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2021 _("Unable to establish listener socket.")); | |
2022 gaim_xfer_cancel_local(xfer); | |
2023 } | |
2024 } | |
2025 | |
2026 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2027 { | |
2028 struct aim_oft_info *oft_info = xfer->data; | |
2029 GaimConnection *gc = oft_info->sess->aux_data; | |
2030 OscarData *od = gc->proto_data; | |
2031 | |
8660 | 2032 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2033 |
9771 | 2034 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2035 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2036 |
2037 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2038 aim_oft_destroyinfo(oft_info); | |
2039 xfer->data = NULL; | |
2040 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2041 } | |
2042 | |
2043 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2044 { | |
2045 struct aim_oft_info *oft_info = xfer->data; | |
2046 | |
2047 /* I'm not sure I like how we do this. --marv | |
2048 * I do. AIM file transfers aren't really meant to be thought | |
2049 * of as a transferring just a single file. The rendezvous | |
2050 * establishes a connection between two computers, and then | |
2051 * those computers can use the same connection for transferring | |
2052 * multiple files. So we don't want the Gaim core up and closing | |
2053 * the socket all willy-nilly. We want to do that in the oscar | |
2054 * prpl, whenever one side or the other says they're finished | |
2055 * using the connection. There might be a better way to intercept | |
2056 * the socket from the core, however... --KingAnt | |
2057 */ | |
2058 | |
2059 /* | |
2060 * If we're done sending, intercept the socket from the core ft code | |
2061 * and wait for the other guy to send the "done" OFT packet. | |
2062 */ | |
2063 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2064 gaim_input_remove(xfer->watcher); | |
2065 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2066 xfer->fd = 0; | |
2067 gaim_xfer_set_completed(xfer, TRUE); | |
2068 } | |
2069 } | |
2070 | |
9466 | 2071 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2072 gboolean can_receive = FALSE; | |
2073 OscarData *od = gc->proto_data; | |
2074 | |
2075 if (!od->icq) { | |
2076 aim_userinfo_t *userinfo; | |
2077 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2078 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2079 can_receive = TRUE; | |
2080 } | |
2081 | |
2082 return can_receive; | |
2083 } | |
2084 | |
2085 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2086 |
2087 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2088 GaimXfer *xfer; |
5146 | 2089 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2090 const char *ip; |
3752 | 2091 |
9030 | 2092 od = (OscarData *)gc->proto_data; |
2093 | |
4617 | 2094 /* You want to send a file to someone else, you're so generous */ |
2095 | |
2096 /* Build the file transfer handle */ | |
9466 | 2097 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2098 |
5146 | 2099 /* Create the oscar-specific data */ |
8838 | 2100 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2101 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2102 xfer->data = oft_info; |
2103 | |
4617 | 2104 /* Setup our I/O op functions */ |
8446 | 2105 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2106 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2107 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2108 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2109 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2110 |
2111 /* Keep track of this transfer for later */ | |
2112 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2113 | |
2114 /* Now perform the request */ | |
9466 | 2115 if (file) |
2116 gaim_xfer_request_accepted(xfer, file); | |
2117 else | |
2118 gaim_xfer_request(xfer); | |
3630 | 2119 } |
2120 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2121 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2122 GaimConnection *gc = sess->aux_data; |
7283 | 2123 OscarData *od = gc->proto_data; |
6029 | 2124 GaimAccount *account = gc->account; |
2125 aim_conn_t *bosconn; | |
2126 char *host; int port; | |
2127 int i, rc; | |
2086 | 2128 va_list ap; |
2704 | 2129 struct aim_authresp_info *info; |
6029 | 2130 |
5575 | 2131 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2132 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2133 va_start(ap, fr); |
2704 | 2134 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2135 va_end(ap); |
2136 | |
8660 | 2137 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2138 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2139 |
4293 | 2140 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2141 char buf[256]; |
2704 | 2142 switch (info->errorcode) { |
2086 | 2143 case 0x05: |
2144 /* Incorrect nick/password */ | |
6498 | 2145 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2146 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2147 break; |
2148 case 0x11: | |
2149 /* Suspended account */ | |
6498 | 2150 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2151 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2152 break; |
3498 | 2153 case 0x14: |
2154 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2155 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2156 break; |
2086 | 2157 case 0x18: |
2158 /* connecting too frequently */ | |
6498 | 2159 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2160 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 | 2161 break; |
2162 case 0x1c: | |
2163 /* client too old */ | |
6498 | 2164 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2165 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
|
2166 gaim_connection_error(gc, buf); |
2086 | 2167 break; |
2168 default: | |
6623 | 2169 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2170 break; |
2171 } | |
8660 | 2172 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2173 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2174 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2175 "Error URL: %s\n", info->errorurl); |
2086 | 2176 od->killme = TRUE; |
2177 return 1; | |
2178 } | |
2179 | |
2180 | |
8660 | 2181 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2182 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2183 |
2704 | 2184 if (info->email) { |
8660 | 2185 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2186 } else { |
8660 | 2187 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2188 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2189 |
8660 | 2190 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2191 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2192 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2193 aim_conn_kill(sess, &fr->conn); |
2086 | 2194 |
2195 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2196 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2197 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2198 od->killme = TRUE; |
2199 return 0; | |
2200 } | |
2201 | |
4649 | 2202 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2203 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2204 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2205 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2206 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2207 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2208 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2209 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2210 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2211 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2212 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2213 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2214 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2215 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2216 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2217 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2218 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2219 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2220 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2221 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2222 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2223 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2224 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2225 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2226 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2227 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2228 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2229 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2230 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2231 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0021, oscar_icon_req,0); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
2232 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
2233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
2234 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2235 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2237 #ifndef NOSSI |
4642 | 2238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2239 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2240 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2241 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2242 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2243 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2244 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2245 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2246 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2247 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2248 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2249 |
7283 | 2250 od->conn = bosconn; |
2704 | 2251 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2252 if (info->bosip[i] == ':') { | |
2253 port = atoi(&(info->bosip[i+1])); | |
2086 | 2254 break; |
2255 } | |
2256 } | |
2704 | 2257 host = g_strndup(info->bosip, i); |
2086 | 2258 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2259 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2260 g_free(host); |
4366 | 2261 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2262 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2263 od->killme = TRUE; |
2264 return 0; | |
2265 } | |
4293 | 2266 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2267 gaim_input_remove(gc->inpa); |
2704 | 2268 |
7283 | 2269 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2270 ck[3] = 0x64; |
7282 | 2271 |
2086 | 2272 return 1; |
2273 } | |
2274 | |
7285 | 2275 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2276 struct pieceofcrap { |
5575 | 2277 GaimConnection *gc; |
2086 | 2278 unsigned long offset; |
2279 unsigned long len; | |
2280 char *modname; | |
2281 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2282 aim_conn_t *conn; |
2086 | 2283 unsigned int inpa; |
2284 }; | |
2285 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2286 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2287 { |
2288 struct pieceofcrap *pos = data; | |
7283 | 2289 OscarData *od = pos->gc->proto_data; |
2086 | 2290 char in = '\0'; |
2291 int x = 0; | |
2292 unsigned char m[17]; | |
2293 | |
2294 while (read(pos->fd, &in, 1) == 1) { | |
2295 if (in == '\n') | |
2296 x++; | |
2297 else if (in != '\r') | |
2298 x = 0; | |
2299 if (x == 2) | |
2300 break; | |
2301 in = '\0'; | |
2302 } | |
2303 if (in != '\n') { | |
4056 | 2304 char buf[256]; |
2305 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
|
2306 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2307 gaim_notify_warning(pos->gc, NULL, |
7422 | 2308 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2309 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2310 gaim_input_remove(pos->inpa); |
2086 | 2311 close(pos->fd); |
2312 g_free(pos); | |
2313 return; | |
2314 } | |
2315 read(pos->fd, m, 16); | |
2316 m[16] = '\0'; | |
8660 | 2317 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2318 for (x = 0; x < 16; x++) |
8660 | 2319 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2320 | |
2321 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2322 gaim_input_remove(pos->inpa); |
2086 | 2323 close(pos->fd); |
2324 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2325 g_free(pos); | |
2326 } | |
2327 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2328 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2329 struct pieceofcrap *pos = data; |
5420 | 2330 gchar *buf; |
2086 | 2331 |
4366 | 2332 pos->fd = source; |
2333 | |
2086 | 2334 if (source < 0) { |
5420 | 2335 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
|
2336 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2337 gaim_notify_warning(pos->gc, NULL, |
7422 | 2338 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2339 buf); |
5420 | 2340 g_free(buf); |
2086 | 2341 if (pos->modname) |
2342 g_free(pos->modname); | |
2343 g_free(pos); | |
2344 return; | |
2345 } | |
2346 | |
5420 | 2347 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2348 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2349 write(pos->fd, buf, strlen(buf)); | |
5420 | 2350 g_free(buf); |
2086 | 2351 if (pos->modname) |
2352 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2353 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2354 return; |
2355 } | |
2356 | |
2357 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2358 #define AIM_MAX_FILE_SIZE 98304 | |
2359 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2360 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2361 va_list ap; |
2362 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2363 fu32_t offset, len; |
2086 | 2364 char *modname; |
2365 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2366 va_start(ap, fr); |
4200 | 2367 offset = va_arg(ap, fu32_t); |
2368 len = va_arg(ap, fu32_t); | |
2086 | 2369 modname = va_arg(ap, char *); |
2370 va_end(ap); | |
2371 | |
8660 | 2372 gaim_debug_misc("oscar", |
5556 | 2373 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2374 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2375 |
2086 | 2376 if (len == 0) { |
8660 | 2377 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2378 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2379 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2380 return 1; | |
2381 } | |
9625 | 2382 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2383 #if 0 | |
2086 | 2384 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2385 char *buf; | |
2386 int i = 8; | |
2387 if (modname) | |
2388 i += strlen(modname); | |
2389 buf = g_malloc(i); | |
2390 i = 0; | |
2391 if (modname) { | |
2392 memcpy(buf, modname, strlen(modname)); | |
2393 i += strlen(modname); | |
2394 } | |
2395 buf[i++] = offset & 0xff; | |
2396 buf[i++] = (offset >> 8) & 0xff; | |
2397 buf[i++] = (offset >> 16) & 0xff; | |
2398 buf[i++] = (offset >> 24) & 0xff; | |
2399 buf[i++] = len & 0xff; | |
2400 buf[i++] = (len >> 8) & 0xff; | |
2401 buf[i++] = (len >> 16) & 0xff; | |
2402 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2403 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2404 "hashing request\n"); |
2086 | 2405 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2406 g_free(buf); | |
2407 return 1; | |
2408 } | |
9625 | 2409 #endif |
2086 | 2410 |
2411 pos = g_new0(struct pieceofcrap, 1); | |
2412 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2413 pos->conn = fr->conn; |
2086 | 2414 |
2415 pos->offset = offset; | |
2416 pos->len = len; | |
2417 pos->modname = modname ? g_strdup(modname) : NULL; | |
2418 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2419 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2420 char buf[256]; |
2086 | 2421 if (pos->modname) |
2422 g_free(pos->modname); | |
2423 g_free(pos); | |
4056 | 2424 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
|
2425 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2426 gaim_notify_warning(pos->gc, NULL, |
7422 | 2427 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2428 buf); |
2086 | 2429 } |
2430 | |
2431 return 1; | |
2432 } | |
2433 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2434 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2435 GaimConnection *gc = sess->aux_data; |
7283 | 2436 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2437 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2438 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2439 #if 0 |
2440 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2441 #endif | |
7011 | 2442 va_list ap; |
2443 char *key; | |
2086 | 2444 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2445 va_start(ap, fr); |
2086 | 2446 key = va_arg(ap, char *); |
2447 va_end(ap); | |
2448 | |
4617 | 2449 if (od->icq) { |
3458 | 2450 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2451 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2452 gaim_account_get_password(account), &info, key); |
3458 | 2453 } else { |
2454 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2455 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2456 gaim_account_get_password(account), &info, key); |
3458 | 2457 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2458 |
7283 | 2459 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2460 ck[2] = 0x6c; |
7282 | 2461 |
2086 | 2462 return 1; |
2463 } | |
2464 | |
2675 | 2465 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2466 GaimConnection *gc = sess->aux_data; |
2647 | 2467 struct chat_connection *chatcon; |
2468 static int id = 1; | |
2469 | |
6905 | 2470 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, 0x0001, gaim_parse_genericerr, 0); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2471 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_conv_chat_join, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2472 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_conv_chat_leave, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2473 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_conv_chat_info_update, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2474 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2475 |
2672 | 2476 aim_clientready(sess, fr->conn); |
2675 | 2477 |
2647 | 2478 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2479 chatcon->id = id; | |
8733 | 2480 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2481 |
2482 return 1; | |
2483 } | |
2484 | |
2675 | 2485 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2486 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2487 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2488 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2489 |
2490 aim_clientready(sess, fr->conn); | |
2491 | |
2492 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2493 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2494 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2495 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2496 |
3694 | 2497 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2498 | |
2499 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2500 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2501 | |
7282 | 2502 aim_email_sendcookies(sess); |
2503 aim_email_activate(sess); | |
3694 | 2504 aim_clientready(sess, fr->conn); |
2505 | |
2506 return 1; | |
2507 } | |
2508 | |
4804 | 2509 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2510 GaimConnection *gc = sess->aux_data; |
7283 | 2511 OscarData *od = gc->proto_data; |
4804 | 2512 |
2513 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2514 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2515 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2516 | |
2517 aim_clientready(sess, fr->conn); | |
2518 | |
4823 | 2519 od->iconconnecting = FALSE; |
2520 | |
4804 | 2521 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2522 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2523 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2524 |
2525 return 1; | |
2526 } | |
2527 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2528 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2529 GaimConnection *gc = data; |
7283 | 2530 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2531 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2532 aim_conn_t *tstconn; |
2086 | 2533 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2534 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2535 close(source); |
2536 return; | |
2537 } | |
2538 | |
4617 | 2539 od = gc->proto_data; |
2540 sess = od->sess; | |
2086 | 2541 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2542 tstconn->fd = source; |
2086 | 2543 |
2544 if (source < 0) { | |
2545 aim_conn_kill(sess, &tstconn); | |
8660 | 2546 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2547 "unable to connect to chatnav server\n"); |
2086 | 2548 return; |
2549 } | |
2550 | |
2551 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2552 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2553 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2554 } |
2555 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2556 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2557 { |
5575 | 2558 GaimConnection *gc = data; |
7283 | 2559 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2560 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2561 aim_conn_t *tstconn; |
2086 | 2562 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2563 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2564 close(source); |
2565 return; | |
2566 } | |
2567 | |
4617 | 2568 od = gc->proto_data; |
2569 sess = od->sess; | |
2086 | 2570 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2571 tstconn->fd = source; |
2086 | 2572 |
2573 if (source < 0) { | |
2574 aim_conn_kill(sess, &tstconn); | |
8660 | 2575 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2576 "unable to connect to authorizer\n"); |
2086 | 2577 return; |
2578 } | |
2579 | |
2580 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2581 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2582 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2583 } |
2584 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2585 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2586 { |
2587 struct chat_connection *ccon = data; | |
5575 | 2588 GaimConnection *gc = ccon->gc; |
7283 | 2589 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2590 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2591 aim_conn_t *tstconn; |
2086 | 2592 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2593 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2594 close(source); |
2595 g_free(ccon->show); | |
2596 g_free(ccon->name); | |
2597 g_free(ccon); | |
2598 return; | |
2599 } | |
2600 | |
4617 | 2601 od = gc->proto_data; |
2602 sess = od->sess; | |
2086 | 2603 tstconn = ccon->conn; |
4366 | 2604 tstconn->fd = source; |
2086 | 2605 |
2606 if (source < 0) { | |
2607 aim_conn_kill(sess, &tstconn); | |
2608 g_free(ccon->show); | |
2609 g_free(ccon->name); | |
2610 g_free(ccon); | |
2611 return; | |
2612 } | |
2613 | |
2614 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2615 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2616 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2617 } |
2618 | |
3694 | 2619 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2620 GaimConnection *gc = data; |
7283 | 2621 OscarData *od; |
3694 | 2622 aim_session_t *sess; |
2623 aim_conn_t *tstconn; | |
2624 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2625 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2626 close(source); |
2627 return; | |
2628 } | |
2629 | |
4617 | 2630 od = gc->proto_data; |
2631 sess = od->sess; | |
3694 | 2632 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2633 tstconn->fd = source; |
3694 | 2634 |
2635 if (source < 0) { | |
2636 aim_conn_kill(sess, &tstconn); | |
8660 | 2637 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2638 "unable to connect to email server\n"); |
3694 | 2639 return; |
2640 } | |
2641 | |
2642 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2643 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2644 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2645 "email: connected\n"); |
3694 | 2646 } |
2647 | |
4804 | 2648 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2649 GaimConnection *gc = data; |
7283 | 2650 OscarData *od; |
4804 | 2651 aim_session_t *sess; |
2652 aim_conn_t *tstconn; | |
2653 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2654 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2655 close(source); |
2656 return; | |
2657 } | |
2658 | |
2659 od = gc->proto_data; | |
2660 sess = od->sess; | |
2661 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2662 tstconn->fd = source; | |
2663 | |
2664 if (source < 0) { | |
2665 aim_conn_kill(sess, &tstconn); | |
8660 | 2666 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2667 "unable to connect to icon server\n"); |
4804 | 2668 return; |
2669 } | |
2670 | |
2671 aim_conn_completeconnect(sess, tstconn); | |
2672 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2673 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2674 } |
2675 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2676 /* Hrmph. I don't know how to make this look better. --mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2677 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2678 GaimConnection *gc = sess->aux_data; |
2679 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2680 aim_conn_t *tstconn; |
4452 | 2681 int i; |
2086 | 2682 char *host; |
2683 int port; | |
4821 | 2684 va_list ap; |
2685 struct aim_redirect_data *redir; | |
2086 | 2686 |
5575 | 2687 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2688 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2689 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2690 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2691 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2692 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2693 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2694 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2695 port = atoi(&(redir->ip[i+1])); |
2086 | 2696 break; |
2697 } | |
2698 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2699 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2700 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2701 switch(redir->group) { |
2086 | 2702 case 0x7: /* Authorizer */ |
8660 | 2703 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2704 "Reconnecting with authorizor...\n"); |
2086 | 2705 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2706 if (tstconn == NULL) { | |
8660 | 2707 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2708 "unable to reconnect with authorizer\n"); |
2086 | 2709 g_free(host); |
2710 return 1; | |
2711 } | |
4649 | 2712 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2713 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2714 |
2715 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2716 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2717 aim_conn_kill(sess, &tstconn); |
8660 | 2718 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2719 "unable to reconnect with authorizer\n"); |
2086 | 2720 g_free(host); |
2721 return 1; | |
2722 } | |
4293 | 2723 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2724 break; |
2725 | |
2086 | 2726 case 0xd: /* ChatNav */ |
2727 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2728 if (tstconn == NULL) { | |
8660 | 2729 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2730 "unable to connect to chatnav server\n"); |
2086 | 2731 g_free(host); |
2732 return 1; | |
2733 } | |
4649 | 2734 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2735 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2736 |
2737 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2738 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2739 aim_conn_kill(sess, &tstconn); |
8660 | 2740 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2741 "unable to connect to chatnav server\n"); |
2086 | 2742 g_free(host); |
2743 return 1; | |
2744 } | |
4293 | 2745 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2746 break; |
2747 | |
2748 case 0xe: { /* Chat */ | |
2086 | 2749 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2750 |
2086 | 2751 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2752 if (tstconn == NULL) { | |
8660 | 2753 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2754 "unable to connect to chat server\n"); |
2086 | 2755 g_free(host); |
2756 return 1; | |
2757 } | |
2758 | |
4649 | 2759 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2760 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2761 | |
2086 | 2762 ccon = g_new0(struct chat_connection, 1); |
2763 ccon->conn = tstconn; | |
2764 ccon->gc = gc; | |
2765 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2766 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2767 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2768 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2769 ccon->show = extract_name(redir->chat.room); |
4634 | 2770 |
2086 | 2771 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2772 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2773 aim_conn_kill(sess, &tstconn); |
8660 | 2774 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2775 "unable to connect to chat server\n"); |
2086 | 2776 g_free(host); |
2777 g_free(ccon->show); | |
2778 g_free(ccon->name); | |
2779 g_free(ccon); | |
2780 return 1; | |
2781 } | |
4293 | 2782 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2783 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2784 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2785 ccon->name, ccon->exchange); |
4194 | 2786 } break; |
3694 | 2787 |
4804 | 2788 case 0x0010: { /* icon */ |
2789 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2790 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2791 "unable to connect to icon server\n"); |
4804 | 2792 g_free(host); |
2793 return 1; | |
2794 } | |
2795 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2796 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2797 | |
2798 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2799 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2800 aim_conn_kill(sess, &tstconn); |
8660 | 2801 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2802 "unable to connect to icon server\n"); |
4804 | 2803 g_free(host); |
2804 return 1; | |
2805 } | |
2806 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2807 } break; | |
2808 | |
3694 | 2809 case 0x0018: { /* email */ |
2810 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2811 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2812 "unable to connect to email server\n"); |
3694 | 2813 g_free(host); |
2814 return 1; | |
2815 } | |
4649 | 2816 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2817 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2818 | |
2819 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2820 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2821 aim_conn_kill(sess, &tstconn); |
8660 | 2822 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2823 "unable to connect to email server\n"); |
3694 | 2824 g_free(host); |
2825 return 1; | |
2826 } | |
4293 | 2827 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2828 } break; |
2829 | |
2086 | 2830 default: /* huh? */ |
8660 | 2831 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2832 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2833 redir->group); |
2086 | 2834 break; |
2835 } | |
2836 | |
2837 g_free(host); | |
2838 return 1; | |
2839 } | |
2840 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2841 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2842 GaimConnection *gc = sess->aux_data; |
9058 | 2843 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 2844 OscarData *od = gc->proto_data; |
4738 | 2845 struct buddyinfo *bi; |
2993 | 2846 time_t time_idle = 0, signon = 0; |
2847 int type = 0; | |
2848 int caps = 0; | |
2086 | 2849 va_list ap; |
4738 | 2850 aim_userinfo_t *info; |
4194 | 2851 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2852 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2853 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2854 va_end(ap); |
2855 | |
2993 | 2856 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2857 caps = info->capabilities; | |
3267 | 2858 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
2859 type |= UC_AB; | |
2860 | |
4766 | 2861 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2862 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
2863 type |= UC_UNCONFIRMED; | |
2864 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
2865 type |= UC_ADMIN; | |
2866 if (info->flags & AIM_FLAG_AOL) | |
2867 type |= UC_AOL; | |
2868 if (info->flags & AIM_FLAG_FREE) | |
2869 type |= UC_NORMAL; | |
2870 if (info->flags & AIM_FLAG_AWAY) | |
2871 type |= UC_UNAVAILABLE; | |
2872 if (info->flags & AIM_FLAG_WIRELESS) | |
2873 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2874 } |
2993 | 2875 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2876 type = (info->icqinfo.status << 16); |
3013 | 2877 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2878 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 2879 type |= UC_UNAVAILABLE; |
3013 | 2880 } |
2993 | 2881 } |
2882 | |
7141 | 2883 if (caps & AIM_CAPS_ICQ_DIRECT) |
2884 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2885 |
2886 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2887 time(&time_idle); |
2888 time_idle -= info->idletime*60; | |
9295 | 2889 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2890 } |
2891 | |
5836 | 2892 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2893 signon = info->onlinesince; | |
2894 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2895 signon = time(NULL) - info->sessionlen; |
2086 | 2896 |
5575 | 2897 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
2898 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2899 |
7261 | 2900 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
4738 | 2901 if (!bi) { |
2902 bi = g_new0(struct buddyinfo, 1); | |
7261 | 2903 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
4738 | 2904 } |
4739 | 2905 bi->typingnot = FALSE; |
2906 bi->ico_informed = FALSE; | |
6857 | 2907 bi->ipaddr = info->icqinfo.ipaddr; |
2908 | |
2909 /* Available message stuff */ | |
6292 | 2910 free(bi->availmsg); |
7011 | 2911 if (info->avail != NULL) |
8225 | 2912 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2913 else |
6292 | 2914 bi->availmsg = NULL; |
4732 | 2915 |
4804 | 2916 /* Server stored icon stuff */ |
4853 | 2917 if (info->iconcsumlen) { |
7125 | 2918 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2919 char *b16 = NULL, *filepath = NULL; |
7093 | 2920 GaimBuddy *b = NULL; |
4853 | 2921 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2922 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
4853 | 2923 b = gaim_find_buddy(gc->account, info->sn); |
7093 | 2924 /* |
2925 * If for some reason the checksum is valid, but cached file is not.. | |
2926 * we want to know. | |
2927 */ | |
7693 | 2928 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2929 if (filename != NULL) { |
2930 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2931 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2932 "icon_checksum"); | |
9801 | 2933 else { |
2934 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2935 filename, NULL); | |
2936 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2937 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2938 "icon_checksum"); | |
2939 g_free(filepath); | |
2940 } | |
7093 | 2941 } else |
2942 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2943 |
4853 | 2944 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2945 GSList *cur = od->requesticon; | |
2946 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2947 cur = cur->next; | |
2948 if (!cur) { | |
7475 | 2949 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
4853 | 2950 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2951 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2952 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2953 } |
2954 } | |
6053 | 2955 g_free(b16); |
4853 | 2956 } |
2957 | |
9058 | 2958 /* |
2959 * If we have info for ourselves, then update our local warning | |
2960 * level and set our official time of login. Is this necessary? | |
2961 * XXX - This needs to be changed some how. evil should not be | |
2962 * handled by the core at all? | |
2963 */ | |
2964 if (!aim_sncmp(info->sn, gaim_account_get_username(account))) { | |
2965 gc->evil = (info->warnlevel/10.0); | |
2966 gc->login_time_official = signon; | |
2967 } | |
2968 | |
5628 | 2969 serv_got_update(gc, info->sn, 1, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 2970 |
2971 return 1; | |
2972 } | |
2973 | |
8341 | 2974 static void gaim_check_comment(OscarData *od, const char *str) { |
2975 if ((str == NULL) || strcmp(str, ck)) | |
2976 aim_locate_setcaps(od->sess, caps_aim); | |
2977 else | |
2978 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2979 } | |
2980 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2981 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2982 GaimConnection *gc = sess->aux_data; |
7283 | 2983 OscarData *od = gc->proto_data; |
2086 | 2984 va_list ap; |
4739 | 2985 aim_userinfo_t *info; |
2086 | 2986 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2987 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2988 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2989 va_end(ap); |
2990 | |
4732 | 2991 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); |
2086 | 2992 |
7261 | 2993 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 2994 |
2086 | 2995 return 1; |
2996 } | |
2997 | |
4617 | 2998 /* BBB */ |
3952 | 2999 /* |
4617 | 3000 * This is called after a remote AIM user has connected to us. We |
3001 * want to do some voodoo with the socket file descriptors, add a | |
3002 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3003 */ |
4656 | 3004 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3005 GaimConnection *gc = sess->aux_data; |
7283 | 3006 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3007 GaimXfer *xfer; |
5146 | 3008 struct aim_oft_info *oft_info; |
3630 | 3009 va_list ap; |
3010 aim_conn_t *conn, *listenerconn; | |
4656 | 3011 |
8660 | 3012 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3013 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3014 va_start(ap, fr); |
3015 conn = va_arg(ap, aim_conn_t *); | |
3016 listenerconn = va_arg(ap, aim_conn_t *); | |
3017 va_end(ap); | |
3018 | |
4617 | 3019 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3020 return 1; | |
3021 | |
5146 | 3022 if (!(oft_info = xfer->data)) |
4617 | 3023 return 1; |
3024 | |
3630 | 3025 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3026 gaim_input_remove(xfer->watcher); |
3630 | 3027 aim_conn_kill(sess, &listenerconn); |
3028 | |
5146 | 3029 oft_info->conn = conn; |
3030 xfer->fd = oft_info->conn->fd; | |
3031 | |
3032 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3033 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3034 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3035 |
3036 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3037 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3038 |
3039 return 0; | |
3040 } | |
3041 | |
3952 | 3042 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3043 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3044 * user in order to transfer a file. |
3952 | 3045 */ |
4617 | 3046 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
|
3047 GaimXfer *xfer; |
5146 | 3048 struct aim_oft_info *oft_info; |
4656 | 3049 |
8660 | 3050 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3051 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3052 if (!(xfer = data)) |
3053 return; | |
5146 | 3054 if (!(oft_info = xfer->data)) |
3630 | 3055 return; |
8446 | 3056 if (source < 0) { |
3057 gaim_xfer_cancel_remote(xfer); | |
4617 | 3058 return; |
8446 | 3059 } |
4617 | 3060 |
3061 xfer->fd = source; | |
5146 | 3062 oft_info->conn->fd = source; |
3063 | |
3064 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3065 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3066 |
3067 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3068 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3069 |
3070 return; | |
3630 | 3071 } |
3072 | |
3952 | 3073 /* |
4617 | 3074 * This is called when a buddy sends us some file info. This happens when they |
3075 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3076 * You should send them the exact same info except use the real cookie. We also |
4617 | 3077 * get like totally ready to like, receive the file, kay? |
3952 | 3078 */ |
4617 | 3079 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3080 GaimConnection *gc = sess->aux_data; |
7283 | 3081 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3082 GaimXfer *xfer; |
5146 | 3083 struct aim_oft_info *oft_info; |
4617 | 3084 va_list ap; |
3085 aim_conn_t *conn; | |
3086 fu8_t *cookie; | |
3087 struct aim_fileheader_t *fh; | |
4656 | 3088 |
8660 | 3089 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3090 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3091 va_start(ap, fr); |
3092 conn = va_arg(ap, aim_conn_t *); | |
3093 cookie = va_arg(ap, fu8_t *); | |
3094 fh = va_arg(ap, struct aim_fileheader_t *); | |
3095 va_end(ap); | |
3096 | |
3097 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3098 return 1; | |
3099 | |
5146 | 3100 if (!(oft_info = xfer->data)) |
4617 | 3101 return 1; |
3102 | |
3103 /* We want to stop listening with a normal thingy */ | |
3104 gaim_input_remove(xfer->watcher); | |
3105 xfer->watcher = 0; | |
3106 | |
5146 | 3107 /* They sent us some information about the file they're sending */ |
3108 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3109 | |
3110 /* Fill in the cookie */ | |
3111 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3112 | |
4617 | 3113 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3114 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3115 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3116 | |
3117 return 0; | |
3630 | 3118 } |
3119 | |
3952 | 3120 /* |
4657 | 3121 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3122 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3123 */ |
4617 | 3124 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3125 GaimConnection *gc = sess->aux_data; |
7283 | 3126 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3127 GaimXfer *xfer; |
4617 | 3128 va_list ap; |
3129 aim_conn_t *conn; | |
3130 fu8_t *cookie; | |
3131 struct aim_fileheader_t *fh; | |
4656 | 3132 |
8660 | 3133 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3134 va_start(ap, fr); |
3135 conn = va_arg(ap, aim_conn_t *); | |
3136 cookie = va_arg(ap, fu8_t *); | |
3137 fh = va_arg(ap, struct aim_fileheader_t *); | |
3138 va_end(ap); | |
3139 | |
3140 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3141 return 1; | |
3142 | |
4656 | 3143 /* We want to stop listening with a normal thingy */ |
3144 gaim_input_remove(xfer->watcher); | |
3145 xfer->watcher = 0; | |
3146 | |
4617 | 3147 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3148 | |
3149 return 0; | |
3630 | 3150 } |
4617 | 3151 |
3152 /* | |
3153 * We just sent a file to someone. They said they got it and everything, | |
3154 * so we can close our direct connection and what not. | |
3155 */ | |
3156 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3157 GaimConnection *gc = sess->aux_data; |
7283 | 3158 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3159 GaimXfer *xfer; |
4617 | 3160 va_list ap; |
3161 aim_conn_t *conn; | |
3162 fu8_t *cookie; | |
3163 struct aim_fileheader_t *fh; | |
4656 | 3164 |
8660 | 3165 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3166 va_start(ap, fr); |
3167 conn = va_arg(ap, aim_conn_t *); | |
3168 cookie = va_arg(ap, fu8_t *); | |
3169 fh = va_arg(ap, struct aim_fileheader_t *); | |
3170 va_end(ap); | |
3171 | |
3172 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3173 return 1; | |
3174 | |
4656 | 3175 xfer->fd = conn->fd; |
4617 | 3176 gaim_xfer_end(xfer); |
3177 | |
3178 return 0; | |
3179 } | |
3630 | 3180 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3181 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3182 GaimConnection *gc = sess->aux_data; |
7283 | 3183 OscarData *od = gc->proto_data; |
8708 | 3184 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3185 GaimConvImFlags flags = 0; |
4738 | 3186 struct buddyinfo *bi; |
5575 | 3187 const char *iconfile; |
9806 | 3188 GString *message; |
3189 gchar *tmp; | |
3190 aim_mpmsg_section_t *curpart; | |
3191 | |
3192 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3193 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3194 |
8708 | 3195 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3196 if (!bi) { |
3197 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3198 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3199 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3200 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3201 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3202 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3203 |
4738 | 3204 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3205 bi->typingnot = TRUE; | |
3206 else | |
3207 bi->typingnot = FALSE; | |
3208 | |
4380 | 3209 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3210 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3211 "%s has an icon\n", userinfo->sn); |
4738 | 3212 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3213 bi->ico_need = TRUE; | |
3214 bi->ico_len = args->iconlen; | |
3215 bi->ico_csum = args->iconsum; | |
3216 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3217 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3218 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3219 |
8708 | 3220 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3221 (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
|
3222 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3223 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3224 |
5575 | 3225 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3226 char *buf = g_malloc(st.st_size); |
5575 | 3227 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3228 if (file) { |
9532 | 3229 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3230 int len = fread(buf, 1, st.st_size, file); |
8660 | 3231 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3232 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3233 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3234 userinfo->sn, len, st.st_size); |
4617 | 3235 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3236 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3237 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3238 } else |
8660 | 3239 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3240 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3241 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3242 } else |
8660 | 3243 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3244 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3245 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3246 |
9806 | 3247 message = g_string_new(""); |
3248 curpart = args->mpmsg.parts; | |
3249 while (curpart != NULL) { | |
9908 | 3250 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3251 curpart->data, curpart->datalen); |
3252 if (tmp != NULL) { | |
3253 g_string_append(message, tmp); | |
3254 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3255 } |
9806 | 3256 |
3257 curpart = curpart->next; | |
3258 } | |
3259 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3260 |
8666 | 3261 /* |
8995 | 3262 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3263 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3264 * so any HTML we receive is intended to be displayed |
3265 * | |
3266 * Note: There *may* be some clients which send messages as HTML formatted - | |
3267 * they need to be special-cased somehow. | |
8666 | 3268 */ |
8995 | 3269 if (isdigit(gaim_account_get_username(account)[0]) && isdigit(userinfo->sn[0])) { |
3270 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ | |
3271 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3272 g_free(tmp); |
3273 tmp = tmp2; | |
3274 } | |
3275 | |
6982 | 3276 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3277 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3278 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3279 return 1; |
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 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3282 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3283 GaimConnection *gc; |
3284 OscarData *od; | |
3285 const char *username; | |
3286 | |
3287 g_return_val_if_fail(sess != NULL, 0); | |
3288 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3289 | |
3290 gc = sess->aux_data; | |
3291 od = gc->proto_data; | |
3292 username = gaim_account_get_username(gaim_connection_get_account(gc)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3293 |
4121 | 3294 if (!args) |
3295 return 0; | |
4194 | 3296 |
8660 | 3297 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3298 "rendezvous with %s, status is %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3299 userinfo->sn, args->status); |
2869 | 3300 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3301 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3302 char *name; |
5234 | 3303 GHashTable *components; |
3304 | |
4121 | 3305 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
3306 return 1; | |
5234 | 3307 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3308 g_free); | |
4121 | 3309 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3310 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3311 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
|
3312 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3313 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3314 userinfo->sn, |
6059 | 3315 args->msg, |
5234 | 3316 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3317 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3318 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3319 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3320 /* BBB */ |
3321 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3322 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3323 GaimXfer *xfer; |
5146 | 3324 struct aim_oft_info *oft_info; |
3325 | |
3326 if (!args->cookie || !args->port || !args->verifiedip || | |
3327 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3328 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3329 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3330 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3331 "information.\n", userinfo->sn); |
5146 | 3332 if (args->proxyip) |
8660 | 3333 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3334 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3335 "does not support this yet.\n"); |
4617 | 3336 return 1; |
4656 | 3337 } |
4617 | 3338 |
3339 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3340 /* 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
|
3341 * directory -- remove the star and trailing slash so we don't save |
4617 | 3342 * directories that look like 'dirname\*' -- arl */ |
3343 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3344 if (tmp && (tmp[1] == '*')) { | |
3345 tmp[0] = '\0'; | |
3346 } | |
8660 | 3347 gaim_debug_warning("oscar", |
8446 | 3348 "We're receiving a whole directory! What fun! " |
3349 "Especially since we don't support that!\n"); | |
4617 | 3350 } |
3351 | |
3352 /* Build the file transfer handle */ | |
3353 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3354 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3355 xfer->remote_port = args->port; |
4617 | 3356 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3357 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
5146 | 3358 |
3359 /* Create the oscar-specific data */ | |
5163 | 3360 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3361 if (args->proxyip) |
5146 | 3362 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3363 if (args->verifiedip) |
5146 | 3364 oft_info->verifiedip = g_strdup(args->verifiedip); |
3365 xfer->data = oft_info; | |
4617 | 3366 |
3367 /* Setup our I/O op functions */ | |
8446 | 3368 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3369 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3370 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
|
3371 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3372 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3373 |
3374 /* | |
3375 * XXX - Should do something with args->msg, args->encoding, and args->language | |
3376 * probably make it apply to all ch2 messages. | |
3752 | 3377 */ |
4617 | 3378 |
3379 /* Keep track of this transfer for later */ | |
3380 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3381 | |
3382 /* Now perform the request */ | |
3383 gaim_xfer_request(xfer); | |
3384 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3385 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3386 GaimXfer *xfer; |
8660 | 3387 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3388 "AAA - File transfer canceled by remote user\n"); |
4617 | 3389 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
|
3390 gaim_xfer_cancel_remote(xfer); |
4617 | 3391 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3392 /* | |
3393 * This gets sent by the receiver of a file | |
3394 * as they connect directly to us. If we don't | |
3395 * get this, then maybe a third party connected | |
3396 * to us, and we shouldn't send them anything. | |
3397 */ | |
3398 } else { | |
8660 | 3399 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3400 "unknown rendezvous status!\n"); |
3630 | 3401 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3402 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3403 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3404 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3405 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3406 userinfo->sn, args->info.icon.icon, |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3407 args->info.icon.length); |
6871 | 3408 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3409 /* 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
|
3410 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3411 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
|
3412 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3413 |
4212 | 3414 if (!args->verifiedip) { |
8983 | 3415 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3416 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3417 "directim kill blocked (%s)\n", userinfo->sn); |
4650 | 3418 return 1; |
4212 | 3419 } |
3420 | |
8660 | 3421 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3422 "%s received direct im request from %s (%s)\n", |
8983 | 3423 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3424 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3425 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3426 d->sn = g_strdup(userinfo->sn); |
8983 | 3427 /* Let's use the clientip here, because I think that's what AIM does. |
3428 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3429 * and then ask them to connect to us. */ | |
3430 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->clientip, args->port?args->port:5190); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3431 memcpy(d->cookie, args->cookie, 8); |
9070 | 3432 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3433 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3434 | |
8971 | 3435 oscar_direct_im_destroy(od, dim); |
8984 | 3436 d->donttryagain = TRUE; |
8971 | 3437 accept_direct_im_request(d); |
3438 } else { | |
8983 | 3439 if (dim && !dim->connected) |
8971 | 3440 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3441 "already connected to that buddy!"); | |
5575 | 3442 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
|
3443 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3444 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3445 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3446 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3447 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3448 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3449 "risk."), 0, d, 2, |
8971 | 3450 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3451 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3452 /* FIXME: we should actually send a packet on cancel */ | |
3453 } | |
8708 | 3454 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3455 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
|
3456 } else { |
8660 | 3457 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3458 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3459 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3460 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3461 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3462 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3463 |
3453 | 3464 /* |
4230 | 3465 * Authorization Functions |
3466 * Most of these are callbacks from dialogs. They're used by both | |
3467 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3468 */ |
4269 | 3469 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3470 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3471 GaimConnection *gc = data->gc; |
4244 | 3472 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3473 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3474 OscarData *od = gc->proto_data; |
6695 | 3475 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3476 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3477 if (buddy && group) { |
8660 | 3478 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3479 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3480 buddy->name, group->name); |
4889 | 3481 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3482 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3483 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3484 } |
4230 | 3485 } |
4337 | 3486 } |
3487 | |
3488 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3489 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3490 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3491 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3492 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3493 data); |
4230 | 3494 } |
3495 | |
3496 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3497 GaimConnection *gc = data->gc; |
4244 | 3498 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3499 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3500 /* Remove from local list */ |
3501 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3502 gaim_blist_remove_buddy(b); | |
4244 | 3503 } |
3504 | |
5836 | 3505 oscar_free_name_data(data); |
4230 | 3506 } |
3507 | |
9030 | 3508 |
3509 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3510 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3511 GaimBuddy *buddy; |
4269 | 3512 gchar *dialog_msg, *nombre; |
3513 | |
4687 | 3514 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3515 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3516 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3517 else |
4830 | 3518 nombre = NULL; |
3519 | |
3520 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 | 3521 data->gc = gc; |
3522 data->name = g_strdup(name); | |
3523 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3524 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3525 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3526 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3527 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3528 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3529 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3530 |
3531 g_free(dialog_msg); | |
3532 g_free(nombre); | |
3533 } | |
3534 | |
9030 | 3535 |
3536 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3537 GaimBuddy *buddy; | |
3538 GaimConnection *gc; | |
3539 | |
3540 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3541 | |
3542 buddy = (GaimBuddy *) node; | |
3543 gc = gaim_account_get_connection(buddy->account); | |
3544 gaim_auth_sendrequest(gc, buddy->name); | |
3545 } | |
3546 | |
4230 | 3547 /* When other people ask you for authorization */ |
3548 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3549 GaimConnection *gc = data->gc; |
4244 | 3550 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3551 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3552 OscarData *od = gc->proto_data; |
4236 | 3553 #ifdef NOSSI |
6695 | 3554 GaimBuddy *buddy; |
4244 | 3555 gchar message; |
3556 message = 0; | |
4687 | 3557 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3558 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3559 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3560 #else |
4889 | 3561 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3562 #endif |
4244 | 3563 } |
3564 | |
5836 | 3565 oscar_free_name_data(data); |
3141 | 3566 } |
3567 | |
4230 | 3568 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3569 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3570 GaimConnection *gc = data->gc; |
4244 | 3571 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3572 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3573 OscarData *od = gc->proto_data; |
4230 | 3574 #ifdef NOSSI |
4617 | 3575 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3576 #else |
4889 | 3577 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3578 #endif |
4244 | 3579 } |
4337 | 3580 } |
3581 | |
3582 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3583 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3584 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3585 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3586 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3587 data); |
3141 | 3588 } |
3589 | |
7023 | 3590 /* When someone sends you buddies */ |
3591 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3592 GaimConnection *gc = data->gc; |
4244 | 3593 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3594 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3595 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3596 } |
3597 | |
5836 | 3598 oscar_free_name_data(data); |
3453 | 3599 } |
3600 | |
4075 | 3601 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) { |
5575 | 3602 GaimConnection *gc = sess->aux_data; |
9908 | 3603 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3604 gchar **msg1, **msg2; |
6051 | 3605 int i, numtoks; |
4076 | 3606 |
4121 | 3607 if (!args->type || !args->msg || !args->uin) |
3608 return 1; | |
4194 | 3609 |
8660 | 3610 gaim_debug_info("oscar", |
9908 | 3611 "Received a channel 4 message of type 0x%02hhx.\n", |
3612 args->type); | |
4076 | 3613 |
3614 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 3615 msg1 = g_strsplit(args->msg, "\376", 0); |
6051 | 3616 for (numtoks=0; msg1[numtoks]; numtoks++); |
3617 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3618 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3619 gaim_str_strip_cr(msg1[i]); |
9908 | 3620 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3621 } |
3622 msg2[i] = NULL; | |
3623 | |
3952 | 3624 switch (args->type) { |
4173 | 3625 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3626 if (i >= 1) { |
5556 | 3627 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3628 gchar *tmp; |
3629 | |
3630 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3631 tmp = gaim_escape_html(msg2[0]); |
8493 | 3632 |
4076 | 3633 if (t) { /* This is an offline message */ |
9680 | 3634 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3635 #ifdef HAVE_TM_GMTOFF |
9724 | 3636 time_t now; |
3637 struct tm *tm; | |
3638 now = time(NULL); | |
3639 tm = localtime(&now); | |
3640 t += tm->tm_gmtoff; | |
9698 | 3641 #else |
3642 # ifdef HAVE_TIMEZONE | |
9680 | 3643 tzset(); |
3644 t -= timezone; | |
9698 | 3645 # endif |
3646 #endif | |
8514 | 3647 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3648 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3649 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3650 } |
3651 g_free(uin); | |
8493 | 3652 g_free(tmp); |
4075 | 3653 } |
3316 | 3654 } break; |
3655 | |
4173 | 3656 case 0x04: { /* Someone sent you a URL */ |
4076 | 3657 if (i >= 2) { |
7385 | 3658 if (msg2[1] != NULL) { |
3659 gchar *uin = g_strdup_printf("%u", args->uin); | |
3660 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3661 msg2[1], | |
3662 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3663 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3664 g_free(uin); | |
3665 g_free(message); | |
3666 } | |
3453 | 3667 } |
3668 } break; | |
3669 | |
4173 | 3670 case 0x06: { /* Someone requested authorization */ |
4076 | 3671 if (i >= 6) { |
4230 | 3672 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3673 gchar *dialog_msg = g_strdup_printf(_("The user %u wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); |
8660 | 3674 gaim_debug_info("oscar", |
5556 | 3675 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3676 args->uin); |
4076 | 3677 data->gc = gc; |
5556 | 3678 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3679 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3680 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3681 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3682 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3683 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3684 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3685 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3686 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3687 g_free(dialog_msg); |
3688 } | |
3141 | 3689 } break; |
3690 | |
4173 | 3691 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3692 if (i >= 1) { |
7023 | 3693 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
|
3694 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3695 dialog_msg); |
4076 | 3696 g_free(dialog_msg); |
3697 } | |
3141 | 3698 } break; |
3699 | |
4173 | 3700 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3701 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
|
3702 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3703 dialog_msg); |
3141 | 3704 g_free(dialog_msg); |
3705 } break; | |
3706 | |
4333 | 3707 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3708 if (i >= 5) { | |
3709 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
|
3710 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3711 g_free(dialog_msg); |
3712 } | |
3713 } break; | |
3714 | |
4173 | 3715 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3716 if (i >= 6) { |
4194 | 3717 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
|
3718 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3719 g_free(dialog_msg); |
3720 } | |
4075 | 3721 } break; |
3722 | |
4173 | 3723 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3724 if (i >= 6) { |
4308 | 3725 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
|
3726 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3727 g_free(dialog_msg); |
3728 } | |
4075 | 3729 } break; |
3730 | |
4173 | 3731 case 0x12: { |
3141 | 3732 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3733 /* Someone added you to their buddy list? */ |
3141 | 3734 } break; |
3735 | |
7023 | 3736 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3737 guint i, num; |
3453 | 3738 gchar **text; |
4173 | 3739 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3740 if (text) { |
3741 num = 0; | |
3742 for (i=0; i<strlen(text[0]); i++) | |
3743 num = num*10 + text[0][i]-48; | |
3744 for (i=0; i<num; i++) { | |
4230 | 3745 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3746 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 | 3747 data->gc = gc; |
4790 | 3748 data->name = g_strdup(text[i*2+1]); |
3749 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3750 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3751 gaim_request_action(gc, NULL, message, |
7023 | 3752 _("Do you want to add this buddy " |
3753 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3754 0, data, 2, |
7023 | 3755 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3756 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3757 g_free(message); |
3758 } | |
3759 g_strfreev(text); | |
3760 } | |
3761 } break; | |
3762 | |
7023 | 3763 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3764 /* This is boring and silly. */ |
3765 } break; | |
3766 | |
3141 | 3767 default: { |
8660 | 3768 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3769 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3770 "(type 0x%02hhx).\n", args->type); |
3141 | 3771 } break; |
3772 } | |
3773 | |
4076 | 3774 g_strfreev(msg1); |
3775 g_strfreev(msg2); | |
3776 | |
3141 | 3777 return 1; |
3778 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3779 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3780 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3781 fu16_t channel; |
3782 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3783 aim_userinfo_t *userinfo; |
2086 | 3784 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3785 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3786 va_start(ap, fr); |
4200 | 3787 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3788 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3789 |
3141 | 3790 switch (channel) { |
3791 case 1: { /* standard message */ | |
3792 struct aim_incomingim_ch1_args *args; | |
3793 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3794 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3795 } break; | |
3796 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3797 case 2: { /* rendezvous */ |
3141 | 3798 struct aim_incomingim_ch2_args *args; |
3799 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3800 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3801 } break; | |
3802 | |
3803 case 4: { /* ICQ */ | |
3804 struct aim_incomingim_ch4_args *args; | |
3805 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3806 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3807 } break; |
3808 | |
3809 default: { | |
8660 | 3810 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3811 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3812 "0x%04hx).", channel); |
3141 | 3813 } break; |
2086 | 3814 } |
3815 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3816 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3817 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3818 return ret; |
2086 | 3819 } |
3820 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3821 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3822 GaimConnection *gc = sess->aux_data; |
3823 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3824 char *buf; |
2086 | 3825 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3826 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3827 aim_userinfo_t *userinfo; |
2086 | 3828 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3829 va_start(ap, fr); |
4200 | 3830 chan = (fu16_t)va_arg(ap, unsigned int); |
3831 userinfo = va_arg(ap, aim_userinfo_t *); | |
3832 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3833 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3834 va_end(ap); |
3835 | |
3836 switch(reason) { | |
5420 | 3837 case 0: /* Invalid (0) */ |
3838 buf = g_strdup_printf( | |
3839 ngettext( | |
4276 | 3840 "You missed %hu message from %s because it was invalid.", |
3841 "You missed %hu messages from %s because they were invalid.", | |
3842 nummissed), | |
4282 | 3843 nummissed, |
3844 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3845 break; |
5420 | 3846 case 1: /* Message too large */ |
3847 buf = g_strdup_printf( | |
3848 ngettext( | |
4276 | 3849 "You missed %hu message from %s because it was too large.", |
3850 "You missed %hu messages from %s because they were too large.", | |
3851 nummissed), | |
4282 | 3852 nummissed, |
3853 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3854 break; |
5420 | 3855 case 2: /* Rate exceeded */ |
3856 buf = g_strdup_printf( | |
3857 ngettext( | |
4276 | 3858 "You missed %hu message from %s because the rate limit has been exceeded.", |
3859 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3860 nummissed), | |
4282 | 3861 nummissed, |
3862 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3863 break; |
5420 | 3864 case 3: /* Evil Sender */ |
3865 buf = g_strdup_printf( | |
3866 ngettext( | |
4276 | 3867 "You missed %hu message from %s because he/she was too evil.", |
3868 "You missed %hu messages from %s because he/she was too evil.", | |
3869 nummissed), | |
4282 | 3870 nummissed, |
3871 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3872 break; |
5420 | 3873 case 4: /* Evil Receiver */ |
3874 buf = g_strdup_printf( | |
3875 ngettext( | |
4276 | 3876 "You missed %hu message from %s because you are too evil.", |
3877 "You missed %hu messages from %s because you are too evil.", | |
3878 nummissed), | |
4282 | 3879 nummissed, |
3880 userinfo->sn); | |
2086 | 3881 break; |
3882 default: | |
5420 | 3883 buf = g_strdup_printf( |
3884 ngettext( | |
4276 | 3885 "You missed %hu message from %s for an unknown reason.", |
3886 "You missed %hu messages from %s for an unknown reason.", | |
3887 nummissed), | |
4282 | 3888 nummissed, |
3889 userinfo->sn); | |
2086 | 3890 break; |
3891 } | |
8733 | 3892 |
9627 | 3893 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3894 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3895 g_free(buf); |
2086 | 3896 |
3897 return 1; | |
3898 } | |
3899 | |
4194 | 3900 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3901 GaimConnection *gc = sess->aux_data; |
7283 | 3902 OscarData *od = gc->proto_data; |
4617 | 3903 |
3904 /* BBB */ | |
3630 | 3905 switch (reason) { |
4151 | 3906 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3907 GaimXfer *xfer; |
8971 | 3908 struct oscar_direct_im *dim; |
3909 | |
8660 | 3910 gaim_debug_info("oscar", |
9070 | 3911 "AAA - Other user declined some sort of direct " |
8971 | 3912 "connect attempt (automaticly?)\n"); |
4617 | 3913 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
|
3914 gaim_xfer_cancel_remote(xfer); |
8971 | 3915 else if ((dim = oscar_direct_im_find(od, who))) { |
3916 /* AAA should use find by cookie or something here */ | |
3917 oscar_direct_im_disconnect(od, dim); | |
3918 } | |
4151 | 3919 } break; |
3920 | |
3921 default: { | |
8660 | 3922 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3923 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3924 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3925 } |
3630 | 3926 |
3927 } | |
3928 | |
3929 return 0; | |
3930 } | |
3931 | |
4194 | 3932 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3933 GaimConnection *gc = sess->aux_data; |
4151 | 3934 |
3935 switch(reason) { | |
3936 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3937 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3938 | |
3939 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3940 |
3941 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3942 statusmsg = oscar_icqstatus(state); |
4151 | 3943 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3944 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3945 g_free(statusmsg); | |
4151 | 3946 g_strfreev(splitmsg); |
9244 | 3947 |
9797 | 3948 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 3949 |
3950 g_free(title); | |
3951 g_free(dialogmsg); | |
4151 | 3952 } break; |
3953 | |
3954 default: { | |
8660 | 3955 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3956 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3957 "Type 0x%04hx\n", who, reason); |
4151 | 3958 } break; |
3959 } /* end of switch */ | |
3960 | |
3961 return 0; | |
3962 } | |
3963 | |
3212 | 3964 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
3965 va_list ap; | |
3966 fu16_t chan, reason; | |
3967 char *who; | |
3968 | |
3969 va_start(ap, fr); | |
4200 | 3970 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3971 who = va_arg(ap, char *); |
4200 | 3972 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3973 |
3952 | 3974 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 3975 char *cookie = va_arg(ap, char *); |
4151 | 3976 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 3977 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 3978 fu32_t state = 0; |
4151 | 3979 char *msg = NULL; |
3980 if (reason == 0x0003) { | |
4200 | 3981 state = va_arg(ap, fu32_t); |
4151 | 3982 msg = va_arg(ap, char *); |
3983 } | |
3984 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
3985 } | |
3952 | 3986 |
3212 | 3987 va_end(ap); |
3988 | |
3989 return 1; | |
3990 } | |
3991 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3992 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3993 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3994 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3995 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3996 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3997 va_start(ap, fr); |
4199 | 3998 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3999 va_end(ap); |
4000 | |
8660 | 4001 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4002 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4003 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4004 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4005 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4006 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4007 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4008 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4009 |
2086 | 4010 return 1; |
4011 } | |
4012 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4013 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4014 GaimConnection *gc = sess->aux_data; |
4617 | 4015 #if 0 |
7283 | 4016 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4017 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4018 #endif |
4617 | 4019 va_list ap; |
4020 fu16_t reason; | |
4021 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4022 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4023 va_start(ap, fr); |
4617 | 4024 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4025 data = va_arg(ap, char *); |
2086 | 4026 va_end(ap); |
4027 | |
8660 | 4028 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4029 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 4030 |
4031 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4032 #if 0 |
4617 | 4033 /* If this was a file transfer request, data is a cookie */ |
4034 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
|
4035 gaim_xfer_cancel_remote(xfer); |
3630 | 4036 return 1; |
4037 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4038 #endif |
3630 | 4039 |
4617 | 4040 /* Data is assumed to be the destination sn */ |
9826 | 4041 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4042 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4043 g_free(buf); | |
4044 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4045 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4046 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4047 } | |
4048 g_free(buf); | |
4049 | |
2086 | 4050 return 1; |
4051 } | |
4052 | |
3595 | 4053 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4054 GaimConnection *gc = sess->aux_data; |
3595 | 4055 va_list ap; |
4056 fu16_t type1, type2; | |
4057 char *sn; | |
4058 | |
4059 va_start(ap, fr); | |
4199 | 4060 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4061 sn = va_arg(ap, char *); |
4199 | 4062 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4063 va_end(ap); |
4064 | |
4065 switch (type2) { | |
4066 case 0x0000: { /* Text has been cleared */ | |
4067 serv_got_typing_stopped(gc, sn); | |
4068 } break; | |
4069 | |
4070 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4071 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4072 } break; |
4073 | |
4074 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4075 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4076 } break; |
4077 | |
4078 default: { | |
8660 | 4079 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 | 4080 } break; |
4081 } | |
4082 | |
4083 return 1; | |
4084 } | |
4085 | |
7141 | 4086 /* |
4087 * We get this error when there was an error in the locate family. This | |
7259 | 4088 * happens when you request info of someone who is offline. |
7141 | 4089 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4090 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4091 gchar *buf; |
2086 | 4092 va_list ap; |
5420 | 4093 fu16_t reason; |
2086 | 4094 char *destn; |
4095 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4096 va_start(ap, fr); |
4199 | 4097 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4098 destn = va_arg(ap, char *); |
4099 va_end(ap); | |
4100 | |
7781 | 4101 if (destn == NULL) |
7793 | 4102 return 1; |
9627 | 4103 |
9826 | 4104 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4105 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4106 g_free(buf); | |
9627 | 4107 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4108 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4109 } | |
4110 g_free(buf); | |
2086 | 4111 |
4112 return 1; | |
4113 } | |
4114 | |
7011 | 4115 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4116 GaimConnection *gc = sess->aux_data; |
8700 | 4117 GaimAccount *account = gaim_connection_get_account(gc); |
4118 GString *str; | |
9244 | 4119 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4120 va_list ap; |
7011 | 4121 aim_userinfo_t *userinfo; |
2086 | 4122 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4123 va_start(ap, fr); |
7011 | 4124 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4125 va_end(ap); |
4126 | |
8700 | 4127 str = g_string_new(""); |
4128 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4129 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4130 |
4131 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 4132 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 4133 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 4134 |
4135 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 4136 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 4137 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 4138 |
4139 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4140 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4141 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4142 g_free(tmp); |
4143 } | |
4144 | |
8701 | 4145 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4146 |
4147 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4148 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4149 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4150 g_free(tmp); | |
7011 | 4151 if (away_utf8 != NULL) { |
8700 | 4152 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4153 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4154 } |
7011 | 4155 } |
4156 | |
4157 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4158 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4159 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4160 g_free(tmp); | |
7011 | 4161 if (info_utf8 != NULL) { |
8700 | 4162 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4163 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4164 } |
7011 | 4165 } |
4166 | |
8701 | 4167 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4168 g_string_free(str, TRUE); |
9244 | 4169 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4170 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4171 g_free(title); |
8700 | 4172 g_free(tmp); |
4151 | 4173 |
2086 | 4174 return 1; |
4175 } | |
4176 | |
8341 | 4177 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4178 { | |
4179 aim_session_t *sess = data; | |
4180 GaimConnection *gc = sess->aux_data; | |
4181 OscarData *od = (OscarData *)gc->proto_data; | |
4182 | |
4183 aim_locate_dorequest(data); | |
4184 od->getinfotimer = 0; | |
4185 | |
4186 return FALSE; | |
4187 } | |
4188 | |
4189 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4190 { | |
4191 GaimConnection *gc = sess->aux_data; | |
4192 OscarData *od = (OscarData *)gc->proto_data; | |
4193 | |
4194 /* | |
4195 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4196 * us from hitting the rate limit due to request away messages and info | |
4197 * too quickly. | |
4198 */ | |
4199 if (od->getinfotimer == 0) | |
4200 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4201 | |
4202 return 1; | |
4203 } | |
4204 | |
4205 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4206 { | |
2086 | 4207 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4208 fu16_t id; |
2086 | 4209 va_list ap; |
4210 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4211 va_start(ap, fr); |
4199 | 4212 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4213 msg = va_arg(ap, char *); |
4214 va_end(ap); | |
4215 | |
8660 | 4216 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4217 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4218 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4219 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4220 _("Your AIM connection may be lost."), NULL); |
2086 | 4221 |
4222 return 1; | |
4223 } | |
4224 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4225 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4226 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4227 fu16_t type; |
5575 | 4228 GaimConnection *gc = sess->aux_data; |
7283 | 4229 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4230 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4231 va_start(ap, fr); |
4199 | 4232 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4233 |
4234 switch(type) { | |
4235 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4236 fu8_t maxrooms; |
2086 | 4237 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4238 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4239 |
4199 | 4240 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4241 exchangecount = va_arg(ap, int); |
4242 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4243 | |
8660 | 4244 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4245 "chat info: Chat Rights:\n"); |
8660 | 4246 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4247 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4248 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4249 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4250 for (i = 0; i < exchangecount; i++) |
8660 | 4251 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4252 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4253 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4254 while (od->create_rooms) { |
4255 struct create_room *cr = od->create_rooms->data; | |
8660 | 4256 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4257 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4258 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4259 g_free(cr->name); |
4617 | 4260 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4261 g_free(cr); |
2086 | 4262 } |
4263 } | |
4264 break; | |
4265 case 0x0008: { | |
4266 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4267 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4268 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4269 fu32_t createtime; |
2086 | 4270 |
4271 fqcn = va_arg(ap, char *); | |
4200 | 4272 instance = (fu16_t)va_arg(ap, unsigned int); |
4273 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4274 flags = (fu16_t)va_arg(ap, unsigned int); | |
4275 createtime = va_arg(ap, fu32_t); | |
4276 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4277 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4278 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4279 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4280 name = va_arg(ap, char *); | |
4281 ck = va_arg(ap, char *); | |
4194 | 4282 |
8660 | 4283 gaim_debug_misc("oscar", |
5556 | 4284 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4285 fqcn, |
4286 exchange, instance, flags, | |
4287 createtime, | |
4288 maxmsglen, maxoccupancy, createperms, unknown, | |
4289 name, ck); | |
4617 | 4290 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4291 } |
4292 break; | |
4293 default: | |
8660 | 4294 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4295 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4296 break; |
4297 } | |
4194 | 4298 |
4299 va_end(ap); | |
4300 | |
2086 | 4301 return 1; |
4302 } | |
4303 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4304 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4305 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4306 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4307 aim_userinfo_t *info; |
5575 | 4308 GaimConnection *g = sess->aux_data; |
2086 | 4309 |
4310 struct chat_connection *c = NULL; | |
4311 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4312 va_start(ap, fr); |
2086 | 4313 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4314 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4315 va_end(ap); |
4316 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4317 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4318 if (!c) |
4319 return 1; | |
4320 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4321 for (i = 0; i < count; i++) |
9846 | 4322 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4323 |
4324 return 1; | |
4325 } | |
4326 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4327 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4328 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4329 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4330 aim_userinfo_t *info; |
5575 | 4331 GaimConnection *g = sess->aux_data; |
2086 | 4332 |
4333 struct chat_connection *c = NULL; | |
4334 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4335 va_start(ap, fr); |
2086 | 4336 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4337 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4338 va_end(ap); |
4339 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4340 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4341 if (!c) |
4342 return 1; | |
4343 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4344 for (i = 0; i < count; i++) |
8733 | 4345 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4346 |
4347 return 1; | |
4348 } | |
4349 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4350 static int gaim_conv_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4351 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4352 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4353 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4354 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4355 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4356 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4357 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4358 fu32_t creationtime; |
5575 | 4359 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4360 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
|
4361 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4362 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4363 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4364 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4365 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4366 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4367 roomdesc = va_arg(ap, char *); |
4200 | 4368 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4369 creationtime = va_arg(ap, fu32_t); | |
4370 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4371 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4372 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4373 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4374 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4375 |
8660 | 4376 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4377 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4378 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4379 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4380 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4381 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4382 |
2086 | 4383 return 1; |
4384 } | |
4385 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4386 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4387 GaimConnection *gc = sess->aux_data; |
8225 | 4388 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4389 gchar *utf8; | |
2086 | 4390 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4391 aim_userinfo_t *info; |
8225 | 4392 int len; |
2086 | 4393 char *msg; |
8219 | 4394 char *charset; |
2086 | 4395 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4396 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4397 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4398 len = va_arg(ap, int); |
4194 | 4399 msg = va_arg(ap, char *); |
8219 | 4400 charset = va_arg(ap, char *); |
4194 | 4401 va_end(ap); |
2086 | 4402 |
8225 | 4403 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4404 if (utf8 == NULL) |
4405 /* The conversion failed! */ | |
8668 | 4406 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4407 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4408 g_free(utf8); | |
2086 | 4409 |
4410 return 1; | |
4411 } | |
4412 | |
3694 | 4413 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4414 va_list ap; | |
5575 | 4415 GaimConnection *gc = sess->aux_data; |
3694 | 4416 struct aim_emailinfo *emailinfo; |
3725 | 4417 int havenewmail; |
7297 | 4418 char *alertitle, *alerturl; |
3694 | 4419 |
4420 va_start(ap, fr); | |
4421 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4422 havenewmail = va_arg(ap, int); |
7301 | 4423 alertitle = va_arg(ap, char *); |
4424 alerturl = va_arg(ap, char *); | |
3694 | 4425 va_end(ap); |
4426 | |
9661 | 4427 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4428 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4429 emailinfo->domain ? "@" : "", | |
4430 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4431 if (emailinfo->unread && havenewmail) |
4432 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4433 g_free(to); |
3694 | 4434 } |
7297 | 4435 |
7301 | 4436 if (alertitle) |
8660 | 4437 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4438 |
4439 return 1; | |
4440 } | |
4441 | |
4804 | 4442 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4443 GaimConnection *gc = sess->aux_data; |
7283 | 4444 OscarData *od = gc->proto_data; |
4804 | 4445 char *sn; |
4446 | |
4447 sn = od->requesticon->data; | |
8660 | 4448 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4449 "removing %s from hash table\n", sn); |
4804 | 4450 od->requesticon = g_slist_remove(od->requesticon, sn); |
4451 free(sn); | |
4452 | |
4453 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4454 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4455 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4456 |
4457 return 1; | |
4458 } | |
4459 | |
4460 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4461 GaimConnection *gc = sess->aux_data; |
7283 | 4462 OscarData *od = gc->proto_data; |
4804 | 4463 GSList *cur; |
4464 va_list ap; | |
4465 char *sn; | |
4853 | 4466 fu8_t *iconcsum, *icon; |
4467 fu16_t iconcsumlen, iconlen; | |
4804 | 4468 |
4469 va_start(ap, fr); | |
4470 sn = va_arg(ap, char *); | |
4853 | 4471 iconcsum = va_arg(ap, fu8_t *); |
4472 iconcsumlen = va_arg(ap, int); | |
4804 | 4473 icon = va_arg(ap, fu8_t *); |
4474 iconlen = va_arg(ap, int); | |
4475 va_end(ap); | |
4476 | |
4853 | 4477 if (iconlen > 0) { |
4478 char *b16; | |
6695 | 4479 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4480 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4481 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4482 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4483 if (b16) { |
7693 | 4484 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4485 g_free(b16); |
5129 | 4486 } |
4853 | 4487 } |
4804 | 4488 |
4489 cur = od->requesticon; | |
4490 while (cur) { | |
4491 char *cursn = cur->data; | |
4492 if (!aim_sncmp(cursn, sn)) { | |
4493 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4494 free(cursn); | |
4495 cur = od->requesticon; | |
4496 } else | |
4497 cur = cur->next; | |
4498 } | |
4499 | |
4500 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4501 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4502 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4503 |
4504 return 1; | |
4505 } | |
4506 | |
4507 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4508 GaimConnection *gc = data; |
7283 | 4509 OscarData *od = gc->proto_data; |
7011 | 4510 aim_userinfo_t *userinfo; |
4804 | 4511 aim_conn_t *conn; |
4512 | |
4513 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4514 if (!conn) { |
4515 if (!od->iconconnecting) { | |
4516 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4517 od->iconconnecting = TRUE; | |
4518 } | |
4804 | 4519 return FALSE; |
4520 } | |
4521 | |
5842 | 4522 if (od->set_icon) { |
6039 | 4523 struct stat st; |
4524 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4525 if (iconfile == NULL) { | |
8363 | 4526 aim_ssi_delicon(od->sess); |
6039 | 4527 } else if (!stat(iconfile, &st)) { |
4528 char *buf = g_malloc(st.st_size); | |
4529 FILE *file = fopen(iconfile, "rb"); | |
4530 if (file) { | |
9532 | 4531 /* XXX - Use g_file_get_contents()? */ |
6039 | 4532 fread(buf, 1, st.st_size, file); |
4533 fclose(file); | |
8660 | 4534 gaim_debug_info("oscar", |
6039 | 4535 "Uploading icon to icon server\n"); |
6879 | 4536 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4537 } else |
8660 | 4538 gaim_debug_error("oscar", |
6039 | 4539 "Can't open buddy icon file!\n"); |
4540 g_free(buf); | |
4541 } else { | |
8660 | 4542 gaim_debug_error("oscar", |
6039 | 4543 "Can't stat buddy icon file!\n"); |
5842 | 4544 } |
4545 od->set_icon = FALSE; | |
4546 } | |
4547 | |
4548 if (!od->requesticon) { | |
8660 | 4549 gaim_debug_misc("oscar", |
5842 | 4550 "no more icons to request\n"); |
4551 return FALSE; | |
4552 } | |
4553 | |
7045 | 4554 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4555 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4556 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4557 return FALSE; |
4558 } else { | |
4559 char *sn = od->requesticon->data; | |
4560 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4561 free(sn); | |
4562 } | |
4563 | |
4564 return TRUE; | |
4565 } | |
4566 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4567 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4568 * 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
|
4569 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4570 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4571 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4572 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4573 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4574 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4575 va_start(ap, fr); |
4199 | 4576 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4577 sn = va_arg(ap, char *); |
4578 va_end(ap); | |
4579 | |
8660 | 4580 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4581 |
4582 return 1; | |
4583 } | |
4584 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4585 static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4586 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4587 "invalid", |
4194 | 4588 "change", |
4589 "warning", | |
4590 "limit", | |
4591 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4592 }; |
2086 | 4593 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4594 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4595 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4596 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4597 va_start(ap, fr); |
4200 | 4598 code = (fu16_t)va_arg(ap, unsigned int); |
4599 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4600 windowsize = va_arg(ap, fu32_t); | |
4601 clear = va_arg(ap, fu32_t); | |
4602 alert = va_arg(ap, fu32_t); | |
4603 limit = va_arg(ap, fu32_t); | |
4604 disconnect = va_arg(ap, fu32_t); | |
4605 currentavg = va_arg(ap, fu32_t); | |
4606 maxavg = va_arg(ap, fu32_t); | |
2086 | 4607 va_end(ap); |
4608 | |
8660 | 4609 gaim_debug_misc("oscar", |
5556 | 4610 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4611 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4612 (code < 5) ? codes[code] : codes[0], |
4613 rateclass, | |
4614 currentavg, maxavg, | |
4615 alert, clear, | |
4616 limit, disconnect, | |
4617 windowsize); | |
4618 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4619 /* XXX fix these values */ |
2086 | 4620 if (code == AIM_RATE_CODE_CHANGE) { |
4621 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4622 aim_conn_setlatency(fr->conn, 0); |
2086 | 4623 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4624 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4625 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4626 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4627 _("The last action you attempted could not be " |
4628 "performed because you are over the rate limit. " | |
4629 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4630 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4631 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4632 aim_conn_setlatency(fr->conn, 0); |
2086 | 4633 } |
4634 | |
4635 return 1; | |
4636 } | |
4637 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4638 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4639 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4640 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4641 aim_userinfo_t *userinfo; |
5575 | 4642 GaimConnection *gc = sess->aux_data; |
2086 | 4643 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4644 va_start(ap, fr); |
4199 | 4645 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4646 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4647 va_end(ap); |
4648 | |
7111 | 4649 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 4650 |
4651 return 1; | |
4652 } | |
4653 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4654 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4655 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4656 aim_userinfo_t *info; |
5575 | 4657 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4658 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4659 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4660 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4661 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4662 |
5628 | 4663 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 4664 |
7872 | 4665 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 4666 gc->login_time_official = info->onlinesince; |
7872 | 4667 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
4668 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4669 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4670 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4671 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4672 |
4649 | 4673 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4674 GaimConnection *gc = sess->aux_data; |
7283 | 4675 OscarData *od = gc->proto_data; |
4649 | 4676 va_list ap; |
4677 fu16_t code; | |
4678 char *msg; | |
4679 | |
4680 va_start(ap, fr); | |
4681 code = (fu16_t)va_arg(ap, int); | |
4682 msg = va_arg(ap, char *); | |
4683 va_end(ap); | |
4684 | |
8660 | 4685 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4686 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4687 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4688 if (code == 0x0001) { |
6113 | 4689 gc->wants_to_die = TRUE; |
5579 | 4690 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4691 } else { |
5579 | 4692 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4693 } |
4666 | 4694 od->killme = TRUE; |
4649 | 4695 } |
4696 | |
4697 return 1; | |
4698 } | |
4699 | |
2675 | 4700 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4701 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4702 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4703 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4704 |
4705 #ifndef NOSSI | |
8660 | 4706 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4707 aim_ssi_reqrights(sess); |
6350 | 4708 aim_ssi_reqdata(sess); |
4230 | 4709 #endif |
4710 | |
7011 | 4711 aim_locate_reqrights(sess); |
7285 | 4712 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4713 aim_im_reqparams(sess); |
7334 | 4714 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4715 |
4716 #ifdef NOSSI | |
8660 | 4717 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4718 aim_bos_reqrights(sess, fr->conn); |
4230 | 4719 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4720 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4721 #endif | |
2086 | 4722 |
7283 | 4723 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4724 | |
2086 | 4725 return 1; |
4726 } | |
4727 | |
2675 | 4728 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4729 GaimConnection *gc = sess->aux_data; |
7283 | 4730 OscarData *od = gc->proto_data; |
2647 | 4731 |
6905 | 4732 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4733 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4734 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4735 | |
2672 | 4736 aim_clientready(sess, fr->conn); |
8660 | 4737 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4738 |
2647 | 4739 if (od->chpass) { |
8660 | 4740 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4741 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4742 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4743 od->oldp = NULL; |
2647 | 4744 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4745 od->newp = NULL; |
2647 | 4746 od->chpass = FALSE; |
4747 } | |
2979 | 4748 if (od->setnick) { |
8660 | 4749 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4750 aim_admin_setnick(sess, fr->conn, od->newsn); |
4751 g_free(od->newsn); | |
4752 od->newsn = NULL; | |
4753 od->setnick = FALSE; | |
4754 } | |
2647 | 4755 if (od->conf) { |
8660 | 4756 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4757 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4758 od->conf = FALSE; |
4759 } | |
4760 if (od->reqemail) { | |
8660 | 4761 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4762 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4763 od->reqemail = FALSE; |
4764 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4765 if (od->setemail) { |
8660 | 4766 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4767 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4768 g_free(od->email); |
5497 | 4769 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4770 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4771 } |
2647 | 4772 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4773 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4774 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4775 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4776 static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4777 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4778 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4779 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4780 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4781 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4782 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4783 |
4194 | 4784 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4785 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4786 "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
|
4787 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4788 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4789 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4790 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4791 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4792 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4793 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4794 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4795 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4796 |
4617 | 4797 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4798 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4799 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4800 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4801 |
2993 | 4802 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4803 { | |
5575 | 4804 GaimConnection *gc = sess->aux_data; |
7283 | 4805 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4806 va_list ap; |
4807 fu16_t maxsiglen; | |
2993 | 4808 |
4809 va_start(ap, fr); | |
4199 | 4810 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4811 va_end(ap); |
4812 | |
8660 | 4813 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4814 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4815 |
4617 | 4816 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4817 | |
4818 if (od->icq) | |
7334 | 4819 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4820 else |
7334 | 4821 aim_locate_setcaps(od->sess, caps_aim); |
4822 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4823 |
4824 return 1; | |
4825 } | |
4826 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4827 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4828 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4829 fu16_t maxbuddies, maxwatchers; |
5575 | 4830 GaimConnection *gc = sess->aux_data; |
7283 | 4831 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4832 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4833 va_start(ap, fr); |
4199 | 4834 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4835 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4836 va_end(ap); |
4837 | |
8660 | 4838 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4839 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4840 |
4617 | 4841 od->rights.maxbuddies = (guint)maxbuddies; |
4842 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4843 |
2086 | 4844 return 1; |
4845 } | |
4846 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4847 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4848 GaimConnection *gc = sess->aux_data; |
7283 | 4849 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4850 va_list ap; |
4851 fu16_t maxpermits, maxdenies; | |
2086 | 4852 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4853 va_start(ap, fr); |
4199 | 4854 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4855 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4856 va_end(ap); |
4857 | |
8660 | 4858 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4859 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4860 |
4617 | 4861 od->rights.maxpermits = (guint)maxpermits; |
4862 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4863 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4864 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4865 serv_finish_login(gc); |
4866 | |
8660 | 4867 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4868 |
2672 | 4869 aim_clientready(sess, fr->conn); |
5948 | 4870 aim_srv_setavailmsg(sess, NULL); |
7474 | 4871 aim_srv_setidle(sess, 0); |
4617 | 4872 |
4664 | 4873 if (od->icq) { |
4874 aim_icq_reqofflinemsgs(sess); | |
4875 aim_icq_hideip(sess); | |
4876 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4877 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4878 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4879 if (sess->authinfo->email) |
4880 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4881 |
4882 return 1; | |
4883 } | |
4884 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4885 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4886 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4887 struct aim_icq_offlinemsg *msg; |
4075 | 4888 struct aim_incomingim_ch4_args args; |
4889 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4890 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4891 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4892 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4893 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4894 |
8660 | 4895 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4896 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4897 args.uin = msg->sender; |
4898 args.type = msg->type; | |
4173 | 4899 args.flags = msg->flags; |
4076 | 4900 args.msglen = msg->msglen; |
4075 | 4901 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4902 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4903 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4904 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4905 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4906 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4907 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4908 static int gaim_offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4909 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4910 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4911 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4912 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4913 |
7388 | 4914 #if 0 |
4915 /* | |
7465 | 4916 * Update, 2003-11-09: |
4917 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4918 * | |
7388 | 4919 * It may not be my place to do this, but... |
4920 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4921 * stupid, and should not exist for % switches (%x in our case) that request | |
4922 * a year in the preferred representation for the current locale. For that | |
4923 * reason I've chosen to not use this workaround (n., see kluge). | |
4924 * | |
4925 * I have a date. I want to show it to the user in the "preferred" way. | |
4926 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4927 * what the locale wanted. | |
4928 * | |
4929 * If I have a necessity for a full representation of the year in the current | |
4930 * locale, then I'll use a switch that returns a full representation of the | |
4931 * year. | |
4932 * | |
4933 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4934 * (because you're anal, or whatever), then change the f***ing locale. | |
4935 * | |
4936 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4937 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4938 * |
4939 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4940 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4941 */ |
4942 | |
4943 /* | |
4944 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4945 * "last 2 digits" warning. |
4946 */ | |
4947 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4948 const struct tm *tm) | |
4949 { | |
4950 return strftime(s, max, fmt, tm); | |
4951 } | |
7388 | 4952 #endif |
7386 | 4953 |
4624 | 4954 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4955 { |
5575 | 4956 GaimConnection *gc = sess->aux_data; |
8670 | 4957 OscarData *od = (OscarData *)gc->proto_data; |
4958 GaimBuddy *buddy; | |
8853 | 4959 struct buddyinfo *bi = NULL; |
4624 | 4960 gchar who[16]; |
8670 | 4961 GString *str; |
4962 gchar *primary, *utf8; | |
9634 | 4963 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4964 va_list ap; |
4151 | 4965 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4966 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4967 va_start(ap, fr); |
4151 | 4968 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4969 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4970 |
4664 | 4971 if (!info->uin) |
4972 return 0; | |
4973 | |
8670 | 4974 str = g_string_sized_new(100); |
5556 | 4975 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 4976 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
4977 if (buddy != NULL) | |
4978 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
4979 | |
4980 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 4981 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 4982 if ((bi != NULL) && (bi->ipaddr != 0)) { |
4983 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
4984 (bi->ipaddr & 0xff000000) >> 24, | |
4985 (bi->ipaddr & 0x00ff0000) >> 16, | |
4986 (bi->ipaddr & 0x0000ff00) >> 8, | |
4987 (bi->ipaddr & 0x000000ff)); | |
8701 | 4988 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 4989 g_free(tstr); |
4990 } | |
8701 | 4991 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
4992 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4993 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 4994 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
4995 g_free(utf8); | |
4625 | 4996 } |
4997 if (info->numaddresses && info->email2) { | |
4998 int i; | |
4999 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5000 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5001 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5002 g_free(utf8); | |
4643 | 5003 } |
4625 | 5004 } |
4624 | 5005 } |
8701 | 5006 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
8902 | 5007 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
5008 info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5009 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5010 char date[30]; |
5011 struct tm tm; | |
5012 tm.tm_mday = (int)info->birthday; | |
5013 tm.tm_mon = (int)info->birthmonth-1; | |
5014 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5015 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5016 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5017 } |
4624 | 5018 if (info->age) { |
5019 char age[5]; | |
5020 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5021 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5022 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5023 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5024 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5025 g_free(utf8); | |
4819 | 5026 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5027 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5028 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5029 g_free(utf8); | |
5030 } | |
5031 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5032 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5033 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5034 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5035 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5036 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5037 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5038 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5039 } |
4641 | 5040 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5041 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5042 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5043 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5044 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5045 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5046 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5047 } |
4641 | 5048 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5049 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5050 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5051 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5052 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5053 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5054 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5055 g_free(utf8); | |
4624 | 5056 } |
8670 | 5057 g_string_append_printf(str, "\n<hr>\n"); |
5058 } | |
5059 | |
9634 | 5060 if (buddy != NULL) |
5061 alias = gaim_buddy_get_alias(buddy); | |
5062 else | |
5063 alias = who; | |
5064 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5065 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5066 g_free(primary); |
8670 | 5067 g_string_free(str, TRUE); |
4151 | 5068 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5069 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5070 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5071 |
4759 | 5072 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5073 { | |
5575 | 5074 GaimConnection *gc = sess->aux_data; |
4820 | 5075 gchar who[16], *utf8; |
6695 | 5076 GaimBuddy *b; |
4759 | 5077 va_list ap; |
5078 struct aim_icq_info *info; | |
5079 | |
5080 va_start(ap, fr); | |
5081 info = va_arg(ap, struct aim_icq_info *); | |
5082 va_end(ap); | |
5083 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5084 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5085 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5086 serv_got_alias(gc, who, utf8); |
4759 | 5087 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5088 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5089 } |
4820 | 5090 g_free(utf8); |
4759 | 5091 } |
5092 | |
5093 return 1; | |
5094 } | |
5095 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5096 static int gaim_popup(aim_session_t *sess, aim_frame_t *fr, ...) |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5097 { |
7032 | 5098 GaimConnection *gc = sess->aux_data; |
5099 gchar *text; | |
5100 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5101 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5102 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5103 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5104 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5105 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5106 url = va_arg(ap, char *); |
4199 | 5107 wid = (fu16_t) va_arg(ap, int); |
5108 hei = (fu16_t) va_arg(ap, int); | |
5109 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5110 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5111 |
7032 | 5112 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5113 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5114 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5115 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5116 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5117 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5118 |
7032 | 5119 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5120 { | |
6873 | 5121 GaimConnection *gc = sess->aux_data; |
5122 gchar *secondary; | |
5123 GString *text; | |
5124 int i, num; | |
2086 | 5125 va_list ap; |
6873 | 5126 char *email, *SNs; |
2086 | 5127 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5128 va_start(ap, fr); |
6873 | 5129 email = va_arg(ap, char *); |
2086 | 5130 num = va_arg(ap, int); |
5131 SNs = va_arg(ap, char *); | |
5132 va_end(ap); | |
5133 | |
8152 | 5134 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5135 text = g_string_new(""); |
2086 | 5136 for (i = 0; i < num; i++) |
6873 | 5137 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5138 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5139 | |
5140 g_free(secondary); | |
5141 g_string_free(text, TRUE); | |
2086 | 5142 |
5143 return 1; | |
5144 } | |
5145 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5146 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5147 va_list ap; |
6873 | 5148 char *email; |
5420 | 5149 char *buf; |
2086 | 5150 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5151 va_start(ap, fr); |
6873 | 5152 email = va_arg(ap, char *); |
2086 | 5153 va_end(ap); |
5154 | |
6873 | 5155 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
|
5156 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5157 g_free(buf); |
2086 | 5158 |
5159 return 1; | |
5160 } | |
5161 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5162 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5163 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5164 fu16_t status; |
2086 | 5165 va_list ap; |
5166 char msg[256]; | |
5167 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5168 va_start(ap, fr); |
4199 | 5169 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5170 va_end(ap); |
5171 | |
8660 | 5172 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5173 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5174 status ? "unknown" : "email sent"); |
5175 if (!status) { | |
5302 | 5176 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5177 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5178 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5179 } |
5180 | |
5181 return 1; | |
5182 } | |
5183 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5184 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5185 GaimConnection *gc = sess->aux_data; |
2086 | 5186 va_list ap; |
3912 | 5187 fu16_t perms, err; |
5188 char *url, *sn, *email; | |
5189 int change; | |
2086 | 5190 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5191 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5192 change = va_arg(ap, int); |
4199 | 5193 perms = (fu16_t) va_arg(ap, unsigned int); |
5194 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5195 url = va_arg(ap, char *); |
5196 sn = va_arg(ap, char *); | |
5197 email = va_arg(ap, char *); | |
2086 | 5198 va_end(ap); |
5199 | |
8660 | 5200 gaim_debug_misc("oscar", |
9626 | 5201 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5202 change ? "change" : "request", perms, err, | |
5203 (url != NULL) ? url : "(null)", | |
5204 (sn != NULL) ? sn : "(null)", | |
5205 (email != NULL) ? email : "(null)"); | |
5206 | |
5207 if ((err > 0) && (url != NULL)) { | |
3912 | 5208 char *dialog_msg; |
5209 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5210 switch (err) { | |
5211 case 0x0001: { | |
5212 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5213 } break; | |
5214 case 0x0006: { | |
5215 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5216 } break; | |
5217 case 0x000b: { | |
5218 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5219 } break; | |
5220 case 0x001d: { | |
5221 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); | |
5222 } break; | |
5223 case 0x0021: { | |
5224 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); | |
5225 } break; | |
5226 case 0x0023: { | |
5227 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5228 } break; | |
5229 default: { | |
5230 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5231 } break; | |
5232 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5233 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5234 g_free(dialog_top); |
5235 g_free(dialog_msg); | |
5236 return 1; | |
5237 } | |
5238 | |
9626 | 5239 if (sn != NULL) { |
4585 | 5240 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
|
5241 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5242 g_free(dialog_msg); |
5243 } | |
5244 | |
9626 | 5245 if (email != NULL) { |
5575 | 5246 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5247 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5248 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5249 g_free(dialog_msg); |
2086 | 5250 } |
5251 | |
5252 return 1; | |
5253 } | |
5254 | |
5575 | 5255 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5256 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5257 aim_flap_nop(od->sess, od->conn); |
2086 | 5258 } |
5259 | |
6059 | 5260 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5261 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5262 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5263 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5264 if (typing == GAIM_TYPING) |
4870 | 5265 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5266 else if (typing == GAIM_TYPED) |
4870 | 5267 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5268 else | |
5269 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5270 else { |
5300 | 5271 /* Don't send if this turkey is in our deny list */ |
5272 GSList *list; | |
5273 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5274 if (!list) { | |
7261 | 5275 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5276 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5277 if (typing == GAIM_TYPING) |
5300 | 5278 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5279 else if (typing == GAIM_TYPED) |
5300 | 5280 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5281 else | |
5282 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5283 } | |
3595 | 5284 } |
5285 } | |
2993 | 5286 return 0; |
5287 } | |
9030 | 5288 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5289 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimConvImFlags); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5290 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5291 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5292 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5293 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
|
5294 int ret = 0; |
5575 | 5295 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5296 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5297 |
4838 | 5298 if (dim && dim->connected) { |
5299 /* If we're directly connected, send a direct IM */ | |
6982 | 5300 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5301 } else { |
4738 | 5302 struct buddyinfo *bi; |
3008 | 5303 struct aim_sendimext_args args; |
5304 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5305 gsize len; |
8962 | 5306 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5307 | |
5308 if (strstr(message, "<IMG ")) | |
5309 gaim_conversation_write(conv, "", | |
5310 _("Your IM Image was not sent. " | |
5311 "You must be Direct Connected to send IM Images."), | |
5312 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5313 |
7261 | 5314 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5315 if (!bi) { |
5316 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5317 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5318 } |
5319 | |
3008 | 5320 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5321 if (od->icq) { |
5322 args.features = features_icq; | |
5323 args.featureslen = sizeof(features_icq); | |
3008 | 5324 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5325 } else { |
5326 args.features = features_aim; | |
5327 args.featureslen = sizeof(features_aim); | |
4972 | 5328 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5329 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5330 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5331 } |
4269 | 5332 |
4738 | 5333 if (bi->ico_need) { |
8660 | 5334 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5335 "Sending buddy icon request with message\n"); |
3008 | 5336 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5337 bi->ico_need = FALSE; |
3008 | 5338 } |
4269 | 5339 |
5575 | 5340 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5341 FILE *file = fopen(iconfile, "rb"); |
3008 | 5342 if (file) { |
5343 char *buf = g_malloc(st.st_size); | |
9532 | 5344 /* XXX - Use g_file_get_contents()? */ |
3008 | 5345 fread(buf, 1, st.st_size, file); |
6039 | 5346 fclose(file); |
4269 | 5347 |
3008 | 5348 args.iconlen = st.st_size; |
4617 | 5349 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5350 args.iconstamp = st.st_mtime; |
5351 | |
7406 | 5352 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5353 bi->ico_informed = FALSE; |
7406 | 5354 bi->ico_sent = FALSE; |
5355 } | |
4738 | 5356 |
5357 if (!bi->ico_informed) { | |
8660 | 5358 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5359 "Claiming to have a buddy icon\n"); |
4738 | 5360 args.flags |= AIM_IMFLAGS_HASICON; |
5361 bi->ico_me_len = args.iconlen; | |
5362 bi->ico_me_csum = args.iconsum; | |
5363 bi->ico_me_time = args.iconstamp; | |
5364 bi->ico_informed = TRUE; | |
5365 } | |
5366 | |
3008 | 5367 g_free(buf); |
2086 | 5368 } |
5369 } | |
4269 | 5370 |
3008 | 5371 args.destsn = name; |
4269 | 5372 |
8985 | 5373 /* |
5374 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5375 * strip all HTML | |
5376 */ | |
8995 | 5377 if (isdigit(name[0]) ) { |
5378 /* being sent to an ICQ user */ | |
5379 if (!isdigit(gaim_account_get_username(gc->account)[0])) { | |
5380 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ | |
5381 tmpmsg = gaim_str_add_cr(message); | |
5382 } else { | |
5383 /* from an ICQ user - do nothing */ | |
5384 tmpmsg = g_strdup(message); | |
5385 } | |
5386 } else { | |
5387 /* being sent to an AIM user */ | |
5388 if (isdigit(gaim_account_get_username(gc->account)[0])) { | |
5389 /* from an ICQ user */ | |
5390 tmpmsg2 = gaim_strdup_withhtml(message); | |
5391 tmpmsg = gaim_escape_html(tmpmsg2); | |
5392 g_free(tmpmsg2); | |
5393 } else | |
5394 tmpmsg = gaim_strdup_withhtml(message); | |
5395 } | |
6310 | 5396 len = strlen(tmpmsg); |
5397 | |
9830 | 5398 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5399 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5400 args.charset, args.charsubset, args.msglen); | |
4617 | 5401 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5402 g_free((char *)args.msg); |
2086 | 5403 } |
4838 | 5404 |
6310 | 5405 g_free(tmpmsg); |
5406 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5407 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5408 return 1; |
6310 | 5409 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5410 return ret; |
2086 | 5411 } |
5412 | |
7011 | 5413 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5414 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5415 |
7173 | 5416 if (od->icq && isdigit(name[0])) |
4624 | 5417 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5418 else |
7235 | 5419 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5420 } |
5421 | |
8950 | 5422 #if 0 |
7011 | 5423 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5424 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5425 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5426 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5427 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5428 maiden, NULL, NULL, city, state, NULL, 0, web); |
5429 } | |
8950 | 5430 #endif |
2086 | 5431 |
5575 | 5432 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5433 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5434 aim_srv_setidle(od->sess, time); |
2086 | 5435 } |
5436 | |
5954 | 5437 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5438 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5439 int charset = 0; |
6019 | 5440 char *text_html = NULL; |
5129 | 5441 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5442 gsize msglen = 0; |
2993 | 5443 |
4617 | 5444 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5445 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5446 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5447 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5448 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5449 "again when you are fully connected.")); |
4617 | 5450 |
7334 | 5451 if (!text) { |
5452 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5453 return; | |
5454 } | |
6019 | 5455 |
7334 | 5456 text_html = gaim_strdup_withhtml(text); |
9807 | 5457 charset = oscar_charset_check(text_html); |
9826 | 5458 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5459 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5460 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5461 g_free(msg); | |
9826 | 5462 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5463 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5464 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5465 g_free(msg); | |
5466 } else { | |
5467 msglen = strlen(text_html); | |
5468 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5469 } | |
5470 | |
5471 if (msglen > od->rights.maxsiglen) { | |
5472 gchar *errstr; | |
5473 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5474 "has been exceeded. Gaim has truncated it for you.", | |
5475 "The maximum profile length of %d bytes " | |
5476 "has been exceeded. Gaim has truncated it for you.", | |
5477 od->rights.maxsiglen), od->rights.maxsiglen); | |
5478 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5479 g_free(errstr); | |
5480 } | |
5481 | |
5482 g_free(text_html); | |
2993 | 5483 |
5484 return; | |
2086 | 5485 } |
5486 | |
8257 | 5487 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 5488 { |
9807 | 5489 int charset = 0; |
6019 | 5490 gchar *text_html = NULL; |
5129 | 5491 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5492 gsize msglen = 0; |
2993 | 5493 |
8257 | 5494 if (!strcmp(state, _("Visible"))) { |
5495 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5496 return; | |
5497 } else if (!strcmp(state, _("Invisible"))) { | |
5498 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5499 return; | |
5500 } /* else... */ | |
5501 | |
8476 | 5502 if (!strcmp(state, _("Back"))) { |
5503 /* If this is our only online account then globally set Gaim not-away */ | |
5504 GList *gcs = gaim_connections_get_all(); | |
5505 if (gcs->next == NULL) | |
9730 | 5506 ; /* XXX do_im_back(NULL, NULL); */ |
8476 | 5507 } |
5508 | |
8257 | 5509 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5510 | |
2993 | 5511 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5512 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5513 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5514 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5515 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5516 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5517 "fully connected.")); |
5129 | 5518 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5519 if (gc->away) { |
2993 | 5520 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5521 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5522 } |
2993 | 5523 |
5129 | 5524 if (!text) { |
7334 | 5525 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5526 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5527 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5528 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5529 text_html = gaim_strdup_withhtml(text); |
9807 | 5530 charset = oscar_charset_check(text_html); |
9826 | 5531 if (charset == AIM_CHARSET_UNICODE) { |
6019 | 5532 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5533 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5534 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5535 g_free(msg); |
5536 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
9826 | 5537 } else if (charset == AIM_CHARSET_CUSTOM) { |
6019 | 5538 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5539 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5540 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5541 g_free(msg); |
6019 | 5542 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5543 } else { |
6019 | 5544 msglen = strlen(text_html); |
7011 | 5545 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5546 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 5547 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5548 } |
5549 | |
5550 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5551 gchar *errstr; |
5552 | |
6308 | 5553 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5554 "has been exceeded. Gaim has truncated it for you.", | |
5555 "The maximum away message length of %d bytes " | |
5556 "has been exceeded. Gaim has truncated it for you.", | |
5557 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5558 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5559 g_free(errstr); |
5560 } | |
6019 | 5561 |
5562 g_free(text_html); | |
8257 | 5563 |
2993 | 5564 return; |
5565 } | |
5566 | |
7283 | 5567 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 5568 { |
5575 | 5569 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5570 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5571 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5572 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5573 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5574 |
8265 | 5575 if (strcmp(state, _("Invisible"))) |
5575 | 5576 account->perm_deny = 4; |
8265 | 5577 else |
5575 | 5578 account->perm_deny = 3; |
8265 | 5579 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5580 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5581 |
5582 if (!strcmp(state, _("Online"))) | |
4901 | 5583 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 5584 else if (!strcmp(state, _("Away"))) { |
4901 | 5585 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5586 gc->away = g_strdup(""); |
4342 | 5587 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 5588 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5589 gc->away = g_strdup(""); |
4342 | 5590 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 5591 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5592 gc->away = g_strdup(""); |
4342 | 5593 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 5594 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5595 gc->away = g_strdup(""); |
4342 | 5596 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 5597 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5598 gc->away = g_strdup(""); |
4342 | 5599 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 5600 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5601 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5602 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 5603 if (message) { |
4901 | 5604 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5605 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5606 } else { |
4901 | 5607 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5608 } |
2086 | 5609 } |
2993 | 5610 |
5611 return; | |
5612 } | |
5613 | |
6059 | 5614 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 5615 { |
7283 | 5616 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 5617 |
5618 if (od->icq) | |
5619 oscar_set_away_icq(gc, od, state, message); | |
5620 else | |
8257 | 5621 oscar_set_away_aim(gc, od, state, message); |
2993 | 5622 |
5623 return; | |
2086 | 5624 } |
5625 | |
9753 | 5626 static void oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { |
7283 | 5627 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5628 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5629 } |
5630 | |
9285 | 5631 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5632 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5633 |
5634 if (!aim_snvalid(buddy->name)) { | |
8092 | 5635 gchar *buf; |
9285 | 5636 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 | 5637 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5638 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5639 g_free(buf); |
8150 | 5640 |
5641 /* Remove from local list */ | |
9285 | 5642 gaim_blist_remove_buddy(buddy); |
8150 | 5643 |
8092 | 5644 return; |
5645 } | |
5646 | |
4230 | 5647 #ifdef NOSSI |
9285 | 5648 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5649 #else |
9285 | 5650 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5651 if (buddy && group) { | |
8660 | 5652 gaim_debug_info("oscar", |
9285 | 5653 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5654 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5655 } |
5656 } | |
5657 #endif | |
8150 | 5658 |
4759 | 5659 if (od->icq) |
9285 | 5660 aim_icq_getalias(od->sess, buddy->name); |
5661 } | |
5662 | |
5663 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5664 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5665 #ifdef NOSSI |
5666 char buf[MSG_LEN]; | |
5667 int n=0; | |
9285 | 5668 |
4230 | 5669 while (buddies) { |
9381 | 5670 GaimBuddy *buddy = buddies->data; |
4230 | 5671 if (n > MSG_LEN - 18) { |
7285 | 5672 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5673 n = 0; |
3092 | 5674 } |
9381 | 5675 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5676 buddies = buddies->next; |
5677 } | |
7285 | 5678 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5679 #else |
9285 | 5680 |
4230 | 5681 if (od->sess->ssi.received_data) { |
9285 | 5682 GList *curb = buddies; |
5683 GList *curg = groups; | |
5684 while ((curb != NULL) && (curg != NULL)) { | |
5685 GaimBuddy *buddy = curb->data; | |
5686 GaimGroup *group = curg->data; | |
5687 oscar_add_buddy(gc, buddy, group); | |
5688 curb = curb->next; | |
5689 curg = curg->next; | |
4230 | 5690 } |
5691 } | |
5692 #endif | |
5693 } | |
5694 | |
9285 | 5695 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5696 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5697 |
4230 | 5698 #ifdef NOSSI |
9285 | 5699 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5700 #else |
5701 if (od->sess->ssi.received_data) { | |
8660 | 5702 gaim_debug_info("oscar", |
9285 | 5703 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5704 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5705 } |
5706 #endif | |
5707 } | |
5708 | |
9285 | 5709 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5710 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5711 |
4230 | 5712 #ifdef NOSSI |
9285 | 5713 for (cur = buddies; cur != NULL; cur = cur->next) { |
5714 GaimBuddy *buddy = cur->data; | |
5715 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5716 } | |
4230 | 5717 #else |
5718 if (od->sess->ssi.received_data) { | |
9285 | 5719 GList *curb = buddies; |
5720 GList *curg = groups; | |
5721 while ((curb != NULL) && (curg != NULL)) { | |
5722 GaimBuddy *buddy = curb->data; | |
5723 GaimGroup *group = curg->data; | |
5724 oscar_remove_buddy(gc, buddy, group); | |
5725 curb = curb->next; | |
5726 curg = curg->next; | |
3092 | 5727 } |
4230 | 5728 } |
5729 #endif | |
5730 } | |
5731 | |
5732 #ifndef NOSSI | |
5575 | 5733 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5734 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5735 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5736 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5737 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5738 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5739 } |
5740 } | |
5741 | |
5575 | 5742 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5743 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5744 if (od->sess->ssi.received_data) { |
5745 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5746 if (gname) { | |
8660 | 5747 gaim_debug_info("oscar", |
9586 | 5748 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5749 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5750 } |
5751 } | |
5752 } | |
5753 | |
9285 | 5754 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5755 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5756 |
5757 if (od->sess->ssi.received_data) { | |
9285 | 5758 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5759 GList *cur, *groups = NULL; | |
5760 | |
5761 /* Make a list of what the groups each buddy is in */ | |
5762 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5763 GaimBlistNode *node = cur->data; | |
5764 groups = g_list_append(groups, node->parent); | |
5765 } | |
5766 | |
5767 oscar_remove_buddies(gc, moved_buddies, groups); | |
5768 oscar_add_buddies(gc, moved_buddies, groups); | |
5769 g_list_free(groups); | |
8660 | 5770 gaim_debug_info("oscar", |
9285 | 5771 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5772 } else { |
9285 | 5773 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5774 gaim_debug_info("oscar", |
9285 | 5775 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5776 } |
5777 } | |
5778 } | |
5779 | |
5968 | 5780 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5781 aim_session_t *sess = data; | |
6350 | 5782 aim_ssi_reqdata(sess); |
5968 | 5783 return FALSE; |
5784 } | |
5785 | |
4642 | 5786 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5787 GaimConnection *gc = sess->aux_data; |
7283 | 5788 OscarData *od = gc->proto_data; |
4642 | 5789 va_list ap; |
5790 fu16_t reason; | |
5791 | |
5792 va_start(ap, fr); | |
5793 reason = (fu16_t)va_arg(ap, unsigned int); | |
5794 va_end(ap); | |
5795 | |
8660 | 5796 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5797 |
5798 if (reason == 0x0005) { | |
5892 | 5799 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5800 _("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.")); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5801 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5802 } |
5803 | |
5804 /* Activate SSI */ | |
5805 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5806 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5807 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5808 aim_ssi_enable(od->sess); |
5809 | |
5810 return 1; | |
5811 } | |
5812 | |
2991 | 5813 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5814 GaimConnection *gc = sess->aux_data; |
7283 | 5815 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5816 int numtypes, i; |
5817 fu16_t *maxitems; | |
2991 | 5818 va_list ap; |
5819 | |
5820 va_start(ap, fr); | |
4230 | 5821 numtypes = va_arg(ap, int); |
5822 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5823 va_end(ap); |
5824 | |
8660 | 5825 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5826 |
4230 | 5827 for (i=0; i<numtypes; i++) |
8660 | 5828 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5829 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5830 |
8660 | 5831 gaim_debug_misc(NULL, "\n"); |
4230 | 5832 |
5833 if (numtypes >= 0) | |
5834 od->rights.maxbuddies = maxitems[0]; | |
5835 if (numtypes >= 1) | |
5836 od->rights.maxgroups = maxitems[1]; | |
5837 if (numtypes >= 2) | |
5838 od->rights.maxpermits = maxitems[2]; | |
5839 if (numtypes >= 3) | |
5840 od->rights.maxdenies = maxitems[3]; | |
2991 | 5841 |
5842 return 1; | |
5843 } | |
5844 | |
5845 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5846 GaimConnection *gc = sess->aux_data; |
5847 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5848 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5849 GaimGroup *g; |
5850 GaimBuddy *b; | |
2995 | 5851 struct aim_ssi_item *curitem; |
2991 | 5852 int tmp; |
4230 | 5853 va_list ap; |
8219 | 5854 fu16_t fmtver, numitems; |
5855 struct aim_ssi_item *items; | |
5856 fu32_t timestamp; | |
4230 | 5857 |
5858 va_start(ap, fr); | |
5859 fmtver = (fu16_t)va_arg(ap, int); | |
5860 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5861 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5862 timestamp = va_arg(ap, fu32_t); |
8219 | 5863 va_end(ap); |
2991 | 5864 |
8660 | 5865 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5866 "ssi: syncing local list and server list\n"); |
2991 | 5867 |
8219 | 5868 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5869 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 | 5870 return 1; |
5871 } | |
5872 | |
2991 | 5873 /* Clean the buddy list */ |
4889 | 5874 aim_ssi_cleanlist(sess); |
2991 | 5875 |
8150 | 5876 { /* If not in server list then prune from local list */ |
5877 GaimBlistNode *gnode, *cnode, *bnode; | |
5878 GaimBuddyList *blist; | |
9539 | 5879 GSList *cur, *next; |
8150 | 5880 |
5881 /* Buddies */ | |
5882 cur = NULL; | |
5883 if ((blist = gaim_get_blist()) != NULL) { | |
5884 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5885 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5886 continue; | |
5887 g = (GaimGroup *)gnode; | |
5888 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5889 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5890 continue; | |
5891 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5892 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5893 continue; | |
5894 b = (GaimBuddy *)bnode; | |
5895 if (b->account == gc->account) { | |
5896 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5897 /* If the buddy is an ICQ user then load his nickname */ | |
5898 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5899 char *alias; |
8150 | 5900 if (servernick) |
5901 serv_got_alias(gc, b->name, servernick); | |
5902 | |
5903 /* Store local alias on server */ | |
8214 | 5904 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5905 if (!alias && b->alias && strlen(b->alias)) |
5906 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5907 free(alias); | |
5908 } else { | |
8660 | 5909 gaim_debug_info("oscar", |
8150 | 5910 "ssi: removing buddy %s from local list\n", b->name); |
5911 /* We can't actually remove now because it will screw up our looping */ | |
5912 cur = g_slist_prepend(cur, b); | |
5913 } | |
5914 } | |
5915 } | |
5916 } | |
5917 } | |
5918 } | |
8175 | 5919 |
8150 | 5920 while (cur != NULL) { |
5921 b = cur->data; | |
5922 cur = g_slist_remove(cur, b); | |
5923 gaim_blist_remove_buddy(b); | |
5924 } | |
5925 | |
5926 /* Permit list */ | |
5927 if (gc->account->permit) { | |
9539 | 5928 next = gc->account->permit; |
5929 while (next != NULL) { | |
5930 cur = next; | |
5931 next = next->next; | |
8150 | 5932 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5933 gaim_debug_info("oscar", |
8150 | 5934 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5935 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5936 } | |
9539 | 5937 } |
8150 | 5938 } |
5939 | |
5940 /* Deny list */ | |
5941 if (gc->account->deny) { | |
9539 | 5942 next = gc->account->deny; |
5943 while (next != NULL) { | |
5944 cur = next; | |
5945 next = next->next; | |
8150 | 5946 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 5947 gaim_debug_info("oscar", |
8150 | 5948 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5949 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5950 } | |
9539 | 5951 } |
8150 | 5952 } |
5953 /* Presence settings (idle time visibility) */ | |
5954 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5955 if (!(tmp & 0x400)) | |
5956 aim_ssi_setpresence(sess, tmp | 0x400); | |
5957 } /* end pruning buddies from local list */ | |
5958 | |
2991 | 5959 /* Add from server list to local list */ |
4230 | 5960 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 5961 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 5962 switch (curitem->type) { |
4230 | 5963 case 0x0000: { /* Buddy */ |
4251 | 5964 if (curitem->name) { |
4292 | 5965 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 5966 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 5967 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 5968 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 5969 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 5970 /* Should gname be freed here? -- elb */ |
4754 | 5971 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 5972 free(alias); |
8150 | 5973 if (b) { |
4292 | 5974 /* Get server stored alias */ |
4705 | 5975 if (alias_utf8) { |
8150 | 5976 g_free(b->alias); |
5977 b->alias = g_strdup(alias_utf8); | |
4705 | 5978 } |
4282 | 5979 } else { |
8150 | 5980 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 5981 |
4754 | 5982 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 5983 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 5984 gaim_blist_add_group(g, NULL); |
5985 } | |
5146 | 5986 |
8660 | 5987 gaim_debug_info("oscar", |
9285 | 5988 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 5989 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 5990 } |
8341 | 5991 if (!aim_sncmp(curitem->name, account->username)) { |
5992 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
5993 gaim_check_comment(od, comment); | |
5994 free(comment); | |
5995 } | |
7162 | 5996 g_free(gname_utf8); |
5997 g_free(alias_utf8); | |
2991 | 5998 } |
4230 | 5999 } break; |
6000 | |
6001 case 0x0001: { /* Group */ | |
4282 | 6002 /* Shouldn't add empty groups */ |
4230 | 6003 } break; |
6004 | |
6005 case 0x0002: { /* Permit buddy */ | |
2991 | 6006 if (curitem->name) { |
4230 | 6007 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6008 GSList *list; |
5575 | 6009 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6010 if (!list) { |
8660 | 6011 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6012 "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
|
6013 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6014 } |
6015 } | |
4230 | 6016 } break; |
6017 | |
6018 case 0x0003: { /* Deny buddy */ | |
2991 | 6019 if (curitem->name) { |
6020 GSList *list; | |
5575 | 6021 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6022 if (!list) { |
8660 | 6023 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6024 "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
|
6025 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6026 } |
6027 } | |
4230 | 6028 } break; |
6029 | |
6030 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6031 if (curitem->data) { |
6032 fu8_t permdeny; | |
5575 | 6033 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6034 gaim_debug_info("oscar", |
5575 | 6035 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6036 account->perm_deny = permdeny; | |
6037 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 6038 serv_set_away(gc, "Invisible", ""); |
6039 } | |
2991 | 6040 } |
6041 } | |
4230 | 6042 } break; |
6043 | |
6044 case 0x0005: { /* Presence setting */ | |
3109 | 6045 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6046 } break; |
2991 | 6047 } /* End of switch on curitem->type */ |
6048 } /* End of for loop */ | |
4230 | 6049 |
4901 | 6050 /* Set our ICQ status */ |
8257 | 6051 if (!gc->away) { |
4901 | 6052 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6053 } | |
6054 | |
4342 | 6055 /* Activate SSI */ |
6056 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6057 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6058 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6059 "ssi: activating server-stored buddy list\n"); |
4642 | 6060 aim_ssi_enable(sess); |
4342 | 6061 |
2991 | 6062 return 1; |
2086 | 6063 } |
4230 | 6064 |
6065 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6066 GaimConnection *gc = sess->aux_data; |
4230 | 6067 va_list ap; |
6068 struct aim_ssi_tmp *retval; | |
6069 | |
6070 va_start(ap, fr); | |
6071 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6072 va_end(ap); | |
6073 | |
6074 while (retval) { | |
8660 | 6075 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6076 "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 | 6077 |
6078 if (retval->ack != 0xffff) | |
6079 switch (retval->ack) { | |
6080 case 0x0000: { /* added successfully */ | |
6081 } break; | |
6082 | |
4829 | 6083 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6084 gchar *buf; | |
6085 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 | 6086 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6087 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6088 g_free(buf); |
6089 } | |
6090 | |
7023 | 6091 case 0x000e: { /* buddy requires authorization */ |
4828 | 6092 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6093 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6094 } break; |
6095 | |
6096 default: { /* La la la */ | |
5197 | 6097 gchar *buf; |
8660 | 6098 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6099 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 | 6100 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6101 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6102 g_free(buf); |
4230 | 6103 } break; |
6104 } | |
6105 | |
6106 retval = retval->next; | |
6107 } | |
6108 | |
6109 return 1; | |
6110 } | |
6111 | |
8227 | 6112 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6113 GaimConnection *gc = sess->aux_data; | |
6114 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6115 GaimBuddy *b; | |
6116 GaimGroup *g; | |
6117 va_list ap; | |
6118 fu16_t type; | |
6119 const char *name; | |
6120 | |
6121 va_start(ap, fr); | |
6122 type = (fu16_t)va_arg(ap, int); | |
6123 name = va_arg(ap, char *); | |
6124 va_end(ap); | |
6125 | |
6126 if ((type != 0x0000) || (name == NULL)) | |
6127 return 1; | |
6128 | |
6129 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6130 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6131 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6132 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6133 b = gaim_find_buddy(gc->account, name); | |
6134 free(alias); | |
6135 | |
6136 if (b) { | |
6137 /* Get server stored alias */ | |
6138 if (alias_utf8) { | |
6139 g_free(b->alias); | |
6140 b->alias = g_strdup(alias_utf8); | |
6141 } | |
6142 } else { | |
6143 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6144 | |
6145 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6146 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6147 gaim_blist_add_group(g, NULL); | |
6148 } | |
6149 | |
8660 | 6150 gaim_debug_info("oscar", |
9285 | 6151 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6152 gaim_blist_add_buddy(b, NULL, g, NULL); |
6153 } | |
6154 g_free(gname_utf8); | |
6155 g_free(alias_utf8); | |
6156 | |
6157 return 1; | |
6158 } | |
6159 | |
4230 | 6160 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6161 GaimConnection *gc = sess->aux_data; |
4230 | 6162 va_list ap; |
6163 char *sn, *msg; | |
4236 | 6164 gchar *dialog_msg, *nombre; |
4230 | 6165 struct name_data *data; |
6695 | 6166 GaimBuddy *buddy; |
4230 | 6167 |
6168 va_start(ap, fr); | |
6169 sn = va_arg(ap, char *); | |
6170 msg = va_arg(ap, char *); | |
6171 va_end(ap); | |
6172 | |
8660 | 6173 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6174 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6175 |
4687 | 6176 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6177 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6178 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6179 else |
6180 nombre = g_strdup(sn); | |
6181 | |
6182 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 | 6183 data = g_new(struct name_data, 1); |
6184 data->gc = gc; | |
6185 data->name = g_strdup(sn); | |
6186 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6187 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6188 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6189 0, data, |
7023 | 6190 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6191 G_CALLBACK(oscar_free_name_data)); |
4236 | 6192 |
4230 | 6193 g_free(dialog_msg); |
4236 | 6194 g_free(nombre); |
4230 | 6195 |
6196 return 1; | |
6197 } | |
6198 | |
6199 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6200 GaimConnection *gc = sess->aux_data; |
4230 | 6201 va_list ap; |
6202 char *sn, *msg; | |
4236 | 6203 gchar *dialog_msg, *nombre; |
4230 | 6204 struct name_data *data; |
6695 | 6205 GaimBuddy *buddy; |
4230 | 6206 |
6207 va_start(ap, fr); | |
6208 sn = va_arg(ap, char *); | |
6209 msg = va_arg(ap, char *); | |
6210 va_end(ap); | |
6211 | |
8660 | 6212 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6213 "ssi: received authorization request from %s\n", sn); |
4230 | 6214 |
4687 | 6215 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6216 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6217 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6218 else |
6219 nombre = g_strdup(sn); | |
6220 | |
4337 | 6221 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
4230 | 6222 data = g_new(struct name_data, 1); |
6223 data->gc = gc; | |
6224 data->name = g_strdup(sn); | |
6225 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6226 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6227 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6228 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6229 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6230 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6231 |
4230 | 6232 g_free(dialog_msg); |
4236 | 6233 g_free(nombre); |
4230 | 6234 |
6235 return 1; | |
6236 } | |
6237 | |
6238 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6239 GaimConnection *gc = sess->aux_data; |
4230 | 6240 va_list ap; |
6241 char *sn, *msg; | |
4236 | 6242 gchar *dialog_msg, *nombre; |
4230 | 6243 fu8_t reply; |
6695 | 6244 GaimBuddy *buddy; |
4230 | 6245 |
6246 va_start(ap, fr); | |
6247 sn = va_arg(ap, char *); | |
6248 reply = (fu8_t)va_arg(ap, int); | |
6249 msg = va_arg(ap, char *); | |
6250 va_end(ap); | |
6251 | |
8660 | 6252 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6253 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6254 |
4687 | 6255 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6256 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6257 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6258 else |
6259 nombre = g_strdup(sn); | |
6260 | |
4230 | 6261 if (reply) { |
6262 /* Granted */ | |
7023 | 6263 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
|
6264 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6265 } else { |
6266 /* Denied */ | |
7023 | 6267 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
|
6268 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6269 } |
6270 g_free(dialog_msg); | |
4236 | 6271 g_free(nombre); |
4230 | 6272 |
6273 return 1; | |
6274 } | |
6275 | |
6276 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6277 GaimConnection *gc = sess->aux_data; |
4230 | 6278 va_list ap; |
6279 char *sn; | |
6695 | 6280 GaimBuddy *buddy; |
4230 | 6281 |
6282 va_start(ap, fr); | |
6283 sn = va_arg(ap, char *); | |
6284 va_end(ap); | |
6285 | |
4687 | 6286 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6287 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6288 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6289 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6290 |
6291 return 1; | |
6292 } | |
4269 | 6293 #endif |
2086 | 6294 |
5575 | 6295 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6296 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6297 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6298 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6299 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6300 pce->label = _("_Room:"); |
5234 | 6301 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6302 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6303 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6304 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6305 pce->label = _("_Exchange:"); |
5234 | 6306 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6307 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6308 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6309 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6310 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6311 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6312 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6313 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6314 |
9754 | 6315 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6316 { | |
6317 GHashTable *defaults; | |
6318 | |
6319 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6320 | |
6321 if (chat_name != NULL) | |
6322 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6323 | |
6324 return defaults; | |
6325 } | |
6326 | |
8308 | 6327 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6328 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6329 aim_conn_t *cur; |
5234 | 6330 char *name, *exchange; |
6331 | |
6332 name = g_hash_table_lookup(data, "room"); | |
6333 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6334 |
8660 | 6335 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6336 "Attempting to join chat room %s.\n", name); |
8308 | 6337 |
6338 if ((name == NULL) || (*name == '\0')) { | |
6339 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6340 return; | |
6341 } | |
6342 | |
4617 | 6343 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6344 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6345 "chatnav exists, creating room\n"); |
5234 | 6346 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6347 } else { |
6348 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6349 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6350 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6351 "chatnav does not exist, opening chatnav\n"); |
5234 | 6352 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6353 cr->name = g_strdup(name); |
4617 | 6354 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6355 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6356 } |
6357 } | |
6358 | |
8308 | 6359 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6360 OscarData *od = (OscarData *)gc->proto_data; | |
6361 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6362 |
6363 if (!ccon) | |
6364 return; | |
6365 | |
8225 | 6366 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6367 ccon->exchange, ccon->name, 0x0); |
6368 } | |
6369 | |
8308 | 6370 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6371 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6372 GSList *bcs = gc->buddy_chats; | |
5679 | 6373 GaimConversation *b = NULL; |
2086 | 6374 struct chat_connection *c = NULL; |
6375 int count = 0; | |
6376 | |
6377 while (bcs) { | |
6378 count++; | |
5679 | 6379 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6380 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6381 break; |
6382 bcs = bcs->next; | |
6383 b = NULL; | |
6384 } | |
6385 | |
6386 if (!b) | |
6387 return; | |
6388 | |
8660 | 6389 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6390 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6391 |
8308 | 6392 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6393 if (c != NULL) { |
4617 | 6394 if (od) |
6395 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6396 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6397 gaim_input_remove(c->inpa); |
8308 | 6398 if (gc && od->sess) |
4617 | 6399 aim_conn_kill(od->sess, &c->conn); |
2086 | 6400 g_free(c->name); |
6401 g_free(c->show); | |
6402 g_free(c); | |
6403 } | |
6404 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6405 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6406 } |
6407 | |
8219 | 6408 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6409 OscarData *od = (OscarData *)gc->proto_data; | |
6410 GaimConversation *conv = NULL; | |
2086 | 6411 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6412 char *buf, *buf2; |
9830 | 6413 fu16_t charset, charsubset; |
9807 | 6414 char *charsetstr = NULL; |
8907 | 6415 gsize len; |
8219 | 6416 |
6417 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6418 return -EINVAL; |
2086 | 6419 |
8219 | 6420 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6421 return -EINVAL; |
2086 | 6422 |
8219 | 6423 buf = gaim_strdup_withhtml(message); |
6424 len = strlen(buf); | |
6425 | |
8962 | 6426 if (strstr(buf, "<IMG ")) |
6427 gaim_conversation_write(conv, "", | |
6428 _("Your IM Image was not sent. " | |
6429 "You cannot send IM Images in AIM chats."), | |
6430 GAIM_MESSAGE_ERROR, time(NULL)); | |
6431 | |
9830 | 6432 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6433 if ((len > c->maxlen) || (len > c->maxvis)) { |
6434 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6435 return -E2BIG; |
8359 | 6436 } |
6437 | |
9831 | 6438 if (charset == AIM_CHARSET_ASCII) |
6439 charsetstr = "us-ascii"; | |
6440 else if (charset == AIM_CHARSET_UNICODE) | |
6441 charsetstr = "unicode-2-0"; | |
6442 else if (charset == AIM_CHARSET_CUSTOM) | |
6443 charsetstr = "iso-8859-1"; | |
9807 | 6444 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6445 g_free(buf2); |
8359 | 6446 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6447 return 0; |
2086 | 6448 } |
6449 | |
6695 | 6450 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6451 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6452 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 6453 return "icq"; |
6454 else | |
6455 return "aim"; | |
6456 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6457 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6458 if (b != NULL && isdigit(b->name[0])) |
4687 | 6459 return "icq"; |
6460 return "aim"; | |
6461 } | |
6462 | |
6695 | 6463 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 6464 { |
7334 | 6465 GaimAccount *account = NULL; |
6466 GaimConnection *gc = NULL; | |
6467 OscarData *od = NULL; | |
4687 | 6468 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6469 int i = 0; | |
7334 | 6470 aim_userinfo_t *userinfo = NULL; |
6471 | |
6472 if (b != NULL) | |
6473 account = b->account; | |
6474 if (account != NULL) | |
6475 gc = account->gc; | |
6476 if (gc != NULL) | |
6477 od = gc->proto_data; | |
7945 | 6478 if (od != NULL) |
6479 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6480 |
5131 | 6481 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6482 char *gname; | |
7334 | 6483 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6484 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6485 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6486 emblems[i++] = "notauthorized"; | |
6487 } else { | |
6488 emblems[i++] = "offline"; | |
6489 } | |
6490 } | |
4916 | 6491 |
4766 | 6492 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 6493 int uc = b->uc >> 16; |
4766 | 6494 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6495 emblems[i++] = "invisible"; |
4766 | 6496 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6497 emblems[i++] = "freeforchat"; |
4766 | 6498 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6499 emblems[i++] = "dnd"; |
4766 | 6500 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6501 emblems[i++] = "na"; |
4766 | 6502 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6503 emblems[i++] = "occupied"; |
4766 | 6504 else if (uc & AIM_ICQ_STATE_AWAY) |
6505 emblems[i++] = "away"; | |
6506 } else { | |
6507 if (b->uc & UC_UNAVAILABLE) | |
6508 emblems[i++] = "away"; | |
6509 } | |
4687 | 6510 if (b->uc & UC_WIRELESS) |
6511 emblems[i++] = "wireless"; | |
6512 if (b->uc & UC_AOL) | |
6513 emblems[i++] = "aol"; | |
6514 if (b->uc & UC_ADMIN) | |
6515 emblems[i++] = "admin"; | |
6516 if (b->uc & UC_AB && i < 4) | |
6517 emblems[i++] = "activebuddy"; | |
4766 | 6518 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6519 emblems[i++] = "unconfirmed"; */ | |
7334 | 6520 |
7945 | 6521 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6522 emblems[i++] = "hiptop"; | |
6523 | |
6524 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6525 emblems[i++] = "secure"; |
6526 | |
4687 | 6527 *se = emblems[0]; |
6528 *sw = emblems[1]; | |
6529 *nw = emblems[2]; | |
6530 *ne = emblems[3]; | |
6531 } | |
6532 | |
6695 | 6533 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6534 GaimConnection *gc = b->account->gc; |
7283 | 6535 OscarData *od = gc->proto_data; |
7045 | 6536 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6537 GString *str = g_string_new(""); |
5131 | 6538 |
6539 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6540 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6541 |
6542 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6543 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6544 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6545 g_free(charset); |
7011 | 6546 if (away_utf8 != NULL) { |
7091 | 6547 gchar *tmp1, *tmp2; |
9627 | 6548 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6549 g_free(away_utf8); |
8571 | 6550 tmp1 = gaim_escape_html(tmp2); |
7091 | 6551 g_free(tmp2); |
8700 | 6552 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6553 g_free(tmp1); |
8701 | 6554 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6555 g_free(tmp2); |
5836 | 6556 } |
5131 | 6557 } |
8701 | 6558 } |
6559 | |
6560 return g_string_free(str, FALSE); | |
5131 | 6561 } |
6562 | |
6695 | 6563 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 6564 GaimConnection *gc = b->account->gc; |
7283 | 6565 OscarData *od = gc->proto_data; |
5167 | 6566 gchar *ret = NULL; |
6567 | |
6568 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
6569 if (isdigit(b->name[0])) | |
8701 | 6570 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6571 else |
6572 ret = g_strdup(_("Away")); | |
5836 | 6573 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6574 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 6575 if (bi->availmsg) |
6576 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 6577 } else { |
5167 | 6578 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6579 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6580 ret = g_strdup(_("Not Authorized")); | |
6581 else | |
6582 ret = g_strdup(_("Offline")); | |
6583 } | |
6584 | |
6585 return ret; | |
6586 } | |
6587 | |
5842 | 6588 |
5844 | 6589 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6590 GaimConnection *gc = sess->aux_data; |
7283 | 6591 OscarData *od = gc->proto_data; |
5892 | 6592 va_list ap; |
5842 | 6593 fu16_t type; |
5892 | 6594 fu8_t flags = 0, length = 0; |
6595 char *md5 = NULL; | |
6596 | |
7334 | 6597 |
5842 | 6598 va_start(ap, fr); |
6599 type = va_arg(ap, int); | |
5892 | 6600 |
6601 switch(type) { | |
6602 case 0x0000: | |
6603 case 0x0001: { | |
6604 flags = va_arg(ap, int); | |
6605 length = va_arg(ap, int); | |
6606 md5 = va_arg(ap, char *); | |
6607 | |
6608 if (flags == 0x41) { | |
6609 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6610 od->iconconnecting = TRUE; | |
6611 od->set_icon = TRUE; | |
6612 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6613 } else { | |
6039 | 6614 struct stat st; |
6615 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6616 if (iconfile == NULL) { | |
8363 | 6617 aim_ssi_delicon(od->sess); |
6039 | 6618 } else if (!stat(iconfile, &st)) { |
6619 char *buf = g_malloc(st.st_size); | |
6620 FILE *file = fopen(iconfile, "rb"); | |
6621 if (file) { | |
9532 | 6622 /* XXX - Use g_file_get_contents()? */ |
6039 | 6623 fread(buf, 1, st.st_size, file); |
6624 fclose(file); | |
8660 | 6625 gaim_debug_info("oscar", |
6039 | 6626 "Uploading icon to icon server\n"); |
6879 | 6627 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6628 } else |
8660 | 6629 gaim_debug_error("oscar", |
6039 | 6630 "Can't open buddy icon file!\n"); |
6631 g_free(buf); | |
6632 } else { | |
8660 | 6633 gaim_debug_error("oscar", |
6039 | 6634 "Can't stat buddy icon file!\n"); |
5892 | 6635 } |
6636 } | |
8363 | 6637 } else if (flags == 0x81) { |
6638 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6639 if (iconfile == NULL) | |
6640 aim_ssi_delicon(od->sess); | |
6641 else | |
6642 aim_ssi_seticon(od->sess, md5, length); | |
6643 } | |
5892 | 6644 } break; |
6645 | |
6646 case 0x0002: { /* We just set an "available" message? */ | |
6647 } break; | |
6648 } | |
6649 | |
5842 | 6650 va_end(ap); |
5844 | 6651 |
6652 return 0; | |
5842 | 6653 } |
5892 | 6654 |
5575 | 6655 static void oscar_set_permit_deny(GaimConnection *gc) { |
6656 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6657 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6658 #ifdef NOSSI |
8143 | 6659 GSList *list; |
4230 | 6660 char buf[MAXMSGLEN]; |
6661 int at; | |
6662 | |
5575 | 6663 switch(account->perm_deny) { |
8175 | 6664 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6665 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6666 break; |
8175 | 6667 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6668 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6669 break; |
8175 | 6670 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6671 list = account->permit; |
4230 | 6672 at = 0; |
6673 while (list) { | |
6674 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6675 list = list->next; | |
6676 } | |
6677 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6678 break; | |
8175 | 6679 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6680 list = account->deny; |
4230 | 6681 at = 0; |
6682 while (list) { | |
6683 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6684 list = list->next; | |
6685 } | |
6686 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6687 break; | |
6688 default: | |
6689 break; | |
2086 | 6690 } |
4230 | 6691 #else |
8175 | 6692 if (od->sess->ssi.received_data) { |
6693 switch (account->perm_deny) { | |
6694 case GAIM_PRIVACY_ALLOW_ALL: | |
6695 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6696 break; | |
6697 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6698 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6699 break; | |
6700 case GAIM_PRIVACY_ALLOW_USERS: | |
6701 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6702 break; | |
6703 case GAIM_PRIVACY_DENY_ALL: | |
6704 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6705 break; | |
6706 case GAIM_PRIVACY_DENY_USERS: | |
6707 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6708 break; | |
6709 default: | |
6710 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6711 break; | |
6712 } | |
6713 } | |
4230 | 6714 #endif |
2086 | 6715 } |
6716 | |
5575 | 6717 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6718 #ifdef NOSSI |
8143 | 6719 if (gc->account->perm_deny == 3) |
4269 | 6720 oscar_set_permit_deny(gc); |
6721 #else | |
7283 | 6722 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6723 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6724 if (od->sess->ssi.received_data) |
4889 | 6725 aim_ssi_addpermit(od->sess, who); |
4230 | 6726 #endif |
2086 | 6727 } |
6728 | |
5575 | 6729 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6730 #ifdef NOSSI |
8143 | 6731 if (gc->account->perm_deny == 4) |
4269 | 6732 oscar_set_permit_deny(gc); |
6733 #else | |
7283 | 6734 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6735 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6736 if (od->sess->ssi.received_data) |
4889 | 6737 aim_ssi_adddeny(od->sess, who); |
4230 | 6738 #endif |
2086 | 6739 } |
6740 | |
5575 | 6741 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6742 #ifdef NOSSI |
8143 | 6743 if (gc->account->perm_deny == 3) |
4269 | 6744 oscar_set_permit_deny(gc); |
6745 #else | |
7283 | 6746 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6747 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6748 if (od->sess->ssi.received_data) |
4889 | 6749 aim_ssi_delpermit(od->sess, who); |
4230 | 6750 #endif |
2086 | 6751 } |
6752 | |
5575 | 6753 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6754 #ifdef NOSSI |
8143 | 6755 if (gc->account->perm_deny == 4) |
4269 | 6756 oscar_set_permit_deny(gc); |
6757 #else | |
7283 | 6758 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6759 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6760 if (od->sess->ssi.received_data) |
4889 | 6761 aim_ssi_deldeny(od->sess, who); |
4230 | 6762 #endif |
2086 | 6763 } |
6764 | |
5575 | 6765 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 6766 { |
7283 | 6767 OscarData *od = gc->proto_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6768 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6769 |
8257 | 6770 if (od->icq) { |
6771 m = g_list_append(m, _("Online")); | |
6772 m = g_list_append(m, _("Away")); | |
6773 m = g_list_append(m, _("Do Not Disturb")); | |
6774 m = g_list_append(m, _("Not Available")); | |
6775 m = g_list_append(m, _("Occupied")); | |
6776 m = g_list_append(m, _("Free For Chat")); | |
6777 m = g_list_append(m, _("Invisible")); | |
6778 } else { | |
6779 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6780 m = g_list_append(m, _("Back")); |
8257 | 6781 m = g_list_append(m, _("Visible")); |
6782 m = g_list_append(m, _("Invisible")); | |
6783 } | |
4333 | 6784 |
6785 return m; | |
6786 } | |
6787 | |
7172 | 6788 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6789 GaimConnection *gc = data->gc; |
6790 OscarData *od = gc->proto_data; | |
7172 | 6791 GaimBuddy *b; |
6792 GaimGroup *g; | |
6793 | |
6794 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6795 oscar_free_name_data(data); | |
6796 return; | |
6797 } | |
6798 | |
6799 if (!(g = gaim_find_buddys_group(b))) { | |
6800 oscar_free_name_data(data); | |
6801 return; | |
6802 } | |
6803 | |
6804 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6805 |
6806 if (!aim_sncmp(data->name, gc->account->username)) | |
6807 gaim_check_comment(od, text); | |
6808 | |
7172 | 6809 oscar_free_name_data(data); |
6810 } | |
6811 | |
9030 | 6812 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6813 | |
6814 GaimBuddy *buddy; | |
6815 GaimConnection *gc; | |
6816 OscarData *od; | |
6817 struct name_data *data; | |
7172 | 6818 GaimGroup *g; |
6819 char *comment; | |
6820 gchar *comment_utf8; | |
9631 | 6821 gchar *title; |
7172 | 6822 |
9030 | 6823 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6824 | |
6825 buddy = (GaimBuddy *) node; | |
6826 gc = gaim_account_get_connection(buddy->account); | |
6827 od = gc->proto_data; | |
6828 | |
6829 data = g_new(struct name_data, 1); | |
6830 | |
6831 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6832 return; |
9030 | 6833 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6834 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6835 | |
6836 data->gc = gc; | |
9030 | 6837 data->name = g_strdup(buddy->name); |
7172 | 6838 data->nick = NULL; |
6839 | |
9631 | 6840 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6841 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6842 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6843 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6844 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6845 data); | |
9631 | 6846 g_free(title); |
7172 | 6847 |
6848 free(comment); | |
6849 g_free(comment_utf8); | |
6850 } | |
6851 | |
9030 | 6852 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6853 | |
6854 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6855 OscarData *od = gc->proto_data; |
9030 | 6856 |
4333 | 6857 GList *m = NULL; |
9030 | 6858 GaimBlistNodeAction *act; |
6859 | |
6860 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6861 oscar_buddycb_edit_comment, NULL); | |
6862 m = g_list_append(m, act); | |
7172 | 6863 |
4333 | 6864 if (od->icq) { |
4624 | 6865 #if 0 |
9030 | 6866 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6867 oscar_get_icqstatusmsg, NULL); | |
6868 m = g_list_append(m, act); | |
4624 | 6869 #endif |
4333 | 6870 } else { |
7011 | 6871 aim_userinfo_t *userinfo; |
9030 | 6872 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6873 | |
6874 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
6875 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
6876 | |
7011 | 6877 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 6878 act = gaim_blist_node_action_new(_("Direct IM"), |
6879 oscar_ask_direct_im, NULL); | |
6880 m = g_list_append(m, act); | |
5917 | 6881 } |
9466 | 6882 #if 0 |
7011 | 6883 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6884 act = gaim_blist_node_action_new(_("Get File"), |
6885 oscar_ask_getfile, NULL); | |
6886 m = g_list_append(m, act); | |
5917 | 6887 } |
4826 | 6888 #endif |
4333 | 6889 } |
5131 | 6890 } |
5197 | 6891 |
5131 | 6892 if (od->sess->ssi.received_data) { |
9030 | 6893 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6894 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
6895 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
6896 gaim_auth_sendrequest_menu, NULL); | |
6897 m = g_list_append(m, act); | |
4333 | 6898 } |
4916 | 6899 } |
6900 | |
4333 | 6901 return m; |
6902 } | |
6903 | |
9030 | 6904 |
6905 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6906 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6907 return oscar_buddy_menu((GaimBuddy *) node); | |
6908 } else { | |
6909 return NULL; | |
6910 } | |
6911 } | |
6912 | |
6913 | |
5575 | 6914 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6915 OscarData *od = gc->proto_data; |
5575 | 6916 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6917 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6918 od->setnick = TRUE; | |
6919 od->newsn = g_strdup(nick); | |
6920 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6921 } else { | |
6922 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6923 } | |
6924 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6925 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6926 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6927 } |
6928 } | |
6929 | |
9015 | 6930 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 6931 { |
9015 | 6932 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 6933 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 6934 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6935 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6936 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6937 gc); |
4333 | 6938 } |
6939 | |
9015 | 6940 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 6941 { |
9015 | 6942 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6943 OscarData *od = gc->proto_data; |
4333 | 6944 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6945 | |
6946 if (conn) { | |
6947 aim_admin_reqconfirm(od->sess, conn); | |
6948 } else { | |
6949 od->conf = TRUE; | |
6950 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6951 } | |
6952 } | |
6953 | |
9015 | 6954 static void oscar_show_email(GaimPluginAction *action) |
4333 | 6955 { |
9015 | 6956 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6957 OscarData *od = gc->proto_data; |
4333 | 6958 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6959 | |
6960 if (conn) { | |
6961 aim_admin_getinfo(od->sess, conn, 0x11); | |
6962 } else { | |
6963 od->reqemail = TRUE; | |
6964 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6965 } | |
6966 } | |
6967 | |
5575 | 6968 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6969 { |
7283 | 6970 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6971 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6972 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6973 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6974 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6975 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6976 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6977 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6978 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6979 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6980 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6981 |
9015 | 6982 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 6983 { |
9015 | 6984 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6985 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 6986 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6987 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6988 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6989 gc); |
4333 | 6990 } |
6991 | |
9015 | 6992 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 6993 { |
9015 | 6994 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6995 OscarData *od = gc->proto_data; |
4333 | 6996 gchar *nombre, *text, *tmp; |
6695 | 6997 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 6998 int num=0; |
6999 | |
6873 | 7000 text = g_strdup(""); |
4333 | 7001 |
4785 | 7002 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7003 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7004 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7005 continue; | |
6695 | 7006 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7007 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7008 continue; |
6695 | 7009 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7010 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7011 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7012 continue; | |
7013 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7014 if (gaim_buddy_get_alias_only(buddy)) |
7015 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7016 else |
7017 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7018 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7019 g_free(text); |
7020 text = tmp; | |
7021 g_free(nombre); | |
7022 num++; | |
7023 } | |
4333 | 7024 } |
2979 | 7025 } |
4333 | 7026 } |
7027 | |
7028 if (!num) { | |
7029 g_free(text); | |
6873 | 7030 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7031 } | |
7032 | |
7033 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7034 "the following buddies"), _("You can re-request " | |
7035 "authorization from these buddies by " | |
7036 "right-clicking on them and selecting " | |
7037 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7038 g_free(text); |
2979 | 7039 } |
7040 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7041 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7042 { |
8950 | 7043 OscarData *od = (OscarData *)gc->proto_data; |
7044 | |
7045 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7046 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7047 |
9015 | 7048 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7049 { |
9015 | 7050 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7051 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7052 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7053 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7054 "searching for."), |
8697 | 7055 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7056 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7057 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7058 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7059 |
5917 | 7060 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 7061 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 7062 |
7334 | 7063 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 7064 aim_srv_setavailmsg(od->sess, text); |
7065 } | |
7066 | |
9879 | 7067 static void oscar_show_setavailmsg(GaimPluginAction *action) |
5917 | 7068 { |
9879 | 7069 GaimConnection *gc = (GaimConnection *) action->context; |
7313 | 7070 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
7071 _("I'm doing work and hoping for a distraction--IM me!"), | |
8697 | 7072 TRUE, FALSE, NULL, |
5917 | 7073 _("OK"), G_CALLBACK(oscar_setavailmsg), |
7074 _("Cancel"), NULL, | |
7075 gc); | |
7076 } | |
7077 | |
9015 | 7078 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7079 { |
9015 | 7080 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7081 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7082 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7083 |
9015 | 7084 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7085 { |
9015 | 7086 GaimConnection *gc = (GaimConnection *) action->context; |
9809 | 7087 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7088 } |
7089 | |
9015 | 7090 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7091 { |
9015 | 7092 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7093 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7094 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7095 |
9015 | 7096 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7097 { |
9015 | 7098 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7099 OscarData *od = gc->proto_data; |
5575 | 7100 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6400
diff
changeset
|
7101 gaim_notify_uri(gc, substituted); |
5517 | 7102 g_free(substituted); |
4333 | 7103 } |
7104 | |
9015 | 7105 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7106 { |
9015 | 7107 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7108 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7109 } | |
7110 | |
5842 | 7111 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7112 { | |
7283 | 7113 OscarData *od = gc->proto_data; |
5844 | 7114 aim_session_t *sess = od->sess; |
5842 | 7115 FILE *file; |
7116 struct stat st; | |
5844 | 7117 |
6039 | 7118 if (iconfile == NULL) { |
8363 | 7119 aim_ssi_delicon(od->sess); |
6039 | 7120 } else if (!stat(iconfile, &st)) { |
5842 | 7121 char *buf = g_malloc(st.st_size); |
7122 file = fopen(iconfile, "rb"); | |
7123 if (file) { | |
6052 | 7124 md5_state_t *state; |
6039 | 7125 char md5[16]; |
9532 | 7126 /* XXX - Use g_file_get_contents()? */ |
5842 | 7127 int len = fread(buf, 1, st.st_size, file); |
6039 | 7128 fclose(file); |
6052 | 7129 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7130 md5_init(state); |
7131 md5_append(state, buf, len); | |
7132 md5_finish(state, md5); | |
7133 g_free(state); | |
7134 aim_ssi_seticon(sess, md5, 16); | |
7135 } else | |
8660 | 7136 gaim_debug_error("oscar", |
5842 | 7137 "Can't open buddy icon file!\n"); |
7138 g_free(buf); | |
7139 } else | |
8660 | 7140 gaim_debug_error("oscar", |
5842 | 7141 "Can't stat buddy icon file!\n"); |
7142 } | |
7143 | |
7144 | |
9015 | 7145 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7146 { |
9015 | 7147 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7148 OscarData *od = gc->proto_data; |
4333 | 7149 GList *m = NULL; |
9015 | 7150 GaimPluginAction *act; |
7151 | |
7152 act = gaim_plugin_action_new(_("Set User Info..."), | |
7153 oscar_show_set_info); | |
7154 m = g_list_append(m, act); | |
4333 | 7155 |
8576 | 7156 if (od->icq) { |
9015 | 7157 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7158 oscar_show_set_info_icqurl); | |
7159 m = g_list_append(m, act); | |
8576 | 7160 } |
7161 | |
9879 | 7162 if (!od->icq) { |
7163 act = gaim_plugin_action_new(_("Set Available Message..."), | |
7164 oscar_show_setavailmsg); | |
7165 m = g_list_append(m, act); | |
7166 } | |
5917 | 7167 |
9015 | 7168 act = gaim_plugin_action_new(_("Change Password..."), |
7169 oscar_change_pass); | |
7170 m = g_list_append(m, act); | |
4617 | 7171 |
7172 if (od->sess->authinfo->chpassurl) { | |
9015 | 7173 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7174 oscar_show_chpassurl); | |
7175 m = g_list_append(m, act); | |
7176 | |
7177 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7178 oscar_show_imforwardingurl); | |
7179 m = g_list_append(m, act); | |
7026 | 7180 } |
7181 | |
5238 | 7182 if (!od->icq) { |
4617 | 7183 /* AIM actions */ |
7184 m = g_list_append(m, NULL); | |
4333 | 7185 |
9015 | 7186 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7187 oscar_show_format_screenname); | |
7188 m = g_list_append(m, act); | |
7189 | |
7190 act = gaim_plugin_action_new(_("Confirm Account"), | |
7191 oscar_confirm_account); | |
7192 m = g_list_append(m, act); | |
7193 | |
7194 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7195 oscar_show_email); | |
7196 m = g_list_append(m, act); | |
7197 | |
7198 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7199 oscar_show_change_email); | |
7200 m = g_list_append(m, act); | |
2086 | 7201 } |
4333 | 7202 |
7203 m = g_list_append(m, NULL); | |
7204 | |
9015 | 7205 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7206 oscar_show_awaitingauth); | |
7207 m = g_list_append(m, act); | |
4333 | 7208 |
2086 | 7209 m = g_list_append(m, NULL); |
4333 | 7210 |
9015 | 7211 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7212 oscar_show_find_email); | |
7213 m = g_list_append(m, act); | |
4333 | 7214 |
8591 | 7215 #if 0 |
9015 | 7216 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7217 show_find_info); | |
7218 m = g_list_append(m, act); | |
8591 | 7219 #endif |
2086 | 7220 |
7221 return m; | |
7222 } | |
7223 | |
5575 | 7224 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7225 { |
7283 | 7226 OscarData *od = gc->proto_data; |
4617 | 7227 |
7228 if (od->icq) { | |
7229 aim_icq_changepasswd(od->sess, new); | |
2086 | 7230 } else { |
4617 | 7231 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7232 if (conn) { | |
7233 aim_admin_changepasswd(od->sess, conn, new, old); | |
7234 } else { | |
7235 od->chpass = TRUE; | |
7236 od->oldp = g_strdup(old); | |
7237 od->newp = g_strdup(new); | |
7238 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7239 } | |
2086 | 7240 } |
7241 } | |
7242 | |
6059 | 7243 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7244 { |
7283 | 7245 OscarData *od = gc->proto_data; |
8971 | 7246 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
|
7247 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7248 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7249 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7250 |
8971 | 7251 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7252 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7253 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7254 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7255 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7256 GAIM_PRPL_API_VERSION, |
9308 | 7257 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7258 NULL, /* user_splits */ |
7259 NULL, /* protocol_options */ | |
7260 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7261 oscar_list_icon, /* list_icon */ | |
7262 oscar_list_emblems, /* list_emblems */ | |
7263 oscar_status_text, /* status_text */ | |
7264 oscar_tooltip_text, /* tooltip_text */ | |
7265 oscar_away_states, /* away_states */ | |
7266 oscar_blist_node_menu, /* blist_node_menu */ | |
7267 oscar_chat_info, /* chat_info */ | |
9754 | 7268 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7269 oscar_login, /* login */ |
7270 oscar_close, /* close */ | |
7271 oscar_send_im, /* send_im */ | |
7272 oscar_set_info, /* set_info */ | |
7273 oscar_send_typing, /* send_typing */ | |
7274 oscar_get_info, /* get_info */ | |
7275 oscar_set_away, /* set_away */ | |
7276 oscar_set_idle, /* set_idle */ | |
7277 oscar_change_passwd, /* change_passwd */ | |
7278 oscar_add_buddy, /* add_buddy */ | |
7279 oscar_add_buddies, /* add_buddies */ | |
7280 oscar_remove_buddy, /* remove_buddy */ | |
7281 oscar_remove_buddies, /* remove_buddies */ | |
7282 oscar_add_permit, /* add_permit */ | |
7283 oscar_add_deny, /* add_deny */ | |
7284 oscar_rem_permit, /* rem_permit */ | |
7285 oscar_rem_deny, /* rem_deny */ | |
7286 oscar_set_permit_deny, /* set_permit_deny */ | |
7287 oscar_warn, /* warn */ | |
7288 oscar_join_chat, /* join_chat */ | |
7289 NULL, /* reject_chat */ | |
7290 oscar_chat_invite, /* chat_invite */ | |
7291 oscar_chat_leave, /* chat_leave */ | |
7292 NULL, /* chat_whisper */ | |
7293 oscar_send_chat, /* chat_send */ | |
7294 oscar_keepalive, /* keepalive */ | |
7295 NULL, /* register_user */ | |
7296 NULL, /* get_cb_info */ | |
7297 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7298 #ifndef NOSSI |
9475 | 7299 oscar_alias_buddy, /* alias_buddy */ |
7300 oscar_move_buddy, /* group_buddy */ | |
7301 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7302 #else |
9475 | 7303 NULL, /* alias_buddy */ |
7304 NULL, /* group_buddy */ | |
7305 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7306 #endif |
9475 | 7307 NULL, /* buddy_free */ |
7308 oscar_convo_closed, /* convo_closed */ | |
7309 NULL, /* normalize */ | |
7310 oscar_set_icon, /* set_buddy_icon */ | |
7311 NULL, /* remove_group */ | |
7312 NULL, /* get_cb_real_name */ | |
7313 NULL, /* set_chat_topic */ | |
7314 NULL, /* find_blist_chat */ | |
7315 NULL, /* roomlist_get_list */ | |
7316 NULL, /* roomlist_cancel */ | |
7317 NULL, /* roomlist_expand_category */ | |
7318 oscar_can_receive_file, /* can_receive_file */ | |
7319 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7320 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7321 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7322 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7323 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7324 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7325 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7326 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7327 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7328 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7329 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7330 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7331 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7332 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7333 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7334 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7335 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7336 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7337 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7338 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7339 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7340 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7341 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7342 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7343 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7344 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7345 NULL, /**< ui_info */ |
8993 | 7346 &prpl_info, /**< extra_info */ |
7347 NULL, | |
9015 | 7348 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7349 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7350 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7351 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7352 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7353 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7354 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7355 |
9830 | 7356 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7357 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7358 | |
7359 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7360 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7361 | |
7362 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7363 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7364 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7365 my_protocol = plugin; |
2086 | 7366 } |
7367 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7368 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |