Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 9638:201c8fe4cee3
[gaim-migrate @ 10486]
This should fix the bogus bogus profile messages
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Mon, 02 Aug 2004 02:09:35 +0000 |
parents | 10f1d729c415 |
children | 58625ebfe03a |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
6 * Some code copyright (C) 2001-2003, Sean Egan | |
8151 | 7 * Some code copyright (C) 2001-2004, Mark Doliner <thekingant@users.sourceforge.net> |
6302 | 8 * |
9 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 10 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 11 * |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 * | |
26 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
8476 | 31 #include "away.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
32 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
33 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
34 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
36 #include "ft.h" |
6982 | 37 #include "imgstore.h" |
2086 | 38 #include "multi.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
39 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
40 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
41 #include "privacy.h" |
2086 | 42 #include "prpl.h" |
4889 | 43 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
46 |
2086 | 47 #include "aim.h" |
5842 | 48 #include "md5.h" |
2086 | 49 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
50 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
51 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
52 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
53 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
54 #define UC_AB 0x20 |
3079 | 55 #define UC_WIRELESS 0x40 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
56 |
2086 | 57 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
58 | |
7283 | 59 #define OSCAR_CONNECT_STEPS 6 |
60 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
61 static GaimPlugin *my_protocol = NULL; |
4249 | 62 |
7376 | 63 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
64 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 65 |
4665 | 66 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
67 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 68 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 69 |
7283 | 70 typedef struct _OscarData OscarData; |
71 struct _OscarData { | |
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; |
8341 | 105 guint getinfotimer; |
2993 | 106 |
107 struct { | |
4230 | 108 guint maxwatchers; /* max users who can watch you */ |
2993 | 109 guint maxbuddies; /* max users you can watch */ |
4230 | 110 guint maxgroups; /* max groups in server list */ |
2993 | 111 guint maxpermits; /* max users on permit list */ |
112 guint maxdenies; /* max users on deny list */ | |
113 guint maxsiglen; /* max size (bytes) of profile */ | |
114 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
115 } rights; | |
2086 | 116 }; |
117 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
118 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
119 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
120 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
121 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
122 |
2086 | 123 struct chat_connection { |
124 char *name; | |
125 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
126 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
127 fu16_t instance; |
2086 | 128 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
|
129 aim_conn_t *conn; |
2086 | 130 int inpa; |
131 int id; | |
5575 | 132 GaimConnection *gc; /* i hate this. */ |
8733 | 133 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
134 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
135 int maxvis; |
2086 | 136 }; |
137 | |
8971 | 138 struct oscar_direct_im { |
5575 | 139 GaimConnection *gc; |
2086 | 140 char name[80]; |
141 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
142 aim_conn_t *conn; |
3008 | 143 gboolean connected; |
8978 | 144 gboolean gpc_pend; |
145 gboolean killme; | |
8984 | 146 gboolean donttryagain; |
2086 | 147 }; |
148 | |
149 struct ask_direct { | |
5575 | 150 GaimConnection *gc; |
2086 | 151 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
152 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
153 fu8_t cookie[8]; |
8984 | 154 gboolean donttryagain; |
2086 | 155 }; |
156 | |
7011 | 157 /* |
158 * Various PRPL-specific buddy info that we want to keep track of | |
159 * Some other info is maintained by locate.c, and I'd like to move | |
160 * the rest of this to libfaim, mostly im.c | |
161 */ | |
4738 | 162 struct buddyinfo { |
163 gboolean typingnot; | |
6292 | 164 gchar *availmsg; |
6857 | 165 fu32_t ipaddr; |
5836 | 166 |
167 unsigned long ico_me_len; | |
168 unsigned long ico_me_csum; | |
169 time_t ico_me_time; | |
170 gboolean ico_informed; | |
4738 | 171 |
172 unsigned long ico_len; | |
173 unsigned long ico_csum; | |
174 time_t ico_time; | |
175 gboolean ico_need; | |
7406 | 176 gboolean ico_sent; |
2086 | 177 }; |
178 | |
4230 | 179 struct name_data { |
5575 | 180 GaimConnection *gc; |
4230 | 181 gchar *name; |
3453 | 182 gchar *nick; |
3141 | 183 }; |
184 | |
5129 | 185 static char *msgerrreason[] = { |
186 N_("Invalid error"), | |
187 N_("Invalid SNAC"), | |
188 N_("Rate to host"), | |
189 N_("Rate to client"), | |
190 N_("Not logged in"), | |
191 N_("Service unavailable"), | |
192 N_("Service not defined"), | |
193 N_("Obsolete SNAC"), | |
194 N_("Not supported by host"), | |
195 N_("Not supported by client"), | |
196 N_("Refused by client"), | |
197 N_("Reply too big"), | |
198 N_("Responses lost"), | |
199 N_("Request denied"), | |
200 N_("Busted SNAC payload"), | |
201 N_("Insufficient rights"), | |
202 N_("In local permit/deny"), | |
203 N_("Too evil (sender)"), | |
204 N_("Too evil (receiver)"), | |
205 N_("User temporarily unavailable"), | |
206 N_("No match"), | |
207 N_("List overflow"), | |
208 N_("Request ambiguous"), | |
209 N_("Queue full"), | |
210 N_("Not while on AOL") | |
211 }; | |
212 static int msgerrreasonlen = 25; | |
213 | |
214 /* All the libfaim->gaim callback functions */ | |
215 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
216 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
217 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
218 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
219 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
220 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
221 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
224 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 225 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 226 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 227 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
228 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
229 static int gaim_conv_chat_join (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
230 static int gaim_conv_chat_leave (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
231 static int gaim_conv_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
232 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 233 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
234 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 236 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 237 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
238 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
240 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
241 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
242 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
243 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
244 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
245 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
246 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
247 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
248 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
249 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
264 #ifndef NOSSI | |
265 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 269 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 270 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
271 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
274 #endif | |
275 | |
276 /* for DirectIM/image transfer */ | |
277 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 280 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 281 |
282 /* for file transfer */ | |
283 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
284 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
285 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
286 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
287 | |
288 /* for icons */ | |
289 static gboolean gaim_icon_timerfunc(gpointer data); | |
290 | |
8971 | 291 /* just because */ |
292 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); | |
8983 | 293 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
8971 | 294 |
8076 | 295 /* remove these at some point? */ |
7282 | 296 /* Because I don't like forward declarations? I think that was why... */ |
5954 | 297 static void oscar_set_info(GaimConnection *gc, const char *text); |
8076 | 298 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message); |
5306 | 299 |
5836 | 300 static void oscar_free_name_data(struct name_data *data) { |
4230 | 301 g_free(data->name); |
302 g_free(data->nick); | |
303 g_free(data); | |
304 } | |
305 | |
5836 | 306 static void oscar_free_buddyinfo(void *data) { |
307 struct buddyinfo *bi = data; | |
6292 | 308 g_free(bi->availmsg); |
5836 | 309 g_free(bi); |
310 } | |
311 | |
5129 | 312 static fu32_t oscar_encoding_check(const char *utf8) |
313 { | |
314 int i = 0; | |
315 fu32_t encodingflag = 0; | |
316 | |
317 /* Determine how we can send this message. Per the warnings elsewhere | |
318 * in this file, these little checks determine the simplest encoding | |
319 * we can use for a given message send using it. */ | |
320 while (utf8[i]) { | |
321 if ((unsigned char)utf8[i] > 0x7f) { | |
322 /* not ASCII! */ | |
323 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
324 break; | |
325 } | |
326 i++; | |
327 } | |
328 while (utf8[i]) { | |
329 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
330 * followed by 0xc0-0xc3 in the second */ | |
331 if ((unsigned char)utf8[i] < 0x80) { | |
332 i++; | |
333 continue; | |
334 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
335 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
336 i += 2; | |
337 continue; | |
338 } | |
339 encodingflag = AIM_IMFLAGS_UNICODE; | |
340 break; | |
341 } | |
342 | |
343 return encodingflag; | |
344 } | |
345 | |
8225 | 346 /* |
347 * Take a string of the form charset="bleh" where bleh is | |
348 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
349 * return a newly allocated string containing bleh. | |
350 */ | |
351 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 352 { |
8225 | 353 gchar *ret = NULL; |
354 char *begin, *end; | |
355 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
356 /* Make sure encoding begins with charset= */ |
8225 | 357 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
358 return NULL; | |
359 | |
360 begin = strchr(encoding, '"'); | |
361 end = strrchr(encoding, '"'); | |
362 | |
363 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
364 return NULL; | |
365 | |
366 ret = g_strndup(begin+1, (end-1) - begin); | |
367 | |
368 return ret; | |
369 } | |
370 | |
8233 | 371 gchar *oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) |
5129 | 372 { |
373 gchar *utf8 = NULL; | |
9595 | 374 |
375 if ((encoding == NULL) || encoding[0] == '\0') { | |
376 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
377 | |
378 } else if (!strcmp(encoding, "iso-8859-1")) { | |
379 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
380 | |
381 } else if (!strcmp(encoding, "unicode-2-0")) { | |
382 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
383 | |
384 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
385 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
386 "attempting to convert to UTF-8 anyway\n"); | |
387 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
388 } | |
389 | |
390 /* | |
391 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
392 * we have been unable to convert the text to utf-8 from the encoding | |
393 * that was specified. So we check if the text is valid utf-8 then | |
394 * just copy it. | |
395 */ | |
396 if (utf8 == NULL) { | |
9638 | 397 if (textlen != 0 && *text != '\0' |
398 && !g_utf8_validate(text, textlen, NULL)) | |
9476 | 399 utf8 = g_strdup(_("(There was an error converting this message. The buddy you are speaking to most likely has a buggy client.)")); |
400 else | |
9481 | 401 utf8 = g_strndup(text, textlen); |
5129 | 402 } |
403 | |
404 return utf8; | |
405 } | |
406 | |
9407 | 407 gchar *oscar_caps_to_string(guint caps) |
8701 | 408 { |
9407 | 409 GString *str; |
410 gchar *tmp; | |
8701 | 411 guint bit = 1; |
412 | |
9407 | 413 str = g_string_new(""); |
414 | |
8701 | 415 if (!caps) { |
416 return NULL; | |
417 } else while (bit <= AIM_CAPS_LAST) { | |
418 if (bit & caps) { | |
419 switch (bit) { | |
420 case AIM_CAPS_BUDDYICON: | |
421 tmp = _("Buddy Icon"); | |
422 break; | |
423 case AIM_CAPS_TALK: | |
424 tmp = _("Voice"); | |
425 break; | |
426 case AIM_CAPS_DIRECTIM: | |
427 tmp = _("AIM Direct IM"); | |
428 break; | |
429 case AIM_CAPS_CHAT: | |
430 tmp = _("Chat"); | |
431 break; | |
432 case AIM_CAPS_GETFILE: | |
433 tmp = _("Get File"); | |
434 break; | |
435 case AIM_CAPS_SENDFILE: | |
436 tmp = _("Send File"); | |
437 break; | |
438 case AIM_CAPS_GAMES: | |
439 case AIM_CAPS_GAMES2: | |
440 tmp = _("Games"); | |
441 break; | |
442 case AIM_CAPS_ADDINS: | |
443 tmp = _("Add-Ins"); | |
444 break; | |
445 case AIM_CAPS_SENDBUDDYLIST: | |
446 tmp = _("Send Buddy List"); | |
447 break; | |
448 case AIM_CAPS_ICQ_DIRECT: | |
449 tmp = _("ICQ Direct Connect"); | |
450 break; | |
451 case AIM_CAPS_APINFO: | |
452 tmp = _("AP User"); | |
453 break; | |
454 case AIM_CAPS_ICQRTF: | |
455 tmp = _("ICQ RTF"); | |
456 break; | |
457 case AIM_CAPS_EMPTY: | |
458 tmp = _("Nihilist"); | |
459 break; | |
460 case AIM_CAPS_ICQSERVERRELAY: | |
461 tmp = _("ICQ Server Relay"); | |
462 break; | |
463 case AIM_CAPS_ICQUTF8OLD: | |
464 tmp = _("Old ICQ UTF8"); | |
465 break; | |
466 case AIM_CAPS_TRILLIANCRYPT: | |
467 tmp = _("Trillian Encryption"); | |
468 break; | |
469 case AIM_CAPS_ICQUTF8: | |
470 tmp = _("ICQ UTF8"); | |
471 break; | |
472 case AIM_CAPS_HIPTOP: | |
473 tmp = _("Hiptop"); | |
474 break; | |
475 case AIM_CAPS_SECUREIM: | |
476 tmp = _("Security Enabled"); | |
477 break; | |
478 case AIM_CAPS_VIDEO: | |
479 tmp = _("Video Chat"); | |
480 break; | |
481 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
482 case AIM_CAPS_ICHATAV: | |
483 tmp = _("iChat AV"); | |
484 break; | |
485 case AIM_CAPS_LIVEVIDEO: | |
486 tmp = _("Live Video"); | |
487 break; | |
488 case AIM_CAPS_CAMERA: | |
489 tmp = _("Camera"); | |
490 break; | |
491 default: | |
492 tmp = NULL; | |
493 break; | |
494 } | |
495 if (tmp) | |
9532 | 496 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 497 } |
498 bit <<= 1; | |
499 } | |
9407 | 500 |
501 return g_string_free(str, FALSE); | |
8701 | 502 } |
503 | |
504 static char *oscar_icqstatus(int state) { | |
505 /* Make a cute little string that shows the status of the dude or dudet */ | |
506 if (state & AIM_ICQ_STATE_CHAT) | |
507 return g_strdup_printf(_("Free For Chat")); | |
508 else if (state & AIM_ICQ_STATE_DND) | |
509 return g_strdup_printf(_("Do Not Disturb")); | |
510 else if (state & AIM_ICQ_STATE_OUT) | |
511 return g_strdup_printf(_("Not Available")); | |
512 else if (state & AIM_ICQ_STATE_BUSY) | |
513 return g_strdup_printf(_("Occupied")); | |
514 else if (state & AIM_ICQ_STATE_AWAY) | |
515 return g_strdup_printf(_("Away")); | |
516 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
517 return g_strdup_printf(_("Web Aware")); | |
518 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
519 return g_strdup_printf(_("Invisible")); | |
520 else | |
521 return g_strdup_printf(_("Online")); | |
522 } | |
523 | |
524 static void oscar_string_append(GString *str, char *newline, char *name, char *value) | |
8700 | 525 { |
526 gchar *utf8; | |
527 | |
528 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 529 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 530 g_free(utf8); |
531 } | |
532 } | |
533 | |
8701 | 534 static void oscar_string_append_info(GaimConnection *gc, GString *str, char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
535 { | |
536 OscarData *od = gc->proto_data; | |
537 GaimAccount *account = gaim_connection_get_account(gc); | |
538 GaimGroup *g = NULL; | |
539 struct buddyinfo *bi = NULL; | |
540 char *tmp; | |
541 | |
542 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
543 return; | |
544 | |
545 if (userinfo == NULL) | |
546 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
547 | |
548 if (b == NULL) | |
549 b = gaim_find_buddy(gc->account, userinfo->sn); | |
550 | |
551 if (b != NULL) | |
552 g = gaim_find_buddys_group(b); | |
553 | |
554 if (userinfo != NULL) | |
555 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
556 | |
8733 | 557 if (b != NULL) { |
558 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
559 if (isdigit(b->name[0])) { | |
560 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
561 oscar_string_append(str, newline, _("Status"), tmp); | |
562 g_free(tmp); | |
563 } | |
564 } else { | |
9625 | 565 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 566 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
567 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
568 else | |
569 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 570 } |
8733 | 571 } |
8701 | 572 |
573 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 574 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 575 (bi->ipaddr & 0xff000000) >> 24, |
576 (bi->ipaddr & 0x00ff0000) >> 16, | |
577 (bi->ipaddr & 0x0000ff00) >> 8, | |
578 (bi->ipaddr & 0x000000ff)); | |
579 oscar_string_append(str, newline, _("IP Address"), tmp); | |
580 g_free(tmp); | |
581 } | |
582 | |
583 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
584 tmp = oscar_caps_to_string(userinfo->capabilities); | |
585 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 586 g_free(tmp); |
8701 | 587 } |
588 | |
589 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
590 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
591 if (tmp != NULL) { | |
9625 | 592 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 593 g_free(tmp); |
9625 | 594 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
595 g_free(tmp2); | |
8701 | 596 } |
597 } | |
598 | |
599 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
600 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
601 oscar_string_append(str, newline, _("Available"), tmp); | |
602 g_free(tmp); | |
603 } | |
604 } | |
605 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
606 static char *extract_name(const char *name) { |
4121 | 607 char *tmp, *x; |
2086 | 608 int i, j; |
4120 | 609 |
610 if (!name) | |
4121 | 611 return NULL; |
612 | |
4120 | 613 x = strchr(name, '-'); |
4121 | 614 |
2086 | 615 if (!x) return NULL; |
616 x = strchr(++x, '-'); | |
617 if (!x) return NULL; | |
618 tmp = g_strdup(++x); | |
619 | |
620 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
621 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
622 if (x[i] != '%') { |
2086 | 623 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
624 continue; |
2086 | 625 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
626 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
627 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
628 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 629 } |
630 | |
631 tmp[j] = 0; | |
632 return tmp; | |
633 } | |
634 | |
5575 | 635 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 636 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 637 struct chat_connection *c = NULL; |
638 | |
639 while (g) { | |
640 c = (struct chat_connection *)g->data; | |
641 if (c->id == id) | |
642 break; | |
643 g = g->next; | |
644 c = NULL; | |
645 } | |
646 | |
647 return c; | |
648 } | |
649 | |
5575 | 650 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
|
651 aim_conn_t *conn) { |
7283 | 652 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 653 struct chat_connection *c = NULL; |
654 | |
655 while (g) { | |
656 c = (struct chat_connection *)g->data; | |
657 if (c->conn == conn) | |
658 break; | |
659 g = g->next; | |
660 c = NULL; | |
661 } | |
662 | |
663 return c; | |
664 } | |
665 | |
8219 | 666 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
667 GaimConversation *conv) { | |
668 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
669 struct chat_connection *c = NULL; | |
670 | |
671 while (g) { | |
672 c = (struct chat_connection *)g->data; | |
8733 | 673 if (c->conv == conv) |
8219 | 674 break; |
675 g = g->next; | |
676 c = NULL; | |
677 } | |
678 | |
679 return c; | |
680 } | |
681 | |
8971 | 682 /***************************************************************************** |
683 * Begin scary direct im stuff | |
684 *****************************************************************************/ | |
685 | |
686 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
687 GSList *d = od->direct_ims; | |
688 struct oscar_direct_im *m = NULL; | |
689 | |
690 while (d) { | |
691 m = (struct oscar_direct_im *)d->data; | |
692 if (!aim_sncmp(who, m->name)) | |
693 return m; | |
694 d = d->next; | |
695 } | |
696 | |
697 return NULL; | |
698 } | |
699 | |
700 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
701 { | |
702 gaim_debug_info("oscar", | |
703 "destroying Direct IM for %s.\n", dim->name); | |
704 | |
705 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 706 if (dim->gpc_pend) { |
707 dim->killme = TRUE; | |
708 return; | |
709 } | |
8971 | 710 if (dim->watcher) |
711 gaim_input_remove(dim->watcher); | |
712 if (dim->conn) { | |
713 aim_conn_close(dim->conn); | |
714 aim_conn_kill(od->sess, &dim->conn); | |
715 } | |
716 g_free(dim); | |
717 } | |
718 | |
719 /* the only difference between this and destroy is this writes a conv message */ | |
720 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
721 { | |
722 GaimConversation *conv; | |
723 char buf[256]; | |
724 | |
725 gaim_debug_info("oscar", | |
726 "%s disconnected Direct IM.\n", dim->name); | |
727 | |
728 if (dim->connected) | |
729 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 730 else |
8971 | 731 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
732 | |
733 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
734 if (conv) { | |
735 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 736 gaim_conversation_update_progress(conv, 0); |
8971 | 737 } else { |
738 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
739 } | |
740 | |
741 oscar_direct_im_destroy(od, dim); | |
742 | |
743 return; | |
744 } | |
745 | |
746 /* oops i made two of these. this one just calls the other one. */ | |
747 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
748 { | |
749 GaimConnection *gc = sess->aux_data; | |
750 OscarData *od = (OscarData *)gc->proto_data; | |
751 struct oscar_direct_im *dim; | |
752 char *sn; | |
753 | |
754 sn = g_strdup(aim_odc_getsn(conn)); | |
755 dim = oscar_direct_im_find(od, sn); | |
756 oscar_direct_im_disconnect(od, dim); | |
757 g_free(sn); | |
758 } | |
759 | |
760 static void destroy_direct_im_request(struct ask_direct *d) { | |
761 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
762 | |
763 g_free(d->sn); | |
764 g_free(d); | |
765 } | |
766 | |
767 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
768 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
769 struct oscar_direct_im *dim = data; | |
770 GaimConnection *gc = dim->gc; | |
771 OscarData *od = gc->proto_data; | |
772 GaimConversation *conv; | |
773 char buf[256]; | |
774 struct sockaddr name; | |
775 socklen_t name_len = 1; | |
776 | |
777 g_return_if_fail(gc != NULL); | |
778 | |
8978 | 779 dim->gpc_pend = FALSE; |
780 if (dim->killme) { | |
781 oscar_direct_im_destroy(od, dim); | |
782 return; | |
783 } | |
784 | |
8971 | 785 if (!g_list_find(gaim_connections_get_all(), gc)) { |
786 oscar_direct_im_destroy(od, dim); | |
787 return; | |
788 } | |
789 | |
790 if (source < 0) { | |
8984 | 791 if (dim->donttryagain) { |
792 oscar_direct_im_disconnect(od, dim); | |
793 return; | |
794 } else { | |
795 fu8_t cookie[8]; | |
796 char *who = g_strdup(dim->name); | |
797 const char *tmp = aim_odc_getcookie(dim->conn); | |
798 | |
799 memcpy(cookie, tmp, 8); | |
800 oscar_direct_im_destroy(od, dim); | |
801 oscar_direct_im_initiate(gc, who, cookie); | |
802 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
803 g_free(who); | |
804 return; | |
805 } | |
8971 | 806 } |
807 | |
808 dim->conn->fd = source; | |
809 aim_conn_completeconnect(od->sess, dim->conn); | |
810 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
811 | |
812 /* This is the best way to see if we're connected or not */ | |
8983 | 813 /* Is this really needed? */ |
8971 | 814 if (getpeername(source, &name, &name_len) == 0) { |
815 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
816 dim->connected = TRUE; | |
817 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 818 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
819 } else { | |
8984 | 820 if (dim->donttryagain) { |
821 oscar_direct_im_disconnect(od, dim); | |
822 return; | |
823 } else { | |
824 fu8_t cookie[8]; | |
825 char *who = g_strdup(dim->name); | |
826 const char *tmp = aim_odc_getcookie(dim->conn); | |
827 | |
828 memcpy(cookie, tmp, 8); | |
829 oscar_direct_im_destroy(od, dim); | |
830 oscar_direct_im_initiate(gc, who, cookie); | |
831 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
832 g_free(who); | |
833 return; | |
834 } | |
8983 | 835 } |
836 | |
837 | |
8971 | 838 } |
839 | |
840 static void accept_direct_im_request(struct ask_direct *d) { | |
841 GaimConnection *gc = d->gc; | |
842 OscarData *od; | |
843 struct oscar_direct_im *dim; | |
844 char *host; int port = 5190; | |
845 int i, rc; | |
8982 | 846 char *tmp; |
847 GaimConversation *conv; | |
8971 | 848 |
849 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
850 destroy_direct_im_request(d); | |
851 return; | |
852 } | |
853 | |
854 od = (OscarData *)gc->proto_data; | |
855 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
856 | |
857 dim = oscar_direct_im_find(od, d->sn); | |
858 if (dim && dim->connected) { | |
859 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
860 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
861 return; | |
862 } | |
863 dim = g_new0(struct oscar_direct_im, 1); | |
864 dim->gc = d->gc; | |
8984 | 865 dim->donttryagain = d->donttryagain; |
8971 | 866 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
867 | |
868 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
869 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
870 if (!dim->conn) { | |
871 oscar_direct_im_disconnect(od, dim); | |
872 destroy_direct_im_request(d); | |
873 return; | |
874 } | |
875 | |
876 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
877 gaim_odc_incoming, 0); | |
878 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
879 gaim_odc_typing, 0); | |
880 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
881 gaim_odc_update_ui, 0); | |
882 | |
883 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
884 for (i = 0; i < (int)strlen(d->ip); i++) { | |
885 if (d->ip[i] == ':') { | |
886 port = atoi(&(d->ip[i+1])); | |
887 break; | |
888 } | |
889 } | |
890 host = g_strndup(d->ip, i); | |
891 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 892 dim->gpc_pend = TRUE; |
8971 | 893 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 894 |
895 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
896 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
897 port); | |
898 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
899 g_free(tmp); | |
8983 | 900 |
8971 | 901 g_free(host); |
902 if (rc < 0) { | |
8978 | 903 dim->gpc_pend = FALSE; |
8971 | 904 oscar_direct_im_disconnect(od, dim); |
905 destroy_direct_im_request(d); | |
906 return; | |
907 } | |
908 | |
909 destroy_direct_im_request(d); | |
910 | |
911 return; | |
912 } | |
913 | |
914 /* | |
915 * We have just established a socket with the other dude, so set up some handlers. | |
916 */ | |
917 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 918 GaimConnection *gc = sess->aux_data; |
7283 | 919 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 920 GaimConversation *conv; |
8971 | 921 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
922 char buf[256]; |
8971 | 923 char *sn; |
924 va_list ap; | |
925 aim_conn_t *newconn, *listenerconn; | |
926 | |
927 va_start(ap, fr); | |
928 newconn = va_arg(ap, aim_conn_t *); | |
929 listenerconn = va_arg(ap, aim_conn_t *); | |
930 va_end(ap); | |
931 | |
932 aim_conn_close(listenerconn); | |
933 aim_conn_kill(sess, &listenerconn); | |
934 | |
935 sn = g_strdup(aim_odc_getsn(newconn)); | |
936 | |
937 gaim_debug_info("oscar", | |
938 "DirectIM: initiate success to %s\n", sn); | |
939 dim = oscar_direct_im_find(od, sn); | |
940 | |
941 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
942 gaim_input_remove(dim->watcher); | |
943 dim->conn = newconn; | |
944 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
945 dim->connected = TRUE; | |
946 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
947 g_free(sn); | |
948 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
949 | |
950 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
951 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
952 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
953 | |
954 return 1; | |
955 } | |
956 | |
957 /* | |
958 * This is called when each chunk of an image is received. It can be used to | |
959 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
960 * nasty, you sicko. | |
961 */ | |
962 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
963 va_list ap; | |
964 char *sn; | |
965 double percent; | |
966 GaimConnection *gc = sess->aux_data; | |
967 OscarData *od = (OscarData *)gc->proto_data; | |
968 GaimConversation *c; | |
969 struct oscar_direct_im *dim; | |
970 | |
971 va_start(ap, fr); | |
972 sn = va_arg(ap, char *); | |
973 percent = va_arg(ap, double); | |
974 va_end(ap); | |
975 | |
976 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
977 return 1; | |
978 if (dim->watcher) { | |
979 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
980 /* The callback will callback? I don't get how that would happen here. */ | |
981 dim->watcher = 0; | |
982 } | |
983 | |
984 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
985 if (c != NULL) | |
986 gaim_conversation_update_progress(c, percent); | |
987 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
988 oscar_callback, dim->conn); | |
989 | |
990 return 1; | |
991 } | |
992 | |
993 /* | |
994 * This is called after a direct IM has been received in its entirety. This | |
995 * function is passed a long chunk of data which contains the IM with any | |
996 * data chunks (images) appended to it. | |
997 * | |
998 * This function rips out all the data chunks and creates an imgstore for | |
999 * each one. In order to do this, it first goes through the IM and takes | |
1000 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1001 * with one compatible with the imgstore Gaim core code. For each one, we | |
1002 * then read in chunks of data from the end of the message and actually | |
1003 * create the img store using the given data. | |
1004 * | |
1005 * For somewhat easy reference, here's a sample message | |
1006 * (without the whitespace and asterisks): | |
1007 * | |
1008 * <HTML><BODY BGCOLOR="#ffffff"> | |
1009 * <FONT LANG="0"> | |
1010 * This is a really stupid picture:<BR> | |
1011 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1012 * Yeah it is<BR> | |
1013 * Here is another one:<BR> | |
1014 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1015 * </FONT> | |
1016 * </BODY></HTML> | |
1017 * <BINARY> | |
1018 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1019 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1020 * </BINARY> | |
1021 */ | |
1022 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1023 GaimConnection *gc = sess->aux_data; | |
1024 GaimConvImFlags imflags = 0; | |
1025 gchar *utf8; | |
1026 GString *newmsg = g_string_new(""); | |
1027 GSList *images = NULL; | |
1028 va_list ap; | |
1029 const char *sn, *msg, *msgend, *binary; | |
1030 size_t len; | |
1031 int encoding, isawaymsg; | |
1032 | |
1033 va_start(ap, fr); | |
1034 sn = va_arg(ap, const char *); | |
1035 msg = va_arg(ap, const char *); | |
1036 len = va_arg(ap, size_t); | |
1037 encoding = va_arg(ap, int); | |
1038 isawaymsg = va_arg(ap, int); | |
1039 va_end(ap); | |
1040 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1041 |
8660 | 1042 gaim_debug_info("oscar", |
8971 | 1043 "Got DirectIM message from %s\n", sn); |
1044 | |
1045 if (isawaymsg) | |
1046 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1047 | |
1048 /* message has a binary trailer */ | |
1049 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1050 GData *attribs; | |
1051 const char *tmp, *start, *end, *last = NULL; | |
1052 | |
1053 tmp = msg; | |
1054 | |
1055 /* for each valid image tag... */ | |
1056 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1057 const char *id, *src, *datasize; | |
1058 const char *tag = NULL, *data = NULL; | |
1059 size_t size; | |
1060 int imgid = 0; | |
1061 | |
1062 /* update the location of the last img tag */ | |
1063 last = end; | |
1064 | |
1065 /* grab attributes */ | |
1066 id = g_datalist_get_data(&attribs, "id"); | |
1067 src = g_datalist_get_data(&attribs, "src"); | |
1068 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1069 | |
1070 /* if we have id & datasize, build the data tag */ | |
1071 if (id && datasize) | |
1072 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1073 | |
1074 /* if we have a tag, find the start of the data */ | |
1075 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1076 data += strlen(tag); | |
1077 | |
1078 /* check the data is here and store it */ | |
1079 if (data + (size = atoi(datasize)) <= msgend) | |
1080 imgid = gaim_imgstore_add(data, size, src); | |
1081 | |
1082 /* | |
1083 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1084 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1085 */ | |
1086 /* if we have a stored image... */ | |
1087 if (imgid) { | |
1088 /* append the message up to the tag */ | |
1089 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1090 if (utf8 != NULL) { | |
1091 newmsg = g_string_append(newmsg, utf8); | |
1092 g_free(utf8); | |
1093 } | |
1094 | |
1095 /* write the new image tag */ | |
1096 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1097 | |
1098 /* and record the image number */ | |
1099 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1100 } else { | |
1101 /* otherwise, copy up to the end of the tag */ | |
1102 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1103 if (utf8 != NULL) { | |
1104 newmsg = g_string_append(newmsg, utf8); | |
1105 g_free(utf8); | |
1106 } | |
1107 } | |
1108 | |
1109 /* clear the attribute list */ | |
1110 g_datalist_clear(&attribs); | |
1111 | |
1112 /* continue from the end of the tag */ | |
1113 tmp = end + 1; | |
1114 } | |
1115 | |
1116 /* append any remaining message data (without the > :-) */ | |
1117 if (last++ && (last < binary)) | |
1118 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1119 | |
1120 /* set the flag if we caught any images */ | |
1121 if (images) | |
1122 imflags |= GAIM_CONV_IM_IMAGES; | |
1123 } else { | |
1124 g_string_append_len(newmsg, msg, len); | |
1125 } | |
1126 | |
1127 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1128 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1129 | |
1130 /* free up the message */ | |
1131 g_string_free(newmsg, TRUE); | |
1132 | |
1133 /* unref any images we allocated */ | |
1134 if (images) { | |
1135 GSList *tmp; | |
1136 int id; | |
1137 | |
1138 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1139 id = GPOINTER_TO_INT(tmp->data); | |
1140 gaim_imgstore_unref(id); | |
1141 } | |
1142 | |
1143 g_slist_free(images); | |
1144 } | |
1145 | |
1146 return 1; | |
1147 } | |
1148 | |
1149 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1150 va_list ap; | |
1151 char *sn; | |
1152 int typing; | |
1153 GaimConnection *gc = sess->aux_data; | |
1154 | |
1155 va_start(ap, fr); | |
1156 sn = va_arg(ap, char *); | |
1157 typing = va_arg(ap, int); | |
1158 va_end(ap); | |
1159 | |
1160 if (typing == 0x0002) { | |
1161 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1162 gaim_debug_info("oscar", | |
1163 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1164 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1165 } else if (typing == 0x0001) | |
1166 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1167 else | |
1168 serv_got_typing_stopped(gc, sn); | |
1169 return 1; | |
1170 } | |
1171 | |
1172 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1173 char *buf; | |
1174 size_t len; | |
1175 int ret; | |
1176 GString *msg = g_string_new("<HTML><BODY>"); | |
1177 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1178 GData *attribs; | |
1179 const char *start, *end, *last; | |
1180 int oscar_id = 0; | |
1181 | |
1182 last = message; | |
1183 | |
1184 /* for each valid IMG tag... */ | |
1185 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1186 GaimStoredImage *image = NULL; | |
1187 const char *id; | |
1188 | |
1189 if (start - last) { | |
1190 g_string_append_len(msg, last, start - last); | |
1191 } | |
1192 | |
1193 id = g_datalist_get_data(&attribs, "id"); | |
1194 | |
1195 /* ... if it refers to a valid gaim image ... */ | |
1196 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1197 /* ... append the message from start to the tag ... */ | |
9126 | 1198 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1199 const char *filename = gaim_imgstore_get_filename(image); |
1200 gpointer imgdata = gaim_imgstore_get_data(image); | |
1201 | |
1202 oscar_id++; | |
1203 | |
1204 /* ... insert a new img tag with the oscar id ... */ | |
1205 if (filename) | |
1206 g_string_append_printf(msg, | |
9126 | 1207 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1208 filename, oscar_id, size); |
1209 else | |
1210 g_string_append_printf(msg, | |
9126 | 1211 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1212 oscar_id, size); |
1213 | |
1214 /* ... and append the data to the binary section ... */ | |
9126 | 1215 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1216 oscar_id, size); |
1217 data = g_string_append_len(data, imgdata, size); | |
1218 data = g_string_append(data, "</DATA>"); | |
1219 } | |
1220 /* If the tag is invalid, skip it, thus no else here */ | |
1221 | |
1222 g_datalist_clear(&attribs); | |
1223 | |
1224 /* continue from the end of the tag */ | |
1225 last = end + 1; | |
1226 } | |
1227 | |
1228 /* append any remaining message data (without the > :-) */ | |
1229 if (last && *last) | |
1230 msg = g_string_append(msg, last); | |
1231 | |
1232 /* if we inserted any images in the binary section, append it */ | |
1233 if (oscar_id) { | |
1234 msg = g_string_append_len(msg, data->str, data->len); | |
1235 msg = g_string_append(msg, "</BINARY>"); | |
1236 } | |
1237 | |
1238 len = msg->len; | |
1239 buf = msg->str; | |
1240 g_string_free(msg, FALSE); | |
1241 g_string_free(data, TRUE); | |
1242 | |
1243 | |
1244 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1245 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1246 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1247 else | |
1248 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1249 | |
1250 g_free(buf); | |
1251 | |
1252 return ret; | |
1253 } | |
1254 | |
1255 struct ask_do_dir_im { | |
1256 char *who; | |
1257 GaimConnection *gc; | |
1258 }; | |
1259 | |
1260 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1261 g_free(data->who); | |
1262 g_free(data); | |
1263 } | |
1264 | |
8983 | 1265 /* this function is used to initiate a direct im session with someone. |
1266 * we start listening on a port and send a request. they either connect | |
1267 * or send some kind of reply. If they can't connect, they ask us to | |
1268 * connect to them, and so we do that. | |
1269 * | |
1270 * this function will also get called if the other side initiate's a direct | |
1271 * im and we try to connect and fail. in that case cookie will not be null. | |
1272 * | |
1273 * note that cookie is an 8 byte string that isn't NULL terminated | |
1274 */ | |
1275 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1276 OscarData *od; |
1277 struct oscar_direct_im *dim; | |
1278 int listenfd; | |
8982 | 1279 const char *ip; |
8971 | 1280 |
1281 od = (OscarData *)gc->proto_data; | |
1282 | |
8983 | 1283 dim = oscar_direct_im_find(od, who); |
8971 | 1284 if (dim) { |
1285 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1286 oscar_direct_im_disconnect(od, dim); | |
1287 gaim_debug_info("oscar", | |
1288 "Gave up on old direct IM, trying again\n"); | |
1289 } else { | |
1290 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1291 return; |
8971 | 1292 } |
1293 } | |
1294 dim = g_new0(struct oscar_direct_im, 1); | |
1295 dim->gc = gc; | |
8983 | 1296 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1297 |
1298 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1299 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1300 if (listenfd >= 0) |
1301 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1302 if (dim->conn != NULL) { |
8982 | 1303 char *tmp; |
1304 GaimConversation *conv; | |
1305 | |
8971 | 1306 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1307 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1308 oscar_callback, dim->conn); | |
1309 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1310 gaim_odc_initiate, 0); | |
8982 | 1311 |
8983 | 1312 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1313 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1314 gaim_network_get_port_from_fd(listenfd)); |
1315 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1316 g_free(tmp); | |
8971 | 1317 } else { |
1318 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1319 oscar_direct_im_destroy(od, dim); | |
1320 } | |
8983 | 1321 } |
1322 | |
1323 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1324 GaimConnection *gc = data->gc; | |
1325 | |
1326 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1327 g_free(data->who); | |
1328 g_free(data); | |
1329 return; | |
1330 } | |
1331 | |
1332 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1333 g_free(data->who); |
1334 g_free(data); | |
1335 } | |
1336 | |
1337 /* this is the right click menu cb thingy */ | |
9030 | 1338 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1339 | |
1340 GaimBuddy *buddy; | |
1341 GaimConnection *gc; | |
8971 | 1342 gchar *buf; |
9030 | 1343 struct ask_do_dir_im *data; |
1344 | |
1345 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1346 | |
1347 buddy = (GaimBuddy *) node; | |
1348 gc = gaim_account_get_connection(buddy->account); | |
1349 | |
1350 data = g_new0(struct ask_do_dir_im, 1); | |
1351 data->who = g_strdup(buddy->name); | |
8971 | 1352 data->gc = gc; |
9030 | 1353 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1354 buddy->name); | |
8971 | 1355 |
1356 gaim_request_action(gc, NULL, buf, | |
9030 | 1357 _("Because this reveals your IP address, it " |
1358 "may be considered a privacy risk. Do you " | |
1359 "wish to continue?"), | |
1360 0, data, 2, | |
1361 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1362 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1363 g_free(buf); |
1364 } | |
1365 | |
1366 /***************************************************************************** | |
1367 * End scary direct im stuff | |
1368 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1369 |
4617 | 1370 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1371 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1372 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1373 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1374 OscarData *od; |
2086 | 1375 |
1376 if (!gc) { | |
8660 | 1377 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1378 "oscar callback for closed connection (1).\n"); |
2086 | 1379 return; |
1380 } | |
1381 | |
7283 | 1382 od = (OscarData *)gc->proto_data; |
2086 | 1383 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1384 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1385 /* oh boy. this is probably bad. i guess the only thing we |
1386 * can really do is return? */ | |
8660 | 1387 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1388 "oscar callback for closed connection (2).\n"); |
8660 | 1389 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1390 return; |
1391 } | |
1392 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1393 if (condition & GAIM_INPUT_READ) { |
4617 | 1394 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1395 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1396 "got information on rendezvous listener\n"); |
4617 | 1397 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1398 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1399 "connection error (rendezvous listener)\n"); |
4617 | 1400 aim_conn_kill(od->sess, &conn); |
8446 | 1401 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1402 } |
1403 } else { | |
4617 | 1404 if (aim_get_command(od->sess, conn) >= 0) { |
1405 aim_rxdispatch(od->sess); | |
6029 | 1406 if (od->killme) { |
8660 | 1407 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1408 return; |
1409 } | |
2086 | 1410 } else { |
1411 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1412 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1413 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1414 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1415 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1416 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1417 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1418 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1419 char *buf; |
8660 | 1420 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1421 "disconnected from chat room %s\n", c->name); |
2086 | 1422 c->conn = NULL; |
1423 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1424 gaim_input_remove(c->inpa); |
2086 | 1425 c->inpa = 0; |
1426 c->fd = -1; | |
4617 | 1427 aim_conn_kill(od->sess, &conn); |
5420 | 1428 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1429 if (conv) |
1430 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1431 else | |
1432 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1433 g_free(buf); |
2086 | 1434 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1435 if (od->cnpa > 0) |
1436 gaim_input_remove(od->cnpa); | |
1437 od->cnpa = 0; | |
8660 | 1438 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1439 "removing chatnav input watcher\n"); |
4617 | 1440 while (od->create_rooms) { |
1441 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1442 g_free(cr->name); |
4617 | 1443 od->create_rooms = |
1444 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1445 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1446 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1447 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1448 NULL); |
2086 | 1449 } |
4617 | 1450 aim_conn_kill(od->sess, &conn); |
2086 | 1451 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1452 if (od->paspa > 0) |
1453 gaim_input_remove(od->paspa); | |
1454 od->paspa = 0; | |
8660 | 1455 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1456 "removing authconn input watcher\n"); |
4617 | 1457 aim_conn_kill(od->sess, &conn); |
3694 | 1458 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1459 if (od->emlpa > 0) |
1460 gaim_input_remove(od->emlpa); | |
1461 od->emlpa = 0; | |
8660 | 1462 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1463 "removing email input watcher\n"); |
4617 | 1464 aim_conn_kill(od->sess, &conn); |
4804 | 1465 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1466 if (od->icopa > 0) | |
1467 gaim_input_remove(od->icopa); | |
1468 od->icopa = 0; | |
8660 | 1469 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1470 "removing icon input watcher\n"); |
4804 | 1471 aim_conn_kill(od->sess, &conn); |
2086 | 1472 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1473 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1474 gaim_odc_disconnect(od->sess, conn); |
1475 aim_conn_kill(od->sess, &conn); | |
2086 | 1476 } else { |
8660 | 1477 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1478 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1479 conn->type); |
4617 | 1480 aim_conn_kill(od->sess, &conn); |
2086 | 1481 } |
1482 } | |
1483 } | |
1484 } | |
1485 } | |
1486 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1487 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1488 GaimConnection *gc = sess->aux_data; |
7285 | 1489 gchar *s = g_strdup_vprintf(format, va); |
1490 gchar *buf; | |
1491 | |
1492 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1493 gaim_debug_info("oscar", buf); |
7285 | 1494 if (buf[strlen(buf)-1] != '\n') |
8660 | 1495 gaim_debug_info(NULL, "\n"); |
7285 | 1496 g_free(buf); |
2086 | 1497 g_free(s); |
1498 } | |
1499 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1500 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1501 { |
5575 | 1502 GaimConnection *gc = data; |
7283 | 1503 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1504 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1505 aim_conn_t *conn; |
2086 | 1506 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1507 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1508 close(source); |
1509 return; | |
1510 } | |
1511 | |
4617 | 1512 od = gc->proto_data; |
1513 sess = od->sess; | |
2086 | 1514 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1515 conn->fd = source; |
2086 | 1516 |
1517 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1518 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1519 return; |
1520 } | |
1521 | |
1522 aim_conn_completeconnect(sess, conn); | |
4617 | 1523 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1524 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1525 | |
8660 | 1526 gaim_debug_info("oscar", |
7282 | 1527 "Screen name sent, waiting for response\n"); |
7283 | 1528 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1529 ck[1] = 0x65; |
2086 | 1530 } |
1531 | |
5575 | 1532 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1533 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1534 aim_conn_t *conn; |
5575 | 1535 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1536 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1537 |
8660 | 1538 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1539 |
8437 | 1540 if (!aim_snvalid(gaim_account_get_username(account))) { |
1541 gchar *buf; | |
8590 | 1542 buf = g_strdup_printf(_("Unable to login: Could not sign on as %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), gaim_account_get_username(account)); |
8437 | 1543 gaim_connection_error(gc, buf); |
1544 g_free(buf); | |
1545 } | |
1546 | |
5575 | 1547 if (isdigit(*(gaim_account_get_username(account)))) { |
4617 | 1548 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1549 } else { |
6622 | 1550 gc->flags |= GAIM_CONNECTION_HTML; |
1551 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1552 } |
5836 | 1553 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1554 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1555 sess = g_new0(aim_session_t, 1); |
7285 | 1556 aim_session_init(sess, TRUE, 0); |
2086 | 1557 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1558 /* |
1559 * We need an immediate queue because we don't use a while-loop | |
1560 * to see if things need to be sent. | |
1561 */ | |
2086 | 1562 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1563 od->sess = sess; |
2086 | 1564 sess->aux_data = gc; |
1565 | |
1566 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
1567 if (conn == NULL) { | |
8660 | 1568 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1569 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1570 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1571 return; |
1572 } | |
1573 | |
4649 | 1574 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1575 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1576 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1577 | |
1578 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1579 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1580 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1581 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1582 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1583 return; |
1584 } | |
7282 | 1585 |
7283 | 1586 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1587 ck[0] = 0x5a; |
5575 | 1588 } |
1589 | |
1590 static void oscar_close(GaimConnection *gc) { | |
7283 | 1591 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1592 |
1593 while (od->oscar_chats) { | |
1594 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1595 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1596 gaim_input_remove(n->inpa); |
2086 | 1597 g_free(n->name); |
1598 g_free(n->show); | |
4617 | 1599 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1600 g_free(n); |
1601 } | |
4617 | 1602 while (od->direct_ims) { |
8971 | 1603 struct oscar_direct_im *n = od->direct_ims->data; |
1604 oscar_direct_im_destroy(od, n); | |
2086 | 1605 } |
4617 | 1606 /* BBB */ |
1607 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1608 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1609 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1610 gaim_xfer_cancel_local(xfer); |
3630 | 1611 } |
4804 | 1612 while (od->requesticon) { |
1613 char *sn = od->requesticon->data; | |
1614 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1615 free(sn); | |
1616 } | |
4738 | 1617 g_hash_table_destroy(od->buddyinfo); |
4617 | 1618 while (od->create_rooms) { |
1619 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1620 g_free(cr->name); |
4617 | 1621 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1622 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1623 } |
4617 | 1624 if (od->email) |
1625 g_free(od->email); | |
1626 if (od->newp) | |
1627 g_free(od->newp); | |
1628 if (od->oldp) | |
1629 g_free(od->oldp); | |
2086 | 1630 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1631 gaim_input_remove(gc->inpa); |
4617 | 1632 if (od->cnpa > 0) |
1633 gaim_input_remove(od->cnpa); | |
1634 if (od->paspa > 0) | |
1635 gaim_input_remove(od->paspa); | |
1636 if (od->emlpa > 0) | |
1637 gaim_input_remove(od->emlpa); | |
4804 | 1638 if (od->icopa > 0) |
1639 gaim_input_remove(od->icopa); | |
6907 | 1640 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1641 gaim_timeout_remove(od->icontimer); |
8341 | 1642 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1643 gaim_timeout_remove(od->getblisttimer); |
8341 | 1644 if (od->getinfotimer > 0) |
1645 gaim_timeout_remove(od->getinfotimer); | |
4617 | 1646 aim_session_kill(od->sess); |
1647 g_free(od->sess); | |
1648 od->sess = NULL; | |
2086 | 1649 g_free(gc->proto_data); |
1650 gc->proto_data = NULL; | |
8660 | 1651 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1652 } |
1653 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1654 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1655 GaimConnection *gc = data; |
7283 | 1656 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1657 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1658 aim_conn_t *bosconn; |
2086 | 1659 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1660 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1661 close(source); |
1662 return; | |
1663 } | |
1664 | |
4617 | 1665 od = gc->proto_data; |
1666 sess = od->sess; | |
1667 bosconn = od->conn; | |
4366 | 1668 bosconn->fd = source; |
2086 | 1669 |
1670 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1671 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1672 return; |
1673 } | |
1674 | |
1675 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1676 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1677 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1678 gaim_connection_update_progress(gc, |
7283 | 1679 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1680 ck[4] = 0x61; |
2086 | 1681 } |
1682 | |
4617 | 1683 /* BBB */ |
4656 | 1684 /* |
1685 * This little area in oscar.c is the nexus of file transfer code, | |
1686 * so I wrote a little explanation of what happens. I am such a | |
1687 * ninja. | |
1688 * | |
1689 * The series of events for a file send is: | |
1690 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
1691 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1692 * listening socket, then asks the remote user to connect to us (and |
1693 * gives them the file name, port, IP, etc.) | |
1694 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1695 * in oscar_sendfile_estblsh) | |
1696 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1697 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1698 * connection. | |
1699 * -We get drunk because file transfer kicks ass. | |
1700 * | |
1701 * The series of events for a file receive is: | |
1702 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1703 * -Gaim user selects file to name and location to save file to and | |
1704 * oscar_xfer_init is called | |
1705 * -It connects to the remote user using the IP they gave us earlier | |
1706 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1707 * them an AIM_CB_OFT_ACK. | |
1708 * -They begin to send us lots of raw data. | |
1709 * -When they finish sending data we send an AIM_CB_OFT_DONE and then close | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
1710 * the connection. |
4656 | 1711 */ |
1712 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1713 | |
8446 | 1714 /* |
1715 * Miscellaneous xfer functions | |
1716 */ | |
1717 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1718 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1719 GaimXfer *xfer; |
5146 | 1720 struct aim_oft_info *oft_info; |
4656 | 1721 |
1722 while (fts) { | |
1723 xfer = fts->data; | |
5146 | 1724 oft_info = xfer->data; |
1725 | |
8446 | 1726 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1727 return xfer; |
1728 | |
1729 fts = g_slist_next(fts); | |
1730 } | |
1731 | |
1732 return NULL; | |
1733 } | |
1734 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1735 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1736 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1737 GaimXfer *xfer; |
5146 | 1738 struct aim_oft_info *oft_info; |
4656 | 1739 |
1740 while (fts) { | |
1741 xfer = fts->data; | |
5146 | 1742 oft_info = xfer->data; |
1743 | |
1744 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1745 return xfer; |
1746 | |
1747 fts = g_slist_next(fts); | |
1748 } | |
1749 | |
1750 return NULL; | |
1751 } | |
1752 | |
8446 | 1753 static void oscar_xfer_end(GaimXfer *xfer) |
1754 { | |
1755 struct aim_oft_info *oft_info = xfer->data; | |
1756 GaimConnection *gc = oft_info->sess->aux_data; | |
1757 OscarData *od = gc->proto_data; | |
1758 | |
8660 | 1759 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1760 |
1761 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1762 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1763 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1764 } | |
1765 | |
1766 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1767 aim_oft_destroyinfo(oft_info); | |
1768 xfer->data = NULL; | |
1769 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1770 } | |
1771 | |
1772 /* | |
1773 * xfer functions used when receiving files | |
1774 */ | |
1775 | |
1776 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1777 { | |
1778 struct aim_oft_info *oft_info = xfer->data; | |
1779 GaimConnection *gc = oft_info->sess->aux_data; | |
1780 OscarData *od = gc->proto_data; | |
1781 | |
8660 | 1782 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1783 |
1784 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1785 if (oft_info->conn) { | |
1786 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1787 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1788 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1789 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1790 if (xfer->fd == -1) { | |
1791 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1792 _("Unable to establish file descriptor.")); | |
1793 gaim_xfer_cancel_local(xfer); | |
1794 } | |
1795 } else { | |
1796 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1797 _("Unable to create new connection.")); | |
1798 gaim_xfer_cancel_local(xfer); | |
1799 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1800 } | |
1801 | |
1802 } | |
1803 | |
1804 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1805 { | |
1806 struct aim_oft_info *oft_info = xfer->data; | |
1807 GaimConnection *gc = oft_info->sess->aux_data; | |
1808 OscarData *od = gc->proto_data; | |
1809 | |
8660 | 1810 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1811 |
1812 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
1813 | |
1814 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1815 aim_oft_destroyinfo(oft_info); | |
1816 xfer->data = NULL; | |
1817 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1818 } | |
1819 | |
1820 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1821 { | |
1822 struct aim_oft_info *oft_info = xfer->data; | |
1823 | |
1824 /* Update our rolling checksum. Like Walmart, yo. */ | |
1825 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
1826 } | |
1827 | |
1828 /* | |
1829 * xfer functions used when sending files | |
1830 */ | |
1831 | |
1832 static void oscar_xfer_init_send(GaimXfer *xfer) | |
1833 { | |
1834 struct aim_oft_info *oft_info = xfer->data; | |
1835 GaimConnection *gc = oft_info->sess->aux_data; | |
1836 OscarData *od = gc->proto_data; | |
1837 int listenfd; | |
1838 | |
8660 | 1839 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 1840 |
1841 xfer->filename = g_path_get_basename(xfer->local_filename); | |
1842 strncpy(oft_info->fh.name, xfer->filename, 64); | |
1843 oft_info->fh.name[63] = '\0'; | |
1844 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
1845 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
1846 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
1847 | |
1848 /* Create a listening socket and an associated libfaim conn */ | |
1849 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
1850 gaim_xfer_cancel_local(xfer); | |
1851 return; | |
1852 } | |
1853 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
1854 oft_info->port = xfer->local_port; | |
1855 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
1856 gaim_xfer_cancel_local(xfer); | |
1857 return; | |
1858 } | |
8660 | 1859 gaim_debug_misc("oscar", |
8446 | 1860 "port is %hu, ip is %s\n", |
1861 xfer->local_port, oft_info->clientip); | |
1862 if (oft_info->conn) { | |
1863 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
1864 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
1865 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
1866 } else { | |
1867 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
1868 _("Unable to establish listener socket.")); | |
1869 gaim_xfer_cancel_local(xfer); | |
1870 } | |
1871 } | |
1872 | |
1873 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
1874 { | |
1875 struct aim_oft_info *oft_info = xfer->data; | |
1876 GaimConnection *gc = oft_info->sess->aux_data; | |
1877 OscarData *od = gc->proto_data; | |
1878 | |
8660 | 1879 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 1880 |
1881 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
1882 | |
1883 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1884 aim_oft_destroyinfo(oft_info); | |
1885 xfer->data = NULL; | |
1886 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1887 } | |
1888 | |
1889 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
1890 { | |
1891 struct aim_oft_info *oft_info = xfer->data; | |
1892 | |
1893 /* I'm not sure I like how we do this. --marv | |
1894 * I do. AIM file transfers aren't really meant to be thought | |
1895 * of as a transferring just a single file. The rendezvous | |
1896 * establishes a connection between two computers, and then | |
1897 * those computers can use the same connection for transferring | |
1898 * multiple files. So we don't want the Gaim core up and closing | |
1899 * the socket all willy-nilly. We want to do that in the oscar | |
1900 * prpl, whenever one side or the other says they're finished | |
1901 * using the connection. There might be a better way to intercept | |
1902 * the socket from the core, however... --KingAnt | |
1903 */ | |
1904 | |
1905 /* | |
1906 * If we're done sending, intercept the socket from the core ft code | |
1907 * and wait for the other guy to send the "done" OFT packet. | |
1908 */ | |
1909 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
1910 gaim_input_remove(xfer->watcher); | |
1911 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
1912 xfer->fd = 0; | |
1913 gaim_xfer_set_completed(xfer, TRUE); | |
1914 } | |
1915 } | |
1916 | |
9466 | 1917 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
1918 gboolean can_receive = FALSE; | |
1919 OscarData *od = gc->proto_data; | |
1920 | |
1921 if (!od->icq) { | |
1922 aim_userinfo_t *userinfo; | |
1923 userinfo = aim_locate_finduserinfo(od->sess, who); | |
1924 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
1925 can_receive = TRUE; | |
1926 } | |
1927 | |
1928 return can_receive; | |
1929 } | |
1930 | |
1931 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 1932 |
1933 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1934 GaimXfer *xfer; |
5146 | 1935 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
1936 const char *ip; |
3752 | 1937 |
9030 | 1938 od = (OscarData *)gc->proto_data; |
1939 | |
4617 | 1940 /* You want to send a file to someone else, you're so generous */ |
1941 | |
1942 /* Build the file transfer handle */ | |
9466 | 1943 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 1944 |
5146 | 1945 /* Create the oscar-specific data */ |
8838 | 1946 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 1947 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 1948 xfer->data = oft_info; |
1949 | |
4617 | 1950 /* Setup our I/O op functions */ |
8446 | 1951 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 1952 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1953 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 1954 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
1955 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 1956 |
1957 /* Keep track of this transfer for later */ | |
1958 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
1959 | |
1960 /* Now perform the request */ | |
9466 | 1961 if (file) |
1962 gaim_xfer_request_accepted(xfer, file); | |
1963 else | |
1964 gaim_xfer_request(xfer); | |
3630 | 1965 } |
1966 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1967 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 1968 GaimConnection *gc = sess->aux_data; |
7283 | 1969 OscarData *od = gc->proto_data; |
6029 | 1970 GaimAccount *account = gc->account; |
1971 aim_conn_t *bosconn; | |
1972 char *host; int port; | |
1973 int i, rc; | |
2086 | 1974 va_list ap; |
2704 | 1975 struct aim_authresp_info *info; |
6029 | 1976 |
5575 | 1977 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 1978 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1979 va_start(ap, fr); |
2704 | 1980 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 1981 va_end(ap); |
1982 | |
8660 | 1983 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1984 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 1985 |
4293 | 1986 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 1987 char buf[256]; |
2704 | 1988 switch (info->errorcode) { |
2086 | 1989 case 0x05: |
1990 /* Incorrect nick/password */ | |
6498 | 1991 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1992 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 1993 break; |
1994 case 0x11: | |
1995 /* Suspended account */ | |
6498 | 1996 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1997 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 1998 break; |
3498 | 1999 case 0x14: |
2000 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2001 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2002 break; |
2086 | 2003 case 0x18: |
2004 /* connecting too frequently */ | |
6498 | 2005 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2006 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 | 2007 break; |
2008 case 0x1c: | |
2009 /* client too old */ | |
6498 | 2010 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2011 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
|
2012 gaim_connection_error(gc, buf); |
2086 | 2013 break; |
2014 default: | |
6623 | 2015 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2016 break; |
2017 } | |
8660 | 2018 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2019 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2020 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2021 "Error URL: %s\n", info->errorurl); |
2086 | 2022 od->killme = TRUE; |
2023 return 1; | |
2024 } | |
2025 | |
2026 | |
8660 | 2027 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2028 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2029 |
2704 | 2030 if (info->email) { |
8660 | 2031 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2032 } else { |
8660 | 2033 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2034 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2035 |
8660 | 2036 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2037 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2038 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2039 aim_conn_kill(sess, &fr->conn); |
2086 | 2040 |
2041 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2042 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2043 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2044 od->killme = TRUE; |
2045 return 0; | |
2046 } | |
2047 | |
4649 | 2048 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2049 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2050 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2051 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2052 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2053 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2054 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2055 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2056 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2057 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2058 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2059 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2060 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2061 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2062 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2063 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2064 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2065 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2066 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2067 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2068 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2069 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2070 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
|
2071 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2072 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2073 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2074 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2075 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2076 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2077 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
|
2078 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
|
2079 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
|
2080 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2081 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2082 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2083 #ifndef NOSSI |
4642 | 2084 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2085 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2086 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2087 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2088 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2089 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2090 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2091 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2092 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2093 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2094 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2095 |
7283 | 2096 od->conn = bosconn; |
2704 | 2097 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2098 if (info->bosip[i] == ':') { | |
2099 port = atoi(&(info->bosip[i+1])); | |
2086 | 2100 break; |
2101 } | |
2102 } | |
2704 | 2103 host = g_strndup(info->bosip, i); |
2086 | 2104 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2105 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2106 g_free(host); |
4366 | 2107 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2108 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2109 od->killme = TRUE; |
2110 return 0; | |
2111 } | |
4293 | 2112 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2113 gaim_input_remove(gc->inpa); |
2704 | 2114 |
7283 | 2115 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2116 ck[3] = 0x64; |
7282 | 2117 |
2086 | 2118 return 1; |
2119 } | |
2120 | |
7285 | 2121 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2122 struct pieceofcrap { |
5575 | 2123 GaimConnection *gc; |
2086 | 2124 unsigned long offset; |
2125 unsigned long len; | |
2126 char *modname; | |
2127 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2128 aim_conn_t *conn; |
2086 | 2129 unsigned int inpa; |
2130 }; | |
2131 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2132 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2133 { |
2134 struct pieceofcrap *pos = data; | |
7283 | 2135 OscarData *od = pos->gc->proto_data; |
2086 | 2136 char in = '\0'; |
2137 int x = 0; | |
2138 unsigned char m[17]; | |
2139 | |
2140 while (read(pos->fd, &in, 1) == 1) { | |
2141 if (in == '\n') | |
2142 x++; | |
2143 else if (in != '\r') | |
2144 x = 0; | |
2145 if (x == 2) | |
2146 break; | |
2147 in = '\0'; | |
2148 } | |
2149 if (in != '\n') { | |
4056 | 2150 char buf[256]; |
2151 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
|
2152 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2153 gaim_notify_warning(pos->gc, NULL, |
7422 | 2154 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2155 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2156 gaim_input_remove(pos->inpa); |
2086 | 2157 close(pos->fd); |
2158 g_free(pos); | |
2159 return; | |
2160 } | |
2161 read(pos->fd, m, 16); | |
2162 m[16] = '\0'; | |
8660 | 2163 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2164 for (x = 0; x < 16; x++) |
8660 | 2165 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2166 | |
2167 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2168 gaim_input_remove(pos->inpa); |
2086 | 2169 close(pos->fd); |
2170 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2171 g_free(pos); | |
2172 } | |
2173 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2174 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2175 struct pieceofcrap *pos = data; |
5420 | 2176 gchar *buf; |
2086 | 2177 |
4366 | 2178 pos->fd = source; |
2179 | |
2086 | 2180 if (source < 0) { |
5420 | 2181 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
|
2182 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2183 gaim_notify_warning(pos->gc, NULL, |
7422 | 2184 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2185 buf); |
5420 | 2186 g_free(buf); |
2086 | 2187 if (pos->modname) |
2188 g_free(pos->modname); | |
2189 g_free(pos); | |
2190 return; | |
2191 } | |
2192 | |
5420 | 2193 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2194 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2195 write(pos->fd, buf, strlen(buf)); | |
5420 | 2196 g_free(buf); |
2086 | 2197 if (pos->modname) |
2198 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2199 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2200 return; |
2201 } | |
2202 | |
2203 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2204 #define AIM_MAX_FILE_SIZE 98304 | |
2205 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2206 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2207 va_list ap; |
2208 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2209 fu32_t offset, len; |
2086 | 2210 char *modname; |
2211 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2212 va_start(ap, fr); |
4200 | 2213 offset = va_arg(ap, fu32_t); |
2214 len = va_arg(ap, fu32_t); | |
2086 | 2215 modname = va_arg(ap, char *); |
2216 va_end(ap); | |
2217 | |
8660 | 2218 gaim_debug_misc("oscar", |
5556 | 2219 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2220 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2221 |
2086 | 2222 if (len == 0) { |
8660 | 2223 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2224 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2225 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2226 return 1; | |
2227 } | |
9625 | 2228 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2229 #if 0 | |
2086 | 2230 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2231 char *buf; | |
2232 int i = 8; | |
2233 if (modname) | |
2234 i += strlen(modname); | |
2235 buf = g_malloc(i); | |
2236 i = 0; | |
2237 if (modname) { | |
2238 memcpy(buf, modname, strlen(modname)); | |
2239 i += strlen(modname); | |
2240 } | |
2241 buf[i++] = offset & 0xff; | |
2242 buf[i++] = (offset >> 8) & 0xff; | |
2243 buf[i++] = (offset >> 16) & 0xff; | |
2244 buf[i++] = (offset >> 24) & 0xff; | |
2245 buf[i++] = len & 0xff; | |
2246 buf[i++] = (len >> 8) & 0xff; | |
2247 buf[i++] = (len >> 16) & 0xff; | |
2248 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2249 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2250 "hashing request\n"); |
2086 | 2251 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2252 g_free(buf); | |
2253 return 1; | |
2254 } | |
9625 | 2255 #endif |
2086 | 2256 |
2257 pos = g_new0(struct pieceofcrap, 1); | |
2258 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2259 pos->conn = fr->conn; |
2086 | 2260 |
2261 pos->offset = offset; | |
2262 pos->len = len; | |
2263 pos->modname = modname ? g_strdup(modname) : NULL; | |
2264 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2265 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2266 char buf[256]; |
2086 | 2267 if (pos->modname) |
2268 g_free(pos->modname); | |
2269 g_free(pos); | |
4056 | 2270 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
|
2271 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2272 gaim_notify_warning(pos->gc, NULL, |
7422 | 2273 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2274 buf); |
2086 | 2275 } |
2276 | |
2277 return 1; | |
2278 } | |
2279 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2280 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2281 GaimConnection *gc = sess->aux_data; |
7283 | 2282 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2283 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2284 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2285 #if 0 |
2286 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2287 #endif | |
7011 | 2288 va_list ap; |
2289 char *key; | |
2086 | 2290 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2291 va_start(ap, fr); |
2086 | 2292 key = va_arg(ap, char *); |
2293 va_end(ap); | |
2294 | |
4617 | 2295 if (od->icq) { |
3458 | 2296 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2297 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2298 gaim_account_get_password(account), &info, key); |
3458 | 2299 } else { |
2300 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2301 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2302 gaim_account_get_password(account), &info, key); |
3458 | 2303 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2304 |
7283 | 2305 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2306 ck[2] = 0x6c; |
7282 | 2307 |
2086 | 2308 return 1; |
2309 } | |
2310 | |
2675 | 2311 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2312 GaimConnection *gc = sess->aux_data; |
2647 | 2313 struct chat_connection *chatcon; |
2314 static int id = 1; | |
2315 | |
6905 | 2316 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, 0x0001, gaim_parse_genericerr, 0); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2317 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_conv_chat_join, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2318 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_conv_chat_leave, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2319 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_conv_chat_info_update, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2320 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2321 |
2672 | 2322 aim_clientready(sess, fr->conn); |
2675 | 2323 |
2647 | 2324 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2325 chatcon->id = id; | |
8733 | 2326 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2327 |
2328 return 1; | |
2329 } | |
2330 | |
2675 | 2331 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2332 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2333 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2334 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2335 |
2336 aim_clientready(sess, fr->conn); | |
2337 | |
2338 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2339 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2340 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2341 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2342 |
3694 | 2343 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2344 | |
2345 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2346 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2347 | |
7282 | 2348 aim_email_sendcookies(sess); |
2349 aim_email_activate(sess); | |
3694 | 2350 aim_clientready(sess, fr->conn); |
2351 | |
2352 return 1; | |
2353 } | |
2354 | |
4804 | 2355 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2356 GaimConnection *gc = sess->aux_data; |
7283 | 2357 OscarData *od = gc->proto_data; |
4804 | 2358 |
2359 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2360 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2361 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2362 | |
2363 aim_clientready(sess, fr->conn); | |
2364 | |
4823 | 2365 od->iconconnecting = FALSE; |
2366 | |
4804 | 2367 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2368 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2369 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2370 |
2371 return 1; | |
2372 } | |
2373 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2374 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2375 GaimConnection *gc = data; |
7283 | 2376 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2377 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2378 aim_conn_t *tstconn; |
2086 | 2379 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2380 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2381 close(source); |
2382 return; | |
2383 } | |
2384 | |
4617 | 2385 od = gc->proto_data; |
2386 sess = od->sess; | |
2086 | 2387 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2388 tstconn->fd = source; |
2086 | 2389 |
2390 if (source < 0) { | |
2391 aim_conn_kill(sess, &tstconn); | |
8660 | 2392 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2393 "unable to connect to chatnav server\n"); |
2086 | 2394 return; |
2395 } | |
2396 | |
2397 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2398 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2399 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2400 } |
2401 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2402 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2403 { |
5575 | 2404 GaimConnection *gc = data; |
7283 | 2405 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2406 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2407 aim_conn_t *tstconn; |
2086 | 2408 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2409 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2410 close(source); |
2411 return; | |
2412 } | |
2413 | |
4617 | 2414 od = gc->proto_data; |
2415 sess = od->sess; | |
2086 | 2416 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2417 tstconn->fd = source; |
2086 | 2418 |
2419 if (source < 0) { | |
2420 aim_conn_kill(sess, &tstconn); | |
8660 | 2421 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2422 "unable to connect to authorizer\n"); |
2086 | 2423 return; |
2424 } | |
2425 | |
2426 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2427 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2428 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2429 } |
2430 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2431 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2432 { |
2433 struct chat_connection *ccon = data; | |
5575 | 2434 GaimConnection *gc = ccon->gc; |
7283 | 2435 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2436 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2437 aim_conn_t *tstconn; |
2086 | 2438 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2439 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2440 close(source); |
2441 g_free(ccon->show); | |
2442 g_free(ccon->name); | |
2443 g_free(ccon); | |
2444 return; | |
2445 } | |
2446 | |
4617 | 2447 od = gc->proto_data; |
2448 sess = od->sess; | |
2086 | 2449 tstconn = ccon->conn; |
4366 | 2450 tstconn->fd = source; |
2086 | 2451 |
2452 if (source < 0) { | |
2453 aim_conn_kill(sess, &tstconn); | |
2454 g_free(ccon->show); | |
2455 g_free(ccon->name); | |
2456 g_free(ccon); | |
2457 return; | |
2458 } | |
2459 | |
2460 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2461 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2462 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2463 } |
2464 | |
3694 | 2465 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2466 GaimConnection *gc = data; |
7283 | 2467 OscarData *od; |
3694 | 2468 aim_session_t *sess; |
2469 aim_conn_t *tstconn; | |
2470 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2471 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2472 close(source); |
2473 return; | |
2474 } | |
2475 | |
4617 | 2476 od = gc->proto_data; |
2477 sess = od->sess; | |
3694 | 2478 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2479 tstconn->fd = source; |
3694 | 2480 |
2481 if (source < 0) { | |
2482 aim_conn_kill(sess, &tstconn); | |
8660 | 2483 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2484 "unable to connect to email server\n"); |
3694 | 2485 return; |
2486 } | |
2487 | |
2488 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2489 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2490 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2491 "email: connected\n"); |
3694 | 2492 } |
2493 | |
4804 | 2494 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2495 GaimConnection *gc = data; |
7283 | 2496 OscarData *od; |
4804 | 2497 aim_session_t *sess; |
2498 aim_conn_t *tstconn; | |
2499 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2500 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2501 close(source); |
2502 return; | |
2503 } | |
2504 | |
2505 od = gc->proto_data; | |
2506 sess = od->sess; | |
2507 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2508 tstconn->fd = source; | |
2509 | |
2510 if (source < 0) { | |
2511 aim_conn_kill(sess, &tstconn); | |
8660 | 2512 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2513 "unable to connect to icon server\n"); |
4804 | 2514 return; |
2515 } | |
2516 | |
2517 aim_conn_completeconnect(sess, tstconn); | |
2518 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2519 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2520 } |
2521 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2522 /* 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
|
2523 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2524 GaimConnection *gc = sess->aux_data; |
2525 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2526 aim_conn_t *tstconn; |
4452 | 2527 int i; |
2086 | 2528 char *host; |
2529 int port; | |
4821 | 2530 va_list ap; |
2531 struct aim_redirect_data *redir; | |
2086 | 2532 |
5575 | 2533 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2534 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2535 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2536 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2537 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2538 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2539 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2540 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2541 port = atoi(&(redir->ip[i+1])); |
2086 | 2542 break; |
2543 } | |
2544 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2545 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2546 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2547 switch(redir->group) { |
2086 | 2548 case 0x7: /* Authorizer */ |
8660 | 2549 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2550 "Reconnecting with authorizor...\n"); |
2086 | 2551 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2552 if (tstconn == NULL) { | |
8660 | 2553 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2554 "unable to reconnect with authorizer\n"); |
2086 | 2555 g_free(host); |
2556 return 1; | |
2557 } | |
4649 | 2558 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2559 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2560 |
2561 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2562 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2563 aim_conn_kill(sess, &tstconn); |
8660 | 2564 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2565 "unable to reconnect with authorizer\n"); |
2086 | 2566 g_free(host); |
2567 return 1; | |
2568 } | |
4293 | 2569 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2570 break; |
2571 | |
2086 | 2572 case 0xd: /* ChatNav */ |
2573 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2574 if (tstconn == NULL) { | |
8660 | 2575 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2576 "unable to connect to chatnav server\n"); |
2086 | 2577 g_free(host); |
2578 return 1; | |
2579 } | |
4649 | 2580 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2581 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2582 |
2583 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2584 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2585 aim_conn_kill(sess, &tstconn); |
8660 | 2586 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2587 "unable to connect to chatnav server\n"); |
2086 | 2588 g_free(host); |
2589 return 1; | |
2590 } | |
4293 | 2591 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2592 break; |
2593 | |
2594 case 0xe: { /* Chat */ | |
2086 | 2595 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2596 |
2086 | 2597 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2598 if (tstconn == NULL) { | |
8660 | 2599 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2600 "unable to connect to chat server\n"); |
2086 | 2601 g_free(host); |
2602 return 1; | |
2603 } | |
2604 | |
4649 | 2605 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2606 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2607 | |
2086 | 2608 ccon = g_new0(struct chat_connection, 1); |
2609 ccon->conn = tstconn; | |
2610 ccon->gc = gc; | |
2611 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2612 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2613 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2614 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2615 ccon->show = extract_name(redir->chat.room); |
4634 | 2616 |
2086 | 2617 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2618 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2619 aim_conn_kill(sess, &tstconn); |
8660 | 2620 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2621 "unable to connect to chat server\n"); |
2086 | 2622 g_free(host); |
2623 g_free(ccon->show); | |
2624 g_free(ccon->name); | |
2625 g_free(ccon); | |
2626 return 1; | |
2627 } | |
4293 | 2628 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2629 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2630 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2631 ccon->name, ccon->exchange); |
4194 | 2632 } break; |
3694 | 2633 |
4804 | 2634 case 0x0010: { /* icon */ |
2635 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2636 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2637 "unable to connect to icon server\n"); |
4804 | 2638 g_free(host); |
2639 return 1; | |
2640 } | |
2641 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2642 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2643 | |
2644 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2645 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2646 aim_conn_kill(sess, &tstconn); |
8660 | 2647 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2648 "unable to connect to icon server\n"); |
4804 | 2649 g_free(host); |
2650 return 1; | |
2651 } | |
2652 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2653 } break; | |
2654 | |
3694 | 2655 case 0x0018: { /* email */ |
2656 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2657 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2658 "unable to connect to email server\n"); |
3694 | 2659 g_free(host); |
2660 return 1; | |
2661 } | |
4649 | 2662 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2663 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2664 | |
2665 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2666 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2667 aim_conn_kill(sess, &tstconn); |
8660 | 2668 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2669 "unable to connect to email server\n"); |
3694 | 2670 g_free(host); |
2671 return 1; | |
2672 } | |
4293 | 2673 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2674 } break; |
2675 | |
2086 | 2676 default: /* huh? */ |
8660 | 2677 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2678 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2679 redir->group); |
2086 | 2680 break; |
2681 } | |
2682 | |
2683 g_free(host); | |
2684 return 1; | |
2685 } | |
2686 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2687 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2688 GaimConnection *gc = sess->aux_data; |
9058 | 2689 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 2690 OscarData *od = gc->proto_data; |
4738 | 2691 struct buddyinfo *bi; |
2993 | 2692 time_t time_idle = 0, signon = 0; |
2693 int type = 0; | |
2694 int caps = 0; | |
2086 | 2695 va_list ap; |
4738 | 2696 aim_userinfo_t *info; |
4194 | 2697 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2698 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2699 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2700 va_end(ap); |
2701 | |
2993 | 2702 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2703 caps = info->capabilities; | |
3267 | 2704 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
2705 type |= UC_AB; | |
2706 | |
4766 | 2707 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2708 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
2709 type |= UC_UNCONFIRMED; | |
2710 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
2711 type |= UC_ADMIN; | |
2712 if (info->flags & AIM_FLAG_AOL) | |
2713 type |= UC_AOL; | |
2714 if (info->flags & AIM_FLAG_FREE) | |
2715 type |= UC_NORMAL; | |
2716 if (info->flags & AIM_FLAG_AWAY) | |
2717 type |= UC_UNAVAILABLE; | |
2718 if (info->flags & AIM_FLAG_WIRELESS) | |
2719 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2720 } |
2993 | 2721 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2722 type = (info->icqinfo.status << 16); |
3013 | 2723 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2724 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 2725 type |= UC_UNAVAILABLE; |
3013 | 2726 } |
2993 | 2727 } |
2728 | |
7141 | 2729 if (caps & AIM_CAPS_ICQ_DIRECT) |
2730 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2731 |
2732 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2733 time(&time_idle); |
2734 time_idle -= info->idletime*60; | |
9295 | 2735 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2736 } |
2737 | |
5836 | 2738 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2739 signon = info->onlinesince; | |
2740 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2741 signon = time(NULL) - info->sessionlen; |
2086 | 2742 |
5575 | 2743 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
2744 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2745 |
7261 | 2746 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
4738 | 2747 if (!bi) { |
2748 bi = g_new0(struct buddyinfo, 1); | |
7261 | 2749 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
4738 | 2750 } |
4739 | 2751 bi->typingnot = FALSE; |
2752 bi->ico_informed = FALSE; | |
6857 | 2753 bi->ipaddr = info->icqinfo.ipaddr; |
2754 | |
2755 /* Available message stuff */ | |
6292 | 2756 free(bi->availmsg); |
7011 | 2757 if (info->avail != NULL) |
8225 | 2758 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2759 else |
6292 | 2760 bi->availmsg = NULL; |
4732 | 2761 |
4804 | 2762 /* Server stored icon stuff */ |
4853 | 2763 if (info->iconcsumlen) { |
7125 | 2764 const char *filename = NULL, *saved_b16 = NULL; |
2765 char *b16 = NULL; | |
7093 | 2766 GaimBuddy *b = NULL; |
4853 | 2767 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2768 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
4853 | 2769 b = gaim_find_buddy(gc->account, info->sn); |
7093 | 2770 /* |
2771 * If for some reason the checksum is valid, but cached file is not.. | |
2772 * we want to know. | |
2773 */ | |
7693 | 2774 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2775 if (filename != NULL) { |
2776 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2777 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2778 "icon_checksum"); | |
7093 | 2779 } else |
2780 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2781 |
4853 | 2782 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2783 GSList *cur = od->requesticon; | |
2784 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2785 cur = cur->next; | |
2786 if (!cur) { | |
7475 | 2787 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
4853 | 2788 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2789 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2790 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2791 } |
2792 } | |
6053 | 2793 g_free(b16); |
4853 | 2794 } |
2795 | |
9058 | 2796 /* |
2797 * If we have info for ourselves, then update our local warning | |
2798 * level and set our official time of login. Is this necessary? | |
2799 * XXX - This needs to be changed some how. evil should not be | |
2800 * handled by the core at all? | |
2801 */ | |
2802 if (!aim_sncmp(info->sn, gaim_account_get_username(account))) { | |
2803 gc->evil = (info->warnlevel/10.0); | |
2804 gc->login_time_official = signon; | |
2805 } | |
2806 | |
5628 | 2807 serv_got_update(gc, info->sn, 1, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 2808 |
2809 return 1; | |
2810 } | |
2811 | |
8341 | 2812 static void gaim_check_comment(OscarData *od, const char *str) { |
2813 if ((str == NULL) || strcmp(str, ck)) | |
2814 aim_locate_setcaps(od->sess, caps_aim); | |
2815 else | |
2816 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2817 } | |
2818 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2819 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2820 GaimConnection *gc = sess->aux_data; |
7283 | 2821 OscarData *od = gc->proto_data; |
2086 | 2822 va_list ap; |
4739 | 2823 aim_userinfo_t *info; |
2086 | 2824 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2825 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2826 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2827 va_end(ap); |
2828 | |
4732 | 2829 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); |
2086 | 2830 |
7261 | 2831 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 2832 |
2086 | 2833 return 1; |
2834 } | |
2835 | |
4617 | 2836 /* BBB */ |
3952 | 2837 /* |
4617 | 2838 * This is called after a remote AIM user has connected to us. We |
2839 * want to do some voodoo with the socket file descriptors, add a | |
2840 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 2841 */ |
4656 | 2842 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2843 GaimConnection *gc = sess->aux_data; |
7283 | 2844 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2845 GaimXfer *xfer; |
5146 | 2846 struct aim_oft_info *oft_info; |
3630 | 2847 va_list ap; |
2848 aim_conn_t *conn, *listenerconn; | |
4656 | 2849 |
8660 | 2850 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2851 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 2852 va_start(ap, fr); |
2853 conn = va_arg(ap, aim_conn_t *); | |
2854 listenerconn = va_arg(ap, aim_conn_t *); | |
2855 va_end(ap); | |
2856 | |
4617 | 2857 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
2858 return 1; | |
2859 | |
5146 | 2860 if (!(oft_info = xfer->data)) |
4617 | 2861 return 1; |
2862 | |
3630 | 2863 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 2864 gaim_input_remove(xfer->watcher); |
3630 | 2865 aim_conn_kill(sess, &listenerconn); |
2866 | |
5146 | 2867 oft_info->conn = conn; |
2868 xfer->fd = oft_info->conn->fd; | |
2869 | |
2870 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
2871 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
2872 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 2873 |
2874 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 2875 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 2876 |
2877 return 0; | |
2878 } | |
2879 | |
3952 | 2880 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2881 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 2882 * user in order to transfer a file. |
3952 | 2883 */ |
4617 | 2884 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
|
2885 GaimXfer *xfer; |
5146 | 2886 struct aim_oft_info *oft_info; |
4656 | 2887 |
8660 | 2888 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2889 "AAA - in oscar_sendfile_connected\n"); |
4617 | 2890 if (!(xfer = data)) |
2891 return; | |
5146 | 2892 if (!(oft_info = xfer->data)) |
3630 | 2893 return; |
8446 | 2894 if (source < 0) { |
2895 gaim_xfer_cancel_remote(xfer); | |
4617 | 2896 return; |
8446 | 2897 } |
4617 | 2898 |
2899 xfer->fd = source; | |
5146 | 2900 oft_info->conn->fd = source; |
2901 | |
2902 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
2903 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 2904 |
2905 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 2906 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 2907 |
2908 return; | |
3630 | 2909 } |
2910 | |
3952 | 2911 /* |
4617 | 2912 * This is called when a buddy sends us some file info. This happens when they |
2913 * are sending a file to you, and you have just established a connection to them. | |
4650 | 2914 * You should send them the exact same info except use the real cookie. We also |
4617 | 2915 * get like totally ready to like, receive the file, kay? |
3952 | 2916 */ |
4617 | 2917 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2918 GaimConnection *gc = sess->aux_data; |
7283 | 2919 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2920 GaimXfer *xfer; |
5146 | 2921 struct aim_oft_info *oft_info; |
4617 | 2922 va_list ap; |
2923 aim_conn_t *conn; | |
2924 fu8_t *cookie; | |
2925 struct aim_fileheader_t *fh; | |
4656 | 2926 |
8660 | 2927 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2928 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 2929 va_start(ap, fr); |
2930 conn = va_arg(ap, aim_conn_t *); | |
2931 cookie = va_arg(ap, fu8_t *); | |
2932 fh = va_arg(ap, struct aim_fileheader_t *); | |
2933 va_end(ap); | |
2934 | |
2935 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
2936 return 1; | |
2937 | |
5146 | 2938 if (!(oft_info = xfer->data)) |
4617 | 2939 return 1; |
2940 | |
2941 /* We want to stop listening with a normal thingy */ | |
2942 gaim_input_remove(xfer->watcher); | |
2943 xfer->watcher = 0; | |
2944 | |
5146 | 2945 /* They sent us some information about the file they're sending */ |
2946 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
2947 | |
2948 /* Fill in the cookie */ | |
2949 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
2950 | |
4617 | 2951 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 2952 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 2953 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2954 | |
2955 return 0; | |
3630 | 2956 } |
2957 | |
3952 | 2958 /* |
4657 | 2959 * We are sending a file to someone else. They have just acknowledged our |
4617 | 2960 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 2961 */ |
4617 | 2962 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2963 GaimConnection *gc = sess->aux_data; |
7283 | 2964 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2965 GaimXfer *xfer; |
4617 | 2966 va_list ap; |
2967 aim_conn_t *conn; | |
2968 fu8_t *cookie; | |
2969 struct aim_fileheader_t *fh; | |
4656 | 2970 |
8660 | 2971 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 2972 va_start(ap, fr); |
2973 conn = va_arg(ap, aim_conn_t *); | |
2974 cookie = va_arg(ap, fu8_t *); | |
2975 fh = va_arg(ap, struct aim_fileheader_t *); | |
2976 va_end(ap); | |
2977 | |
2978 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
2979 return 1; | |
2980 | |
4656 | 2981 /* We want to stop listening with a normal thingy */ |
2982 gaim_input_remove(xfer->watcher); | |
2983 xfer->watcher = 0; | |
2984 | |
4617 | 2985 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2986 | |
2987 return 0; | |
3630 | 2988 } |
4617 | 2989 |
2990 /* | |
2991 * We just sent a file to someone. They said they got it and everything, | |
2992 * so we can close our direct connection and what not. | |
2993 */ | |
2994 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 2995 GaimConnection *gc = sess->aux_data; |
7283 | 2996 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2997 GaimXfer *xfer; |
4617 | 2998 va_list ap; |
2999 aim_conn_t *conn; | |
3000 fu8_t *cookie; | |
3001 struct aim_fileheader_t *fh; | |
4656 | 3002 |
8660 | 3003 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3004 va_start(ap, fr); |
3005 conn = va_arg(ap, aim_conn_t *); | |
3006 cookie = va_arg(ap, fu8_t *); | |
3007 fh = va_arg(ap, struct aim_fileheader_t *); | |
3008 va_end(ap); | |
3009 | |
3010 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3011 return 1; | |
3012 | |
4656 | 3013 xfer->fd = conn->fd; |
4617 | 3014 gaim_xfer_end(xfer); |
3015 | |
3016 return 0; | |
3017 } | |
3630 | 3018 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3019 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3020 GaimConnection *gc = sess->aux_data; |
7283 | 3021 OscarData *od = gc->proto_data; |
8708 | 3022 GaimAccount *account = gaim_connection_get_account(gc); |
7475 | 3023 gchar *tmp; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3024 GaimConvImFlags flags = 0; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
3025 gsize convlen; |
3659 | 3026 GError *err = NULL; |
4738 | 3027 struct buddyinfo *bi; |
5575 | 3028 const char *iconfile; |
4738 | 3029 |
8708 | 3030 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3031 if (!bi) { |
3032 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3033 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3034 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3035 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3036 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3037 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3038 |
4738 | 3039 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3040 bi->typingnot = TRUE; | |
3041 else | |
3042 bi->typingnot = FALSE; | |
3043 | |
4380 | 3044 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3045 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3046 "%s has an icon\n", userinfo->sn); |
4738 | 3047 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3048 bi->ico_need = TRUE; | |
3049 bi->ico_len = args->iconlen; | |
3050 bi->ico_csum = args->iconsum; | |
3051 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3052 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3053 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3054 |
8708 | 3055 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3056 (args->icbmflags & AIM_IMFLAGS_BUDDYREQ) && !bi->ico_sent && bi->ico_informed) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3057 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3058 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3059 |
5575 | 3060 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3061 char *buf = g_malloc(st.st_size); |
5575 | 3062 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3063 if (file) { |
9532 | 3064 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3065 int len = fread(buf, 1, st.st_size, file); |
8660 | 3066 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3067 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3068 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3069 userinfo->sn, len, st.st_size); |
4617 | 3070 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3071 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3072 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3073 } else |
8660 | 3074 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3075 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3076 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3077 } else |
8660 | 3078 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3079 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3080 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3081 |
8660 | 3082 gaim_debug_misc("oscar", |
8623 | 3083 "Received message from %s with charset %hu %hu\n", |
3084 userinfo->sn, args->charset, args->charsubset); | |
3085 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3086 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
3722 | 3087 /* This message is marked as UNICODE, so we have to |
3088 * convert it to utf-8 before handing it to the gaim core. | |
3089 * This conversion should *never* fail, if it does it | |
3090 * means that either the incoming ICBM is corrupted or | |
4662 | 3091 * there is something we don't understand about it. |
3092 * For the record, AIM Unicode is big-endian UCS-2 */ | |
3093 | |
8660 | 3094 gaim_debug_info("oscar", "Received UNICODE IM\n"); |
4121 | 3095 |
3096 if (!args->msg || !args->msglen) | |
3097 return 1; | |
4641 | 3098 |
3659 | 3099 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
3100 if (err) { | |
8660 | 3101 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3102 "Unicode IM conversion: %s\n", err->message); |
7475 | 3103 tmp = g_strdup(_("(There was an error receiving this message)")); |
4800 | 3104 g_error_free(err); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3105 } |
3722 | 3106 } else { |
3850 | 3107 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 3108 * unflagged messages, which are ASCII. That's OK because |
3109 * ASCII is a strict subset of ISO-8859-1; this should | |
3110 * help with compatibility with old, broken versions of | |
3111 * gaim (everything before 0.60) and other broken clients | |
3112 * that will happily send ISO-8859-1 without marking it as | |
3113 * such */ | |
4662 | 3114 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
8660 | 3115 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3116 "Received ISO-8859-1 IM\n"); |
4121 | 3117 |
3118 if (!args->msg || !args->msglen) | |
3119 return 1; | |
3120 | |
3659 | 3121 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
3122 if (err) { | |
8660 | 3123 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3124 "ISO-8859-1 IM conversion: %s\n", err->message); |
7475 | 3125 tmp = g_strdup(_("(There was an error receiving this message)")); |
4800 | 3126 g_error_free(err); |
3659 | 3127 } |
3642 | 3128 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3129 |
8666 | 3130 /* |
8995 | 3131 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3132 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3133 * so any HTML we receive is intended to be displayed |
3134 * | |
3135 * Note: There *may* be some clients which send messages as HTML formatted - | |
3136 * they need to be special-cased somehow. | |
8666 | 3137 */ |
8995 | 3138 if (isdigit(gaim_account_get_username(account)[0]) && isdigit(userinfo->sn[0])) { |
3139 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ | |
3140 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3141 g_free(tmp); |
3142 tmp = tmp2; | |
3143 } | |
3144 | |
6982 | 3145 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3146 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3147 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3148 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3149 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3150 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3151 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3152 GaimConnection *gc; |
3153 OscarData *od; | |
3154 const char *username; | |
3155 | |
3156 g_return_val_if_fail(sess != NULL, 0); | |
3157 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3158 | |
3159 gc = sess->aux_data; | |
3160 od = gc->proto_data; | |
3161 username = gaim_account_get_username(gaim_connection_get_account(gc)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3162 |
4121 | 3163 if (!args) |
3164 return 0; | |
4194 | 3165 |
8660 | 3166 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3167 "rendezvous with %s, status is %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3168 userinfo->sn, args->status); |
2869 | 3169 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3170 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3171 char *name; |
5234 | 3172 GHashTable *components; |
3173 | |
4121 | 3174 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
3175 return 1; | |
5234 | 3176 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3177 g_free); | |
4121 | 3178 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3179 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3180 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
|
3181 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3182 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3183 userinfo->sn, |
6059 | 3184 args->msg, |
5234 | 3185 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3186 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3187 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3188 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3189 /* BBB */ |
3190 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3191 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3192 GaimXfer *xfer; |
5146 | 3193 struct aim_oft_info *oft_info; |
3194 | |
3195 if (!args->cookie || !args->port || !args->verifiedip || | |
3196 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3197 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3198 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3199 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3200 "information.\n", userinfo->sn); |
5146 | 3201 if (args->proxyip) |
8660 | 3202 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3203 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3204 "does not support this yet.\n"); |
4617 | 3205 return 1; |
4656 | 3206 } |
4617 | 3207 |
3208 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3209 /* last char of the ft req is a star, they are sending us a | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3210 * directory -- remove the star and trailing slash so we don't save |
4617 | 3211 * directories that look like 'dirname\*' -- arl */ |
3212 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3213 if (tmp && (tmp[1] == '*')) { | |
3214 tmp[0] = '\0'; | |
3215 } | |
8660 | 3216 gaim_debug_warning("oscar", |
8446 | 3217 "We're receiving a whole directory! What fun! " |
3218 "Especially since we don't support that!\n"); | |
4617 | 3219 } |
3220 | |
3221 /* Build the file transfer handle */ | |
3222 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3223 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3224 xfer->remote_port = args->port; |
4617 | 3225 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3226 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
5146 | 3227 |
3228 /* Create the oscar-specific data */ | |
5163 | 3229 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3230 if (args->proxyip) |
5146 | 3231 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3232 if (args->verifiedip) |
5146 | 3233 oft_info->verifiedip = g_strdup(args->verifiedip); |
3234 xfer->data = oft_info; | |
4617 | 3235 |
3236 /* Setup our I/O op functions */ | |
8446 | 3237 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3238 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3239 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_recv); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
3240 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3241 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3242 |
3243 /* | |
3244 * XXX - Should do something with args->msg, args->encoding, and args->language | |
3245 * probably make it apply to all ch2 messages. | |
3752 | 3246 */ |
4617 | 3247 |
3248 /* Keep track of this transfer for later */ | |
3249 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3250 | |
3251 /* Now perform the request */ | |
3252 gaim_xfer_request(xfer); | |
3253 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3254 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3255 GaimXfer *xfer; |
8660 | 3256 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3257 "AAA - File transfer canceled by remote user\n"); |
4617 | 3258 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
|
3259 gaim_xfer_cancel_remote(xfer); |
4617 | 3260 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3261 /* | |
3262 * This gets sent by the receiver of a file | |
3263 * as they connect directly to us. If we don't | |
3264 * get this, then maybe a third party connected | |
3265 * to us, and we shouldn't send them anything. | |
3266 */ | |
3267 } else { | |
8660 | 3268 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3269 "unknown rendezvous status!\n"); |
3630 | 3270 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3271 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3272 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3273 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3274 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3275 userinfo->sn, args->info.icon.icon, |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3276 args->info.icon.length); |
6871 | 3277 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3278 /* Consider moving all this into a helper func in the direct im block way up there */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3279 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3280 struct oscar_direct_im *dim = oscar_direct_im_find(od, userinfo->sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3281 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3282 |
4212 | 3283 if (!args->verifiedip) { |
8983 | 3284 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3285 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3286 "directim kill blocked (%s)\n", userinfo->sn); |
4650 | 3287 return 1; |
4212 | 3288 } |
3289 | |
8660 | 3290 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3291 "%s received direct im request from %s (%s)\n", |
8983 | 3292 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3293 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3294 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3295 d->sn = g_strdup(userinfo->sn); |
8983 | 3296 /* Let's use the clientip here, because I think that's what AIM does. |
3297 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3298 * and then ask them to connect to us. */ | |
3299 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->clientip, args->port?args->port:5190); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3300 memcpy(d->cookie, args->cookie, 8); |
9070 | 3301 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3302 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3303 | |
8971 | 3304 oscar_direct_im_destroy(od, dim); |
8984 | 3305 d->donttryagain = TRUE; |
8971 | 3306 accept_direct_im_request(d); |
3307 } else { | |
8983 | 3308 if (dim && !dim->connected) |
8971 | 3309 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3310 "already connected to that buddy!"); | |
5575 | 3311 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
|
3312 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3313 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3314 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3315 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3316 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3317 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3318 "risk."), 0, d, 2, |
8971 | 3319 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3320 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3321 /* FIXME: we should actually send a packet on cancel */ | |
3322 } | |
8708 | 3323 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3324 gaim_debug_error("oscar", "Got an ICQ Server Relay message of type %d\n", args->info.rtfmsg.msgtype); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3325 } else { |
8660 | 3326 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3327 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3328 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3329 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3330 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3331 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3332 |
3453 | 3333 /* |
4230 | 3334 * Authorization Functions |
3335 * Most of these are callbacks from dialogs. They're used by both | |
3336 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3337 */ |
4269 | 3338 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3339 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3340 GaimConnection *gc = data->gc; |
4244 | 3341 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3342 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3343 OscarData *od = gc->proto_data; |
6695 | 3344 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3345 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3346 if (buddy && group) { |
8660 | 3347 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3348 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3349 buddy->name, group->name); |
4889 | 3350 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3351 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3352 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3353 } |
4230 | 3354 } |
4337 | 3355 } |
3356 | |
3357 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3358 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3359 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3360 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3361 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3362 data); |
4230 | 3363 } |
3364 | |
3365 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3366 GaimConnection *gc = data->gc; |
4244 | 3367 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3368 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3369 /* Remove from local list */ |
3370 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3371 gaim_blist_remove_buddy(b); | |
4244 | 3372 } |
3373 | |
5836 | 3374 oscar_free_name_data(data); |
4230 | 3375 } |
3376 | |
9030 | 3377 |
3378 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3379 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3380 GaimBuddy *buddy; |
4269 | 3381 gchar *dialog_msg, *nombre; |
3382 | |
4687 | 3383 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3384 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3385 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3386 else |
4830 | 3387 nombre = NULL; |
3388 | |
3389 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 | 3390 data->gc = gc; |
3391 data->name = g_strdup(name); | |
3392 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3393 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3394 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3395 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3396 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3397 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3398 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3399 |
3400 g_free(dialog_msg); | |
3401 g_free(nombre); | |
3402 } | |
3403 | |
9030 | 3404 |
3405 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3406 GaimBuddy *buddy; | |
3407 GaimConnection *gc; | |
3408 | |
3409 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3410 | |
3411 buddy = (GaimBuddy *) node; | |
3412 gc = gaim_account_get_connection(buddy->account); | |
3413 gaim_auth_sendrequest(gc, buddy->name); | |
3414 } | |
3415 | |
4230 | 3416 /* When other people ask you for authorization */ |
3417 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3418 GaimConnection *gc = data->gc; |
4244 | 3419 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3420 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3421 OscarData *od = gc->proto_data; |
4236 | 3422 #ifdef NOSSI |
6695 | 3423 GaimBuddy *buddy; |
4244 | 3424 gchar message; |
3425 message = 0; | |
4687 | 3426 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3427 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3428 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3429 #else |
4889 | 3430 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3431 #endif |
4244 | 3432 } |
3433 | |
5836 | 3434 oscar_free_name_data(data); |
3141 | 3435 } |
3436 | |
4230 | 3437 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3438 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3439 GaimConnection *gc = data->gc; |
4244 | 3440 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3441 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3442 OscarData *od = gc->proto_data; |
4230 | 3443 #ifdef NOSSI |
4617 | 3444 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3445 #else |
4889 | 3446 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3447 #endif |
4244 | 3448 } |
4337 | 3449 } |
3450 | |
3451 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3452 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3453 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3454 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3455 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3456 data); |
3141 | 3457 } |
3458 | |
7023 | 3459 /* When someone sends you buddies */ |
3460 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3461 GaimConnection *gc = data->gc; |
4244 | 3462 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3463 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3464 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3465 } |
3466 | |
5836 | 3467 oscar_free_name_data(data); |
3453 | 3468 } |
3469 | |
4075 | 3470 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 | 3471 GaimConnection *gc = sess->aux_data; |
4076 | 3472 gchar **msg1, **msg2; |
3473 GError *err = NULL; | |
6051 | 3474 int i, numtoks; |
4076 | 3475 |
4121 | 3476 if (!args->type || !args->msg || !args->uin) |
3477 return 1; | |
4194 | 3478 |
8660 | 3479 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3480 "Received a channel 4 message of type 0x%02hhx.\n", args->type); |
4076 | 3481 |
3482 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 3483 msg1 = g_strsplit(args->msg, "\376", 0); |
6051 | 3484 for (numtoks=0; msg1[numtoks]; numtoks++); |
3485 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3486 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3487 gaim_str_strip_cr(msg1[i]); |
4076 | 3488 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); |
4800 | 3489 if (err) { |
8660 | 3490 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3491 "Error converting a string from ISO-8859-1 to " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3492 "UTF-8 in oscar ICBM channel 4 parsing\n"); |
4800 | 3493 g_error_free(err); |
3494 } | |
4076 | 3495 } |
3496 msg2[i] = NULL; | |
3497 | |
3952 | 3498 switch (args->type) { |
4173 | 3499 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3500 if (i >= 1) { |
5556 | 3501 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3502 gchar *tmp; |
3503 | |
3504 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3505 tmp = gaim_escape_html(msg2[0]); |
8493 | 3506 |
4076 | 3507 if (t) { /* This is an offline message */ |
3508 /* I think this timestamp is in UTC, or something */ | |
8514 | 3509 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3510 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3511 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3512 } |
3513 g_free(uin); | |
8493 | 3514 g_free(tmp); |
4075 | 3515 } |
3316 | 3516 } break; |
3517 | |
4173 | 3518 case 0x04: { /* Someone sent you a URL */ |
4076 | 3519 if (i >= 2) { |
7385 | 3520 if (msg2[1] != NULL) { |
3521 gchar *uin = g_strdup_printf("%u", args->uin); | |
3522 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3523 msg2[1], | |
3524 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3525 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3526 g_free(uin); | |
3527 g_free(message); | |
3528 } | |
3453 | 3529 } |
3530 } break; | |
3531 | |
4173 | 3532 case 0x06: { /* Someone requested authorization */ |
4076 | 3533 if (i >= 6) { |
4230 | 3534 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3535 gchar *dialog_msg = g_strdup_printf(_("The user %u wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); |
8660 | 3536 gaim_debug_info("oscar", |
5556 | 3537 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3538 args->uin); |
4076 | 3539 data->gc = gc; |
5556 | 3540 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3541 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3542 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3543 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3544 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3545 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3546 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3547 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3548 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3549 g_free(dialog_msg); |
3550 } | |
3141 | 3551 } break; |
3552 | |
4173 | 3553 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3554 if (i >= 1) { |
7023 | 3555 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
|
3556 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3557 dialog_msg); |
4076 | 3558 g_free(dialog_msg); |
3559 } | |
3141 | 3560 } break; |
3561 | |
4173 | 3562 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3563 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
|
3564 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3565 dialog_msg); |
3141 | 3566 g_free(dialog_msg); |
3567 } break; | |
3568 | |
4333 | 3569 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3570 if (i >= 5) { | |
3571 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
|
3572 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3573 g_free(dialog_msg); |
3574 } | |
3575 } break; | |
3576 | |
4173 | 3577 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3578 if (i >= 6) { |
4194 | 3579 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
|
3580 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3581 g_free(dialog_msg); |
3582 } | |
4075 | 3583 } break; |
3584 | |
4173 | 3585 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3586 if (i >= 6) { |
4308 | 3587 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
|
3588 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3589 g_free(dialog_msg); |
3590 } | |
4075 | 3591 } break; |
3592 | |
4173 | 3593 case 0x12: { |
3141 | 3594 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3595 /* Someone added you to their buddy list? */ |
3141 | 3596 } break; |
3597 | |
7023 | 3598 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3599 guint i, num; |
3453 | 3600 gchar **text; |
4173 | 3601 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3602 if (text) { |
3603 num = 0; | |
3604 for (i=0; i<strlen(text[0]); i++) | |
3605 num = num*10 + text[0][i]-48; | |
3606 for (i=0; i<num; i++) { | |
4230 | 3607 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3608 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 | 3609 data->gc = gc; |
4790 | 3610 data->name = g_strdup(text[i*2+1]); |
3611 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3612 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3613 gaim_request_action(gc, NULL, message, |
7023 | 3614 _("Do you want to add this buddy " |
3615 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3616 0, data, 2, |
7023 | 3617 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3618 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3619 g_free(message); |
3620 } | |
3621 g_strfreev(text); | |
3622 } | |
3623 } break; | |
3624 | |
7023 | 3625 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3626 /* This is boring and silly. */ |
3627 } break; | |
3628 | |
3141 | 3629 default: { |
8660 | 3630 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3631 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3632 "(type 0x%02hhx).\n", args->type); |
3141 | 3633 } break; |
3634 } | |
3635 | |
4076 | 3636 g_strfreev(msg1); |
3637 g_strfreev(msg2); | |
3638 | |
3141 | 3639 return 1; |
3640 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3641 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3642 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3643 fu16_t channel; |
3644 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3645 aim_userinfo_t *userinfo; |
2086 | 3646 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3647 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3648 va_start(ap, fr); |
4200 | 3649 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3650 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3651 |
3141 | 3652 switch (channel) { |
3653 case 1: { /* standard message */ | |
3654 struct aim_incomingim_ch1_args *args; | |
3655 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3656 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3657 } break; | |
3658 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3659 case 2: { /* rendezvous */ |
3141 | 3660 struct aim_incomingim_ch2_args *args; |
3661 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3662 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3663 } break; | |
3664 | |
3665 case 4: { /* ICQ */ | |
3666 struct aim_incomingim_ch4_args *args; | |
3667 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3668 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3669 } break; |
3670 | |
3671 default: { | |
8660 | 3672 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3673 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3674 "0x%04hx).", channel); |
3141 | 3675 } break; |
2086 | 3676 } |
3677 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3678 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3679 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3680 return ret; |
2086 | 3681 } |
3682 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3683 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3684 GaimConnection *gc = sess->aux_data; |
3685 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3686 char *buf; |
2086 | 3687 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3688 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3689 aim_userinfo_t *userinfo; |
2086 | 3690 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3691 va_start(ap, fr); |
4200 | 3692 chan = (fu16_t)va_arg(ap, unsigned int); |
3693 userinfo = va_arg(ap, aim_userinfo_t *); | |
3694 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3695 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3696 va_end(ap); |
3697 | |
3698 switch(reason) { | |
5420 | 3699 case 0: /* Invalid (0) */ |
3700 buf = g_strdup_printf( | |
3701 ngettext( | |
4276 | 3702 "You missed %hu message from %s because it was invalid.", |
3703 "You missed %hu messages from %s because they were invalid.", | |
3704 nummissed), | |
4282 | 3705 nummissed, |
3706 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3707 break; |
5420 | 3708 case 1: /* Message too large */ |
3709 buf = g_strdup_printf( | |
3710 ngettext( | |
4276 | 3711 "You missed %hu message from %s because it was too large.", |
3712 "You missed %hu messages from %s because they were too large.", | |
3713 nummissed), | |
4282 | 3714 nummissed, |
3715 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3716 break; |
5420 | 3717 case 2: /* Rate exceeded */ |
3718 buf = g_strdup_printf( | |
3719 ngettext( | |
4276 | 3720 "You missed %hu message from %s because the rate limit has been exceeded.", |
3721 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3722 nummissed), | |
4282 | 3723 nummissed, |
3724 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3725 break; |
5420 | 3726 case 3: /* Evil Sender */ |
3727 buf = g_strdup_printf( | |
3728 ngettext( | |
4276 | 3729 "You missed %hu message from %s because he/she was too evil.", |
3730 "You missed %hu messages from %s because he/she was too evil.", | |
3731 nummissed), | |
4282 | 3732 nummissed, |
3733 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3734 break; |
5420 | 3735 case 4: /* Evil Receiver */ |
3736 buf = g_strdup_printf( | |
3737 ngettext( | |
4276 | 3738 "You missed %hu message from %s because you are too evil.", |
3739 "You missed %hu messages from %s because you are too evil.", | |
3740 nummissed), | |
4282 | 3741 nummissed, |
3742 userinfo->sn); | |
2086 | 3743 break; |
3744 default: | |
5420 | 3745 buf = g_strdup_printf( |
3746 ngettext( | |
4276 | 3747 "You missed %hu message from %s for an unknown reason.", |
3748 "You missed %hu messages from %s for an unknown reason.", | |
3749 nummissed), | |
4282 | 3750 nummissed, |
3751 userinfo->sn); | |
2086 | 3752 break; |
3753 } | |
8733 | 3754 |
9627 | 3755 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3756 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3757 g_free(buf); |
2086 | 3758 |
3759 return 1; | |
3760 } | |
3761 | |
4194 | 3762 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3763 GaimConnection *gc = sess->aux_data; |
7283 | 3764 OscarData *od = gc->proto_data; |
4617 | 3765 |
3766 /* BBB */ | |
3630 | 3767 switch (reason) { |
4151 | 3768 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3769 GaimXfer *xfer; |
8971 | 3770 struct oscar_direct_im *dim; |
3771 | |
8660 | 3772 gaim_debug_info("oscar", |
9070 | 3773 "AAA - Other user declined some sort of direct " |
8971 | 3774 "connect attempt (automaticly?)\n"); |
4617 | 3775 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
|
3776 gaim_xfer_cancel_remote(xfer); |
8971 | 3777 else if ((dim = oscar_direct_im_find(od, who))) { |
3778 /* AAA should use find by cookie or something here */ | |
3779 oscar_direct_im_disconnect(od, dim); | |
3780 } | |
4151 | 3781 } break; |
3782 | |
3783 default: { | |
8660 | 3784 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3785 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3786 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3787 } |
3630 | 3788 |
3789 } | |
3790 | |
3791 return 0; | |
3792 } | |
3793 | |
4194 | 3794 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3795 GaimConnection *gc = sess->aux_data; |
4151 | 3796 |
3797 switch(reason) { | |
3798 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3799 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3800 | |
3801 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3802 |
3803 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3804 statusmsg = oscar_icqstatus(state); |
4151 | 3805 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3806 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3807 g_free(statusmsg); | |
4151 | 3808 g_strfreev(splitmsg); |
9244 | 3809 |
3810 gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); | |
3811 | |
3812 g_free(title); | |
3813 g_free(dialogmsg); | |
4151 | 3814 } break; |
3815 | |
3816 default: { | |
8660 | 3817 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3818 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3819 "Type 0x%04hx\n", who, reason); |
4151 | 3820 } break; |
3821 } /* end of switch */ | |
3822 | |
3823 return 0; | |
3824 } | |
3825 | |
3212 | 3826 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
3827 va_list ap; | |
3828 fu16_t chan, reason; | |
3829 char *who; | |
3830 | |
3831 va_start(ap, fr); | |
4200 | 3832 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3833 who = va_arg(ap, char *); |
4200 | 3834 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3835 |
3952 | 3836 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 3837 char *cookie = va_arg(ap, char *); |
4151 | 3838 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 3839 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 3840 fu32_t state = 0; |
4151 | 3841 char *msg = NULL; |
3842 if (reason == 0x0003) { | |
4200 | 3843 state = va_arg(ap, fu32_t); |
4151 | 3844 msg = va_arg(ap, char *); |
3845 } | |
3846 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
3847 } | |
3952 | 3848 |
3212 | 3849 va_end(ap); |
3850 | |
3851 return 1; | |
3852 } | |
3853 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3854 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3855 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3856 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3857 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3858 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3859 va_start(ap, fr); |
4199 | 3860 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3861 va_end(ap); |
3862 | |
8660 | 3863 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3864 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3865 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 3866 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3867 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 3868 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3869 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3870 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3871 |
2086 | 3872 return 1; |
3873 } | |
3874 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3875 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 3876 GaimConnection *gc = sess->aux_data; |
4617 | 3877 #if 0 |
7283 | 3878 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3879 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3880 #endif |
4617 | 3881 va_list ap; |
3882 fu16_t reason; | |
3883 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3884 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3885 va_start(ap, fr); |
4617 | 3886 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 3887 data = va_arg(ap, char *); |
2086 | 3888 va_end(ap); |
3889 | |
8660 | 3890 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3891 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 3892 |
3893 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3894 #if 0 |
4617 | 3895 /* If this was a file transfer request, data is a cookie */ |
3896 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
|
3897 gaim_xfer_cancel_remote(xfer); |
3630 | 3898 return 1; |
3899 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3900 #endif |
3630 | 3901 |
4617 | 3902 /* Data is assumed to be the destination sn */ |
9627 | 3903 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), |
3904 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Your message did not get sent."))) { | |
3905 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); | |
3906 gaim_notify_error(sess->aux_data, NULL, buf, | |
3907 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3908 g_free(buf); | |
3909 } | |
2086 | 3910 return 1; |
3911 } | |
3912 | |
3595 | 3913 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3914 GaimConnection *gc = sess->aux_data; |
3595 | 3915 va_list ap; |
3916 fu16_t type1, type2; | |
3917 char *sn; | |
3918 | |
3919 va_start(ap, fr); | |
4199 | 3920 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3921 sn = va_arg(ap, char *); |
4199 | 3922 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3923 va_end(ap); |
3924 | |
3925 switch (type2) { | |
3926 case 0x0000: { /* Text has been cleared */ | |
3927 serv_got_typing_stopped(gc, sn); | |
3928 } break; | |
3929 | |
3930 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3931 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 3932 } break; |
3933 | |
3934 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3935 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 3936 } break; |
3937 | |
3938 default: { | |
8660 | 3939 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 | 3940 } break; |
3941 } | |
3942 | |
3943 return 1; | |
3944 } | |
3945 | |
7141 | 3946 /* |
3947 * We get this error when there was an error in the locate family. This | |
7259 | 3948 * happens when you request info of someone who is offline. |
7141 | 3949 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3950 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 3951 gchar *buf, *cbuf; |
2086 | 3952 va_list ap; |
5420 | 3953 fu16_t reason; |
2086 | 3954 char *destn; |
3955 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3956 va_start(ap, fr); |
4199 | 3957 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3958 destn = va_arg(ap, char *); |
3959 va_end(ap); | |
3960 | |
7781 | 3961 if (destn == NULL) |
7793 | 3962 return 1; |
9627 | 3963 |
3964 cbuf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3965 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), cbuf)) { | |
3966 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); | |
3967 gaim_notify_error(sess->aux_data, NULL, buf, | |
3968 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3969 g_free(buf); | |
3970 } | |
3971 g_free(cbuf); | |
2086 | 3972 |
3973 return 1; | |
3974 } | |
3975 | |
7011 | 3976 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3977 GaimConnection *gc = sess->aux_data; |
8700 | 3978 GaimAccount *account = gaim_connection_get_account(gc); |
3979 GString *str; | |
9244 | 3980 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 3981 va_list ap; |
7011 | 3982 aim_userinfo_t *userinfo; |
2086 | 3983 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3984 va_start(ap, fr); |
7011 | 3985 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3986 va_end(ap); |
3987 | |
8700 | 3988 str = g_string_new(""); |
3989 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
3990 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 3991 |
3992 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 3993 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 3994 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 3995 |
3996 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 3997 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 3998 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 3999 |
4000 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4001 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4002 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4003 g_free(tmp); |
4004 } | |
4005 | |
8701 | 4006 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4007 |
4008 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4009 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4010 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4011 g_free(tmp); | |
7011 | 4012 if (away_utf8 != NULL) { |
8700 | 4013 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4014 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4015 } |
7011 | 4016 } |
4017 | |
4018 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4019 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4020 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4021 g_free(tmp); | |
7011 | 4022 if (info_utf8 != NULL) { |
8700 | 4023 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4024 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4025 } |
7011 | 4026 } |
4027 | |
8701 | 4028 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4029 g_string_free(str, TRUE); |
9244 | 4030 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
4031 gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, tmp, NULL, NULL); | |
4032 g_free(title); | |
8700 | 4033 g_free(tmp); |
4151 | 4034 |
2086 | 4035 return 1; |
4036 } | |
4037 | |
8341 | 4038 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4039 { | |
4040 aim_session_t *sess = data; | |
4041 GaimConnection *gc = sess->aux_data; | |
4042 OscarData *od = (OscarData *)gc->proto_data; | |
4043 | |
4044 aim_locate_dorequest(data); | |
4045 od->getinfotimer = 0; | |
4046 | |
4047 return FALSE; | |
4048 } | |
4049 | |
4050 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4051 { | |
4052 GaimConnection *gc = sess->aux_data; | |
4053 OscarData *od = (OscarData *)gc->proto_data; | |
4054 | |
4055 /* | |
4056 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4057 * us from hitting the rate limit due to request away messages and info | |
4058 * too quickly. | |
4059 */ | |
4060 if (od->getinfotimer == 0) | |
4061 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4062 | |
4063 return 1; | |
4064 } | |
4065 | |
4066 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4067 { | |
2086 | 4068 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4069 fu16_t id; |
2086 | 4070 va_list ap; |
4071 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4072 va_start(ap, fr); |
4199 | 4073 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4074 msg = va_arg(ap, char *); |
4075 va_end(ap); | |
4076 | |
8660 | 4077 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4078 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4079 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4080 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4081 _("Your AIM connection may be lost."), NULL); |
2086 | 4082 |
4083 return 1; | |
4084 } | |
4085 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4086 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4087 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4088 fu16_t type; |
5575 | 4089 GaimConnection *gc = sess->aux_data; |
7283 | 4090 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4091 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4092 va_start(ap, fr); |
4199 | 4093 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4094 |
4095 switch(type) { | |
4096 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4097 fu8_t maxrooms; |
2086 | 4098 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4099 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4100 |
4199 | 4101 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4102 exchangecount = va_arg(ap, int); |
4103 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4104 | |
8660 | 4105 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4106 "chat info: Chat Rights:\n"); |
8660 | 4107 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4108 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4109 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4110 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4111 for (i = 0; i < exchangecount; i++) |
8660 | 4112 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4113 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4114 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4115 while (od->create_rooms) { |
4116 struct create_room *cr = od->create_rooms->data; | |
8660 | 4117 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4118 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4119 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4120 g_free(cr->name); |
4617 | 4121 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4122 g_free(cr); |
2086 | 4123 } |
4124 } | |
4125 break; | |
4126 case 0x0008: { | |
4127 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4128 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4129 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4130 fu32_t createtime; |
2086 | 4131 |
4132 fqcn = va_arg(ap, char *); | |
4200 | 4133 instance = (fu16_t)va_arg(ap, unsigned int); |
4134 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4135 flags = (fu16_t)va_arg(ap, unsigned int); | |
4136 createtime = va_arg(ap, fu32_t); | |
4137 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4138 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4139 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4140 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4141 name = va_arg(ap, char *); | |
4142 ck = va_arg(ap, char *); | |
4194 | 4143 |
8660 | 4144 gaim_debug_misc("oscar", |
5556 | 4145 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4146 fqcn, |
4147 exchange, instance, flags, | |
4148 createtime, | |
4149 maxmsglen, maxoccupancy, createperms, unknown, | |
4150 name, ck); | |
4617 | 4151 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4152 } |
4153 break; | |
4154 default: | |
8660 | 4155 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4156 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4157 break; |
4158 } | |
4194 | 4159 |
4160 va_end(ap); | |
4161 | |
2086 | 4162 return 1; |
4163 } | |
4164 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4165 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4166 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4167 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4168 aim_userinfo_t *info; |
5575 | 4169 GaimConnection *g = sess->aux_data; |
2086 | 4170 |
4171 struct chat_connection *c = NULL; | |
4172 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4173 va_start(ap, fr); |
2086 | 4174 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4175 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4176 va_end(ap); |
4177 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4178 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4179 if (!c) |
4180 return 1; | |
4181 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4182 for (i = 0; i < count; i++) |
9554 | 4183 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE); |
2086 | 4184 |
4185 return 1; | |
4186 } | |
4187 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4188 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4189 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4190 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4191 aim_userinfo_t *info; |
5575 | 4192 GaimConnection *g = sess->aux_data; |
2086 | 4193 |
4194 struct chat_connection *c = NULL; | |
4195 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4196 va_start(ap, fr); |
2086 | 4197 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4198 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4199 va_end(ap); |
4200 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4201 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4202 if (!c) |
4203 return 1; | |
4204 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4205 for (i = 0; i < count; i++) |
8733 | 4206 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4207 |
4208 return 1; | |
4209 } | |
4210 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4211 static int gaim_conv_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4212 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4213 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4214 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4215 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4216 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4217 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4218 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4219 fu32_t creationtime; |
5575 | 4220 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4221 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
|
4222 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4223 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4224 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4225 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4226 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4227 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4228 roomdesc = va_arg(ap, char *); |
4200 | 4229 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4230 creationtime = va_arg(ap, fu32_t); | |
4231 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4232 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4233 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4234 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4235 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4236 |
8660 | 4237 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4238 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4239 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4240 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4241 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4242 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4243 |
2086 | 4244 return 1; |
4245 } | |
4246 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4247 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4248 GaimConnection *gc = sess->aux_data; |
8225 | 4249 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4250 gchar *utf8; | |
2086 | 4251 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4252 aim_userinfo_t *info; |
8225 | 4253 int len; |
2086 | 4254 char *msg; |
8219 | 4255 char *charset; |
2086 | 4256 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4257 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4258 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4259 len = va_arg(ap, int); |
4194 | 4260 msg = va_arg(ap, char *); |
8219 | 4261 charset = va_arg(ap, char *); |
4194 | 4262 va_end(ap); |
2086 | 4263 |
8225 | 4264 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4265 if (utf8 == NULL) |
4266 /* The conversion failed! */ | |
8668 | 4267 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4268 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4269 g_free(utf8); | |
2086 | 4270 |
4271 return 1; | |
4272 } | |
4273 | |
3694 | 4274 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4275 va_list ap; | |
5575 | 4276 GaimConnection *gc = sess->aux_data; |
3694 | 4277 struct aim_emailinfo *emailinfo; |
3725 | 4278 int havenewmail; |
7297 | 4279 char *alertitle, *alerturl; |
3694 | 4280 |
4281 va_start(ap, fr); | |
4282 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4283 havenewmail = va_arg(ap, int); |
7301 | 4284 alertitle = va_arg(ap, char *); |
4285 alerturl = va_arg(ap, char *); | |
3694 | 4286 va_end(ap); |
4287 | |
5628 | 4288 if (emailinfo && gaim_account_get_check_mail(gc->account)) { |
5575 | 4289 gchar *to = g_strdup_printf("%s@%s", gaim_account_get_username(gaim_connection_get_account(gc)), emailinfo->domain); |
5542 | 4290 if (emailinfo->unread && havenewmail) |
4291 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4292 g_free(to); |
3694 | 4293 } |
7297 | 4294 |
7301 | 4295 if (alertitle) |
8660 | 4296 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4297 |
4298 return 1; | |
4299 } | |
4300 | |
4804 | 4301 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4302 GaimConnection *gc = sess->aux_data; |
7283 | 4303 OscarData *od = gc->proto_data; |
4804 | 4304 char *sn; |
4305 | |
4306 sn = od->requesticon->data; | |
8660 | 4307 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4308 "removing %s from hash table\n", sn); |
4804 | 4309 od->requesticon = g_slist_remove(od->requesticon, sn); |
4310 free(sn); | |
4311 | |
4312 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4313 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4314 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4315 |
4316 return 1; | |
4317 } | |
4318 | |
4319 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4320 GaimConnection *gc = sess->aux_data; |
7283 | 4321 OscarData *od = gc->proto_data; |
4804 | 4322 GSList *cur; |
4323 va_list ap; | |
4324 char *sn; | |
4853 | 4325 fu8_t *iconcsum, *icon; |
4326 fu16_t iconcsumlen, iconlen; | |
4804 | 4327 |
4328 va_start(ap, fr); | |
4329 sn = va_arg(ap, char *); | |
4853 | 4330 iconcsum = va_arg(ap, fu8_t *); |
4331 iconcsumlen = va_arg(ap, int); | |
4804 | 4332 icon = va_arg(ap, fu8_t *); |
4333 iconlen = va_arg(ap, int); | |
4334 va_end(ap); | |
4335 | |
4853 | 4336 if (iconlen > 0) { |
4337 char *b16; | |
6695 | 4338 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4339 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4340 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4341 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4342 if (b16) { |
7693 | 4343 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4344 g_free(b16); |
5129 | 4345 } |
4853 | 4346 } |
4804 | 4347 |
4348 cur = od->requesticon; | |
4349 while (cur) { | |
4350 char *cursn = cur->data; | |
4351 if (!aim_sncmp(cursn, sn)) { | |
4352 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4353 free(cursn); | |
4354 cur = od->requesticon; | |
4355 } else | |
4356 cur = cur->next; | |
4357 } | |
4358 | |
4359 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4360 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4361 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4362 |
4363 return 1; | |
4364 } | |
4365 | |
4366 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4367 GaimConnection *gc = data; |
7283 | 4368 OscarData *od = gc->proto_data; |
7011 | 4369 aim_userinfo_t *userinfo; |
4804 | 4370 aim_conn_t *conn; |
4371 | |
4372 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4373 if (!conn) { |
4374 if (!od->iconconnecting) { | |
4375 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4376 od->iconconnecting = TRUE; | |
4377 } | |
4804 | 4378 return FALSE; |
4379 } | |
4380 | |
5842 | 4381 if (od->set_icon) { |
6039 | 4382 struct stat st; |
4383 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4384 if (iconfile == NULL) { | |
8363 | 4385 aim_ssi_delicon(od->sess); |
6039 | 4386 } else if (!stat(iconfile, &st)) { |
4387 char *buf = g_malloc(st.st_size); | |
4388 FILE *file = fopen(iconfile, "rb"); | |
4389 if (file) { | |
9532 | 4390 /* XXX - Use g_file_get_contents()? */ |
6039 | 4391 fread(buf, 1, st.st_size, file); |
4392 fclose(file); | |
8660 | 4393 gaim_debug_info("oscar", |
6039 | 4394 "Uploading icon to icon server\n"); |
6879 | 4395 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4396 } else |
8660 | 4397 gaim_debug_error("oscar", |
6039 | 4398 "Can't open buddy icon file!\n"); |
4399 g_free(buf); | |
4400 } else { | |
8660 | 4401 gaim_debug_error("oscar", |
6039 | 4402 "Can't stat buddy icon file!\n"); |
5842 | 4403 } |
4404 od->set_icon = FALSE; | |
4405 } | |
4406 | |
4407 if (!od->requesticon) { | |
8660 | 4408 gaim_debug_misc("oscar", |
5842 | 4409 "no more icons to request\n"); |
4410 return FALSE; | |
4411 } | |
4412 | |
7045 | 4413 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4414 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4415 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4416 return FALSE; |
4417 } else { | |
4418 char *sn = od->requesticon->data; | |
4419 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4420 free(sn); | |
4421 } | |
4422 | |
4423 return TRUE; | |
4424 } | |
4425 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4426 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4427 * 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
|
4428 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4429 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4430 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4431 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4432 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4433 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4434 va_start(ap, fr); |
4199 | 4435 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4436 sn = va_arg(ap, char *); |
4437 va_end(ap); | |
4438 | |
8660 | 4439 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4440 |
4441 return 1; | |
4442 } | |
4443 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4444 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
|
4445 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4446 "invalid", |
4194 | 4447 "change", |
4448 "warning", | |
4449 "limit", | |
4450 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4451 }; |
2086 | 4452 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4453 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4454 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4455 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4456 va_start(ap, fr); |
4200 | 4457 code = (fu16_t)va_arg(ap, unsigned int); |
4458 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4459 windowsize = va_arg(ap, fu32_t); | |
4460 clear = va_arg(ap, fu32_t); | |
4461 alert = va_arg(ap, fu32_t); | |
4462 limit = va_arg(ap, fu32_t); | |
4463 disconnect = va_arg(ap, fu32_t); | |
4464 currentavg = va_arg(ap, fu32_t); | |
4465 maxavg = va_arg(ap, fu32_t); | |
2086 | 4466 va_end(ap); |
4467 | |
8660 | 4468 gaim_debug_misc("oscar", |
5556 | 4469 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4470 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4471 (code < 5) ? codes[code] : codes[0], |
4472 rateclass, | |
4473 currentavg, maxavg, | |
4474 alert, clear, | |
4475 limit, disconnect, | |
4476 windowsize); | |
4477 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4478 /* XXX fix these values */ |
2086 | 4479 if (code == AIM_RATE_CODE_CHANGE) { |
4480 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4481 aim_conn_setlatency(fr->conn, 0); |
2086 | 4482 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4483 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4484 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4485 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4486 _("The last action you attempted could not be " |
4487 "performed because you are over the rate limit. " | |
4488 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4489 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4490 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4491 aim_conn_setlatency(fr->conn, 0); |
2086 | 4492 } |
4493 | |
4494 return 1; | |
4495 } | |
4496 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4497 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4498 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4499 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4500 aim_userinfo_t *userinfo; |
5575 | 4501 GaimConnection *gc = sess->aux_data; |
2086 | 4502 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4503 va_start(ap, fr); |
4199 | 4504 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4505 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4506 va_end(ap); |
4507 | |
7111 | 4508 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 4509 |
4510 return 1; | |
4511 } | |
4512 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4513 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
|
4514 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4515 aim_userinfo_t *info; |
5575 | 4516 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4517 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4518 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4519 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4520 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4521 |
5628 | 4522 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 4523 |
7872 | 4524 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 4525 gc->login_time_official = info->onlinesince; |
7872 | 4526 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
4527 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4528 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4529 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4530 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4531 |
4649 | 4532 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4533 GaimConnection *gc = sess->aux_data; |
7283 | 4534 OscarData *od = gc->proto_data; |
4649 | 4535 va_list ap; |
4536 fu16_t code; | |
4537 char *msg; | |
4538 | |
4539 va_start(ap, fr); | |
4540 code = (fu16_t)va_arg(ap, int); | |
4541 msg = va_arg(ap, char *); | |
4542 va_end(ap); | |
4543 | |
8660 | 4544 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4545 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4546 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4547 if (code == 0x0001) { |
6113 | 4548 gc->wants_to_die = TRUE; |
5579 | 4549 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4550 } else { |
5579 | 4551 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4552 } |
4666 | 4553 od->killme = TRUE; |
4649 | 4554 } |
4555 | |
4556 return 1; | |
4557 } | |
4558 | |
2675 | 4559 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4560 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4561 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4562 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4563 |
4564 #ifndef NOSSI | |
8660 | 4565 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4566 aim_ssi_reqrights(sess); |
6350 | 4567 aim_ssi_reqdata(sess); |
4230 | 4568 #endif |
4569 | |
7011 | 4570 aim_locate_reqrights(sess); |
7285 | 4571 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4572 aim_im_reqparams(sess); |
7334 | 4573 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4574 |
4575 #ifdef NOSSI | |
8660 | 4576 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4577 aim_bos_reqrights(sess, fr->conn); |
4230 | 4578 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4579 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4580 #endif | |
2086 | 4581 |
7283 | 4582 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4583 | |
2086 | 4584 return 1; |
4585 } | |
4586 | |
2675 | 4587 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4588 GaimConnection *gc = sess->aux_data; |
7283 | 4589 OscarData *od = gc->proto_data; |
2647 | 4590 |
6905 | 4591 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4592 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4593 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4594 | |
2672 | 4595 aim_clientready(sess, fr->conn); |
8660 | 4596 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4597 |
2647 | 4598 if (od->chpass) { |
8660 | 4599 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4600 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4601 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4602 od->oldp = NULL; |
2647 | 4603 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4604 od->newp = NULL; |
2647 | 4605 od->chpass = FALSE; |
4606 } | |
2979 | 4607 if (od->setnick) { |
8660 | 4608 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4609 aim_admin_setnick(sess, fr->conn, od->newsn); |
4610 g_free(od->newsn); | |
4611 od->newsn = NULL; | |
4612 od->setnick = FALSE; | |
4613 } | |
2647 | 4614 if (od->conf) { |
8660 | 4615 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4616 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4617 od->conf = FALSE; |
4618 } | |
4619 if (od->reqemail) { | |
8660 | 4620 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4621 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4622 od->reqemail = FALSE; |
4623 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4624 if (od->setemail) { |
8660 | 4625 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4626 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4627 g_free(od->email); |
5497 | 4628 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4629 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4630 } |
2647 | 4631 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4632 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4633 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4634 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4635 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
|
4636 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4637 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4638 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4639 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4640 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4641 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4642 |
4194 | 4643 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4644 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4645 "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
|
4646 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4647 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4648 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4649 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4650 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4651 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4652 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4653 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4654 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4655 |
4617 | 4656 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4657 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4658 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4659 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4660 |
2993 | 4661 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4662 { | |
5575 | 4663 GaimConnection *gc = sess->aux_data; |
7283 | 4664 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4665 va_list ap; |
4666 fu16_t maxsiglen; | |
2993 | 4667 |
4668 va_start(ap, fr); | |
4199 | 4669 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4670 va_end(ap); |
4671 | |
8660 | 4672 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4673 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4674 |
4617 | 4675 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4676 | |
4677 if (od->icq) | |
7334 | 4678 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4679 else |
7334 | 4680 aim_locate_setcaps(od->sess, caps_aim); |
4681 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4682 |
4683 return 1; | |
4684 } | |
4685 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4686 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
|
4687 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4688 fu16_t maxbuddies, maxwatchers; |
5575 | 4689 GaimConnection *gc = sess->aux_data; |
7283 | 4690 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4691 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4692 va_start(ap, fr); |
4199 | 4693 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4694 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4695 va_end(ap); |
4696 | |
8660 | 4697 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4698 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4699 |
4617 | 4700 od->rights.maxbuddies = (guint)maxbuddies; |
4701 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4702 |
2086 | 4703 return 1; |
4704 } | |
4705 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4706 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4707 GaimConnection *gc = sess->aux_data; |
7283 | 4708 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4709 va_list ap; |
4710 fu16_t maxpermits, maxdenies; | |
2086 | 4711 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4712 va_start(ap, fr); |
4199 | 4713 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4714 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4715 va_end(ap); |
4716 | |
8660 | 4717 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4718 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4719 |
4617 | 4720 od->rights.maxpermits = (guint)maxpermits; |
4721 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4722 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4723 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4724 serv_finish_login(gc); |
4725 | |
8660 | 4726 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4727 |
2672 | 4728 aim_clientready(sess, fr->conn); |
5948 | 4729 aim_srv_setavailmsg(sess, NULL); |
7474 | 4730 aim_srv_setidle(sess, 0); |
4617 | 4731 |
4664 | 4732 if (od->icq) { |
4733 aim_icq_reqofflinemsgs(sess); | |
4734 aim_icq_hideip(sess); | |
4735 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4736 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4737 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4738 if (sess->authinfo->email) |
4739 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4740 |
4741 return 1; | |
4742 } | |
4743 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4744 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
|
4745 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4746 struct aim_icq_offlinemsg *msg; |
4075 | 4747 struct aim_incomingim_ch4_args args; |
4748 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4749 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4750 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4751 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4752 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4753 |
8660 | 4754 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4755 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4756 args.uin = msg->sender; |
4757 args.type = msg->type; | |
4173 | 4758 args.flags = msg->flags; |
4076 | 4759 args.msglen = msg->msglen; |
4075 | 4760 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4761 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4762 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4763 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4764 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4765 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4766 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4767 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
|
4768 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4769 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4770 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4771 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4772 |
7388 | 4773 #if 0 |
4774 /* | |
7465 | 4775 * Update, 2003-11-09: |
4776 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4777 * | |
7388 | 4778 * It may not be my place to do this, but... |
4779 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4780 * stupid, and should not exist for % switches (%x in our case) that request | |
4781 * a year in the preferred representation for the current locale. For that | |
4782 * reason I've chosen to not use this workaround (n., see kluge). | |
4783 * | |
4784 * I have a date. I want to show it to the user in the "preferred" way. | |
4785 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4786 * what the locale wanted. | |
4787 * | |
4788 * If I have a necessity for a full representation of the year in the current | |
4789 * locale, then I'll use a switch that returns a full representation of the | |
4790 * year. | |
4791 * | |
4792 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4793 * (because you're anal, or whatever), then change the f***ing locale. | |
4794 * | |
4795 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4796 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4797 * |
4798 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4799 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4800 */ |
4801 | |
4802 /* | |
4803 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4804 * "last 2 digits" warning. |
4805 */ | |
4806 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4807 const struct tm *tm) | |
4808 { | |
4809 return strftime(s, max, fmt, tm); | |
4810 } | |
7388 | 4811 #endif |
7386 | 4812 |
4624 | 4813 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
|
4814 { |
5575 | 4815 GaimConnection *gc = sess->aux_data; |
8670 | 4816 OscarData *od = (OscarData *)gc->proto_data; |
4817 GaimBuddy *buddy; | |
8853 | 4818 struct buddyinfo *bi = NULL; |
4624 | 4819 gchar who[16]; |
8670 | 4820 GString *str; |
4821 gchar *primary, *utf8; | |
9634 | 4822 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4823 va_list ap; |
4151 | 4824 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4825 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4826 va_start(ap, fr); |
4151 | 4827 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4828 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4829 |
4664 | 4830 if (!info->uin) |
4831 return 0; | |
4832 | |
8670 | 4833 str = g_string_sized_new(100); |
5556 | 4834 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 4835 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
4836 if (buddy != NULL) | |
4837 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
4838 | |
4839 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 4840 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 4841 if ((bi != NULL) && (bi->ipaddr != 0)) { |
4842 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
4843 (bi->ipaddr & 0xff000000) >> 24, | |
4844 (bi->ipaddr & 0x00ff0000) >> 16, | |
4845 (bi->ipaddr & 0x0000ff00) >> 8, | |
4846 (bi->ipaddr & 0x000000ff)); | |
8701 | 4847 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 4848 g_free(tstr); |
4849 } | |
8701 | 4850 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
4851 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4852 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 4853 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
4854 g_free(utf8); | |
4625 | 4855 } |
4856 if (info->numaddresses && info->email2) { | |
4857 int i; | |
4858 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4859 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 4860 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
4861 g_free(utf8); | |
4643 | 4862 } |
4625 | 4863 } |
4624 | 4864 } |
8701 | 4865 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
8902 | 4866 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
4867 info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 4868 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 4869 char date[30]; |
4870 struct tm tm; | |
4871 tm.tm_mday = (int)info->birthday; | |
4872 tm.tm_mon = (int)info->birthmonth-1; | |
4873 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 4874 strftime(date, sizeof(date), "%x", &tm); |
8701 | 4875 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 4876 } |
4624 | 4877 if (info->age) { |
4878 char age[5]; | |
4879 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 4880 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 4881 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4882 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 4883 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
4884 g_free(utf8); | |
4819 | 4885 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4886 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 4887 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
4888 g_free(utf8); | |
4889 } | |
4890 g_string_append_printf(str, "<hr>\n"); | |
4641 | 4891 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 4892 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 4893 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
4894 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
4895 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
4896 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 4897 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 4898 } |
4641 | 4899 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 4900 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 4901 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
4902 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
4903 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
4904 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 4905 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 4906 } |
4641 | 4907 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 4908 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 4909 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
4910 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
4911 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4912 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 4913 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
4914 g_free(utf8); | |
4624 | 4915 } |
8670 | 4916 g_string_append_printf(str, "\n<hr>\n"); |
4917 } | |
4918 | |
9634 | 4919 if (buddy != NULL) |
4920 alias = gaim_buddy_get_alias(buddy); | |
4921 else | |
4922 alias = who; | |
4923 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
8670 | 4924 gaim_notify_formatted(gc, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 4925 g_free(primary); |
8670 | 4926 g_string_free(str, TRUE); |
4151 | 4927 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4928 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4929 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4930 |
4759 | 4931 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
4932 { | |
5575 | 4933 GaimConnection *gc = sess->aux_data; |
4820 | 4934 gchar who[16], *utf8; |
6695 | 4935 GaimBuddy *b; |
4759 | 4936 va_list ap; |
4937 struct aim_icq_info *info; | |
4938 | |
4939 va_start(ap, fr); | |
4940 info = va_arg(ap, struct aim_icq_info *); | |
4941 va_end(ap); | |
4942 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4943 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 4944 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 4945 serv_got_alias(gc, who, utf8); |
4759 | 4946 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 4947 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 4948 } |
4820 | 4949 g_free(utf8); |
4759 | 4950 } |
4951 | |
4952 return 1; | |
4953 } | |
4954 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4955 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
|
4956 { |
7032 | 4957 GaimConnection *gc = sess->aux_data; |
4958 gchar *text; | |
4959 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4960 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4961 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4962 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4963 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4964 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4965 url = va_arg(ap, char *); |
4199 | 4966 wid = (fu16_t) va_arg(ap, int); |
4967 hei = (fu16_t) va_arg(ap, int); | |
4968 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4969 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4970 |
7032 | 4971 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
4972 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
4973 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4974 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4975 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4976 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4977 |
7032 | 4978 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
4979 { | |
6873 | 4980 GaimConnection *gc = sess->aux_data; |
4981 gchar *secondary; | |
4982 GString *text; | |
4983 int i, num; | |
2086 | 4984 va_list ap; |
6873 | 4985 char *email, *SNs; |
2086 | 4986 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4987 va_start(ap, fr); |
6873 | 4988 email = va_arg(ap, char *); |
2086 | 4989 num = va_arg(ap, int); |
4990 SNs = va_arg(ap, char *); | |
4991 va_end(ap); | |
4992 | |
8152 | 4993 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 4994 text = g_string_new(""); |
2086 | 4995 for (i = 0; i < num; i++) |
6873 | 4996 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
4997 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
4998 | |
4999 g_free(secondary); | |
5000 g_string_free(text, TRUE); | |
2086 | 5001 |
5002 return 1; | |
5003 } | |
5004 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5005 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5006 va_list ap; |
6873 | 5007 char *email; |
5420 | 5008 char *buf; |
2086 | 5009 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5010 va_start(ap, fr); |
6873 | 5011 email = va_arg(ap, char *); |
2086 | 5012 va_end(ap); |
5013 | |
6873 | 5014 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
|
5015 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5016 g_free(buf); |
2086 | 5017 |
5018 return 1; | |
5019 } | |
5020 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5021 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5022 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5023 fu16_t status; |
2086 | 5024 va_list ap; |
5025 char msg[256]; | |
5026 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5027 va_start(ap, fr); |
4199 | 5028 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5029 va_end(ap); |
5030 | |
8660 | 5031 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5032 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5033 status ? "unknown" : "email sent"); |
5034 if (!status) { | |
5302 | 5035 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5036 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5037 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5038 } |
5039 | |
5040 return 1; | |
5041 } | |
5042 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5043 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5044 GaimConnection *gc = sess->aux_data; |
2086 | 5045 va_list ap; |
3912 | 5046 fu16_t perms, err; |
5047 char *url, *sn, *email; | |
5048 int change; | |
2086 | 5049 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5050 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5051 change = va_arg(ap, int); |
4199 | 5052 perms = (fu16_t) va_arg(ap, unsigned int); |
5053 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5054 url = va_arg(ap, char *); |
5055 sn = va_arg(ap, char *); | |
5056 email = va_arg(ap, char *); | |
2086 | 5057 va_end(ap); |
5058 | |
8660 | 5059 gaim_debug_misc("oscar", |
9626 | 5060 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5061 change ? "change" : "request", perms, err, | |
5062 (url != NULL) ? url : "(null)", | |
5063 (sn != NULL) ? sn : "(null)", | |
5064 (email != NULL) ? email : "(null)"); | |
5065 | |
5066 if ((err > 0) && (url != NULL)) { | |
3912 | 5067 char *dialog_msg; |
5068 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5069 switch (err) { | |
5070 case 0x0001: { | |
5071 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5072 } break; | |
5073 case 0x0006: { | |
5074 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5075 } break; | |
5076 case 0x000b: { | |
5077 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5078 } break; | |
5079 case 0x001d: { | |
5080 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); | |
5081 } break; | |
5082 case 0x0021: { | |
5083 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); | |
5084 } break; | |
5085 case 0x0023: { | |
5086 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5087 } break; | |
5088 default: { | |
5089 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5090 } break; | |
5091 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5092 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5093 g_free(dialog_top); |
5094 g_free(dialog_msg); | |
5095 return 1; | |
5096 } | |
5097 | |
9626 | 5098 if (sn != NULL) { |
4585 | 5099 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
|
5100 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5101 g_free(dialog_msg); |
5102 } | |
5103 | |
9626 | 5104 if (email != NULL) { |
5575 | 5105 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5106 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5107 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5108 g_free(dialog_msg); |
2086 | 5109 } |
5110 | |
5111 return 1; | |
5112 } | |
5113 | |
5575 | 5114 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5115 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5116 aim_flap_nop(od->sess, od->conn); |
2086 | 5117 } |
5118 | |
6059 | 5119 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5120 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5121 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5122 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5123 if (typing == GAIM_TYPING) |
4870 | 5124 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5125 else if (typing == GAIM_TYPED) |
4870 | 5126 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5127 else | |
5128 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5129 else { |
5300 | 5130 /* Don't send if this turkey is in our deny list */ |
5131 GSList *list; | |
5132 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5133 if (!list) { | |
7261 | 5134 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5135 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5136 if (typing == GAIM_TYPING) |
5300 | 5137 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5138 else if (typing == GAIM_TYPED) |
5300 | 5139 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5140 else | |
5141 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5142 } | |
3595 | 5143 } |
5144 } | |
2993 | 5145 return 0; |
5146 } | |
9030 | 5147 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5148 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimConvImFlags); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5149 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5150 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5151 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5152 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5153 int ret = 0; |
3659 | 5154 GError *err = NULL; |
5575 | 5155 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5156 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5157 |
4838 | 5158 if (dim && dim->connected) { |
5159 /* If we're directly connected, send a direct IM */ | |
6982 | 5160 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5161 } else { |
4738 | 5162 struct buddyinfo *bi; |
3008 | 5163 struct aim_sendimext_args args; |
5164 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5165 gsize len; |
8962 | 5166 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5167 | |
5168 if (strstr(message, "<IMG ")) | |
5169 gaim_conversation_write(conv, "", | |
5170 _("Your IM Image was not sent. " | |
5171 "You must be Direct Connected to send IM Images."), | |
5172 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5173 |
7261 | 5174 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5175 if (!bi) { |
5176 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5177 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5178 } |
5179 | |
3008 | 5180 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5181 if (od->icq) { |
5182 args.features = features_icq; | |
5183 args.featureslen = sizeof(features_icq); | |
3008 | 5184 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5185 } else { |
5186 args.features = features_aim; | |
5187 args.featureslen = sizeof(features_aim); | |
4972 | 5188 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5189 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5190 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5191 } |
4269 | 5192 |
4738 | 5193 if (bi->ico_need) { |
8660 | 5194 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5195 "Sending buddy icon request with message\n"); |
3008 | 5196 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5197 bi->ico_need = FALSE; |
3008 | 5198 } |
4269 | 5199 |
5575 | 5200 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5201 FILE *file = fopen(iconfile, "rb"); |
3008 | 5202 if (file) { |
5203 char *buf = g_malloc(st.st_size); | |
9532 | 5204 /* XXX - Use g_file_get_contents()? */ |
3008 | 5205 fread(buf, 1, st.st_size, file); |
6039 | 5206 fclose(file); |
4269 | 5207 |
3008 | 5208 args.iconlen = st.st_size; |
4617 | 5209 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5210 args.iconstamp = st.st_mtime; |
5211 | |
7406 | 5212 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5213 bi->ico_informed = FALSE; |
7406 | 5214 bi->ico_sent = FALSE; |
5215 } | |
4738 | 5216 |
5217 if (!bi->ico_informed) { | |
8660 | 5218 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5219 "Claiming to have a buddy icon\n"); |
4738 | 5220 args.flags |= AIM_IMFLAGS_HASICON; |
5221 bi->ico_me_len = args.iconlen; | |
5222 bi->ico_me_csum = args.iconsum; | |
5223 bi->ico_me_time = args.iconstamp; | |
5224 bi->ico_informed = TRUE; | |
5225 } | |
5226 | |
3008 | 5227 g_free(buf); |
2086 | 5228 } |
5229 } | |
4269 | 5230 |
3008 | 5231 args.destsn = name; |
4269 | 5232 |
8985 | 5233 /* |
5234 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5235 * strip all HTML | |
5236 */ | |
8995 | 5237 if (isdigit(name[0]) ) { |
5238 /* being sent to an ICQ user */ | |
5239 if (!isdigit(gaim_account_get_username(gc->account)[0])) { | |
5240 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ | |
5241 tmpmsg = gaim_str_add_cr(message); | |
5242 } else { | |
5243 /* from an ICQ user - do nothing */ | |
5244 tmpmsg = g_strdup(message); | |
5245 } | |
5246 } else { | |
5247 /* being sent to an AIM user */ | |
5248 if (isdigit(gaim_account_get_username(gc->account)[0])) { | |
5249 /* from an ICQ user */ | |
5250 tmpmsg2 = gaim_strdup_withhtml(message); | |
5251 tmpmsg = gaim_escape_html(tmpmsg2); | |
5252 g_free(tmpmsg2); | |
5253 } else | |
5254 tmpmsg = gaim_strdup_withhtml(message); | |
5255 } | |
6310 | 5256 len = strlen(tmpmsg); |
5257 | |
5258 args.flags |= oscar_encoding_check(tmpmsg); | |
3642 | 5259 if (args.flags & AIM_IMFLAGS_UNICODE) { |
8660 | 5260 gaim_debug_info("oscar", "Sending Unicode IM\n"); |
4662 | 5261 args.charset = 0x0002; |
4665 | 5262 args.charsubset = 0x0000; |
6310 | 5263 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3659 | 5264 if (err) { |
8660 | 5265 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5266 "Error converting a unicode message: %s\n", err->message); |
8660 | 5267 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5268 "This really shouldn't happen!\n"); |
3659 | 5269 /* We really shouldn't try to send the |
5270 * IM now, but I'm not sure what to do */ | |
4800 | 5271 g_error_free(err); |
3659 | 5272 } |
3850 | 5273 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
8660 | 5274 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5275 "Sending ISO-8859-1 IM\n"); |
4662 | 5276 args.charset = 0x0003; |
4665 | 5277 args.charsubset = 0x0000; |
6310 | 5278 args.msg = g_convert(tmpmsg, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3659 | 5279 if (err) { |
8660 | 5280 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5281 "conversion error: %s\n", err->message); |
8660 | 5282 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5283 "Someone tell Ethan his 8859-1 detection is wrong\n"); |
3642 | 5284 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
6310 | 5285 len = strlen(tmpmsg); |
4800 | 5286 g_error_free(err); |
6310 | 5287 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3659 | 5288 if (err) { |
8660 | 5289 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5290 "Error in unicode fallback: %s\n", err->message); |
4800 | 5291 g_error_free(err); |
3659 | 5292 } |
3642 | 5293 } |
5294 } else { | |
4662 | 5295 args.charset = 0x0000; |
5296 args.charsubset = 0x0000; | |
6310 | 5297 args.msg = tmpmsg; |
3642 | 5298 } |
5299 args.msglen = len; | |
4269 | 5300 |
4617 | 5301 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 5302 } |
4838 | 5303 |
6310 | 5304 g_free(tmpmsg); |
5305 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5306 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5307 return 1; |
6310 | 5308 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5309 return ret; |
2086 | 5310 } |
5311 | |
7011 | 5312 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5313 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5314 |
7173 | 5315 if (od->icq && isdigit(name[0])) |
4624 | 5316 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5317 else |
7235 | 5318 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5319 } |
5320 | |
8950 | 5321 #if 0 |
7011 | 5322 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5323 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5324 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5325 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5326 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5327 maiden, NULL, NULL, city, state, NULL, 0, web); |
5328 } | |
8950 | 5329 #endif |
2086 | 5330 |
5575 | 5331 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5332 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5333 aim_srv_setidle(od->sess, time); |
2086 | 5334 } |
5335 | |
5954 | 5336 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5337 OscarData *od = (OscarData *)gc->proto_data; |
5129 | 5338 fu32_t flags = 0; |
6019 | 5339 char *text_html = NULL; |
5129 | 5340 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5341 gsize msglen = 0; |
2993 | 5342 |
4617 | 5343 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5344 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5345 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5346 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5347 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5348 "again when you are fully connected.")); |
4617 | 5349 |
7334 | 5350 if (!text) { |
5351 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5352 return; | |
5353 } | |
6019 | 5354 |
7334 | 5355 text_html = gaim_strdup_withhtml(text); |
5356 flags = oscar_encoding_check(text_html); | |
5357 if (flags & AIM_IMFLAGS_UNICODE) { | |
5358 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5359 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5360 g_free(msg); | |
5361 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
5362 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5363 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5364 g_free(msg); | |
5365 } else { | |
5366 msglen = strlen(text_html); | |
5367 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5368 } | |
5369 | |
5370 if (msglen > od->rights.maxsiglen) { | |
5371 gchar *errstr; | |
5372 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5373 "has been exceeded. Gaim has truncated it for you.", | |
5374 "The maximum profile length of %d bytes " | |
5375 "has been exceeded. Gaim has truncated it for you.", | |
5376 od->rights.maxsiglen), od->rights.maxsiglen); | |
5377 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5378 g_free(errstr); | |
5379 } | |
5380 | |
5381 g_free(text_html); | |
2993 | 5382 |
5383 return; | |
2086 | 5384 } |
5385 | |
8257 | 5386 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 5387 { |
5129 | 5388 fu32_t flags = 0; |
6019 | 5389 gchar *text_html = NULL; |
5129 | 5390 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5391 gsize msglen = 0; |
2993 | 5392 |
8257 | 5393 if (!strcmp(state, _("Visible"))) { |
5394 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5395 return; | |
5396 } else if (!strcmp(state, _("Invisible"))) { | |
5397 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5398 return; | |
5399 } /* else... */ | |
5400 | |
8476 | 5401 if (!strcmp(state, _("Back"))) { |
5402 /* If this is our only online account then globally set Gaim not-away */ | |
5403 GList *gcs = gaim_connections_get_all(); | |
5404 if (gcs->next == NULL) | |
5405 do_im_back(NULL, NULL); | |
5406 } | |
5407 | |
8257 | 5408 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5409 | |
2993 | 5410 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5411 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5412 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5413 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5414 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5415 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5416 "fully connected.")); |
5129 | 5417 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5418 if (gc->away) { |
2993 | 5419 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5420 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5421 } |
2993 | 5422 |
5129 | 5423 if (!text) { |
7334 | 5424 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5425 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5426 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5427 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5428 text_html = gaim_strdup_withhtml(text); |
6019 | 5429 flags = oscar_encoding_check(text_html); |
5129 | 5430 if (flags & AIM_IMFLAGS_UNICODE) { |
6019 | 5431 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5432 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5433 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5434 g_free(msg); |
5435 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
5436 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
6019 | 5437 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5438 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5439 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5440 g_free(msg); |
6019 | 5441 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5442 } else { |
6019 | 5443 msglen = strlen(text_html); |
7011 | 5444 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5445 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 5446 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5447 } |
5448 | |
5449 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5450 gchar *errstr; |
5451 | |
6308 | 5452 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5453 "has been exceeded. Gaim has truncated it for you.", | |
5454 "The maximum away message length of %d bytes " | |
5455 "has been exceeded. Gaim has truncated it for you.", | |
5456 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5457 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5458 g_free(errstr); |
5459 } | |
6019 | 5460 |
5461 g_free(text_html); | |
8257 | 5462 |
2993 | 5463 return; |
5464 } | |
5465 | |
7283 | 5466 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 5467 { |
5575 | 5468 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5469 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5470 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5471 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5472 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5473 |
8265 | 5474 if (strcmp(state, _("Invisible"))) |
5575 | 5475 account->perm_deny = 4; |
8265 | 5476 else |
5575 | 5477 account->perm_deny = 3; |
8265 | 5478 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5479 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5480 |
5481 if (!strcmp(state, _("Online"))) | |
4901 | 5482 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 5483 else if (!strcmp(state, _("Away"))) { |
4901 | 5484 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5485 gc->away = g_strdup(""); |
4342 | 5486 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 5487 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
|
5488 gc->away = g_strdup(""); |
4342 | 5489 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 5490 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
|
5491 gc->away = g_strdup(""); |
4342 | 5492 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 5493 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
|
5494 gc->away = g_strdup(""); |
4342 | 5495 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 5496 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5497 gc->away = g_strdup(""); |
4342 | 5498 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 5499 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5500 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5501 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 5502 if (message) { |
4901 | 5503 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
|
5504 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5505 } else { |
4901 | 5506 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5507 } |
2086 | 5508 } |
2993 | 5509 |
5510 return; | |
5511 } | |
5512 | |
6059 | 5513 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 5514 { |
7283 | 5515 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 5516 |
5517 if (od->icq) | |
5518 oscar_set_away_icq(gc, od, state, message); | |
5519 else | |
8257 | 5520 oscar_set_away_aim(gc, od, state, message); |
2993 | 5521 |
5522 return; | |
2086 | 5523 } |
5524 | |
6059 | 5525 static void oscar_warn(GaimConnection *gc, const char *name, int anon) { |
7283 | 5526 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5527 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); |
2086 | 5528 } |
5529 | |
9285 | 5530 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5531 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5532 |
5533 if (!aim_snvalid(buddy->name)) { | |
8092 | 5534 gchar *buf; |
9285 | 5535 buf = g_strdup_printf(_("Could not add the buddy %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name); |
9627 | 5536 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5537 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5538 g_free(buf); |
8150 | 5539 |
5540 /* Remove from local list */ | |
9285 | 5541 gaim_blist_remove_buddy(buddy); |
8150 | 5542 |
8092 | 5543 return; |
5544 } | |
5545 | |
4230 | 5546 #ifdef NOSSI |
9285 | 5547 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5548 #else |
9285 | 5549 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5550 if (buddy && group) { | |
8660 | 5551 gaim_debug_info("oscar", |
9285 | 5552 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5553 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5554 } |
5555 } | |
5556 #endif | |
8150 | 5557 |
4759 | 5558 if (od->icq) |
9285 | 5559 aim_icq_getalias(od->sess, buddy->name); |
5560 } | |
5561 | |
5562 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5563 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5564 #ifdef NOSSI |
5565 char buf[MSG_LEN]; | |
5566 int n=0; | |
9285 | 5567 |
4230 | 5568 while (buddies) { |
9381 | 5569 GaimBuddy *buddy = buddies->data; |
4230 | 5570 if (n > MSG_LEN - 18) { |
7285 | 5571 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5572 n = 0; |
3092 | 5573 } |
9381 | 5574 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5575 buddies = buddies->next; |
5576 } | |
7285 | 5577 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5578 #else |
9285 | 5579 |
4230 | 5580 if (od->sess->ssi.received_data) { |
9285 | 5581 GList *curb = buddies; |
5582 GList *curg = groups; | |
5583 while ((curb != NULL) && (curg != NULL)) { | |
5584 GaimBuddy *buddy = curb->data; | |
5585 GaimGroup *group = curg->data; | |
5586 oscar_add_buddy(gc, buddy, group); | |
5587 curb = curb->next; | |
5588 curg = curg->next; | |
4230 | 5589 } |
5590 } | |
5591 #endif | |
5592 } | |
5593 | |
9285 | 5594 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5595 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5596 |
4230 | 5597 #ifdef NOSSI |
9285 | 5598 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5599 #else |
5600 if (od->sess->ssi.received_data) { | |
8660 | 5601 gaim_debug_info("oscar", |
9285 | 5602 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5603 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5604 } |
5605 #endif | |
5606 } | |
5607 | |
9285 | 5608 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5609 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5610 |
4230 | 5611 #ifdef NOSSI |
9285 | 5612 for (cur = buddies; cur != NULL; cur = cur->next) { |
5613 GaimBuddy *buddy = cur->data; | |
5614 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5615 } | |
4230 | 5616 #else |
5617 if (od->sess->ssi.received_data) { | |
9285 | 5618 GList *curb = buddies; |
5619 GList *curg = groups; | |
5620 while ((curb != NULL) && (curg != NULL)) { | |
5621 GaimBuddy *buddy = curb->data; | |
5622 GaimGroup *group = curg->data; | |
5623 oscar_remove_buddy(gc, buddy, group); | |
5624 curb = curb->next; | |
5625 curg = curg->next; | |
3092 | 5626 } |
4230 | 5627 } |
5628 #endif | |
5629 } | |
5630 | |
5631 #ifndef NOSSI | |
5575 | 5632 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5633 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5634 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5635 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5636 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5637 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5638 } |
5639 } | |
5640 | |
5575 | 5641 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5642 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5643 if (od->sess->ssi.received_data) { |
5644 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5645 if (gname) { | |
8660 | 5646 gaim_debug_info("oscar", |
9586 | 5647 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5648 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5649 } |
5650 } | |
5651 } | |
5652 | |
9285 | 5653 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5654 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5655 |
5656 if (od->sess->ssi.received_data) { | |
9285 | 5657 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5658 GList *cur, *groups = NULL; | |
5659 | |
5660 /* Make a list of what the groups each buddy is in */ | |
5661 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5662 GaimBlistNode *node = cur->data; | |
5663 groups = g_list_append(groups, node->parent); | |
5664 } | |
5665 | |
5666 oscar_remove_buddies(gc, moved_buddies, groups); | |
5667 oscar_add_buddies(gc, moved_buddies, groups); | |
5668 g_list_free(groups); | |
8660 | 5669 gaim_debug_info("oscar", |
9285 | 5670 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5671 } else { |
9285 | 5672 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5673 gaim_debug_info("oscar", |
9285 | 5674 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5675 } |
5676 } | |
5677 } | |
5678 | |
5968 | 5679 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5680 aim_session_t *sess = data; | |
6350 | 5681 aim_ssi_reqdata(sess); |
5968 | 5682 return FALSE; |
5683 } | |
5684 | |
4642 | 5685 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5686 GaimConnection *gc = sess->aux_data; |
7283 | 5687 OscarData *od = gc->proto_data; |
4642 | 5688 va_list ap; |
5689 fu16_t reason; | |
5690 | |
5691 va_start(ap, fr); | |
5692 reason = (fu16_t)va_arg(ap, unsigned int); | |
5693 va_end(ap); | |
5694 | |
8660 | 5695 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5696 |
5697 if (reason == 0x0005) { | |
5892 | 5698 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5699 _("Gaim was temporarily unable to retrieve your buddy list from the AIM servers. Your buddy list is not lost, and will probably become available in a few hours.")); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5700 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5701 } |
5702 | |
5703 /* Activate SSI */ | |
5704 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5705 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5706 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5707 aim_ssi_enable(od->sess); |
5708 | |
5709 return 1; | |
5710 } | |
5711 | |
2991 | 5712 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5713 GaimConnection *gc = sess->aux_data; |
7283 | 5714 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5715 int numtypes, i; |
5716 fu16_t *maxitems; | |
2991 | 5717 va_list ap; |
5718 | |
5719 va_start(ap, fr); | |
4230 | 5720 numtypes = va_arg(ap, int); |
5721 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5722 va_end(ap); |
5723 | |
8660 | 5724 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5725 |
4230 | 5726 for (i=0; i<numtypes; i++) |
8660 | 5727 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5728 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5729 |
8660 | 5730 gaim_debug_misc(NULL, "\n"); |
4230 | 5731 |
5732 if (numtypes >= 0) | |
5733 od->rights.maxbuddies = maxitems[0]; | |
5734 if (numtypes >= 1) | |
5735 od->rights.maxgroups = maxitems[1]; | |
5736 if (numtypes >= 2) | |
5737 od->rights.maxpermits = maxitems[2]; | |
5738 if (numtypes >= 3) | |
5739 od->rights.maxdenies = maxitems[3]; | |
2991 | 5740 |
5741 return 1; | |
5742 } | |
5743 | |
5744 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5745 GaimConnection *gc = sess->aux_data; |
5746 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5747 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5748 GaimGroup *g; |
5749 GaimBuddy *b; | |
2995 | 5750 struct aim_ssi_item *curitem; |
2991 | 5751 int tmp; |
4230 | 5752 va_list ap; |
8219 | 5753 fu16_t fmtver, numitems; |
5754 struct aim_ssi_item *items; | |
5755 fu32_t timestamp; | |
4230 | 5756 |
5757 va_start(ap, fr); | |
5758 fmtver = (fu16_t)va_arg(ap, int); | |
5759 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5760 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5761 timestamp = va_arg(ap, fu32_t); |
8219 | 5762 va_end(ap); |
2991 | 5763 |
8660 | 5764 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5765 "ssi: syncing local list and server list\n"); |
2991 | 5766 |
8219 | 5767 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5768 gaim_debug_info("oscar", "Got AIM SSI with a 0 timestamp or 0 numitems--not syncing. This probably means your buddy list is empty.", NULL); |
8219 | 5769 return 1; |
5770 } | |
5771 | |
2991 | 5772 /* Clean the buddy list */ |
4889 | 5773 aim_ssi_cleanlist(sess); |
2991 | 5774 |
8150 | 5775 { /* If not in server list then prune from local list */ |
5776 GaimBlistNode *gnode, *cnode, *bnode; | |
5777 GaimBuddyList *blist; | |
9539 | 5778 GSList *cur, *next; |
8150 | 5779 |
5780 /* Buddies */ | |
5781 cur = NULL; | |
5782 if ((blist = gaim_get_blist()) != NULL) { | |
5783 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5784 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5785 continue; | |
5786 g = (GaimGroup *)gnode; | |
5787 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5788 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5789 continue; | |
5790 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5791 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5792 continue; | |
5793 b = (GaimBuddy *)bnode; | |
5794 if (b->account == gc->account) { | |
5795 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5796 /* If the buddy is an ICQ user then load his nickname */ | |
5797 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5798 char *alias; |
8150 | 5799 if (servernick) |
5800 serv_got_alias(gc, b->name, servernick); | |
5801 | |
5802 /* Store local alias on server */ | |
8214 | 5803 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5804 if (!alias && b->alias && strlen(b->alias)) |
5805 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5806 free(alias); | |
5807 } else { | |
8660 | 5808 gaim_debug_info("oscar", |
8150 | 5809 "ssi: removing buddy %s from local list\n", b->name); |
5810 /* We can't actually remove now because it will screw up our looping */ | |
5811 cur = g_slist_prepend(cur, b); | |
5812 } | |
5813 } | |
5814 } | |
5815 } | |
5816 } | |
5817 } | |
8175 | 5818 |
8150 | 5819 while (cur != NULL) { |
5820 b = cur->data; | |
5821 cur = g_slist_remove(cur, b); | |
5822 gaim_blist_remove_buddy(b); | |
5823 } | |
5824 | |
5825 /* Permit list */ | |
5826 if (gc->account->permit) { | |
9539 | 5827 next = gc->account->permit; |
5828 while (next != NULL) { | |
5829 cur = next; | |
5830 next = next->next; | |
8150 | 5831 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5832 gaim_debug_info("oscar", |
8150 | 5833 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5834 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5835 } | |
9539 | 5836 } |
8150 | 5837 } |
5838 | |
5839 /* Deny list */ | |
5840 if (gc->account->deny) { | |
9539 | 5841 next = gc->account->deny; |
5842 while (next != NULL) { | |
5843 cur = next; | |
5844 next = next->next; | |
8150 | 5845 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 5846 gaim_debug_info("oscar", |
8150 | 5847 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5848 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5849 } | |
9539 | 5850 } |
8150 | 5851 } |
5852 /* Presence settings (idle time visibility) */ | |
5853 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5854 if (!(tmp & 0x400)) | |
5855 aim_ssi_setpresence(sess, tmp | 0x400); | |
5856 } /* end pruning buddies from local list */ | |
5857 | |
2991 | 5858 /* Add from server list to local list */ |
4230 | 5859 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 5860 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 5861 switch (curitem->type) { |
4230 | 5862 case 0x0000: { /* Buddy */ |
4251 | 5863 if (curitem->name) { |
4292 | 5864 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 5865 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 5866 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 5867 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 5868 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 5869 /* Should gname be freed here? -- elb */ |
4754 | 5870 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 5871 free(alias); |
8150 | 5872 if (b) { |
4292 | 5873 /* Get server stored alias */ |
4705 | 5874 if (alias_utf8) { |
8150 | 5875 g_free(b->alias); |
5876 b->alias = g_strdup(alias_utf8); | |
4705 | 5877 } |
4282 | 5878 } else { |
8150 | 5879 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 5880 |
4754 | 5881 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 5882 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 5883 gaim_blist_add_group(g, NULL); |
5884 } | |
5146 | 5885 |
8660 | 5886 gaim_debug_info("oscar", |
9285 | 5887 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 5888 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 5889 } |
8341 | 5890 if (!aim_sncmp(curitem->name, account->username)) { |
5891 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
5892 gaim_check_comment(od, comment); | |
5893 free(comment); | |
5894 } | |
7162 | 5895 g_free(gname_utf8); |
5896 g_free(alias_utf8); | |
2991 | 5897 } |
4230 | 5898 } break; |
5899 | |
5900 case 0x0001: { /* Group */ | |
4282 | 5901 /* Shouldn't add empty groups */ |
4230 | 5902 } break; |
5903 | |
5904 case 0x0002: { /* Permit buddy */ | |
2991 | 5905 if (curitem->name) { |
4230 | 5906 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 5907 GSList *list; |
5575 | 5908 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5909 if (!list) { |
8660 | 5910 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5911 "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
|
5912 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 5913 } |
5914 } | |
4230 | 5915 } break; |
5916 | |
5917 case 0x0003: { /* Deny buddy */ | |
2991 | 5918 if (curitem->name) { |
5919 GSList *list; | |
5575 | 5920 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5921 if (!list) { |
8660 | 5922 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5923 "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
|
5924 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 5925 } |
5926 } | |
4230 | 5927 } break; |
5928 | |
5929 case 0x0004: { /* Permit/deny setting */ | |
2991 | 5930 if (curitem->data) { |
5931 fu8_t permdeny; | |
5575 | 5932 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 5933 gaim_debug_info("oscar", |
5575 | 5934 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
5935 account->perm_deny = permdeny; | |
5936 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 5937 serv_set_away(gc, "Invisible", ""); |
5938 } | |
2991 | 5939 } |
5940 } | |
4230 | 5941 } break; |
5942 | |
5943 case 0x0005: { /* Presence setting */ | |
3109 | 5944 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 5945 } break; |
2991 | 5946 } /* End of switch on curitem->type */ |
5947 } /* End of for loop */ | |
4230 | 5948 |
4901 | 5949 /* Set our ICQ status */ |
8257 | 5950 if (!gc->away) { |
4901 | 5951 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
5952 } | |
5953 | |
4342 | 5954 /* Activate SSI */ |
5955 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5956 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5957 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5958 "ssi: activating server-stored buddy list\n"); |
4642 | 5959 aim_ssi_enable(sess); |
4342 | 5960 |
2991 | 5961 return 1; |
2086 | 5962 } |
4230 | 5963 |
5964 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5965 GaimConnection *gc = sess->aux_data; |
4230 | 5966 va_list ap; |
5967 struct aim_ssi_tmp *retval; | |
5968 | |
5969 va_start(ap, fr); | |
5970 retval = va_arg(ap, struct aim_ssi_tmp *); | |
5971 va_end(ap); | |
5972 | |
5973 while (retval) { | |
8660 | 5974 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5975 "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 | 5976 |
5977 if (retval->ack != 0xffff) | |
5978 switch (retval->ack) { | |
5979 case 0x0000: { /* added successfully */ | |
5980 } break; | |
5981 | |
4829 | 5982 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
5983 gchar *buf; | |
5984 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)"))); | |
9627 | 5985 if (!gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
5986 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
4829 | 5987 g_free(buf); |
5988 } | |
5989 | |
7023 | 5990 case 0x000e: { /* buddy requires authorization */ |
4828 | 5991 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 5992 gaim_auth_sendrequest(gc, retval->name); |
4230 | 5993 } break; |
5994 | |
5995 default: { /* La la la */ | |
5197 | 5996 gchar *buf; |
8660 | 5997 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 5998 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)"))); |
9627 | 5999 if (!gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
6000 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
5197 | 6001 g_free(buf); |
4230 | 6002 } break; |
6003 } | |
6004 | |
6005 retval = retval->next; | |
6006 } | |
6007 | |
6008 return 1; | |
6009 } | |
6010 | |
8227 | 6011 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6012 GaimConnection *gc = sess->aux_data; | |
6013 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6014 GaimBuddy *b; | |
6015 GaimGroup *g; | |
6016 va_list ap; | |
6017 fu16_t type; | |
6018 const char *name; | |
6019 | |
6020 va_start(ap, fr); | |
6021 type = (fu16_t)va_arg(ap, int); | |
6022 name = va_arg(ap, char *); | |
6023 va_end(ap); | |
6024 | |
6025 if ((type != 0x0000) || (name == NULL)) | |
6026 return 1; | |
6027 | |
6028 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6029 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6030 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6031 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6032 b = gaim_find_buddy(gc->account, name); | |
6033 free(alias); | |
6034 | |
6035 if (b) { | |
6036 /* Get server stored alias */ | |
6037 if (alias_utf8) { | |
6038 g_free(b->alias); | |
6039 b->alias = g_strdup(alias_utf8); | |
6040 } | |
6041 } else { | |
6042 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6043 | |
6044 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6045 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6046 gaim_blist_add_group(g, NULL); | |
6047 } | |
6048 | |
8660 | 6049 gaim_debug_info("oscar", |
9285 | 6050 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6051 gaim_blist_add_buddy(b, NULL, g, NULL); |
6052 } | |
6053 g_free(gname_utf8); | |
6054 g_free(alias_utf8); | |
6055 | |
6056 return 1; | |
6057 } | |
6058 | |
4230 | 6059 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6060 GaimConnection *gc = sess->aux_data; |
4230 | 6061 va_list ap; |
6062 char *sn, *msg; | |
4236 | 6063 gchar *dialog_msg, *nombre; |
4230 | 6064 struct name_data *data; |
6695 | 6065 GaimBuddy *buddy; |
4230 | 6066 |
6067 va_start(ap, fr); | |
6068 sn = va_arg(ap, char *); | |
6069 msg = va_arg(ap, char *); | |
6070 va_end(ap); | |
6071 | |
8660 | 6072 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6073 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6074 |
4687 | 6075 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6076 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6077 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6078 else |
6079 nombre = g_strdup(sn); | |
6080 | |
6081 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 | 6082 data = g_new(struct name_data, 1); |
6083 data->gc = gc; | |
6084 data->name = g_strdup(sn); | |
6085 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6086 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6087 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6088 0, data, |
7023 | 6089 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6090 G_CALLBACK(oscar_free_name_data)); |
4236 | 6091 |
4230 | 6092 g_free(dialog_msg); |
4236 | 6093 g_free(nombre); |
4230 | 6094 |
6095 return 1; | |
6096 } | |
6097 | |
6098 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6099 GaimConnection *gc = sess->aux_data; |
4230 | 6100 va_list ap; |
6101 char *sn, *msg; | |
4236 | 6102 gchar *dialog_msg, *nombre; |
4230 | 6103 struct name_data *data; |
6695 | 6104 GaimBuddy *buddy; |
4230 | 6105 |
6106 va_start(ap, fr); | |
6107 sn = va_arg(ap, char *); | |
6108 msg = va_arg(ap, char *); | |
6109 va_end(ap); | |
6110 | |
8660 | 6111 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6112 "ssi: received authorization request from %s\n", sn); |
4230 | 6113 |
4687 | 6114 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6115 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6116 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6117 else |
6118 nombre = g_strdup(sn); | |
6119 | |
4337 | 6120 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 | 6121 data = g_new(struct name_data, 1); |
6122 data->gc = gc; | |
6123 data->name = g_strdup(sn); | |
6124 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6125 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6126 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6127 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6128 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6129 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6130 |
4230 | 6131 g_free(dialog_msg); |
4236 | 6132 g_free(nombre); |
4230 | 6133 |
6134 return 1; | |
6135 } | |
6136 | |
6137 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6138 GaimConnection *gc = sess->aux_data; |
4230 | 6139 va_list ap; |
6140 char *sn, *msg; | |
4236 | 6141 gchar *dialog_msg, *nombre; |
4230 | 6142 fu8_t reply; |
6695 | 6143 GaimBuddy *buddy; |
4230 | 6144 |
6145 va_start(ap, fr); | |
6146 sn = va_arg(ap, char *); | |
6147 reply = (fu8_t)va_arg(ap, int); | |
6148 msg = va_arg(ap, char *); | |
6149 va_end(ap); | |
6150 | |
8660 | 6151 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6152 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6153 |
4687 | 6154 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6155 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6156 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6157 else |
6158 nombre = g_strdup(sn); | |
6159 | |
4230 | 6160 if (reply) { |
6161 /* Granted */ | |
7023 | 6162 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
|
6163 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6164 } else { |
6165 /* Denied */ | |
7023 | 6166 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
|
6167 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6168 } |
6169 g_free(dialog_msg); | |
4236 | 6170 g_free(nombre); |
4230 | 6171 |
6172 return 1; | |
6173 } | |
6174 | |
6175 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6176 GaimConnection *gc = sess->aux_data; |
4230 | 6177 va_list ap; |
6178 char *sn; | |
6695 | 6179 GaimBuddy *buddy; |
4230 | 6180 |
6181 va_start(ap, fr); | |
6182 sn = va_arg(ap, char *); | |
6183 va_end(ap); | |
6184 | |
4687 | 6185 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6186 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6187 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6188 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6189 |
6190 return 1; | |
6191 } | |
4269 | 6192 #endif |
2086 | 6193 |
5575 | 6194 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6195 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6196 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6197 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6198 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6199 pce->label = _("_Group:"); |
5234 | 6200 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6201 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6202 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6203 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6204 pce->label = _("_Exchange:"); |
5234 | 6205 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6206 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6207 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6208 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6209 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6210 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6211 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6212 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6213 |
8308 | 6214 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6215 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6216 aim_conn_t *cur; |
5234 | 6217 char *name, *exchange; |
6218 | |
6219 name = g_hash_table_lookup(data, "room"); | |
6220 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6221 |
8660 | 6222 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6223 "Attempting to join chat room %s.\n", name); |
8308 | 6224 |
6225 if ((name == NULL) || (*name == '\0')) { | |
6226 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6227 return; | |
6228 } | |
6229 | |
4617 | 6230 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6231 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6232 "chatnav exists, creating room\n"); |
5234 | 6233 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6234 } else { |
6235 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6236 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6237 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6238 "chatnav does not exist, opening chatnav\n"); |
5234 | 6239 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6240 cr->name = g_strdup(name); |
4617 | 6241 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6242 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6243 } |
6244 } | |
6245 | |
8308 | 6246 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6247 OscarData *od = (OscarData *)gc->proto_data; | |
6248 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6249 |
6250 if (!ccon) | |
6251 return; | |
6252 | |
8225 | 6253 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6254 ccon->exchange, ccon->name, 0x0); |
6255 } | |
6256 | |
8308 | 6257 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6258 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6259 GSList *bcs = gc->buddy_chats; | |
5679 | 6260 GaimConversation *b = NULL; |
2086 | 6261 struct chat_connection *c = NULL; |
6262 int count = 0; | |
6263 | |
6264 while (bcs) { | |
6265 count++; | |
5679 | 6266 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6267 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6268 break; |
6269 bcs = bcs->next; | |
6270 b = NULL; | |
6271 } | |
6272 | |
6273 if (!b) | |
6274 return; | |
6275 | |
8660 | 6276 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6277 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6278 |
8308 | 6279 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6280 if (c != NULL) { |
4617 | 6281 if (od) |
6282 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6283 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6284 gaim_input_remove(c->inpa); |
8308 | 6285 if (gc && od->sess) |
4617 | 6286 aim_conn_kill(od->sess, &c->conn); |
2086 | 6287 g_free(c->name); |
6288 g_free(c->show); | |
6289 g_free(c); | |
6290 } | |
6291 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6292 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6293 } |
6294 | |
8219 | 6295 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6296 OscarData *od = (OscarData *)gc->proto_data; | |
6297 GError *err = NULL; | |
6298 GaimConversation *conv = NULL; | |
2086 | 6299 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6300 char *buf, *buf2; |
8219 | 6301 char *charset = NULL; |
6302 int encoding; | |
8907 | 6303 gsize len; |
8219 | 6304 |
6305 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6306 return -EINVAL; |
2086 | 6307 |
8219 | 6308 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6309 return -EINVAL; |
2086 | 6310 |
8219 | 6311 buf = gaim_strdup_withhtml(message); |
6312 len = strlen(buf); | |
6313 | |
8962 | 6314 if (strstr(buf, "<IMG ")) |
6315 gaim_conversation_write(conv, "", | |
6316 _("Your IM Image was not sent. " | |
6317 "You cannot send IM Images in AIM chats."), | |
6318 GAIM_MESSAGE_ERROR, time(NULL)); | |
6319 | |
8219 | 6320 encoding = oscar_encoding_check(buf); |
8233 | 6321 if (encoding & AIM_IMFLAGS_UNICODE) { |
8660 | 6322 gaim_debug_info("oscar", "Sending Unicode chat\n"); |
8219 | 6323 charset = "unicode-2-0"; |
6324 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
6325 if (err) { | |
8660 | 6326 gaim_debug_error("oscar", |
8359 | 6327 "Error converting to unicode-2-0: %s\n", err->message); |
6328 g_error_free(err); | |
6329 } | |
8219 | 6330 } else if (encoding & AIM_IMFLAGS_ISO_8859_1) { |
8660 | 6331 gaim_debug_info("oscar", "Sending ISO-8859-1 chat\n"); |
8219 | 6332 charset = "iso-8859-1"; |
6333 buf2 = g_convert(buf, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); | |
6334 if (err) { | |
8660 | 6335 gaim_debug_error("oscar", |
8359 | 6336 "Error converting to iso-8859-1: %s\n", err->message); |
8219 | 6337 g_error_free(err); |
8359 | 6338 err = NULL; |
6339 | |
8660 | 6340 gaim_debug_info("oscar", "Falling back to Unicode\n"); |
8359 | 6341 charset = "unicode-2-0"; |
6342 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
8219 | 6343 if (err) { |
8660 | 6344 gaim_debug_error("oscar", |
8359 | 6345 "Error converting to unicode-2-0: %s\n", |
6346 err->message); | |
8219 | 6347 g_error_free(err); |
6348 } | |
2086 | 6349 } |
8219 | 6350 } else { |
6351 charset = "us-ascii"; | |
6352 buf2 = g_strdup(buf); | |
6353 } | |
8359 | 6354 g_free(buf); |
6355 | |
6356 if ((len > c->maxlen) || (len > c->maxvis)) { | |
6357 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6358 return -E2BIG; |
8359 | 6359 } |
6360 | |
6361 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charset, "en"); | |
8219 | 6362 g_free(buf2); |
8359 | 6363 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6364 return 0; |
2086 | 6365 } |
6366 | |
6695 | 6367 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6368 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6369 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 6370 return "icq"; |
6371 else | |
6372 return "aim"; | |
6373 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6374 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6375 if (b != NULL && isdigit(b->name[0])) |
4687 | 6376 return "icq"; |
6377 return "aim"; | |
6378 } | |
6379 | |
6695 | 6380 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 6381 { |
7334 | 6382 GaimAccount *account = NULL; |
6383 GaimConnection *gc = NULL; | |
6384 OscarData *od = NULL; | |
4687 | 6385 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6386 int i = 0; | |
7334 | 6387 aim_userinfo_t *userinfo = NULL; |
6388 | |
6389 if (b != NULL) | |
6390 account = b->account; | |
6391 if (account != NULL) | |
6392 gc = account->gc; | |
6393 if (gc != NULL) | |
6394 od = gc->proto_data; | |
7945 | 6395 if (od != NULL) |
6396 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6397 |
5131 | 6398 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6399 char *gname; | |
7334 | 6400 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6401 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6402 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6403 emblems[i++] = "notauthorized"; | |
6404 } else { | |
6405 emblems[i++] = "offline"; | |
6406 } | |
6407 } | |
4916 | 6408 |
4766 | 6409 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 6410 int uc = b->uc >> 16; |
4766 | 6411 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6412 emblems[i++] = "invisible"; |
4766 | 6413 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6414 emblems[i++] = "freeforchat"; |
4766 | 6415 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6416 emblems[i++] = "dnd"; |
4766 | 6417 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6418 emblems[i++] = "na"; |
4766 | 6419 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6420 emblems[i++] = "occupied"; |
4766 | 6421 else if (uc & AIM_ICQ_STATE_AWAY) |
6422 emblems[i++] = "away"; | |
6423 } else { | |
6424 if (b->uc & UC_UNAVAILABLE) | |
6425 emblems[i++] = "away"; | |
6426 } | |
4687 | 6427 if (b->uc & UC_WIRELESS) |
6428 emblems[i++] = "wireless"; | |
6429 if (b->uc & UC_AOL) | |
6430 emblems[i++] = "aol"; | |
6431 if (b->uc & UC_ADMIN) | |
6432 emblems[i++] = "admin"; | |
6433 if (b->uc & UC_AB && i < 4) | |
6434 emblems[i++] = "activebuddy"; | |
4766 | 6435 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6436 emblems[i++] = "unconfirmed"; */ | |
7334 | 6437 |
7945 | 6438 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6439 emblems[i++] = "hiptop"; | |
6440 | |
6441 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6442 emblems[i++] = "secure"; |
6443 | |
4687 | 6444 *se = emblems[0]; |
6445 *sw = emblems[1]; | |
6446 *nw = emblems[2]; | |
6447 *ne = emblems[3]; | |
6448 } | |
6449 | |
6695 | 6450 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6451 GaimConnection *gc = b->account->gc; |
7283 | 6452 OscarData *od = gc->proto_data; |
7045 | 6453 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6454 GString *str = g_string_new(""); |
5131 | 6455 |
6456 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6457 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6458 |
6459 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6460 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6461 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6462 g_free(charset); |
7011 | 6463 if (away_utf8 != NULL) { |
7091 | 6464 gchar *tmp1, *tmp2; |
9627 | 6465 /* tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); This replacement is handled in strip_html. |
6466 * g_free(away_utf8); | |
6467 */ | |
6468 tmp2 = gaim_markup_strip_html(away_utf8); | |
8341 | 6469 g_free(away_utf8); |
8571 | 6470 tmp1 = gaim_escape_html(tmp2); |
7091 | 6471 g_free(tmp2); |
8700 | 6472 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6473 g_free(tmp1); |
8701 | 6474 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
9627 | 6475 |
8700 | 6476 g_free(tmp2); |
5836 | 6477 } |
5131 | 6478 } |
8701 | 6479 } |
6480 | |
6481 return g_string_free(str, FALSE); | |
5131 | 6482 } |
6483 | |
6695 | 6484 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 6485 GaimConnection *gc = b->account->gc; |
7283 | 6486 OscarData *od = gc->proto_data; |
5167 | 6487 gchar *ret = NULL; |
6488 | |
6489 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
6490 if (isdigit(b->name[0])) | |
8701 | 6491 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6492 else |
6493 ret = g_strdup(_("Away")); | |
5836 | 6494 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6495 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 6496 if (bi->availmsg) |
6497 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 6498 } else { |
5167 | 6499 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6500 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6501 ret = g_strdup(_("Not Authorized")); | |
6502 else | |
6503 ret = g_strdup(_("Offline")); | |
6504 } | |
6505 | |
6506 return ret; | |
6507 } | |
6508 | |
5842 | 6509 |
5844 | 6510 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6511 GaimConnection *gc = sess->aux_data; |
7283 | 6512 OscarData *od = gc->proto_data; |
5892 | 6513 va_list ap; |
5842 | 6514 fu16_t type; |
5892 | 6515 fu8_t flags = 0, length = 0; |
6516 char *md5 = NULL; | |
6517 | |
7334 | 6518 |
5842 | 6519 va_start(ap, fr); |
6520 type = va_arg(ap, int); | |
5892 | 6521 |
6522 switch(type) { | |
6523 case 0x0000: | |
6524 case 0x0001: { | |
6525 flags = va_arg(ap, int); | |
6526 length = va_arg(ap, int); | |
6527 md5 = va_arg(ap, char *); | |
6528 | |
6529 if (flags == 0x41) { | |
6530 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6531 od->iconconnecting = TRUE; | |
6532 od->set_icon = TRUE; | |
6533 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6534 } else { | |
6039 | 6535 struct stat st; |
6536 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6537 if (iconfile == NULL) { | |
8363 | 6538 aim_ssi_delicon(od->sess); |
6039 | 6539 } else if (!stat(iconfile, &st)) { |
6540 char *buf = g_malloc(st.st_size); | |
6541 FILE *file = fopen(iconfile, "rb"); | |
6542 if (file) { | |
9532 | 6543 /* XXX - Use g_file_get_contents()? */ |
6039 | 6544 fread(buf, 1, st.st_size, file); |
6545 fclose(file); | |
8660 | 6546 gaim_debug_info("oscar", |
6039 | 6547 "Uploading icon to icon server\n"); |
6879 | 6548 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6549 } else |
8660 | 6550 gaim_debug_error("oscar", |
6039 | 6551 "Can't open buddy icon file!\n"); |
6552 g_free(buf); | |
6553 } else { | |
8660 | 6554 gaim_debug_error("oscar", |
6039 | 6555 "Can't stat buddy icon file!\n"); |
5892 | 6556 } |
6557 } | |
8363 | 6558 } else if (flags == 0x81) { |
6559 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6560 if (iconfile == NULL) | |
6561 aim_ssi_delicon(od->sess); | |
6562 else | |
6563 aim_ssi_seticon(od->sess, md5, length); | |
6564 } | |
5892 | 6565 } break; |
6566 | |
6567 case 0x0002: { /* We just set an "available" message? */ | |
6568 } break; | |
6569 } | |
6570 | |
5842 | 6571 va_end(ap); |
5844 | 6572 |
6573 return 0; | |
5842 | 6574 } |
5892 | 6575 |
5575 | 6576 static void oscar_set_permit_deny(GaimConnection *gc) { |
6577 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6578 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6579 #ifdef NOSSI |
8143 | 6580 GSList *list; |
4230 | 6581 char buf[MAXMSGLEN]; |
6582 int at; | |
6583 | |
5575 | 6584 switch(account->perm_deny) { |
8175 | 6585 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6586 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6587 break; |
8175 | 6588 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6589 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6590 break; |
8175 | 6591 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6592 list = account->permit; |
4230 | 6593 at = 0; |
6594 while (list) { | |
6595 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6596 list = list->next; | |
6597 } | |
6598 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6599 break; | |
8175 | 6600 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6601 list = account->deny; |
4230 | 6602 at = 0; |
6603 while (list) { | |
6604 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6605 list = list->next; | |
6606 } | |
6607 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6608 break; | |
6609 default: | |
6610 break; | |
2086 | 6611 } |
4230 | 6612 #else |
8175 | 6613 if (od->sess->ssi.received_data) { |
6614 switch (account->perm_deny) { | |
6615 case GAIM_PRIVACY_ALLOW_ALL: | |
6616 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6617 break; | |
6618 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6619 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6620 break; | |
6621 case GAIM_PRIVACY_ALLOW_USERS: | |
6622 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6623 break; | |
6624 case GAIM_PRIVACY_DENY_ALL: | |
6625 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6626 break; | |
6627 case GAIM_PRIVACY_DENY_USERS: | |
6628 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6629 break; | |
6630 default: | |
6631 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6632 break; | |
6633 } | |
6634 } | |
4230 | 6635 #endif |
2086 | 6636 } |
6637 | |
5575 | 6638 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6639 #ifdef NOSSI |
8143 | 6640 if (gc->account->perm_deny == 3) |
4269 | 6641 oscar_set_permit_deny(gc); |
6642 #else | |
7283 | 6643 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6644 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6645 if (od->sess->ssi.received_data) |
4889 | 6646 aim_ssi_addpermit(od->sess, who); |
4230 | 6647 #endif |
2086 | 6648 } |
6649 | |
5575 | 6650 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6651 #ifdef NOSSI |
8143 | 6652 if (gc->account->perm_deny == 4) |
4269 | 6653 oscar_set_permit_deny(gc); |
6654 #else | |
7283 | 6655 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6656 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6657 if (od->sess->ssi.received_data) |
4889 | 6658 aim_ssi_adddeny(od->sess, who); |
4230 | 6659 #endif |
2086 | 6660 } |
6661 | |
5575 | 6662 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6663 #ifdef NOSSI |
8143 | 6664 if (gc->account->perm_deny == 3) |
4269 | 6665 oscar_set_permit_deny(gc); |
6666 #else | |
7283 | 6667 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6668 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6669 if (od->sess->ssi.received_data) |
4889 | 6670 aim_ssi_delpermit(od->sess, who); |
4230 | 6671 #endif |
2086 | 6672 } |
6673 | |
5575 | 6674 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6675 #ifdef NOSSI |
8143 | 6676 if (gc->account->perm_deny == 4) |
4269 | 6677 oscar_set_permit_deny(gc); |
6678 #else | |
7283 | 6679 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6680 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6681 if (od->sess->ssi.received_data) |
4889 | 6682 aim_ssi_deldeny(od->sess, who); |
4230 | 6683 #endif |
2086 | 6684 } |
6685 | |
5575 | 6686 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 6687 { |
7283 | 6688 OscarData *od = gc->proto_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6689 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6690 |
8257 | 6691 if (od->icq) { |
6692 m = g_list_append(m, _("Online")); | |
6693 m = g_list_append(m, _("Away")); | |
6694 m = g_list_append(m, _("Do Not Disturb")); | |
6695 m = g_list_append(m, _("Not Available")); | |
6696 m = g_list_append(m, _("Occupied")); | |
6697 m = g_list_append(m, _("Free For Chat")); | |
6698 m = g_list_append(m, _("Invisible")); | |
6699 } else { | |
6700 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6701 m = g_list_append(m, _("Back")); |
8257 | 6702 m = g_list_append(m, _("Visible")); |
6703 m = g_list_append(m, _("Invisible")); | |
6704 } | |
4333 | 6705 |
6706 return m; | |
6707 } | |
6708 | |
7172 | 6709 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6710 GaimConnection *gc = data->gc; |
6711 OscarData *od = gc->proto_data; | |
7172 | 6712 GaimBuddy *b; |
6713 GaimGroup *g; | |
6714 | |
6715 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6716 oscar_free_name_data(data); | |
6717 return; | |
6718 } | |
6719 | |
6720 if (!(g = gaim_find_buddys_group(b))) { | |
6721 oscar_free_name_data(data); | |
6722 return; | |
6723 } | |
6724 | |
6725 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6726 |
6727 if (!aim_sncmp(data->name, gc->account->username)) | |
6728 gaim_check_comment(od, text); | |
6729 | |
7172 | 6730 oscar_free_name_data(data); |
6731 } | |
6732 | |
9030 | 6733 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6734 | |
6735 GaimBuddy *buddy; | |
6736 GaimConnection *gc; | |
6737 OscarData *od; | |
6738 struct name_data *data; | |
7172 | 6739 GaimGroup *g; |
6740 char *comment; | |
6741 gchar *comment_utf8; | |
9631 | 6742 gchar *title; |
7172 | 6743 |
9030 | 6744 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6745 | |
6746 buddy = (GaimBuddy *) node; | |
6747 gc = gaim_account_get_connection(buddy->account); | |
6748 od = gc->proto_data; | |
6749 | |
6750 data = g_new(struct name_data, 1); | |
6751 | |
6752 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6753 return; |
9030 | 6754 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6755 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6756 | |
6757 data->gc = gc; | |
9030 | 6758 data->name = g_strdup(buddy->name); |
7172 | 6759 data->nick = NULL; |
6760 | |
9631 | 6761 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6762 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6763 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6764 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6765 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6766 data); | |
9631 | 6767 g_free(title); |
7172 | 6768 |
6769 free(comment); | |
6770 g_free(comment_utf8); | |
6771 } | |
6772 | |
9030 | 6773 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6774 | |
6775 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6776 OscarData *od = gc->proto_data; |
9030 | 6777 |
4333 | 6778 GList *m = NULL; |
9030 | 6779 GaimBlistNodeAction *act; |
6780 | |
6781 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6782 oscar_buddycb_edit_comment, NULL); | |
6783 m = g_list_append(m, act); | |
7172 | 6784 |
4333 | 6785 if (od->icq) { |
4624 | 6786 #if 0 |
9030 | 6787 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6788 oscar_get_icqstatusmsg, NULL); | |
6789 m = g_list_append(m, act); | |
4624 | 6790 #endif |
4333 | 6791 } else { |
7011 | 6792 aim_userinfo_t *userinfo; |
9030 | 6793 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6794 | |
6795 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
6796 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
6797 | |
7011 | 6798 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 6799 act = gaim_blist_node_action_new(_("Direct IM"), |
6800 oscar_ask_direct_im, NULL); | |
6801 m = g_list_append(m, act); | |
5917 | 6802 } |
9466 | 6803 #if 0 |
7650 | 6804 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { |
9030 | 6805 act = gaim_blist_node_action_new(_("Send File"), |
6806 oscar_ask_sendfile, NULL); | |
6807 m = g_list_append(m, act); | |
7650 | 6808 } |
7011 | 6809 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6810 act = gaim_blist_node_action_new(_("Get File"), |
6811 oscar_ask_getfile, NULL); | |
6812 m = g_list_append(m, act); | |
5917 | 6813 } |
4826 | 6814 #endif |
4333 | 6815 } |
5131 | 6816 } |
5197 | 6817 |
5131 | 6818 if (od->sess->ssi.received_data) { |
9030 | 6819 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6820 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
6821 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
6822 gaim_auth_sendrequest_menu, NULL); | |
6823 m = g_list_append(m, act); | |
4333 | 6824 } |
4916 | 6825 } |
6826 | |
4333 | 6827 return m; |
6828 } | |
6829 | |
9030 | 6830 |
6831 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6832 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6833 return oscar_buddy_menu((GaimBuddy *) node); | |
6834 } else { | |
6835 return NULL; | |
6836 } | |
6837 } | |
6838 | |
6839 | |
5575 | 6840 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6841 OscarData *od = gc->proto_data; |
5575 | 6842 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6843 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6844 od->setnick = TRUE; | |
6845 od->newsn = g_strdup(nick); | |
6846 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6847 } else { | |
6848 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6849 } | |
6850 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6851 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6852 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6853 } |
6854 } | |
6855 | |
9015 | 6856 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 6857 { |
9015 | 6858 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 6859 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 6860 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6861 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6862 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6863 gc); |
4333 | 6864 } |
6865 | |
9015 | 6866 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 6867 { |
9015 | 6868 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6869 OscarData *od = gc->proto_data; |
4333 | 6870 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6871 | |
6872 if (conn) { | |
6873 aim_admin_reqconfirm(od->sess, conn); | |
6874 } else { | |
6875 od->conf = TRUE; | |
6876 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6877 } | |
6878 } | |
6879 | |
9015 | 6880 static void oscar_show_email(GaimPluginAction *action) |
4333 | 6881 { |
9015 | 6882 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6883 OscarData *od = gc->proto_data; |
4333 | 6884 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6885 | |
6886 if (conn) { | |
6887 aim_admin_getinfo(od->sess, conn, 0x11); | |
6888 } else { | |
6889 od->reqemail = TRUE; | |
6890 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6891 } | |
6892 } | |
6893 | |
5575 | 6894 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6895 { |
7283 | 6896 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6897 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
|
6898 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6899 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6900 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6901 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6902 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6903 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6904 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6905 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6906 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6907 |
9015 | 6908 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 6909 { |
9015 | 6910 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6911 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 6912 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6913 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6914 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6915 gc); |
4333 | 6916 } |
6917 | |
9015 | 6918 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 6919 { |
9015 | 6920 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6921 OscarData *od = gc->proto_data; |
4333 | 6922 gchar *nombre, *text, *tmp; |
6695 | 6923 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 6924 int num=0; |
6925 | |
6873 | 6926 text = g_strdup(""); |
4333 | 6927 |
4785 | 6928 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 6929 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 6930 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
6931 continue; | |
6695 | 6932 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
6933 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 6934 continue; |
6695 | 6935 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
6936 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
6937 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6938 continue; | |
6939 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 6940 if (gaim_buddy_get_alias_only(buddy)) |
6941 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 6942 else |
6943 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 6944 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 6945 g_free(text); |
6946 text = tmp; | |
6947 g_free(nombre); | |
6948 num++; | |
6949 } | |
4333 | 6950 } |
2979 | 6951 } |
4333 | 6952 } |
6953 | |
6954 if (!num) { | |
6955 g_free(text); | |
6873 | 6956 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
6957 } | |
6958 | |
6959 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
6960 "the following buddies"), _("You can re-request " | |
6961 "authorization from these buddies by " | |
6962 "right-clicking on them and selecting " | |
6963 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 6964 g_free(text); |
2979 | 6965 } |
6966 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6967 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6968 { |
8950 | 6969 OscarData *od = (OscarData *)gc->proto_data; |
6970 | |
6971 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6972 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6973 |
9015 | 6974 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6975 { |
9015 | 6976 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6977 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6978 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6979 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6980 "searching for."), |
8697 | 6981 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6982 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6983 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6984 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6985 |
7366 | 6986 #if 0 |
5917 | 6987 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 6988 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 6989 |
7334 | 6990 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 6991 aim_srv_setavailmsg(od->sess, text); |
6992 } | |
6993 | |
6994 static void oscar_show_setavailmsg(GaimConnection *gc) | |
6995 { | |
7313 | 6996 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
6997 _("I'm doing work and hoping for a distraction--IM me!"), | |
8697 | 6998 TRUE, FALSE, NULL, |
5917 | 6999 _("OK"), G_CALLBACK(oscar_setavailmsg), |
7000 _("Cancel"), NULL, | |
7001 gc); | |
7002 } | |
7366 | 7003 #endif |
5917 | 7004 |
9015 | 7005 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7006 { |
9015 | 7007 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7008 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7009 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7010 |
9015 | 7011 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7012 { |
9015 | 7013 GaimConnection *gc = (GaimConnection *) action->context; |
8576 | 7014 gaim_notify_uri(gc, "http://web.icq.com/whitepages/login/1,,,00.html"); |
7015 } | |
7016 | |
9015 | 7017 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7018 { |
9015 | 7019 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7020 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7021 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7022 |
9015 | 7023 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7024 { |
9015 | 7025 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7026 OscarData *od = gc->proto_data; |
5575 | 7027 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
|
7028 gaim_notify_uri(gc, substituted); |
5517 | 7029 g_free(substituted); |
4333 | 7030 } |
7031 | |
9015 | 7032 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7033 { |
9015 | 7034 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7035 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7036 } | |
7037 | |
5842 | 7038 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7039 { | |
7283 | 7040 OscarData *od = gc->proto_data; |
5844 | 7041 aim_session_t *sess = od->sess; |
5842 | 7042 FILE *file; |
7043 struct stat st; | |
5844 | 7044 |
6039 | 7045 if (iconfile == NULL) { |
8363 | 7046 aim_ssi_delicon(od->sess); |
6039 | 7047 } else if (!stat(iconfile, &st)) { |
5842 | 7048 char *buf = g_malloc(st.st_size); |
7049 file = fopen(iconfile, "rb"); | |
7050 if (file) { | |
6052 | 7051 md5_state_t *state; |
6039 | 7052 char md5[16]; |
9532 | 7053 /* XXX - Use g_file_get_contents()? */ |
5842 | 7054 int len = fread(buf, 1, st.st_size, file); |
6039 | 7055 fclose(file); |
6052 | 7056 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7057 md5_init(state); |
7058 md5_append(state, buf, len); | |
7059 md5_finish(state, md5); | |
7060 g_free(state); | |
7061 aim_ssi_seticon(sess, md5, 16); | |
7062 } else | |
8660 | 7063 gaim_debug_error("oscar", |
5842 | 7064 "Can't open buddy icon file!\n"); |
7065 g_free(buf); | |
7066 } else | |
8660 | 7067 gaim_debug_error("oscar", |
5842 | 7068 "Can't stat buddy icon file!\n"); |
7069 } | |
7070 | |
7071 | |
9015 | 7072 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7073 { |
9015 | 7074 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7075 OscarData *od = gc->proto_data; |
4333 | 7076 GList *m = NULL; |
9015 | 7077 GaimPluginAction *act; |
7078 | |
7079 act = gaim_plugin_action_new(_("Set User Info..."), | |
7080 oscar_show_set_info); | |
7081 m = g_list_append(m, act); | |
4333 | 7082 |
8576 | 7083 if (od->icq) { |
9015 | 7084 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7085 oscar_show_set_info_icqurl); | |
7086 m = g_list_append(m, act); | |
8576 | 7087 } |
7088 | |
7366 | 7089 #if 0 |
9015 | 7090 act = gaim_plugin_action_new(_("Set Available Message..."), |
7091 oscar_show_setavailmsg); | |
7092 m = g_list_append(m, act); | |
7366 | 7093 #endif |
5917 | 7094 |
9015 | 7095 act = gaim_plugin_action_new(_("Change Password..."), |
7096 oscar_change_pass); | |
7097 m = g_list_append(m, act); | |
4617 | 7098 |
7099 if (od->sess->authinfo->chpassurl) { | |
9015 | 7100 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7101 oscar_show_chpassurl); | |
7102 m = g_list_append(m, act); | |
7103 | |
7104 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7105 oscar_show_imforwardingurl); | |
7106 m = g_list_append(m, act); | |
7026 | 7107 } |
7108 | |
5238 | 7109 if (!od->icq) { |
4617 | 7110 /* AIM actions */ |
7111 m = g_list_append(m, NULL); | |
4333 | 7112 |
9015 | 7113 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7114 oscar_show_format_screenname); | |
7115 m = g_list_append(m, act); | |
7116 | |
7117 act = gaim_plugin_action_new(_("Confirm Account"), | |
7118 oscar_confirm_account); | |
7119 m = g_list_append(m, act); | |
7120 | |
7121 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7122 oscar_show_email); | |
7123 m = g_list_append(m, act); | |
7124 | |
7125 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7126 oscar_show_change_email); | |
7127 m = g_list_append(m, act); | |
2086 | 7128 } |
4333 | 7129 |
7130 m = g_list_append(m, NULL); | |
7131 | |
9015 | 7132 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7133 oscar_show_awaitingauth); | |
7134 m = g_list_append(m, act); | |
4333 | 7135 |
2086 | 7136 m = g_list_append(m, NULL); |
4333 | 7137 |
9015 | 7138 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7139 oscar_show_find_email); | |
7140 m = g_list_append(m, act); | |
4333 | 7141 |
8591 | 7142 #if 0 |
9015 | 7143 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7144 show_find_info); | |
7145 m = g_list_append(m, act); | |
8591 | 7146 #endif |
2086 | 7147 |
7148 return m; | |
7149 } | |
7150 | |
5575 | 7151 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7152 { |
7283 | 7153 OscarData *od = gc->proto_data; |
4617 | 7154 |
7155 if (od->icq) { | |
7156 aim_icq_changepasswd(od->sess, new); | |
2086 | 7157 } else { |
4617 | 7158 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7159 if (conn) { | |
7160 aim_admin_changepasswd(od->sess, conn, new, old); | |
7161 } else { | |
7162 od->chpass = TRUE; | |
7163 od->oldp = g_strdup(old); | |
7164 od->newp = g_strdup(new); | |
7165 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7166 } | |
2086 | 7167 } |
7168 } | |
7169 | |
6059 | 7170 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7171 { |
7283 | 7172 OscarData *od = gc->proto_data; |
8971 | 7173 struct oscar_direct_im *dim = oscar_direct_im_find(od, who); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7174 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7175 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7176 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7177 |
8971 | 7178 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7179 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7180 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7181 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7182 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7183 GAIM_PRPL_API_VERSION, |
9308 | 7184 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7185 NULL, /* user_splits */ |
7186 NULL, /* protocol_options */ | |
7187 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7188 oscar_list_icon, /* list_icon */ | |
7189 oscar_list_emblems, /* list_emblems */ | |
7190 oscar_status_text, /* status_text */ | |
7191 oscar_tooltip_text, /* tooltip_text */ | |
7192 oscar_away_states, /* away_states */ | |
7193 oscar_blist_node_menu, /* blist_node_menu */ | |
7194 oscar_chat_info, /* chat_info */ | |
7195 oscar_login, /* login */ | |
7196 oscar_close, /* close */ | |
7197 oscar_send_im, /* send_im */ | |
7198 oscar_set_info, /* set_info */ | |
7199 oscar_send_typing, /* send_typing */ | |
7200 oscar_get_info, /* get_info */ | |
7201 oscar_set_away, /* set_away */ | |
7202 oscar_set_idle, /* set_idle */ | |
7203 oscar_change_passwd, /* change_passwd */ | |
7204 oscar_add_buddy, /* add_buddy */ | |
7205 oscar_add_buddies, /* add_buddies */ | |
7206 oscar_remove_buddy, /* remove_buddy */ | |
7207 oscar_remove_buddies, /* remove_buddies */ | |
7208 oscar_add_permit, /* add_permit */ | |
7209 oscar_add_deny, /* add_deny */ | |
7210 oscar_rem_permit, /* rem_permit */ | |
7211 oscar_rem_deny, /* rem_deny */ | |
7212 oscar_set_permit_deny, /* set_permit_deny */ | |
7213 oscar_warn, /* warn */ | |
7214 oscar_join_chat, /* join_chat */ | |
7215 NULL, /* reject_chat */ | |
7216 oscar_chat_invite, /* chat_invite */ | |
7217 oscar_chat_leave, /* chat_leave */ | |
7218 NULL, /* chat_whisper */ | |
7219 oscar_send_chat, /* chat_send */ | |
7220 oscar_keepalive, /* keepalive */ | |
7221 NULL, /* register_user */ | |
7222 NULL, /* get_cb_info */ | |
7223 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7224 #ifndef NOSSI |
9475 | 7225 oscar_alias_buddy, /* alias_buddy */ |
7226 oscar_move_buddy, /* group_buddy */ | |
7227 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7228 #else |
9475 | 7229 NULL, /* alias_buddy */ |
7230 NULL, /* group_buddy */ | |
7231 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7232 #endif |
9475 | 7233 NULL, /* buddy_free */ |
7234 oscar_convo_closed, /* convo_closed */ | |
7235 NULL, /* normalize */ | |
7236 oscar_set_icon, /* set_buddy_icon */ | |
7237 NULL, /* remove_group */ | |
7238 NULL, /* get_cb_real_name */ | |
7239 NULL, /* set_chat_topic */ | |
7240 NULL, /* find_blist_chat */ | |
7241 NULL, /* roomlist_get_list */ | |
7242 NULL, /* roomlist_cancel */ | |
7243 NULL, /* roomlist_expand_category */ | |
7244 oscar_can_receive_file, /* can_receive_file */ | |
7245 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7246 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7247 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7248 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7249 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7250 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7251 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7252 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7253 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7254 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7255 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7256 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7257 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7258 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7259 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7260 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7261 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7262 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7263 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7264 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7265 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7266 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7267 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7268 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7269 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7270 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7271 NULL, /**< ui_info */ |
8993 | 7272 &prpl_info, /**< extra_info */ |
7273 NULL, | |
9015 | 7274 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7275 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7276 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7277 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7278 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7279 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7280 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7281 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7282 option = gaim_account_option_string_new(_("Auth host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7283 "login.oscar.aol.com"); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7284 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7285 option); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7286 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7287 option = gaim_account_option_int_new(_("Auth port"), "port", 5190); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7288 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7289 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7290 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7291 my_protocol = plugin; |
2086 | 7292 } |
7293 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7294 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |