Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 9680:958cfbb47ad6
[gaim-migrate @ 10532]
Dave West fixed bug 720441, "ICQ Offline messages have GMT timestamp."
Thanks!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 05 Aug 2004 21:15:41 +0000 |
parents | 52319a1d9a55 |
children | bd5abccacff2 |
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 | |
9639 | 378 } else if (!strcmp(encoding, "iso-8859-1") |
379 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 380 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
381 | |
382 } else if (!strcmp(encoding, "unicode-2-0")) { | |
383 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
384 | |
385 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
386 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
387 "attempting to convert to UTF-8 anyway\n"); | |
388 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
389 } | |
390 | |
391 /* | |
392 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
393 * we have been unable to convert the text to utf-8 from the encoding | |
394 * that was specified. So we check if the text is valid utf-8 then | |
395 * just copy it. | |
396 */ | |
397 if (utf8 == NULL) { | |
9638 | 398 if (textlen != 0 && *text != '\0' |
399 && !g_utf8_validate(text, textlen, NULL)) | |
9476 | 400 utf8 = g_strdup(_("(There was an error converting this message. The buddy you are speaking to most likely has a buggy client.)")); |
401 else | |
9481 | 402 utf8 = g_strndup(text, textlen); |
5129 | 403 } |
404 | |
405 return utf8; | |
406 } | |
407 | |
9407 | 408 gchar *oscar_caps_to_string(guint caps) |
8701 | 409 { |
9407 | 410 GString *str; |
411 gchar *tmp; | |
8701 | 412 guint bit = 1; |
413 | |
9407 | 414 str = g_string_new(""); |
415 | |
8701 | 416 if (!caps) { |
417 return NULL; | |
418 } else while (bit <= AIM_CAPS_LAST) { | |
419 if (bit & caps) { | |
420 switch (bit) { | |
421 case AIM_CAPS_BUDDYICON: | |
422 tmp = _("Buddy Icon"); | |
423 break; | |
424 case AIM_CAPS_TALK: | |
425 tmp = _("Voice"); | |
426 break; | |
427 case AIM_CAPS_DIRECTIM: | |
428 tmp = _("AIM Direct IM"); | |
429 break; | |
430 case AIM_CAPS_CHAT: | |
431 tmp = _("Chat"); | |
432 break; | |
433 case AIM_CAPS_GETFILE: | |
434 tmp = _("Get File"); | |
435 break; | |
436 case AIM_CAPS_SENDFILE: | |
437 tmp = _("Send File"); | |
438 break; | |
439 case AIM_CAPS_GAMES: | |
440 case AIM_CAPS_GAMES2: | |
441 tmp = _("Games"); | |
442 break; | |
443 case AIM_CAPS_ADDINS: | |
444 tmp = _("Add-Ins"); | |
445 break; | |
446 case AIM_CAPS_SENDBUDDYLIST: | |
447 tmp = _("Send Buddy List"); | |
448 break; | |
449 case AIM_CAPS_ICQ_DIRECT: | |
450 tmp = _("ICQ Direct Connect"); | |
451 break; | |
452 case AIM_CAPS_APINFO: | |
453 tmp = _("AP User"); | |
454 break; | |
455 case AIM_CAPS_ICQRTF: | |
456 tmp = _("ICQ RTF"); | |
457 break; | |
458 case AIM_CAPS_EMPTY: | |
459 tmp = _("Nihilist"); | |
460 break; | |
461 case AIM_CAPS_ICQSERVERRELAY: | |
462 tmp = _("ICQ Server Relay"); | |
463 break; | |
464 case AIM_CAPS_ICQUTF8OLD: | |
465 tmp = _("Old ICQ UTF8"); | |
466 break; | |
467 case AIM_CAPS_TRILLIANCRYPT: | |
468 tmp = _("Trillian Encryption"); | |
469 break; | |
470 case AIM_CAPS_ICQUTF8: | |
471 tmp = _("ICQ UTF8"); | |
472 break; | |
473 case AIM_CAPS_HIPTOP: | |
474 tmp = _("Hiptop"); | |
475 break; | |
476 case AIM_CAPS_SECUREIM: | |
477 tmp = _("Security Enabled"); | |
478 break; | |
479 case AIM_CAPS_VIDEO: | |
480 tmp = _("Video Chat"); | |
481 break; | |
482 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
483 case AIM_CAPS_ICHATAV: | |
484 tmp = _("iChat AV"); | |
485 break; | |
486 case AIM_CAPS_LIVEVIDEO: | |
487 tmp = _("Live Video"); | |
488 break; | |
489 case AIM_CAPS_CAMERA: | |
490 tmp = _("Camera"); | |
491 break; | |
492 default: | |
493 tmp = NULL; | |
494 break; | |
495 } | |
496 if (tmp) | |
9532 | 497 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 498 } |
499 bit <<= 1; | |
500 } | |
9407 | 501 |
502 return g_string_free(str, FALSE); | |
8701 | 503 } |
504 | |
505 static char *oscar_icqstatus(int state) { | |
506 /* Make a cute little string that shows the status of the dude or dudet */ | |
507 if (state & AIM_ICQ_STATE_CHAT) | |
508 return g_strdup_printf(_("Free For Chat")); | |
509 else if (state & AIM_ICQ_STATE_DND) | |
510 return g_strdup_printf(_("Do Not Disturb")); | |
511 else if (state & AIM_ICQ_STATE_OUT) | |
512 return g_strdup_printf(_("Not Available")); | |
513 else if (state & AIM_ICQ_STATE_BUSY) | |
514 return g_strdup_printf(_("Occupied")); | |
515 else if (state & AIM_ICQ_STATE_AWAY) | |
516 return g_strdup_printf(_("Away")); | |
517 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
518 return g_strdup_printf(_("Web Aware")); | |
519 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
520 return g_strdup_printf(_("Invisible")); | |
521 else | |
522 return g_strdup_printf(_("Online")); | |
523 } | |
524 | |
525 static void oscar_string_append(GString *str, char *newline, char *name, char *value) | |
8700 | 526 { |
527 gchar *utf8; | |
528 | |
529 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 530 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 531 g_free(utf8); |
532 } | |
533 } | |
534 | |
8701 | 535 static void oscar_string_append_info(GaimConnection *gc, GString *str, char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
536 { | |
537 OscarData *od = gc->proto_data; | |
538 GaimAccount *account = gaim_connection_get_account(gc); | |
539 GaimGroup *g = NULL; | |
540 struct buddyinfo *bi = NULL; | |
541 char *tmp; | |
542 | |
543 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
544 return; | |
545 | |
546 if (userinfo == NULL) | |
547 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
548 | |
549 if (b == NULL) | |
550 b = gaim_find_buddy(gc->account, userinfo->sn); | |
551 | |
552 if (b != NULL) | |
553 g = gaim_find_buddys_group(b); | |
554 | |
555 if (userinfo != NULL) | |
556 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
557 | |
8733 | 558 if (b != NULL) { |
559 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
560 if (isdigit(b->name[0])) { | |
561 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
562 oscar_string_append(str, newline, _("Status"), tmp); | |
563 g_free(tmp); | |
564 } | |
565 } else { | |
9625 | 566 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 567 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
568 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
569 else | |
570 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 571 } |
8733 | 572 } |
8701 | 573 |
574 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 575 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 576 (bi->ipaddr & 0xff000000) >> 24, |
577 (bi->ipaddr & 0x00ff0000) >> 16, | |
578 (bi->ipaddr & 0x0000ff00) >> 8, | |
579 (bi->ipaddr & 0x000000ff)); | |
580 oscar_string_append(str, newline, _("IP Address"), tmp); | |
581 g_free(tmp); | |
582 } | |
583 | |
584 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
585 tmp = oscar_caps_to_string(userinfo->capabilities); | |
586 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 587 g_free(tmp); |
8701 | 588 } |
589 | |
590 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
591 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
592 if (tmp != NULL) { | |
9625 | 593 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 594 g_free(tmp); |
9625 | 595 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
596 g_free(tmp2); | |
8701 | 597 } |
598 } | |
599 | |
600 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
601 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
602 oscar_string_append(str, newline, _("Available"), tmp); | |
603 g_free(tmp); | |
604 } | |
605 } | |
606 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
607 static char *extract_name(const char *name) { |
4121 | 608 char *tmp, *x; |
2086 | 609 int i, j; |
4120 | 610 |
611 if (!name) | |
4121 | 612 return NULL; |
613 | |
4120 | 614 x = strchr(name, '-'); |
4121 | 615 |
2086 | 616 if (!x) return NULL; |
617 x = strchr(++x, '-'); | |
618 if (!x) return NULL; | |
619 tmp = g_strdup(++x); | |
620 | |
621 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
622 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
623 if (x[i] != '%') { |
2086 | 624 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
625 continue; |
2086 | 626 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
627 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
628 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
629 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 630 } |
631 | |
632 tmp[j] = 0; | |
633 return tmp; | |
634 } | |
635 | |
5575 | 636 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 637 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 638 struct chat_connection *c = NULL; |
639 | |
640 while (g) { | |
641 c = (struct chat_connection *)g->data; | |
642 if (c->id == id) | |
643 break; | |
644 g = g->next; | |
645 c = NULL; | |
646 } | |
647 | |
648 return c; | |
649 } | |
650 | |
5575 | 651 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
|
652 aim_conn_t *conn) { |
7283 | 653 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 654 struct chat_connection *c = NULL; |
655 | |
656 while (g) { | |
657 c = (struct chat_connection *)g->data; | |
658 if (c->conn == conn) | |
659 break; | |
660 g = g->next; | |
661 c = NULL; | |
662 } | |
663 | |
664 return c; | |
665 } | |
666 | |
8219 | 667 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
668 GaimConversation *conv) { | |
669 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
670 struct chat_connection *c = NULL; | |
671 | |
672 while (g) { | |
673 c = (struct chat_connection *)g->data; | |
8733 | 674 if (c->conv == conv) |
8219 | 675 break; |
676 g = g->next; | |
677 c = NULL; | |
678 } | |
679 | |
680 return c; | |
681 } | |
682 | |
8971 | 683 /***************************************************************************** |
684 * Begin scary direct im stuff | |
685 *****************************************************************************/ | |
686 | |
687 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
688 GSList *d = od->direct_ims; | |
689 struct oscar_direct_im *m = NULL; | |
690 | |
691 while (d) { | |
692 m = (struct oscar_direct_im *)d->data; | |
693 if (!aim_sncmp(who, m->name)) | |
694 return m; | |
695 d = d->next; | |
696 } | |
697 | |
698 return NULL; | |
699 } | |
700 | |
701 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
702 { | |
703 gaim_debug_info("oscar", | |
704 "destroying Direct IM for %s.\n", dim->name); | |
705 | |
706 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 707 if (dim->gpc_pend) { |
708 dim->killme = TRUE; | |
709 return; | |
710 } | |
8971 | 711 if (dim->watcher) |
712 gaim_input_remove(dim->watcher); | |
713 if (dim->conn) { | |
714 aim_conn_close(dim->conn); | |
715 aim_conn_kill(od->sess, &dim->conn); | |
716 } | |
717 g_free(dim); | |
718 } | |
719 | |
720 /* the only difference between this and destroy is this writes a conv message */ | |
721 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
722 { | |
723 GaimConversation *conv; | |
724 char buf[256]; | |
725 | |
726 gaim_debug_info("oscar", | |
727 "%s disconnected Direct IM.\n", dim->name); | |
728 | |
729 if (dim->connected) | |
730 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 731 else |
8971 | 732 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
733 | |
734 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
735 if (conv) { | |
736 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 737 gaim_conversation_update_progress(conv, 0); |
8971 | 738 } else { |
739 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
740 } | |
741 | |
742 oscar_direct_im_destroy(od, dim); | |
743 | |
744 return; | |
745 } | |
746 | |
747 /* oops i made two of these. this one just calls the other one. */ | |
748 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
749 { | |
750 GaimConnection *gc = sess->aux_data; | |
751 OscarData *od = (OscarData *)gc->proto_data; | |
752 struct oscar_direct_im *dim; | |
753 char *sn; | |
754 | |
755 sn = g_strdup(aim_odc_getsn(conn)); | |
756 dim = oscar_direct_im_find(od, sn); | |
757 oscar_direct_im_disconnect(od, dim); | |
758 g_free(sn); | |
759 } | |
760 | |
761 static void destroy_direct_im_request(struct ask_direct *d) { | |
762 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
763 | |
764 g_free(d->sn); | |
765 g_free(d); | |
766 } | |
767 | |
768 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
769 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
770 struct oscar_direct_im *dim = data; | |
771 GaimConnection *gc = dim->gc; | |
772 OscarData *od = gc->proto_data; | |
773 GaimConversation *conv; | |
774 char buf[256]; | |
775 struct sockaddr name; | |
776 socklen_t name_len = 1; | |
777 | |
778 g_return_if_fail(gc != NULL); | |
779 | |
8978 | 780 dim->gpc_pend = FALSE; |
781 if (dim->killme) { | |
782 oscar_direct_im_destroy(od, dim); | |
783 return; | |
784 } | |
785 | |
8971 | 786 if (!g_list_find(gaim_connections_get_all(), gc)) { |
787 oscar_direct_im_destroy(od, dim); | |
788 return; | |
789 } | |
790 | |
791 if (source < 0) { | |
8984 | 792 if (dim->donttryagain) { |
793 oscar_direct_im_disconnect(od, dim); | |
794 return; | |
795 } else { | |
796 fu8_t cookie[8]; | |
797 char *who = g_strdup(dim->name); | |
798 const char *tmp = aim_odc_getcookie(dim->conn); | |
799 | |
800 memcpy(cookie, tmp, 8); | |
801 oscar_direct_im_destroy(od, dim); | |
802 oscar_direct_im_initiate(gc, who, cookie); | |
803 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
804 g_free(who); | |
805 return; | |
806 } | |
8971 | 807 } |
808 | |
809 dim->conn->fd = source; | |
810 aim_conn_completeconnect(od->sess, dim->conn); | |
811 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
812 | |
813 /* This is the best way to see if we're connected or not */ | |
8983 | 814 /* Is this really needed? */ |
8971 | 815 if (getpeername(source, &name, &name_len) == 0) { |
816 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
817 dim->connected = TRUE; | |
818 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 819 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
820 } else { | |
8984 | 821 if (dim->donttryagain) { |
822 oscar_direct_im_disconnect(od, dim); | |
823 return; | |
824 } else { | |
825 fu8_t cookie[8]; | |
826 char *who = g_strdup(dim->name); | |
827 const char *tmp = aim_odc_getcookie(dim->conn); | |
828 | |
829 memcpy(cookie, tmp, 8); | |
830 oscar_direct_im_destroy(od, dim); | |
831 oscar_direct_im_initiate(gc, who, cookie); | |
832 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
833 g_free(who); | |
834 return; | |
835 } | |
8983 | 836 } |
837 | |
838 | |
8971 | 839 } |
840 | |
841 static void accept_direct_im_request(struct ask_direct *d) { | |
842 GaimConnection *gc = d->gc; | |
843 OscarData *od; | |
844 struct oscar_direct_im *dim; | |
845 char *host; int port = 5190; | |
846 int i, rc; | |
8982 | 847 char *tmp; |
848 GaimConversation *conv; | |
8971 | 849 |
850 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
851 destroy_direct_im_request(d); | |
852 return; | |
853 } | |
854 | |
855 od = (OscarData *)gc->proto_data; | |
856 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
857 | |
858 dim = oscar_direct_im_find(od, d->sn); | |
859 if (dim && dim->connected) { | |
860 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
861 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
862 return; | |
863 } | |
864 dim = g_new0(struct oscar_direct_im, 1); | |
865 dim->gc = d->gc; | |
8984 | 866 dim->donttryagain = d->donttryagain; |
8971 | 867 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
868 | |
869 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
870 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
871 if (!dim->conn) { | |
872 oscar_direct_im_disconnect(od, dim); | |
873 destroy_direct_im_request(d); | |
874 return; | |
875 } | |
876 | |
877 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
878 gaim_odc_incoming, 0); | |
879 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
880 gaim_odc_typing, 0); | |
881 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
882 gaim_odc_update_ui, 0); | |
883 | |
884 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
885 for (i = 0; i < (int)strlen(d->ip); i++) { | |
886 if (d->ip[i] == ':') { | |
887 port = atoi(&(d->ip[i+1])); | |
888 break; | |
889 } | |
890 } | |
891 host = g_strndup(d->ip, i); | |
892 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 893 dim->gpc_pend = TRUE; |
8971 | 894 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 895 |
896 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
897 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
898 port); | |
899 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
900 g_free(tmp); | |
8983 | 901 |
8971 | 902 g_free(host); |
903 if (rc < 0) { | |
8978 | 904 dim->gpc_pend = FALSE; |
8971 | 905 oscar_direct_im_disconnect(od, dim); |
906 destroy_direct_im_request(d); | |
907 return; | |
908 } | |
909 | |
910 destroy_direct_im_request(d); | |
911 | |
912 return; | |
913 } | |
914 | |
915 /* | |
916 * We have just established a socket with the other dude, so set up some handlers. | |
917 */ | |
918 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 919 GaimConnection *gc = sess->aux_data; |
7283 | 920 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 921 GaimConversation *conv; |
8971 | 922 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
923 char buf[256]; |
8971 | 924 char *sn; |
925 va_list ap; | |
926 aim_conn_t *newconn, *listenerconn; | |
927 | |
928 va_start(ap, fr); | |
929 newconn = va_arg(ap, aim_conn_t *); | |
930 listenerconn = va_arg(ap, aim_conn_t *); | |
931 va_end(ap); | |
932 | |
933 aim_conn_close(listenerconn); | |
934 aim_conn_kill(sess, &listenerconn); | |
935 | |
936 sn = g_strdup(aim_odc_getsn(newconn)); | |
937 | |
938 gaim_debug_info("oscar", | |
939 "DirectIM: initiate success to %s\n", sn); | |
940 dim = oscar_direct_im_find(od, sn); | |
941 | |
942 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
943 gaim_input_remove(dim->watcher); | |
944 dim->conn = newconn; | |
945 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
946 dim->connected = TRUE; | |
947 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
948 g_free(sn); | |
949 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
950 | |
951 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
952 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
953 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
954 | |
955 return 1; | |
956 } | |
957 | |
958 /* | |
959 * This is called when each chunk of an image is received. It can be used to | |
960 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
961 * nasty, you sicko. | |
962 */ | |
963 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
964 va_list ap; | |
965 char *sn; | |
966 double percent; | |
967 GaimConnection *gc = sess->aux_data; | |
968 OscarData *od = (OscarData *)gc->proto_data; | |
969 GaimConversation *c; | |
970 struct oscar_direct_im *dim; | |
971 | |
972 va_start(ap, fr); | |
973 sn = va_arg(ap, char *); | |
974 percent = va_arg(ap, double); | |
975 va_end(ap); | |
976 | |
977 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
978 return 1; | |
979 if (dim->watcher) { | |
980 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
981 /* The callback will callback? I don't get how that would happen here. */ | |
982 dim->watcher = 0; | |
983 } | |
984 | |
985 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
986 if (c != NULL) | |
987 gaim_conversation_update_progress(c, percent); | |
988 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
989 oscar_callback, dim->conn); | |
990 | |
991 return 1; | |
992 } | |
993 | |
994 /* | |
995 * This is called after a direct IM has been received in its entirety. This | |
996 * function is passed a long chunk of data which contains the IM with any | |
997 * data chunks (images) appended to it. | |
998 * | |
999 * This function rips out all the data chunks and creates an imgstore for | |
1000 * each one. In order to do this, it first goes through the IM and takes | |
1001 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1002 * with one compatible with the imgstore Gaim core code. For each one, we | |
1003 * then read in chunks of data from the end of the message and actually | |
1004 * create the img store using the given data. | |
1005 * | |
1006 * For somewhat easy reference, here's a sample message | |
1007 * (without the whitespace and asterisks): | |
1008 * | |
1009 * <HTML><BODY BGCOLOR="#ffffff"> | |
1010 * <FONT LANG="0"> | |
1011 * This is a really stupid picture:<BR> | |
1012 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1013 * Yeah it is<BR> | |
1014 * Here is another one:<BR> | |
1015 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1016 * </FONT> | |
1017 * </BODY></HTML> | |
1018 * <BINARY> | |
1019 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1020 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1021 * </BINARY> | |
1022 */ | |
1023 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1024 GaimConnection *gc = sess->aux_data; | |
1025 GaimConvImFlags imflags = 0; | |
1026 gchar *utf8; | |
1027 GString *newmsg = g_string_new(""); | |
1028 GSList *images = NULL; | |
1029 va_list ap; | |
1030 const char *sn, *msg, *msgend, *binary; | |
1031 size_t len; | |
1032 int encoding, isawaymsg; | |
1033 | |
1034 va_start(ap, fr); | |
1035 sn = va_arg(ap, const char *); | |
1036 msg = va_arg(ap, const char *); | |
1037 len = va_arg(ap, size_t); | |
1038 encoding = va_arg(ap, int); | |
1039 isawaymsg = va_arg(ap, int); | |
1040 va_end(ap); | |
1041 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1042 |
8660 | 1043 gaim_debug_info("oscar", |
8971 | 1044 "Got DirectIM message from %s\n", sn); |
1045 | |
1046 if (isawaymsg) | |
1047 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1048 | |
1049 /* message has a binary trailer */ | |
1050 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1051 GData *attribs; | |
1052 const char *tmp, *start, *end, *last = NULL; | |
1053 | |
1054 tmp = msg; | |
1055 | |
1056 /* for each valid image tag... */ | |
1057 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1058 const char *id, *src, *datasize; | |
1059 const char *tag = NULL, *data = NULL; | |
1060 size_t size; | |
1061 int imgid = 0; | |
1062 | |
1063 /* update the location of the last img tag */ | |
1064 last = end; | |
1065 | |
1066 /* grab attributes */ | |
1067 id = g_datalist_get_data(&attribs, "id"); | |
1068 src = g_datalist_get_data(&attribs, "src"); | |
1069 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1070 | |
1071 /* if we have id & datasize, build the data tag */ | |
1072 if (id && datasize) | |
1073 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1074 | |
1075 /* if we have a tag, find the start of the data */ | |
1076 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1077 data += strlen(tag); | |
1078 | |
1079 /* check the data is here and store it */ | |
1080 if (data + (size = atoi(datasize)) <= msgend) | |
1081 imgid = gaim_imgstore_add(data, size, src); | |
1082 | |
1083 /* | |
1084 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1085 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1086 */ | |
1087 /* if we have a stored image... */ | |
1088 if (imgid) { | |
1089 /* append the message up to the tag */ | |
1090 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1091 if (utf8 != NULL) { | |
1092 newmsg = g_string_append(newmsg, utf8); | |
1093 g_free(utf8); | |
1094 } | |
1095 | |
1096 /* write the new image tag */ | |
1097 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1098 | |
1099 /* and record the image number */ | |
1100 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1101 } else { | |
1102 /* otherwise, copy up to the end of the tag */ | |
1103 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1104 if (utf8 != NULL) { | |
1105 newmsg = g_string_append(newmsg, utf8); | |
1106 g_free(utf8); | |
1107 } | |
1108 } | |
1109 | |
1110 /* clear the attribute list */ | |
1111 g_datalist_clear(&attribs); | |
1112 | |
1113 /* continue from the end of the tag */ | |
1114 tmp = end + 1; | |
1115 } | |
1116 | |
1117 /* append any remaining message data (without the > :-) */ | |
1118 if (last++ && (last < binary)) | |
1119 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1120 | |
1121 /* set the flag if we caught any images */ | |
1122 if (images) | |
1123 imflags |= GAIM_CONV_IM_IMAGES; | |
1124 } else { | |
1125 g_string_append_len(newmsg, msg, len); | |
1126 } | |
1127 | |
1128 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1129 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1130 | |
1131 /* free up the message */ | |
1132 g_string_free(newmsg, TRUE); | |
1133 | |
1134 /* unref any images we allocated */ | |
1135 if (images) { | |
1136 GSList *tmp; | |
1137 int id; | |
1138 | |
1139 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1140 id = GPOINTER_TO_INT(tmp->data); | |
1141 gaim_imgstore_unref(id); | |
1142 } | |
1143 | |
1144 g_slist_free(images); | |
1145 } | |
1146 | |
1147 return 1; | |
1148 } | |
1149 | |
1150 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1151 va_list ap; | |
1152 char *sn; | |
1153 int typing; | |
1154 GaimConnection *gc = sess->aux_data; | |
1155 | |
1156 va_start(ap, fr); | |
1157 sn = va_arg(ap, char *); | |
1158 typing = va_arg(ap, int); | |
1159 va_end(ap); | |
1160 | |
1161 if (typing == 0x0002) { | |
1162 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1163 gaim_debug_info("oscar", | |
1164 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1165 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1166 } else if (typing == 0x0001) | |
1167 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1168 else | |
1169 serv_got_typing_stopped(gc, sn); | |
1170 return 1; | |
1171 } | |
1172 | |
1173 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1174 char *buf; | |
1175 size_t len; | |
1176 int ret; | |
1177 GString *msg = g_string_new("<HTML><BODY>"); | |
1178 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1179 GData *attribs; | |
1180 const char *start, *end, *last; | |
1181 int oscar_id = 0; | |
1182 | |
1183 last = message; | |
1184 | |
1185 /* for each valid IMG tag... */ | |
1186 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1187 GaimStoredImage *image = NULL; | |
1188 const char *id; | |
1189 | |
1190 if (start - last) { | |
1191 g_string_append_len(msg, last, start - last); | |
1192 } | |
1193 | |
1194 id = g_datalist_get_data(&attribs, "id"); | |
1195 | |
1196 /* ... if it refers to a valid gaim image ... */ | |
1197 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1198 /* ... append the message from start to the tag ... */ | |
9126 | 1199 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1200 const char *filename = gaim_imgstore_get_filename(image); |
1201 gpointer imgdata = gaim_imgstore_get_data(image); | |
1202 | |
1203 oscar_id++; | |
1204 | |
1205 /* ... insert a new img tag with the oscar id ... */ | |
1206 if (filename) | |
1207 g_string_append_printf(msg, | |
9126 | 1208 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1209 filename, oscar_id, size); |
1210 else | |
1211 g_string_append_printf(msg, | |
9126 | 1212 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1213 oscar_id, size); |
1214 | |
1215 /* ... and append the data to the binary section ... */ | |
9126 | 1216 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1217 oscar_id, size); |
1218 data = g_string_append_len(data, imgdata, size); | |
1219 data = g_string_append(data, "</DATA>"); | |
1220 } | |
1221 /* If the tag is invalid, skip it, thus no else here */ | |
1222 | |
1223 g_datalist_clear(&attribs); | |
1224 | |
1225 /* continue from the end of the tag */ | |
1226 last = end + 1; | |
1227 } | |
1228 | |
1229 /* append any remaining message data (without the > :-) */ | |
1230 if (last && *last) | |
1231 msg = g_string_append(msg, last); | |
1232 | |
1233 /* if we inserted any images in the binary section, append it */ | |
1234 if (oscar_id) { | |
1235 msg = g_string_append_len(msg, data->str, data->len); | |
1236 msg = g_string_append(msg, "</BINARY>"); | |
1237 } | |
1238 | |
1239 len = msg->len; | |
1240 buf = msg->str; | |
1241 g_string_free(msg, FALSE); | |
1242 g_string_free(data, TRUE); | |
1243 | |
1244 | |
1245 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1246 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1247 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1248 else | |
1249 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1250 | |
1251 g_free(buf); | |
1252 | |
1253 return ret; | |
1254 } | |
1255 | |
1256 struct ask_do_dir_im { | |
1257 char *who; | |
1258 GaimConnection *gc; | |
1259 }; | |
1260 | |
1261 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1262 g_free(data->who); | |
1263 g_free(data); | |
1264 } | |
1265 | |
8983 | 1266 /* this function is used to initiate a direct im session with someone. |
1267 * we start listening on a port and send a request. they either connect | |
1268 * or send some kind of reply. If they can't connect, they ask us to | |
1269 * connect to them, and so we do that. | |
1270 * | |
1271 * this function will also get called if the other side initiate's a direct | |
1272 * im and we try to connect and fail. in that case cookie will not be null. | |
1273 * | |
1274 * note that cookie is an 8 byte string that isn't NULL terminated | |
1275 */ | |
1276 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1277 OscarData *od; |
1278 struct oscar_direct_im *dim; | |
1279 int listenfd; | |
8982 | 1280 const char *ip; |
8971 | 1281 |
1282 od = (OscarData *)gc->proto_data; | |
1283 | |
8983 | 1284 dim = oscar_direct_im_find(od, who); |
8971 | 1285 if (dim) { |
1286 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1287 oscar_direct_im_disconnect(od, dim); | |
1288 gaim_debug_info("oscar", | |
1289 "Gave up on old direct IM, trying again\n"); | |
1290 } else { | |
1291 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1292 return; |
8971 | 1293 } |
1294 } | |
1295 dim = g_new0(struct oscar_direct_im, 1); | |
1296 dim->gc = gc; | |
8983 | 1297 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1298 |
1299 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1300 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1301 if (listenfd >= 0) |
1302 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1303 if (dim->conn != NULL) { |
8982 | 1304 char *tmp; |
1305 GaimConversation *conv; | |
1306 | |
8971 | 1307 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1308 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1309 oscar_callback, dim->conn); | |
1310 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1311 gaim_odc_initiate, 0); | |
8982 | 1312 |
8983 | 1313 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1314 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1315 gaim_network_get_port_from_fd(listenfd)); |
1316 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1317 g_free(tmp); | |
8971 | 1318 } else { |
1319 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1320 oscar_direct_im_destroy(od, dim); | |
1321 } | |
8983 | 1322 } |
1323 | |
1324 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1325 GaimConnection *gc = data->gc; | |
1326 | |
1327 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1328 g_free(data->who); | |
1329 g_free(data); | |
1330 return; | |
1331 } | |
1332 | |
1333 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1334 g_free(data->who); |
1335 g_free(data); | |
1336 } | |
1337 | |
1338 /* this is the right click menu cb thingy */ | |
9030 | 1339 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1340 | |
1341 GaimBuddy *buddy; | |
1342 GaimConnection *gc; | |
8971 | 1343 gchar *buf; |
9030 | 1344 struct ask_do_dir_im *data; |
1345 | |
1346 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1347 | |
1348 buddy = (GaimBuddy *) node; | |
1349 gc = gaim_account_get_connection(buddy->account); | |
1350 | |
1351 data = g_new0(struct ask_do_dir_im, 1); | |
1352 data->who = g_strdup(buddy->name); | |
8971 | 1353 data->gc = gc; |
9030 | 1354 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1355 buddy->name); | |
8971 | 1356 |
1357 gaim_request_action(gc, NULL, buf, | |
9030 | 1358 _("Because this reveals your IP address, it " |
1359 "may be considered a privacy risk. Do you " | |
1360 "wish to continue?"), | |
1361 0, data, 2, | |
1362 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1363 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1364 g_free(buf); |
1365 } | |
1366 | |
1367 /***************************************************************************** | |
1368 * End scary direct im stuff | |
1369 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1370 |
4617 | 1371 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1372 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1373 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1374 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1375 OscarData *od; |
2086 | 1376 |
1377 if (!gc) { | |
8660 | 1378 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1379 "oscar callback for closed connection (1).\n"); |
2086 | 1380 return; |
1381 } | |
1382 | |
7283 | 1383 od = (OscarData *)gc->proto_data; |
2086 | 1384 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1385 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1386 /* oh boy. this is probably bad. i guess the only thing we |
1387 * can really do is return? */ | |
8660 | 1388 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1389 "oscar callback for closed connection (2).\n"); |
8660 | 1390 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1391 return; |
1392 } | |
1393 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1394 if (condition & GAIM_INPUT_READ) { |
4617 | 1395 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1396 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1397 "got information on rendezvous listener\n"); |
4617 | 1398 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1399 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1400 "connection error (rendezvous listener)\n"); |
4617 | 1401 aim_conn_kill(od->sess, &conn); |
8446 | 1402 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1403 } |
1404 } else { | |
4617 | 1405 if (aim_get_command(od->sess, conn) >= 0) { |
1406 aim_rxdispatch(od->sess); | |
6029 | 1407 if (od->killme) { |
8660 | 1408 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1409 return; |
1410 } | |
2086 | 1411 } else { |
1412 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1413 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1414 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1415 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1416 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1417 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1418 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1419 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1420 char *buf; |
8660 | 1421 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1422 "disconnected from chat room %s\n", c->name); |
2086 | 1423 c->conn = NULL; |
1424 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1425 gaim_input_remove(c->inpa); |
2086 | 1426 c->inpa = 0; |
1427 c->fd = -1; | |
4617 | 1428 aim_conn_kill(od->sess, &conn); |
5420 | 1429 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1430 if (conv) |
1431 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1432 else | |
1433 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1434 g_free(buf); |
2086 | 1435 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1436 if (od->cnpa > 0) |
1437 gaim_input_remove(od->cnpa); | |
1438 od->cnpa = 0; | |
8660 | 1439 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1440 "removing chatnav input watcher\n"); |
4617 | 1441 while (od->create_rooms) { |
1442 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1443 g_free(cr->name); |
4617 | 1444 od->create_rooms = |
1445 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1446 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1447 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1448 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1449 NULL); |
2086 | 1450 } |
4617 | 1451 aim_conn_kill(od->sess, &conn); |
2086 | 1452 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1453 if (od->paspa > 0) |
1454 gaim_input_remove(od->paspa); | |
1455 od->paspa = 0; | |
8660 | 1456 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1457 "removing authconn input watcher\n"); |
4617 | 1458 aim_conn_kill(od->sess, &conn); |
3694 | 1459 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1460 if (od->emlpa > 0) |
1461 gaim_input_remove(od->emlpa); | |
1462 od->emlpa = 0; | |
8660 | 1463 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1464 "removing email input watcher\n"); |
4617 | 1465 aim_conn_kill(od->sess, &conn); |
4804 | 1466 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1467 if (od->icopa > 0) | |
1468 gaim_input_remove(od->icopa); | |
1469 od->icopa = 0; | |
8660 | 1470 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1471 "removing icon input watcher\n"); |
4804 | 1472 aim_conn_kill(od->sess, &conn); |
2086 | 1473 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1474 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1475 gaim_odc_disconnect(od->sess, conn); |
1476 aim_conn_kill(od->sess, &conn); | |
2086 | 1477 } else { |
8660 | 1478 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1479 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1480 conn->type); |
4617 | 1481 aim_conn_kill(od->sess, &conn); |
2086 | 1482 } |
1483 } | |
1484 } | |
1485 } | |
1486 } | |
1487 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1488 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1489 GaimConnection *gc = sess->aux_data; |
7285 | 1490 gchar *s = g_strdup_vprintf(format, va); |
1491 gchar *buf; | |
1492 | |
1493 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1494 gaim_debug_info("oscar", buf); |
7285 | 1495 if (buf[strlen(buf)-1] != '\n') |
8660 | 1496 gaim_debug_info(NULL, "\n"); |
7285 | 1497 g_free(buf); |
2086 | 1498 g_free(s); |
1499 } | |
1500 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1501 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1502 { |
5575 | 1503 GaimConnection *gc = data; |
7283 | 1504 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1505 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1506 aim_conn_t *conn; |
2086 | 1507 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1508 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1509 close(source); |
1510 return; | |
1511 } | |
1512 | |
4617 | 1513 od = gc->proto_data; |
1514 sess = od->sess; | |
2086 | 1515 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1516 conn->fd = source; |
2086 | 1517 |
1518 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1519 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1520 return; |
1521 } | |
1522 | |
1523 aim_conn_completeconnect(sess, conn); | |
4617 | 1524 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1525 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1526 | |
8660 | 1527 gaim_debug_info("oscar", |
7282 | 1528 "Screen name sent, waiting for response\n"); |
7283 | 1529 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1530 ck[1] = 0x65; |
2086 | 1531 } |
1532 | |
5575 | 1533 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1534 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1535 aim_conn_t *conn; |
5575 | 1536 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1537 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1538 |
8660 | 1539 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1540 |
8437 | 1541 if (!aim_snvalid(gaim_account_get_username(account))) { |
1542 gchar *buf; | |
8590 | 1543 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 | 1544 gaim_connection_error(gc, buf); |
1545 g_free(buf); | |
1546 } | |
1547 | |
5575 | 1548 if (isdigit(*(gaim_account_get_username(account)))) { |
4617 | 1549 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1550 } else { |
6622 | 1551 gc->flags |= GAIM_CONNECTION_HTML; |
1552 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1553 } |
5836 | 1554 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1555 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1556 sess = g_new0(aim_session_t, 1); |
7285 | 1557 aim_session_init(sess, TRUE, 0); |
2086 | 1558 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1559 /* |
1560 * We need an immediate queue because we don't use a while-loop | |
1561 * to see if things need to be sent. | |
1562 */ | |
2086 | 1563 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1564 od->sess = sess; |
2086 | 1565 sess->aux_data = gc; |
1566 | |
1567 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
1568 if (conn == NULL) { | |
8660 | 1569 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1570 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1571 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1572 return; |
1573 } | |
1574 | |
4649 | 1575 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1576 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1577 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1578 | |
1579 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1580 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1581 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1582 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1583 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1584 return; |
1585 } | |
7282 | 1586 |
7283 | 1587 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1588 ck[0] = 0x5a; |
5575 | 1589 } |
1590 | |
1591 static void oscar_close(GaimConnection *gc) { | |
7283 | 1592 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1593 |
1594 while (od->oscar_chats) { | |
1595 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1596 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1597 gaim_input_remove(n->inpa); |
2086 | 1598 g_free(n->name); |
1599 g_free(n->show); | |
4617 | 1600 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1601 g_free(n); |
1602 } | |
4617 | 1603 while (od->direct_ims) { |
8971 | 1604 struct oscar_direct_im *n = od->direct_ims->data; |
1605 oscar_direct_im_destroy(od, n); | |
2086 | 1606 } |
4617 | 1607 /* BBB */ |
1608 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1609 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1610 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1611 gaim_xfer_cancel_local(xfer); |
3630 | 1612 } |
4804 | 1613 while (od->requesticon) { |
1614 char *sn = od->requesticon->data; | |
1615 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1616 free(sn); | |
1617 } | |
4738 | 1618 g_hash_table_destroy(od->buddyinfo); |
4617 | 1619 while (od->create_rooms) { |
1620 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1621 g_free(cr->name); |
4617 | 1622 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1623 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1624 } |
4617 | 1625 if (od->email) |
1626 g_free(od->email); | |
1627 if (od->newp) | |
1628 g_free(od->newp); | |
1629 if (od->oldp) | |
1630 g_free(od->oldp); | |
2086 | 1631 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1632 gaim_input_remove(gc->inpa); |
4617 | 1633 if (od->cnpa > 0) |
1634 gaim_input_remove(od->cnpa); | |
1635 if (od->paspa > 0) | |
1636 gaim_input_remove(od->paspa); | |
1637 if (od->emlpa > 0) | |
1638 gaim_input_remove(od->emlpa); | |
4804 | 1639 if (od->icopa > 0) |
1640 gaim_input_remove(od->icopa); | |
6907 | 1641 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1642 gaim_timeout_remove(od->icontimer); |
8341 | 1643 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1644 gaim_timeout_remove(od->getblisttimer); |
8341 | 1645 if (od->getinfotimer > 0) |
1646 gaim_timeout_remove(od->getinfotimer); | |
4617 | 1647 aim_session_kill(od->sess); |
1648 g_free(od->sess); | |
1649 od->sess = NULL; | |
2086 | 1650 g_free(gc->proto_data); |
1651 gc->proto_data = NULL; | |
8660 | 1652 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1653 } |
1654 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1655 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1656 GaimConnection *gc = data; |
7283 | 1657 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1658 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1659 aim_conn_t *bosconn; |
2086 | 1660 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1661 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1662 close(source); |
1663 return; | |
1664 } | |
1665 | |
4617 | 1666 od = gc->proto_data; |
1667 sess = od->sess; | |
1668 bosconn = od->conn; | |
4366 | 1669 bosconn->fd = source; |
2086 | 1670 |
1671 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1672 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1673 return; |
1674 } | |
1675 | |
1676 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1677 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1678 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1679 gaim_connection_update_progress(gc, |
7283 | 1680 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1681 ck[4] = 0x61; |
2086 | 1682 } |
1683 | |
4617 | 1684 /* BBB */ |
4656 | 1685 /* |
1686 * This little area in oscar.c is the nexus of file transfer code, | |
1687 * so I wrote a little explanation of what happens. I am such a | |
1688 * ninja. | |
1689 * | |
1690 * The series of events for a file send is: | |
1691 * -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
|
1692 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1693 * listening socket, then asks the remote user to connect to us (and |
1694 * gives them the file name, port, IP, etc.) | |
1695 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1696 * in oscar_sendfile_estblsh) | |
1697 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1698 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1699 * connection. | |
1700 * -We get drunk because file transfer kicks ass. | |
1701 * | |
1702 * The series of events for a file receive is: | |
1703 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1704 * -Gaim user selects file to name and location to save file to and | |
1705 * oscar_xfer_init is called | |
1706 * -It connects to the remote user using the IP they gave us earlier | |
1707 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1708 * them an AIM_CB_OFT_ACK. | |
1709 * -They begin to send us lots of raw data. | |
1710 * -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
|
1711 * the connection. |
4656 | 1712 */ |
1713 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1714 | |
8446 | 1715 /* |
1716 * Miscellaneous xfer functions | |
1717 */ | |
1718 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1719 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1720 GaimXfer *xfer; |
5146 | 1721 struct aim_oft_info *oft_info; |
4656 | 1722 |
1723 while (fts) { | |
1724 xfer = fts->data; | |
5146 | 1725 oft_info = xfer->data; |
1726 | |
8446 | 1727 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1728 return xfer; |
1729 | |
1730 fts = g_slist_next(fts); | |
1731 } | |
1732 | |
1733 return NULL; | |
1734 } | |
1735 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1736 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1737 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1738 GaimXfer *xfer; |
5146 | 1739 struct aim_oft_info *oft_info; |
4656 | 1740 |
1741 while (fts) { | |
1742 xfer = fts->data; | |
5146 | 1743 oft_info = xfer->data; |
1744 | |
1745 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1746 return xfer; |
1747 | |
1748 fts = g_slist_next(fts); | |
1749 } | |
1750 | |
1751 return NULL; | |
1752 } | |
1753 | |
8446 | 1754 static void oscar_xfer_end(GaimXfer *xfer) |
1755 { | |
1756 struct aim_oft_info *oft_info = xfer->data; | |
1757 GaimConnection *gc = oft_info->sess->aux_data; | |
1758 OscarData *od = gc->proto_data; | |
1759 | |
8660 | 1760 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1761 |
1762 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1763 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1764 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1765 } | |
1766 | |
1767 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1768 aim_oft_destroyinfo(oft_info); | |
1769 xfer->data = NULL; | |
1770 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1771 } | |
1772 | |
1773 /* | |
1774 * xfer functions used when receiving files | |
1775 */ | |
1776 | |
1777 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1778 { | |
1779 struct aim_oft_info *oft_info = xfer->data; | |
1780 GaimConnection *gc = oft_info->sess->aux_data; | |
1781 OscarData *od = gc->proto_data; | |
1782 | |
8660 | 1783 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1784 |
1785 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1786 if (oft_info->conn) { | |
1787 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1788 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1789 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1790 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1791 if (xfer->fd == -1) { | |
1792 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1793 _("Unable to establish file descriptor.")); | |
1794 gaim_xfer_cancel_local(xfer); | |
1795 } | |
1796 } else { | |
1797 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1798 _("Unable to create new connection.")); | |
1799 gaim_xfer_cancel_local(xfer); | |
1800 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1801 } | |
1802 | |
1803 } | |
1804 | |
1805 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1806 { | |
1807 struct aim_oft_info *oft_info = xfer->data; | |
1808 GaimConnection *gc = oft_info->sess->aux_data; | |
1809 OscarData *od = gc->proto_data; | |
1810 | |
8660 | 1811 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1812 |
1813 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
1814 | |
1815 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1816 aim_oft_destroyinfo(oft_info); | |
1817 xfer->data = NULL; | |
1818 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1819 } | |
1820 | |
1821 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1822 { | |
1823 struct aim_oft_info *oft_info = xfer->data; | |
1824 | |
1825 /* Update our rolling checksum. Like Walmart, yo. */ | |
1826 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
1827 } | |
1828 | |
1829 /* | |
1830 * xfer functions used when sending files | |
1831 */ | |
1832 | |
1833 static void oscar_xfer_init_send(GaimXfer *xfer) | |
1834 { | |
1835 struct aim_oft_info *oft_info = xfer->data; | |
1836 GaimConnection *gc = oft_info->sess->aux_data; | |
1837 OscarData *od = gc->proto_data; | |
1838 int listenfd; | |
1839 | |
8660 | 1840 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 1841 |
1842 xfer->filename = g_path_get_basename(xfer->local_filename); | |
1843 strncpy(oft_info->fh.name, xfer->filename, 64); | |
1844 oft_info->fh.name[63] = '\0'; | |
1845 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
1846 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
1847 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
1848 | |
1849 /* Create a listening socket and an associated libfaim conn */ | |
1850 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
1851 gaim_xfer_cancel_local(xfer); | |
1852 return; | |
1853 } | |
1854 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
1855 oft_info->port = xfer->local_port; | |
1856 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
1857 gaim_xfer_cancel_local(xfer); | |
1858 return; | |
1859 } | |
8660 | 1860 gaim_debug_misc("oscar", |
8446 | 1861 "port is %hu, ip is %s\n", |
1862 xfer->local_port, oft_info->clientip); | |
1863 if (oft_info->conn) { | |
1864 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
1865 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
1866 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
1867 } else { | |
1868 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
1869 _("Unable to establish listener socket.")); | |
1870 gaim_xfer_cancel_local(xfer); | |
1871 } | |
1872 } | |
1873 | |
1874 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
1875 { | |
1876 struct aim_oft_info *oft_info = xfer->data; | |
1877 GaimConnection *gc = oft_info->sess->aux_data; | |
1878 OscarData *od = gc->proto_data; | |
1879 | |
8660 | 1880 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 1881 |
1882 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
1883 | |
1884 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1885 aim_oft_destroyinfo(oft_info); | |
1886 xfer->data = NULL; | |
1887 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1888 } | |
1889 | |
1890 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
1891 { | |
1892 struct aim_oft_info *oft_info = xfer->data; | |
1893 | |
1894 /* I'm not sure I like how we do this. --marv | |
1895 * I do. AIM file transfers aren't really meant to be thought | |
1896 * of as a transferring just a single file. The rendezvous | |
1897 * establishes a connection between two computers, and then | |
1898 * those computers can use the same connection for transferring | |
1899 * multiple files. So we don't want the Gaim core up and closing | |
1900 * the socket all willy-nilly. We want to do that in the oscar | |
1901 * prpl, whenever one side or the other says they're finished | |
1902 * using the connection. There might be a better way to intercept | |
1903 * the socket from the core, however... --KingAnt | |
1904 */ | |
1905 | |
1906 /* | |
1907 * If we're done sending, intercept the socket from the core ft code | |
1908 * and wait for the other guy to send the "done" OFT packet. | |
1909 */ | |
1910 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
1911 gaim_input_remove(xfer->watcher); | |
1912 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
1913 xfer->fd = 0; | |
1914 gaim_xfer_set_completed(xfer, TRUE); | |
1915 } | |
1916 } | |
1917 | |
9466 | 1918 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
1919 gboolean can_receive = FALSE; | |
1920 OscarData *od = gc->proto_data; | |
1921 | |
1922 if (!od->icq) { | |
1923 aim_userinfo_t *userinfo; | |
1924 userinfo = aim_locate_finduserinfo(od->sess, who); | |
1925 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
1926 can_receive = TRUE; | |
1927 } | |
1928 | |
1929 return can_receive; | |
1930 } | |
1931 | |
1932 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 1933 |
1934 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1935 GaimXfer *xfer; |
5146 | 1936 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
1937 const char *ip; |
3752 | 1938 |
9030 | 1939 od = (OscarData *)gc->proto_data; |
1940 | |
4617 | 1941 /* You want to send a file to someone else, you're so generous */ |
1942 | |
1943 /* Build the file transfer handle */ | |
9466 | 1944 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 1945 |
5146 | 1946 /* Create the oscar-specific data */ |
8838 | 1947 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 1948 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 1949 xfer->data = oft_info; |
1950 | |
4617 | 1951 /* Setup our I/O op functions */ |
8446 | 1952 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 1953 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1954 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 1955 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
1956 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 1957 |
1958 /* Keep track of this transfer for later */ | |
1959 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
1960 | |
1961 /* Now perform the request */ | |
9466 | 1962 if (file) |
1963 gaim_xfer_request_accepted(xfer, file); | |
1964 else | |
1965 gaim_xfer_request(xfer); | |
3630 | 1966 } |
1967 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1968 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 1969 GaimConnection *gc = sess->aux_data; |
7283 | 1970 OscarData *od = gc->proto_data; |
6029 | 1971 GaimAccount *account = gc->account; |
1972 aim_conn_t *bosconn; | |
1973 char *host; int port; | |
1974 int i, rc; | |
2086 | 1975 va_list ap; |
2704 | 1976 struct aim_authresp_info *info; |
6029 | 1977 |
5575 | 1978 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 1979 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1980 va_start(ap, fr); |
2704 | 1981 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 1982 va_end(ap); |
1983 | |
8660 | 1984 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1985 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 1986 |
4293 | 1987 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 1988 char buf[256]; |
2704 | 1989 switch (info->errorcode) { |
2086 | 1990 case 0x05: |
1991 /* Incorrect nick/password */ | |
6498 | 1992 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1993 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 1994 break; |
1995 case 0x11: | |
1996 /* Suspended account */ | |
6498 | 1997 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1998 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 1999 break; |
3498 | 2000 case 0x14: |
2001 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2002 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2003 break; |
2086 | 2004 case 0x18: |
2005 /* connecting too frequently */ | |
6498 | 2006 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2007 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 | 2008 break; |
2009 case 0x1c: | |
2010 /* client too old */ | |
6498 | 2011 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2012 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
|
2013 gaim_connection_error(gc, buf); |
2086 | 2014 break; |
2015 default: | |
6623 | 2016 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2017 break; |
2018 } | |
8660 | 2019 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2020 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2021 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2022 "Error URL: %s\n", info->errorurl); |
2086 | 2023 od->killme = TRUE; |
2024 return 1; | |
2025 } | |
2026 | |
2027 | |
8660 | 2028 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2029 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2030 |
2704 | 2031 if (info->email) { |
8660 | 2032 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2033 } else { |
8660 | 2034 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2035 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2036 |
8660 | 2037 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2038 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2039 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2040 aim_conn_kill(sess, &fr->conn); |
2086 | 2041 |
2042 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2043 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2044 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2045 od->killme = TRUE; |
2046 return 0; | |
2047 } | |
2048 | |
4649 | 2049 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2050 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2051 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2052 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2053 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2054 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2055 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2056 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2057 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2058 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2059 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2060 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2061 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2062 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2063 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2064 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2065 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2066 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2067 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2068 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2069 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2070 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2071 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
|
2072 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2073 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2074 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2075 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2076 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2077 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2078 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
|
2079 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
|
2080 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
|
2081 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2082 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2083 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2084 #ifndef NOSSI |
4642 | 2085 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2086 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2087 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2088 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2089 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2090 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2091 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2092 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2093 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2094 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2095 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2096 |
7283 | 2097 od->conn = bosconn; |
2704 | 2098 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2099 if (info->bosip[i] == ':') { | |
2100 port = atoi(&(info->bosip[i+1])); | |
2086 | 2101 break; |
2102 } | |
2103 } | |
2704 | 2104 host = g_strndup(info->bosip, i); |
2086 | 2105 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2106 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2107 g_free(host); |
4366 | 2108 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2109 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2110 od->killme = TRUE; |
2111 return 0; | |
2112 } | |
4293 | 2113 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2114 gaim_input_remove(gc->inpa); |
2704 | 2115 |
7283 | 2116 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2117 ck[3] = 0x64; |
7282 | 2118 |
2086 | 2119 return 1; |
2120 } | |
2121 | |
7285 | 2122 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2123 struct pieceofcrap { |
5575 | 2124 GaimConnection *gc; |
2086 | 2125 unsigned long offset; |
2126 unsigned long len; | |
2127 char *modname; | |
2128 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2129 aim_conn_t *conn; |
2086 | 2130 unsigned int inpa; |
2131 }; | |
2132 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2133 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2134 { |
2135 struct pieceofcrap *pos = data; | |
7283 | 2136 OscarData *od = pos->gc->proto_data; |
2086 | 2137 char in = '\0'; |
2138 int x = 0; | |
2139 unsigned char m[17]; | |
2140 | |
2141 while (read(pos->fd, &in, 1) == 1) { | |
2142 if (in == '\n') | |
2143 x++; | |
2144 else if (in != '\r') | |
2145 x = 0; | |
2146 if (x == 2) | |
2147 break; | |
2148 in = '\0'; | |
2149 } | |
2150 if (in != '\n') { | |
4056 | 2151 char buf[256]; |
2152 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
|
2153 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2154 gaim_notify_warning(pos->gc, NULL, |
7422 | 2155 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2156 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2157 gaim_input_remove(pos->inpa); |
2086 | 2158 close(pos->fd); |
2159 g_free(pos); | |
2160 return; | |
2161 } | |
2162 read(pos->fd, m, 16); | |
2163 m[16] = '\0'; | |
8660 | 2164 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2165 for (x = 0; x < 16; x++) |
8660 | 2166 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2167 | |
2168 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2169 gaim_input_remove(pos->inpa); |
2086 | 2170 close(pos->fd); |
2171 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2172 g_free(pos); | |
2173 } | |
2174 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2175 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2176 struct pieceofcrap *pos = data; |
5420 | 2177 gchar *buf; |
2086 | 2178 |
4366 | 2179 pos->fd = source; |
2180 | |
2086 | 2181 if (source < 0) { |
5420 | 2182 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
|
2183 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2184 gaim_notify_warning(pos->gc, NULL, |
7422 | 2185 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2186 buf); |
5420 | 2187 g_free(buf); |
2086 | 2188 if (pos->modname) |
2189 g_free(pos->modname); | |
2190 g_free(pos); | |
2191 return; | |
2192 } | |
2193 | |
5420 | 2194 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2195 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2196 write(pos->fd, buf, strlen(buf)); | |
5420 | 2197 g_free(buf); |
2086 | 2198 if (pos->modname) |
2199 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2200 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2201 return; |
2202 } | |
2203 | |
2204 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2205 #define AIM_MAX_FILE_SIZE 98304 | |
2206 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2207 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2208 va_list ap; |
2209 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2210 fu32_t offset, len; |
2086 | 2211 char *modname; |
2212 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2213 va_start(ap, fr); |
4200 | 2214 offset = va_arg(ap, fu32_t); |
2215 len = va_arg(ap, fu32_t); | |
2086 | 2216 modname = va_arg(ap, char *); |
2217 va_end(ap); | |
2218 | |
8660 | 2219 gaim_debug_misc("oscar", |
5556 | 2220 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2221 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2222 |
2086 | 2223 if (len == 0) { |
8660 | 2224 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2225 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2226 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2227 return 1; | |
2228 } | |
9625 | 2229 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2230 #if 0 | |
2086 | 2231 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2232 char *buf; | |
2233 int i = 8; | |
2234 if (modname) | |
2235 i += strlen(modname); | |
2236 buf = g_malloc(i); | |
2237 i = 0; | |
2238 if (modname) { | |
2239 memcpy(buf, modname, strlen(modname)); | |
2240 i += strlen(modname); | |
2241 } | |
2242 buf[i++] = offset & 0xff; | |
2243 buf[i++] = (offset >> 8) & 0xff; | |
2244 buf[i++] = (offset >> 16) & 0xff; | |
2245 buf[i++] = (offset >> 24) & 0xff; | |
2246 buf[i++] = len & 0xff; | |
2247 buf[i++] = (len >> 8) & 0xff; | |
2248 buf[i++] = (len >> 16) & 0xff; | |
2249 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2250 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2251 "hashing request\n"); |
2086 | 2252 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2253 g_free(buf); | |
2254 return 1; | |
2255 } | |
9625 | 2256 #endif |
2086 | 2257 |
2258 pos = g_new0(struct pieceofcrap, 1); | |
2259 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2260 pos->conn = fr->conn; |
2086 | 2261 |
2262 pos->offset = offset; | |
2263 pos->len = len; | |
2264 pos->modname = modname ? g_strdup(modname) : NULL; | |
2265 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2266 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2267 char buf[256]; |
2086 | 2268 if (pos->modname) |
2269 g_free(pos->modname); | |
2270 g_free(pos); | |
4056 | 2271 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
|
2272 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2273 gaim_notify_warning(pos->gc, NULL, |
7422 | 2274 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2275 buf); |
2086 | 2276 } |
2277 | |
2278 return 1; | |
2279 } | |
2280 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2281 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2282 GaimConnection *gc = sess->aux_data; |
7283 | 2283 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2284 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2285 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2286 #if 0 |
2287 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2288 #endif | |
7011 | 2289 va_list ap; |
2290 char *key; | |
2086 | 2291 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2292 va_start(ap, fr); |
2086 | 2293 key = va_arg(ap, char *); |
2294 va_end(ap); | |
2295 | |
4617 | 2296 if (od->icq) { |
3458 | 2297 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2298 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2299 gaim_account_get_password(account), &info, key); |
3458 | 2300 } else { |
2301 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2302 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2303 gaim_account_get_password(account), &info, key); |
3458 | 2304 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2305 |
7283 | 2306 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2307 ck[2] = 0x6c; |
7282 | 2308 |
2086 | 2309 return 1; |
2310 } | |
2311 | |
2675 | 2312 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2313 GaimConnection *gc = sess->aux_data; |
2647 | 2314 struct chat_connection *chatcon; |
2315 static int id = 1; | |
2316 | |
6905 | 2317 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
|
2318 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
|
2319 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
|
2320 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
|
2321 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2322 |
2672 | 2323 aim_clientready(sess, fr->conn); |
2675 | 2324 |
2647 | 2325 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2326 chatcon->id = id; | |
8733 | 2327 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2328 |
2329 return 1; | |
2330 } | |
2331 | |
2675 | 2332 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2333 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2334 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2335 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2336 |
2337 aim_clientready(sess, fr->conn); | |
2338 | |
2339 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2340 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2341 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2342 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2343 |
3694 | 2344 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2345 | |
2346 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2347 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2348 | |
7282 | 2349 aim_email_sendcookies(sess); |
2350 aim_email_activate(sess); | |
3694 | 2351 aim_clientready(sess, fr->conn); |
2352 | |
2353 return 1; | |
2354 } | |
2355 | |
4804 | 2356 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2357 GaimConnection *gc = sess->aux_data; |
7283 | 2358 OscarData *od = gc->proto_data; |
4804 | 2359 |
2360 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2361 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2362 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2363 | |
2364 aim_clientready(sess, fr->conn); | |
2365 | |
4823 | 2366 od->iconconnecting = FALSE; |
2367 | |
4804 | 2368 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2369 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2370 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2371 |
2372 return 1; | |
2373 } | |
2374 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2375 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2376 GaimConnection *gc = data; |
7283 | 2377 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2378 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2379 aim_conn_t *tstconn; |
2086 | 2380 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2381 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2382 close(source); |
2383 return; | |
2384 } | |
2385 | |
4617 | 2386 od = gc->proto_data; |
2387 sess = od->sess; | |
2086 | 2388 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2389 tstconn->fd = source; |
2086 | 2390 |
2391 if (source < 0) { | |
2392 aim_conn_kill(sess, &tstconn); | |
8660 | 2393 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2394 "unable to connect to chatnav server\n"); |
2086 | 2395 return; |
2396 } | |
2397 | |
2398 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2399 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2400 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2401 } |
2402 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2403 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2404 { |
5575 | 2405 GaimConnection *gc = data; |
7283 | 2406 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2407 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2408 aim_conn_t *tstconn; |
2086 | 2409 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2410 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2411 close(source); |
2412 return; | |
2413 } | |
2414 | |
4617 | 2415 od = gc->proto_data; |
2416 sess = od->sess; | |
2086 | 2417 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2418 tstconn->fd = source; |
2086 | 2419 |
2420 if (source < 0) { | |
2421 aim_conn_kill(sess, &tstconn); | |
8660 | 2422 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2423 "unable to connect to authorizer\n"); |
2086 | 2424 return; |
2425 } | |
2426 | |
2427 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2428 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2429 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2430 } |
2431 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2432 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2433 { |
2434 struct chat_connection *ccon = data; | |
5575 | 2435 GaimConnection *gc = ccon->gc; |
7283 | 2436 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2437 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2438 aim_conn_t *tstconn; |
2086 | 2439 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2440 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2441 close(source); |
2442 g_free(ccon->show); | |
2443 g_free(ccon->name); | |
2444 g_free(ccon); | |
2445 return; | |
2446 } | |
2447 | |
4617 | 2448 od = gc->proto_data; |
2449 sess = od->sess; | |
2086 | 2450 tstconn = ccon->conn; |
4366 | 2451 tstconn->fd = source; |
2086 | 2452 |
2453 if (source < 0) { | |
2454 aim_conn_kill(sess, &tstconn); | |
2455 g_free(ccon->show); | |
2456 g_free(ccon->name); | |
2457 g_free(ccon); | |
2458 return; | |
2459 } | |
2460 | |
2461 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2462 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2463 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2464 } |
2465 | |
3694 | 2466 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2467 GaimConnection *gc = data; |
7283 | 2468 OscarData *od; |
3694 | 2469 aim_session_t *sess; |
2470 aim_conn_t *tstconn; | |
2471 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2472 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2473 close(source); |
2474 return; | |
2475 } | |
2476 | |
4617 | 2477 od = gc->proto_data; |
2478 sess = od->sess; | |
3694 | 2479 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2480 tstconn->fd = source; |
3694 | 2481 |
2482 if (source < 0) { | |
2483 aim_conn_kill(sess, &tstconn); | |
8660 | 2484 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2485 "unable to connect to email server\n"); |
3694 | 2486 return; |
2487 } | |
2488 | |
2489 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2490 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2491 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2492 "email: connected\n"); |
3694 | 2493 } |
2494 | |
4804 | 2495 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2496 GaimConnection *gc = data; |
7283 | 2497 OscarData *od; |
4804 | 2498 aim_session_t *sess; |
2499 aim_conn_t *tstconn; | |
2500 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2501 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2502 close(source); |
2503 return; | |
2504 } | |
2505 | |
2506 od = gc->proto_data; | |
2507 sess = od->sess; | |
2508 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2509 tstconn->fd = source; | |
2510 | |
2511 if (source < 0) { | |
2512 aim_conn_kill(sess, &tstconn); | |
8660 | 2513 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2514 "unable to connect to icon server\n"); |
4804 | 2515 return; |
2516 } | |
2517 | |
2518 aim_conn_completeconnect(sess, tstconn); | |
2519 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2520 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2521 } |
2522 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2523 /* 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
|
2524 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2525 GaimConnection *gc = sess->aux_data; |
2526 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2527 aim_conn_t *tstconn; |
4452 | 2528 int i; |
2086 | 2529 char *host; |
2530 int port; | |
4821 | 2531 va_list ap; |
2532 struct aim_redirect_data *redir; | |
2086 | 2533 |
5575 | 2534 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2535 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2536 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2537 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2538 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2539 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2540 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2541 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2542 port = atoi(&(redir->ip[i+1])); |
2086 | 2543 break; |
2544 } | |
2545 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2546 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2547 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2548 switch(redir->group) { |
2086 | 2549 case 0x7: /* Authorizer */ |
8660 | 2550 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2551 "Reconnecting with authorizor...\n"); |
2086 | 2552 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2553 if (tstconn == NULL) { | |
8660 | 2554 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2555 "unable to reconnect with authorizer\n"); |
2086 | 2556 g_free(host); |
2557 return 1; | |
2558 } | |
4649 | 2559 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2560 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2561 |
2562 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2563 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2564 aim_conn_kill(sess, &tstconn); |
8660 | 2565 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2566 "unable to reconnect with authorizer\n"); |
2086 | 2567 g_free(host); |
2568 return 1; | |
2569 } | |
4293 | 2570 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2571 break; |
2572 | |
2086 | 2573 case 0xd: /* ChatNav */ |
2574 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2575 if (tstconn == NULL) { | |
8660 | 2576 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2577 "unable to connect to chatnav server\n"); |
2086 | 2578 g_free(host); |
2579 return 1; | |
2580 } | |
4649 | 2581 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2582 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2583 |
2584 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2585 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2586 aim_conn_kill(sess, &tstconn); |
8660 | 2587 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2588 "unable to connect to chatnav server\n"); |
2086 | 2589 g_free(host); |
2590 return 1; | |
2591 } | |
4293 | 2592 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2593 break; |
2594 | |
2595 case 0xe: { /* Chat */ | |
2086 | 2596 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2597 |
2086 | 2598 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2599 if (tstconn == NULL) { | |
8660 | 2600 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2601 "unable to connect to chat server\n"); |
2086 | 2602 g_free(host); |
2603 return 1; | |
2604 } | |
2605 | |
4649 | 2606 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2607 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2608 | |
2086 | 2609 ccon = g_new0(struct chat_connection, 1); |
2610 ccon->conn = tstconn; | |
2611 ccon->gc = gc; | |
2612 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2613 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2614 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2615 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2616 ccon->show = extract_name(redir->chat.room); |
4634 | 2617 |
2086 | 2618 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2619 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2620 aim_conn_kill(sess, &tstconn); |
8660 | 2621 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2622 "unable to connect to chat server\n"); |
2086 | 2623 g_free(host); |
2624 g_free(ccon->show); | |
2625 g_free(ccon->name); | |
2626 g_free(ccon); | |
2627 return 1; | |
2628 } | |
4293 | 2629 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2630 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2631 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2632 ccon->name, ccon->exchange); |
4194 | 2633 } break; |
3694 | 2634 |
4804 | 2635 case 0x0010: { /* icon */ |
2636 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2637 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2638 "unable to connect to icon server\n"); |
4804 | 2639 g_free(host); |
2640 return 1; | |
2641 } | |
2642 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2643 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2644 | |
2645 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2646 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2647 aim_conn_kill(sess, &tstconn); |
8660 | 2648 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2649 "unable to connect to icon server\n"); |
4804 | 2650 g_free(host); |
2651 return 1; | |
2652 } | |
2653 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2654 } break; | |
2655 | |
3694 | 2656 case 0x0018: { /* email */ |
2657 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2658 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2659 "unable to connect to email server\n"); |
3694 | 2660 g_free(host); |
2661 return 1; | |
2662 } | |
4649 | 2663 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2664 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2665 | |
2666 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2667 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2668 aim_conn_kill(sess, &tstconn); |
8660 | 2669 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2670 "unable to connect to email server\n"); |
3694 | 2671 g_free(host); |
2672 return 1; | |
2673 } | |
4293 | 2674 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2675 } break; |
2676 | |
2086 | 2677 default: /* huh? */ |
8660 | 2678 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2679 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2680 redir->group); |
2086 | 2681 break; |
2682 } | |
2683 | |
2684 g_free(host); | |
2685 return 1; | |
2686 } | |
2687 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2688 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2689 GaimConnection *gc = sess->aux_data; |
9058 | 2690 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 2691 OscarData *od = gc->proto_data; |
4738 | 2692 struct buddyinfo *bi; |
2993 | 2693 time_t time_idle = 0, signon = 0; |
2694 int type = 0; | |
2695 int caps = 0; | |
2086 | 2696 va_list ap; |
4738 | 2697 aim_userinfo_t *info; |
4194 | 2698 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2699 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2700 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2701 va_end(ap); |
2702 | |
2993 | 2703 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2704 caps = info->capabilities; | |
3267 | 2705 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
2706 type |= UC_AB; | |
2707 | |
4766 | 2708 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2709 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
2710 type |= UC_UNCONFIRMED; | |
2711 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
2712 type |= UC_ADMIN; | |
2713 if (info->flags & AIM_FLAG_AOL) | |
2714 type |= UC_AOL; | |
2715 if (info->flags & AIM_FLAG_FREE) | |
2716 type |= UC_NORMAL; | |
2717 if (info->flags & AIM_FLAG_AWAY) | |
2718 type |= UC_UNAVAILABLE; | |
2719 if (info->flags & AIM_FLAG_WIRELESS) | |
2720 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2721 } |
2993 | 2722 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2723 type = (info->icqinfo.status << 16); |
3013 | 2724 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2725 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 2726 type |= UC_UNAVAILABLE; |
3013 | 2727 } |
2993 | 2728 } |
2729 | |
7141 | 2730 if (caps & AIM_CAPS_ICQ_DIRECT) |
2731 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2732 |
2733 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2734 time(&time_idle); |
2735 time_idle -= info->idletime*60; | |
9295 | 2736 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2737 } |
2738 | |
5836 | 2739 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2740 signon = info->onlinesince; | |
2741 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2742 signon = time(NULL) - info->sessionlen; |
2086 | 2743 |
5575 | 2744 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
2745 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2746 |
7261 | 2747 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
4738 | 2748 if (!bi) { |
2749 bi = g_new0(struct buddyinfo, 1); | |
7261 | 2750 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
4738 | 2751 } |
4739 | 2752 bi->typingnot = FALSE; |
2753 bi->ico_informed = FALSE; | |
6857 | 2754 bi->ipaddr = info->icqinfo.ipaddr; |
2755 | |
2756 /* Available message stuff */ | |
6292 | 2757 free(bi->availmsg); |
7011 | 2758 if (info->avail != NULL) |
8225 | 2759 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2760 else |
6292 | 2761 bi->availmsg = NULL; |
4732 | 2762 |
4804 | 2763 /* Server stored icon stuff */ |
4853 | 2764 if (info->iconcsumlen) { |
7125 | 2765 const char *filename = NULL, *saved_b16 = NULL; |
2766 char *b16 = NULL; | |
7093 | 2767 GaimBuddy *b = NULL; |
4853 | 2768 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2769 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
4853 | 2770 b = gaim_find_buddy(gc->account, info->sn); |
7093 | 2771 /* |
2772 * If for some reason the checksum is valid, but cached file is not.. | |
2773 * we want to know. | |
2774 */ | |
7693 | 2775 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2776 if (filename != NULL) { |
2777 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2778 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2779 "icon_checksum"); | |
7093 | 2780 } else |
2781 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2782 |
4853 | 2783 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2784 GSList *cur = od->requesticon; | |
2785 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2786 cur = cur->next; | |
2787 if (!cur) { | |
7475 | 2788 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
4853 | 2789 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2790 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2791 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2792 } |
2793 } | |
6053 | 2794 g_free(b16); |
4853 | 2795 } |
2796 | |
9058 | 2797 /* |
2798 * If we have info for ourselves, then update our local warning | |
2799 * level and set our official time of login. Is this necessary? | |
2800 * XXX - This needs to be changed some how. evil should not be | |
2801 * handled by the core at all? | |
2802 */ | |
2803 if (!aim_sncmp(info->sn, gaim_account_get_username(account))) { | |
2804 gc->evil = (info->warnlevel/10.0); | |
2805 gc->login_time_official = signon; | |
2806 } | |
2807 | |
5628 | 2808 serv_got_update(gc, info->sn, 1, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 2809 |
2810 return 1; | |
2811 } | |
2812 | |
8341 | 2813 static void gaim_check_comment(OscarData *od, const char *str) { |
2814 if ((str == NULL) || strcmp(str, ck)) | |
2815 aim_locate_setcaps(od->sess, caps_aim); | |
2816 else | |
2817 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2818 } | |
2819 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2820 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2821 GaimConnection *gc = sess->aux_data; |
7283 | 2822 OscarData *od = gc->proto_data; |
2086 | 2823 va_list ap; |
4739 | 2824 aim_userinfo_t *info; |
2086 | 2825 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2826 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2827 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2828 va_end(ap); |
2829 | |
4732 | 2830 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); |
2086 | 2831 |
7261 | 2832 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 2833 |
2086 | 2834 return 1; |
2835 } | |
2836 | |
4617 | 2837 /* BBB */ |
3952 | 2838 /* |
4617 | 2839 * This is called after a remote AIM user has connected to us. We |
2840 * want to do some voodoo with the socket file descriptors, add a | |
2841 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 2842 */ |
4656 | 2843 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2844 GaimConnection *gc = sess->aux_data; |
7283 | 2845 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2846 GaimXfer *xfer; |
5146 | 2847 struct aim_oft_info *oft_info; |
3630 | 2848 va_list ap; |
2849 aim_conn_t *conn, *listenerconn; | |
4656 | 2850 |
8660 | 2851 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2852 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 2853 va_start(ap, fr); |
2854 conn = va_arg(ap, aim_conn_t *); | |
2855 listenerconn = va_arg(ap, aim_conn_t *); | |
2856 va_end(ap); | |
2857 | |
4617 | 2858 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
2859 return 1; | |
2860 | |
5146 | 2861 if (!(oft_info = xfer->data)) |
4617 | 2862 return 1; |
2863 | |
3630 | 2864 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 2865 gaim_input_remove(xfer->watcher); |
3630 | 2866 aim_conn_kill(sess, &listenerconn); |
2867 | |
5146 | 2868 oft_info->conn = conn; |
2869 xfer->fd = oft_info->conn->fd; | |
2870 | |
2871 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
2872 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
2873 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 2874 |
2875 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 2876 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 2877 |
2878 return 0; | |
2879 } | |
2880 | |
3952 | 2881 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2882 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 2883 * user in order to transfer a file. |
3952 | 2884 */ |
4617 | 2885 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
|
2886 GaimXfer *xfer; |
5146 | 2887 struct aim_oft_info *oft_info; |
4656 | 2888 |
8660 | 2889 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2890 "AAA - in oscar_sendfile_connected\n"); |
4617 | 2891 if (!(xfer = data)) |
2892 return; | |
5146 | 2893 if (!(oft_info = xfer->data)) |
3630 | 2894 return; |
8446 | 2895 if (source < 0) { |
2896 gaim_xfer_cancel_remote(xfer); | |
4617 | 2897 return; |
8446 | 2898 } |
4617 | 2899 |
2900 xfer->fd = source; | |
5146 | 2901 oft_info->conn->fd = source; |
2902 | |
2903 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
2904 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 2905 |
2906 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 2907 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 2908 |
2909 return; | |
3630 | 2910 } |
2911 | |
3952 | 2912 /* |
4617 | 2913 * This is called when a buddy sends us some file info. This happens when they |
2914 * are sending a file to you, and you have just established a connection to them. | |
4650 | 2915 * You should send them the exact same info except use the real cookie. We also |
4617 | 2916 * get like totally ready to like, receive the file, kay? |
3952 | 2917 */ |
4617 | 2918 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2919 GaimConnection *gc = sess->aux_data; |
7283 | 2920 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2921 GaimXfer *xfer; |
5146 | 2922 struct aim_oft_info *oft_info; |
4617 | 2923 va_list ap; |
2924 aim_conn_t *conn; | |
2925 fu8_t *cookie; | |
2926 struct aim_fileheader_t *fh; | |
4656 | 2927 |
8660 | 2928 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2929 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 2930 va_start(ap, fr); |
2931 conn = va_arg(ap, aim_conn_t *); | |
2932 cookie = va_arg(ap, fu8_t *); | |
2933 fh = va_arg(ap, struct aim_fileheader_t *); | |
2934 va_end(ap); | |
2935 | |
2936 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
2937 return 1; | |
2938 | |
5146 | 2939 if (!(oft_info = xfer->data)) |
4617 | 2940 return 1; |
2941 | |
2942 /* We want to stop listening with a normal thingy */ | |
2943 gaim_input_remove(xfer->watcher); | |
2944 xfer->watcher = 0; | |
2945 | |
5146 | 2946 /* They sent us some information about the file they're sending */ |
2947 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
2948 | |
2949 /* Fill in the cookie */ | |
2950 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
2951 | |
4617 | 2952 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 2953 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 2954 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2955 | |
2956 return 0; | |
3630 | 2957 } |
2958 | |
3952 | 2959 /* |
4657 | 2960 * We are sending a file to someone else. They have just acknowledged our |
4617 | 2961 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 2962 */ |
4617 | 2963 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2964 GaimConnection *gc = sess->aux_data; |
7283 | 2965 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2966 GaimXfer *xfer; |
4617 | 2967 va_list ap; |
2968 aim_conn_t *conn; | |
2969 fu8_t *cookie; | |
2970 struct aim_fileheader_t *fh; | |
4656 | 2971 |
8660 | 2972 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 2973 va_start(ap, fr); |
2974 conn = va_arg(ap, aim_conn_t *); | |
2975 cookie = va_arg(ap, fu8_t *); | |
2976 fh = va_arg(ap, struct aim_fileheader_t *); | |
2977 va_end(ap); | |
2978 | |
2979 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
2980 return 1; | |
2981 | |
4656 | 2982 /* We want to stop listening with a normal thingy */ |
2983 gaim_input_remove(xfer->watcher); | |
2984 xfer->watcher = 0; | |
2985 | |
4617 | 2986 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2987 | |
2988 return 0; | |
3630 | 2989 } |
4617 | 2990 |
2991 /* | |
2992 * We just sent a file to someone. They said they got it and everything, | |
2993 * so we can close our direct connection and what not. | |
2994 */ | |
2995 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 2996 GaimConnection *gc = sess->aux_data; |
7283 | 2997 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2998 GaimXfer *xfer; |
4617 | 2999 va_list ap; |
3000 aim_conn_t *conn; | |
3001 fu8_t *cookie; | |
3002 struct aim_fileheader_t *fh; | |
4656 | 3003 |
8660 | 3004 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3005 va_start(ap, fr); |
3006 conn = va_arg(ap, aim_conn_t *); | |
3007 cookie = va_arg(ap, fu8_t *); | |
3008 fh = va_arg(ap, struct aim_fileheader_t *); | |
3009 va_end(ap); | |
3010 | |
3011 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3012 return 1; | |
3013 | |
4656 | 3014 xfer->fd = conn->fd; |
4617 | 3015 gaim_xfer_end(xfer); |
3016 | |
3017 return 0; | |
3018 } | |
3630 | 3019 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3020 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3021 GaimConnection *gc = sess->aux_data; |
7283 | 3022 OscarData *od = gc->proto_data; |
8708 | 3023 GaimAccount *account = gaim_connection_get_account(gc); |
7475 | 3024 gchar *tmp; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3025 GaimConvImFlags flags = 0; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
3026 gsize convlen; |
3659 | 3027 GError *err = NULL; |
4738 | 3028 struct buddyinfo *bi; |
5575 | 3029 const char *iconfile; |
4738 | 3030 |
8708 | 3031 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3032 if (!bi) { |
3033 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3034 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3035 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3036 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3037 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3038 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3039 |
4738 | 3040 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3041 bi->typingnot = TRUE; | |
3042 else | |
3043 bi->typingnot = FALSE; | |
3044 | |
4380 | 3045 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3046 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3047 "%s has an icon\n", userinfo->sn); |
4738 | 3048 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3049 bi->ico_need = TRUE; | |
3050 bi->ico_len = args->iconlen; | |
3051 bi->ico_csum = args->iconsum; | |
3052 bi->ico_time = args->iconstamp; | |
2246
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 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3055 |
8708 | 3056 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3057 (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
|
3058 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3059 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3060 |
5575 | 3061 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3062 char *buf = g_malloc(st.st_size); |
5575 | 3063 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3064 if (file) { |
9532 | 3065 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3066 int len = fread(buf, 1, st.st_size, file); |
8660 | 3067 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3068 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3069 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3070 userinfo->sn, len, st.st_size); |
4617 | 3071 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3072 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3073 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3074 } else |
8660 | 3075 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3076 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3077 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3078 } else |
8660 | 3079 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3080 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3081 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3082 |
8660 | 3083 gaim_debug_misc("oscar", |
8623 | 3084 "Received message from %s with charset %hu %hu\n", |
3085 userinfo->sn, args->charset, args->charsubset); | |
3086 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3087 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
3722 | 3088 /* This message is marked as UNICODE, so we have to |
3089 * convert it to utf-8 before handing it to the gaim core. | |
3090 * This conversion should *never* fail, if it does it | |
3091 * means that either the incoming ICBM is corrupted or | |
4662 | 3092 * there is something we don't understand about it. |
3093 * For the record, AIM Unicode is big-endian UCS-2 */ | |
3094 | |
8660 | 3095 gaim_debug_info("oscar", "Received UNICODE IM\n"); |
4121 | 3096 |
3097 if (!args->msg || !args->msglen) | |
3098 return 1; | |
4641 | 3099 |
3659 | 3100 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
3101 if (err) { | |
8660 | 3102 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3103 "Unicode IM conversion: %s\n", err->message); |
7475 | 3104 tmp = g_strdup(_("(There was an error receiving this message)")); |
4800 | 3105 g_error_free(err); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3106 } |
3722 | 3107 } else { |
3850 | 3108 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 3109 * unflagged messages, which are ASCII. That's OK because |
3110 * ASCII is a strict subset of ISO-8859-1; this should | |
3111 * help with compatibility with old, broken versions of | |
3112 * gaim (everything before 0.60) and other broken clients | |
3113 * that will happily send ISO-8859-1 without marking it as | |
3114 * such */ | |
4662 | 3115 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
8660 | 3116 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3117 "Received ISO-8859-1 IM\n"); |
4121 | 3118 |
3119 if (!args->msg || !args->msglen) | |
3120 return 1; | |
3121 | |
3659 | 3122 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
3123 if (err) { | |
8660 | 3124 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3125 "ISO-8859-1 IM conversion: %s\n", err->message); |
7475 | 3126 tmp = g_strdup(_("(There was an error receiving this message)")); |
4800 | 3127 g_error_free(err); |
3659 | 3128 } |
3642 | 3129 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3130 |
8666 | 3131 /* |
8995 | 3132 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3133 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3134 * so any HTML we receive is intended to be displayed |
3135 * | |
3136 * Note: There *may* be some clients which send messages as HTML formatted - | |
3137 * they need to be special-cased somehow. | |
8666 | 3138 */ |
8995 | 3139 if (isdigit(gaim_account_get_username(account)[0]) && isdigit(userinfo->sn[0])) { |
3140 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ | |
3141 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3142 g_free(tmp); |
3143 tmp = tmp2; | |
3144 } | |
3145 | |
6982 | 3146 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3147 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3148 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3149 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3150 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3151 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3152 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3153 GaimConnection *gc; |
3154 OscarData *od; | |
3155 const char *username; | |
3156 | |
3157 g_return_val_if_fail(sess != NULL, 0); | |
3158 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3159 | |
3160 gc = sess->aux_data; | |
3161 od = gc->proto_data; | |
3162 username = gaim_account_get_username(gaim_connection_get_account(gc)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3163 |
4121 | 3164 if (!args) |
3165 return 0; | |
4194 | 3166 |
8660 | 3167 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3168 "rendezvous with %s, status is %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3169 userinfo->sn, args->status); |
2869 | 3170 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3171 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3172 char *name; |
5234 | 3173 GHashTable *components; |
3174 | |
4121 | 3175 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
3176 return 1; | |
5234 | 3177 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3178 g_free); | |
4121 | 3179 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3180 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3181 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
|
3182 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3183 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3184 userinfo->sn, |
6059 | 3185 args->msg, |
5234 | 3186 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3187 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3188 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3189 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3190 /* BBB */ |
3191 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3192 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3193 GaimXfer *xfer; |
5146 | 3194 struct aim_oft_info *oft_info; |
3195 | |
3196 if (!args->cookie || !args->port || !args->verifiedip || | |
3197 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3198 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3199 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3200 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3201 "information.\n", userinfo->sn); |
5146 | 3202 if (args->proxyip) |
8660 | 3203 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3204 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3205 "does not support this yet.\n"); |
4617 | 3206 return 1; |
4656 | 3207 } |
4617 | 3208 |
3209 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3210 /* 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
|
3211 * directory -- remove the star and trailing slash so we don't save |
4617 | 3212 * directories that look like 'dirname\*' -- arl */ |
3213 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3214 if (tmp && (tmp[1] == '*')) { | |
3215 tmp[0] = '\0'; | |
3216 } | |
8660 | 3217 gaim_debug_warning("oscar", |
8446 | 3218 "We're receiving a whole directory! What fun! " |
3219 "Especially since we don't support that!\n"); | |
4617 | 3220 } |
3221 | |
3222 /* Build the file transfer handle */ | |
3223 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3224 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3225 xfer->remote_port = args->port; |
4617 | 3226 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3227 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
5146 | 3228 |
3229 /* Create the oscar-specific data */ | |
5163 | 3230 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3231 if (args->proxyip) |
5146 | 3232 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3233 if (args->verifiedip) |
5146 | 3234 oft_info->verifiedip = g_strdup(args->verifiedip); |
3235 xfer->data = oft_info; | |
4617 | 3236 |
3237 /* Setup our I/O op functions */ | |
8446 | 3238 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3239 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3240 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
|
3241 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3242 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3243 |
3244 /* | |
3245 * XXX - Should do something with args->msg, args->encoding, and args->language | |
3246 * probably make it apply to all ch2 messages. | |
3752 | 3247 */ |
4617 | 3248 |
3249 /* Keep track of this transfer for later */ | |
3250 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3251 | |
3252 /* Now perform the request */ | |
3253 gaim_xfer_request(xfer); | |
3254 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3255 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3256 GaimXfer *xfer; |
8660 | 3257 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3258 "AAA - File transfer canceled by remote user\n"); |
4617 | 3259 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
|
3260 gaim_xfer_cancel_remote(xfer); |
4617 | 3261 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3262 /* | |
3263 * This gets sent by the receiver of a file | |
3264 * as they connect directly to us. If we don't | |
3265 * get this, then maybe a third party connected | |
3266 * to us, and we shouldn't send them anything. | |
3267 */ | |
3268 } else { | |
8660 | 3269 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3270 "unknown rendezvous status!\n"); |
3630 | 3271 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3272 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3273 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3274 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3275 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3276 userinfo->sn, args->info.icon.icon, |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3277 args->info.icon.length); |
6871 | 3278 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3279 /* 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
|
3280 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3281 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
|
3282 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3283 |
4212 | 3284 if (!args->verifiedip) { |
8983 | 3285 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3286 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3287 "directim kill blocked (%s)\n", userinfo->sn); |
4650 | 3288 return 1; |
4212 | 3289 } |
3290 | |
8660 | 3291 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3292 "%s received direct im request from %s (%s)\n", |
8983 | 3293 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3294 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3295 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3296 d->sn = g_strdup(userinfo->sn); |
8983 | 3297 /* Let's use the clientip here, because I think that's what AIM does. |
3298 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3299 * and then ask them to connect to us. */ | |
3300 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
|
3301 memcpy(d->cookie, args->cookie, 8); |
9070 | 3302 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3303 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3304 | |
8971 | 3305 oscar_direct_im_destroy(od, dim); |
8984 | 3306 d->donttryagain = TRUE; |
8971 | 3307 accept_direct_im_request(d); |
3308 } else { | |
8983 | 3309 if (dim && !dim->connected) |
8971 | 3310 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3311 "already connected to that buddy!"); | |
5575 | 3312 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
|
3313 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3314 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3315 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3316 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3317 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3318 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3319 "risk."), 0, d, 2, |
8971 | 3320 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3321 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3322 /* FIXME: we should actually send a packet on cancel */ | |
3323 } | |
8708 | 3324 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3325 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
|
3326 } else { |
8660 | 3327 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3328 "Unknown reqclass %hu\n", args->reqclass); |
2246
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 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3331 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3332 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3333 |
3453 | 3334 /* |
4230 | 3335 * Authorization Functions |
3336 * Most of these are callbacks from dialogs. They're used by both | |
3337 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3338 */ |
4269 | 3339 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3340 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3341 GaimConnection *gc = data->gc; |
4244 | 3342 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3343 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3344 OscarData *od = gc->proto_data; |
6695 | 3345 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3346 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3347 if (buddy && group) { |
8660 | 3348 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3349 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3350 buddy->name, group->name); |
4889 | 3351 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3352 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3353 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3354 } |
4230 | 3355 } |
4337 | 3356 } |
3357 | |
3358 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3359 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3360 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3361 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3362 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3363 data); |
4230 | 3364 } |
3365 | |
3366 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3367 GaimConnection *gc = data->gc; |
4244 | 3368 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3369 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3370 /* Remove from local list */ |
3371 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3372 gaim_blist_remove_buddy(b); | |
4244 | 3373 } |
3374 | |
5836 | 3375 oscar_free_name_data(data); |
4230 | 3376 } |
3377 | |
9030 | 3378 |
3379 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3380 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3381 GaimBuddy *buddy; |
4269 | 3382 gchar *dialog_msg, *nombre; |
3383 | |
4687 | 3384 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3385 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3386 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3387 else |
4830 | 3388 nombre = NULL; |
3389 | |
3390 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 | 3391 data->gc = gc; |
3392 data->name = g_strdup(name); | |
3393 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3394 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3395 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3396 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3397 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3398 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3399 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3400 |
3401 g_free(dialog_msg); | |
3402 g_free(nombre); | |
3403 } | |
3404 | |
9030 | 3405 |
3406 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3407 GaimBuddy *buddy; | |
3408 GaimConnection *gc; | |
3409 | |
3410 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3411 | |
3412 buddy = (GaimBuddy *) node; | |
3413 gc = gaim_account_get_connection(buddy->account); | |
3414 gaim_auth_sendrequest(gc, buddy->name); | |
3415 } | |
3416 | |
4230 | 3417 /* When other people ask you for authorization */ |
3418 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3419 GaimConnection *gc = data->gc; |
4244 | 3420 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3421 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3422 OscarData *od = gc->proto_data; |
4236 | 3423 #ifdef NOSSI |
6695 | 3424 GaimBuddy *buddy; |
4244 | 3425 gchar message; |
3426 message = 0; | |
4687 | 3427 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3428 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3429 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3430 #else |
4889 | 3431 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3432 #endif |
4244 | 3433 } |
3434 | |
5836 | 3435 oscar_free_name_data(data); |
3141 | 3436 } |
3437 | |
4230 | 3438 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3439 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3440 GaimConnection *gc = data->gc; |
4244 | 3441 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3442 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3443 OscarData *od = gc->proto_data; |
4230 | 3444 #ifdef NOSSI |
4617 | 3445 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3446 #else |
4889 | 3447 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3448 #endif |
4244 | 3449 } |
4337 | 3450 } |
3451 | |
3452 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3453 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3454 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3455 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3456 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3457 data); |
3141 | 3458 } |
3459 | |
7023 | 3460 /* When someone sends you buddies */ |
3461 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3462 GaimConnection *gc = data->gc; |
4244 | 3463 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3464 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3465 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3466 } |
3467 | |
5836 | 3468 oscar_free_name_data(data); |
3453 | 3469 } |
3470 | |
4075 | 3471 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 | 3472 GaimConnection *gc = sess->aux_data; |
4076 | 3473 gchar **msg1, **msg2; |
3474 GError *err = NULL; | |
6051 | 3475 int i, numtoks; |
4076 | 3476 |
4121 | 3477 if (!args->type || !args->msg || !args->uin) |
3478 return 1; | |
4194 | 3479 |
8660 | 3480 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3481 "Received a channel 4 message of type 0x%02hhx.\n", args->type); |
4076 | 3482 |
3483 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 3484 msg1 = g_strsplit(args->msg, "\376", 0); |
6051 | 3485 for (numtoks=0; msg1[numtoks]; numtoks++); |
3486 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3487 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3488 gaim_str_strip_cr(msg1[i]); |
4076 | 3489 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); |
4800 | 3490 if (err) { |
8660 | 3491 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3492 "Error converting a string from ISO-8859-1 to " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3493 "UTF-8 in oscar ICBM channel 4 parsing\n"); |
4800 | 3494 g_error_free(err); |
3495 } | |
4076 | 3496 } |
3497 msg2[i] = NULL; | |
3498 | |
3952 | 3499 switch (args->type) { |
4173 | 3500 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3501 if (i >= 1) { |
5556 | 3502 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3503 gchar *tmp; |
3504 | |
3505 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3506 tmp = gaim_escape_html(msg2[0]); |
8493 | 3507 |
4076 | 3508 if (t) { /* This is an offline message */ |
9680 | 3509 /* The timestamp is UTC-ish, so we need to get the offset */ |
3510 tzset(); | |
3511 t -= timezone; | |
8514 | 3512 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3513 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3514 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3515 } |
3516 g_free(uin); | |
8493 | 3517 g_free(tmp); |
4075 | 3518 } |
3316 | 3519 } break; |
3520 | |
4173 | 3521 case 0x04: { /* Someone sent you a URL */ |
4076 | 3522 if (i >= 2) { |
7385 | 3523 if (msg2[1] != NULL) { |
3524 gchar *uin = g_strdup_printf("%u", args->uin); | |
3525 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3526 msg2[1], | |
3527 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3528 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3529 g_free(uin); | |
3530 g_free(message); | |
3531 } | |
3453 | 3532 } |
3533 } break; | |
3534 | |
4173 | 3535 case 0x06: { /* Someone requested authorization */ |
4076 | 3536 if (i >= 6) { |
4230 | 3537 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3538 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 | 3539 gaim_debug_info("oscar", |
5556 | 3540 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3541 args->uin); |
4076 | 3542 data->gc = gc; |
5556 | 3543 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3544 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3545 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3546 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3547 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3548 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3549 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3550 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3551 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3552 g_free(dialog_msg); |
3553 } | |
3141 | 3554 } break; |
3555 | |
4173 | 3556 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3557 if (i >= 1) { |
7023 | 3558 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
|
3559 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3560 dialog_msg); |
4076 | 3561 g_free(dialog_msg); |
3562 } | |
3141 | 3563 } break; |
3564 | |
4173 | 3565 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3566 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
|
3567 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3568 dialog_msg); |
3141 | 3569 g_free(dialog_msg); |
3570 } break; | |
3571 | |
4333 | 3572 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3573 if (i >= 5) { | |
3574 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
|
3575 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3576 g_free(dialog_msg); |
3577 } | |
3578 } break; | |
3579 | |
4173 | 3580 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3581 if (i >= 6) { |
4194 | 3582 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
|
3583 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3584 g_free(dialog_msg); |
3585 } | |
4075 | 3586 } break; |
3587 | |
4173 | 3588 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3589 if (i >= 6) { |
4308 | 3590 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
|
3591 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3592 g_free(dialog_msg); |
3593 } | |
4075 | 3594 } break; |
3595 | |
4173 | 3596 case 0x12: { |
3141 | 3597 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3598 /* Someone added you to their buddy list? */ |
3141 | 3599 } break; |
3600 | |
7023 | 3601 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3602 guint i, num; |
3453 | 3603 gchar **text; |
4173 | 3604 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3605 if (text) { |
3606 num = 0; | |
3607 for (i=0; i<strlen(text[0]); i++) | |
3608 num = num*10 + text[0][i]-48; | |
3609 for (i=0; i<num; i++) { | |
4230 | 3610 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3611 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 | 3612 data->gc = gc; |
4790 | 3613 data->name = g_strdup(text[i*2+1]); |
3614 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3615 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3616 gaim_request_action(gc, NULL, message, |
7023 | 3617 _("Do you want to add this buddy " |
3618 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3619 0, data, 2, |
7023 | 3620 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3621 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3622 g_free(message); |
3623 } | |
3624 g_strfreev(text); | |
3625 } | |
3626 } break; | |
3627 | |
7023 | 3628 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3629 /* This is boring and silly. */ |
3630 } break; | |
3631 | |
3141 | 3632 default: { |
8660 | 3633 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3634 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3635 "(type 0x%02hhx).\n", args->type); |
3141 | 3636 } break; |
3637 } | |
3638 | |
4076 | 3639 g_strfreev(msg1); |
3640 g_strfreev(msg2); | |
3641 | |
3141 | 3642 return 1; |
3643 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3644 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3645 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3646 fu16_t channel; |
3647 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3648 aim_userinfo_t *userinfo; |
2086 | 3649 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3650 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3651 va_start(ap, fr); |
4200 | 3652 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3653 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3654 |
3141 | 3655 switch (channel) { |
3656 case 1: { /* standard message */ | |
3657 struct aim_incomingim_ch1_args *args; | |
3658 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3659 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3660 } break; | |
3661 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3662 case 2: { /* rendezvous */ |
3141 | 3663 struct aim_incomingim_ch2_args *args; |
3664 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3665 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3666 } break; | |
3667 | |
3668 case 4: { /* ICQ */ | |
3669 struct aim_incomingim_ch4_args *args; | |
3670 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3671 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3672 } break; |
3673 | |
3674 default: { | |
8660 | 3675 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3676 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3677 "0x%04hx).", channel); |
3141 | 3678 } break; |
2086 | 3679 } |
3680 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3681 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3682 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3683 return ret; |
2086 | 3684 } |
3685 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3686 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3687 GaimConnection *gc = sess->aux_data; |
3688 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3689 char *buf; |
2086 | 3690 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3691 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3692 aim_userinfo_t *userinfo; |
2086 | 3693 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3694 va_start(ap, fr); |
4200 | 3695 chan = (fu16_t)va_arg(ap, unsigned int); |
3696 userinfo = va_arg(ap, aim_userinfo_t *); | |
3697 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3698 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3699 va_end(ap); |
3700 | |
3701 switch(reason) { | |
5420 | 3702 case 0: /* Invalid (0) */ |
3703 buf = g_strdup_printf( | |
3704 ngettext( | |
4276 | 3705 "You missed %hu message from %s because it was invalid.", |
3706 "You missed %hu messages from %s because they were invalid.", | |
3707 nummissed), | |
4282 | 3708 nummissed, |
3709 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3710 break; |
5420 | 3711 case 1: /* Message too large */ |
3712 buf = g_strdup_printf( | |
3713 ngettext( | |
4276 | 3714 "You missed %hu message from %s because it was too large.", |
3715 "You missed %hu messages from %s because they were too large.", | |
3716 nummissed), | |
4282 | 3717 nummissed, |
3718 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3719 break; |
5420 | 3720 case 2: /* Rate exceeded */ |
3721 buf = g_strdup_printf( | |
3722 ngettext( | |
4276 | 3723 "You missed %hu message from %s because the rate limit has been exceeded.", |
3724 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3725 nummissed), | |
4282 | 3726 nummissed, |
3727 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3728 break; |
5420 | 3729 case 3: /* Evil Sender */ |
3730 buf = g_strdup_printf( | |
3731 ngettext( | |
4276 | 3732 "You missed %hu message from %s because he/she was too evil.", |
3733 "You missed %hu messages from %s because he/she was too evil.", | |
3734 nummissed), | |
4282 | 3735 nummissed, |
3736 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3737 break; |
5420 | 3738 case 4: /* Evil Receiver */ |
3739 buf = g_strdup_printf( | |
3740 ngettext( | |
4276 | 3741 "You missed %hu message from %s because you are too evil.", |
3742 "You missed %hu messages from %s because you are too evil.", | |
3743 nummissed), | |
4282 | 3744 nummissed, |
3745 userinfo->sn); | |
2086 | 3746 break; |
3747 default: | |
5420 | 3748 buf = g_strdup_printf( |
3749 ngettext( | |
4276 | 3750 "You missed %hu message from %s for an unknown reason.", |
3751 "You missed %hu messages from %s for an unknown reason.", | |
3752 nummissed), | |
4282 | 3753 nummissed, |
3754 userinfo->sn); | |
2086 | 3755 break; |
3756 } | |
8733 | 3757 |
9627 | 3758 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3759 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3760 g_free(buf); |
2086 | 3761 |
3762 return 1; | |
3763 } | |
3764 | |
4194 | 3765 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3766 GaimConnection *gc = sess->aux_data; |
7283 | 3767 OscarData *od = gc->proto_data; |
4617 | 3768 |
3769 /* BBB */ | |
3630 | 3770 switch (reason) { |
4151 | 3771 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3772 GaimXfer *xfer; |
8971 | 3773 struct oscar_direct_im *dim; |
3774 | |
8660 | 3775 gaim_debug_info("oscar", |
9070 | 3776 "AAA - Other user declined some sort of direct " |
8971 | 3777 "connect attempt (automaticly?)\n"); |
4617 | 3778 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
|
3779 gaim_xfer_cancel_remote(xfer); |
8971 | 3780 else if ((dim = oscar_direct_im_find(od, who))) { |
3781 /* AAA should use find by cookie or something here */ | |
3782 oscar_direct_im_disconnect(od, dim); | |
3783 } | |
4151 | 3784 } break; |
3785 | |
3786 default: { | |
8660 | 3787 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3788 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3789 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3790 } |
3630 | 3791 |
3792 } | |
3793 | |
3794 return 0; | |
3795 } | |
3796 | |
4194 | 3797 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3798 GaimConnection *gc = sess->aux_data; |
4151 | 3799 |
3800 switch(reason) { | |
3801 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3802 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3803 | |
3804 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3805 |
3806 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3807 statusmsg = oscar_icqstatus(state); |
4151 | 3808 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3809 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3810 g_free(statusmsg); | |
4151 | 3811 g_strfreev(splitmsg); |
9244 | 3812 |
3813 gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); | |
3814 | |
3815 g_free(title); | |
3816 g_free(dialogmsg); | |
4151 | 3817 } break; |
3818 | |
3819 default: { | |
8660 | 3820 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3821 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3822 "Type 0x%04hx\n", who, reason); |
4151 | 3823 } break; |
3824 } /* end of switch */ | |
3825 | |
3826 return 0; | |
3827 } | |
3828 | |
3212 | 3829 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
3830 va_list ap; | |
3831 fu16_t chan, reason; | |
3832 char *who; | |
3833 | |
3834 va_start(ap, fr); | |
4200 | 3835 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3836 who = va_arg(ap, char *); |
4200 | 3837 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3838 |
3952 | 3839 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 3840 char *cookie = va_arg(ap, char *); |
4151 | 3841 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 3842 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 3843 fu32_t state = 0; |
4151 | 3844 char *msg = NULL; |
3845 if (reason == 0x0003) { | |
4200 | 3846 state = va_arg(ap, fu32_t); |
4151 | 3847 msg = va_arg(ap, char *); |
3848 } | |
3849 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
3850 } | |
3952 | 3851 |
3212 | 3852 va_end(ap); |
3853 | |
3854 return 1; | |
3855 } | |
3856 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3857 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3858 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3859 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3860 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3861 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3862 va_start(ap, fr); |
4199 | 3863 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3864 va_end(ap); |
3865 | |
8660 | 3866 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3867 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3868 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 3869 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3870 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 3871 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3872 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3873 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3874 |
2086 | 3875 return 1; |
3876 } | |
3877 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3878 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 3879 GaimConnection *gc = sess->aux_data; |
4617 | 3880 #if 0 |
7283 | 3881 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3882 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3883 #endif |
4617 | 3884 va_list ap; |
3885 fu16_t reason; | |
3886 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3887 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3888 va_start(ap, fr); |
4617 | 3889 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 3890 data = va_arg(ap, char *); |
2086 | 3891 va_end(ap); |
3892 | |
8660 | 3893 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3894 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 3895 |
3896 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3897 #if 0 |
4617 | 3898 /* If this was a file transfer request, data is a cookie */ |
3899 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
|
3900 gaim_xfer_cancel_remote(xfer); |
3630 | 3901 return 1; |
3902 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3903 #endif |
3630 | 3904 |
4617 | 3905 /* Data is assumed to be the destination sn */ |
9627 | 3906 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), |
3907 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Your message did not get sent."))) { | |
9647 | 3908 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data ? data : "(null)"); |
9627 | 3909 gaim_notify_error(sess->aux_data, NULL, buf, |
3910 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3911 g_free(buf); | |
3912 } | |
2086 | 3913 return 1; |
3914 } | |
3915 | |
3595 | 3916 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3917 GaimConnection *gc = sess->aux_data; |
3595 | 3918 va_list ap; |
3919 fu16_t type1, type2; | |
3920 char *sn; | |
3921 | |
3922 va_start(ap, fr); | |
4199 | 3923 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3924 sn = va_arg(ap, char *); |
4199 | 3925 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3926 va_end(ap); |
3927 | |
3928 switch (type2) { | |
3929 case 0x0000: { /* Text has been cleared */ | |
3930 serv_got_typing_stopped(gc, sn); | |
3931 } break; | |
3932 | |
3933 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3934 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 3935 } break; |
3936 | |
3937 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3938 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 3939 } break; |
3940 | |
3941 default: { | |
8660 | 3942 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 | 3943 } break; |
3944 } | |
3945 | |
3946 return 1; | |
3947 } | |
3948 | |
7141 | 3949 /* |
3950 * We get this error when there was an error in the locate family. This | |
7259 | 3951 * happens when you request info of someone who is offline. |
7141 | 3952 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3953 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 3954 gchar *buf, *cbuf; |
2086 | 3955 va_list ap; |
5420 | 3956 fu16_t reason; |
2086 | 3957 char *destn; |
3958 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3959 va_start(ap, fr); |
4199 | 3960 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3961 destn = va_arg(ap, char *); |
3962 va_end(ap); | |
3963 | |
7781 | 3964 if (destn == NULL) |
7793 | 3965 return 1; |
9627 | 3966 |
3967 cbuf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3968 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), cbuf)) { | |
3969 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); | |
3970 gaim_notify_error(sess->aux_data, NULL, buf, | |
3971 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3972 g_free(buf); | |
3973 } | |
3974 g_free(cbuf); | |
2086 | 3975 |
3976 return 1; | |
3977 } | |
3978 | |
7011 | 3979 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3980 GaimConnection *gc = sess->aux_data; |
8700 | 3981 GaimAccount *account = gaim_connection_get_account(gc); |
3982 GString *str; | |
9244 | 3983 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 3984 va_list ap; |
7011 | 3985 aim_userinfo_t *userinfo; |
2086 | 3986 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3987 va_start(ap, fr); |
7011 | 3988 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3989 va_end(ap); |
3990 | |
8700 | 3991 str = g_string_new(""); |
3992 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
3993 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 3994 |
3995 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 3996 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 3997 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 3998 |
3999 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 4000 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 4001 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 4002 |
4003 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4004 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4005 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4006 g_free(tmp); |
4007 } | |
4008 | |
8701 | 4009 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4010 |
4011 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4012 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4013 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4014 g_free(tmp); | |
7011 | 4015 if (away_utf8 != NULL) { |
8700 | 4016 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4017 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4018 } |
7011 | 4019 } |
4020 | |
4021 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4022 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4023 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4024 g_free(tmp); | |
7011 | 4025 if (info_utf8 != NULL) { |
8700 | 4026 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4027 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4028 } |
7011 | 4029 } |
4030 | |
8701 | 4031 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4032 g_string_free(str, TRUE); |
9244 | 4033 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
4034 gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, tmp, NULL, NULL); | |
4035 g_free(title); | |
8700 | 4036 g_free(tmp); |
4151 | 4037 |
2086 | 4038 return 1; |
4039 } | |
4040 | |
8341 | 4041 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4042 { | |
4043 aim_session_t *sess = data; | |
4044 GaimConnection *gc = sess->aux_data; | |
4045 OscarData *od = (OscarData *)gc->proto_data; | |
4046 | |
4047 aim_locate_dorequest(data); | |
4048 od->getinfotimer = 0; | |
4049 | |
4050 return FALSE; | |
4051 } | |
4052 | |
4053 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4054 { | |
4055 GaimConnection *gc = sess->aux_data; | |
4056 OscarData *od = (OscarData *)gc->proto_data; | |
4057 | |
4058 /* | |
4059 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4060 * us from hitting the rate limit due to request away messages and info | |
4061 * too quickly. | |
4062 */ | |
4063 if (od->getinfotimer == 0) | |
4064 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4065 | |
4066 return 1; | |
4067 } | |
4068 | |
4069 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4070 { | |
2086 | 4071 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4072 fu16_t id; |
2086 | 4073 va_list ap; |
4074 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4075 va_start(ap, fr); |
4199 | 4076 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4077 msg = va_arg(ap, char *); |
4078 va_end(ap); | |
4079 | |
8660 | 4080 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4081 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4082 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4083 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4084 _("Your AIM connection may be lost."), NULL); |
2086 | 4085 |
4086 return 1; | |
4087 } | |
4088 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4089 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4090 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4091 fu16_t type; |
5575 | 4092 GaimConnection *gc = sess->aux_data; |
7283 | 4093 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4094 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4095 va_start(ap, fr); |
4199 | 4096 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4097 |
4098 switch(type) { | |
4099 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4100 fu8_t maxrooms; |
2086 | 4101 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4102 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4103 |
4199 | 4104 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4105 exchangecount = va_arg(ap, int); |
4106 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4107 | |
8660 | 4108 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4109 "chat info: Chat Rights:\n"); |
8660 | 4110 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4111 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4112 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4113 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4114 for (i = 0; i < exchangecount; i++) |
8660 | 4115 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4116 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4117 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4118 while (od->create_rooms) { |
4119 struct create_room *cr = od->create_rooms->data; | |
8660 | 4120 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4121 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4122 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4123 g_free(cr->name); |
4617 | 4124 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4125 g_free(cr); |
2086 | 4126 } |
4127 } | |
4128 break; | |
4129 case 0x0008: { | |
4130 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4131 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4132 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4133 fu32_t createtime; |
2086 | 4134 |
4135 fqcn = va_arg(ap, char *); | |
4200 | 4136 instance = (fu16_t)va_arg(ap, unsigned int); |
4137 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4138 flags = (fu16_t)va_arg(ap, unsigned int); | |
4139 createtime = va_arg(ap, fu32_t); | |
4140 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4141 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4142 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4143 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4144 name = va_arg(ap, char *); | |
4145 ck = va_arg(ap, char *); | |
4194 | 4146 |
8660 | 4147 gaim_debug_misc("oscar", |
5556 | 4148 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4149 fqcn, |
4150 exchange, instance, flags, | |
4151 createtime, | |
4152 maxmsglen, maxoccupancy, createperms, unknown, | |
4153 name, ck); | |
4617 | 4154 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4155 } |
4156 break; | |
4157 default: | |
8660 | 4158 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4159 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4160 break; |
4161 } | |
4194 | 4162 |
4163 va_end(ap); | |
4164 | |
2086 | 4165 return 1; |
4166 } | |
4167 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4168 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4169 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4170 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4171 aim_userinfo_t *info; |
5575 | 4172 GaimConnection *g = sess->aux_data; |
2086 | 4173 |
4174 struct chat_connection *c = NULL; | |
4175 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4176 va_start(ap, fr); |
2086 | 4177 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4178 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4179 va_end(ap); |
4180 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4181 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4182 if (!c) |
4183 return 1; | |
4184 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4185 for (i = 0; i < count; i++) |
9554 | 4186 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE); |
2086 | 4187 |
4188 return 1; | |
4189 } | |
4190 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4191 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4192 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4193 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4194 aim_userinfo_t *info; |
5575 | 4195 GaimConnection *g = sess->aux_data; |
2086 | 4196 |
4197 struct chat_connection *c = NULL; | |
4198 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4199 va_start(ap, fr); |
2086 | 4200 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4201 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4202 va_end(ap); |
4203 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4204 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4205 if (!c) |
4206 return 1; | |
4207 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4208 for (i = 0; i < count; i++) |
8733 | 4209 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4210 |
4211 return 1; | |
4212 } | |
4213 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4214 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
|
4215 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4216 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4217 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4218 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4219 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4220 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4221 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4222 fu32_t creationtime; |
5575 | 4223 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4224 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
|
4225 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4226 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4227 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4228 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4229 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4230 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4231 roomdesc = va_arg(ap, char *); |
4200 | 4232 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4233 creationtime = va_arg(ap, fu32_t); | |
4234 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4235 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4236 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4237 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4238 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4239 |
8660 | 4240 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4241 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4242 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4243 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4244 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4245 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4246 |
2086 | 4247 return 1; |
4248 } | |
4249 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4250 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4251 GaimConnection *gc = sess->aux_data; |
8225 | 4252 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4253 gchar *utf8; | |
2086 | 4254 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4255 aim_userinfo_t *info; |
8225 | 4256 int len; |
2086 | 4257 char *msg; |
8219 | 4258 char *charset; |
2086 | 4259 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4260 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4261 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4262 len = va_arg(ap, int); |
4194 | 4263 msg = va_arg(ap, char *); |
8219 | 4264 charset = va_arg(ap, char *); |
4194 | 4265 va_end(ap); |
2086 | 4266 |
8225 | 4267 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4268 if (utf8 == NULL) |
4269 /* The conversion failed! */ | |
8668 | 4270 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4271 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4272 g_free(utf8); | |
2086 | 4273 |
4274 return 1; | |
4275 } | |
4276 | |
3694 | 4277 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4278 va_list ap; | |
5575 | 4279 GaimConnection *gc = sess->aux_data; |
3694 | 4280 struct aim_emailinfo *emailinfo; |
3725 | 4281 int havenewmail; |
7297 | 4282 char *alertitle, *alerturl; |
3694 | 4283 |
4284 va_start(ap, fr); | |
4285 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4286 havenewmail = va_arg(ap, int); |
7301 | 4287 alertitle = va_arg(ap, char *); |
4288 alerturl = va_arg(ap, char *); | |
3694 | 4289 va_end(ap); |
4290 | |
9661 | 4291 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4292 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4293 emailinfo->domain ? "@" : "", | |
4294 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4295 if (emailinfo->unread && havenewmail) |
4296 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4297 g_free(to); |
3694 | 4298 } |
7297 | 4299 |
7301 | 4300 if (alertitle) |
8660 | 4301 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4302 |
4303 return 1; | |
4304 } | |
4305 | |
4804 | 4306 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4307 GaimConnection *gc = sess->aux_data; |
7283 | 4308 OscarData *od = gc->proto_data; |
4804 | 4309 char *sn; |
4310 | |
4311 sn = od->requesticon->data; | |
8660 | 4312 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4313 "removing %s from hash table\n", sn); |
4804 | 4314 od->requesticon = g_slist_remove(od->requesticon, sn); |
4315 free(sn); | |
4316 | |
4317 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4318 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4319 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4320 |
4321 return 1; | |
4322 } | |
4323 | |
4324 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4325 GaimConnection *gc = sess->aux_data; |
7283 | 4326 OscarData *od = gc->proto_data; |
4804 | 4327 GSList *cur; |
4328 va_list ap; | |
4329 char *sn; | |
4853 | 4330 fu8_t *iconcsum, *icon; |
4331 fu16_t iconcsumlen, iconlen; | |
4804 | 4332 |
4333 va_start(ap, fr); | |
4334 sn = va_arg(ap, char *); | |
4853 | 4335 iconcsum = va_arg(ap, fu8_t *); |
4336 iconcsumlen = va_arg(ap, int); | |
4804 | 4337 icon = va_arg(ap, fu8_t *); |
4338 iconlen = va_arg(ap, int); | |
4339 va_end(ap); | |
4340 | |
4853 | 4341 if (iconlen > 0) { |
4342 char *b16; | |
6695 | 4343 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4344 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4345 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4346 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4347 if (b16) { |
7693 | 4348 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4349 g_free(b16); |
5129 | 4350 } |
4853 | 4351 } |
4804 | 4352 |
4353 cur = od->requesticon; | |
4354 while (cur) { | |
4355 char *cursn = cur->data; | |
4356 if (!aim_sncmp(cursn, sn)) { | |
4357 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4358 free(cursn); | |
4359 cur = od->requesticon; | |
4360 } else | |
4361 cur = cur->next; | |
4362 } | |
4363 | |
4364 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4365 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4366 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4367 |
4368 return 1; | |
4369 } | |
4370 | |
4371 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4372 GaimConnection *gc = data; |
7283 | 4373 OscarData *od = gc->proto_data; |
7011 | 4374 aim_userinfo_t *userinfo; |
4804 | 4375 aim_conn_t *conn; |
4376 | |
4377 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4378 if (!conn) { |
4379 if (!od->iconconnecting) { | |
4380 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4381 od->iconconnecting = TRUE; | |
4382 } | |
4804 | 4383 return FALSE; |
4384 } | |
4385 | |
5842 | 4386 if (od->set_icon) { |
6039 | 4387 struct stat st; |
4388 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4389 if (iconfile == NULL) { | |
8363 | 4390 aim_ssi_delicon(od->sess); |
6039 | 4391 } else if (!stat(iconfile, &st)) { |
4392 char *buf = g_malloc(st.st_size); | |
4393 FILE *file = fopen(iconfile, "rb"); | |
4394 if (file) { | |
9532 | 4395 /* XXX - Use g_file_get_contents()? */ |
6039 | 4396 fread(buf, 1, st.st_size, file); |
4397 fclose(file); | |
8660 | 4398 gaim_debug_info("oscar", |
6039 | 4399 "Uploading icon to icon server\n"); |
6879 | 4400 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4401 } else |
8660 | 4402 gaim_debug_error("oscar", |
6039 | 4403 "Can't open buddy icon file!\n"); |
4404 g_free(buf); | |
4405 } else { | |
8660 | 4406 gaim_debug_error("oscar", |
6039 | 4407 "Can't stat buddy icon file!\n"); |
5842 | 4408 } |
4409 od->set_icon = FALSE; | |
4410 } | |
4411 | |
4412 if (!od->requesticon) { | |
8660 | 4413 gaim_debug_misc("oscar", |
5842 | 4414 "no more icons to request\n"); |
4415 return FALSE; | |
4416 } | |
4417 | |
7045 | 4418 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4419 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4420 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4421 return FALSE; |
4422 } else { | |
4423 char *sn = od->requesticon->data; | |
4424 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4425 free(sn); | |
4426 } | |
4427 | |
4428 return TRUE; | |
4429 } | |
4430 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4431 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4432 * 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
|
4433 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4434 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4435 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4436 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4437 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4438 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4439 va_start(ap, fr); |
4199 | 4440 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4441 sn = va_arg(ap, char *); |
4442 va_end(ap); | |
4443 | |
8660 | 4444 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4445 |
4446 return 1; | |
4447 } | |
4448 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4449 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
|
4450 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4451 "invalid", |
4194 | 4452 "change", |
4453 "warning", | |
4454 "limit", | |
4455 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4456 }; |
2086 | 4457 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4458 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4459 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4460 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4461 va_start(ap, fr); |
4200 | 4462 code = (fu16_t)va_arg(ap, unsigned int); |
4463 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4464 windowsize = va_arg(ap, fu32_t); | |
4465 clear = va_arg(ap, fu32_t); | |
4466 alert = va_arg(ap, fu32_t); | |
4467 limit = va_arg(ap, fu32_t); | |
4468 disconnect = va_arg(ap, fu32_t); | |
4469 currentavg = va_arg(ap, fu32_t); | |
4470 maxavg = va_arg(ap, fu32_t); | |
2086 | 4471 va_end(ap); |
4472 | |
8660 | 4473 gaim_debug_misc("oscar", |
5556 | 4474 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4475 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4476 (code < 5) ? codes[code] : codes[0], |
4477 rateclass, | |
4478 currentavg, maxavg, | |
4479 alert, clear, | |
4480 limit, disconnect, | |
4481 windowsize); | |
4482 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4483 /* XXX fix these values */ |
2086 | 4484 if (code == AIM_RATE_CODE_CHANGE) { |
4485 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4486 aim_conn_setlatency(fr->conn, 0); |
2086 | 4487 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4488 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4489 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4490 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4491 _("The last action you attempted could not be " |
4492 "performed because you are over the rate limit. " | |
4493 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4494 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4495 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4496 aim_conn_setlatency(fr->conn, 0); |
2086 | 4497 } |
4498 | |
4499 return 1; | |
4500 } | |
4501 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4502 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4503 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4504 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4505 aim_userinfo_t *userinfo; |
5575 | 4506 GaimConnection *gc = sess->aux_data; |
2086 | 4507 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4508 va_start(ap, fr); |
4199 | 4509 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4510 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4511 va_end(ap); |
4512 | |
7111 | 4513 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 4514 |
4515 return 1; | |
4516 } | |
4517 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4518 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
|
4519 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4520 aim_userinfo_t *info; |
5575 | 4521 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4522 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4523 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4524 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4525 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4526 |
5628 | 4527 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 4528 |
7872 | 4529 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 4530 gc->login_time_official = info->onlinesince; |
7872 | 4531 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
4532 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4533 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4534 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4535 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4536 |
4649 | 4537 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4538 GaimConnection *gc = sess->aux_data; |
7283 | 4539 OscarData *od = gc->proto_data; |
4649 | 4540 va_list ap; |
4541 fu16_t code; | |
4542 char *msg; | |
4543 | |
4544 va_start(ap, fr); | |
4545 code = (fu16_t)va_arg(ap, int); | |
4546 msg = va_arg(ap, char *); | |
4547 va_end(ap); | |
4548 | |
8660 | 4549 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4550 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4551 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4552 if (code == 0x0001) { |
6113 | 4553 gc->wants_to_die = TRUE; |
5579 | 4554 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4555 } else { |
5579 | 4556 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4557 } |
4666 | 4558 od->killme = TRUE; |
4649 | 4559 } |
4560 | |
4561 return 1; | |
4562 } | |
4563 | |
2675 | 4564 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4565 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4566 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4567 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4568 |
4569 #ifndef NOSSI | |
8660 | 4570 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4571 aim_ssi_reqrights(sess); |
6350 | 4572 aim_ssi_reqdata(sess); |
4230 | 4573 #endif |
4574 | |
7011 | 4575 aim_locate_reqrights(sess); |
7285 | 4576 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4577 aim_im_reqparams(sess); |
7334 | 4578 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4579 |
4580 #ifdef NOSSI | |
8660 | 4581 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4582 aim_bos_reqrights(sess, fr->conn); |
4230 | 4583 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4584 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4585 #endif | |
2086 | 4586 |
7283 | 4587 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4588 | |
2086 | 4589 return 1; |
4590 } | |
4591 | |
2675 | 4592 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4593 GaimConnection *gc = sess->aux_data; |
7283 | 4594 OscarData *od = gc->proto_data; |
2647 | 4595 |
6905 | 4596 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4597 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4598 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4599 | |
2672 | 4600 aim_clientready(sess, fr->conn); |
8660 | 4601 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4602 |
2647 | 4603 if (od->chpass) { |
8660 | 4604 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4605 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4606 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4607 od->oldp = NULL; |
2647 | 4608 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4609 od->newp = NULL; |
2647 | 4610 od->chpass = FALSE; |
4611 } | |
2979 | 4612 if (od->setnick) { |
8660 | 4613 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4614 aim_admin_setnick(sess, fr->conn, od->newsn); |
4615 g_free(od->newsn); | |
4616 od->newsn = NULL; | |
4617 od->setnick = FALSE; | |
4618 } | |
2647 | 4619 if (od->conf) { |
8660 | 4620 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4621 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4622 od->conf = FALSE; |
4623 } | |
4624 if (od->reqemail) { | |
8660 | 4625 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4626 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4627 od->reqemail = FALSE; |
4628 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4629 if (od->setemail) { |
8660 | 4630 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4631 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4632 g_free(od->email); |
5497 | 4633 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4634 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4635 } |
2647 | 4636 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4637 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4638 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4639 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4640 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
|
4641 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4642 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4643 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4644 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4645 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4646 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4647 |
4194 | 4648 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4649 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4650 "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
|
4651 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4652 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4653 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4654 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4655 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4656 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4657 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4658 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4659 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4660 |
4617 | 4661 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4662 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4663 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4664 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4665 |
2993 | 4666 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4667 { | |
5575 | 4668 GaimConnection *gc = sess->aux_data; |
7283 | 4669 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4670 va_list ap; |
4671 fu16_t maxsiglen; | |
2993 | 4672 |
4673 va_start(ap, fr); | |
4199 | 4674 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4675 va_end(ap); |
4676 | |
8660 | 4677 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4678 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4679 |
4617 | 4680 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4681 | |
4682 if (od->icq) | |
7334 | 4683 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4684 else |
7334 | 4685 aim_locate_setcaps(od->sess, caps_aim); |
4686 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4687 |
4688 return 1; | |
4689 } | |
4690 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4691 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
|
4692 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4693 fu16_t maxbuddies, maxwatchers; |
5575 | 4694 GaimConnection *gc = sess->aux_data; |
7283 | 4695 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4696 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4697 va_start(ap, fr); |
4199 | 4698 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4699 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4700 va_end(ap); |
4701 | |
8660 | 4702 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4703 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4704 |
4617 | 4705 od->rights.maxbuddies = (guint)maxbuddies; |
4706 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4707 |
2086 | 4708 return 1; |
4709 } | |
4710 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4711 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4712 GaimConnection *gc = sess->aux_data; |
7283 | 4713 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4714 va_list ap; |
4715 fu16_t maxpermits, maxdenies; | |
2086 | 4716 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4717 va_start(ap, fr); |
4199 | 4718 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4719 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4720 va_end(ap); |
4721 | |
8660 | 4722 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4723 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4724 |
4617 | 4725 od->rights.maxpermits = (guint)maxpermits; |
4726 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4727 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4728 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4729 serv_finish_login(gc); |
4730 | |
8660 | 4731 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4732 |
2672 | 4733 aim_clientready(sess, fr->conn); |
5948 | 4734 aim_srv_setavailmsg(sess, NULL); |
7474 | 4735 aim_srv_setidle(sess, 0); |
4617 | 4736 |
4664 | 4737 if (od->icq) { |
4738 aim_icq_reqofflinemsgs(sess); | |
4739 aim_icq_hideip(sess); | |
4740 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4741 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4742 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4743 if (sess->authinfo->email) |
4744 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4745 |
4746 return 1; | |
4747 } | |
4748 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4749 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
|
4750 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4751 struct aim_icq_offlinemsg *msg; |
4075 | 4752 struct aim_incomingim_ch4_args args; |
4753 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4754 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4755 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4756 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4757 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4758 |
8660 | 4759 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4760 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4761 args.uin = msg->sender; |
4762 args.type = msg->type; | |
4173 | 4763 args.flags = msg->flags; |
4076 | 4764 args.msglen = msg->msglen; |
4075 | 4765 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4766 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4767 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
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 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4770 } |
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 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
|
4773 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4774 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4775 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4776 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4777 |
7388 | 4778 #if 0 |
4779 /* | |
7465 | 4780 * Update, 2003-11-09: |
4781 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4782 * | |
7388 | 4783 * It may not be my place to do this, but... |
4784 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4785 * stupid, and should not exist for % switches (%x in our case) that request | |
4786 * a year in the preferred representation for the current locale. For that | |
4787 * reason I've chosen to not use this workaround (n., see kluge). | |
4788 * | |
4789 * I have a date. I want to show it to the user in the "preferred" way. | |
4790 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4791 * what the locale wanted. | |
4792 * | |
4793 * If I have a necessity for a full representation of the year in the current | |
4794 * locale, then I'll use a switch that returns a full representation of the | |
4795 * year. | |
4796 * | |
4797 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4798 * (because you're anal, or whatever), then change the f***ing locale. | |
4799 * | |
4800 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4801 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4802 * |
4803 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4804 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4805 */ |
4806 | |
4807 /* | |
4808 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4809 * "last 2 digits" warning. |
4810 */ | |
4811 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4812 const struct tm *tm) | |
4813 { | |
4814 return strftime(s, max, fmt, tm); | |
4815 } | |
7388 | 4816 #endif |
7386 | 4817 |
4624 | 4818 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
|
4819 { |
5575 | 4820 GaimConnection *gc = sess->aux_data; |
8670 | 4821 OscarData *od = (OscarData *)gc->proto_data; |
4822 GaimBuddy *buddy; | |
8853 | 4823 struct buddyinfo *bi = NULL; |
4624 | 4824 gchar who[16]; |
8670 | 4825 GString *str; |
4826 gchar *primary, *utf8; | |
9634 | 4827 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4828 va_list ap; |
4151 | 4829 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4830 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4831 va_start(ap, fr); |
4151 | 4832 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4833 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4834 |
4664 | 4835 if (!info->uin) |
4836 return 0; | |
4837 | |
8670 | 4838 str = g_string_sized_new(100); |
5556 | 4839 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 4840 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
4841 if (buddy != NULL) | |
4842 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
4843 | |
4844 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 4845 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 4846 if ((bi != NULL) && (bi->ipaddr != 0)) { |
4847 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
4848 (bi->ipaddr & 0xff000000) >> 24, | |
4849 (bi->ipaddr & 0x00ff0000) >> 16, | |
4850 (bi->ipaddr & 0x0000ff00) >> 8, | |
4851 (bi->ipaddr & 0x000000ff)); | |
8701 | 4852 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 4853 g_free(tstr); |
4854 } | |
8701 | 4855 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
4856 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4857 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 4858 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
4859 g_free(utf8); | |
4625 | 4860 } |
4861 if (info->numaddresses && info->email2) { | |
4862 int i; | |
4863 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4864 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 4865 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
4866 g_free(utf8); | |
4643 | 4867 } |
4625 | 4868 } |
4624 | 4869 } |
8701 | 4870 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
8902 | 4871 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
4872 info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 4873 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 4874 char date[30]; |
4875 struct tm tm; | |
4876 tm.tm_mday = (int)info->birthday; | |
4877 tm.tm_mon = (int)info->birthmonth-1; | |
4878 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 4879 strftime(date, sizeof(date), "%x", &tm); |
8701 | 4880 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 4881 } |
4624 | 4882 if (info->age) { |
4883 char age[5]; | |
4884 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 4885 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 4886 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4887 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 4888 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
4889 g_free(utf8); | |
4819 | 4890 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4891 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 4892 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
4893 g_free(utf8); | |
4894 } | |
4895 g_string_append_printf(str, "<hr>\n"); | |
4641 | 4896 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 4897 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 4898 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
4899 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
4900 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
4901 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 4902 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 4903 } |
4641 | 4904 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 4905 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 4906 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
4907 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
4908 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
4909 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 4910 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 4911 } |
4641 | 4912 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 4913 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 4914 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
4915 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
4916 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4917 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 4918 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
4919 g_free(utf8); | |
4624 | 4920 } |
8670 | 4921 g_string_append_printf(str, "\n<hr>\n"); |
4922 } | |
4923 | |
9634 | 4924 if (buddy != NULL) |
4925 alias = gaim_buddy_get_alias(buddy); | |
4926 else | |
4927 alias = who; | |
4928 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
8670 | 4929 gaim_notify_formatted(gc, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 4930 g_free(primary); |
8670 | 4931 g_string_free(str, TRUE); |
4151 | 4932 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4933 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4934 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4935 |
4759 | 4936 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
4937 { | |
5575 | 4938 GaimConnection *gc = sess->aux_data; |
4820 | 4939 gchar who[16], *utf8; |
6695 | 4940 GaimBuddy *b; |
4759 | 4941 va_list ap; |
4942 struct aim_icq_info *info; | |
4943 | |
4944 va_start(ap, fr); | |
4945 info = va_arg(ap, struct aim_icq_info *); | |
4946 va_end(ap); | |
4947 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4948 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 4949 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 4950 serv_got_alias(gc, who, utf8); |
4759 | 4951 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 4952 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 4953 } |
4820 | 4954 g_free(utf8); |
4759 | 4955 } |
4956 | |
4957 return 1; | |
4958 } | |
4959 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4960 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
|
4961 { |
7032 | 4962 GaimConnection *gc = sess->aux_data; |
4963 gchar *text; | |
4964 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4965 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4966 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4967 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4968 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4969 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4970 url = va_arg(ap, char *); |
4199 | 4971 wid = (fu16_t) va_arg(ap, int); |
4972 hei = (fu16_t) va_arg(ap, int); | |
4973 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4974 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4975 |
7032 | 4976 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
4977 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
4978 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4979 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4980 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4981 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4982 |
7032 | 4983 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
4984 { | |
6873 | 4985 GaimConnection *gc = sess->aux_data; |
4986 gchar *secondary; | |
4987 GString *text; | |
4988 int i, num; | |
2086 | 4989 va_list ap; |
6873 | 4990 char *email, *SNs; |
2086 | 4991 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4992 va_start(ap, fr); |
6873 | 4993 email = va_arg(ap, char *); |
2086 | 4994 num = va_arg(ap, int); |
4995 SNs = va_arg(ap, char *); | |
4996 va_end(ap); | |
4997 | |
8152 | 4998 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 4999 text = g_string_new(""); |
2086 | 5000 for (i = 0; i < num; i++) |
6873 | 5001 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5002 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5003 | |
5004 g_free(secondary); | |
5005 g_string_free(text, TRUE); | |
2086 | 5006 |
5007 return 1; | |
5008 } | |
5009 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5010 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5011 va_list ap; |
6873 | 5012 char *email; |
5420 | 5013 char *buf; |
2086 | 5014 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5015 va_start(ap, fr); |
6873 | 5016 email = va_arg(ap, char *); |
2086 | 5017 va_end(ap); |
5018 | |
6873 | 5019 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
|
5020 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5021 g_free(buf); |
2086 | 5022 |
5023 return 1; | |
5024 } | |
5025 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5026 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5027 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5028 fu16_t status; |
2086 | 5029 va_list ap; |
5030 char msg[256]; | |
5031 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5032 va_start(ap, fr); |
4199 | 5033 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5034 va_end(ap); |
5035 | |
8660 | 5036 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5037 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5038 status ? "unknown" : "email sent"); |
5039 if (!status) { | |
5302 | 5040 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5041 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5042 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5043 } |
5044 | |
5045 return 1; | |
5046 } | |
5047 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5048 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5049 GaimConnection *gc = sess->aux_data; |
2086 | 5050 va_list ap; |
3912 | 5051 fu16_t perms, err; |
5052 char *url, *sn, *email; | |
5053 int change; | |
2086 | 5054 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5055 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5056 change = va_arg(ap, int); |
4199 | 5057 perms = (fu16_t) va_arg(ap, unsigned int); |
5058 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5059 url = va_arg(ap, char *); |
5060 sn = va_arg(ap, char *); | |
5061 email = va_arg(ap, char *); | |
2086 | 5062 va_end(ap); |
5063 | |
8660 | 5064 gaim_debug_misc("oscar", |
9626 | 5065 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5066 change ? "change" : "request", perms, err, | |
5067 (url != NULL) ? url : "(null)", | |
5068 (sn != NULL) ? sn : "(null)", | |
5069 (email != NULL) ? email : "(null)"); | |
5070 | |
5071 if ((err > 0) && (url != NULL)) { | |
3912 | 5072 char *dialog_msg; |
5073 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5074 switch (err) { | |
5075 case 0x0001: { | |
5076 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5077 } break; | |
5078 case 0x0006: { | |
5079 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5080 } break; | |
5081 case 0x000b: { | |
5082 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5083 } break; | |
5084 case 0x001d: { | |
5085 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); | |
5086 } break; | |
5087 case 0x0021: { | |
5088 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); | |
5089 } break; | |
5090 case 0x0023: { | |
5091 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5092 } break; | |
5093 default: { | |
5094 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5095 } break; | |
5096 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5097 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5098 g_free(dialog_top); |
5099 g_free(dialog_msg); | |
5100 return 1; | |
5101 } | |
5102 | |
9626 | 5103 if (sn != NULL) { |
4585 | 5104 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
|
5105 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5106 g_free(dialog_msg); |
5107 } | |
5108 | |
9626 | 5109 if (email != NULL) { |
5575 | 5110 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5111 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5112 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5113 g_free(dialog_msg); |
2086 | 5114 } |
5115 | |
5116 return 1; | |
5117 } | |
5118 | |
5575 | 5119 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5120 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5121 aim_flap_nop(od->sess, od->conn); |
2086 | 5122 } |
5123 | |
6059 | 5124 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5125 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5126 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5127 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5128 if (typing == GAIM_TYPING) |
4870 | 5129 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5130 else if (typing == GAIM_TYPED) |
4870 | 5131 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5132 else | |
5133 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5134 else { |
5300 | 5135 /* Don't send if this turkey is in our deny list */ |
5136 GSList *list; | |
5137 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5138 if (!list) { | |
7261 | 5139 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5140 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5141 if (typing == GAIM_TYPING) |
5300 | 5142 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5143 else if (typing == GAIM_TYPED) |
5300 | 5144 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5145 else | |
5146 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5147 } | |
3595 | 5148 } |
5149 } | |
2993 | 5150 return 0; |
5151 } | |
9030 | 5152 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5153 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
|
5154 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5155 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5156 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5157 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
|
5158 int ret = 0; |
3659 | 5159 GError *err = NULL; |
5575 | 5160 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5161 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5162 |
4838 | 5163 if (dim && dim->connected) { |
5164 /* If we're directly connected, send a direct IM */ | |
6982 | 5165 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5166 } else { |
4738 | 5167 struct buddyinfo *bi; |
3008 | 5168 struct aim_sendimext_args args; |
5169 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5170 gsize len; |
8962 | 5171 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5172 | |
5173 if (strstr(message, "<IMG ")) | |
5174 gaim_conversation_write(conv, "", | |
5175 _("Your IM Image was not sent. " | |
5176 "You must be Direct Connected to send IM Images."), | |
5177 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5178 |
7261 | 5179 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5180 if (!bi) { |
5181 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5182 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5183 } |
5184 | |
3008 | 5185 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5186 if (od->icq) { |
5187 args.features = features_icq; | |
5188 args.featureslen = sizeof(features_icq); | |
3008 | 5189 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5190 } else { |
5191 args.features = features_aim; | |
5192 args.featureslen = sizeof(features_aim); | |
4972 | 5193 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5194 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5195 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5196 } |
4269 | 5197 |
4738 | 5198 if (bi->ico_need) { |
8660 | 5199 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5200 "Sending buddy icon request with message\n"); |
3008 | 5201 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5202 bi->ico_need = FALSE; |
3008 | 5203 } |
4269 | 5204 |
5575 | 5205 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5206 FILE *file = fopen(iconfile, "rb"); |
3008 | 5207 if (file) { |
5208 char *buf = g_malloc(st.st_size); | |
9532 | 5209 /* XXX - Use g_file_get_contents()? */ |
3008 | 5210 fread(buf, 1, st.st_size, file); |
6039 | 5211 fclose(file); |
4269 | 5212 |
3008 | 5213 args.iconlen = st.st_size; |
4617 | 5214 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5215 args.iconstamp = st.st_mtime; |
5216 | |
7406 | 5217 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5218 bi->ico_informed = FALSE; |
7406 | 5219 bi->ico_sent = FALSE; |
5220 } | |
4738 | 5221 |
5222 if (!bi->ico_informed) { | |
8660 | 5223 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5224 "Claiming to have a buddy icon\n"); |
4738 | 5225 args.flags |= AIM_IMFLAGS_HASICON; |
5226 bi->ico_me_len = args.iconlen; | |
5227 bi->ico_me_csum = args.iconsum; | |
5228 bi->ico_me_time = args.iconstamp; | |
5229 bi->ico_informed = TRUE; | |
5230 } | |
5231 | |
3008 | 5232 g_free(buf); |
2086 | 5233 } |
5234 } | |
4269 | 5235 |
3008 | 5236 args.destsn = name; |
4269 | 5237 |
8985 | 5238 /* |
5239 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5240 * strip all HTML | |
5241 */ | |
8995 | 5242 if (isdigit(name[0]) ) { |
5243 /* being sent to an ICQ user */ | |
5244 if (!isdigit(gaim_account_get_username(gc->account)[0])) { | |
5245 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ | |
5246 tmpmsg = gaim_str_add_cr(message); | |
5247 } else { | |
5248 /* from an ICQ user - do nothing */ | |
5249 tmpmsg = g_strdup(message); | |
5250 } | |
5251 } else { | |
5252 /* being sent to an AIM user */ | |
5253 if (isdigit(gaim_account_get_username(gc->account)[0])) { | |
5254 /* from an ICQ user */ | |
5255 tmpmsg2 = gaim_strdup_withhtml(message); | |
5256 tmpmsg = gaim_escape_html(tmpmsg2); | |
5257 g_free(tmpmsg2); | |
5258 } else | |
5259 tmpmsg = gaim_strdup_withhtml(message); | |
5260 } | |
6310 | 5261 len = strlen(tmpmsg); |
5262 | |
5263 args.flags |= oscar_encoding_check(tmpmsg); | |
3642 | 5264 if (args.flags & AIM_IMFLAGS_UNICODE) { |
8660 | 5265 gaim_debug_info("oscar", "Sending Unicode IM\n"); |
4662 | 5266 args.charset = 0x0002; |
4665 | 5267 args.charsubset = 0x0000; |
6310 | 5268 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3659 | 5269 if (err) { |
8660 | 5270 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5271 "Error converting a unicode message: %s\n", err->message); |
8660 | 5272 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5273 "This really shouldn't happen!\n"); |
3659 | 5274 /* We really shouldn't try to send the |
5275 * IM now, but I'm not sure what to do */ | |
4800 | 5276 g_error_free(err); |
3659 | 5277 } |
3850 | 5278 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
8660 | 5279 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5280 "Sending ISO-8859-1 IM\n"); |
4662 | 5281 args.charset = 0x0003; |
4665 | 5282 args.charsubset = 0x0000; |
6310 | 5283 args.msg = g_convert(tmpmsg, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3659 | 5284 if (err) { |
8660 | 5285 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5286 "conversion error: %s\n", err->message); |
8660 | 5287 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5288 "Someone tell Ethan his 8859-1 detection is wrong\n"); |
3642 | 5289 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
6310 | 5290 len = strlen(tmpmsg); |
4800 | 5291 g_error_free(err); |
6310 | 5292 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3659 | 5293 if (err) { |
8660 | 5294 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5295 "Error in unicode fallback: %s\n", err->message); |
4800 | 5296 g_error_free(err); |
3659 | 5297 } |
3642 | 5298 } |
5299 } else { | |
4662 | 5300 args.charset = 0x0000; |
5301 args.charsubset = 0x0000; | |
6310 | 5302 args.msg = tmpmsg; |
3642 | 5303 } |
5304 args.msglen = len; | |
4269 | 5305 |
4617 | 5306 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 5307 } |
4838 | 5308 |
6310 | 5309 g_free(tmpmsg); |
5310 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5311 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5312 return 1; |
6310 | 5313 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5314 return ret; |
2086 | 5315 } |
5316 | |
7011 | 5317 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5318 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5319 |
7173 | 5320 if (od->icq && isdigit(name[0])) |
4624 | 5321 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5322 else |
7235 | 5323 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5324 } |
5325 | |
8950 | 5326 #if 0 |
7011 | 5327 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5328 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5329 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5330 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5331 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5332 maiden, NULL, NULL, city, state, NULL, 0, web); |
5333 } | |
8950 | 5334 #endif |
2086 | 5335 |
5575 | 5336 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5337 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5338 aim_srv_setidle(od->sess, time); |
2086 | 5339 } |
5340 | |
5954 | 5341 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5342 OscarData *od = (OscarData *)gc->proto_data; |
5129 | 5343 fu32_t flags = 0; |
6019 | 5344 char *text_html = NULL; |
5129 | 5345 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5346 gsize msglen = 0; |
2993 | 5347 |
4617 | 5348 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5349 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5350 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5351 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5352 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5353 "again when you are fully connected.")); |
4617 | 5354 |
7334 | 5355 if (!text) { |
5356 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5357 return; | |
5358 } | |
6019 | 5359 |
7334 | 5360 text_html = gaim_strdup_withhtml(text); |
5361 flags = oscar_encoding_check(text_html); | |
5362 if (flags & AIM_IMFLAGS_UNICODE) { | |
5363 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5364 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5365 g_free(msg); | |
5366 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
5367 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5368 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5369 g_free(msg); | |
5370 } else { | |
5371 msglen = strlen(text_html); | |
5372 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5373 } | |
5374 | |
5375 if (msglen > od->rights.maxsiglen) { | |
5376 gchar *errstr; | |
5377 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5378 "has been exceeded. Gaim has truncated it for you.", | |
5379 "The maximum profile length of %d bytes " | |
5380 "has been exceeded. Gaim has truncated it for you.", | |
5381 od->rights.maxsiglen), od->rights.maxsiglen); | |
5382 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5383 g_free(errstr); | |
5384 } | |
5385 | |
5386 g_free(text_html); | |
2993 | 5387 |
5388 return; | |
2086 | 5389 } |
5390 | |
8257 | 5391 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 5392 { |
5129 | 5393 fu32_t flags = 0; |
6019 | 5394 gchar *text_html = NULL; |
5129 | 5395 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5396 gsize msglen = 0; |
2993 | 5397 |
8257 | 5398 if (!strcmp(state, _("Visible"))) { |
5399 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5400 return; | |
5401 } else if (!strcmp(state, _("Invisible"))) { | |
5402 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5403 return; | |
5404 } /* else... */ | |
5405 | |
8476 | 5406 if (!strcmp(state, _("Back"))) { |
5407 /* If this is our only online account then globally set Gaim not-away */ | |
5408 GList *gcs = gaim_connections_get_all(); | |
5409 if (gcs->next == NULL) | |
5410 do_im_back(NULL, NULL); | |
5411 } | |
5412 | |
8257 | 5413 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5414 | |
2993 | 5415 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5416 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5417 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5418 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5419 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5420 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5421 "fully connected.")); |
5129 | 5422 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5423 if (gc->away) { |
2993 | 5424 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5425 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5426 } |
2993 | 5427 |
5129 | 5428 if (!text) { |
7334 | 5429 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5430 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5431 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5432 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5433 text_html = gaim_strdup_withhtml(text); |
6019 | 5434 flags = oscar_encoding_check(text_html); |
5129 | 5435 if (flags & AIM_IMFLAGS_UNICODE) { |
6019 | 5436 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5437 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5438 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5439 g_free(msg); |
5440 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
5441 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
6019 | 5442 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5443 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5444 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5445 g_free(msg); |
6019 | 5446 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5447 } else { |
6019 | 5448 msglen = strlen(text_html); |
7011 | 5449 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5450 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 5451 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5452 } |
5453 | |
5454 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5455 gchar *errstr; |
5456 | |
6308 | 5457 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5458 "has been exceeded. Gaim has truncated it for you.", | |
5459 "The maximum away message length of %d bytes " | |
5460 "has been exceeded. Gaim has truncated it for you.", | |
5461 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5462 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5463 g_free(errstr); |
5464 } | |
6019 | 5465 |
5466 g_free(text_html); | |
8257 | 5467 |
2993 | 5468 return; |
5469 } | |
5470 | |
7283 | 5471 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 5472 { |
5575 | 5473 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5474 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5475 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5476 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5477 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5478 |
8265 | 5479 if (strcmp(state, _("Invisible"))) |
5575 | 5480 account->perm_deny = 4; |
8265 | 5481 else |
5575 | 5482 account->perm_deny = 3; |
8265 | 5483 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5484 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5485 |
5486 if (!strcmp(state, _("Online"))) | |
4901 | 5487 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 5488 else if (!strcmp(state, _("Away"))) { |
4901 | 5489 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5490 gc->away = g_strdup(""); |
4342 | 5491 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 5492 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
|
5493 gc->away = g_strdup(""); |
4342 | 5494 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 5495 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
|
5496 gc->away = g_strdup(""); |
4342 | 5497 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 5498 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
|
5499 gc->away = g_strdup(""); |
4342 | 5500 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 5501 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5502 gc->away = g_strdup(""); |
4342 | 5503 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 5504 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5505 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5506 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 5507 if (message) { |
4901 | 5508 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
|
5509 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5510 } else { |
4901 | 5511 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5512 } |
2086 | 5513 } |
2993 | 5514 |
5515 return; | |
5516 } | |
5517 | |
6059 | 5518 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 5519 { |
7283 | 5520 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 5521 |
5522 if (od->icq) | |
5523 oscar_set_away_icq(gc, od, state, message); | |
5524 else | |
8257 | 5525 oscar_set_away_aim(gc, od, state, message); |
2993 | 5526 |
5527 return; | |
2086 | 5528 } |
5529 | |
6059 | 5530 static void oscar_warn(GaimConnection *gc, const char *name, int anon) { |
7283 | 5531 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5532 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); |
2086 | 5533 } |
5534 | |
9285 | 5535 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5536 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5537 |
5538 if (!aim_snvalid(buddy->name)) { | |
8092 | 5539 gchar *buf; |
9285 | 5540 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 | 5541 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5542 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5543 g_free(buf); |
8150 | 5544 |
5545 /* Remove from local list */ | |
9285 | 5546 gaim_blist_remove_buddy(buddy); |
8150 | 5547 |
8092 | 5548 return; |
5549 } | |
5550 | |
4230 | 5551 #ifdef NOSSI |
9285 | 5552 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5553 #else |
9285 | 5554 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5555 if (buddy && group) { | |
8660 | 5556 gaim_debug_info("oscar", |
9285 | 5557 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5558 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5559 } |
5560 } | |
5561 #endif | |
8150 | 5562 |
4759 | 5563 if (od->icq) |
9285 | 5564 aim_icq_getalias(od->sess, buddy->name); |
5565 } | |
5566 | |
5567 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5568 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5569 #ifdef NOSSI |
5570 char buf[MSG_LEN]; | |
5571 int n=0; | |
9285 | 5572 |
4230 | 5573 while (buddies) { |
9381 | 5574 GaimBuddy *buddy = buddies->data; |
4230 | 5575 if (n > MSG_LEN - 18) { |
7285 | 5576 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5577 n = 0; |
3092 | 5578 } |
9381 | 5579 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5580 buddies = buddies->next; |
5581 } | |
7285 | 5582 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5583 #else |
9285 | 5584 |
4230 | 5585 if (od->sess->ssi.received_data) { |
9285 | 5586 GList *curb = buddies; |
5587 GList *curg = groups; | |
5588 while ((curb != NULL) && (curg != NULL)) { | |
5589 GaimBuddy *buddy = curb->data; | |
5590 GaimGroup *group = curg->data; | |
5591 oscar_add_buddy(gc, buddy, group); | |
5592 curb = curb->next; | |
5593 curg = curg->next; | |
4230 | 5594 } |
5595 } | |
5596 #endif | |
5597 } | |
5598 | |
9285 | 5599 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5600 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5601 |
4230 | 5602 #ifdef NOSSI |
9285 | 5603 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5604 #else |
5605 if (od->sess->ssi.received_data) { | |
8660 | 5606 gaim_debug_info("oscar", |
9285 | 5607 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5608 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5609 } |
5610 #endif | |
5611 } | |
5612 | |
9285 | 5613 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5614 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5615 |
4230 | 5616 #ifdef NOSSI |
9285 | 5617 for (cur = buddies; cur != NULL; cur = cur->next) { |
5618 GaimBuddy *buddy = cur->data; | |
5619 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5620 } | |
4230 | 5621 #else |
5622 if (od->sess->ssi.received_data) { | |
9285 | 5623 GList *curb = buddies; |
5624 GList *curg = groups; | |
5625 while ((curb != NULL) && (curg != NULL)) { | |
5626 GaimBuddy *buddy = curb->data; | |
5627 GaimGroup *group = curg->data; | |
5628 oscar_remove_buddy(gc, buddy, group); | |
5629 curb = curb->next; | |
5630 curg = curg->next; | |
3092 | 5631 } |
4230 | 5632 } |
5633 #endif | |
5634 } | |
5635 | |
5636 #ifndef NOSSI | |
5575 | 5637 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5638 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5639 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5640 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5641 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5642 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5643 } |
5644 } | |
5645 | |
5575 | 5646 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5647 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5648 if (od->sess->ssi.received_data) { |
5649 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5650 if (gname) { | |
8660 | 5651 gaim_debug_info("oscar", |
9586 | 5652 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5653 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5654 } |
5655 } | |
5656 } | |
5657 | |
9285 | 5658 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5659 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5660 |
5661 if (od->sess->ssi.received_data) { | |
9285 | 5662 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5663 GList *cur, *groups = NULL; | |
5664 | |
5665 /* Make a list of what the groups each buddy is in */ | |
5666 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5667 GaimBlistNode *node = cur->data; | |
5668 groups = g_list_append(groups, node->parent); | |
5669 } | |
5670 | |
5671 oscar_remove_buddies(gc, moved_buddies, groups); | |
5672 oscar_add_buddies(gc, moved_buddies, groups); | |
5673 g_list_free(groups); | |
8660 | 5674 gaim_debug_info("oscar", |
9285 | 5675 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5676 } else { |
9285 | 5677 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5678 gaim_debug_info("oscar", |
9285 | 5679 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5680 } |
5681 } | |
5682 } | |
5683 | |
5968 | 5684 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5685 aim_session_t *sess = data; | |
6350 | 5686 aim_ssi_reqdata(sess); |
5968 | 5687 return FALSE; |
5688 } | |
5689 | |
4642 | 5690 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5691 GaimConnection *gc = sess->aux_data; |
7283 | 5692 OscarData *od = gc->proto_data; |
4642 | 5693 va_list ap; |
5694 fu16_t reason; | |
5695 | |
5696 va_start(ap, fr); | |
5697 reason = (fu16_t)va_arg(ap, unsigned int); | |
5698 va_end(ap); | |
5699 | |
8660 | 5700 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5701 |
5702 if (reason == 0x0005) { | |
5892 | 5703 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5704 _("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
|
5705 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5706 } |
5707 | |
5708 /* Activate SSI */ | |
5709 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5710 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5711 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5712 aim_ssi_enable(od->sess); |
5713 | |
5714 return 1; | |
5715 } | |
5716 | |
2991 | 5717 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5718 GaimConnection *gc = sess->aux_data; |
7283 | 5719 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5720 int numtypes, i; |
5721 fu16_t *maxitems; | |
2991 | 5722 va_list ap; |
5723 | |
5724 va_start(ap, fr); | |
4230 | 5725 numtypes = va_arg(ap, int); |
5726 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5727 va_end(ap); |
5728 | |
8660 | 5729 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5730 |
4230 | 5731 for (i=0; i<numtypes; i++) |
8660 | 5732 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5733 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5734 |
8660 | 5735 gaim_debug_misc(NULL, "\n"); |
4230 | 5736 |
5737 if (numtypes >= 0) | |
5738 od->rights.maxbuddies = maxitems[0]; | |
5739 if (numtypes >= 1) | |
5740 od->rights.maxgroups = maxitems[1]; | |
5741 if (numtypes >= 2) | |
5742 od->rights.maxpermits = maxitems[2]; | |
5743 if (numtypes >= 3) | |
5744 od->rights.maxdenies = maxitems[3]; | |
2991 | 5745 |
5746 return 1; | |
5747 } | |
5748 | |
5749 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5750 GaimConnection *gc = sess->aux_data; |
5751 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5752 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5753 GaimGroup *g; |
5754 GaimBuddy *b; | |
2995 | 5755 struct aim_ssi_item *curitem; |
2991 | 5756 int tmp; |
4230 | 5757 va_list ap; |
8219 | 5758 fu16_t fmtver, numitems; |
5759 struct aim_ssi_item *items; | |
5760 fu32_t timestamp; | |
4230 | 5761 |
5762 va_start(ap, fr); | |
5763 fmtver = (fu16_t)va_arg(ap, int); | |
5764 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5765 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5766 timestamp = va_arg(ap, fu32_t); |
8219 | 5767 va_end(ap); |
2991 | 5768 |
8660 | 5769 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5770 "ssi: syncing local list and server list\n"); |
2991 | 5771 |
8219 | 5772 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5773 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 | 5774 return 1; |
5775 } | |
5776 | |
2991 | 5777 /* Clean the buddy list */ |
4889 | 5778 aim_ssi_cleanlist(sess); |
2991 | 5779 |
8150 | 5780 { /* If not in server list then prune from local list */ |
5781 GaimBlistNode *gnode, *cnode, *bnode; | |
5782 GaimBuddyList *blist; | |
9539 | 5783 GSList *cur, *next; |
8150 | 5784 |
5785 /* Buddies */ | |
5786 cur = NULL; | |
5787 if ((blist = gaim_get_blist()) != NULL) { | |
5788 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5789 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5790 continue; | |
5791 g = (GaimGroup *)gnode; | |
5792 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5793 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5794 continue; | |
5795 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5796 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5797 continue; | |
5798 b = (GaimBuddy *)bnode; | |
5799 if (b->account == gc->account) { | |
5800 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5801 /* If the buddy is an ICQ user then load his nickname */ | |
5802 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5803 char *alias; |
8150 | 5804 if (servernick) |
5805 serv_got_alias(gc, b->name, servernick); | |
5806 | |
5807 /* Store local alias on server */ | |
8214 | 5808 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5809 if (!alias && b->alias && strlen(b->alias)) |
5810 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5811 free(alias); | |
5812 } else { | |
8660 | 5813 gaim_debug_info("oscar", |
8150 | 5814 "ssi: removing buddy %s from local list\n", b->name); |
5815 /* We can't actually remove now because it will screw up our looping */ | |
5816 cur = g_slist_prepend(cur, b); | |
5817 } | |
5818 } | |
5819 } | |
5820 } | |
5821 } | |
5822 } | |
8175 | 5823 |
8150 | 5824 while (cur != NULL) { |
5825 b = cur->data; | |
5826 cur = g_slist_remove(cur, b); | |
5827 gaim_blist_remove_buddy(b); | |
5828 } | |
5829 | |
5830 /* Permit list */ | |
5831 if (gc->account->permit) { | |
9539 | 5832 next = gc->account->permit; |
5833 while (next != NULL) { | |
5834 cur = next; | |
5835 next = next->next; | |
8150 | 5836 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5837 gaim_debug_info("oscar", |
8150 | 5838 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5839 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5840 } | |
9539 | 5841 } |
8150 | 5842 } |
5843 | |
5844 /* Deny list */ | |
5845 if (gc->account->deny) { | |
9539 | 5846 next = gc->account->deny; |
5847 while (next != NULL) { | |
5848 cur = next; | |
5849 next = next->next; | |
8150 | 5850 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 5851 gaim_debug_info("oscar", |
8150 | 5852 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5853 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5854 } | |
9539 | 5855 } |
8150 | 5856 } |
5857 /* Presence settings (idle time visibility) */ | |
5858 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5859 if (!(tmp & 0x400)) | |
5860 aim_ssi_setpresence(sess, tmp | 0x400); | |
5861 } /* end pruning buddies from local list */ | |
5862 | |
2991 | 5863 /* Add from server list to local list */ |
4230 | 5864 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 5865 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 5866 switch (curitem->type) { |
4230 | 5867 case 0x0000: { /* Buddy */ |
4251 | 5868 if (curitem->name) { |
4292 | 5869 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 5870 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 5871 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 5872 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 5873 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 5874 /* Should gname be freed here? -- elb */ |
4754 | 5875 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 5876 free(alias); |
8150 | 5877 if (b) { |
4292 | 5878 /* Get server stored alias */ |
4705 | 5879 if (alias_utf8) { |
8150 | 5880 g_free(b->alias); |
5881 b->alias = g_strdup(alias_utf8); | |
4705 | 5882 } |
4282 | 5883 } else { |
8150 | 5884 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 5885 |
4754 | 5886 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 5887 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 5888 gaim_blist_add_group(g, NULL); |
5889 } | |
5146 | 5890 |
8660 | 5891 gaim_debug_info("oscar", |
9285 | 5892 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 5893 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 5894 } |
8341 | 5895 if (!aim_sncmp(curitem->name, account->username)) { |
5896 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
5897 gaim_check_comment(od, comment); | |
5898 free(comment); | |
5899 } | |
7162 | 5900 g_free(gname_utf8); |
5901 g_free(alias_utf8); | |
2991 | 5902 } |
4230 | 5903 } break; |
5904 | |
5905 case 0x0001: { /* Group */ | |
4282 | 5906 /* Shouldn't add empty groups */ |
4230 | 5907 } break; |
5908 | |
5909 case 0x0002: { /* Permit buddy */ | |
2991 | 5910 if (curitem->name) { |
4230 | 5911 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 5912 GSList *list; |
5575 | 5913 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5914 if (!list) { |
8660 | 5915 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5916 "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
|
5917 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 5918 } |
5919 } | |
4230 | 5920 } break; |
5921 | |
5922 case 0x0003: { /* Deny buddy */ | |
2991 | 5923 if (curitem->name) { |
5924 GSList *list; | |
5575 | 5925 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5926 if (!list) { |
8660 | 5927 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5928 "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
|
5929 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 5930 } |
5931 } | |
4230 | 5932 } break; |
5933 | |
5934 case 0x0004: { /* Permit/deny setting */ | |
2991 | 5935 if (curitem->data) { |
5936 fu8_t permdeny; | |
5575 | 5937 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 5938 gaim_debug_info("oscar", |
5575 | 5939 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
5940 account->perm_deny = permdeny; | |
5941 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 5942 serv_set_away(gc, "Invisible", ""); |
5943 } | |
2991 | 5944 } |
5945 } | |
4230 | 5946 } break; |
5947 | |
5948 case 0x0005: { /* Presence setting */ | |
3109 | 5949 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 5950 } break; |
2991 | 5951 } /* End of switch on curitem->type */ |
5952 } /* End of for loop */ | |
4230 | 5953 |
4901 | 5954 /* Set our ICQ status */ |
8257 | 5955 if (!gc->away) { |
4901 | 5956 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
5957 } | |
5958 | |
4342 | 5959 /* Activate SSI */ |
5960 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5961 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5962 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5963 "ssi: activating server-stored buddy list\n"); |
4642 | 5964 aim_ssi_enable(sess); |
4342 | 5965 |
2991 | 5966 return 1; |
2086 | 5967 } |
4230 | 5968 |
5969 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5970 GaimConnection *gc = sess->aux_data; |
4230 | 5971 va_list ap; |
5972 struct aim_ssi_tmp *retval; | |
5973 | |
5974 va_start(ap, fr); | |
5975 retval = va_arg(ap, struct aim_ssi_tmp *); | |
5976 va_end(ap); | |
5977 | |
5978 while (retval) { | |
8660 | 5979 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5980 "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 | 5981 |
5982 if (retval->ack != 0xffff) | |
5983 switch (retval->ack) { | |
5984 case 0x0000: { /* added successfully */ | |
5985 } break; | |
5986 | |
4829 | 5987 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
5988 gchar *buf; | |
5989 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 | 5990 if (!gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
5991 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
4829 | 5992 g_free(buf); |
5993 } | |
5994 | |
7023 | 5995 case 0x000e: { /* buddy requires authorization */ |
4828 | 5996 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 5997 gaim_auth_sendrequest(gc, retval->name); |
4230 | 5998 } break; |
5999 | |
6000 default: { /* La la la */ | |
5197 | 6001 gchar *buf; |
8660 | 6002 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6003 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 | 6004 if (!gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
6005 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
5197 | 6006 g_free(buf); |
4230 | 6007 } break; |
6008 } | |
6009 | |
6010 retval = retval->next; | |
6011 } | |
6012 | |
6013 return 1; | |
6014 } | |
6015 | |
8227 | 6016 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6017 GaimConnection *gc = sess->aux_data; | |
6018 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6019 GaimBuddy *b; | |
6020 GaimGroup *g; | |
6021 va_list ap; | |
6022 fu16_t type; | |
6023 const char *name; | |
6024 | |
6025 va_start(ap, fr); | |
6026 type = (fu16_t)va_arg(ap, int); | |
6027 name = va_arg(ap, char *); | |
6028 va_end(ap); | |
6029 | |
6030 if ((type != 0x0000) || (name == NULL)) | |
6031 return 1; | |
6032 | |
6033 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6034 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6035 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6036 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6037 b = gaim_find_buddy(gc->account, name); | |
6038 free(alias); | |
6039 | |
6040 if (b) { | |
6041 /* Get server stored alias */ | |
6042 if (alias_utf8) { | |
6043 g_free(b->alias); | |
6044 b->alias = g_strdup(alias_utf8); | |
6045 } | |
6046 } else { | |
6047 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6048 | |
6049 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6050 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6051 gaim_blist_add_group(g, NULL); | |
6052 } | |
6053 | |
8660 | 6054 gaim_debug_info("oscar", |
9285 | 6055 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6056 gaim_blist_add_buddy(b, NULL, g, NULL); |
6057 } | |
6058 g_free(gname_utf8); | |
6059 g_free(alias_utf8); | |
6060 | |
6061 return 1; | |
6062 } | |
6063 | |
4230 | 6064 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6065 GaimConnection *gc = sess->aux_data; |
4230 | 6066 va_list ap; |
6067 char *sn, *msg; | |
4236 | 6068 gchar *dialog_msg, *nombre; |
4230 | 6069 struct name_data *data; |
6695 | 6070 GaimBuddy *buddy; |
4230 | 6071 |
6072 va_start(ap, fr); | |
6073 sn = va_arg(ap, char *); | |
6074 msg = va_arg(ap, char *); | |
6075 va_end(ap); | |
6076 | |
8660 | 6077 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6078 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6079 |
4687 | 6080 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6081 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6082 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6083 else |
6084 nombre = g_strdup(sn); | |
6085 | |
6086 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 | 6087 data = g_new(struct name_data, 1); |
6088 data->gc = gc; | |
6089 data->name = g_strdup(sn); | |
6090 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6091 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6092 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6093 0, data, |
7023 | 6094 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6095 G_CALLBACK(oscar_free_name_data)); |
4236 | 6096 |
4230 | 6097 g_free(dialog_msg); |
4236 | 6098 g_free(nombre); |
4230 | 6099 |
6100 return 1; | |
6101 } | |
6102 | |
6103 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6104 GaimConnection *gc = sess->aux_data; |
4230 | 6105 va_list ap; |
6106 char *sn, *msg; | |
4236 | 6107 gchar *dialog_msg, *nombre; |
4230 | 6108 struct name_data *data; |
6695 | 6109 GaimBuddy *buddy; |
4230 | 6110 |
6111 va_start(ap, fr); | |
6112 sn = va_arg(ap, char *); | |
6113 msg = va_arg(ap, char *); | |
6114 va_end(ap); | |
6115 | |
8660 | 6116 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6117 "ssi: received authorization request from %s\n", sn); |
4230 | 6118 |
4687 | 6119 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6120 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6121 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6122 else |
6123 nombre = g_strdup(sn); | |
6124 | |
4337 | 6125 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 | 6126 data = g_new(struct name_data, 1); |
6127 data->gc = gc; | |
6128 data->name = g_strdup(sn); | |
6129 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6130 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6131 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6132 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6133 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6134 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6135 |
4230 | 6136 g_free(dialog_msg); |
4236 | 6137 g_free(nombre); |
4230 | 6138 |
6139 return 1; | |
6140 } | |
6141 | |
6142 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6143 GaimConnection *gc = sess->aux_data; |
4230 | 6144 va_list ap; |
6145 char *sn, *msg; | |
4236 | 6146 gchar *dialog_msg, *nombre; |
4230 | 6147 fu8_t reply; |
6695 | 6148 GaimBuddy *buddy; |
4230 | 6149 |
6150 va_start(ap, fr); | |
6151 sn = va_arg(ap, char *); | |
6152 reply = (fu8_t)va_arg(ap, int); | |
6153 msg = va_arg(ap, char *); | |
6154 va_end(ap); | |
6155 | |
8660 | 6156 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6157 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6158 |
4687 | 6159 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6160 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6161 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6162 else |
6163 nombre = g_strdup(sn); | |
6164 | |
4230 | 6165 if (reply) { |
6166 /* Granted */ | |
7023 | 6167 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
|
6168 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6169 } else { |
6170 /* Denied */ | |
7023 | 6171 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
|
6172 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6173 } |
6174 g_free(dialog_msg); | |
4236 | 6175 g_free(nombre); |
4230 | 6176 |
6177 return 1; | |
6178 } | |
6179 | |
6180 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6181 GaimConnection *gc = sess->aux_data; |
4230 | 6182 va_list ap; |
6183 char *sn; | |
6695 | 6184 GaimBuddy *buddy; |
4230 | 6185 |
6186 va_start(ap, fr); | |
6187 sn = va_arg(ap, char *); | |
6188 va_end(ap); | |
6189 | |
4687 | 6190 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6191 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6192 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6193 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6194 |
6195 return 1; | |
6196 } | |
4269 | 6197 #endif |
2086 | 6198 |
5575 | 6199 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6200 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6201 struct proto_chat_entry *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 = _("_Group:"); |
5234 | 6205 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6206 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6207 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6208 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6209 pce->label = _("_Exchange:"); |
5234 | 6210 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6211 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6212 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6213 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6214 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6215 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6216 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6217 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6218 |
8308 | 6219 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6220 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6221 aim_conn_t *cur; |
5234 | 6222 char *name, *exchange; |
6223 | |
6224 name = g_hash_table_lookup(data, "room"); | |
6225 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6226 |
8660 | 6227 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6228 "Attempting to join chat room %s.\n", name); |
8308 | 6229 |
6230 if ((name == NULL) || (*name == '\0')) { | |
6231 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6232 return; | |
6233 } | |
6234 | |
4617 | 6235 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6236 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6237 "chatnav exists, creating room\n"); |
5234 | 6238 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6239 } else { |
6240 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6241 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6242 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6243 "chatnav does not exist, opening chatnav\n"); |
5234 | 6244 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6245 cr->name = g_strdup(name); |
4617 | 6246 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6247 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6248 } |
6249 } | |
6250 | |
8308 | 6251 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6252 OscarData *od = (OscarData *)gc->proto_data; | |
6253 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6254 |
6255 if (!ccon) | |
6256 return; | |
6257 | |
8225 | 6258 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6259 ccon->exchange, ccon->name, 0x0); |
6260 } | |
6261 | |
8308 | 6262 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6263 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6264 GSList *bcs = gc->buddy_chats; | |
5679 | 6265 GaimConversation *b = NULL; |
2086 | 6266 struct chat_connection *c = NULL; |
6267 int count = 0; | |
6268 | |
6269 while (bcs) { | |
6270 count++; | |
5679 | 6271 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6272 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6273 break; |
6274 bcs = bcs->next; | |
6275 b = NULL; | |
6276 } | |
6277 | |
6278 if (!b) | |
6279 return; | |
6280 | |
8660 | 6281 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6282 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6283 |
8308 | 6284 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6285 if (c != NULL) { |
4617 | 6286 if (od) |
6287 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6288 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6289 gaim_input_remove(c->inpa); |
8308 | 6290 if (gc && od->sess) |
4617 | 6291 aim_conn_kill(od->sess, &c->conn); |
2086 | 6292 g_free(c->name); |
6293 g_free(c->show); | |
6294 g_free(c); | |
6295 } | |
6296 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6297 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6298 } |
6299 | |
8219 | 6300 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6301 OscarData *od = (OscarData *)gc->proto_data; | |
6302 GError *err = NULL; | |
6303 GaimConversation *conv = NULL; | |
2086 | 6304 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6305 char *buf, *buf2; |
8219 | 6306 char *charset = NULL; |
6307 int encoding; | |
8907 | 6308 gsize len; |
8219 | 6309 |
6310 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6311 return -EINVAL; |
2086 | 6312 |
8219 | 6313 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6314 return -EINVAL; |
2086 | 6315 |
8219 | 6316 buf = gaim_strdup_withhtml(message); |
6317 len = strlen(buf); | |
6318 | |
8962 | 6319 if (strstr(buf, "<IMG ")) |
6320 gaim_conversation_write(conv, "", | |
6321 _("Your IM Image was not sent. " | |
6322 "You cannot send IM Images in AIM chats."), | |
6323 GAIM_MESSAGE_ERROR, time(NULL)); | |
6324 | |
8219 | 6325 encoding = oscar_encoding_check(buf); |
8233 | 6326 if (encoding & AIM_IMFLAGS_UNICODE) { |
8660 | 6327 gaim_debug_info("oscar", "Sending Unicode chat\n"); |
8219 | 6328 charset = "unicode-2-0"; |
6329 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
6330 if (err) { | |
8660 | 6331 gaim_debug_error("oscar", |
8359 | 6332 "Error converting to unicode-2-0: %s\n", err->message); |
6333 g_error_free(err); | |
6334 } | |
8219 | 6335 } else if (encoding & AIM_IMFLAGS_ISO_8859_1) { |
8660 | 6336 gaim_debug_info("oscar", "Sending ISO-8859-1 chat\n"); |
8219 | 6337 charset = "iso-8859-1"; |
6338 buf2 = g_convert(buf, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); | |
6339 if (err) { | |
8660 | 6340 gaim_debug_error("oscar", |
8359 | 6341 "Error converting to iso-8859-1: %s\n", err->message); |
8219 | 6342 g_error_free(err); |
8359 | 6343 err = NULL; |
6344 | |
8660 | 6345 gaim_debug_info("oscar", "Falling back to Unicode\n"); |
8359 | 6346 charset = "unicode-2-0"; |
6347 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
8219 | 6348 if (err) { |
8660 | 6349 gaim_debug_error("oscar", |
8359 | 6350 "Error converting to unicode-2-0: %s\n", |
6351 err->message); | |
8219 | 6352 g_error_free(err); |
6353 } | |
2086 | 6354 } |
8219 | 6355 } else { |
6356 charset = "us-ascii"; | |
6357 buf2 = g_strdup(buf); | |
6358 } | |
8359 | 6359 g_free(buf); |
6360 | |
6361 if ((len > c->maxlen) || (len > c->maxvis)) { | |
6362 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6363 return -E2BIG; |
8359 | 6364 } |
6365 | |
6366 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charset, "en"); | |
8219 | 6367 g_free(buf2); |
8359 | 6368 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6369 return 0; |
2086 | 6370 } |
6371 | |
6695 | 6372 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6373 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6374 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 6375 return "icq"; |
6376 else | |
6377 return "aim"; | |
6378 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6379 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6380 if (b != NULL && isdigit(b->name[0])) |
4687 | 6381 return "icq"; |
6382 return "aim"; | |
6383 } | |
6384 | |
6695 | 6385 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 6386 { |
7334 | 6387 GaimAccount *account = NULL; |
6388 GaimConnection *gc = NULL; | |
6389 OscarData *od = NULL; | |
4687 | 6390 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6391 int i = 0; | |
7334 | 6392 aim_userinfo_t *userinfo = NULL; |
6393 | |
6394 if (b != NULL) | |
6395 account = b->account; | |
6396 if (account != NULL) | |
6397 gc = account->gc; | |
6398 if (gc != NULL) | |
6399 od = gc->proto_data; | |
7945 | 6400 if (od != NULL) |
6401 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6402 |
5131 | 6403 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6404 char *gname; | |
7334 | 6405 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6406 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6407 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6408 emblems[i++] = "notauthorized"; | |
6409 } else { | |
6410 emblems[i++] = "offline"; | |
6411 } | |
6412 } | |
4916 | 6413 |
4766 | 6414 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 6415 int uc = b->uc >> 16; |
4766 | 6416 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6417 emblems[i++] = "invisible"; |
4766 | 6418 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6419 emblems[i++] = "freeforchat"; |
4766 | 6420 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6421 emblems[i++] = "dnd"; |
4766 | 6422 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6423 emblems[i++] = "na"; |
4766 | 6424 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6425 emblems[i++] = "occupied"; |
4766 | 6426 else if (uc & AIM_ICQ_STATE_AWAY) |
6427 emblems[i++] = "away"; | |
6428 } else { | |
6429 if (b->uc & UC_UNAVAILABLE) | |
6430 emblems[i++] = "away"; | |
6431 } | |
4687 | 6432 if (b->uc & UC_WIRELESS) |
6433 emblems[i++] = "wireless"; | |
6434 if (b->uc & UC_AOL) | |
6435 emblems[i++] = "aol"; | |
6436 if (b->uc & UC_ADMIN) | |
6437 emblems[i++] = "admin"; | |
6438 if (b->uc & UC_AB && i < 4) | |
6439 emblems[i++] = "activebuddy"; | |
4766 | 6440 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6441 emblems[i++] = "unconfirmed"; */ | |
7334 | 6442 |
7945 | 6443 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6444 emblems[i++] = "hiptop"; | |
6445 | |
6446 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6447 emblems[i++] = "secure"; |
6448 | |
4687 | 6449 *se = emblems[0]; |
6450 *sw = emblems[1]; | |
6451 *nw = emblems[2]; | |
6452 *ne = emblems[3]; | |
6453 } | |
6454 | |
6695 | 6455 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6456 GaimConnection *gc = b->account->gc; |
7283 | 6457 OscarData *od = gc->proto_data; |
7045 | 6458 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6459 GString *str = g_string_new(""); |
5131 | 6460 |
6461 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6462 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6463 |
6464 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6465 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6466 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6467 g_free(charset); |
7011 | 6468 if (away_utf8 != NULL) { |
7091 | 6469 gchar *tmp1, *tmp2; |
9627 | 6470 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6471 g_free(away_utf8); |
8571 | 6472 tmp1 = gaim_escape_html(tmp2); |
7091 | 6473 g_free(tmp2); |
8700 | 6474 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6475 g_free(tmp1); |
8701 | 6476 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6477 g_free(tmp2); |
5836 | 6478 } |
5131 | 6479 } |
8701 | 6480 } |
6481 | |
6482 return g_string_free(str, FALSE); | |
5131 | 6483 } |
6484 | |
6695 | 6485 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 6486 GaimConnection *gc = b->account->gc; |
7283 | 6487 OscarData *od = gc->proto_data; |
5167 | 6488 gchar *ret = NULL; |
6489 | |
6490 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
6491 if (isdigit(b->name[0])) | |
8701 | 6492 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6493 else |
6494 ret = g_strdup(_("Away")); | |
5836 | 6495 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6496 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 6497 if (bi->availmsg) |
6498 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 6499 } else { |
5167 | 6500 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6501 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6502 ret = g_strdup(_("Not Authorized")); | |
6503 else | |
6504 ret = g_strdup(_("Offline")); | |
6505 } | |
6506 | |
6507 return ret; | |
6508 } | |
6509 | |
5842 | 6510 |
5844 | 6511 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6512 GaimConnection *gc = sess->aux_data; |
7283 | 6513 OscarData *od = gc->proto_data; |
5892 | 6514 va_list ap; |
5842 | 6515 fu16_t type; |
5892 | 6516 fu8_t flags = 0, length = 0; |
6517 char *md5 = NULL; | |
6518 | |
7334 | 6519 |
5842 | 6520 va_start(ap, fr); |
6521 type = va_arg(ap, int); | |
5892 | 6522 |
6523 switch(type) { | |
6524 case 0x0000: | |
6525 case 0x0001: { | |
6526 flags = va_arg(ap, int); | |
6527 length = va_arg(ap, int); | |
6528 md5 = va_arg(ap, char *); | |
6529 | |
6530 if (flags == 0x41) { | |
6531 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6532 od->iconconnecting = TRUE; | |
6533 od->set_icon = TRUE; | |
6534 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6535 } else { | |
6039 | 6536 struct stat st; |
6537 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6538 if (iconfile == NULL) { | |
8363 | 6539 aim_ssi_delicon(od->sess); |
6039 | 6540 } else if (!stat(iconfile, &st)) { |
6541 char *buf = g_malloc(st.st_size); | |
6542 FILE *file = fopen(iconfile, "rb"); | |
6543 if (file) { | |
9532 | 6544 /* XXX - Use g_file_get_contents()? */ |
6039 | 6545 fread(buf, 1, st.st_size, file); |
6546 fclose(file); | |
8660 | 6547 gaim_debug_info("oscar", |
6039 | 6548 "Uploading icon to icon server\n"); |
6879 | 6549 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6550 } else |
8660 | 6551 gaim_debug_error("oscar", |
6039 | 6552 "Can't open buddy icon file!\n"); |
6553 g_free(buf); | |
6554 } else { | |
8660 | 6555 gaim_debug_error("oscar", |
6039 | 6556 "Can't stat buddy icon file!\n"); |
5892 | 6557 } |
6558 } | |
8363 | 6559 } else if (flags == 0x81) { |
6560 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6561 if (iconfile == NULL) | |
6562 aim_ssi_delicon(od->sess); | |
6563 else | |
6564 aim_ssi_seticon(od->sess, md5, length); | |
6565 } | |
5892 | 6566 } break; |
6567 | |
6568 case 0x0002: { /* We just set an "available" message? */ | |
6569 } break; | |
6570 } | |
6571 | |
5842 | 6572 va_end(ap); |
5844 | 6573 |
6574 return 0; | |
5842 | 6575 } |
5892 | 6576 |
5575 | 6577 static void oscar_set_permit_deny(GaimConnection *gc) { |
6578 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6579 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6580 #ifdef NOSSI |
8143 | 6581 GSList *list; |
4230 | 6582 char buf[MAXMSGLEN]; |
6583 int at; | |
6584 | |
5575 | 6585 switch(account->perm_deny) { |
8175 | 6586 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6587 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6588 break; |
8175 | 6589 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6590 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6591 break; |
8175 | 6592 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6593 list = account->permit; |
4230 | 6594 at = 0; |
6595 while (list) { | |
6596 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6597 list = list->next; | |
6598 } | |
6599 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6600 break; | |
8175 | 6601 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6602 list = account->deny; |
4230 | 6603 at = 0; |
6604 while (list) { | |
6605 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6606 list = list->next; | |
6607 } | |
6608 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6609 break; | |
6610 default: | |
6611 break; | |
2086 | 6612 } |
4230 | 6613 #else |
8175 | 6614 if (od->sess->ssi.received_data) { |
6615 switch (account->perm_deny) { | |
6616 case GAIM_PRIVACY_ALLOW_ALL: | |
6617 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6618 break; | |
6619 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6620 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6621 break; | |
6622 case GAIM_PRIVACY_ALLOW_USERS: | |
6623 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6624 break; | |
6625 case GAIM_PRIVACY_DENY_ALL: | |
6626 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6627 break; | |
6628 case GAIM_PRIVACY_DENY_USERS: | |
6629 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6630 break; | |
6631 default: | |
6632 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6633 break; | |
6634 } | |
6635 } | |
4230 | 6636 #endif |
2086 | 6637 } |
6638 | |
5575 | 6639 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6640 #ifdef NOSSI |
8143 | 6641 if (gc->account->perm_deny == 3) |
4269 | 6642 oscar_set_permit_deny(gc); |
6643 #else | |
7283 | 6644 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6645 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6646 if (od->sess->ssi.received_data) |
4889 | 6647 aim_ssi_addpermit(od->sess, who); |
4230 | 6648 #endif |
2086 | 6649 } |
6650 | |
5575 | 6651 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6652 #ifdef NOSSI |
8143 | 6653 if (gc->account->perm_deny == 4) |
4269 | 6654 oscar_set_permit_deny(gc); |
6655 #else | |
7283 | 6656 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6657 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6658 if (od->sess->ssi.received_data) |
4889 | 6659 aim_ssi_adddeny(od->sess, who); |
4230 | 6660 #endif |
2086 | 6661 } |
6662 | |
5575 | 6663 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6664 #ifdef NOSSI |
8143 | 6665 if (gc->account->perm_deny == 3) |
4269 | 6666 oscar_set_permit_deny(gc); |
6667 #else | |
7283 | 6668 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6669 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6670 if (od->sess->ssi.received_data) |
4889 | 6671 aim_ssi_delpermit(od->sess, who); |
4230 | 6672 #endif |
2086 | 6673 } |
6674 | |
5575 | 6675 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6676 #ifdef NOSSI |
8143 | 6677 if (gc->account->perm_deny == 4) |
4269 | 6678 oscar_set_permit_deny(gc); |
6679 #else | |
7283 | 6680 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6681 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6682 if (od->sess->ssi.received_data) |
4889 | 6683 aim_ssi_deldeny(od->sess, who); |
4230 | 6684 #endif |
2086 | 6685 } |
6686 | |
5575 | 6687 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 6688 { |
7283 | 6689 OscarData *od = gc->proto_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6690 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6691 |
8257 | 6692 if (od->icq) { |
6693 m = g_list_append(m, _("Online")); | |
6694 m = g_list_append(m, _("Away")); | |
6695 m = g_list_append(m, _("Do Not Disturb")); | |
6696 m = g_list_append(m, _("Not Available")); | |
6697 m = g_list_append(m, _("Occupied")); | |
6698 m = g_list_append(m, _("Free For Chat")); | |
6699 m = g_list_append(m, _("Invisible")); | |
6700 } else { | |
6701 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6702 m = g_list_append(m, _("Back")); |
8257 | 6703 m = g_list_append(m, _("Visible")); |
6704 m = g_list_append(m, _("Invisible")); | |
6705 } | |
4333 | 6706 |
6707 return m; | |
6708 } | |
6709 | |
7172 | 6710 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6711 GaimConnection *gc = data->gc; |
6712 OscarData *od = gc->proto_data; | |
7172 | 6713 GaimBuddy *b; |
6714 GaimGroup *g; | |
6715 | |
6716 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6717 oscar_free_name_data(data); | |
6718 return; | |
6719 } | |
6720 | |
6721 if (!(g = gaim_find_buddys_group(b))) { | |
6722 oscar_free_name_data(data); | |
6723 return; | |
6724 } | |
6725 | |
6726 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6727 |
6728 if (!aim_sncmp(data->name, gc->account->username)) | |
6729 gaim_check_comment(od, text); | |
6730 | |
7172 | 6731 oscar_free_name_data(data); |
6732 } | |
6733 | |
9030 | 6734 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6735 | |
6736 GaimBuddy *buddy; | |
6737 GaimConnection *gc; | |
6738 OscarData *od; | |
6739 struct name_data *data; | |
7172 | 6740 GaimGroup *g; |
6741 char *comment; | |
6742 gchar *comment_utf8; | |
9631 | 6743 gchar *title; |
7172 | 6744 |
9030 | 6745 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6746 | |
6747 buddy = (GaimBuddy *) node; | |
6748 gc = gaim_account_get_connection(buddy->account); | |
6749 od = gc->proto_data; | |
6750 | |
6751 data = g_new(struct name_data, 1); | |
6752 | |
6753 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6754 return; |
9030 | 6755 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6756 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6757 | |
6758 data->gc = gc; | |
9030 | 6759 data->name = g_strdup(buddy->name); |
7172 | 6760 data->nick = NULL; |
6761 | |
9631 | 6762 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6763 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6764 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6765 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6766 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6767 data); | |
9631 | 6768 g_free(title); |
7172 | 6769 |
6770 free(comment); | |
6771 g_free(comment_utf8); | |
6772 } | |
6773 | |
9030 | 6774 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6775 | |
6776 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6777 OscarData *od = gc->proto_data; |
9030 | 6778 |
4333 | 6779 GList *m = NULL; |
9030 | 6780 GaimBlistNodeAction *act; |
6781 | |
6782 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6783 oscar_buddycb_edit_comment, NULL); | |
6784 m = g_list_append(m, act); | |
7172 | 6785 |
4333 | 6786 if (od->icq) { |
4624 | 6787 #if 0 |
9030 | 6788 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6789 oscar_get_icqstatusmsg, NULL); | |
6790 m = g_list_append(m, act); | |
4624 | 6791 #endif |
4333 | 6792 } else { |
7011 | 6793 aim_userinfo_t *userinfo; |
9030 | 6794 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6795 | |
6796 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
6797 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
6798 | |
7011 | 6799 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 6800 act = gaim_blist_node_action_new(_("Direct IM"), |
6801 oscar_ask_direct_im, NULL); | |
6802 m = g_list_append(m, act); | |
5917 | 6803 } |
9466 | 6804 #if 0 |
7011 | 6805 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6806 act = gaim_blist_node_action_new(_("Get File"), |
6807 oscar_ask_getfile, NULL); | |
6808 m = g_list_append(m, act); | |
5917 | 6809 } |
4826 | 6810 #endif |
4333 | 6811 } |
5131 | 6812 } |
5197 | 6813 |
5131 | 6814 if (od->sess->ssi.received_data) { |
9030 | 6815 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6816 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
6817 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
6818 gaim_auth_sendrequest_menu, NULL); | |
6819 m = g_list_append(m, act); | |
4333 | 6820 } |
4916 | 6821 } |
6822 | |
4333 | 6823 return m; |
6824 } | |
6825 | |
9030 | 6826 |
6827 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6828 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6829 return oscar_buddy_menu((GaimBuddy *) node); | |
6830 } else { | |
6831 return NULL; | |
6832 } | |
6833 } | |
6834 | |
6835 | |
5575 | 6836 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6837 OscarData *od = gc->proto_data; |
5575 | 6838 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6839 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6840 od->setnick = TRUE; | |
6841 od->newsn = g_strdup(nick); | |
6842 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6843 } else { | |
6844 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6845 } | |
6846 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6847 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6848 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6849 } |
6850 } | |
6851 | |
9015 | 6852 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 6853 { |
9015 | 6854 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 6855 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 6856 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6857 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6858 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6859 gc); |
4333 | 6860 } |
6861 | |
9015 | 6862 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 6863 { |
9015 | 6864 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6865 OscarData *od = gc->proto_data; |
4333 | 6866 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6867 | |
6868 if (conn) { | |
6869 aim_admin_reqconfirm(od->sess, conn); | |
6870 } else { | |
6871 od->conf = TRUE; | |
6872 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6873 } | |
6874 } | |
6875 | |
9015 | 6876 static void oscar_show_email(GaimPluginAction *action) |
4333 | 6877 { |
9015 | 6878 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6879 OscarData *od = gc->proto_data; |
4333 | 6880 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6881 | |
6882 if (conn) { | |
6883 aim_admin_getinfo(od->sess, conn, 0x11); | |
6884 } else { | |
6885 od->reqemail = TRUE; | |
6886 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6887 } | |
6888 } | |
6889 | |
5575 | 6890 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6891 { |
7283 | 6892 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6893 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
|
6894 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6895 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6896 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6897 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6898 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6899 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6900 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6901 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6902 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6903 |
9015 | 6904 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 6905 { |
9015 | 6906 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6907 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 6908 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6909 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6910 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6911 gc); |
4333 | 6912 } |
6913 | |
9015 | 6914 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 6915 { |
9015 | 6916 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6917 OscarData *od = gc->proto_data; |
4333 | 6918 gchar *nombre, *text, *tmp; |
6695 | 6919 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 6920 int num=0; |
6921 | |
6873 | 6922 text = g_strdup(""); |
4333 | 6923 |
4785 | 6924 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 6925 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 6926 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
6927 continue; | |
6695 | 6928 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
6929 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 6930 continue; |
6695 | 6931 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
6932 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
6933 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6934 continue; | |
6935 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 6936 if (gaim_buddy_get_alias_only(buddy)) |
6937 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 6938 else |
6939 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 6940 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 6941 g_free(text); |
6942 text = tmp; | |
6943 g_free(nombre); | |
6944 num++; | |
6945 } | |
4333 | 6946 } |
2979 | 6947 } |
4333 | 6948 } |
6949 | |
6950 if (!num) { | |
6951 g_free(text); | |
6873 | 6952 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
6953 } | |
6954 | |
6955 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
6956 "the following buddies"), _("You can re-request " | |
6957 "authorization from these buddies by " | |
6958 "right-clicking on them and selecting " | |
6959 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 6960 g_free(text); |
2979 | 6961 } |
6962 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6963 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6964 { |
8950 | 6965 OscarData *od = (OscarData *)gc->proto_data; |
6966 | |
6967 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6968 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6969 |
9015 | 6970 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6971 { |
9015 | 6972 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6973 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6974 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6975 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6976 "searching for."), |
8697 | 6977 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6978 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6979 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6980 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6981 |
7366 | 6982 #if 0 |
5917 | 6983 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 6984 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 6985 |
7334 | 6986 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 6987 aim_srv_setavailmsg(od->sess, text); |
6988 } | |
6989 | |
6990 static void oscar_show_setavailmsg(GaimConnection *gc) | |
6991 { | |
7313 | 6992 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
6993 _("I'm doing work and hoping for a distraction--IM me!"), | |
8697 | 6994 TRUE, FALSE, NULL, |
5917 | 6995 _("OK"), G_CALLBACK(oscar_setavailmsg), |
6996 _("Cancel"), NULL, | |
6997 gc); | |
6998 } | |
7366 | 6999 #endif |
5917 | 7000 |
9015 | 7001 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7002 { |
9015 | 7003 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7004 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7005 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7006 |
9015 | 7007 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7008 { |
9015 | 7009 GaimConnection *gc = (GaimConnection *) action->context; |
8576 | 7010 gaim_notify_uri(gc, "http://web.icq.com/whitepages/login/1,,,00.html"); |
7011 } | |
7012 | |
9015 | 7013 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7014 { |
9015 | 7015 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7016 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7017 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7018 |
9015 | 7019 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7020 { |
9015 | 7021 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7022 OscarData *od = gc->proto_data; |
5575 | 7023 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
|
7024 gaim_notify_uri(gc, substituted); |
5517 | 7025 g_free(substituted); |
4333 | 7026 } |
7027 | |
9015 | 7028 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7029 { |
9015 | 7030 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7031 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7032 } | |
7033 | |
5842 | 7034 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7035 { | |
7283 | 7036 OscarData *od = gc->proto_data; |
5844 | 7037 aim_session_t *sess = od->sess; |
5842 | 7038 FILE *file; |
7039 struct stat st; | |
5844 | 7040 |
6039 | 7041 if (iconfile == NULL) { |
8363 | 7042 aim_ssi_delicon(od->sess); |
6039 | 7043 } else if (!stat(iconfile, &st)) { |
5842 | 7044 char *buf = g_malloc(st.st_size); |
7045 file = fopen(iconfile, "rb"); | |
7046 if (file) { | |
6052 | 7047 md5_state_t *state; |
6039 | 7048 char md5[16]; |
9532 | 7049 /* XXX - Use g_file_get_contents()? */ |
5842 | 7050 int len = fread(buf, 1, st.st_size, file); |
6039 | 7051 fclose(file); |
6052 | 7052 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7053 md5_init(state); |
7054 md5_append(state, buf, len); | |
7055 md5_finish(state, md5); | |
7056 g_free(state); | |
7057 aim_ssi_seticon(sess, md5, 16); | |
7058 } else | |
8660 | 7059 gaim_debug_error("oscar", |
5842 | 7060 "Can't open buddy icon file!\n"); |
7061 g_free(buf); | |
7062 } else | |
8660 | 7063 gaim_debug_error("oscar", |
5842 | 7064 "Can't stat buddy icon file!\n"); |
7065 } | |
7066 | |
7067 | |
9015 | 7068 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7069 { |
9015 | 7070 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7071 OscarData *od = gc->proto_data; |
4333 | 7072 GList *m = NULL; |
9015 | 7073 GaimPluginAction *act; |
7074 | |
7075 act = gaim_plugin_action_new(_("Set User Info..."), | |
7076 oscar_show_set_info); | |
7077 m = g_list_append(m, act); | |
4333 | 7078 |
8576 | 7079 if (od->icq) { |
9015 | 7080 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7081 oscar_show_set_info_icqurl); | |
7082 m = g_list_append(m, act); | |
8576 | 7083 } |
7084 | |
7366 | 7085 #if 0 |
9015 | 7086 act = gaim_plugin_action_new(_("Set Available Message..."), |
7087 oscar_show_setavailmsg); | |
7088 m = g_list_append(m, act); | |
7366 | 7089 #endif |
5917 | 7090 |
9015 | 7091 act = gaim_plugin_action_new(_("Change Password..."), |
7092 oscar_change_pass); | |
7093 m = g_list_append(m, act); | |
4617 | 7094 |
7095 if (od->sess->authinfo->chpassurl) { | |
9015 | 7096 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7097 oscar_show_chpassurl); | |
7098 m = g_list_append(m, act); | |
7099 | |
7100 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7101 oscar_show_imforwardingurl); | |
7102 m = g_list_append(m, act); | |
7026 | 7103 } |
7104 | |
5238 | 7105 if (!od->icq) { |
4617 | 7106 /* AIM actions */ |
7107 m = g_list_append(m, NULL); | |
4333 | 7108 |
9015 | 7109 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7110 oscar_show_format_screenname); | |
7111 m = g_list_append(m, act); | |
7112 | |
7113 act = gaim_plugin_action_new(_("Confirm Account"), | |
7114 oscar_confirm_account); | |
7115 m = g_list_append(m, act); | |
7116 | |
7117 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7118 oscar_show_email); | |
7119 m = g_list_append(m, act); | |
7120 | |
7121 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7122 oscar_show_change_email); | |
7123 m = g_list_append(m, act); | |
2086 | 7124 } |
4333 | 7125 |
7126 m = g_list_append(m, NULL); | |
7127 | |
9015 | 7128 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7129 oscar_show_awaitingauth); | |
7130 m = g_list_append(m, act); | |
4333 | 7131 |
2086 | 7132 m = g_list_append(m, NULL); |
4333 | 7133 |
9015 | 7134 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7135 oscar_show_find_email); | |
7136 m = g_list_append(m, act); | |
4333 | 7137 |
8591 | 7138 #if 0 |
9015 | 7139 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7140 show_find_info); | |
7141 m = g_list_append(m, act); | |
8591 | 7142 #endif |
2086 | 7143 |
7144 return m; | |
7145 } | |
7146 | |
5575 | 7147 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7148 { |
7283 | 7149 OscarData *od = gc->proto_data; |
4617 | 7150 |
7151 if (od->icq) { | |
7152 aim_icq_changepasswd(od->sess, new); | |
2086 | 7153 } else { |
4617 | 7154 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7155 if (conn) { | |
7156 aim_admin_changepasswd(od->sess, conn, new, old); | |
7157 } else { | |
7158 od->chpass = TRUE; | |
7159 od->oldp = g_strdup(old); | |
7160 od->newp = g_strdup(new); | |
7161 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7162 } | |
2086 | 7163 } |
7164 } | |
7165 | |
6059 | 7166 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7167 { |
7283 | 7168 OscarData *od = gc->proto_data; |
8971 | 7169 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
|
7170 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7171 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7172 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7173 |
8971 | 7174 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7175 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7176 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7177 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7178 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7179 GAIM_PRPL_API_VERSION, |
9308 | 7180 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7181 NULL, /* user_splits */ |
7182 NULL, /* protocol_options */ | |
7183 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7184 oscar_list_icon, /* list_icon */ | |
7185 oscar_list_emblems, /* list_emblems */ | |
7186 oscar_status_text, /* status_text */ | |
7187 oscar_tooltip_text, /* tooltip_text */ | |
7188 oscar_away_states, /* away_states */ | |
7189 oscar_blist_node_menu, /* blist_node_menu */ | |
7190 oscar_chat_info, /* chat_info */ | |
7191 oscar_login, /* login */ | |
7192 oscar_close, /* close */ | |
7193 oscar_send_im, /* send_im */ | |
7194 oscar_set_info, /* set_info */ | |
7195 oscar_send_typing, /* send_typing */ | |
7196 oscar_get_info, /* get_info */ | |
7197 oscar_set_away, /* set_away */ | |
7198 oscar_set_idle, /* set_idle */ | |
7199 oscar_change_passwd, /* change_passwd */ | |
7200 oscar_add_buddy, /* add_buddy */ | |
7201 oscar_add_buddies, /* add_buddies */ | |
7202 oscar_remove_buddy, /* remove_buddy */ | |
7203 oscar_remove_buddies, /* remove_buddies */ | |
7204 oscar_add_permit, /* add_permit */ | |
7205 oscar_add_deny, /* add_deny */ | |
7206 oscar_rem_permit, /* rem_permit */ | |
7207 oscar_rem_deny, /* rem_deny */ | |
7208 oscar_set_permit_deny, /* set_permit_deny */ | |
7209 oscar_warn, /* warn */ | |
7210 oscar_join_chat, /* join_chat */ | |
7211 NULL, /* reject_chat */ | |
7212 oscar_chat_invite, /* chat_invite */ | |
7213 oscar_chat_leave, /* chat_leave */ | |
7214 NULL, /* chat_whisper */ | |
7215 oscar_send_chat, /* chat_send */ | |
7216 oscar_keepalive, /* keepalive */ | |
7217 NULL, /* register_user */ | |
7218 NULL, /* get_cb_info */ | |
7219 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7220 #ifndef NOSSI |
9475 | 7221 oscar_alias_buddy, /* alias_buddy */ |
7222 oscar_move_buddy, /* group_buddy */ | |
7223 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7224 #else |
9475 | 7225 NULL, /* alias_buddy */ |
7226 NULL, /* group_buddy */ | |
7227 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7228 #endif |
9475 | 7229 NULL, /* buddy_free */ |
7230 oscar_convo_closed, /* convo_closed */ | |
7231 NULL, /* normalize */ | |
7232 oscar_set_icon, /* set_buddy_icon */ | |
7233 NULL, /* remove_group */ | |
7234 NULL, /* get_cb_real_name */ | |
7235 NULL, /* set_chat_topic */ | |
7236 NULL, /* find_blist_chat */ | |
7237 NULL, /* roomlist_get_list */ | |
7238 NULL, /* roomlist_cancel */ | |
7239 NULL, /* roomlist_expand_category */ | |
7240 oscar_can_receive_file, /* can_receive_file */ | |
7241 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7242 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7243 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7244 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7245 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7246 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7247 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7248 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7249 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7250 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7251 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7252 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7253 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7254 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7255 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7256 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7257 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7258 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7259 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7260 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7261 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7262 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7263 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7264 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7265 NULL, /**< destroy */ |
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, /**< ui_info */ |
8993 | 7268 &prpl_info, /**< extra_info */ |
7269 NULL, | |
9015 | 7270 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7271 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7272 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7273 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7274 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7275 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7276 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7277 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7278 option = gaim_account_option_string_new(_("Auth host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7279 "login.oscar.aol.com"); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7280 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7281 option); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7282 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7283 option = gaim_account_option_int_new(_("Auth port"), "port", 5190); |
5638
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); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7286 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7287 my_protocol = plugin; |
2086 | 7288 } |
7289 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7290 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |