Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 7082:25a616f16b6c
[gaim-migrate @ 7647]
Added more core wrappers for the glib mainloops, and replaced the last
GTK+ code in OSCAR with them.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 30 Sep 2003 22:55:22 +0000 |
parents | fc9c74cfb306 |
children | 3100a6e03644 |
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 | |
7 * Some code copyright (C) 2001-2003, Mark Doliner <thekingant@users.sourceforge.net> | |
8 * | |
9 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
10 * Some libfaim code copyright (C) 2001-2003 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" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
33 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "ft.h" |
6982 | 35 #include "imgstore.h" |
2086 | 36 #include "multi.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
37 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
38 #include "privacy.h" |
2086 | 39 #include "prpl.h" |
4889 | 40 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
41 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
42 #include "util.h" |
6115
11bedb793a44
[gaim-migrate @ 6578]
Christian Hammond <chipx86@chipx86.com>
parents:
6113
diff
changeset
|
43 #include "html.h" |
5872
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 |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
48 /* XXX CORE/UI */ |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
49 #include "gtkinternal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
50 #include "gaim.h" |
3630 | 51 |
2086 | 52 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
53 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
54 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
55 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
56 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
57 #define UC_AB 0x20 |
3079 | 58 #define UC_WIRELESS 0x40 |
6318 | 59 #define UC_HIPTOP 0x80 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
60 |
2086 | 61 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
62 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
63 static GaimPlugin *my_protocol = NULL; |
4249 | 64 |
6871 | 65 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE; |
66 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE; | |
3458 | 67 |
4665 | 68 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
69 static fu8_t features_icq[] = {0x01, 0x06}; | |
2086 | 70 |
71 struct oscar_data { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
72 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
73 aim_conn_t *conn; |
2086 | 74 |
75 guint cnpa; | |
76 guint paspa; | |
3694 | 77 guint emlpa; |
4804 | 78 guint icopa; |
2086 | 79 |
4823 | 80 gboolean iconconnecting; |
5842 | 81 gboolean set_icon; |
4823 | 82 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
83 GSList *create_rooms; |
2086 | 84 |
85 gboolean conf; | |
86 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
87 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
88 char *email; |
2979 | 89 gboolean setnick; |
90 char *newsn; | |
2086 | 91 gboolean chpass; |
92 char *oldp; | |
93 char *newp; | |
5842 | 94 |
2086 | 95 GSList *oscar_chats; |
96 GSList *direct_ims; | |
3630 | 97 GSList *file_transfers; |
4738 | 98 GHashTable *buddyinfo; |
4804 | 99 GSList *requesticon; |
2086 | 100 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
101 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
102 gboolean icq; |
4804 | 103 guint icontimer; |
5968 | 104 guint getblisttimer; |
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. */ |
5679 | 132 GaimConversation *cnv; /* 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 | |
137 struct 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; |
2086 | 143 }; |
144 | |
145 struct ask_direct { | |
5575 | 146 GaimConnection *gc; |
2086 | 147 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
148 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
149 fu8_t cookie[8]; |
2086 | 150 }; |
151 | |
7011 | 152 /* |
153 * Various PRPL-specific buddy info that we want to keep track of | |
154 * Some other info is maintained by locate.c, and I'd like to move | |
155 * the rest of this to libfaim, mostly im.c | |
156 */ | |
4738 | 157 struct buddyinfo { |
158 gboolean typingnot; | |
6292 | 159 gchar *availmsg; |
6857 | 160 fu32_t ipaddr; |
5836 | 161 |
162 unsigned long ico_me_len; | |
163 unsigned long ico_me_csum; | |
164 time_t ico_me_time; | |
165 gboolean ico_informed; | |
4738 | 166 |
167 unsigned long ico_len; | |
168 unsigned long ico_csum; | |
169 time_t ico_time; | |
170 gboolean ico_need; | |
2086 | 171 }; |
172 | |
4230 | 173 struct name_data { |
5575 | 174 GaimConnection *gc; |
4230 | 175 gchar *name; |
3453 | 176 gchar *nick; |
3141 | 177 }; |
178 | |
5129 | 179 static char *msgerrreason[] = { |
180 N_("Invalid error"), | |
181 N_("Invalid SNAC"), | |
182 N_("Rate to host"), | |
183 N_("Rate to client"), | |
184 N_("Not logged in"), | |
185 N_("Service unavailable"), | |
186 N_("Service not defined"), | |
187 N_("Obsolete SNAC"), | |
188 N_("Not supported by host"), | |
189 N_("Not supported by client"), | |
190 N_("Refused by client"), | |
191 N_("Reply too big"), | |
192 N_("Responses lost"), | |
193 N_("Request denied"), | |
194 N_("Busted SNAC payload"), | |
195 N_("Insufficient rights"), | |
196 N_("In local permit/deny"), | |
197 N_("Too evil (sender)"), | |
198 N_("Too evil (receiver)"), | |
199 N_("User temporarily unavailable"), | |
200 N_("No match"), | |
201 N_("List overflow"), | |
202 N_("Request ambiguous"), | |
203 N_("Queue full"), | |
204 N_("Not while on AOL") | |
205 }; | |
206 static int msgerrreasonlen = 25; | |
207 | |
208 /* All the libfaim->gaim callback functions */ | |
209 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
210 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
211 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
212 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
213 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
214 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
215 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
216 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
217 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
218 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 219 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
5129 | 220 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
221 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_chat_join (aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_chat_leave (aim_session_t *, aim_frame_t *, ...); | |
224 static int gaim_chat_info_update (aim_session_t *, aim_frame_t *, ...); | |
225 static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); | |
226 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 229 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 230 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
231 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
237 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
238 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
239 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
240 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
241 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
242 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
243 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
244 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
245 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
257 #ifndef NOSSI | |
258 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
266 #endif | |
267 | |
268 /* for DirectIM/image transfer */ | |
269 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 272 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 273 |
274 /* for file transfer */ | |
275 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
276 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
277 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
278 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
279 | |
280 /* for icons */ | |
281 static gboolean gaim_icon_timerfunc(gpointer data); | |
282 | |
5306 | 283 /* prpl actions - remove this at some point */ |
5954 | 284 static void oscar_set_info(GaimConnection *gc, const char *text); |
5306 | 285 |
5836 | 286 static void oscar_free_name_data(struct name_data *data) { |
4230 | 287 g_free(data->name); |
288 g_free(data->nick); | |
289 g_free(data); | |
290 } | |
291 | |
5836 | 292 static void oscar_free_buddyinfo(void *data) { |
293 struct buddyinfo *bi = data; | |
6292 | 294 g_free(bi->availmsg); |
5836 | 295 g_free(bi); |
296 } | |
297 | |
5129 | 298 static fu32_t oscar_encoding_check(const char *utf8) |
299 { | |
300 int i = 0; | |
301 fu32_t encodingflag = 0; | |
302 | |
303 /* Determine how we can send this message. Per the warnings elsewhere | |
304 * in this file, these little checks determine the simplest encoding | |
305 * we can use for a given message send using it. */ | |
306 while (utf8[i]) { | |
307 if ((unsigned char)utf8[i] > 0x7f) { | |
308 /* not ASCII! */ | |
309 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
310 break; | |
311 } | |
312 i++; | |
313 } | |
314 while (utf8[i]) { | |
315 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
316 * followed by 0xc0-0xc3 in the second */ | |
317 if ((unsigned char)utf8[i] < 0x80) { | |
318 i++; | |
319 continue; | |
320 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
321 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
322 i += 2; | |
323 continue; | |
324 } | |
325 encodingflag = AIM_IMFLAGS_UNICODE; | |
326 break; | |
327 } | |
328 | |
329 return encodingflag; | |
330 } | |
331 | |
332 static fu32_t oscar_encoding_parse(const char *enc) | |
333 { | |
334 char *charset; | |
335 | |
336 /* If anything goes wrong, fall back on ASCII and print a message */ | |
337 if (enc == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
338 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
339 "Encoding was null, that's odd\n"); |
5129 | 340 return 0; |
341 } | |
342 charset = strstr(enc, "charset="); | |
343 if (charset == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
344 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
345 "No charset specified for info, assuming ASCII\n"); |
5129 | 346 return 0; |
347 } | |
348 charset += 8; | |
349 if (!strcmp(charset, "\"us-ascii\"") || !strcmp(charset, "\"utf-8\"")) { | |
350 /* UTF-8 is our native charset, ASCII is a proper subset */ | |
351 return 0; | |
352 } else if (!strcmp(charset, "\"iso-8859-1\"")) { | |
353 return AIM_IMFLAGS_ISO_8859_1; | |
354 } else if (!strcmp(charset, "\"unicode-2-0\"")) { | |
355 return AIM_IMFLAGS_UNICODE; | |
356 } else { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
357 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
358 "Unrecognized character set '%s', using ASCII\n", charset); |
5129 | 359 return 0; |
360 } | |
361 } | |
362 | |
363 gchar *oscar_encoding_to_utf8(const char *encoding, char *text, int textlen) | |
364 { | |
365 gchar *utf8 = NULL; | |
366 int flags = oscar_encoding_parse(encoding); | |
367 | |
368 switch (flags) { | |
369 case 0: | |
370 utf8 = g_strndup(text, textlen); | |
371 break; | |
372 case AIM_IMFLAGS_ISO_8859_1: | |
373 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
374 break; | |
375 case AIM_IMFLAGS_UNICODE: | |
376 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
377 break; | |
378 } | |
379 | |
380 return utf8; | |
381 } | |
382 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
383 static struct direct_im *find_direct_im(struct oscar_data *od, const char *who) { |
2086 | 384 GSList *d = od->direct_ims; |
385 struct direct_im *m = NULL; | |
386 | |
387 while (d) { | |
388 m = (struct direct_im *)d->data; | |
4355 | 389 if (!aim_sncmp(who, m->name)) |
4269 | 390 return m; |
2086 | 391 d = d->next; |
392 } | |
393 | |
4269 | 394 return NULL; |
2086 | 395 } |
396 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
397 static char *extract_name(const char *name) { |
4121 | 398 char *tmp, *x; |
2086 | 399 int i, j; |
4120 | 400 |
401 if (!name) | |
4121 | 402 return NULL; |
403 | |
4120 | 404 x = strchr(name, '-'); |
4121 | 405 |
2086 | 406 if (!x) return NULL; |
407 x = strchr(++x, '-'); | |
408 if (!x) return NULL; | |
409 tmp = g_strdup(++x); | |
410 | |
411 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
412 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
413 if (x[i] != '%') { |
2086 | 414 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
415 continue; |
2086 | 416 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
417 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
418 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
419 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 420 } |
421 | |
422 tmp[j] = 0; | |
423 return tmp; | |
424 } | |
425 | |
5575 | 426 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
2086 | 427 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
428 struct chat_connection *c = NULL; | |
429 | |
430 while (g) { | |
431 c = (struct chat_connection *)g->data; | |
432 if (c->id == id) | |
433 break; | |
434 g = g->next; | |
435 c = NULL; | |
436 } | |
437 | |
438 return c; | |
439 } | |
440 | |
5575 | 441 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
|
442 aim_conn_t *conn) { |
2086 | 443 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
444 struct chat_connection *c = NULL; | |
445 | |
446 while (g) { | |
447 c = (struct chat_connection *)g->data; | |
448 if (c->conn == conn) | |
449 break; | |
450 g = g->next; | |
451 c = NULL; | |
452 } | |
453 | |
454 return c; | |
455 } | |
456 | |
4617 | 457 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) { |
5575 | 458 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
459 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5679 | 460 GaimConversation *cnv; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
461 struct direct_im *dim; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
462 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
463 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
464 |
4617 | 465 sn = g_strdup(aim_odc_getsn(conn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
466 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
467 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
468 "%s disconnected Direct IM.\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
469 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
470 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
471 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
472 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
473 |
3008 | 474 if (dim->connected) |
475 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); | |
476 else | |
477 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), sn); | |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
478 |
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
479 cnv = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); |
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
480 if (cnv) |
6982 | 481 gaim_conversation_write(cnv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
482 |
5579 | 483 gaim_conversation_update_progress(cnv, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
484 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
485 g_free(dim); /* I guess? I don't see it anywhere else... -- mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
486 g_free(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
487 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
488 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
489 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
490 |
4617 | 491 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
492 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
493 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 494 GaimConnection *gc = sess ? sess->aux_data : NULL; |
4617 | 495 struct oscar_data *od; |
2086 | 496 |
497 if (!gc) { | |
498 /* gc is null. we return, else we seg SIGSEG on next line. */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
499 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
500 "oscar callback for closed connection (1).\n"); |
2086 | 501 return; |
502 } | |
503 | |
4617 | 504 od = (struct oscar_data *)gc->proto_data; |
2086 | 505 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
506 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 507 /* oh boy. this is probably bad. i guess the only thing we |
508 * can really do is return? */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
509 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
510 "oscar callback for closed connection (2).\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
511 gaim_debug(GAIM_DEBUG_MISC, "oscar", "gc = %p\n", gc); |
2086 | 512 return; |
513 } | |
514 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
515 if (condition & GAIM_INPUT_READ) { |
4617 | 516 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
517 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
518 "got information on rendezvous listener\n"); |
4617 | 519 if (aim_handlerendconnect(od->sess, conn) < 0) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
520 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
521 "connection error (rendezvous listener)\n"); |
4617 | 522 aim_conn_kill(od->sess, &conn); |
2086 | 523 } |
524 } else { | |
4617 | 525 if (aim_get_command(od->sess, conn) >= 0) { |
526 aim_rxdispatch(od->sess); | |
6029 | 527 if (od->killme) { |
528 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "Waiting to be destroyed\n"); | |
529 return; | |
530 } | |
2086 | 531 } else { |
532 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 533 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
534 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
535 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
536 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 537 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
538 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
5420 | 539 char *buf; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
540 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
541 "disconnected from chat room %s\n", c->name); |
2086 | 542 c->conn = NULL; |
543 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
544 gaim_input_remove(c->inpa); |
2086 | 545 c->inpa = 0; |
546 c->fd = -1; | |
4617 | 547 aim_conn_kill(od->sess, &conn); |
5420 | 548 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
549 gaim_notify_error(gc, NULL, buf, NULL); |
5420 | 550 g_free(buf); |
2086 | 551 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 552 if (od->cnpa > 0) |
553 gaim_input_remove(od->cnpa); | |
554 od->cnpa = 0; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
555 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
556 "removing chatnav input watcher\n"); |
4617 | 557 while (od->create_rooms) { |
558 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
559 g_free(cr->name); |
4617 | 560 od->create_rooms = |
561 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
562 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
563 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
564 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
565 NULL); |
2086 | 566 } |
4617 | 567 aim_conn_kill(od->sess, &conn); |
2086 | 568 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 569 if (od->paspa > 0) |
570 gaim_input_remove(od->paspa); | |
571 od->paspa = 0; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
572 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
573 "removing authconn input watcher\n"); |
4617 | 574 aim_conn_kill(od->sess, &conn); |
3694 | 575 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 576 if (od->emlpa > 0) |
577 gaim_input_remove(od->emlpa); | |
578 od->emlpa = 0; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
579 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
580 "removing email input watcher\n"); |
4617 | 581 aim_conn_kill(od->sess, &conn); |
4804 | 582 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
583 if (od->icopa > 0) | |
584 gaim_input_remove(od->icopa); | |
585 od->icopa = 0; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
586 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
587 "removing icon input watcher\n"); |
4804 | 588 aim_conn_kill(od->sess, &conn); |
2086 | 589 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
590 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 591 gaim_odc_disconnect(od->sess, conn); |
592 aim_conn_kill(od->sess, &conn); | |
2086 | 593 } else { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
594 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
595 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
596 conn->type); |
4617 | 597 aim_conn_kill(od->sess, &conn); |
2086 | 598 } |
599 } | |
600 } | |
601 } | |
602 } | |
603 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
604 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
2086 | 605 char *s = g_strdup_vprintf(format, va); |
606 char buf[256]; | |
607 char *t; | |
5575 | 608 GaimConnection *gc = sess->aux_data; |
609 | |
610 g_snprintf(buf, sizeof(buf), "%s %d: ", gaim_account_get_username(gaim_connection_get_account(gc)), level); | |
2086 | 611 t = g_strconcat(buf, s, NULL); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
612 gaim_debug(GAIM_DEBUG_INFO, "oscar", t); |
2086 | 613 if (t[strlen(t)-1] != '\n') |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
614 gaim_debug(GAIM_DEBUG_INFO, NULL, "\n"); |
2086 | 615 g_free(t); |
616 g_free(s); | |
617 } | |
618 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
619 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 620 { |
5575 | 621 GaimConnection *gc = data; |
4617 | 622 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
623 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
624 aim_conn_t *conn; |
2086 | 625 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
626 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 627 close(source); |
628 return; | |
629 } | |
630 | |
4617 | 631 od = gc->proto_data; |
632 sess = od->sess; | |
2086 | 633 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 634 |
635 conn->fd = source; | |
2086 | 636 |
637 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
638 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 639 return; |
640 } | |
641 | |
642 aim_conn_completeconnect(sess, conn); | |
4617 | 643 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
644 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
645 "Password sent, waiting for response\n"); |
2086 | 646 } |
647 | |
5575 | 648 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
649 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
650 aim_conn_t *conn; |
2086 | 651 char buf[256]; |
5575 | 652 GaimConnection *gc = gaim_account_get_connection(account); |
4617 | 653 struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1); |
2086 | 654 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
655 gaim_debug(GAIM_DEBUG_MISC, "oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
656 |
5575 | 657 if (isdigit(*(gaim_account_get_username(account)))) { |
4617 | 658 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
659 } else { |
6622 | 660 gc->flags |= GAIM_CONNECTION_HTML; |
661 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
662 } |
5836 | 663 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 664 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
665 sess = g_new0(aim_session_t, 1); |
2086 | 666 |
667 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | |
668 aim_setdebuggingcb(sess, oscar_debug); | |
669 | |
670 /* we need an immediate queue because we don't use a while-loop to | |
671 * see if things need to be sent. */ | |
672 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); | |
4617 | 673 od->sess = sess; |
2086 | 674 sess->aux_data = gc; |
675 | |
676 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
677 if (conn == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
678 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
679 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
680 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 681 return; |
682 } | |
683 | |
5575 | 684 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(account)); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
685 gaim_connection_update_progress(gc, buf, 2, 5); |
2086 | 686 |
4649 | 687 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 688 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
689 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
690 | |
691 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
692 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 693 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
694 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
695 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 696 return; |
697 } | |
5575 | 698 aim_request_login(sess, conn, gaim_account_get_username(account)); |
699 } | |
700 | |
701 static void oscar_close(GaimConnection *gc) { | |
4617 | 702 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
703 | |
704 while (od->oscar_chats) { | |
705 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 706 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
707 gaim_input_remove(n->inpa); |
2086 | 708 g_free(n->name); |
709 g_free(n->show); | |
4617 | 710 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 711 g_free(n); |
712 } | |
4617 | 713 while (od->direct_ims) { |
714 struct direct_im *n = od->direct_ims->data; | |
2086 | 715 if (n->watcher > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
716 gaim_input_remove(n->watcher); |
4617 | 717 od->direct_ims = g_slist_remove(od->direct_ims, n); |
2086 | 718 g_free(n); |
719 } | |
4617 | 720 /* BBB */ |
721 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
722 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
723 xfer = (GaimXfer *)od->file_transfers->data; |
4617 | 724 gaim_xfer_destroy(xfer); |
3630 | 725 } |
4804 | 726 while (od->requesticon) { |
727 char *sn = od->requesticon->data; | |
728 od->requesticon = g_slist_remove(od->requesticon, sn); | |
729 free(sn); | |
730 } | |
4738 | 731 g_hash_table_destroy(od->buddyinfo); |
4617 | 732 while (od->create_rooms) { |
733 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
734 g_free(cr->name); |
4617 | 735 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
736 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
737 } |
4617 | 738 if (od->email) |
739 g_free(od->email); | |
740 if (od->newp) | |
741 g_free(od->newp); | |
742 if (od->oldp) | |
743 g_free(od->oldp); | |
2086 | 744 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
745 gaim_input_remove(gc->inpa); |
4617 | 746 if (od->cnpa > 0) |
747 gaim_input_remove(od->cnpa); | |
748 if (od->paspa > 0) | |
749 gaim_input_remove(od->paspa); | |
750 if (od->emlpa > 0) | |
751 gaim_input_remove(od->emlpa); | |
4804 | 752 if (od->icopa > 0) |
753 gaim_input_remove(od->icopa); | |
6907 | 754 if (od->icontimer > 0) |
4832 | 755 g_source_remove(od->icontimer); |
5968 | 756 if (od->getblisttimer) |
757 g_source_remove(od->getblisttimer); | |
4617 | 758 aim_session_kill(od->sess); |
759 g_free(od->sess); | |
760 od->sess = NULL; | |
2086 | 761 g_free(gc->proto_data); |
762 gc->proto_data = NULL; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
763 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Signed off.\n"); |
2086 | 764 } |
765 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
766 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 767 GaimConnection *gc = data; |
4617 | 768 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
769 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
770 aim_conn_t *bosconn; |
2086 | 771 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
772 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 773 close(source); |
774 return; | |
775 } | |
776 | |
4617 | 777 od = gc->proto_data; |
778 sess = od->sess; | |
779 bosconn = od->conn; | |
4366 | 780 bosconn->fd = source; |
2086 | 781 |
782 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
783 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 784 return; |
785 } | |
786 | |
787 aim_conn_completeconnect(sess, bosconn); | |
4617 | 788 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
789 gaim_connection_update_progress(gc, |
5577
7ed9999926af
[gaim-migrate @ 5981]
Christian Hammond <chipx86@chipx86.com>
parents:
5576
diff
changeset
|
790 _("Connection established, cookie sent"), 4, 5); |
2086 | 791 } |
792 | |
4617 | 793 /* BBB */ |
4656 | 794 /* |
795 * This little area in oscar.c is the nexus of file transfer code, | |
796 * so I wrote a little explanation of what happens. I am such a | |
797 * ninja. | |
798 * | |
799 * The series of events for a file send is: | |
800 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
801 * -User chooses a file and oscar_xfer_init is called. It establishs a | |
802 * listening socket, then asks the remote user to connect to us (and | |
803 * gives them the file name, port, IP, etc.) | |
804 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
805 * in oscar_sendfile_estblsh) | |
806 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
807 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
808 * connection. | |
809 * -We get drunk because file transfer kicks ass. | |
810 * | |
811 * The series of events for a file receive is: | |
812 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
813 * -Gaim user selects file to name and location to save file to and | |
814 * oscar_xfer_init is called | |
815 * -It connects to the remote user using the IP they gave us earlier | |
816 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
817 * them an AIM_CB_OFT_ACK. | |
818 * -They begin to send us lots of raw data. | |
819 * -When they finish sending data we send an AIM_CB_OFT_DONE and then close | |
820 * the connectionn. | |
821 */ | |
822 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
823 | |
824 /* XXX - This function is pretty ugly */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
825 static void oscar_xfer_init(GaimXfer *xfer) |
4656 | 826 { |
5146 | 827 struct aim_oft_info *oft_info = xfer->data; |
5575 | 828 GaimConnection *gc = oft_info->sess->aux_data; |
5146 | 829 struct oscar_data *od = gc->proto_data; |
4656 | 830 |
831 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { | |
832 int i; | |
833 | |
834 xfer->filename = g_path_get_basename(xfer->local_filename); | |
5146 | 835 strncpy(oft_info->fh.name, xfer->filename, 64); |
836 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
837 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
838 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
4656 | 839 |
840 /* | |
5146 | 841 * First try the port specified earlier (5190). If that fails, |
842 * increment by 1 and try again. | |
4656 | 843 */ |
5146 | 844 aim_sendfile_listen(od->sess, oft_info); |
845 for (i=0; (i<5 && !oft_info->conn); i++) { | |
846 xfer->local_port = oft_info->port = oft_info->port + 1; | |
847 aim_sendfile_listen(od->sess, oft_info); | |
4656 | 848 } |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
849 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
850 "port is %d, ip is %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
851 xfer->local_port, oft_info->clientip); |
5146 | 852 if (oft_info->conn) { |
853 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
854 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
855 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
4656 | 856 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
857 gaim_notify_error(gc, NULL, _("File Transfer Aborted"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
858 _("Unable to establish listener socket.")); |
4656 | 859 /* XXX - The below line causes a crash because the transfer is canceled before the "Ok" callback on the file selection thing exists, I think */ |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
860 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 861 } |
862 } else if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
5146 | 863 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); |
864 if (oft_info->conn) { | |
865 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
866 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
867 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), xfer->remote_ip, xfer->remote_port, |
5575 | 868 oscar_sendfile_connected, xfer); |
4656 | 869 if (xfer->fd == -1) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
870 gaim_notify_error(gc, NULL, _("File Transfer Aborted"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
871 _("Unable to establish file descriptor.")); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
872 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 873 } |
874 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
875 gaim_notify_error(gc, NULL, _("File Transfer Aborted"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
876 _("Unable to create new connection.")); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
877 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 878 /* Try a different port? Ask them to connect to us? */ |
879 } | |
880 | |
881 } | |
882 } | |
883 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
884 static void oscar_xfer_start(GaimXfer *xfer) |
4656 | 885 { |
5146 | 886 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
887 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_start\n"); |
4656 | 888 /* I'm pretty sure we don't need to do jack here. Nor Jill. */ |
889 } | |
890 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
891 static void oscar_xfer_end(GaimXfer *xfer) |
4656 | 892 { |
5146 | 893 struct aim_oft_info *oft_info = xfer->data; |
5575 | 894 GaimConnection *gc = oft_info->sess->aux_data; |
5146 | 895 struct oscar_data *od = gc->proto_data; |
4656 | 896 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
897 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_end\n"); |
5146 | 898 |
899 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
900 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
901 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
902 } | |
903 | |
904 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
905 aim_oft_destroyinfo(oft_info); | |
4656 | 906 xfer->data = NULL; |
5146 | 907 od->file_transfers = g_slist_remove(od->file_transfers, xfer); |
4656 | 908 } |
909 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
910 static void oscar_xfer_cancel_send(GaimXfer *xfer) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
911 { |
5146 | 912 struct aim_oft_info *oft_info = xfer->data; |
5575 | 913 GaimConnection *gc = oft_info->sess->aux_data; |
5146 | 914 struct oscar_data *od = gc->proto_data; |
4763 | 915 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
916 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
917 "AAA - in oscar_xfer_cancel_send\n"); |
5146 | 918 |
919 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
920 | |
921 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
922 aim_oft_destroyinfo(oft_info); | |
4763 | 923 xfer->data = NULL; |
5146 | 924 od->file_transfers = g_slist_remove(od->file_transfers, xfer); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
925 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
926 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
927 static void oscar_xfer_cancel_recv(GaimXfer *xfer) |
4656 | 928 { |
5146 | 929 struct aim_oft_info *oft_info = xfer->data; |
5575 | 930 GaimConnection *gc = oft_info->sess->aux_data; |
5146 | 931 struct oscar_data *od = gc->proto_data; |
4656 | 932 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
933 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
934 "AAA - in oscar_xfer_cancel_recv\n"); |
5146 | 935 |
936 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
937 | |
938 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
939 aim_oft_destroyinfo(oft_info); | |
4656 | 940 xfer->data = NULL; |
5146 | 941 od->file_transfers = g_slist_remove(od->file_transfers, xfer); |
4656 | 942 } |
943 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
944 static void oscar_xfer_ack(GaimXfer *xfer, const char *buffer, size_t size) |
4656 | 945 { |
5146 | 946 struct aim_oft_info *oft_info = xfer->data; |
4656 | 947 |
948 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { | |
949 /* | |
950 * If we're done sending, intercept the socket from the core ft code | |
951 * and wait for the other guy to send the "done" OFT packet. | |
952 */ | |
953 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
954 gaim_input_remove(xfer->watcher); | |
5146 | 955 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); |
4656 | 956 xfer->fd = 0; |
957 gaim_xfer_set_completed(xfer, TRUE); | |
958 } | |
959 } else if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
5146 | 960 /* Update our rolling checksum. Like Walmart, yo. */ |
961 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
4656 | 962 } |
963 } | |
964 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
965 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const char *ck) |
4656 | 966 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
967 GaimXfer *xfer; |
5146 | 968 struct aim_oft_info *oft_info; |
4656 | 969 |
970 while (fts) { | |
971 xfer = fts->data; | |
5146 | 972 oft_info = xfer->data; |
973 | |
974 if (oft_info && !strcmp(ck, oft_info->cookie)) | |
4656 | 975 return xfer; |
976 | |
977 fts = g_slist_next(fts); | |
978 } | |
979 | |
980 return NULL; | |
981 } | |
982 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
983 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 984 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
985 GaimXfer *xfer; |
5146 | 986 struct aim_oft_info *oft_info; |
4656 | 987 |
988 while (fts) { | |
989 xfer = fts->data; | |
5146 | 990 oft_info = xfer->data; |
991 | |
992 if (oft_info && (conn == oft_info->conn)) | |
4656 | 993 return xfer; |
994 | |
995 fts = g_slist_next(fts); | |
996 } | |
997 | |
998 return NULL; | |
999 } | |
1000 | |
5575 | 1001 static void oscar_ask_sendfile(GaimConnection *gc, const char *destsn) { |
3630 | 1002 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1003 GaimXfer *xfer; |
5146 | 1004 struct aim_oft_info *oft_info; |
3752 | 1005 |
4617 | 1006 /* You want to send a file to someone else, you're so generous */ |
1007 | |
1008 /* Build the file transfer handle */ | |
5575 | 1009 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, destsn); |
4617 | 1010 xfer->local_port = 5190; |
1011 | |
5146 | 1012 /* Create the oscar-specific data */ |
1013 oft_info = aim_oft_createinfo(od->sess, NULL, destsn, xfer->local_ip, xfer->local_port, 0, 0, NULL); | |
1014 xfer->data = oft_info; | |
1015 | |
4617 | 1016 /* Setup our I/O op functions */ |
1017 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); | |
1018 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); | |
1019 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1020 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1021 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
4656 | 1022 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack); |
4617 | 1023 |
1024 /* Keep track of this transfer for later */ | |
1025 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
1026 | |
1027 /* Now perform the request */ | |
1028 gaim_xfer_request(xfer); | |
3630 | 1029 } |
1030 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1031 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 1032 GaimConnection *gc = sess->aux_data; |
1033 struct oscar_data *od = gc->proto_data; | |
1034 GaimAccount *account = gc->account; | |
1035 aim_conn_t *bosconn; | |
1036 char *host; int port; | |
1037 int i, rc; | |
2086 | 1038 va_list ap; |
2704 | 1039 struct aim_authresp_info *info; |
6029 | 1040 |
5575 | 1041 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 1042 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1043 va_start(ap, fr); |
2704 | 1044 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 1045 va_end(ap); |
1046 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1047 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1048 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 1049 |
4293 | 1050 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 1051 char buf[256]; |
2704 | 1052 switch (info->errorcode) { |
2086 | 1053 case 0x05: |
1054 /* Incorrect nick/password */ | |
6498 | 1055 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1056 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 1057 break; |
1058 case 0x11: | |
1059 /* Suspended account */ | |
6498 | 1060 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1061 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 1062 break; |
3498 | 1063 case 0x14: |
1064 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1065 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 1066 break; |
2086 | 1067 case 0x18: |
1068 /* connecting too frequently */ | |
6498 | 1069 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1070 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 | 1071 break; |
1072 case 0x1c: | |
1073 /* client too old */ | |
6498 | 1074 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
1075 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
|
1076 gaim_connection_error(gc, buf); |
2086 | 1077 break; |
1078 default: | |
6623 | 1079 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 1080 break; |
1081 } | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1082 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1083 "Login Error Code 0x%04hx\n", info->errorcode); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1084 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1085 "Error URL: %s\n", info->errorurl); |
2086 | 1086 od->killme = TRUE; |
1087 return 1; | |
1088 } | |
1089 | |
1090 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1091 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1092 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1093 |
2704 | 1094 if (info->email) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1095 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Email: %s\n", info->email); |
2086 | 1096 } else { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1097 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Email is NULL\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1098 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1099 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1100 gaim_debug(GAIM_DEBUG_MISC, "oscar", "BOSIP: %s\n", info->bosip); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1101 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1102 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1103 aim_conn_kill(sess, &fr->conn); |
2086 | 1104 |
1105 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
1106 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1107 gaim_connection_error(gc, _("Internal Error")); |
2086 | 1108 od->killme = TRUE; |
1109 return 0; | |
1110 } | |
1111 | |
4649 | 1112 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1113 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 1114 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
1115 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
1116 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 1117 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 1118 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
1119 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
1120 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
1121 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
1122 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
1123 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 1124 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 1125 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
1126 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
1127 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
1128 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
1129 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 1130 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 1131 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
2086 | 1132 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
1133 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
|
1134 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 1135 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
1136 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
1137 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
1138 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
1139 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 1140 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
|
1141 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
|
1142 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
|
1143 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 1144 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 1145 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 1146 #ifndef NOSSI |
4642 | 1147 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 1148 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
1149 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
1150 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 1151 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
1152 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); | |
1153 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
1154 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
1155 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
1156 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1157 |
2086 | 1158 ((struct oscar_data *)gc->proto_data)->conn = bosconn; |
2704 | 1159 for (i = 0; i < (int)strlen(info->bosip); i++) { |
1160 if (info->bosip[i] == ':') { | |
1161 port = atoi(&(info->bosip[i+1])); | |
2086 | 1162 break; |
1163 } | |
1164 } | |
2704 | 1165 host = g_strndup(info->bosip, i); |
2086 | 1166 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1167 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 1168 g_free(host); |
4366 | 1169 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1170 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1171 od->killme = TRUE; |
1172 return 0; | |
1173 } | |
4293 | 1174 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1175 gaim_input_remove(gc->inpa); |
2704 | 1176 |
2086 | 1177 return 1; |
1178 } | |
1179 | |
1180 struct pieceofcrap { | |
5575 | 1181 GaimConnection *gc; |
2086 | 1182 unsigned long offset; |
1183 unsigned long len; | |
1184 char *modname; | |
1185 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1186 aim_conn_t *conn; |
2086 | 1187 unsigned int inpa; |
1188 }; | |
1189 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1190 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 1191 { |
1192 struct pieceofcrap *pos = data; | |
1193 struct oscar_data *od = pos->gc->proto_data; | |
1194 char in = '\0'; | |
1195 int x = 0; | |
1196 unsigned char m[17]; | |
1197 | |
1198 while (read(pos->fd, &in, 1) == 1) { | |
1199 if (in == '\n') | |
1200 x++; | |
1201 else if (in != '\r') | |
1202 x = 0; | |
1203 if (x == 2) | |
1204 break; | |
1205 in = '\0'; | |
1206 } | |
1207 if (in != '\n') { | |
4056 | 1208 char buf[256]; |
1209 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
|
1210 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1211 gaim_notify_warning(pos->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1212 _("Gaim was Unable to get a valid AIM login hash."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1213 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1214 gaim_input_remove(pos->inpa); |
2086 | 1215 close(pos->fd); |
1216 g_free(pos); | |
1217 return; | |
1218 } | |
1219 read(pos->fd, m, 16); | |
1220 m[16] = '\0'; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1221 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Sending hash: "); |
2086 | 1222 for (x = 0; x < 16; x++) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1223 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02hhx ", (unsigned char)m[x]); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1224 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1225 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1226 gaim_input_remove(pos->inpa); |
2086 | 1227 close(pos->fd); |
1228 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
1229 g_free(pos); | |
1230 } | |
1231 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1232 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 1233 struct pieceofcrap *pos = data; |
5420 | 1234 gchar *buf; |
2086 | 1235 |
4366 | 1236 pos->fd = source; |
1237 | |
2086 | 1238 if (source < 0) { |
5420 | 1239 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
|
1240 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1241 gaim_notify_warning(pos->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1242 _("Gaim was Unable to get a valid AIM login hash."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1243 buf); |
5420 | 1244 g_free(buf); |
2086 | 1245 if (pos->modname) |
1246 g_free(pos->modname); | |
1247 g_free(pos); | |
1248 return; | |
1249 } | |
1250 | |
5420 | 1251 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 1252 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
1253 write(pos->fd, buf, strlen(buf)); | |
5420 | 1254 g_free(buf); |
2086 | 1255 if (pos->modname) |
1256 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1257 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 1258 return; |
1259 } | |
1260 | |
1261 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
1262 #define AIM_MAX_FILE_SIZE 98304 | |
1263 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1264 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1265 va_list ap; |
1266 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1267 fu32_t offset, len; |
2086 | 1268 char *modname; |
1269 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1270 va_start(ap, fr); |
4200 | 1271 offset = va_arg(ap, fu32_t); |
1272 len = va_arg(ap, fu32_t); | |
2086 | 1273 modname = va_arg(ap, char *); |
1274 va_end(ap); | |
1275 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1276 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
5556 | 1277 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1278 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1279 |
2086 | 1280 if (len == 0) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1281 gaim_debug(GAIM_DEBUG_MISC, "oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1282 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 1283 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
1284 return 1; | |
1285 } | |
1286 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
1287 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
1288 char *buf; | |
1289 int i = 8; | |
1290 if (modname) | |
1291 i += strlen(modname); | |
1292 buf = g_malloc(i); | |
1293 i = 0; | |
1294 if (modname) { | |
1295 memcpy(buf, modname, strlen(modname)); | |
1296 i += strlen(modname); | |
1297 } | |
1298 buf[i++] = offset & 0xff; | |
1299 buf[i++] = (offset >> 8) & 0xff; | |
1300 buf[i++] = (offset >> 16) & 0xff; | |
1301 buf[i++] = (offset >> 24) & 0xff; | |
1302 buf[i++] = len & 0xff; | |
1303 buf[i++] = (len >> 8) & 0xff; | |
1304 buf[i++] = (len >> 16) & 0xff; | |
1305 buf[i++] = (len >> 24) & 0xff; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1306 gaim_debug(GAIM_DEBUG_MISC, "oscar", "len + offset is invalid, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1307 "hashing request\n"); |
2086 | 1308 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
1309 g_free(buf); | |
1310 return 1; | |
1311 } | |
1312 */ | |
1313 | |
1314 pos = g_new0(struct pieceofcrap, 1); | |
1315 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1316 pos->conn = fr->conn; |
2086 | 1317 |
1318 pos->offset = offset; | |
1319 pos->len = len; | |
1320 pos->modname = modname ? g_strdup(modname) : NULL; | |
1321 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1322 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 1323 char buf[256]; |
2086 | 1324 if (pos->modname) |
1325 g_free(pos->modname); | |
1326 g_free(pos); | |
4056 | 1327 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
|
1328 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1329 gaim_notify_warning(pos->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1330 _("Gaim was Unable to get a valid login hash."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1331 buf); |
2086 | 1332 } |
1333 | |
1334 return 1; | |
1335 } | |
1336 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1337 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1338 GaimConnection *gc = sess->aux_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1339 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 1340 GaimAccount *ac = gaim_connection_get_account(gc); |
4617 | 1341 struct oscar_data *od = gc->proto_data; |
7011 | 1342 va_list ap; |
1343 char *key; | |
2086 | 1344 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1345 va_start(ap, fr); |
2086 | 1346 key = va_arg(ap, char *); |
1347 va_end(ap); | |
1348 | |
4617 | 1349 if (od->icq) { |
3458 | 1350 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1351 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1352 gaim_account_get_password(account), &info, key); |
3458 | 1353 } else { |
1354 #if 0 | |
1355 struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b}; | |
1356 #endif | |
1357 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1358 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1359 gaim_account_get_password(account), &info, key); |
3458 | 1360 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1361 |
2086 | 1362 return 1; |
1363 } | |
1364 | |
2675 | 1365 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1366 GaimConnection *gc = sess->aux_data; |
2647 | 1367 struct chat_connection *chatcon; |
1368 static int id = 1; | |
1369 | |
6905 | 1370 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, 0x0001, gaim_parse_genericerr, 0); |
2675 | 1371 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
1372 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
1373 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
1374 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
1375 | |
2672 | 1376 aim_clientready(sess, fr->conn); |
2675 | 1377 |
2647 | 1378 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
1379 chatcon->id = id; | |
1380 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); | |
1381 | |
1382 return 1; | |
1383 } | |
1384 | |
2675 | 1385 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
1386 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1387 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 1388 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 1389 |
1390 aim_clientready(sess, fr->conn); | |
1391 | |
1392 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1393 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1394 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1395 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1396 |
3694 | 1397 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
1398 | |
1399 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1400 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
1401 | |
1402 aim_email_sendcookies(sess, fr->conn); | |
1403 aim_email_activate(sess, fr->conn); | |
1404 aim_clientready(sess, fr->conn); | |
1405 | |
1406 return 1; | |
1407 } | |
1408 | |
4804 | 1409 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1410 GaimConnection *gc = sess->aux_data; |
4804 | 1411 struct oscar_data *od = gc->proto_data; |
1412 | |
1413 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1414 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
1415 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
1416 | |
1417 aim_clientready(sess, fr->conn); | |
1418 | |
4823 | 1419 od->iconconnecting = FALSE; |
1420 | |
4804 | 1421 if (od->icontimer) |
1422 g_source_remove(od->icontimer); | |
1423 od->icontimer = g_timeout_add(100, gaim_icon_timerfunc, gc); | |
1424 | |
1425 return 1; | |
1426 } | |
1427 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1428 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1429 GaimConnection *gc = data; |
4617 | 1430 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1431 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1432 aim_conn_t *tstconn; |
2086 | 1433 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1434 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1435 close(source); |
1436 return; | |
1437 } | |
1438 | |
4617 | 1439 od = gc->proto_data; |
1440 sess = od->sess; | |
2086 | 1441 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 1442 tstconn->fd = source; |
2086 | 1443 |
1444 if (source < 0) { | |
1445 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1446 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1447 "unable to connect to chatnav server\n"); |
2086 | 1448 return; |
1449 } | |
1450 | |
1451 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1452 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1453 gaim_debug(GAIM_DEBUG_INFO, "oscar", "chatnav: connected\n"); |
2086 | 1454 } |
1455 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1456 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1457 { |
5575 | 1458 GaimConnection *gc = data; |
4617 | 1459 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1460 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1461 aim_conn_t *tstconn; |
2086 | 1462 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1463 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1464 close(source); |
1465 return; | |
1466 } | |
1467 | |
4617 | 1468 od = gc->proto_data; |
1469 sess = od->sess; | |
2086 | 1470 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1471 tstconn->fd = source; |
2086 | 1472 |
1473 if (source < 0) { | |
1474 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1475 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1476 "unable to connect to authorizer\n"); |
2086 | 1477 return; |
1478 } | |
1479 | |
1480 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1481 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
6905 | 1482 gaim_debug(GAIM_DEBUG_INFO, "oscar", "admin: connected\n"); |
2086 | 1483 } |
1484 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1485 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1486 { |
1487 struct chat_connection *ccon = data; | |
5575 | 1488 GaimConnection *gc = ccon->gc; |
4617 | 1489 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1490 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1491 aim_conn_t *tstconn; |
2086 | 1492 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1493 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1494 close(source); |
1495 g_free(ccon->show); | |
1496 g_free(ccon->name); | |
1497 g_free(ccon); | |
1498 return; | |
1499 } | |
1500 | |
4617 | 1501 od = gc->proto_data; |
1502 sess = od->sess; | |
2086 | 1503 tstconn = ccon->conn; |
4366 | 1504 tstconn->fd = source; |
2086 | 1505 |
1506 if (source < 0) { | |
1507 aim_conn_kill(sess, &tstconn); | |
1508 g_free(ccon->show); | |
1509 g_free(ccon->name); | |
1510 g_free(ccon); | |
1511 return; | |
1512 } | |
1513 | |
1514 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 1515 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
1516 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 1517 } |
1518 | |
3694 | 1519 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1520 GaimConnection *gc = data; |
4617 | 1521 struct oscar_data *od; |
3694 | 1522 aim_session_t *sess; |
1523 aim_conn_t *tstconn; | |
1524 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1525 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 1526 close(source); |
1527 return; | |
1528 } | |
1529 | |
4617 | 1530 od = gc->proto_data; |
1531 sess = od->sess; | |
3694 | 1532 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 1533 tstconn->fd = source; |
3694 | 1534 |
1535 if (source < 0) { | |
1536 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1537 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1538 "unable to connect to email server\n"); |
3694 | 1539 return; |
1540 } | |
1541 | |
1542 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1543 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1544 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1545 "email: connected\n"); |
3694 | 1546 } |
1547 | |
4804 | 1548 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1549 GaimConnection *gc = data; |
4804 | 1550 struct oscar_data *od; |
1551 aim_session_t *sess; | |
1552 aim_conn_t *tstconn; | |
1553 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1554 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 1555 close(source); |
1556 return; | |
1557 } | |
1558 | |
1559 od = gc->proto_data; | |
1560 sess = od->sess; | |
1561 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
1562 tstconn->fd = source; | |
1563 | |
1564 if (source < 0) { | |
1565 aim_conn_kill(sess, &tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1566 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1567 "unable to connect to icon server\n"); |
4804 | 1568 return; |
1569 } | |
1570 | |
1571 aim_conn_completeconnect(sess, tstconn); | |
1572 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1573 gaim_debug(GAIM_DEBUG_INFO, "oscar", "icon: connected\n"); |
4804 | 1574 } |
1575 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1576 /* 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
|
1577 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1578 GaimConnection *gc = sess->aux_data; |
1579 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1580 aim_conn_t *tstconn; |
4452 | 1581 int i; |
2086 | 1582 char *host; |
1583 int port; | |
4821 | 1584 va_list ap; |
1585 struct aim_redirect_data *redir; | |
2086 | 1586 |
5575 | 1587 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 1588 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1589 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1590 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1591 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1592 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1593 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1594 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1595 port = atoi(&(redir->ip[i+1])); |
2086 | 1596 break; |
1597 } | |
1598 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1599 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1600 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1601 switch(redir->group) { |
2086 | 1602 case 0x7: /* Authorizer */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1603 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1604 "Reconnecting with authorizor...\n"); |
2086 | 1605 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1606 if (tstconn == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1607 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1608 "unable to reconnect with authorizer\n"); |
2086 | 1609 g_free(host); |
1610 return 1; | |
1611 } | |
4649 | 1612 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1613 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 1614 |
1615 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1616 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 1617 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1618 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1619 "unable to reconnect with authorizer\n"); |
2086 | 1620 g_free(host); |
1621 return 1; | |
1622 } | |
4293 | 1623 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1624 break; |
1625 | |
2086 | 1626 case 0xd: /* ChatNav */ |
1627 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
1628 if (tstconn == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1629 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1630 "unable to connect to chatnav server\n"); |
2086 | 1631 g_free(host); |
1632 return 1; | |
1633 } | |
4649 | 1634 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1635 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 1636 |
1637 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1638 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 1639 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1640 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1641 "unable to connect to chatnav server\n"); |
2086 | 1642 g_free(host); |
1643 return 1; | |
1644 } | |
4293 | 1645 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1646 break; |
1647 | |
1648 case 0xe: { /* Chat */ | |
2086 | 1649 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1650 |
2086 | 1651 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
1652 if (tstconn == NULL) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1653 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1654 "unable to connect to chat server\n"); |
2086 | 1655 g_free(host); |
1656 return 1; | |
1657 } | |
1658 | |
4649 | 1659 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1660 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
1661 | |
2086 | 1662 ccon = g_new0(struct chat_connection, 1); |
1663 ccon->conn = tstconn; | |
1664 ccon->gc = gc; | |
1665 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1666 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1667 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1668 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1669 ccon->show = extract_name(redir->chat.room); |
4634 | 1670 |
2086 | 1671 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1672 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 1673 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1674 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1675 "unable to connect to chat server\n"); |
2086 | 1676 g_free(host); |
1677 g_free(ccon->show); | |
1678 g_free(ccon->name); | |
1679 g_free(ccon); | |
1680 return 1; | |
1681 } | |
4293 | 1682 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1683 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1684 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1685 ccon->name, ccon->exchange); |
4194 | 1686 } break; |
3694 | 1687 |
4804 | 1688 case 0x0010: { /* icon */ |
1689 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1690 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1691 "unable to connect to icon server\n"); |
4804 | 1692 g_free(host); |
1693 return 1; | |
1694 } | |
1695 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
1696 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
1697 | |
1698 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1699 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 1700 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1701 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1702 "unable to connect to icon server\n"); |
4804 | 1703 g_free(host); |
1704 return 1; | |
1705 } | |
1706 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
1707 } break; | |
1708 | |
3694 | 1709 case 0x0018: { /* email */ |
1710 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1711 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1712 "unable to connect to email server\n"); |
3694 | 1713 g_free(host); |
1714 return 1; | |
1715 } | |
4649 | 1716 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 1717 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
1718 | |
1719 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1720 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 1721 aim_conn_kill(sess, &tstconn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1722 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1723 "unable to connect to email server\n"); |
3694 | 1724 g_free(host); |
1725 return 1; | |
1726 } | |
4293 | 1727 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 1728 } break; |
1729 | |
2086 | 1730 default: /* huh? */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1731 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1732 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1733 redir->group); |
2086 | 1734 break; |
1735 } | |
1736 | |
1737 g_free(host); | |
1738 return 1; | |
1739 } | |
1740 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1741 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1742 GaimConnection *gc = sess->aux_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1743 struct oscar_data *od = gc->proto_data; |
4738 | 1744 struct buddyinfo *bi; |
2993 | 1745 time_t time_idle = 0, signon = 0; |
1746 int type = 0; | |
1747 int caps = 0; | |
2086 | 1748 va_list ap; |
4738 | 1749 aim_userinfo_t *info; |
4194 | 1750 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1751 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1752 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1753 va_end(ap); |
1754 | |
2993 | 1755 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
1756 caps = info->capabilities; | |
3267 | 1757 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
1758 type |= UC_AB; | |
6318 | 1759 if (caps & AIM_CAPS_HIPTOP) |
1760 type |= UC_HIPTOP; | |
3267 | 1761 |
4766 | 1762 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
1763 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
1764 type |= UC_UNCONFIRMED; | |
1765 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
1766 type |= UC_ADMIN; | |
1767 if (info->flags & AIM_FLAG_AOL) | |
1768 type |= UC_AOL; | |
1769 if (info->flags & AIM_FLAG_FREE) | |
1770 type |= UC_NORMAL; | |
1771 if (info->flags & AIM_FLAG_AWAY) | |
1772 type |= UC_UNAVAILABLE; | |
1773 if (info->flags & AIM_FLAG_WIRELESS) | |
1774 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1775 } |
2993 | 1776 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 1777 type = (info->icqinfo.status << 16); |
3013 | 1778 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
1779 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 1780 type |= UC_UNAVAILABLE; |
3013 | 1781 } |
2993 | 1782 } |
1783 | |
1784 if (caps & AIM_CAPS_ICQ) | |
1785 caps ^= AIM_CAPS_ICQ; | |
1786 | |
1787 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 1788 time(&time_idle); |
1789 time_idle -= info->idletime*60; | |
2993 | 1790 } |
1791 | |
5836 | 1792 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
1793 signon = info->onlinesince; | |
1794 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 1795 signon = time(NULL) - info->sessionlen; |
2086 | 1796 |
5575 | 1797 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
1798 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1799 |
4738 | 1800 bi = g_hash_table_lookup(od->buddyinfo, normalize(info->sn)); |
1801 if (!bi) { | |
1802 bi = g_new0(struct buddyinfo, 1); | |
1803 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(info->sn)), bi); | |
1804 } | |
4739 | 1805 bi->typingnot = FALSE; |
1806 bi->ico_informed = FALSE; | |
6857 | 1807 bi->ipaddr = info->icqinfo.ipaddr; |
1808 | |
1809 /* Available message stuff */ | |
6292 | 1810 free(bi->availmsg); |
7011 | 1811 if (info->avail != NULL) |
1812 if (info->avail_encoding) { | |
1813 gchar *enc = g_strdup_printf("charset=\"%s\"", info->avail_encoding); | |
1814 bi->availmsg = oscar_encoding_to_utf8(enc, info->avail, info->avail_len); | |
6292 | 1815 g_free(enc); |
1816 } else { | |
1817 /* No explicit encoding means utf8. Yay. */ | |
7011 | 1818 bi->availmsg = g_strdup(info->avail); |
6292 | 1819 } |
5837 | 1820 else |
6292 | 1821 bi->availmsg = NULL; |
4732 | 1822 |
4804 | 1823 /* Server stored icon stuff */ |
4853 | 1824 if (info->iconcsumlen) { |
1825 char *b16, *saved_b16; | |
6695 | 1826 GaimBuddy *b; |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1827 FILE *file; |
4853 | 1828 |
7011 | 1829 b16 = tobase16(info->iconcsum, info->iconcsumlen); |
4853 | 1830 b = gaim_find_buddy(gc->account, info->sn); |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1831 /* If for some reason the checksum is valid, but cached file is not.. |
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1832 we want to know. */ |
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1833 if((file = fopen(gaim_buddy_get_setting(b, "buddy_icon"), "rb"))) { |
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1834 fclose(file); |
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1835 saved_b16 = gaim_buddy_get_setting(b, "icon_checksum"); |
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1836 } |
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1837 else |
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1838 saved_b16 = NULL; |
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1839 |
4853 | 1840 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
1841 GSList *cur = od->requesticon; | |
1842 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
1843 cur = cur->next; | |
1844 if (!cur) { | |
1845 od->requesticon = g_slist_append(od->requesticon, strdup(normalize(info->sn))); | |
1846 if (od->icontimer) | |
1847 g_source_remove(od->icontimer); | |
1848 od->icontimer = g_timeout_add(500, gaim_icon_timerfunc, gc); | |
1849 } | |
1850 } | |
6053 | 1851 g_free(saved_b16); |
1852 g_free(b16); | |
4853 | 1853 } |
1854 | |
5628 | 1855 serv_got_update(gc, info->sn, 1, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 1856 |
1857 return 1; | |
1858 } | |
1859 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1860 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1861 GaimConnection *gc = sess->aux_data; |
5837 | 1862 struct oscar_data *od = gc->proto_data; |
2086 | 1863 va_list ap; |
4739 | 1864 aim_userinfo_t *info; |
2086 | 1865 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1866 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1867 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1868 va_end(ap); |
1869 | |
4732 | 1870 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); |
2086 | 1871 |
5837 | 1872 g_hash_table_remove(od->buddyinfo, normalize(info->sn)); |
1873 | |
2086 | 1874 return 1; |
1875 } | |
1876 | |
3730 | 1877 static void cancel_direct_im(struct ask_direct *d) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1878 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Freeing DirectIM prompts.\n"); |
2086 | 1879 |
1880 g_free(d->sn); | |
1881 g_free(d); | |
1882 } | |
1883 | |
4617 | 1884 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { |
2086 | 1885 struct direct_im *dim = data; |
5575 | 1886 GaimConnection *gc = dim->gc; |
2086 | 1887 struct oscar_data *od = gc->proto_data; |
5679 | 1888 GaimConversation *cnv; |
2086 | 1889 char buf[256]; |
3008 | 1890 struct sockaddr name; |
1891 socklen_t name_len = 1; | |
1892 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1893 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1894 g_free(dim); |
1895 return; | |
1896 } | |
1897 | |
1898 if (source < 0) { | |
1899 g_free(dim); | |
1900 return; | |
1901 } | |
1902 | |
4366 | 1903 dim->conn->fd = source; |
2086 | 1904 aim_conn_completeconnect(od->sess, dim->conn); |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
1905 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); |
3008 | 1906 |
1907 /* This is the best way to see if we're connected or not */ | |
1908 if (getpeername(source, &name, &name_len) == 0) { | |
1909 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1910 dim->connected = TRUE; | |
6982 | 1911 gaim_conversation_write(cnv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
3008 | 1912 } |
2086 | 1913 od->direct_ims = g_slist_append(od->direct_ims, dim); |
3008 | 1914 |
4617 | 1915 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
2086 | 1916 } |
1917 | |
4617 | 1918 /* BBB */ |
3952 | 1919 /* |
4617 | 1920 * This is called after a remote AIM user has connected to us. We |
1921 * want to do some voodoo with the socket file descriptors, add a | |
1922 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 1923 */ |
4656 | 1924 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1925 GaimConnection *gc = sess->aux_data; |
3630 | 1926 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1927 GaimXfer *xfer; |
5146 | 1928 struct aim_oft_info *oft_info; |
3630 | 1929 va_list ap; |
1930 aim_conn_t *conn, *listenerconn; | |
4656 | 1931 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1932 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1933 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 1934 va_start(ap, fr); |
1935 conn = va_arg(ap, aim_conn_t *); | |
1936 listenerconn = va_arg(ap, aim_conn_t *); | |
1937 va_end(ap); | |
1938 | |
4617 | 1939 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
1940 return 1; | |
1941 | |
5146 | 1942 if (!(oft_info = xfer->data)) |
4617 | 1943 return 1; |
1944 | |
3630 | 1945 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 1946 gaim_input_remove(xfer->watcher); |
3630 | 1947 aim_conn_kill(sess, &listenerconn); |
1948 | |
5146 | 1949 oft_info->conn = conn; |
1950 xfer->fd = oft_info->conn->fd; | |
1951 | |
1952 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
1953 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
1954 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 1955 |
1956 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 1957 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 1958 |
1959 return 0; | |
1960 } | |
1961 | |
3952 | 1962 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1963 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 1964 * user in order to transfer a file. |
3952 | 1965 */ |
4617 | 1966 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
|
1967 GaimXfer *xfer; |
5146 | 1968 struct aim_oft_info *oft_info; |
4656 | 1969 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1970 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1971 "AAA - in oscar_sendfile_connected\n"); |
4617 | 1972 if (!(xfer = data)) |
1973 return; | |
5146 | 1974 if (!(oft_info = xfer->data)) |
3630 | 1975 return; |
4617 | 1976 if (source < 0) |
1977 return; | |
1978 | |
1979 xfer->fd = source; | |
5146 | 1980 oft_info->conn->fd = source; |
1981 | |
1982 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
1983 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 1984 |
1985 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 1986 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 1987 |
1988 return; | |
3630 | 1989 } |
1990 | |
3952 | 1991 /* |
4617 | 1992 * This is called when a buddy sends us some file info. This happens when they |
1993 * are sending a file to you, and you have just established a connection to them. | |
4650 | 1994 * You should send them the exact same info except use the real cookie. We also |
4617 | 1995 * get like totally ready to like, receive the file, kay? |
3952 | 1996 */ |
4617 | 1997 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1998 GaimConnection *gc = sess->aux_data; |
4617 | 1999 struct oscar_data *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2000 GaimXfer *xfer; |
5146 | 2001 struct aim_oft_info *oft_info; |
4617 | 2002 va_list ap; |
2003 aim_conn_t *conn; | |
2004 fu8_t *cookie; | |
2005 struct aim_fileheader_t *fh; | |
4656 | 2006 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2007 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2008 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 2009 va_start(ap, fr); |
2010 conn = va_arg(ap, aim_conn_t *); | |
2011 cookie = va_arg(ap, fu8_t *); | |
2012 fh = va_arg(ap, struct aim_fileheader_t *); | |
2013 va_end(ap); | |
2014 | |
2015 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
2016 return 1; | |
2017 | |
5146 | 2018 if (!(oft_info = xfer->data)) |
4617 | 2019 return 1; |
2020 | |
2021 /* We want to stop listening with a normal thingy */ | |
2022 gaim_input_remove(xfer->watcher); | |
2023 xfer->watcher = 0; | |
2024 | |
5146 | 2025 /* They sent us some information about the file they're sending */ |
2026 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
2027 | |
2028 /* Fill in the cookie */ | |
2029 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
2030 | |
4617 | 2031 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 2032 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 2033 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2034 | |
2035 return 0; | |
3630 | 2036 } |
2037 | |
3952 | 2038 /* |
4657 | 2039 * We are sending a file to someone else. They have just acknowledged our |
4617 | 2040 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 2041 */ |
4617 | 2042 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2043 GaimConnection *gc = sess->aux_data; |
4617 | 2044 struct oscar_data *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2045 GaimXfer *xfer; |
4617 | 2046 va_list ap; |
2047 aim_conn_t *conn; | |
2048 fu8_t *cookie; | |
2049 struct aim_fileheader_t *fh; | |
4656 | 2050 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2051 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 2052 va_start(ap, fr); |
2053 conn = va_arg(ap, aim_conn_t *); | |
2054 cookie = va_arg(ap, fu8_t *); | |
2055 fh = va_arg(ap, struct aim_fileheader_t *); | |
2056 va_end(ap); | |
2057 | |
2058 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
2059 return 1; | |
2060 | |
4656 | 2061 /* We want to stop listening with a normal thingy */ |
2062 gaim_input_remove(xfer->watcher); | |
2063 xfer->watcher = 0; | |
2064 | |
4617 | 2065 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2066 | |
2067 return 0; | |
3630 | 2068 } |
4617 | 2069 |
2070 /* | |
2071 * We just sent a file to someone. They said they got it and everything, | |
2072 * so we can close our direct connection and what not. | |
2073 */ | |
2074 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 2075 GaimConnection *gc = sess->aux_data; |
4617 | 2076 struct oscar_data *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2077 GaimXfer *xfer; |
4617 | 2078 va_list ap; |
2079 aim_conn_t *conn; | |
2080 fu8_t *cookie; | |
2081 struct aim_fileheader_t *fh; | |
4656 | 2082 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2083 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 2084 va_start(ap, fr); |
2085 conn = va_arg(ap, aim_conn_t *); | |
2086 cookie = va_arg(ap, fu8_t *); | |
2087 fh = va_arg(ap, struct aim_fileheader_t *); | |
2088 va_end(ap); | |
2089 | |
2090 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
2091 return 1; | |
2092 | |
4656 | 2093 xfer->fd = conn->fd; |
4617 | 2094 gaim_xfer_end(xfer); |
2095 | |
2096 return 0; | |
2097 } | |
3630 | 2098 |
4244 | 2099 static void accept_direct_im(struct ask_direct *d) { |
5575 | 2100 GaimConnection *gc = d->gc; |
4244 | 2101 struct oscar_data *od; |
2086 | 2102 struct direct_im *dim; |
2945 | 2103 char *host; int port = 4443; |
4366 | 2104 int i, rc; |
2086 | 2105 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2106 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2107 cancel_direct_im(d); |
2108 return; | |
2109 } | |
2110 | |
2111 od = (struct oscar_data *)gc->proto_data; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2112 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Accepted DirectIM.\n"); |
2086 | 2113 |
2114 dim = find_direct_im(od, d->sn); | |
2115 if (dim) { | |
3730 | 2116 cancel_direct_im(d); /* 40 */ |
4244 | 2117 return; |
2086 | 2118 } |
2119 dim = g_new0(struct direct_im, 1); | |
2120 dim->gc = d->gc; | |
2121 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
2122 | |
4617 | 2123 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2124 if (!dim->conn) { |
2086 | 2125 g_free(dim); |
3730 | 2126 cancel_direct_im(d); |
4244 | 2127 return; |
2086 | 2128 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2129 |
2086 | 2130 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
4617 | 2131 gaim_odc_incoming, 0); |
2086 | 2132 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, |
4617 | 2133 gaim_odc_typing, 0); |
3033 | 2134 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, |
6982 | 2135 gaim_odc_update_ui, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2136 for (i = 0; i < (int)strlen(d->ip); i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2137 if (d->ip[i] == ':') { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2138 port = atoi(&(d->ip[i+1])); |
2086 | 2139 break; |
2140 } | |
2141 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2142 host = g_strndup(d->ip, i); |
2086 | 2143 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2144 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
2086 | 2145 g_free(host); |
4366 | 2146 if (rc < 0) { |
2086 | 2147 aim_conn_kill(od->sess, &dim->conn); |
2148 g_free(dim); | |
3730 | 2149 cancel_direct_im(d); |
4244 | 2150 return; |
2086 | 2151 } |
2152 | |
3730 | 2153 cancel_direct_im(d); |
2086 | 2154 |
4244 | 2155 return; |
2086 | 2156 } |
2157 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2158 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 2159 GaimConnection *gc = sess->aux_data; |
3600 | 2160 struct oscar_data *od = gc->proto_data; |
4738 | 2161 char *tmp; |
6622 | 2162 GaimImFlags flags = 0; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
2163 gsize convlen; |
3659 | 2164 GError *err = NULL; |
4738 | 2165 struct buddyinfo *bi; |
5575 | 2166 const char *iconfile; |
4738 | 2167 |
2168 bi = g_hash_table_lookup(od->buddyinfo, normalize(userinfo->sn)); | |
2169 if (!bi) { | |
2170 bi = g_new0(struct buddyinfo, 1); | |
2171 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(userinfo->sn)), bi); | |
2172 } | |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2173 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2174 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
6622 | 2175 flags |= GAIM_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2176 |
4738 | 2177 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
2178 bi->typingnot = TRUE; | |
2179 else | |
2180 bi->typingnot = FALSE; | |
2181 | |
4380 | 2182 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2183 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2184 "%s has an icon\n", userinfo->sn); |
4738 | 2185 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
2186 bi->ico_need = TRUE; | |
2187 bi->ico_len = args->iconlen; | |
2188 bi->ico_csum = args->iconsum; | |
2189 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2190 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2191 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2192 |
5575 | 2193 if ((iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc))) && |
2194 (args->icbmflags & AIM_IMFLAGS_BUDDYREQ)) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2195 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2196 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2197 |
5575 | 2198 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2199 char *buf = g_malloc(st.st_size); |
5575 | 2200 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2201 if (file) { |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
2202 int len = fread(buf, 1, st.st_size, file); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2203 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2204 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2205 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2206 userinfo->sn, len, st.st_size); |
4617 | 2207 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
2208 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2209 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2210 } else |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2211 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2212 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2213 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2214 } else |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2215 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2216 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2217 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2218 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2219 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2220 "Character set is %hu %hu\n", args->charset, args->charsubset); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2221 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
3722 | 2222 /* This message is marked as UNICODE, so we have to |
2223 * convert it to utf-8 before handing it to the gaim core. | |
2224 * This conversion should *never* fail, if it does it | |
2225 * means that either the incoming ICBM is corrupted or | |
4662 | 2226 * there is something we don't understand about it. |
2227 * For the record, AIM Unicode is big-endian UCS-2 */ | |
2228 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2229 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Received UNICODE IM\n"); |
4121 | 2230 |
2231 if (!args->msg || !args->msglen) | |
2232 return 1; | |
4641 | 2233 |
3659 | 2234 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
2235 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2236 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2237 "Unicode IM conversion: %s\n", err->message); |
3659 | 2238 tmp = strdup(_("(There was an error receiving this message)")); |
4800 | 2239 g_error_free(err); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2240 } |
3722 | 2241 } else { |
3850 | 2242 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 2243 * unflagged messages, which are ASCII. That's OK because |
2244 * ASCII is a strict subset of ISO-8859-1; this should | |
2245 * help with compatibility with old, broken versions of | |
2246 * gaim (everything before 0.60) and other broken clients | |
2247 * that will happily send ISO-8859-1 without marking it as | |
2248 * such */ | |
4662 | 2249 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2250 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2251 "Received ISO-8859-1 IM\n"); |
4121 | 2252 |
2253 if (!args->msg || !args->msglen) | |
2254 return 1; | |
2255 | |
3659 | 2256 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
2257 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2258 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2259 "ISO-8859-1 IM conversion: %s\n", err->message); |
3659 | 2260 tmp = strdup(_("(There was an error receiving this message)")); |
4800 | 2261 g_error_free(err); |
3659 | 2262 } |
3642 | 2263 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2264 |
4333 | 2265 /* strip_linefeed(tmp); */ |
6982 | 2266 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2267 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2268 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2269 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2270 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2271 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2272 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
5575 | 2273 GaimConnection *gc = sess->aux_data; |
4617 | 2274 struct oscar_data *od = gc->proto_data; |
5575 | 2275 const char *username = gaim_account_get_username(gaim_connection_get_account(gc)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2276 |
4121 | 2277 if (!args) |
2278 return 0; | |
4194 | 2279 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2280 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2281 "rendezvous with %s, status is %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2282 userinfo->sn, args->status); |
2869 | 2283 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2284 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 2285 char *name; |
5234 | 2286 GHashTable *components; |
2287 | |
4121 | 2288 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
2289 return 1; | |
5234 | 2290 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
2291 g_free); | |
4121 | 2292 name = extract_name(args->info.chat.roominfo.name); |
5234 | 2293 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
2294 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
|
2295 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2296 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2297 userinfo->sn, |
6059 | 2298 args->msg, |
5234 | 2299 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2300 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2301 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2302 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 2303 /* BBB */ |
2304 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
2305 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2306 GaimXfer *xfer; |
5146 | 2307 struct aim_oft_info *oft_info; |
2308 | |
2309 if (!args->cookie || !args->port || !args->verifiedip || | |
2310 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 2311 !args->info.sendfile.totfiles || !args->reqclass) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2312 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2313 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2314 "information.\n", userinfo->sn); |
5146 | 2315 if (args->proxyip) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2316 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2317 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2318 "does not support this yet.\n"); |
4617 | 2319 return 1; |
4656 | 2320 } |
4617 | 2321 |
2322 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
2323 /* last char of the ft req is a star, they are sending us a | |
2324 * directory -- remove the star and trailing slash so we dont save | |
2325 * directories that look like 'dirname\*' -- arl */ | |
2326 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
2327 if (tmp && (tmp[1] == '*')) { | |
2328 tmp[0] = '\0'; | |
2329 } | |
2330 } | |
2331 | |
2332 /* Build the file transfer handle */ | |
2333 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 2334 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 2335 xfer->remote_port = args->port; |
4617 | 2336 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
2337 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
5146 | 2338 |
2339 /* Create the oscar-specific data */ | |
5163 | 2340 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 2341 if (args->proxyip) |
5146 | 2342 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 2343 if (args->verifiedip) |
5146 | 2344 oft_info->verifiedip = g_strdup(args->verifiedip); |
2345 xfer->data = oft_info; | |
4617 | 2346 |
2347 /* Setup our I/O op functions */ | |
2348 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); | |
2349 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); | |
2350 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2351 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2352 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
4617 | 2353 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack); |
2354 | |
2355 /* | |
2356 * XXX - Should do something with args->msg, args->encoding, and args->language | |
2357 * probably make it apply to all ch2 messages. | |
3752 | 2358 */ |
4617 | 2359 |
2360 /* Keep track of this transfer for later */ | |
2361 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2362 | |
2363 /* Now perform the request */ | |
2364 gaim_xfer_request(xfer); | |
2365 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
2366 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2367 GaimXfer *xfer; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2368 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2369 "AAA - File transfer canceled by remote user\n"); |
4617 | 2370 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
|
2371 gaim_xfer_cancel_remote(xfer); |
4617 | 2372 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
2373 /* | |
2374 * This gets sent by the receiver of a file | |
2375 * as they connect directly to us. If we don't | |
2376 * get this, then maybe a third party connected | |
2377 * to us, and we shouldn't send them anything. | |
2378 */ | |
2379 } else { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2380 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2381 "unknown rendezvous status!\n"); |
3630 | 2382 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2383 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2384 } else if (args->reqclass & AIM_CAPS_VOICE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2385 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2386 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2387 userinfo->sn, args->info.icon.icon, |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2388 args->info.icon.length); |
6871 | 2389 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2390 struct ask_direct *d = g_new0(struct ask_direct, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2391 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2392 |
4212 | 2393 if (!args->verifiedip) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2394 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2395 "directim kill blocked (%s)\n", userinfo->sn); |
4650 | 2396 return 1; |
4212 | 2397 } |
2398 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2399 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2400 "%s received direct im request from %s (%s)\n", |
5575 | 2401 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2402 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2403 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2404 d->sn = g_strdup(userinfo->sn); |
2869 | 2405 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2406 memcpy(d->cookie, args->cookie, 8); |
5575 | 2407 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
|
2408 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2409 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2410 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2411 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2412 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2413 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2414 "risk."), 0, d, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2415 _("Connect"), G_CALLBACK(accept_direct_im), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2416 _("Cancel"), G_CALLBACK(cancel_direct_im)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2417 } else { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2418 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2419 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2420 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2421 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2422 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2423 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2424 |
3453 | 2425 /* |
4230 | 2426 * Authorization Functions |
2427 * Most of these are callbacks from dialogs. They're used by both | |
2428 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 2429 */ |
4269 | 2430 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2431 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 2432 GaimConnection *gc = data->gc; |
4244 | 2433 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2434 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2435 struct oscar_data *od = gc->proto_data; |
6695 | 2436 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
2437 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 2438 if (buddy && group) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2439 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2440 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2441 buddy->name, group->name); |
4889 | 2442 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 2443 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
4889 | 2444 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 1); |
4244 | 2445 } |
4230 | 2446 } |
4337 | 2447 } |
2448 | |
2449 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2450 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
2451 NULL, _("Please authorize me!"), TRUE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2452 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 2453 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2454 data); |
4230 | 2455 } |
2456 | |
2457 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 2458 GaimConnection *gc = data->gc; |
4244 | 2459 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2460 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2461 /* struct oscar_data *od = gc->proto_data; */ |
2462 /* XXX - Take the buddy out of our buddy list */ | |
2463 } | |
2464 | |
5836 | 2465 oscar_free_name_data(data); |
4230 | 2466 } |
2467 | |
5575 | 2468 static void gaim_auth_sendrequest(GaimConnection *gc, const char *name) { |
4269 | 2469 struct name_data *data = g_new(struct name_data, 1); |
6695 | 2470 GaimBuddy *buddy; |
4269 | 2471 gchar *dialog_msg, *nombre; |
2472 | |
4687 | 2473 buddy = gaim_find_buddy(gc->account, name); |
2474 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
2475 nombre = g_strdup_printf("%s (%s)", name, gaim_get_buddy_alias_only(buddy)); | |
4269 | 2476 else |
4830 | 2477 nombre = NULL; |
2478 | |
2479 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 | 2480 data->gc = gc; |
2481 data->name = g_strdup(name); | |
2482 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2483 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2484 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2485 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2486 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2487 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2488 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 2489 |
2490 g_free(dialog_msg); | |
2491 g_free(nombre); | |
2492 } | |
2493 | |
4230 | 2494 /* When other people ask you for authorization */ |
2495 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 2496 GaimConnection *gc = data->gc; |
4244 | 2497 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2498 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2499 struct oscar_data *od = gc->proto_data; |
4236 | 2500 #ifdef NOSSI |
6695 | 2501 GaimBuddy *buddy; |
4244 | 2502 gchar message; |
2503 message = 0; | |
4687 | 2504 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 2505 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
7011
diff
changeset
|
2506 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 2507 #else |
4889 | 2508 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 2509 #endif |
4244 | 2510 } |
2511 | |
5836 | 2512 oscar_free_name_data(data); |
3141 | 2513 } |
2514 | |
4230 | 2515 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2516 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 2517 GaimConnection *gc = data->gc; |
4244 | 2518 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2519 if (g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2520 struct oscar_data *od = gc->proto_data; |
4230 | 2521 #ifdef NOSSI |
4617 | 2522 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 2523 #else |
4889 | 2524 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 2525 #endif |
4244 | 2526 } |
4337 | 2527 } |
2528 | |
2529 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2530 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
2531 NULL, _("No reason given."), TRUE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2532 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 2533 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2534 data); |
3141 | 2535 } |
2536 | |
7023 | 2537 /* When someone sends you buddies */ |
2538 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 2539 GaimConnection *gc = data->gc; |
4244 | 2540 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2541 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
2542 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 2543 } |
2544 | |
5836 | 2545 oscar_free_name_data(data); |
3453 | 2546 } |
2547 | |
4075 | 2548 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 | 2549 GaimConnection *gc = sess->aux_data; |
4076 | 2550 gchar **msg1, **msg2; |
2551 GError *err = NULL; | |
6051 | 2552 int i, numtoks; |
4076 | 2553 |
4121 | 2554 if (!args->type || !args->msg || !args->uin) |
2555 return 1; | |
4194 | 2556 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2557 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2558 "Received a channel 4 message of type 0x%02hhx.\n", args->type); |
4076 | 2559 |
2560 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 2561 msg1 = g_strsplit(args->msg, "\376", 0); |
6051 | 2562 for (numtoks=0; msg1[numtoks]; numtoks++); |
2563 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 2564 for (i=0; msg1[i]; i++) { |
2565 strip_linefeed(msg1[i]); | |
2566 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); | |
4800 | 2567 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2568 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2569 "Error converting a string from ISO-8859-1 to " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2570 "UTF-8 in oscar ICBM channel 4 parsing\n"); |
4800 | 2571 g_error_free(err); |
2572 } | |
4076 | 2573 } |
2574 msg2[i] = NULL; | |
2575 | |
3952 | 2576 switch (args->type) { |
4173 | 2577 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 2578 if (i >= 1) { |
5556 | 2579 gchar *uin = g_strdup_printf("%u", args->uin); |
4076 | 2580 if (t) { /* This is an offline message */ |
2581 /* I think this timestamp is in UTC, or something */ | |
6982 | 2582 serv_got_im(gc, uin, msg2[0], 0, t); |
4076 | 2583 } else { /* This is a message from MacICQ/Miranda */ |
6982 | 2584 serv_got_im(gc, uin, msg2[0], 0, time(NULL)); |
4076 | 2585 } |
2586 g_free(uin); | |
4075 | 2587 } |
3316 | 2588 } break; |
2589 | |
4173 | 2590 case 0x04: { /* Someone sent you a URL */ |
4076 | 2591 if (i >= 2) { |
5556 | 2592 gchar *uin = g_strdup_printf("%u", args->uin); |
4076 | 2593 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]); |
6982 | 2594 serv_got_im(gc, uin, message, 0, time(NULL)); |
3453 | 2595 g_free(uin); |
2596 g_free(message); | |
2597 } | |
2598 } break; | |
2599 | |
4173 | 2600 case 0x06: { /* Someone requested authorization */ |
4076 | 2601 if (i >= 6) { |
4230 | 2602 struct name_data *data = g_new(struct name_data, 1); |
5556 | 2603 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.")); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2604 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
5556 | 2605 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2606 args->uin); |
4076 | 2607 data->gc = gc; |
5556 | 2608 data->name = g_strdup_printf("%u", args->uin); |
4230 | 2609 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2610 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2611 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2612 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2613 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2614 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2615 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2616 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 2617 g_free(dialog_msg); |
2618 } | |
3141 | 2619 } break; |
2620 | |
4173 | 2621 case 0x07: { /* Someone has denied you authorization */ |
4076 | 2622 if (i >= 1) { |
7023 | 2623 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
|
2624 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2625 dialog_msg); |
4076 | 2626 g_free(dialog_msg); |
2627 } | |
3141 | 2628 } break; |
2629 | |
4173 | 2630 case 0x08: { /* Someone has granted you authorization */ |
7023 | 2631 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
|
2632 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2633 dialog_msg); |
3141 | 2634 g_free(dialog_msg); |
2635 } break; | |
2636 | |
4333 | 2637 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
2638 if (i >= 5) { | |
2639 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
|
2640 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 2641 g_free(dialog_msg); |
2642 } | |
2643 } break; | |
2644 | |
4173 | 2645 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 2646 if (i >= 6) { |
4194 | 2647 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
|
2648 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 2649 g_free(dialog_msg); |
2650 } | |
4075 | 2651 } break; |
2652 | |
4173 | 2653 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 2654 if (i >= 6) { |
4308 | 2655 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
|
2656 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 2657 g_free(dialog_msg); |
2658 } | |
4075 | 2659 } break; |
2660 | |
4173 | 2661 case 0x12: { |
3141 | 2662 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 2663 /* Someone added you to their buddy list? */ |
3141 | 2664 } break; |
2665 | |
7023 | 2666 case 0x13: { /* Someone has sent you some ICQ buddies */ |
3453 | 2667 int i, num; |
2668 gchar **text; | |
4173 | 2669 text = g_strsplit(args->msg, "\376", 0); |
3453 | 2670 if (text) { |
2671 num = 0; | |
2672 for (i=0; i<strlen(text[0]); i++) | |
2673 num = num*10 + text[0][i]-48; | |
2674 for (i=0; i<num; i++) { | |
4230 | 2675 struct name_data *data = g_new(struct name_data, 1); |
7023 | 2676 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 | 2677 data->gc = gc; |
4790 | 2678 data->name = g_strdup(text[i*2+1]); |
2679 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2680 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2681 gaim_request_action(gc, NULL, message, |
7023 | 2682 _("Do you want to add this buddy " |
2683 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2684 0, data, 2, |
7023 | 2685 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 2686 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 2687 g_free(message); |
2688 } | |
2689 g_strfreev(text); | |
2690 } | |
2691 } break; | |
2692 | |
7023 | 2693 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 2694 /* This is boring and silly. */ |
2695 } break; | |
2696 | |
3141 | 2697 default: { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2698 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2699 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2700 "(type 0x%02hhx).\n", args->type); |
3141 | 2701 } break; |
2702 } | |
2703 | |
4076 | 2704 g_strfreev(msg1); |
2705 g_strfreev(msg2); | |
2706 | |
3141 | 2707 return 1; |
2708 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2709 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2710 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 2711 fu16_t channel; |
2712 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2713 aim_userinfo_t *userinfo; |
2086 | 2714 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2715 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2716 va_start(ap, fr); |
4200 | 2717 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2718 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 2719 |
3141 | 2720 switch (channel) { |
2721 case 1: { /* standard message */ | |
2722 struct aim_incomingim_ch1_args *args; | |
2723 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
2724 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
2725 } break; | |
2726 | |
2727 case 2: { /* rendevous */ | |
2728 struct aim_incomingim_ch2_args *args; | |
2729 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
2730 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
2731 } break; | |
2732 | |
2733 case 4: { /* ICQ */ | |
2734 struct aim_incomingim_ch4_args *args; | |
2735 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 2736 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 2737 } break; |
2738 | |
2739 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2740 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2741 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2742 "0x%04hx).", channel); |
3141 | 2743 } break; |
2086 | 2744 } |
2745 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2746 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2747 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2748 return ret; |
2086 | 2749 } |
2750 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2751 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
5420 | 2752 char *buf; |
2086 | 2753 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2754 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2755 aim_userinfo_t *userinfo; |
2086 | 2756 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2757 va_start(ap, fr); |
4200 | 2758 chan = (fu16_t)va_arg(ap, unsigned int); |
2759 userinfo = va_arg(ap, aim_userinfo_t *); | |
2760 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
2761 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 2762 va_end(ap); |
2763 | |
2764 switch(reason) { | |
5420 | 2765 case 0: /* Invalid (0) */ |
2766 buf = g_strdup_printf( | |
2767 ngettext( | |
4276 | 2768 "You missed %hu message from %s because it was invalid.", |
2769 "You missed %hu messages from %s because they were invalid.", | |
2770 nummissed), | |
4282 | 2771 nummissed, |
2772 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2773 break; |
5420 | 2774 case 1: /* Message too large */ |
2775 buf = g_strdup_printf( | |
2776 ngettext( | |
4276 | 2777 "You missed %hu message from %s because it was too large.", |
2778 "You missed %hu messages from %s because they were too large.", | |
2779 nummissed), | |
4282 | 2780 nummissed, |
2781 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2782 break; |
5420 | 2783 case 2: /* Rate exceeded */ |
2784 buf = g_strdup_printf( | |
2785 ngettext( | |
4276 | 2786 "You missed %hu message from %s because the rate limit has been exceeded.", |
2787 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
2788 nummissed), | |
4282 | 2789 nummissed, |
2790 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2791 break; |
5420 | 2792 case 3: /* Evil Sender */ |
2793 buf = g_strdup_printf( | |
2794 ngettext( | |
4276 | 2795 "You missed %hu message from %s because he/she was too evil.", |
2796 "You missed %hu messages from %s because he/she was too evil.", | |
2797 nummissed), | |
4282 | 2798 nummissed, |
2799 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2800 break; |
5420 | 2801 case 4: /* Evil Receiver */ |
2802 buf = g_strdup_printf( | |
2803 ngettext( | |
4276 | 2804 "You missed %hu message from %s because you are too evil.", |
2805 "You missed %hu messages from %s because you are too evil.", | |
2806 nummissed), | |
4282 | 2807 nummissed, |
2808 userinfo->sn); | |
2086 | 2809 break; |
2810 default: | |
5420 | 2811 buf = g_strdup_printf( |
2812 ngettext( | |
4276 | 2813 "You missed %hu message from %s for an unknown reason.", |
2814 "You missed %hu messages from %s for an unknown reason.", | |
2815 nummissed), | |
4282 | 2816 nummissed, |
2817 userinfo->sn); | |
2086 | 2818 break; |
2819 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2820 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 2821 g_free(buf); |
2086 | 2822 |
2823 return 1; | |
2824 } | |
2825 | |
3212 | 2826 static char *gaim_icq_status(int state) { |
2827 /* Make a cute little string that shows the status of the dude or dudet */ | |
2828 if (state & AIM_ICQ_STATE_CHAT) | |
4342 | 2829 return g_strdup_printf(_("Free For Chat")); |
3212 | 2830 else if (state & AIM_ICQ_STATE_DND) |
4342 | 2831 return g_strdup_printf(_("Do Not Disturb")); |
3212 | 2832 else if (state & AIM_ICQ_STATE_OUT) |
4342 | 2833 return g_strdup_printf(_("Not Available")); |
3212 | 2834 else if (state & AIM_ICQ_STATE_BUSY) |
4342 | 2835 return g_strdup_printf(_("Occupied")); |
3212 | 2836 else if (state & AIM_ICQ_STATE_AWAY) |
4342 | 2837 return g_strdup_printf(_("Away")); |
3212 | 2838 else if (state & AIM_ICQ_STATE_WEBAWARE) |
4342 | 2839 return g_strdup_printf(_("Web Aware")); |
3212 | 2840 else if (state & AIM_ICQ_STATE_INVISIBLE) |
4342 | 2841 return g_strdup_printf(_("Invisible")); |
3212 | 2842 else |
4342 | 2843 return g_strdup_printf(_("Online")); |
3212 | 2844 } |
2845 | |
4194 | 2846 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 2847 GaimConnection *gc = sess->aux_data; |
4617 | 2848 struct oscar_data *od = gc->proto_data; |
2849 | |
2850 /* BBB */ | |
3630 | 2851 switch (reason) { |
4151 | 2852 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2853 GaimXfer *xfer; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2854 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2855 "AAA - Other user declined file transfer\n"); |
4617 | 2856 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
|
2857 gaim_xfer_cancel_remote(xfer); |
4151 | 2858 } break; |
2859 | |
2860 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2861 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2862 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2863 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 2864 } |
3630 | 2865 |
2866 } | |
2867 | |
2868 return 0; | |
2869 } | |
2870 | |
4194 | 2871 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 2872 GaimConnection *gc = sess->aux_data; |
4151 | 2873 |
2874 switch(reason) { | |
2875 case 0x0003: { /* Reply from an ICQ status message request */ | |
2876 char *status_msg = gaim_icq_status(state); | |
2877 char *dialog_msg, **splitmsg; | |
2878 | |
2879 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
2880 splitmsg = g_strsplit(msg, "\r\n", 0); | |
2881 | |
7011 | 2882 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, status_msg, g_strjoinv("<BR>", splitmsg)); |
7032 | 2883 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, dialog_msg, NULL, NULL); |
4151 | 2884 |
2885 g_free(status_msg); | |
2886 g_free(dialog_msg); | |
2887 g_strfreev(splitmsg); | |
2888 } break; | |
2889 | |
2890 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2891 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2892 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2893 "Type 0x%04hx\n", who, reason); |
4151 | 2894 } break; |
2895 } /* end of switch */ | |
2896 | |
2897 return 0; | |
2898 } | |
2899 | |
3212 | 2900 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
2901 va_list ap; | |
2902 fu16_t chan, reason; | |
2903 char *who; | |
2904 | |
2905 va_start(ap, fr); | |
4200 | 2906 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 2907 who = va_arg(ap, char *); |
4200 | 2908 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 2909 |
3952 | 2910 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 2911 char *cookie = va_arg(ap, char *); |
4151 | 2912 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 2913 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 2914 fu32_t state = 0; |
4151 | 2915 char *msg = NULL; |
2916 if (reason == 0x0003) { | |
4200 | 2917 state = va_arg(ap, fu32_t); |
4151 | 2918 msg = va_arg(ap, char *); |
2919 } | |
2920 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
2921 } | |
3952 | 2922 |
3212 | 2923 va_end(ap); |
2924 | |
2925 return 1; | |
2926 } | |
2927 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2928 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2929 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2930 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2931 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2932 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2933 va_start(ap, fr); |
4199 | 2934 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 2935 va_end(ap); |
2936 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2937 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2938 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2939 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 2940 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2941 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 2942 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2943 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2944 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2945 |
2086 | 2946 return 1; |
2947 } | |
2948 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2949 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
4617 | 2950 #if 0 |
5575 | 2951 GaimConnection *gc = sess->aux_data; |
4617 | 2952 struct oscar_data *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2953 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2954 #endif |
4617 | 2955 va_list ap; |
2956 fu16_t reason; | |
2957 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2958 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2959 va_start(ap, fr); |
4617 | 2960 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 2961 data = va_arg(ap, char *); |
2086 | 2962 va_end(ap); |
2963 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2964 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2965 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 2966 |
2967 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2968 #if 0 |
4617 | 2969 /* If this was a file transfer request, data is a cookie */ |
2970 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
|
2971 gaim_xfer_cancel_remote(xfer); |
3630 | 2972 return 1; |
2973 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2974 #endif |
3630 | 2975 |
4617 | 2976 /* Data is assumed to be the destination sn */ |
2977 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2978 gaim_notify_error(sess->aux_data, NULL, buf, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2979 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); |
4617 | 2980 g_free(buf); |
2086 | 2981 |
2982 return 1; | |
2983 } | |
2984 | |
3595 | 2985 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2986 GaimConnection *gc = sess->aux_data; |
3595 | 2987 va_list ap; |
2988 fu16_t type1, type2; | |
2989 char *sn; | |
2990 | |
2991 va_start(ap, fr); | |
4199 | 2992 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 2993 sn = va_arg(ap, char *); |
4199 | 2994 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 2995 va_end(ap); |
2996 | |
2997 switch (type2) { | |
2998 case 0x0000: { /* Text has been cleared */ | |
2999 serv_got_typing_stopped(gc, sn); | |
3000 } break; | |
3001 | |
3002 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3003 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 3004 } break; |
3005 | |
3006 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3007 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 3008 } break; |
3009 | |
3010 default: { | |
5435 | 3011 gaim_debug(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 | 3012 } break; |
3013 } | |
3014 | |
3015 return 1; | |
3016 } | |
3017 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3018 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5420 | 3019 char *buf; |
2086 | 3020 va_list ap; |
5420 | 3021 fu16_t reason; |
2086 | 3022 char *destn; |
3023 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3024 va_start(ap, fr); |
4199 | 3025 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3026 destn = va_arg(ap, char *); |
3027 va_end(ap); | |
3028 | |
5420 | 3029 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3030 gaim_notify_error(sess->aux_data, NULL, buf, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3031 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); |
5420 | 3032 g_free(buf); |
2086 | 3033 |
3034 return 1; | |
3035 } | |
3036 | |
6982 | 3037 #if 0 |
2086 | 3038 static char *images(int flags) { |
3039 static char buf[1024]; | |
3101 | 3040 g_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s", |
2679 | 3041 (flags & AIM_FLAG_ACTIVEBUDDY) ? "<IMG SRC=\"ab_icon.gif\">" : "", |
2086 | 3042 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", |
3043 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
3101 | 3044 (flags & AIM_FLAG_ICQ) ? "<IMG SRC=\"icq_icon.gif\">" : "", |
2086 | 3045 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", |
3079 | 3046 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : "", |
3047 (flags & AIM_FLAG_WIRELESS) ? "<IMG SRC=\"wireless_icon.gif\">" : ""); | |
2086 | 3048 return buf; |
3049 } | |
6982 | 3050 #endif |
3101 | 3051 |
2920 | 3052 static char *caps_string(guint caps) |
3053 { | |
3054 static char buf[512], *tmp; | |
3055 int count = 0, i = 0; | |
3056 guint bit = 1; | |
4742 | 3057 |
3058 if (!caps) { | |
4744 | 3059 return NULL; |
6318 | 3060 } else while (bit <= AIM_CAPS_LAST) { |
2920 | 3061 if (bit & caps) { |
3062 switch (bit) { | |
6871 | 3063 case AIM_CAPS_BUDDYICON: |
2920 | 3064 tmp = _("Buddy Icon"); |
3065 break; | |
6871 | 3066 case AIM_CAPS_VOICE: |
2920 | 3067 tmp = _("Voice"); |
3068 break; | |
6871 | 3069 case AIM_CAPS_DIRECTIM: |
4898 | 3070 tmp = _("Direct IM"); |
2920 | 3071 break; |
6871 | 3072 case AIM_CAPS_CHAT: |
2920 | 3073 tmp = _("Chat"); |
3074 break; | |
6871 | 3075 case AIM_CAPS_GETFILE: |
2920 | 3076 tmp = _("Get File"); |
3077 break; | |
6871 | 3078 case AIM_CAPS_SENDFILE: |
2920 | 3079 tmp = _("Send File"); |
3080 break; | |
6871 | 3081 case AIM_CAPS_GAMES: |
3082 case AIM_CAPS_GAMES2: | |
2920 | 3083 tmp = _("Games"); |
3084 break; | |
6871 | 3085 case AIM_CAPS_SAVESTOCKS: |
4898 | 3086 tmp = _("Add-Ins"); |
2920 | 3087 break; |
6871 | 3088 case AIM_CAPS_SENDBUDDYLIST: |
2920 | 3089 tmp = _("Send Buddy List"); |
3090 break; | |
6871 | 3091 case AIM_CAPS_ICQ: |
2920 | 3092 tmp = _("EveryBuddy Bug"); |
3093 break; | |
6871 | 3094 case AIM_CAPS_APINFO: |
2920 | 3095 tmp = _("AP User"); |
3096 break; | |
6871 | 3097 case AIM_CAPS_ICQRTF: |
2920 | 3098 tmp = _("ICQ RTF"); |
3099 break; | |
6871 | 3100 case AIM_CAPS_EMPTY: |
2920 | 3101 tmp = _("Nihilist"); |
3102 break; | |
6871 | 3103 case AIM_CAPS_ICQSERVERRELAY: |
2920 | 3104 tmp = _("ICQ Server Relay"); |
3105 break; | |
6871 | 3106 case AIM_CAPS_ICQUTF8OLD: |
3107 tmp = _("Old ICQ UTF8"); | |
2920 | 3108 break; |
6871 | 3109 case AIM_CAPS_TRILLIANCRYPT: |
2920 | 3110 tmp = _("Trillian Encryption"); |
3111 break; | |
6871 | 3112 case AIM_CAPS_ICQUTF8: |
4742 | 3113 tmp = _("ICQ UTF8"); |
3114 break; | |
6318 | 3115 case AIM_CAPS_HIPTOP: |
3116 tmp = _("Hiptop"); | |
3117 break; | |
6871 | 3118 case AIM_CAPS_SECUREIM: |
3119 tmp = _("Secure IM"); | |
3120 break; | |
2920 | 3121 default: |
3122 tmp = NULL; | |
3123 break; | |
3124 } | |
3125 if (tmp) | |
3126 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
3127 tmp); | |
3128 count++; | |
3129 } | |
3130 bit <<= 1; | |
3131 } | |
4744 | 3132 return buf; |
2920 | 3133 } |
3134 | |
7011 | 3135 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3136 GaimConnection *gc = sess->aux_data; |
7011 | 3137 GString *text; |
3138 char *info_utf8 = NULL, *away_utf8 = NULL; | |
4791 | 3139 va_list ap; |
7011 | 3140 aim_userinfo_t *userinfo; |
2086 | 3141 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3142 va_start(ap, fr); |
7011 | 3143 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3144 va_end(ap); |
3145 | |
7011 | 3146 text = g_string_new(""); |
3147 g_string_append_printf(text, _("Username: <b>%s</b><br>\n"), userinfo->sn); | |
3148 g_string_append_printf(text, _("Warning Level: <b>%d%%</b><br>\n"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
3149 | |
3150 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
3151 g_string_append_printf(text, _("Online Since: <b>%s</b><br>\n"), | |
3152 asctime(localtime((time_t *)&userinfo->onlinesince))); | |
3153 | |
3154 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
3155 g_string_append_printf(text, _("Member Since: <b>%s</b><br>\n"), | |
3156 asctime(localtime((time_t *)&userinfo->membersince))); | |
3157 | |
3158 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
3159 gchar *itime = sec_to_text(userinfo->idletime*60); | |
3160 g_string_append_printf(text, _("Idle: <b>%s</b>"), itime); | |
4426 | 3161 g_free(itime); |
2993 | 3162 } else |
7011 | 3163 g_string_append_printf(text, _("Idle: <b>Active</b>")); |
3164 | |
3165 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
3166 away_utf8 = oscar_encoding_to_utf8(userinfo->away_encoding, userinfo->away, userinfo->away_len); | |
3167 if (away_utf8 != NULL) { | |
3168 g_string_append_printf(text, _("<hr>%s"), away_utf8); | |
3169 g_free(away_utf8); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3170 } |
7011 | 3171 } |
3172 | |
3173 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
3174 info_utf8 = oscar_encoding_to_utf8(userinfo->info_encoding, userinfo->info, userinfo->info_len); | |
3175 if (info_utf8 != NULL) { | |
3176 g_string_append_printf(text, _("<hr>%s"), info_utf8); | |
3177 g_free(info_utf8); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3178 } |
7011 | 3179 } |
3180 | |
7045 | 3181 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, text->str, NULL, NULL); |
7011 | 3182 g_string_free(text, TRUE); |
4151 | 3183 |
2086 | 3184 return 1; |
3185 } | |
3186 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3187 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3188 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3189 fu16_t id; |
2086 | 3190 va_list ap; |
3191 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3192 va_start(ap, fr); |
4199 | 3193 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3194 msg = va_arg(ap, char *); |
3195 va_end(ap); | |
3196 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3197 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3198 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
3199 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3200 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3201 _("Your AIM connection may be lost."), NULL); |
2086 | 3202 |
3203 return 1; | |
3204 } | |
3205 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3206 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3207 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3208 fu16_t type; |
5575 | 3209 GaimConnection *gc = sess->aux_data; |
4617 | 3210 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 3211 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3212 va_start(ap, fr); |
4199 | 3213 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3214 |
3215 switch(type) { | |
3216 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3217 fu8_t maxrooms; |
2086 | 3218 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3219 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3220 |
4199 | 3221 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 3222 exchangecount = va_arg(ap, int); |
3223 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
3224 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3225 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3226 "chat info: Chat Rights:\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3227 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3228 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3229 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3230 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3231 for (i = 0; i < exchangecount; i++) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3232 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3233 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3234 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 3235 while (od->create_rooms) { |
3236 struct create_room *cr = od->create_rooms->data; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3237 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3238 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3239 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3240 g_free(cr->name); |
4617 | 3241 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3242 g_free(cr); |
2086 | 3243 } |
3244 } | |
3245 break; | |
3246 case 0x0008: { | |
3247 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3248 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3249 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3250 fu32_t createtime; |
2086 | 3251 |
3252 fqcn = va_arg(ap, char *); | |
4200 | 3253 instance = (fu16_t)va_arg(ap, unsigned int); |
3254 exchange = (fu16_t)va_arg(ap, unsigned int); | |
3255 flags = (fu16_t)va_arg(ap, unsigned int); | |
3256 createtime = va_arg(ap, fu32_t); | |
3257 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3258 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
3259 createperms = (fu8_t)va_arg(ap, unsigned int); | |
3260 unknown = (fu16_t)va_arg(ap, unsigned int); | |
3261 name = va_arg(ap, char *); | |
3262 ck = va_arg(ap, char *); | |
4194 | 3263 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3264 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
5556 | 3265 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 3266 fqcn, |
3267 exchange, instance, flags, | |
3268 createtime, | |
3269 maxmsglen, maxoccupancy, createperms, unknown, | |
3270 name, ck); | |
4617 | 3271 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 3272 } |
3273 break; | |
3274 default: | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3275 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3276 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 3277 break; |
3278 } | |
4194 | 3279 |
3280 va_end(ap); | |
3281 | |
2086 | 3282 return 1; |
3283 } | |
3284 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3285 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3286 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3287 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3288 aim_userinfo_t *info; |
5575 | 3289 GaimConnection *g = sess->aux_data; |
2086 | 3290 |
3291 struct chat_connection *c = NULL; | |
3292 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3293 va_start(ap, fr); |
2086 | 3294 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3295 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3296 va_end(ap); |
3297 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3298 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3299 if (!c) |
3300 return 1; | |
3301 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3302 for (i = 0; i < count; i++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
3303 gaim_chat_add_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3304 |
3305 return 1; | |
3306 } | |
3307 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3308 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3309 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3310 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3311 aim_userinfo_t *info; |
5575 | 3312 GaimConnection *g = sess->aux_data; |
2086 | 3313 |
3314 struct chat_connection *c = NULL; | |
3315 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3316 va_start(ap, fr); |
2086 | 3317 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3318 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3319 va_end(ap); |
3320 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3321 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3322 if (!c) |
3323 return 1; | |
3324 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3325 for (i = 0; i < count; i++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
3326 gaim_chat_remove_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3327 |
3328 return 1; | |
3329 } | |
3330 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3331 static int gaim_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
|
3332 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3333 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3334 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3335 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3336 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3337 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3338 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3339 fu32_t creationtime; |
5575 | 3340 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3341 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
|
3342 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3343 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3344 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3345 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3346 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3347 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3348 roomdesc = va_arg(ap, char *); |
4200 | 3349 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
3350 creationtime = va_arg(ap, fu32_t); | |
3351 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3352 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
3353 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
3354 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3355 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3356 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3357 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3358 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3359 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3360 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3361 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3362 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3363 |
2086 | 3364 return 1; |
3365 } | |
3366 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3367 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3368 GaimConnection *gc = sess->aux_data; |
2086 | 3369 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3370 aim_userinfo_t *info; |
2086 | 3371 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3372 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
2086 | 3373 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3374 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3375 info = va_arg(ap, aim_userinfo_t *); |
4194 | 3376 msg = va_arg(ap, char *); |
3377 va_end(ap); | |
2086 | 3378 |
4269 | 3379 serv_got_chat_in(gc, ccon->id, info->sn, 0, msg, time((time_t)NULL)); |
2086 | 3380 |
3381 return 1; | |
3382 } | |
3383 | |
3694 | 3384 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
3385 va_list ap; | |
5575 | 3386 GaimConnection *gc = sess->aux_data; |
3694 | 3387 struct aim_emailinfo *emailinfo; |
3725 | 3388 int havenewmail; |
3694 | 3389 |
3390 va_start(ap, fr); | |
3391 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 3392 havenewmail = va_arg(ap, int); |
3694 | 3393 va_end(ap); |
3394 | |
5628 | 3395 if (emailinfo && gaim_account_get_check_mail(gc->account)) { |
5575 | 3396 gchar *to = g_strdup_printf("%s@%s", gaim_account_get_username(gaim_connection_get_account(gc)), emailinfo->domain); |
5542 | 3397 if (emailinfo->unread && havenewmail) |
3398 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 3399 g_free(to); |
3694 | 3400 } |
3401 | |
3402 return 1; | |
3403 } | |
3404 | |
4804 | 3405 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3406 GaimConnection *gc = sess->aux_data; |
4804 | 3407 struct oscar_data *od = gc->proto_data; |
3408 char *sn; | |
3409 | |
3410 sn = od->requesticon->data; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3411 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3412 "removing %s from hash table\n", sn); |
4804 | 3413 od->requesticon = g_slist_remove(od->requesticon, sn); |
3414 free(sn); | |
3415 | |
3416 if (od->icontimer) | |
3417 g_source_remove(od->icontimer); | |
3418 od->icontimer = g_timeout_add(500, gaim_icon_timerfunc, gc); | |
3419 | |
3420 return 1; | |
3421 } | |
3422 | |
3423 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3424 GaimConnection *gc = sess->aux_data; |
4804 | 3425 struct oscar_data *od = gc->proto_data; |
3426 GSList *cur; | |
3427 va_list ap; | |
3428 char *sn; | |
4853 | 3429 fu8_t *iconcsum, *icon; |
3430 fu16_t iconcsumlen, iconlen; | |
4804 | 3431 |
3432 va_start(ap, fr); | |
3433 sn = va_arg(ap, char *); | |
4853 | 3434 iconcsum = va_arg(ap, fu8_t *); |
3435 iconcsumlen = va_arg(ap, int); | |
4804 | 3436 icon = va_arg(ap, fu8_t *); |
3437 iconlen = va_arg(ap, int); | |
3438 va_end(ap); | |
3439 | |
4853 | 3440 if (iconlen > 0) { |
3441 char *b16; | |
6695 | 3442 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3443 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3444 sn, icon, iconlen); |
4853 | 3445 b16 = tobase16(iconcsum, iconcsumlen); |
5129 | 3446 if (b16) { |
3447 gaim_buddy_set_setting(b, "icon_checksum", b16); | |
3448 gaim_blist_save(); | |
5125 | 3449 free(b16); |
5129 | 3450 } |
4853 | 3451 } |
4804 | 3452 |
3453 cur = od->requesticon; | |
3454 while (cur) { | |
3455 char *cursn = cur->data; | |
3456 if (!aim_sncmp(cursn, sn)) { | |
3457 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
3458 free(cursn); | |
3459 cur = od->requesticon; | |
3460 } else | |
3461 cur = cur->next; | |
3462 } | |
3463 | |
3464 if (od->icontimer) | |
3465 g_source_remove(od->icontimer); | |
3466 od->icontimer = g_timeout_add(250, gaim_icon_timerfunc, gc); | |
3467 | |
3468 return 1; | |
3469 } | |
3470 | |
3471 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 3472 GaimConnection *gc = data; |
4804 | 3473 struct oscar_data *od = gc->proto_data; |
7011 | 3474 aim_userinfo_t *userinfo; |
4804 | 3475 aim_conn_t *conn; |
3476 | |
3477 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 3478 if (!conn) { |
3479 if (!od->iconconnecting) { | |
3480 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
3481 od->iconconnecting = TRUE; | |
3482 } | |
4804 | 3483 return FALSE; |
3484 } | |
3485 | |
5842 | 3486 if (od->set_icon) { |
6039 | 3487 struct stat st; |
3488 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
3489 if (iconfile == NULL) { | |
3490 /* Set an empty icon, or something */ | |
3491 } else if (!stat(iconfile, &st)) { | |
3492 char *buf = g_malloc(st.st_size); | |
3493 FILE *file = fopen(iconfile, "rb"); | |
3494 if (file) { | |
3495 fread(buf, 1, st.st_size, file); | |
3496 fclose(file); | |
3497 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
3498 "Uploading icon to icon server\n"); | |
6879 | 3499 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 3500 } else |
3501 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
6039 | 3502 "Can't open buddy icon file!\n"); |
3503 g_free(buf); | |
3504 } else { | |
3505 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
3506 "Can't stat buddy icon file!\n"); | |
5842 | 3507 } |
3508 od->set_icon = FALSE; | |
3509 } | |
3510 | |
3511 if (!od->requesticon) { | |
3512 gaim_debug(GAIM_DEBUG_MISC, "oscar", | |
3513 "no more icons to request\n"); | |
3514 return FALSE; | |
3515 } | |
3516 | |
7045 | 3517 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 3518 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
3519 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 3520 return FALSE; |
3521 } else { | |
3522 char *sn = od->requesticon->data; | |
3523 od->requesticon = g_slist_remove(od->requesticon, sn); | |
3524 free(sn); | |
3525 } | |
3526 | |
3527 return TRUE; | |
3528 } | |
3529 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3530 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3531 * 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
|
3532 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3533 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3534 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3535 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3536 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3537 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3538 va_start(ap, fr); |
4199 | 3539 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3540 sn = va_arg(ap, char *); |
3541 va_end(ap); | |
3542 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3543 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sent message to %s.\n", sn); |
2086 | 3544 |
3545 return 1; | |
3546 } | |
3547 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3548 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
|
3549 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3550 "invalid", |
4194 | 3551 "change", |
3552 "warning", | |
3553 "limit", | |
3554 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3555 }; |
2086 | 3556 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3557 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3558 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3559 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3560 va_start(ap, fr); |
4200 | 3561 code = (fu16_t)va_arg(ap, unsigned int); |
3562 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
3563 windowsize = va_arg(ap, fu32_t); | |
3564 clear = va_arg(ap, fu32_t); | |
3565 alert = va_arg(ap, fu32_t); | |
3566 limit = va_arg(ap, fu32_t); | |
3567 disconnect = va_arg(ap, fu32_t); | |
3568 currentavg = va_arg(ap, fu32_t); | |
3569 maxavg = va_arg(ap, fu32_t); | |
2086 | 3570 va_end(ap); |
3571 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3572 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
5556 | 3573 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
3574 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 3575 (code < 5) ? codes[code] : codes[0], |
3576 rateclass, | |
3577 currentavg, maxavg, | |
3578 alert, clear, | |
3579 limit, disconnect, | |
3580 windowsize); | |
3581 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3582 /* XXX fix these values */ |
2086 | 3583 if (code == AIM_RATE_CODE_CHANGE) { |
3584 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3585 aim_conn_setlatency(fr->conn, 0); |
2086 | 3586 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3587 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
3588 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3589 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 3590 _("The last action you attempted could not be " |
3591 "performed because you are over the rate limit. " | |
3592 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3593 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 3594 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3595 aim_conn_setlatency(fr->conn, 0); |
2086 | 3596 } |
3597 | |
3598 return 1; | |
3599 } | |
3600 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3601 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3602 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3603 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3604 aim_userinfo_t *userinfo; |
5575 | 3605 GaimConnection *gc = sess->aux_data; |
2086 | 3606 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3607 va_start(ap, fr); |
4199 | 3608 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3609 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3610 va_end(ap); |
3611 | |
5628 | 3612 serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 3613 |
3614 return 1; | |
3615 } | |
3616 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3617 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
|
3618 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3619 aim_userinfo_t *info; |
5575 | 3620 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3621 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3622 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3623 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3624 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3625 |
5628 | 3626 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 3627 |
3628 if (info->onlinesince) | |
3629 gc->login_time_official = info->onlinesince; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3630 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3631 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3632 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3633 |
4649 | 3634 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3635 GaimConnection *gc = sess->aux_data; |
4666 | 3636 struct oscar_data *od = gc->proto_data; |
4649 | 3637 va_list ap; |
3638 fu16_t code; | |
3639 char *msg; | |
3640 | |
3641 va_start(ap, fr); | |
3642 code = (fu16_t)va_arg(ap, int); | |
3643 msg = va_arg(ap, char *); | |
3644 va_end(ap); | |
3645 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3646 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3647 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 3648 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 3649 if (code == 0x0001) { |
6113 | 3650 gc->wants_to_die = TRUE; |
5579 | 3651 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 3652 } else { |
5579 | 3653 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 3654 } |
4666 | 3655 od->killme = TRUE; |
4649 | 3656 } |
3657 | |
3658 return 1; | |
3659 } | |
3660 | |
2675 | 3661 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3662 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3663 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 3664 |
3665 #ifndef NOSSI | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3666 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: requesting ssi list\n"); |
4889 | 3667 aim_ssi_reqrights(sess); |
6350 | 3668 aim_ssi_reqdata(sess); |
4230 | 3669 #endif |
3670 | |
7011 | 3671 aim_locate_reqrights(sess); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3672 aim_bos_reqbuddyrights(sess, fr->conn); |
4617 | 3673 aim_im_reqparams(sess); |
5948 | 3674 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi? */ |
4230 | 3675 |
3676 #ifdef NOSSI | |
3677 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); | |
3678 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
3679 #endif | |
2086 | 3680 |
3681 return 1; | |
3682 } | |
3683 | |
2675 | 3684 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3685 GaimConnection *gc = sess->aux_data; |
2647 | 3686 struct oscar_data *od = gc->proto_data; |
3687 | |
6905 | 3688 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
3689 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
3690 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
3691 | |
2672 | 3692 aim_clientready(sess, fr->conn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3693 gaim_debug(GAIM_DEBUG_INFO, "oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3694 |
2647 | 3695 if (od->chpass) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3696 gaim_debug(GAIM_DEBUG_INFO, "oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3697 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 3698 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3699 od->oldp = NULL; |
2647 | 3700 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3701 od->newp = NULL; |
2647 | 3702 od->chpass = FALSE; |
3703 } | |
2979 | 3704 if (od->setnick) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3705 gaim_debug(GAIM_DEBUG_INFO, "oscar", "formatting screenname\n"); |
2979 | 3706 aim_admin_setnick(sess, fr->conn, od->newsn); |
3707 g_free(od->newsn); | |
3708 od->newsn = NULL; | |
3709 od->setnick = FALSE; | |
3710 } | |
2647 | 3711 if (od->conf) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3712 gaim_debug(GAIM_DEBUG_INFO, "oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3713 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 3714 od->conf = FALSE; |
3715 } | |
3716 if (od->reqemail) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3717 gaim_debug(GAIM_DEBUG_INFO, "oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3718 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 3719 od->reqemail = FALSE; |
3720 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3721 if (od->setemail) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3722 gaim_debug(GAIM_DEBUG_INFO, "oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3723 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3724 g_free(od->email); |
5497 | 3725 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3726 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3727 } |
2647 | 3728 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3729 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3730 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3731 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3732 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
|
3733 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3734 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3735 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3736 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3737 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3738 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3739 |
4194 | 3740 /* XXX - evidently this crashes on solaris. i have no clue why |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3741 gaim_debug(GAIM_DEBUG_MISC, "oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 3742 "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
|
3743 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3744 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3745 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3746 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3747 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3748 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 3749 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3750 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3751 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3752 |
4617 | 3753 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3754 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3755 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3756 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3757 |
2993 | 3758 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
3759 { | |
5575 | 3760 GaimConnection *gc = sess->aux_data; |
4617 | 3761 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5306 | 3762 va_list ap; |
3763 fu16_t maxsiglen; | |
2993 | 3764 |
3765 va_start(ap, fr); | |
4199 | 3766 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 3767 va_end(ap); |
3768 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3769 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3770 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 3771 |
4617 | 3772 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
3773 | |
3774 if (od->icq) | |
7011 | 3775 aim_locate_setprofile(sess, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
5301 | 3776 else |
5954 | 3777 oscar_set_info(gc, gc->account->user_info); |
2993 | 3778 |
3779 return 1; | |
3780 } | |
3781 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3782 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
|
3783 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3784 fu16_t maxbuddies, maxwatchers; |
5575 | 3785 GaimConnection *gc = sess->aux_data; |
4617 | 3786 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3787 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3788 va_start(ap, fr); |
4199 | 3789 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
3790 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3791 va_end(ap); |
3792 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3793 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3794 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 3795 |
4617 | 3796 od->rights.maxbuddies = (guint)maxbuddies; |
3797 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 3798 |
2086 | 3799 return 1; |
3800 } | |
3801 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3802 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3803 fu16_t maxpermits, maxdenies; |
2086 | 3804 va_list ap; |
5575 | 3805 GaimConnection *gc = sess->aux_data; |
4617 | 3806 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 3807 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3808 va_start(ap, fr); |
4199 | 3809 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
3810 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3811 va_end(ap); |
3812 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3813 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3814 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 3815 |
4617 | 3816 od->rights.maxpermits = (guint)maxpermits; |
3817 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 3818 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
3819 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 3820 serv_finish_login(gc); |
3821 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3822 gaim_debug(GAIM_DEBUG_INFO, "oscar", "buddy list loaded\n"); |
2993 | 3823 |
2672 | 3824 aim_clientready(sess, fr->conn); |
5948 | 3825 aim_srv_setavailmsg(sess, NULL); |
5917 | 3826 aim_bos_setidle(sess, fr->conn, 0); |
4617 | 3827 |
4664 | 3828 if (od->icq) { |
3829 aim_icq_reqofflinemsgs(sess); | |
3830 aim_icq_hideip(sess); | |
3831 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3832 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3833 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 3834 if (sess->authinfo->email) |
3835 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 3836 |
3837 return 1; | |
3838 } | |
3839 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3840 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
|
3841 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3842 struct aim_icq_offlinemsg *msg; |
4075 | 3843 struct aim_incomingim_ch4_args args; |
3844 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3845 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3846 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3847 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3848 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3849 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3850 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3851 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 3852 args.uin = msg->sender; |
3853 args.type = msg->type; | |
4173 | 3854 args.flags = msg->flags; |
4076 | 3855 args.msglen = msg->msglen; |
4075 | 3856 args.msg = msg->msg; |
3857 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); | |
3858 incomingim_chan4(sess, fr->conn, NULL, &args, t); | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3859 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3860 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3861 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3862 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3863 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
|
3864 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3865 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3866 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3867 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3868 |
4624 | 3869 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
|
3870 { |
5575 | 3871 GaimConnection *gc = sess->aux_data; |
4819 | 3872 gchar *buf, *tmp, *utf8; |
4624 | 3873 gchar who[16]; |
6873 | 3874 GaimBuddy *buddy; |
3875 gchar *primary; | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3876 va_list ap; |
4151 | 3877 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3878 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3879 va_start(ap, fr); |
4151 | 3880 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3881 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3882 |
4664 | 3883 if (!info->uin) |
3884 return 0; | |
3885 | |
5556 | 3886 g_snprintf(who, sizeof(who), "%u", info->uin); |
6623 | 3887 buf = g_strdup_printf("<b>%s:</b> %s", _("UIN"), who); |
4819 | 3888 if (info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) { |
6623 | 3889 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Nick"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 3890 } |
3891 if (info->first && info->first[0] && (utf8 = gaim_try_conv_to_utf8(info->first))) { | |
6623 | 3892 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("First Name"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 3893 } |
3894 if (info->last && info->last[0] && (utf8 = gaim_try_conv_to_utf8(info->last))) { | |
6623 | 3895 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Last Name"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 3896 } |
3897 if (info->email && info->email[0] && (utf8 = gaim_try_conv_to_utf8(info->email))) { | |
6623 | 3898 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address"), ":</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); |
4625 | 3899 } |
3900 if (info->numaddresses && info->email2) { | |
3901 int i; | |
3902 for (i = 0; i < info->numaddresses; i++) { | |
4819 | 3903 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_try_conv_to_utf8(info->email2[i]))) { |
6623 | 3904 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address"), ":</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); |
4643 | 3905 } |
4625 | 3906 } |
4624 | 3907 } |
4819 | 3908 if (info->mobile && info->mobile[0] && (utf8 = gaim_try_conv_to_utf8(info->mobile))) { |
6623 | 3909 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Mobile Phone"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4625 | 3910 } |
3911 if (info->gender) { | |
6623 | 3912 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Gender"), ":</b> ", info->gender==1 ? _("Female") : _("Male"), NULL); g_free(tmp); |
4151 | 3913 } |
4624 | 3914 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 3915 char date[30]; |
3916 struct tm tm; | |
3917 tm.tm_mday = (int)info->birthday; | |
3918 tm.tm_mon = (int)info->birthmonth-1; | |
3919 tm.tm_year = (int)info->birthyear-1900; | |
4628 | 3920 strftime(date, sizeof(date), "%x", &tm); |
6623 | 3921 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Birthday"), ":</b> ", date, NULL); g_free(tmp); |
4151 | 3922 } |
4624 | 3923 if (info->age) { |
3924 char age[5]; | |
3925 snprintf(age, sizeof(age), "%hhd", info->age); | |
6623 | 3926 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Age"), ":</b> ", age, NULL); g_free(tmp); |
4819 | 3927 } |
3928 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->personalwebpage))) { | |
6623 | 3929 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Personal Web Page"), ":</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); |
4819 | 3930 } |
3931 if (info->info && info->info[0] && (utf8 = gaim_try_conv_to_utf8(info->info))) { | |
6623 | 3932 tmp = buf; buf = g_strconcat(tmp, "<hr><b>", _("Additional Information"), ":</b><br>", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3933 } |
3934 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp); | |
4641 | 3935 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
6623 | 3936 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Home Address"), ":</b>", NULL); g_free(tmp); |
4819 | 3937 if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->homeaddr))) { |
6623 | 3938 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3939 } |
4819 | 3940 if (info->homecity && info->homecity[0] && (utf8 = gaim_try_conv_to_utf8(info->homecity))) { |
6623 | 3941 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3942 } |
4819 | 3943 if (info->homestate && info->homestate[0] && (utf8 = gaim_try_conv_to_utf8(info->homestate))) { |
6623 | 3944 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3945 } |
4819 | 3946 if (info->homezip && info->homezip[0] && (utf8 = gaim_try_conv_to_utf8(info->homezip))) { |
6623 | 3947 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3948 } |
3949 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 3950 } |
4641 | 3951 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
6623 | 3952 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Address"), ":</b>", NULL); g_free(tmp); |
4819 | 3953 if (info->workaddr && info->workaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->workaddr))) { |
6623 | 3954 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3955 } |
4819 | 3956 if (info->workcity && info->workcity[0] && (utf8 = gaim_try_conv_to_utf8(info->workcity))) { |
6623 | 3957 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3958 } |
4819 | 3959 if (info->workstate && info->workstate[0] && (utf8 = gaim_try_conv_to_utf8(info->workstate))) { |
6623 | 3960 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3961 } |
4819 | 3962 if (info->workzip && info->workzip[0] && (utf8 = gaim_try_conv_to_utf8(info->workzip))) { |
6623 | 3963 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3964 } |
3965 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
3966 } | |
4641 | 3967 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
6623 | 3968 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Information"), ":</b>", NULL); g_free(tmp); |
4819 | 3969 if (info->workcompany && info->workcompany[0] && (utf8 = gaim_try_conv_to_utf8(info->workcompany))) { |
6623 | 3970 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Company"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3971 } |
4819 | 3972 if (info->workdivision && info->workdivision[0] && (utf8 = gaim_try_conv_to_utf8(info->workdivision))) { |
6623 | 3973 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Division"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3974 } |
4819 | 3975 if (info->workposition && info->workposition[0] && (utf8 = gaim_try_conv_to_utf8(info->workposition))) { |
6623 | 3976 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Position"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 3977 } |
4819 | 3978 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->workwebpage))) { |
6623 | 3979 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Web Page"), ":</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); |
4624 | 3980 } |
3981 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 3982 } |
3983 | |
6873 | 3984 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
3985 primary = g_strdup_printf(_("ICQ Info for %s"), gaim_get_buddy_alias(buddy)); | |
3986 gaim_notify_formatted(gc, NULL, primary, NULL, buf, NULL, NULL); | |
3987 g_free(primary); | |
4151 | 3988 g_free(buf); |
3989 | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3990 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3991 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3992 |
4759 | 3993 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
3994 { | |
5575 | 3995 GaimConnection *gc = sess->aux_data; |
4820 | 3996 gchar who[16], *utf8; |
6695 | 3997 GaimBuddy *b; |
4759 | 3998 va_list ap; |
3999 struct aim_icq_info *info; | |
4000 | |
4001 va_start(ap, fr); | |
4002 info = va_arg(ap, struct aim_icq_info *); | |
4003 va_end(ap); | |
4004 | |
4822 | 4005 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) { |
5556 | 4006 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 4007 serv_got_alias(gc, who, utf8); |
4759 | 4008 if ((b = gaim_find_buddy(gc->account, who))) { |
4820 | 4009 gaim_buddy_set_setting(b, "servernick", utf8); |
4759 | 4010 gaim_blist_save(); |
4011 } | |
4820 | 4012 g_free(utf8); |
4759 | 4013 } |
4014 | |
4015 return 1; | |
4016 } | |
4017 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4018 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
|
4019 { |
7032 | 4020 GaimConnection *gc = sess->aux_data; |
4021 gchar *text; | |
4022 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4023 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4024 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4025 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4026 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4027 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4028 url = va_arg(ap, char *); |
4199 | 4029 wid = (fu16_t) va_arg(ap, int); |
4030 hei = (fu16_t) va_arg(ap, int); | |
4031 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4032 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4033 |
7032 | 4034 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
4035 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
4036 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4037 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4038 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4039 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4040 |
7032 | 4041 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
4042 { | |
6873 | 4043 GaimConnection *gc = sess->aux_data; |
4044 gchar *secondary; | |
4045 GString *text; | |
4046 int i, num; | |
2086 | 4047 va_list ap; |
6873 | 4048 char *email, *SNs; |
2086 | 4049 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4050 va_start(ap, fr); |
6873 | 4051 email = va_arg(ap, char *); |
2086 | 4052 num = va_arg(ap, int); |
4053 SNs = va_arg(ap, char *); | |
4054 va_end(ap); | |
4055 | |
6873 | 4056 secondary = g_strdup_printf(_("The following screennames are associated with %s"), email); |
4057 text = g_string_new(""); | |
2086 | 4058 for (i = 0; i < num; i++) |
6873 | 4059 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
4060 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
4061 | |
4062 g_free(secondary); | |
4063 g_string_free(text, TRUE); | |
2086 | 4064 |
4065 return 1; | |
4066 } | |
4067 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4068 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4069 va_list ap; |
6873 | 4070 char *email; |
5420 | 4071 char *buf; |
2086 | 4072 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4073 va_start(ap, fr); |
6873 | 4074 email = va_arg(ap, char *); |
2086 | 4075 va_end(ap); |
4076 | |
6873 | 4077 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
|
4078 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4079 g_free(buf); |
2086 | 4080 |
4081 return 1; | |
4082 } | |
4083 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4084 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 4085 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4086 fu16_t status; |
2086 | 4087 va_list ap; |
4088 char msg[256]; | |
4089 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4090 va_start(ap, fr); |
4199 | 4091 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 4092 va_end(ap); |
4093 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4094 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4095 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 4096 status ? "unknown" : "email sent"); |
4097 if (!status) { | |
5302 | 4098 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 4099 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4100 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 4101 } |
4102 | |
4103 return 1; | |
4104 } | |
4105 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4106 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4107 GaimConnection *gc = sess->aux_data; |
2086 | 4108 va_list ap; |
3912 | 4109 fu16_t perms, err; |
4110 char *url, *sn, *email; | |
4111 int change; | |
2086 | 4112 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4113 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4114 change = va_arg(ap, int); |
4199 | 4115 perms = (fu16_t) va_arg(ap, unsigned int); |
4116 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 4117 url = va_arg(ap, char *); |
4118 sn = va_arg(ap, char *); | |
4119 email = va_arg(ap, char *); | |
2086 | 4120 va_end(ap); |
4121 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4122 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4123 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
3912 | 4124 change ? "change" : "request", perms, err, url, sn, email); |
4125 | |
4126 if (err && url) { | |
4127 char *dialog_msg; | |
4128 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
4129 switch (err) { | |
4130 case 0x0001: { | |
4131 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
4132 } break; | |
4133 case 0x0006: { | |
4134 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
4135 } break; | |
4136 case 0x000b: { | |
4137 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
4138 } break; | |
4139 case 0x001d: { | |
4140 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); | |
4141 } break; | |
4142 case 0x0021: { | |
4143 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); | |
4144 } break; | |
4145 case 0x0023: { | |
4146 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
4147 } break; | |
4148 default: { | |
4149 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
4150 } break; | |
4151 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4152 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 4153 g_free(dialog_top); |
4154 g_free(dialog_msg); | |
4155 return 1; | |
4156 } | |
4157 | |
4158 if (sn) { | |
4585 | 4159 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
|
4160 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 4161 g_free(dialog_msg); |
4162 } | |
4163 | |
4164 if (email) { | |
5575 | 4165 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
4166 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4167 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 4168 g_free(dialog_msg); |
2086 | 4169 } |
4170 | |
4171 return 1; | |
4172 } | |
4173 | |
5575 | 4174 static void oscar_keepalive(GaimConnection *gc) { |
4617 | 4175 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4176 aim_flap_nop(od->sess, od->conn); | |
2086 | 4177 } |
4178 | |
6059 | 4179 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
4617 | 4180 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4181 struct direct_im *dim = find_direct_im(od, name); | |
3595 | 4182 if (dim) |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4183 if (typing == GAIM_TYPING) |
4870 | 4184 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4185 else if (typing == GAIM_TYPED) |
4870 | 4186 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
4187 else | |
4188 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 4189 else { |
5300 | 4190 /* Don't send if this turkey is in our deny list */ |
4191 GSList *list; | |
4192 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
4193 if (!list) { | |
4194 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(name)); | |
4195 if (bi && bi->typingnot) { | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4196 if (typing == GAIM_TYPING) |
5300 | 4197 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4198 else if (typing == GAIM_TYPED) |
5300 | 4199 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
4200 else | |
4201 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
4202 } | |
3595 | 4203 } |
4204 } | |
2993 | 4205 return 0; |
4206 } | |
5575 | 4207 static void oscar_ask_direct_im(GaimConnection *gc, const char *name); |
6982 | 4208 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimImFlags); |
4209 | |
4210 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimImFlags imflags) { | |
4617 | 4211 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4212 struct direct_im *dim = find_direct_im(od, name); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4213 int ret = 0; |
3659 | 4214 GError *err = NULL; |
5575 | 4215 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
4216 char *tmpmsg = NULL; |
3458 | 4217 |
4838 | 4218 if (dim && dim->connected) { |
4219 /* If we're directly connected, send a direct IM */ | |
6982 | 4220 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
4221 } else if (imflags & GAIM_IM_IMAGES) { | |
3044 | 4222 /* Trying to send an IM image outside of a direct connection. */ |
4223 oscar_ask_direct_im(gc, name); | |
4838 | 4224 ret = -ENOTCONN; |
2086 | 4225 } else { |
4738 | 4226 struct buddyinfo *bi; |
3008 | 4227 struct aim_sendimext_args args; |
4228 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4229 gsize len; |
4269 | 4230 |
4738 | 4231 bi = g_hash_table_lookup(od->buddyinfo, normalize(name)); |
4232 if (!bi) { | |
4233 bi = g_new0(struct buddyinfo, 1); | |
4234 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(name)), bi); | |
4235 } | |
4236 | |
3008 | 4237 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 4238 if (od->icq) { |
4239 args.features = features_icq; | |
4240 args.featureslen = sizeof(features_icq); | |
3008 | 4241 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 4242 } else { |
4243 args.features = features_aim; | |
4244 args.featureslen = sizeof(features_aim); | |
4972 | 4245 |
6622 | 4246 if (imflags & GAIM_IM_AUTO_RESP) |
4972 | 4247 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 4248 } |
4269 | 4249 |
4738 | 4250 if (bi->ico_need) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4251 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4252 "Sending buddy icon request with message\n"); |
3008 | 4253 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 4254 bi->ico_need = FALSE; |
3008 | 4255 } |
4269 | 4256 |
5575 | 4257 if (iconfile && !stat(iconfile, &st)) { |
4258 FILE *file = fopen(iconfile, "r"); | |
3008 | 4259 if (file) { |
4260 char *buf = g_malloc(st.st_size); | |
4261 fread(buf, 1, st.st_size, file); | |
6039 | 4262 fclose(file); |
4269 | 4263 |
3008 | 4264 args.iconlen = st.st_size; |
4617 | 4265 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 4266 args.iconstamp = st.st_mtime; |
4267 | |
4738 | 4268 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) |
4269 bi->ico_informed = FALSE; | |
4270 | |
4271 if (!bi->ico_informed) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4272 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4273 "Claiming to have a buddy icon\n"); |
4738 | 4274 args.flags |= AIM_IMFLAGS_HASICON; |
4275 bi->ico_me_len = args.iconlen; | |
4276 bi->ico_me_csum = args.iconsum; | |
4277 bi->ico_me_time = args.iconstamp; | |
4278 bi->ico_informed = TRUE; | |
4279 } | |
4280 | |
3008 | 4281 g_free(buf); |
2086 | 4282 } |
4283 } | |
4269 | 4284 |
3008 | 4285 args.destsn = name; |
4269 | 4286 |
6310 | 4287 /* For ICQ send newlines as CR/LF, for AIM send newlines as <BR> */ |
4288 if (isdigit(name[0])) | |
4289 tmpmsg = add_cr(message); | |
4290 else | |
4291 tmpmsg = strdup_withhtml(message); | |
4292 len = strlen(tmpmsg); | |
4293 | |
4294 args.flags |= oscar_encoding_check(tmpmsg); | |
3642 | 4295 if (args.flags & AIM_IMFLAGS_UNICODE) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4296 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode IM\n"); |
4662 | 4297 args.charset = 0x0002; |
4665 | 4298 args.charsubset = 0x0000; |
6310 | 4299 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3659 | 4300 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4301 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4302 "Error converting a unicode message: %s\n", err->message); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4303 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4304 "This really shouldn't happen!\n"); |
3659 | 4305 /* We really shouldn't try to send the |
4306 * IM now, but I'm not sure what to do */ | |
4800 | 4307 g_error_free(err); |
3659 | 4308 } |
3850 | 4309 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4310 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4311 "Sending ISO-8859-1 IM\n"); |
4662 | 4312 args.charset = 0x0003; |
4665 | 4313 args.charsubset = 0x0000; |
6310 | 4314 args.msg = g_convert(tmpmsg, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3659 | 4315 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4316 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4317 "conversion error: %s\n", err->message); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4318 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4319 "Someone tell Ethan his 8859-1 detection is wrong\n"); |
3642 | 4320 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
6310 | 4321 len = strlen(tmpmsg); |
4800 | 4322 g_error_free(err); |
6310 | 4323 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3659 | 4324 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4325 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4326 "Error in unicode fallback: %s\n", err->message); |
4800 | 4327 g_error_free(err); |
3659 | 4328 } |
3642 | 4329 } |
4330 } else { | |
4662 | 4331 args.charset = 0x0000; |
4332 args.charsubset = 0x0000; | |
6310 | 4333 args.msg = tmpmsg; |
3642 | 4334 } |
4335 args.msglen = len; | |
4269 | 4336 |
4617 | 4337 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 4338 } |
4838 | 4339 |
6310 | 4340 g_free(tmpmsg); |
4341 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4342 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4343 return 1; |
6310 | 4344 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4345 return ret; |
2086 | 4346 } |
4347 | |
7011 | 4348 static void oscar_get_info(GaimConnection *gc, const char *name) { |
4349 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4350 | |
4617 | 4351 if (od->icq) |
4624 | 4352 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4353 else |
7011 | 4354 aim_locate_getinfoshort(od->sess, name, 0x00000007); |
4355 } | |
4356 | |
4357 static void oscar_get_away(GaimConnection *gc, const char *who) { | |
4358 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4617 | 4359 if (od->icq) { |
7011 | 4360 GaimBuddy *budlight = gaim_find_buddy(gc->account, who); |
3212 | 4361 if (budlight) |
3595 | 4362 if ((budlight->uc & 0xffff0000) >> 16) |
4687 | 4363 aim_im_sendch2_geticqaway(od->sess, who, (budlight->uc & 0xffff0000) >> 16); |
3212 | 4364 else |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4365 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4366 "Error: The user %s has no status message, therefore not requesting.\n", who); |
3212 | 4367 else |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4368 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
7023 | 4369 "Error: Could not find %s in local buddy list, therefore unable to request status message.\n", who); |
3212 | 4370 } else |
7011 | 4371 aim_locate_getinfoshort(od->sess, who, 0x00000002); |
4372 } | |
4373 | |
4374 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, | |
3466 | 4375 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 4376 /* XXX - some of these things are wrong, but i'm lazy */ |
7011 | 4377 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4378 aim_locate_setdirinfo(od->sess, first, middle, last, | |
2086 | 4379 maiden, NULL, NULL, city, state, NULL, 0, web); |
4380 } | |
4381 | |
5575 | 4382 static void oscar_set_idle(GaimConnection *gc, int time) { |
5129 | 4383 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4617 | 4384 aim_bos_setidle(od->sess, od->conn, time); |
2086 | 4385 } |
4386 | |
5954 | 4387 static void oscar_set_info(GaimConnection *gc, const char *text) { |
5129 | 4388 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4389 fu32_t flags = 0; | |
6019 | 4390 char *text_html = NULL; |
5129 | 4391 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4392 gsize msglen = 0; |
2993 | 4393 |
4617 | 4394 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4395 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4396 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4397 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4398 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4399 "again when you are fully connected.")); |
4617 | 4400 |
4401 if (od->icq) | |
7011 | 4402 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
4151 | 4403 else { |
5129 | 4404 if (!text) { |
7011 | 4405 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, NULL, 0, caps_aim); |
5129 | 4406 return; |
4407 } | |
6019 | 4408 |
4409 text_html = strdup_withhtml(text); | |
4410 flags = oscar_encoding_check(text_html); | |
5129 | 4411 if (flags & AIM_IMFLAGS_UNICODE) { |
6019 | 4412 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 4413 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); |
5129 | 4414 g_free(msg); |
4415 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
6019 | 4416 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 4417 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); |
5129 | 4418 g_free(msg); |
4151 | 4419 } else { |
6019 | 4420 msglen = strlen(text_html); |
7011 | 4421 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); |
4151 | 4422 } |
5129 | 4423 |
4424 if (msglen > od->rights.maxsiglen) { | |
4425 gchar *errstr; | |
6308 | 4426 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " |
4427 "has been exceeded. Gaim has truncated it for you.", | |
4428 "The maximum profile length of %d bytes " | |
4429 "has been exceeded. Gaim has truncated it for you.", | |
4430 od->rights.maxsiglen), od->rights.maxsiglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4431 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); |
5129 | 4432 g_free(errstr); |
4433 } | |
4434 | |
6019 | 4435 g_free(text_html); |
4436 | |
5129 | 4437 } |
2993 | 4438 |
4439 return; | |
2086 | 4440 } |
4441 | |
5575 | 4442 static void oscar_set_away_aim(GaimConnection *gc, struct oscar_data *od, const char *text) |
2993 | 4443 { |
5129 | 4444 fu32_t flags = 0; |
6019 | 4445 gchar *text_html = NULL; |
5129 | 4446 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4447 gsize msglen = 0; |
2993 | 4448 |
4449 if (od->rights.maxawaymsglen == 0) | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4450 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4451 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4452 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4453 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4454 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4455 "fully connected.")); |
5129 | 4456 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4457 if (gc->away) { |
2993 | 4458 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4459 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4460 } |
2993 | 4461 |
5129 | 4462 if (!text) { |
7011 | 4463 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0, caps_aim); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4464 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4465 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4466 |
6037 | 4467 text_html = strdup_withhtml(text); |
6019 | 4468 flags = oscar_encoding_check(text_html); |
5129 | 4469 if (flags & AIM_IMFLAGS_UNICODE) { |
6019 | 4470 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 4471 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
5129 | 4472 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); |
4473 g_free(msg); | |
4474 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
4475 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
6019 | 4476 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 4477 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
5129 | 4478 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); |
4479 g_free(msg); | |
6019 | 4480 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 4481 } else { |
6019 | 4482 msglen = strlen(text_html); |
7011 | 4483 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
5129 | 4484 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); |
6019 | 4485 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 4486 } |
4487 | |
4488 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 4489 gchar *errstr; |
4490 | |
6308 | 4491 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
4492 "has been exceeded. Gaim has truncated it for you.", | |
4493 "The maximum away message length of %d bytes " | |
4494 "has been exceeded. Gaim has truncated it for you.", | |
4495 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4496 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 4497 g_free(errstr); |
4498 } | |
6019 | 4499 |
4500 g_free(text_html); | |
2993 | 4501 return; |
4502 } | |
4503 | |
5575 | 4504 static void oscar_set_away_icq(GaimConnection *gc, struct oscar_data *od, const char *state, const char *message) |
2993 | 4505 { |
5575 | 4506 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4507 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4508 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4509 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4510 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4511 |
4342 | 4512 if (strcmp(state, _("Invisible"))) { |
5575 | 4513 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
4514 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4515 account->perm_deny = 4; | |
4342 | 4516 } else { |
5542 | 4517 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != 0x03)) |
4889 | 4518 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); |
5575 | 4519 account->perm_deny = 3; |
4342 | 4520 } |
4521 | |
4522 if (!strcmp(state, _("Online"))) | |
4901 | 4523 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 4524 else if (!strcmp(state, _("Away"))) { |
4901 | 4525 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4526 gc->away = g_strdup(""); |
4342 | 4527 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 4528 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
|
4529 gc->away = g_strdup(""); |
4342 | 4530 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 4531 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
|
4532 gc->away = g_strdup(""); |
4342 | 4533 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 4534 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
|
4535 gc->away = g_strdup(""); |
4342 | 4536 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 4537 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4538 gc->away = g_strdup(""); |
4342 | 4539 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 4540 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4541 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4542 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 4543 if (message) { |
4901 | 4544 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
|
4545 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4546 } else { |
4901 | 4547 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4548 } |
2086 | 4549 } |
2993 | 4550 |
4551 return; | |
4552 } | |
4553 | |
6059 | 4554 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 4555 { |
4556 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4557 | |
4558 if (od->icq) | |
4559 oscar_set_away_icq(gc, od, state, message); | |
4560 else | |
4561 oscar_set_away_aim(gc, od, message); | |
4562 | |
4563 return; | |
2086 | 4564 } |
4565 | |
6059 | 4566 static void oscar_warn(GaimConnection *gc, const char *name, int anon) { |
4617 | 4567 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4568 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); | |
2086 | 4569 } |
4570 | |
5575 | 4571 static void oscar_dir_search(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 4572 const char *maiden, const char *city, const char *state, const char *country, const char *email) { |
4617 | 4573 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 4574 if (strlen(email)) |
6879 | 4575 aim_search_address(od->sess, od->conn, email); |
2086 | 4576 } |
4577 | |
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
4578 static void oscar_add_buddy(GaimConnection *gc, const char *name, GaimGroup *g) { |
4230 | 4579 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4580 #ifdef NOSSI | |
4581 aim_add_buddy(od->sess, od->conn, name); | |
4582 #else | |
4583 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_exists(od->sess->ssi.local, name))) { | |
6695 | 4584 GaimBuddy *buddy = gaim_find_buddy(gc->account, name); |
4585 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4230 | 4586 if (buddy && group) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4587 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4588 "ssi: adding buddy %s to group %s\n", name, group->name); |
4889 | 4589 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4230 | 4590 } |
4591 } | |
4592 #endif | |
4759 | 4593 if (od->icq) |
4594 aim_icq_getalias(od->sess, name); | |
4230 | 4595 } |
4596 | |
5575 | 4597 static void oscar_add_buddies(GaimConnection *gc, GList *buddies) { |
4230 | 4598 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4599 #ifdef NOSSI | |
4600 char buf[MSG_LEN]; | |
4601 int n=0; | |
4602 while (buddies) { | |
4603 if (n > MSG_LEN - 18) { | |
4604 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
4605 n = 0; | |
3092 | 4606 } |
4230 | 4607 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); |
4608 buddies = buddies->next; | |
4609 } | |
4610 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
4611 #else | |
4612 if (od->sess->ssi.received_data) { | |
4613 while (buddies) { | |
6695 | 4614 GaimBuddy *buddy = gaim_find_buddy(gc->account, (const char *)buddies->data); |
4615 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4230 | 4616 if (buddy && group) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4617 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4618 "ssi: adding buddy %s to group %s\n", (const char *)buddies->data, group->name); |
4889 | 4619 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4230 | 4620 } |
4621 buddies = buddies->next; | |
4622 } | |
4623 } | |
4624 #endif | |
4625 } | |
4626 | |
6059 | 4627 static void oscar_remove_buddy(GaimConnection *gc, const char *name, const char *group) { |
4230 | 4628 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4629 #ifdef NOSSI | |
4630 aim_remove_buddy(od->sess, od->conn, name); | |
4631 #else | |
4632 if (od->sess->ssi.received_data) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4633 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4634 "ssi: deleting buddy %s from group %s\n", name, group); |
4889 | 4635 aim_ssi_delbuddy(od->sess, name, group); |
4230 | 4636 } |
4637 #endif | |
4638 } | |
4639 | |
5575 | 4640 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) { |
4230 | 4641 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4642 #ifdef NOSSI | |
4643 GList *cur; | |
4644 for (cur=buddies; cur; cur=cur->next) | |
4645 aim_remove_buddy(od->sess, od->conn, cur->data); | |
4646 #else | |
4647 if (od->sess->ssi.received_data) { | |
3092 | 4648 while (buddies) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4649 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4650 "ssi: deleting buddy %s from group %s\n", (char *)buddies->data, group); |
4889 | 4651 aim_ssi_delbuddy(od->sess, buddies->data, group); |
3092 | 4652 buddies = buddies->next; |
4653 } | |
4230 | 4654 } |
4655 #endif | |
4656 } | |
4657 | |
4658 #ifndef NOSSI | |
5575 | 4659 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
4269 | 4660 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4303 | 4661 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4662 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4663 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 4664 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 4665 } |
4666 } | |
4667 | |
5575 | 4668 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
4269 | 4669 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4670 if (od->sess->ssi.received_data) { | |
4671 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
4672 if (gname) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4673 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4674 "ssi: changing the alias for buddy %s to %s\n", name, alias); |
4889 | 4675 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 4676 } |
4677 } | |
4678 } | |
4679 | |
5575 | 4680 static void oscar_rename_group(GaimConnection *g, const char *old_group, const char *new_group, GList *members) { |
4230 | 4681 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4682 | |
4683 if (od->sess->ssi.received_data) { | |
4684 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) { | |
4685 oscar_remove_buddies(g, members, old_group); | |
4686 oscar_add_buddies(g, members); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4687 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4688 "ssi: moved all buddies from group %s to %s\n", old_group, new_group); |
4230 | 4689 } else { |
4889 | 4690 aim_ssi_rename_group(od->sess, old_group, new_group); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4691 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4692 "ssi: renamed group %s to %s\n", old_group, new_group); |
2995 | 4693 } |
4694 } | |
4695 } | |
4696 | |
5968 | 4697 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
4698 aim_session_t *sess = data; | |
6350 | 4699 aim_ssi_reqdata(sess); |
5968 | 4700 return FALSE; |
4701 } | |
4702 | |
4642 | 4703 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4704 GaimConnection *gc = sess->aux_data; |
4642 | 4705 struct oscar_data *od = gc->proto_data; |
4706 va_list ap; | |
4707 fu16_t reason; | |
4708 | |
4709 va_start(ap, fr); | |
4710 reason = (fu16_t)va_arg(ap, unsigned int); | |
4711 va_end(ap); | |
4712 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4713 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 4714 |
4715 if (reason == 0x0005) { | |
5892 | 4716 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 4717 _("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.")); |
5968 | 4718 od->getblisttimer = g_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 4719 } |
4720 | |
4721 /* Activate SSI */ | |
4722 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4723 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
5968 | 4724 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 4725 aim_ssi_enable(od->sess); |
4726 | |
4727 return 1; | |
4728 } | |
4729 | |
2991 | 4730 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4731 GaimConnection *gc = sess->aux_data; |
4230 | 4732 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4733 int numtypes, i; | |
4734 fu16_t *maxitems; | |
2991 | 4735 va_list ap; |
4736 | |
4737 va_start(ap, fr); | |
4230 | 4738 numtypes = va_arg(ap, int); |
4739 maxitems = va_arg(ap, fu16_t *); | |
2991 | 4740 va_end(ap); |
4741 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4742 gaim_debug(GAIM_DEBUG_MISC, "oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4743 |
4230 | 4744 for (i=0; i<numtypes; i++) |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4745 gaim_debug(GAIM_DEBUG_MISC, NULL, " max type 0x%04x=%hd,", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4746 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4747 |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4748 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
4230 | 4749 |
4750 if (numtypes >= 0) | |
4751 od->rights.maxbuddies = maxitems[0]; | |
4752 if (numtypes >= 1) | |
4753 od->rights.maxgroups = maxitems[1]; | |
4754 if (numtypes >= 2) | |
4755 od->rights.maxpermits = maxitems[2]; | |
4756 if (numtypes >= 3) | |
4757 od->rights.maxdenies = maxitems[3]; | |
2991 | 4758 |
4759 return 1; | |
4760 } | |
4761 | |
4762 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4763 GaimConnection *gc = sess->aux_data; |
4764 GaimAccount *account = gaim_connection_get_account(gc); | |
4230 | 4765 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2995 | 4766 struct aim_ssi_item *curitem; |
2991 | 4767 int tmp; |
4778 | 4768 gboolean export = FALSE; |
4617 | 4769 /* XXX - use these? |
4230 | 4770 va_list ap; |
4771 | |
4772 va_start(ap, fr); | |
4773 fmtver = (fu16_t)va_arg(ap, int); | |
4774 numitems = (fu16_t)va_arg(ap, int); | |
4775 items = va_arg(ap, struct aim_ssi_item); | |
4776 timestamp = va_arg(ap, fu32_t); | |
4777 va_end(ap); */ | |
2991 | 4778 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4779 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4780 "ssi: syncing local list and server list\n"); |
2991 | 4781 |
4782 /* Clean the buddy list */ | |
4889 | 4783 aim_ssi_cleanlist(sess); |
2991 | 4784 |
4785 /* Add from server list to local list */ | |
4230 | 4786 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
2991 | 4787 switch (curitem->type) { |
4230 | 4788 case 0x0000: { /* Buddy */ |
4251 | 4789 if (curitem->name) { |
4292 | 4790 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
4458 | 4791 char *gname_utf8 = gaim_try_conv_to_utf8(gname); |
4282 | 4792 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
4458 | 4793 char *alias_utf8 = gaim_try_conv_to_utf8(alias); |
6695 | 4794 GaimBuddy *buddy = gaim_find_buddy(gc->account, curitem->name); |
4458 | 4795 /* Should gname be freed here? -- elb */ |
4754 | 4796 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 4797 free(alias); |
4282 | 4798 if (buddy) { |
4292 | 4799 /* Get server stored alias */ |
4705 | 4800 if (alias_utf8) { |
4801 g_free(buddy->alias); | |
4802 buddy->alias = g_strdup(alias_utf8); | |
4803 } | |
4282 | 4804 } else { |
6695 | 4805 GaimGroup *g; |
4687 | 4806 buddy = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 4807 |
4754 | 4808 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 4809 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 4810 gaim_blist_add_group(g, NULL); |
4811 } | |
5146 | 4812 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4813 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4814 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
6695 | 4815 gaim_blist_add_buddy(buddy, NULL, g, NULL); |
4778 | 4816 export = TRUE; |
4251 | 4817 } |
4458 | 4818 free(gname_utf8); |
4819 free(alias_utf8); | |
2991 | 4820 } |
4230 | 4821 } break; |
4822 | |
4823 case 0x0001: { /* Group */ | |
4282 | 4824 /* Shouldn't add empty groups */ |
4230 | 4825 } break; |
4826 | |
4827 case 0x0002: { /* Permit buddy */ | |
2991 | 4828 if (curitem->name) { |
4230 | 4829 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 4830 GSList *list; |
5575 | 4831 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 4832 if (!list) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4833 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4834 "ssi: adding permit buddy %s to local list\n", curitem->name); |
6400
588e88bcdac5
[gaim-migrate @ 6905]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
4835 gaim_privacy_permit_add(account, curitem->name, TRUE); |
4778 | 4836 export = TRUE; |
2991 | 4837 } |
4838 } | |
4230 | 4839 } break; |
4840 | |
4841 case 0x0003: { /* Deny buddy */ | |
2991 | 4842 if (curitem->name) { |
4843 GSList *list; | |
5575 | 4844 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 4845 if (!list) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4846 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4847 "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
|
4848 gaim_privacy_deny_add(account, curitem->name, TRUE); |
4778 | 4849 export = TRUE; |
2991 | 4850 } |
4851 } | |
4230 | 4852 } break; |
4853 | |
4854 case 0x0004: { /* Permit/deny setting */ | |
2991 | 4855 if (curitem->data) { |
4856 fu8_t permdeny; | |
5575 | 4857 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4858 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
5575 | 4859 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
4860 account->perm_deny = permdeny; | |
4861 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 4862 serv_set_away(gc, "Invisible", ""); |
4863 } | |
4778 | 4864 export = TRUE; |
2991 | 4865 } |
4866 } | |
4230 | 4867 } break; |
4868 | |
4869 case 0x0005: { /* Presence setting */ | |
3109 | 4870 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 4871 } break; |
2991 | 4872 } /* End of switch on curitem->type */ |
4873 } /* End of for loop */ | |
4230 | 4874 |
4875 /* If changes were made, then flush buddy list to file */ | |
4778 | 4876 if (export) |
4349 | 4877 gaim_blist_save(); |
2991 | 4878 |
4759 | 4879 { /* Add from local list to server list */ |
6695 | 4880 GaimBlistNode *gnode, *cnode, *bnode; |
4881 GaimGroup *group; | |
4882 GaimBuddy *buddy; | |
4759 | 4883 struct gaim_buddy_list *blist; |
3017 | 4884 GSList *cur; |
4885 | |
2991 | 4886 /* Buddies */ |
4759 | 4887 if ((blist = gaim_get_blist())) |
4888 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5234 | 4889 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
4890 continue; | |
6695 | 4891 group = (GaimGroup *)gnode; |
4892 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
4893 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5234 | 4894 continue; |
6695 | 4895 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
4896 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
4897 continue; | |
4898 buddy = (GaimBuddy *)bnode; | |
4899 if (buddy->account == gc->account) { | |
4900 gchar *servernick = gaim_buddy_get_setting(buddy, "servernick"); | |
4901 if (servernick) { | |
4902 serv_got_alias(gc, buddy->name, servernick); | |
4903 g_free(servernick); | |
4904 } | |
4905 if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) { | |
4906 /* Store local alias on server */ | |
4907 char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name); | |
4908 if (!alias && buddy->alias && strlen(buddy->alias)) | |
4909 aim_ssi_aliasbuddy(sess, group->name, buddy->name, buddy->alias); | |
4910 free(alias); | |
4911 } else { | |
4912 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
4913 "ssi: adding buddy %s from local list to server list\n", buddy->name); | |
4914 aim_ssi_addbuddy(sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); | |
4915 } | |
4759 | 4916 } |
4349 | 4917 } |
4230 | 4918 } |
4292 | 4919 } |
6695 | 4920 |
2991 | 4921 /* Permit list */ |
4491 | 4922 if (gc->account->permit) { |
4923 for (cur=gc->account->permit; cur; cur=cur->next) | |
4230 | 4924 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4925 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
6695 | 4926 "ssi: adding permit %s from local list to server list\n", (char *)cur->data); |
4889 | 4927 aim_ssi_addpermit(sess, cur->data); |
4230 | 4928 } |
2991 | 4929 } |
4930 | |
4931 /* Deny list */ | |
4491 | 4932 if (gc->account->deny) { |
4933 for (cur=gc->account->deny; cur; cur=cur->next) | |
4230 | 4934 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4935 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
6695 | 4936 "ssi: adding deny %s from local list to server list\n", (char *)cur->data); |
4889 | 4937 aim_ssi_adddeny(sess, cur->data); |
4230 | 4938 } |
2991 | 4939 } |
3109 | 4940 /* Presence settings (idle time visibility) */ |
4230 | 4941 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) |
5631 | 4942 if (!(tmp & 0x400)) |
4889 | 4943 aim_ssi_setpresence(sess, tmp | 0x400); |
4778 | 4944 } /* end adding buddies from local list to server list */ |
4945 | |
4901 | 4946 /* Set our ICQ status */ |
4947 if (od->icq && !gc->away) { | |
4948 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); | |
4949 } | |
4950 | |
4342 | 4951 /* Activate SSI */ |
4952 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4953 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4954 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4955 "ssi: activating server-stored buddy list\n"); |
4642 | 4956 aim_ssi_enable(sess); |
4342 | 4957 |
2991 | 4958 return 1; |
2086 | 4959 } |
4230 | 4960 |
4961 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4962 GaimConnection *gc = sess->aux_data; |
4230 | 4963 va_list ap; |
4964 struct aim_ssi_tmp *retval; | |
4965 | |
4966 va_start(ap, fr); | |
4967 retval = va_arg(ap, struct aim_ssi_tmp *); | |
4968 va_end(ap); | |
4969 | |
4970 while (retval) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4971 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4972 "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 | 4973 |
4974 if (retval->ack != 0xffff) | |
4975 switch (retval->ack) { | |
4976 case 0x0000: { /* added successfully */ | |
4977 } break; | |
4978 | |
4829 | 4979 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
4980 gchar *buf; | |
4981 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)"))); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4982 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 4983 g_free(buf); |
4984 } | |
4985 | |
7023 | 4986 case 0x000e: { /* buddy requires authorization */ |
4828 | 4987 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 4988 gaim_auth_sendrequest(gc, retval->name); |
4230 | 4989 } break; |
4990 | |
4991 default: { /* La la la */ | |
5197 | 4992 gchar *buf; |
5402 | 4993 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
4994 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)"))); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4995 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 4996 g_free(buf); |
5402 | 4997 /* XXX - Should remove buddy from local list */ |
4230 | 4998 } break; |
4999 } | |
5000 | |
5001 retval = retval->next; | |
5002 } | |
5003 | |
5004 return 1; | |
5005 } | |
5006 | |
5007 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5008 GaimConnection *gc = sess->aux_data; |
4230 | 5009 va_list ap; |
5010 char *sn, *msg; | |
4236 | 5011 gchar *dialog_msg, *nombre; |
4230 | 5012 struct name_data *data; |
6695 | 5013 GaimBuddy *buddy; |
4230 | 5014 |
5015 va_start(ap, fr); | |
5016 sn = va_arg(ap, char *); | |
5017 msg = va_arg(ap, char *); | |
5018 va_end(ap); | |
5019 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5020 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5021 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 5022 |
4687 | 5023 buddy = gaim_find_buddy(gc->account, sn); |
5024 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5025 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5026 else |
5027 nombre = g_strdup(sn); | |
5028 | |
5029 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 | 5030 data = g_new(struct name_data, 1); |
5031 data->gc = gc; | |
5032 data->name = g_strdup(sn); | |
5033 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5034 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5035 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5036 0, data, |
7023 | 5037 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 5038 G_CALLBACK(oscar_free_name_data)); |
4236 | 5039 |
4230 | 5040 g_free(dialog_msg); |
4236 | 5041 g_free(nombre); |
4230 | 5042 |
5043 return 1; | |
5044 } | |
5045 | |
5046 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5047 GaimConnection *gc = sess->aux_data; |
4230 | 5048 va_list ap; |
5049 char *sn, *msg; | |
4236 | 5050 gchar *dialog_msg, *nombre; |
4230 | 5051 struct name_data *data; |
6695 | 5052 GaimBuddy *buddy; |
4230 | 5053 |
5054 va_start(ap, fr); | |
5055 sn = va_arg(ap, char *); | |
5056 msg = va_arg(ap, char *); | |
5057 va_end(ap); | |
5058 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5059 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5060 "ssi: received authorization request from %s\n", sn); |
4230 | 5061 |
4687 | 5062 buddy = gaim_find_buddy(gc->account, sn); |
5063 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5064 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5065 else |
5066 nombre = g_strdup(sn); | |
5067 | |
4337 | 5068 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 | 5069 data = g_new(struct name_data, 1); |
5070 data->gc = gc; | |
5071 data->name = g_strdup(sn); | |
5072 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5073 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5074 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5075 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5076 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5077 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 5078 |
4230 | 5079 g_free(dialog_msg); |
4236 | 5080 g_free(nombre); |
4230 | 5081 |
5082 return 1; | |
5083 } | |
5084 | |
5085 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5086 GaimConnection *gc = sess->aux_data; |
4230 | 5087 va_list ap; |
5088 char *sn, *msg; | |
4236 | 5089 gchar *dialog_msg, *nombre; |
4230 | 5090 fu8_t reply; |
6695 | 5091 GaimBuddy *buddy; |
4230 | 5092 |
5093 va_start(ap, fr); | |
5094 sn = va_arg(ap, char *); | |
5095 reply = (fu8_t)va_arg(ap, int); | |
5096 msg = va_arg(ap, char *); | |
5097 va_end(ap); | |
5098 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5099 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5100 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 5101 |
4687 | 5102 buddy = gaim_find_buddy(gc->account, sn); |
5103 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5104 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5105 else |
5106 nombre = g_strdup(sn); | |
5107 | |
4230 | 5108 if (reply) { |
5109 /* Granted */ | |
7023 | 5110 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
|
5111 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 5112 } else { |
5113 /* Denied */ | |
7023 | 5114 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
|
5115 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 5116 } |
5117 g_free(dialog_msg); | |
4236 | 5118 g_free(nombre); |
4230 | 5119 |
5120 return 1; | |
5121 } | |
5122 | |
5123 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5124 GaimConnection *gc = sess->aux_data; |
4230 | 5125 va_list ap; |
5126 char *sn; | |
6695 | 5127 GaimBuddy *buddy; |
4230 | 5128 |
5129 va_start(ap, fr); | |
5130 sn = va_arg(ap, char *); | |
5131 va_end(ap); | |
5132 | |
4687 | 5133 buddy = gaim_find_buddy(gc->account, sn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5134 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5135 "ssi: %s added you to their buddy list\n", sn); |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
7011
diff
changeset
|
5136 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 5137 |
5138 return 1; | |
5139 } | |
4269 | 5140 #endif |
2086 | 5141 |
5575 | 5142 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5143 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5144 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5145 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5146 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5147 pce->label = _("Join what group:"); |
5234 | 5148 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5149 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5150 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5151 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5152 pce->label = _("Exchange:"); |
5234 | 5153 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5154 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5155 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5156 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5157 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5158 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5159 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5160 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5161 |
5575 | 5162 static void oscar_join_chat(GaimConnection *g, GHashTable *data) { |
4617 | 5163 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5164 aim_conn_t *cur; |
5234 | 5165 char *name, *exchange; |
5166 | |
5167 name = g_hash_table_lookup(data, "room"); | |
5168 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5169 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5170 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5171 "Attempting to join chat room %s.\n", name); |
4617 | 5172 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5173 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5174 "chatnav exists, creating room\n"); |
5234 | 5175 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 5176 } else { |
5177 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5178 struct create_room *cr = g_new0(struct create_room, 1); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5179 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5180 "chatnav does not exist, opening chatnav\n"); |
5234 | 5181 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5182 cr->name = g_strdup(name); |
4617 | 5183 od->create_rooms = g_slist_append(od->create_rooms, cr); |
5184 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 5185 } |
5186 } | |
5187 | |
5575 | 5188 static void oscar_chat_invite(GaimConnection *g, int id, const char *message, const char *name) { |
4617 | 5189 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2086 | 5190 struct chat_connection *ccon = find_oscar_chat(g, id); |
5191 | |
5192 if (!ccon) | |
5193 return; | |
5194 | |
4617 | 5195 aim_chat_invite(od->sess, od->conn, name, message ? message : "", |
2086 | 5196 ccon->exchange, ccon->name, 0x0); |
5197 } | |
5198 | |
5575 | 5199 static void oscar_chat_leave(GaimConnection *g, int id) { |
4617 | 5200 struct oscar_data *od = g ? (struct oscar_data *)g->proto_data : NULL; |
2086 | 5201 GSList *bcs = g->buddy_chats; |
5679 | 5202 GaimConversation *b = NULL; |
2086 | 5203 struct chat_connection *c = NULL; |
5204 int count = 0; | |
5205 | |
5206 while (bcs) { | |
5207 count++; | |
5679 | 5208 b = (GaimConversation *)bcs->data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5209 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 5210 break; |
5211 bcs = bcs->next; | |
5212 b = NULL; | |
5213 } | |
5214 | |
5215 if (!b) | |
5216 return; | |
5217 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5218 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5219 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 5220 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5221 c = find_oscar_chat(g, gaim_chat_get_id(GAIM_CHAT(b))); |
2086 | 5222 if (c != NULL) { |
4617 | 5223 if (od) |
5224 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 5225 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5226 gaim_input_remove(c->inpa); |
4617 | 5227 if (g && od->sess) |
5228 aim_conn_kill(od->sess, &c->conn); | |
2086 | 5229 g_free(c->name); |
5230 g_free(c->show); | |
5231 g_free(c); | |
5232 } | |
5233 /* we do this because with Oscar it doesn't tell us we left */ | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5234 serv_got_chat_left(g, gaim_chat_get_id(GAIM_CHAT(b))); |
2086 | 5235 } |
5236 | |
6059 | 5237 static int oscar_chat_send(GaimConnection *g, int id, const char *message) { |
4617 | 5238 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2086 | 5239 GSList *bcs = g->buddy_chats; |
5679 | 5240 GaimConversation *b = NULL; |
2086 | 5241 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5242 char *buf, *buf2; |
2086 | 5243 int i, j; |
5244 | |
5245 while (bcs) { | |
5679 | 5246 b = (GaimConversation *)bcs->data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5247 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 5248 break; |
5249 bcs = bcs->next; | |
5250 b = NULL; | |
5251 } | |
5252 if (!b) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5253 return -EINVAL; |
2086 | 5254 |
4617 | 5255 bcs = od->oscar_chats; |
2086 | 5256 while (bcs) { |
5257 c = (struct chat_connection *)bcs->data; | |
5258 if (b == c->cnv) | |
5259 break; | |
5260 bcs = bcs->next; | |
5261 c = NULL; | |
5262 } | |
5263 if (!c) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5264 return -EINVAL; |
2086 | 5265 |
5266 buf = g_malloc(strlen(message) * 4 + 1); | |
5267 for (i = 0, j = 0; i < strlen(message); i++) { | |
5268 if (message[i] == '\n') { | |
5269 buf[j++] = '<'; | |
5270 buf[j++] = 'B'; | |
5271 buf[j++] = 'R'; | |
5272 buf[j++] = '>'; | |
5273 } else { | |
5274 buf[j++] = message[i]; | |
5275 } | |
5276 } | |
5277 buf[j] = '\0'; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5278 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5279 if (strlen(buf) > c->maxlen) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5280 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5281 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5282 buf2 = strip_html(buf); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5283 if (strlen(buf2) > c->maxvis) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5284 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5285 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5286 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5287 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5288 |
4617 | 5289 aim_chat_send_im(od->sess, c->conn, 0, buf, strlen(buf)); |
2086 | 5290 g_free(buf); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5291 return 0; |
2086 | 5292 } |
5293 | |
6695 | 5294 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 5295 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5296 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 5297 return "icq"; |
5298 else | |
5299 return "aim"; | |
5300 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5301 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5302 if (b != NULL && isdigit(b->name[0])) |
4687 | 5303 return "icq"; |
5304 return "aim"; | |
5305 } | |
5306 | |
6695 | 5307 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 5308 { |
5309 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
5310 int i = 0; | |
5311 | |
5131 | 5312 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
5575 | 5313 GaimAccount *account; |
5314 GaimConnection *gc; | |
5131 | 5315 struct oscar_data *od; |
5316 char *gname; | |
5317 if ((b->name) && (account = b->account) && (gc = account->gc) && | |
5318 (od = gc->proto_data) && (od->sess->ssi.received_data) && | |
5319 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && | |
5320 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
5321 emblems[i++] = "notauthorized"; | |
5322 } else { | |
5323 emblems[i++] = "offline"; | |
5324 } | |
5325 } | |
4916 | 5326 |
4766 | 5327 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 5328 int uc = b->uc >> 16; |
4766 | 5329 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 5330 emblems[i++] = "invisible"; |
4766 | 5331 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 5332 emblems[i++] = "freeforchat"; |
4766 | 5333 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 5334 emblems[i++] = "dnd"; |
4766 | 5335 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 5336 emblems[i++] = "na"; |
4766 | 5337 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 5338 emblems[i++] = "occupied"; |
4766 | 5339 else if (uc & AIM_ICQ_STATE_AWAY) |
5340 emblems[i++] = "away"; | |
5341 } else { | |
5342 if (b->uc & UC_UNAVAILABLE) | |
5343 emblems[i++] = "away"; | |
5344 } | |
4687 | 5345 if (b->uc & UC_WIRELESS) |
5346 emblems[i++] = "wireless"; | |
5347 if (b->uc & UC_AOL) | |
5348 emblems[i++] = "aol"; | |
5349 if (b->uc & UC_ADMIN) | |
5350 emblems[i++] = "admin"; | |
5351 if (b->uc & UC_AB && i < 4) | |
5352 emblems[i++] = "activebuddy"; | |
6318 | 5353 if (b->uc & UC_HIPTOP && i < 4) |
5354 emblems[i++] = "hiptop"; | |
4766 | 5355 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
5356 emblems[i++] = "unconfirmed"; */ | |
4687 | 5357 *se = emblems[0]; |
5358 *sw = emblems[1]; | |
5359 *nw = emblems[2]; | |
5360 *ne = emblems[3]; | |
5361 } | |
5362 | |
6695 | 5363 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 5364 GaimConnection *gc = b->account->gc; |
5131 | 5365 struct oscar_data *od = gc->proto_data; |
5366 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name)); | |
7045 | 5367 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
7011 | 5368 gchar *tmp = NULL, *ret = g_strdup(""); |
5131 | 5369 |
5370 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
5371 if (isdigit(b->name[0])) { | |
7011 | 5372 char *status; |
5131 | 5373 status = gaim_icq_status((b->uc & 0xffff0000) >> 16); |
7011 | 5374 tmp = ret; |
5375 ret = g_strconcat(tmp, _("<b>Status:</b> "), status, "\n", NULL); | |
5131 | 5376 g_free(tmp); |
5377 g_free(status); | |
5378 } | |
5379 | |
7011 | 5380 if (userinfo != NULL) { |
5381 char *tstr = sec_to_text(time(NULL) - userinfo->onlinesince + | |
5131 | 5382 (gc->login_time_official ? gc->login_time_official - gc->login_time : 0)); |
7011 | 5383 tmp = ret; |
5384 ret = g_strconcat(tmp, _("<b>Logged In:</b> "), tstr, "\n", NULL); | |
5385 free(tmp); | |
5386 free(tstr); | |
5387 } | |
5388 | |
5389 if ((bi != NULL) && (bi->ipaddr)) { | |
5390 char *tstr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", | |
5391 (bi->ipaddr & 0xff000000) >> 24, | |
5392 (bi->ipaddr & 0x00ff0000) >> 16, | |
5393 (bi->ipaddr & 0x0000ff00) >> 8, | |
5394 (bi->ipaddr & 0x000000ff)); | |
5395 tmp = ret; | |
5396 ret = g_strconcat(tmp, _("<b>IP Address:</b> "), tstr, "\n", NULL); | |
5131 | 5397 free(tmp); |
5398 free(tstr); | |
7011 | 5399 } |
5400 | |
5401 if ((userinfo != NULL) && (userinfo->capabilities)) { | |
5402 char *caps = caps_string(userinfo->capabilities); | |
5403 tmp = ret; | |
5404 ret = g_strconcat(tmp, _("<b>Capabilities:</b> "), caps, "\n", NULL); | |
5405 free(tmp); | |
5406 } | |
5407 | |
5408 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
5409 gchar *escaped = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5410 tmp = ret; | |
5411 ret = g_strconcat(tmp, _("<b>Available:</b> "), escaped, "\n", NULL); | |
5412 free(tmp); | |
5413 g_free(escaped); | |
5414 } | |
5415 | |
5416 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
5417 gchar *away_utf8 = oscar_encoding_to_utf8(userinfo->away_encoding, userinfo->away, userinfo->away_len); | |
5418 if (away_utf8 != NULL) { | |
5419 gchar *withcr, *nohtml; | |
5420 withcr = gaim_strreplace(away_utf8, "<BR>", "\n"); | |
5421 nohtml = strip_html(withcr); | |
5422 g_free(withcr); | |
5423 tmp = ret; | |
5424 ret = g_strconcat(tmp, _("<b>Away Message:</b> "), nohtml, "\n", NULL); | |
6857 | 5425 free(tmp); |
7011 | 5426 g_free(nohtml); |
5427 g_free(away_utf8); | |
5836 | 5428 } |
5131 | 5429 } |
5430 } else { | |
5431 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | |
5432 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) { | |
7011 | 5433 tmp = ret; |
5434 ret = g_strconcat(tmp, _("<b>Status:</b> Not Authorized"), "\n", NULL); | |
5131 | 5435 g_free(tmp); |
5436 } else { | |
7011 | 5437 tmp = ret; |
5438 ret = g_strconcat(tmp, _("<b>Status:</b> Offline"), "\n", NULL); | |
5131 | 5439 g_free(tmp); |
5440 } | |
5441 } | |
5442 | |
5443 /* remove the trailing newline character */ | |
7011 | 5444 if (ret) |
5445 ret[strlen(ret)-1] = '\0'; | |
5446 return ret; | |
5131 | 5447 } |
5448 | |
6695 | 5449 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 5450 GaimConnection *gc = b->account->gc; |
5167 | 5451 struct oscar_data *od = gc->proto_data; |
5452 gchar *ret = NULL; | |
5453 | |
5454 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
5455 if (isdigit(b->name[0])) | |
5456 ret = gaim_icq_status((b->uc & 0xffff0000) >> 16); | |
7038 | 5457 else |
5458 ret = g_strdup(_("Away")); | |
5836 | 5459 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
5460 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name)); | |
6292 | 5461 if (bi->availmsg) |
5462 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 5463 } else { |
5167 | 5464 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
5465 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
5466 ret = g_strdup(_("Not Authorized")); | |
5467 else | |
5468 ret = g_strdup(_("Offline")); | |
5469 } | |
5470 | |
5471 return ret; | |
5472 } | |
5473 | |
5842 | 5474 |
5844 | 5475 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 5476 GaimConnection *gc = sess->aux_data; |
5477 struct oscar_data *od = gc->proto_data; | |
5892 | 5478 va_list ap; |
5842 | 5479 fu16_t type; |
5892 | 5480 fu8_t flags = 0, length = 0; |
5481 char *md5 = NULL; | |
5482 | |
5842 | 5483 va_start(ap, fr); |
5484 type = va_arg(ap, int); | |
5892 | 5485 |
5486 switch(type) { | |
5487 case 0x0000: | |
5488 case 0x0001: { | |
5489 flags = va_arg(ap, int); | |
5490 length = va_arg(ap, int); | |
5491 md5 = va_arg(ap, char *); | |
5492 | |
5493 if (flags == 0x41) { | |
5494 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
5495 od->iconconnecting = TRUE; | |
5496 od->set_icon = TRUE; | |
5497 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
5498 } else { | |
6039 | 5499 struct stat st; |
5500 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
5501 if (iconfile == NULL) { | |
5502 /* Set an empty icon, or something */ | |
5503 } else if (!stat(iconfile, &st)) { | |
5504 char *buf = g_malloc(st.st_size); | |
5505 FILE *file = fopen(iconfile, "rb"); | |
5506 if (file) { | |
5507 fread(buf, 1, st.st_size, file); | |
5508 fclose(file); | |
5509 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
5510 "Uploading icon to icon server\n"); | |
6879 | 5511 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 5512 } else |
5513 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
6039 | 5514 "Can't open buddy icon file!\n"); |
5515 g_free(buf); | |
5516 } else { | |
5517 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
5518 "Can't stat buddy icon file!\n"); | |
5892 | 5519 } |
5520 } | |
5893 | 5521 } else if (flags == 0x81) |
5522 aim_ssi_seticon(od->sess, md5, length); | |
5892 | 5523 } break; |
5524 | |
5525 case 0x0002: { /* We just set an "available" message? */ | |
5526 } break; | |
5527 } | |
5528 | |
5842 | 5529 va_end(ap); |
5844 | 5530 |
5531 return 0; | |
5842 | 5532 } |
5892 | 5533 |
3952 | 5534 /* |
4617 | 5535 * We have just established a socket with the other dude, so set up some handlers. |
3952 | 5536 */ |
4617 | 5537 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5538 GaimConnection *gc = sess->aux_data; |
2086 | 5539 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5679 | 5540 GaimConversation *cnv; |
2086 | 5541 struct direct_im *dim; |
5542 char buf[256]; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5543 char *sn; |
4617 | 5544 va_list ap; |
5545 aim_conn_t *newconn, *listenerconn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5546 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5547 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5548 newconn = va_arg(ap, aim_conn_t *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5549 listenerconn = va_arg(ap, aim_conn_t *); |
2086 | 5550 va_end(ap); |
5551 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5552 aim_conn_close(listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5553 aim_conn_kill(sess, &listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5554 |
4617 | 5555 sn = g_strdup(aim_odc_getsn(newconn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5556 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5557 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5558 "DirectIM: initiate success to %s\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5559 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5560 |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
5561 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5562 gaim_input_remove(dim->watcher); |
2086 | 5563 dim->conn = newconn; |
4617 | 5564 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
3008 | 5565 dim->connected = TRUE; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5566 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5567 g_free(sn); |
6982 | 5568 gaim_conversation_write(cnv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
2086 | 5569 |
4617 | 5570 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
5571 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
6982 | 5572 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); |
4617 | 5573 |
2993 | 5574 return 1; |
5575 } | |
5576 | |
6982 | 5577 /* |
5578 * This is called when each chunk of an image is received. It can be used to | |
5579 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
5580 * nasty, you sicko. | |
5581 */ | |
5582 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
2993 | 5583 va_list ap; |
5584 char *sn; | |
5585 double percent; | |
5575 | 5586 GaimConnection *gc = sess->aux_data; |
2993 | 5587 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5679 | 5588 GaimConversation *c; |
2993 | 5589 struct direct_im *dim; |
5590 | |
5591 va_start(ap, fr); | |
5592 sn = va_arg(ap, char *); | |
5593 percent = va_arg(ap, double); | |
5594 va_end(ap); | |
6873 | 5595 |
2994 | 5596 if (!(dim = find_direct_im(od, sn))) |
5597 return 1; | |
3059 | 5598 if (dim->watcher) { |
5599 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
5600 dim->watcher = 0; | |
5601 } | |
6982 | 5602 /* XXX is this really necessary? */ |
7082
25a616f16b6c
[gaim-migrate @ 7647]
Christian Hammond <chipx86@chipx86.com>
parents:
7080
diff
changeset
|
5603 gaim_core_mainloop_finish_events(); |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
5604 |
6982 | 5605 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); |
6873 | 5606 if (c != NULL) |
5607 gaim_conversation_update_progress(c, percent); | |
2993 | 5608 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
5609 oscar_callback, dim->conn); | |
2086 | 5610 |
5611 return 1; | |
5612 } | |
5613 | |
6982 | 5614 /* |
5615 * This is called after a direct IM has been received in its entirety. This | |
5616 * function is passed a long chunk of data which contains the IM with any | |
5617 * data chunks (images) appended to it. | |
5618 * | |
5619 * This function rips out all the data chunks and creates an imgstore for | |
5620 * each one. In order to do this, it first goes through the IM and takes | |
5621 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
5622 * with one compatable with the imgstore Gaim core code. For each one, we | |
5623 * then read in chunks of data from the end of the message and actually | |
5624 * create the img store using the given data. | |
5625 * | |
5626 * For somewhat easy reference, here's a sample message | |
5627 * (without the whitespace and asterisks): | |
5628 * | |
5629 * <HTML><BODY BGCOLOR="#ffffff"> | |
5630 * <FONT LANG="0"> | |
5631 * This is a really stupid picture:<BR> | |
5632 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
5633 * Yeah it is<BR> | |
5634 * Here is another one:<BR> | |
5635 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
5636 * </FONT> | |
5637 * </BODY></HTML> | |
5638 * <BINARY> | |
5639 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
5640 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
5641 * </BINARY> | |
5642 */ | |
4617 | 5643 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5644 GaimConnection *gc = sess->aux_data; |
6622 | 5645 GaimImFlags imflags = 0; |
6982 | 5646 GString *newmsg = g_string_new(""); |
5647 GSList *images = NULL; | |
2086 | 5648 va_list ap; |
6982 | 5649 const char *sn, *msg, *msgend, *binary; |
5650 size_t len; | |
5651 int encoding, isawaymsg; | |
2086 | 5652 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5653 va_start(ap, fr); |
6982 | 5654 sn = va_arg(ap, const char *); |
5655 msg = va_arg(ap, const char *); | |
5656 len = va_arg(ap, size_t); | |
3952 | 5657 encoding = va_arg(ap, int); |
4870 | 5658 isawaymsg = va_arg(ap, int); |
2086 | 5659 va_end(ap); |
6982 | 5660 msgend = msg + len; |
2086 | 5661 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5662 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5663 "Got DirectIM message from %s\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5664 |
4870 | 5665 if (isawaymsg) |
6622 | 5666 imflags |= GAIM_IM_AUTO_RESP; |
4870 | 5667 |
6982 | 5668 /* message has a binary trailer */ |
5669 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
5670 GData *attribs; | |
5671 const char *tmp, *start, *end, *last = NULL; | |
5672 | |
5673 tmp = msg; | |
5674 | |
5675 /* for each valid image tag... */ | |
5676 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
5677 const char *id, *src, *datasize; | |
5678 const char *tag = NULL, *data = NULL; | |
5679 size_t size; | |
5680 int imgid = 0; | |
5681 | |
5682 /* update the location of the last img tag */ | |
5683 last = end; | |
5684 | |
5685 /* grab attributes */ | |
5686 id = g_datalist_get_data(&attribs, "id"); | |
5687 src = g_datalist_get_data(&attribs, "src"); | |
5688 datasize = g_datalist_get_data(&attribs, "datasize"); | |
5689 | |
5690 /* if we have id & datasize, build the data tag */ | |
5691 if (id && datasize) | |
5692 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
5693 | |
5694 /* if we have a tag, find the start of the data */ | |
5695 if (tag && (data = gaim_strcasestr(binary, tag))) | |
5696 data += strlen(tag); | |
5697 | |
5698 /* check the data is here and store it */ | |
5699 if (data + (size = atoi(datasize)) <= msgend) | |
5700 imgid = gaim_imgstore_add(data, size, src); | |
5701 | |
5702 /* if we have a stored image... */ | |
5703 if (imgid) { | |
5704 /* append the message up to the tag */ | |
5705 newmsg = g_string_append_len(newmsg, tmp, start - tmp); | |
5706 | |
5707 /* write the new image tag */ | |
5708 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
5709 | |
5710 /* and record the image number */ | |
5711 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
5712 } else { | |
5713 /* otherwise, copy up to the end of the tag */ | |
5714 newmsg = g_string_append_len(newmsg, tmp, (end + 1) - tmp); | |
5715 } | |
5716 | |
5717 /* clear the attribute list */ | |
5718 g_datalist_clear(&attribs); | |
5719 | |
5720 /* continue from the end of the tag */ | |
5721 tmp = end + 1; | |
5722 } | |
5723 | |
5724 /* append any remaining message data (without the > :-) */ | |
5725 if (last++ && (last < binary)) | |
5726 newmsg = g_string_append_len(newmsg, last, binary - last); | |
5727 | |
5728 /* set the flag if we caught any images */ | |
5729 if (images) | |
5730 imflags |= GAIM_IM_IMAGES; | |
5731 } else { | |
5732 g_string_append_len(newmsg, msg, len); | |
5733 } | |
5734 | |
4617 | 5735 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ |
6982 | 5736 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); |
5737 | |
5738 /* free up the message */ | |
5739 g_string_free(newmsg, TRUE); | |
5740 | |
5741 /* unref any images we allocated */ | |
5742 if (images) { | |
5743 GSList *tmp; | |
5744 int id; | |
5745 | |
5746 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
5747 id = GPOINTER_TO_INT(tmp->data); | |
5748 gaim_imgstore_unref(id); | |
5749 } | |
5750 | |
5751 g_slist_free(images); | |
5752 } | |
2086 | 5753 |
5754 return 1; | |
5755 } | |
5756 | |
4617 | 5757 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5758 va_list ap; |
5759 char *sn; | |
2993 | 5760 int typing; |
5575 | 5761 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5762 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5763 va_start(ap, fr); |
2086 | 5764 sn = va_arg(ap, char *); |
2993 | 5765 typing = va_arg(ap, int); |
2086 | 5766 va_end(ap); |
5767 | |
4870 | 5768 if (typing == 0x0002) { |
2993 | 5769 /* I had to leave this. It's just too funny. It reminds me of my sister. */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5770 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5771 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5772 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
4870 | 5773 } else if (typing == 0x0001) |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5774 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
4870 | 5775 else |
4342 | 5776 serv_got_typing_stopped(gc, sn); |
2086 | 5777 return 1; |
5778 } | |
5779 | |
6982 | 5780 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimImFlags imflags) { |
5781 char *buf; | |
5782 size_t len; | |
5783 int ret; | |
5784 | |
5785 if (imflags & GAIM_IM_IMAGES) { | |
5786 GString *msg = g_string_new(""); | |
5787 GString *data = g_string_new("<BINARY>"); | |
5788 GData *attribs; | |
5789 const char *tmp, *start, *end, *last = NULL; | |
5790 int oscar_id = 0; | |
5791 | |
5792 tmp = message; | |
5793 | |
5794 /* for each valid IMG tag... */ | |
5795 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
5796 GaimStoredImage *image = NULL; | |
5797 const char *id; | |
5798 | |
5799 last = end; | |
5800 id = g_datalist_get_data(&attribs, "id"); | |
5801 | |
5802 /* ... if it refers to a valid gaim image ... */ | |
5803 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
5804 /* ... append the message from start to the tag ... */ | |
5805 msg = g_string_append_len(msg, tmp, start - tmp); | |
5806 oscar_id++; | |
5807 | |
5808 /* ... insert a new img tag with the oscar id ... */ | |
5809 if (image->filename) | |
5810 g_string_append_printf(msg, | |
5811 "<IMG SRC=\"file://%s\" ID=\"%d\" DATASIZE=\"%d\">", | |
5812 image->filename, oscar_id, image->size); | |
5813 else | |
5814 g_string_append_printf(msg, | |
5815 "<IMG ID=\"%d\" DATASIZE=\"%d\">", | |
5816 oscar_id, image->size); | |
5817 | |
5818 /* ... and append the data to the binary section ... */ | |
5819 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%d\">", | |
5820 oscar_id, image->size); | |
5821 data = g_string_append_len(data, image->data, image->size); | |
5822 data = g_string_append(data, "</DATA>"); | |
5823 } else { | |
5824 /* ... otherwise, allow the possibly invalid img tag through. */ | |
5825 /* should we do something else? */ | |
5826 msg = g_string_append_len(msg, tmp, (end + 1) - tmp); | |
5827 } | |
5828 | |
5829 g_datalist_clear(&attribs); | |
5830 | |
5831 /* continue from the end of the tag */ | |
5832 tmp = end + 1; | |
5833 } | |
5834 | |
5835 /* append any remaining message data (without the > :-) */ | |
5836 if (last++ && *last) | |
5837 msg = g_string_append(msg, last); | |
5838 | |
5839 /* if we inserted any images in the binary section, append it */ | |
5840 if (oscar_id) { | |
5841 msg = g_string_append_len(msg, data->str, data->len); | |
5842 msg = g_string_append(msg, "</BINARY>"); | |
5843 } | |
5844 | |
5845 len = msg->len; | |
5846 buf = msg->str; | |
5847 g_string_free(msg, FALSE); | |
5848 g_string_free(data, TRUE); | |
5849 } else { | |
5850 len = strlen(message); | |
5851 buf = g_memdup(message, len+1); | |
5852 } | |
5853 | |
5854 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
5855 if (imflags & GAIM_IM_AUTO_RESP) | |
5856 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
5857 else | |
5858 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
5859 | |
5860 g_free(buf); | |
5861 | |
5862 return ret; | |
5863 } | |
5864 | |
2086 | 5865 struct ask_do_dir_im { |
5866 char *who; | |
5575 | 5867 GaimConnection *gc; |
2086 | 5868 }; |
5869 | |
3730 | 5870 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
5136 | 5871 g_free(data->who); |
2086 | 5872 g_free(data); |
5873 } | |
5874 | |
3730 | 5875 static void oscar_direct_im(struct ask_do_dir_im *data) { |
5575 | 5876 GaimConnection *gc = data->gc; |
4244 | 5877 struct oscar_data *od; |
2086 | 5878 struct direct_im *dim; |
5879 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
5880 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5136 | 5881 g_free(data->who); |
4244 | 5882 g_free(data); |
5883 return; | |
5884 } | |
5885 | |
5886 od = (struct oscar_data *)gc->proto_data; | |
5887 | |
2086 | 5888 dim = find_direct_im(od, data->who); |
5889 if (dim) { | |
3008 | 5890 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
5891 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
5892 gaim_input_remove(dim->watcher); | |
5893 g_free(dim); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5894 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5895 "Gave up on old direct IM, trying again\n"); |
3008 | 5896 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5897 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); |
5136 | 5898 g_free(data->who); |
4244 | 5899 g_free(data); |
3008 | 5900 return; |
5901 } | |
2086 | 5902 } |
5903 dim = g_new0(struct direct_im, 1); | |
5904 dim->gc = gc; | |
5905 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
5906 | |
4617 | 5907 dim->conn = aim_odc_initiate(od->sess, data->who); |
2086 | 5908 if (dim->conn != NULL) { |
5909 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5910 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 5911 oscar_callback, dim->conn); |
4617 | 5912 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
5913 gaim_odc_initiate, 0); | |
2086 | 5914 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5915 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); |
2086 | 5916 g_free(dim); |
5917 } | |
4244 | 5918 |
5136 | 5919 g_free(data->who); |
4244 | 5920 g_free(data); |
2086 | 5921 } |
5922 | |
5575 | 5923 static void oscar_ask_direct_im(GaimConnection *gc, const char *who) { |
5420 | 5924 gchar *buf; |
2086 | 5925 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); |
5136 | 5926 data->who = g_strdup(who); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
5927 data->gc = gc; |
5420 | 5928 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), who); |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5929 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5930 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5931 _("Because this reveals your IP address, it " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5932 "may be considered a privacy risk. Do you " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5933 "wish to continue?"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5934 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5935 _("Connect"), G_CALLBACK(oscar_direct_im), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5936 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); |
5420 | 5937 g_free(buf); |
2086 | 5938 } |
5939 | |
5575 | 5940 static void oscar_set_permit_deny(GaimConnection *gc) { |
5941 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 5942 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5943 #ifdef NOSSI |
4770 | 5944 GSList *list, *g = gaim_blist_groups(), *g1; |
4230 | 5945 char buf[MAXMSGLEN]; |
5946 int at; | |
5947 | |
5575 | 5948 switch(account->perm_deny) { |
4687 | 5949 case 1: |
5575 | 5950 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 5951 break; |
5952 case 2: | |
5575 | 5953 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 5954 break; |
5955 case 3: | |
5575 | 5956 list = account->permit; |
4230 | 5957 at = 0; |
5958 while (list) { | |
5959 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
5960 list = list->next; | |
5961 } | |
5962 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
5963 break; | |
5964 case 4: | |
5575 | 5965 list = account->deny; |
4230 | 5966 at = 0; |
5967 while (list) { | |
5968 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
5969 list = list->next; | |
5970 } | |
5971 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
5972 break; | |
5973 case 5: | |
4770 | 5974 g1 = g; |
4230 | 5975 at = 0; |
4770 | 5976 while (g1) { |
5977 list = gaim_blist_members((struct group *)g->data); | |
5978 GSList list1 = list; | |
5979 while (list1) { | |
5980 struct buddy *b = list1->data; | |
5575 | 5981 if(b->account == account) |
4349 | 5982 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", b->name); |
4770 | 5983 list1 = list1->next; |
2995 | 5984 } |
4770 | 5985 g_slist_free(list); |
5986 g1 = g1->next; | |
4349 | 5987 } |
4770 | 5988 g_slist_free(g); |
4230 | 5989 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); |
5990 break; | |
5991 default: | |
5992 break; | |
2086 | 5993 } |
4230 | 5994 signoff_blocked(gc); |
5995 #else | |
5996 if (od->sess->ssi.received_data) | |
5575 | 5997 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); |
4230 | 5998 #endif |
2086 | 5999 } |
6000 | |
5575 | 6001 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6002 #ifdef NOSSI |
4491 | 6003 if (gc->account->permdeny == 3) |
4269 | 6004 oscar_set_permit_deny(gc); |
6005 #else | |
2991 | 6006 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6007 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to add a permit\n"); |
4230 | 6008 if (od->sess->ssi.received_data) |
4889 | 6009 aim_ssi_addpermit(od->sess, who); |
4230 | 6010 #endif |
2086 | 6011 } |
6012 | |
5575 | 6013 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6014 #ifdef NOSSI |
4491 | 6015 if (gc->account->permdeny == 4) |
4269 | 6016 oscar_set_permit_deny(gc); |
6017 #else | |
2991 | 6018 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6019 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to add a deny\n"); |
4230 | 6020 if (od->sess->ssi.received_data) |
4889 | 6021 aim_ssi_adddeny(od->sess, who); |
4230 | 6022 #endif |
2086 | 6023 } |
6024 | |
5575 | 6025 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6026 #ifdef NOSSI |
4491 | 6027 if (gc->account->permdeny == 3) |
4269 | 6028 oscar_set_permit_deny(gc); |
6029 #else | |
2991 | 6030 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6031 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to delete a permit\n"); |
4230 | 6032 if (od->sess->ssi.received_data) |
4889 | 6033 aim_ssi_delpermit(od->sess, who); |
4230 | 6034 #endif |
2086 | 6035 } |
6036 | |
5575 | 6037 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6038 #ifdef NOSSI |
4491 | 6039 if (gc->account->permdeny == 4) |
4269 | 6040 oscar_set_permit_deny(gc); |
6041 #else | |
2991 | 6042 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6043 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to delete a deny\n"); |
4230 | 6044 if (od->sess->ssi.received_data) |
4889 | 6045 aim_ssi_deldeny(od->sess, who); |
4230 | 6046 #endif |
2086 | 6047 } |
6048 | |
5575 | 6049 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 6050 { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6051 struct oscar_data *od = gc->proto_data; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6052 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6053 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6054 if (!od->icq) |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6055 return g_list_append(m, GAIM_AWAY_CUSTOM); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6056 |
4333 | 6057 m = g_list_append(m, _("Online")); |
6058 m = g_list_append(m, _("Away")); | |
6059 m = g_list_append(m, _("Do Not Disturb")); | |
6060 m = g_list_append(m, _("Not Available")); | |
6061 m = g_list_append(m, _("Occupied")); | |
6062 m = g_list_append(m, _("Free For Chat")); | |
6063 m = g_list_append(m, _("Invisible")); | |
6064 | |
6065 return m; | |
6066 } | |
6067 | |
5575 | 6068 static GList *oscar_buddy_menu(GaimConnection *gc, const char *who) { |
4333 | 6069 struct oscar_data *od = gc->proto_data; |
6070 GList *m = NULL; | |
6071 struct proto_buddy_menu *pbm; | |
6072 | |
6073 if (od->icq) { | |
4624 | 6074 #if 0 |
4333 | 6075 pbm = g_new0(struct proto_buddy_menu, 1); |
6076 pbm->label = _("Get Status Msg"); | |
4969 | 6077 pbm->callback = oscar_get_icqstatusmsg; |
4333 | 6078 pbm->gc = gc; |
6079 m = g_list_append(m, pbm); | |
4624 | 6080 #endif |
4333 | 6081 } else { |
6695 | 6082 GaimBuddy *b = gaim_find_buddy(gc->account, who); |
7011 | 6083 aim_userinfo_t *userinfo; |
5975 | 6084 |
6085 if (b) | |
7045 | 6086 userinfo = aim_locate_finduserinfo(od->sess, b->name); |
7011 | 6087 |
6088 if (b && userinfo && aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), who) && GAIM_BUDDY_IS_ONLINE(b)) { | |
6089 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { | |
5917 | 6090 pbm = g_new0(struct proto_buddy_menu, 1); |
6091 pbm->label = _("Direct IM"); | |
6092 pbm->callback = oscar_ask_direct_im; | |
6093 pbm->gc = gc; | |
6094 m = g_list_append(m, pbm); | |
6095 } | |
6096 | |
7011 | 6097 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { |
5917 | 6098 pbm = g_new0(struct proto_buddy_menu, 1); |
6099 pbm->label = _("Send File"); | |
6100 pbm->callback = oscar_ask_sendfile; | |
6101 pbm->gc = gc; | |
6102 m = g_list_append(m, pbm); | |
6103 } | |
4826 | 6104 #if 0 |
7011 | 6105 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
5917 | 6106 pbm = g_new0(struct proto_buddy_menu, 1); |
6107 pbm->label = _("Get File"); | |
6108 pbm->callback = oscar_ask_getfile; | |
6109 pbm->gc = gc; | |
6110 m = g_list_append(m, pbm); | |
6111 } | |
4826 | 6112 #endif |
4333 | 6113 } |
5131 | 6114 } |
5197 | 6115 |
5131 | 6116 if (od->sess->ssi.received_data) { |
6117 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); | |
6118 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { | |
6119 pbm = g_new0(struct proto_buddy_menu, 1); | |
6873 | 6120 pbm->label = _("Re-request Authorization"); |
5131 | 6121 pbm->callback = gaim_auth_sendrequest; |
6122 pbm->gc = gc; | |
6123 m = g_list_append(m, pbm); | |
4333 | 6124 } |
4916 | 6125 } |
6126 | |
4333 | 6127 return m; |
6128 } | |
6129 | |
5575 | 6130 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
4333 | 6131 struct oscar_data *od = gc->proto_data; |
5575 | 6132 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6133 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6134 od->setnick = TRUE; | |
6135 od->newsn = g_strdup(nick); | |
6136 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6137 } else { | |
6138 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6139 } | |
6140 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6141 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6142 _("Screenname formatting can change only capitalization and whitespace.")); |
4333 | 6143 } |
6144 } | |
6145 | |
5575 | 6146 static void oscar_show_format_screenname(GaimConnection *gc) |
4333 | 6147 { |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6148 gaim_request_input(gc, NULL, _("New screenname formatting:"), NULL, |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6149 gaim_connection_get_display_name(gc), FALSE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6150 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6151 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6152 gc); |
4333 | 6153 } |
6154 | |
5575 | 6155 static void oscar_confirm_account(GaimConnection *gc) |
4333 | 6156 { |
6157 struct oscar_data *od = gc->proto_data; | |
6158 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
6159 | |
6160 if (conn) { | |
6161 aim_admin_reqconfirm(od->sess, conn); | |
6162 } else { | |
6163 od->conf = TRUE; | |
6164 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6165 } | |
6166 } | |
6167 | |
5575 | 6168 static void oscar_show_email(GaimConnection *gc) |
4333 | 6169 { |
6170 struct oscar_data *od = gc->proto_data; | |
6171 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
6172 | |
6173 if (conn) { | |
6174 aim_admin_getinfo(od->sess, conn, 0x11); | |
6175 } else { | |
6176 od->reqemail = TRUE; | |
6177 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6178 } | |
6179 } | |
6180 | |
5575 | 6181 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6182 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6183 struct oscar_data *od = gc->proto_data; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6184 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
|
6185 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6186 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6187 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6188 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6189 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6190 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6191 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6192 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6193 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6194 |
5575 | 6195 static void oscar_show_change_email(GaimConnection *gc) |
4333 | 6196 { |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6197 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6198 FALSE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6199 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6200 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6201 gc); |
4333 | 6202 } |
6203 | |
5575 | 6204 static void oscar_show_awaitingauth(GaimConnection *gc) |
4333 | 6205 { |
2979 | 6206 struct oscar_data *od = gc->proto_data; |
4333 | 6207 gchar *nombre, *text, *tmp; |
6695 | 6208 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 6209 int num=0; |
6210 | |
6873 | 6211 text = g_strdup(""); |
4333 | 6212 |
4785 | 6213 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 6214 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 6215 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
6216 continue; | |
6695 | 6217 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
6218 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 6219 continue; |
6695 | 6220 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
6221 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
6222 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6223 continue; | |
6224 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
6225 if (gaim_get_buddy_alias_only(buddy)) | |
6226 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_get_buddy_alias_only(buddy)); | |
6227 else | |
6228 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 6229 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 6230 g_free(text); |
6231 text = tmp; | |
6232 g_free(nombre); | |
6233 num++; | |
6234 } | |
4333 | 6235 } |
2979 | 6236 } |
4333 | 6237 } |
6238 | |
6239 if (!num) { | |
6240 g_free(text); | |
6873 | 6241 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
6242 } | |
6243 | |
6244 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
6245 "the following buddies"), _("You can re-request " | |
6246 "authorization from these buddies by " | |
6247 "right-clicking on them and selecting " | |
6248 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 6249 g_free(text); |
2979 | 6250 } |
6251 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6252 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6253 { |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6254 serv_dir_search(gc, "", "", "", "", "", "", "", email); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6255 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6256 |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6257 static void oscar_show_find_email(GaimConnection *gc) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6258 { |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6259 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6260 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6261 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6262 "searching for."), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6263 NULL, FALSE, FALSE, |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6264 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6265 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6266 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6267 |
5975 | 6268 #if 0 |
5917 | 6269 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
6270 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
6271 | |
6272 aim_srv_setavailmsg(od->sess, text); | |
6273 } | |
6274 | |
6275 static void oscar_show_setavailmsg(GaimConnection *gc) | |
6276 { | |
6277 gaim_request_input(gc, NULL, _("Available Message:"), | |
7032 | 6278 NULL, "Please talk to me, I'm lonely! (and single)", TRUE, FALSE, |
5917 | 6279 _("OK"), G_CALLBACK(oscar_setavailmsg), |
6280 _("Cancel"), NULL, | |
6281 gc); | |
6282 } | |
5975 | 6283 #endif |
5917 | 6284 |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6285 static void oscar_show_set_info(GaimConnection *gc) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6286 { |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6287 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6288 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6289 |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6290 static void oscar_change_pass(GaimConnection *gc) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6291 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6292 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6293 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6294 |
5575 | 6295 static void oscar_show_chpassurl(GaimConnection *gc) |
4333 | 6296 { |
6297 struct oscar_data *od = gc->proto_data; | |
5575 | 6298 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
|
6299 gaim_notify_uri(gc, substituted); |
5517 | 6300 g_free(substituted); |
4333 | 6301 } |
6302 | |
7026 | 6303 static void oscar_show_imforwardingurl(GaimConnection *gc) |
6304 { | |
6305 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); | |
6306 } | |
6307 | |
5842 | 6308 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
6309 { | |
5844 | 6310 struct oscar_data *od = gc->proto_data; |
6311 aim_session_t *sess = od->sess; | |
5842 | 6312 FILE *file; |
6313 struct stat st; | |
5844 | 6314 |
6039 | 6315 if (iconfile == NULL) { |
6316 /* Set an empty icon, or something */ | |
6317 } else if (!stat(iconfile, &st)) { | |
5842 | 6318 char *buf = g_malloc(st.st_size); |
6319 file = fopen(iconfile, "rb"); | |
6320 if (file) { | |
6052 | 6321 md5_state_t *state; |
6039 | 6322 char md5[16]; |
5842 | 6323 int len = fread(buf, 1, st.st_size, file); |
6039 | 6324 fclose(file); |
6052 | 6325 state = g_malloc(sizeof(md5_state_t)); |
5842 | 6326 md5_init(state); |
6327 md5_append(state, buf, len); | |
6328 md5_finish(state, md5); | |
6329 g_free(state); | |
6330 aim_ssi_seticon(sess, md5, 16); | |
6331 } else | |
6332 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
6333 "Can't open buddy icon file!\n"); | |
6334 g_free(buf); | |
6335 } else | |
6336 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
6337 "Can't stat buddy icon file!\n"); | |
6338 } | |
6339 | |
6340 | |
5575 | 6341 static GList *oscar_actions(GaimConnection *gc) |
2086 | 6342 { |
6343 struct oscar_data *od = gc->proto_data; | |
4333 | 6344 struct proto_actions_menu *pam; |
6345 GList *m = NULL; | |
6346 | |
6347 pam = g_new0(struct proto_actions_menu, 1); | |
6348 pam->label = _("Set User Info"); | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6349 pam->callback = oscar_show_set_info; |
4333 | 6350 pam->gc = gc; |
6351 m = g_list_append(m, pam); | |
6352 | |
5917 | 6353 #if 0 |
6354 pam = g_new0(struct proto_actions_menu, 1); | |
6355 pam->label = _("Set Available Message"); | |
6356 pam->callback = oscar_show_setavailmsg; | |
6357 pam->gc = gc; | |
6358 m = g_list_append(m, pam); | |
6359 #endif | |
6360 | |
5238 | 6361 pam = g_new0(struct proto_actions_menu, 1); |
6362 pam->label = _("Change Password"); | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6363 pam->callback = oscar_change_pass; |
5238 | 6364 pam->gc = gc; |
6365 m = g_list_append(m, pam); | |
4617 | 6366 |
6367 if (od->sess->authinfo->chpassurl) { | |
6368 pam = g_new0(struct proto_actions_menu, 1); | |
6369 pam->label = _("Change Password (URL)"); | |
6370 pam->callback = oscar_show_chpassurl; | |
6371 pam->gc = gc; | |
6372 m = g_list_append(m, pam); | |
6373 } | |
6374 | |
7026 | 6375 if (od->sess->authinfo->chpassurl) { |
6376 pam = g_new0(struct proto_actions_menu, 1); | |
6377 pam->label = _("Configure IM Forwarding (URL)"); | |
6378 pam->callback = oscar_show_imforwardingurl; | |
6379 pam->gc = gc; | |
6380 m = g_list_append(m, pam); | |
6381 } | |
6382 | |
5238 | 6383 if (!od->icq) { |
4617 | 6384 /* AIM actions */ |
6385 m = g_list_append(m, NULL); | |
4333 | 6386 |
5917 | 6387 pam = g_new0(struct proto_actions_menu, 1); |
4333 | 6388 pam->label = _("Format Screenname"); |
5844 | 6389 pam->callback = oscar_show_format_screenname; |
4333 | 6390 pam->gc = gc; |
6391 m = g_list_append(m, pam); | |
6392 | |
6393 pam = g_new0(struct proto_actions_menu, 1); | |
6394 pam->label = _("Confirm Account"); | |
6395 pam->callback = oscar_confirm_account; | |
6396 pam->gc = gc; | |
6397 m = g_list_append(m, pam); | |
6398 | |
6399 pam = g_new0(struct proto_actions_menu, 1); | |
6400 pam->label = _("Display Current Registered Address"); | |
6401 pam->callback = oscar_show_email; | |
6402 pam->gc = gc; | |
6403 m = g_list_append(m, pam); | |
6404 | |
6405 pam = g_new0(struct proto_actions_menu, 1); | |
6406 pam->label = _("Change Current Registered Address"); | |
6407 pam->callback = oscar_show_change_email; | |
6408 pam->gc = gc; | |
6409 m = g_list_append(m, pam); | |
2086 | 6410 } |
4333 | 6411 |
6412 m = g_list_append(m, NULL); | |
6413 | |
6414 pam = g_new0(struct proto_actions_menu, 1); | |
6415 pam->label = _("Show Buddies Awaiting Authorization"); | |
6416 pam->callback = oscar_show_awaitingauth; | |
6417 pam->gc = gc; | |
6418 m = g_list_append(m, pam); | |
6419 | |
2086 | 6420 m = g_list_append(m, NULL); |
4333 | 6421 |
6422 pam = g_new0(struct proto_actions_menu, 1); | |
6423 pam->label = _("Search for Buddy by Email"); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6424 pam->callback = oscar_show_find_email; |
4333 | 6425 pam->gc = gc; |
6426 m = g_list_append(m, pam); | |
6427 | |
4336 | 6428 /* pam = g_new0(struct proto_actions_menu, 1); |
4333 | 6429 pam->label = _("Search for Buddy by Information"); |
6430 pam->callback = show_find_info; | |
6431 pam->gc = gc; | |
4336 | 6432 m = g_list_append(m, pam); */ |
2086 | 6433 |
6434 return m; | |
6435 } | |
6436 | |
5575 | 6437 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 6438 { |
6439 struct oscar_data *od = gc->proto_data; | |
4617 | 6440 |
6441 if (od->icq) { | |
6442 aim_icq_changepasswd(od->sess, new); | |
2086 | 6443 } else { |
4617 | 6444 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6445 if (conn) { | |
6446 aim_admin_changepasswd(od->sess, conn, new, old); | |
6447 } else { | |
6448 od->chpass = TRUE; | |
6449 od->oldp = g_strdup(old); | |
6450 od->newp = g_strdup(new); | |
6451 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6452 } | |
2086 | 6453 } |
6454 } | |
6455 | |
6059 | 6456 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6457 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6458 struct oscar_data *od = gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6459 struct direct_im *dim = find_direct_im(od, who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6460 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6461 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6462 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6463 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6464 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6465 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6466 aim_conn_kill(od->sess, &dim->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6467 g_free(dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6468 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6469 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6470 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6471 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6472 GAIM_PROTO_OSCAR, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6473 OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6474 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6475 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6476 oscar_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6477 oscar_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6478 oscar_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6479 oscar_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6480 oscar_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6481 oscar_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6482 oscar_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6483 oscar_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6484 oscar_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6485 oscar_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6486 oscar_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6487 oscar_set_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6488 oscar_send_typing, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6489 oscar_get_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6490 oscar_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6491 oscar_get_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6492 oscar_set_dir, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6493 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6494 oscar_dir_search, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6495 oscar_set_idle, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6496 oscar_change_passwd, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6497 oscar_add_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6498 oscar_add_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6499 oscar_remove_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6500 oscar_remove_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6501 oscar_add_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6502 oscar_add_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6503 oscar_rem_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6504 oscar_rem_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6505 oscar_set_permit_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6506 oscar_warn, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6507 oscar_join_chat, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6508 oscar_chat_invite, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6509 oscar_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6510 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6511 oscar_chat_send, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6512 oscar_keepalive, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6513 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6514 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6515 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6516 #ifndef NOSSI |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6517 oscar_alias_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6518 oscar_move_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6519 oscar_rename_group, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6520 #else |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6521 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6522 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6523 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6524 #endif |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6525 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6526 oscar_convo_closed, |
5842 | 6527 NULL, |
6528 oscar_set_icon | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6529 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6530 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6531 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6532 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6533 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6534 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6535 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6536 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6537 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6538 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6539 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6540 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6541 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6542 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6543 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6544 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6545 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6546 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6547 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
6548 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6549 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6550 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6551 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6552 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6553 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6554 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6555 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6556 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6557 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6558 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
6559 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6560 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6561 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6562 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
6563 option = gaim_account_option_string_new(_("Auth host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6564 "login.oscar.aol.com"); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6565 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6566 option); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6567 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
6568 option = gaim_account_option_int_new(_("Auth port"), "port", 5190); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6569 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6570 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6571 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6572 my_protocol = plugin; |
2086 | 6573 } |
6574 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
6575 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |