Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 9639:58625ebfe03a
[gaim-migrate @ 10487]
This is completely untested. Sean is going to test it for me.
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Mon, 02 Aug 2004 02:16:47 +0000 |
parents | 201c8fe4cee3 |
children | b8aee06adc83 |
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 */ |
3509 /* I think this timestamp is in UTC, or something */ | |
8514 | 3510 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3511 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3512 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3513 } |
3514 g_free(uin); | |
8493 | 3515 g_free(tmp); |
4075 | 3516 } |
3316 | 3517 } break; |
3518 | |
4173 | 3519 case 0x04: { /* Someone sent you a URL */ |
4076 | 3520 if (i >= 2) { |
7385 | 3521 if (msg2[1] != NULL) { |
3522 gchar *uin = g_strdup_printf("%u", args->uin); | |
3523 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3524 msg2[1], | |
3525 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3526 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3527 g_free(uin); | |
3528 g_free(message); | |
3529 } | |
3453 | 3530 } |
3531 } break; | |
3532 | |
4173 | 3533 case 0x06: { /* Someone requested authorization */ |
4076 | 3534 if (i >= 6) { |
4230 | 3535 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3536 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 | 3537 gaim_debug_info("oscar", |
5556 | 3538 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3539 args->uin); |
4076 | 3540 data->gc = gc; |
5556 | 3541 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3542 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3543 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3544 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3545 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3546 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3547 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3548 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3549 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3550 g_free(dialog_msg); |
3551 } | |
3141 | 3552 } break; |
3553 | |
4173 | 3554 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3555 if (i >= 1) { |
7023 | 3556 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
|
3557 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3558 dialog_msg); |
4076 | 3559 g_free(dialog_msg); |
3560 } | |
3141 | 3561 } break; |
3562 | |
4173 | 3563 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3564 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
|
3565 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3566 dialog_msg); |
3141 | 3567 g_free(dialog_msg); |
3568 } break; | |
3569 | |
4333 | 3570 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3571 if (i >= 5) { | |
3572 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
|
3573 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3574 g_free(dialog_msg); |
3575 } | |
3576 } break; | |
3577 | |
4173 | 3578 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3579 if (i >= 6) { |
4194 | 3580 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
|
3581 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3582 g_free(dialog_msg); |
3583 } | |
4075 | 3584 } break; |
3585 | |
4173 | 3586 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3587 if (i >= 6) { |
4308 | 3588 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
|
3589 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3590 g_free(dialog_msg); |
3591 } | |
4075 | 3592 } break; |
3593 | |
4173 | 3594 case 0x12: { |
3141 | 3595 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3596 /* Someone added you to their buddy list? */ |
3141 | 3597 } break; |
3598 | |
7023 | 3599 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3600 guint i, num; |
3453 | 3601 gchar **text; |
4173 | 3602 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3603 if (text) { |
3604 num = 0; | |
3605 for (i=0; i<strlen(text[0]); i++) | |
3606 num = num*10 + text[0][i]-48; | |
3607 for (i=0; i<num; i++) { | |
4230 | 3608 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3609 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 | 3610 data->gc = gc; |
4790 | 3611 data->name = g_strdup(text[i*2+1]); |
3612 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3613 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3614 gaim_request_action(gc, NULL, message, |
7023 | 3615 _("Do you want to add this buddy " |
3616 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3617 0, data, 2, |
7023 | 3618 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3619 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3620 g_free(message); |
3621 } | |
3622 g_strfreev(text); | |
3623 } | |
3624 } break; | |
3625 | |
7023 | 3626 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3627 /* This is boring and silly. */ |
3628 } break; | |
3629 | |
3141 | 3630 default: { |
8660 | 3631 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3632 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3633 "(type 0x%02hhx).\n", args->type); |
3141 | 3634 } break; |
3635 } | |
3636 | |
4076 | 3637 g_strfreev(msg1); |
3638 g_strfreev(msg2); | |
3639 | |
3141 | 3640 return 1; |
3641 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3642 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3643 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3644 fu16_t channel; |
3645 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3646 aim_userinfo_t *userinfo; |
2086 | 3647 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3648 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3649 va_start(ap, fr); |
4200 | 3650 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3651 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3652 |
3141 | 3653 switch (channel) { |
3654 case 1: { /* standard message */ | |
3655 struct aim_incomingim_ch1_args *args; | |
3656 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3657 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3658 } break; | |
3659 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3660 case 2: { /* rendezvous */ |
3141 | 3661 struct aim_incomingim_ch2_args *args; |
3662 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3663 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3664 } break; | |
3665 | |
3666 case 4: { /* ICQ */ | |
3667 struct aim_incomingim_ch4_args *args; | |
3668 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3669 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3670 } break; |
3671 | |
3672 default: { | |
8660 | 3673 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3674 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3675 "0x%04hx).", channel); |
3141 | 3676 } break; |
2086 | 3677 } |
3678 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3679 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3680 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3681 return ret; |
2086 | 3682 } |
3683 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3684 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3685 GaimConnection *gc = sess->aux_data; |
3686 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3687 char *buf; |
2086 | 3688 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3689 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3690 aim_userinfo_t *userinfo; |
2086 | 3691 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3692 va_start(ap, fr); |
4200 | 3693 chan = (fu16_t)va_arg(ap, unsigned int); |
3694 userinfo = va_arg(ap, aim_userinfo_t *); | |
3695 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3696 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3697 va_end(ap); |
3698 | |
3699 switch(reason) { | |
5420 | 3700 case 0: /* Invalid (0) */ |
3701 buf = g_strdup_printf( | |
3702 ngettext( | |
4276 | 3703 "You missed %hu message from %s because it was invalid.", |
3704 "You missed %hu messages from %s because they were invalid.", | |
3705 nummissed), | |
4282 | 3706 nummissed, |
3707 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3708 break; |
5420 | 3709 case 1: /* Message too large */ |
3710 buf = g_strdup_printf( | |
3711 ngettext( | |
4276 | 3712 "You missed %hu message from %s because it was too large.", |
3713 "You missed %hu messages from %s because they were too large.", | |
3714 nummissed), | |
4282 | 3715 nummissed, |
3716 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3717 break; |
5420 | 3718 case 2: /* Rate exceeded */ |
3719 buf = g_strdup_printf( | |
3720 ngettext( | |
4276 | 3721 "You missed %hu message from %s because the rate limit has been exceeded.", |
3722 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3723 nummissed), | |
4282 | 3724 nummissed, |
3725 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3726 break; |
5420 | 3727 case 3: /* Evil Sender */ |
3728 buf = g_strdup_printf( | |
3729 ngettext( | |
4276 | 3730 "You missed %hu message from %s because he/she was too evil.", |
3731 "You missed %hu messages from %s because he/she was too evil.", | |
3732 nummissed), | |
4282 | 3733 nummissed, |
3734 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3735 break; |
5420 | 3736 case 4: /* Evil Receiver */ |
3737 buf = g_strdup_printf( | |
3738 ngettext( | |
4276 | 3739 "You missed %hu message from %s because you are too evil.", |
3740 "You missed %hu messages from %s because you are too evil.", | |
3741 nummissed), | |
4282 | 3742 nummissed, |
3743 userinfo->sn); | |
2086 | 3744 break; |
3745 default: | |
5420 | 3746 buf = g_strdup_printf( |
3747 ngettext( | |
4276 | 3748 "You missed %hu message from %s for an unknown reason.", |
3749 "You missed %hu messages from %s for an unknown reason.", | |
3750 nummissed), | |
4282 | 3751 nummissed, |
3752 userinfo->sn); | |
2086 | 3753 break; |
3754 } | |
8733 | 3755 |
9627 | 3756 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3757 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3758 g_free(buf); |
2086 | 3759 |
3760 return 1; | |
3761 } | |
3762 | |
4194 | 3763 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3764 GaimConnection *gc = sess->aux_data; |
7283 | 3765 OscarData *od = gc->proto_data; |
4617 | 3766 |
3767 /* BBB */ | |
3630 | 3768 switch (reason) { |
4151 | 3769 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3770 GaimXfer *xfer; |
8971 | 3771 struct oscar_direct_im *dim; |
3772 | |
8660 | 3773 gaim_debug_info("oscar", |
9070 | 3774 "AAA - Other user declined some sort of direct " |
8971 | 3775 "connect attempt (automaticly?)\n"); |
4617 | 3776 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
|
3777 gaim_xfer_cancel_remote(xfer); |
8971 | 3778 else if ((dim = oscar_direct_im_find(od, who))) { |
3779 /* AAA should use find by cookie or something here */ | |
3780 oscar_direct_im_disconnect(od, dim); | |
3781 } | |
4151 | 3782 } break; |
3783 | |
3784 default: { | |
8660 | 3785 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3786 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3787 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3788 } |
3630 | 3789 |
3790 } | |
3791 | |
3792 return 0; | |
3793 } | |
3794 | |
4194 | 3795 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3796 GaimConnection *gc = sess->aux_data; |
4151 | 3797 |
3798 switch(reason) { | |
3799 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3800 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3801 | |
3802 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3803 |
3804 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3805 statusmsg = oscar_icqstatus(state); |
4151 | 3806 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3807 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3808 g_free(statusmsg); | |
4151 | 3809 g_strfreev(splitmsg); |
9244 | 3810 |
3811 gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); | |
3812 | |
3813 g_free(title); | |
3814 g_free(dialogmsg); | |
4151 | 3815 } break; |
3816 | |
3817 default: { | |
8660 | 3818 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3819 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3820 "Type 0x%04hx\n", who, reason); |
4151 | 3821 } break; |
3822 } /* end of switch */ | |
3823 | |
3824 return 0; | |
3825 } | |
3826 | |
3212 | 3827 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
3828 va_list ap; | |
3829 fu16_t chan, reason; | |
3830 char *who; | |
3831 | |
3832 va_start(ap, fr); | |
4200 | 3833 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3834 who = va_arg(ap, char *); |
4200 | 3835 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3836 |
3952 | 3837 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 3838 char *cookie = va_arg(ap, char *); |
4151 | 3839 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 3840 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 3841 fu32_t state = 0; |
4151 | 3842 char *msg = NULL; |
3843 if (reason == 0x0003) { | |
4200 | 3844 state = va_arg(ap, fu32_t); |
4151 | 3845 msg = va_arg(ap, char *); |
3846 } | |
3847 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
3848 } | |
3952 | 3849 |
3212 | 3850 va_end(ap); |
3851 | |
3852 return 1; | |
3853 } | |
3854 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3855 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3856 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3857 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3858 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3859 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3860 va_start(ap, fr); |
4199 | 3861 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3862 va_end(ap); |
3863 | |
8660 | 3864 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3865 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3866 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 3867 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3868 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 3869 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3870 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3871 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3872 |
2086 | 3873 return 1; |
3874 } | |
3875 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3876 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 3877 GaimConnection *gc = sess->aux_data; |
4617 | 3878 #if 0 |
7283 | 3879 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3880 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3881 #endif |
4617 | 3882 va_list ap; |
3883 fu16_t reason; | |
3884 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3885 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3886 va_start(ap, fr); |
4617 | 3887 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 3888 data = va_arg(ap, char *); |
2086 | 3889 va_end(ap); |
3890 | |
8660 | 3891 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3892 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 3893 |
3894 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3895 #if 0 |
4617 | 3896 /* If this was a file transfer request, data is a cookie */ |
3897 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
|
3898 gaim_xfer_cancel_remote(xfer); |
3630 | 3899 return 1; |
3900 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3901 #endif |
3630 | 3902 |
4617 | 3903 /* Data is assumed to be the destination sn */ |
9627 | 3904 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), |
3905 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Your message did not get sent."))) { | |
3906 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); | |
3907 gaim_notify_error(sess->aux_data, NULL, buf, | |
3908 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3909 g_free(buf); | |
3910 } | |
2086 | 3911 return 1; |
3912 } | |
3913 | |
3595 | 3914 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3915 GaimConnection *gc = sess->aux_data; |
3595 | 3916 va_list ap; |
3917 fu16_t type1, type2; | |
3918 char *sn; | |
3919 | |
3920 va_start(ap, fr); | |
4199 | 3921 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3922 sn = va_arg(ap, char *); |
4199 | 3923 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3924 va_end(ap); |
3925 | |
3926 switch (type2) { | |
3927 case 0x0000: { /* Text has been cleared */ | |
3928 serv_got_typing_stopped(gc, sn); | |
3929 } break; | |
3930 | |
3931 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3932 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 3933 } break; |
3934 | |
3935 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3936 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 3937 } break; |
3938 | |
3939 default: { | |
8660 | 3940 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 | 3941 } break; |
3942 } | |
3943 | |
3944 return 1; | |
3945 } | |
3946 | |
7141 | 3947 /* |
3948 * We get this error when there was an error in the locate family. This | |
7259 | 3949 * happens when you request info of someone who is offline. |
7141 | 3950 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3951 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 3952 gchar *buf, *cbuf; |
2086 | 3953 va_list ap; |
5420 | 3954 fu16_t reason; |
2086 | 3955 char *destn; |
3956 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3957 va_start(ap, fr); |
4199 | 3958 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3959 destn = va_arg(ap, char *); |
3960 va_end(ap); | |
3961 | |
7781 | 3962 if (destn == NULL) |
7793 | 3963 return 1; |
9627 | 3964 |
3965 cbuf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3966 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), cbuf)) { | |
3967 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); | |
3968 gaim_notify_error(sess->aux_data, NULL, buf, | |
3969 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3970 g_free(buf); | |
3971 } | |
3972 g_free(cbuf); | |
2086 | 3973 |
3974 return 1; | |
3975 } | |
3976 | |
7011 | 3977 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3978 GaimConnection *gc = sess->aux_data; |
8700 | 3979 GaimAccount *account = gaim_connection_get_account(gc); |
3980 GString *str; | |
9244 | 3981 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 3982 va_list ap; |
7011 | 3983 aim_userinfo_t *userinfo; |
2086 | 3984 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3985 va_start(ap, fr); |
7011 | 3986 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3987 va_end(ap); |
3988 | |
8700 | 3989 str = g_string_new(""); |
3990 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
3991 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 3992 |
3993 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 3994 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 3995 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 3996 |
3997 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 3998 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 3999 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 4000 |
4001 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4002 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4003 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4004 g_free(tmp); |
4005 } | |
4006 | |
8701 | 4007 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4008 |
4009 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4010 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4011 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4012 g_free(tmp); | |
7011 | 4013 if (away_utf8 != NULL) { |
8700 | 4014 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4015 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4016 } |
7011 | 4017 } |
4018 | |
4019 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4020 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4021 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4022 g_free(tmp); | |
7011 | 4023 if (info_utf8 != NULL) { |
8700 | 4024 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4025 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4026 } |
7011 | 4027 } |
4028 | |
8701 | 4029 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4030 g_string_free(str, TRUE); |
9244 | 4031 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
4032 gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, tmp, NULL, NULL); | |
4033 g_free(title); | |
8700 | 4034 g_free(tmp); |
4151 | 4035 |
2086 | 4036 return 1; |
4037 } | |
4038 | |
8341 | 4039 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4040 { | |
4041 aim_session_t *sess = data; | |
4042 GaimConnection *gc = sess->aux_data; | |
4043 OscarData *od = (OscarData *)gc->proto_data; | |
4044 | |
4045 aim_locate_dorequest(data); | |
4046 od->getinfotimer = 0; | |
4047 | |
4048 return FALSE; | |
4049 } | |
4050 | |
4051 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4052 { | |
4053 GaimConnection *gc = sess->aux_data; | |
4054 OscarData *od = (OscarData *)gc->proto_data; | |
4055 | |
4056 /* | |
4057 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4058 * us from hitting the rate limit due to request away messages and info | |
4059 * too quickly. | |
4060 */ | |
4061 if (od->getinfotimer == 0) | |
4062 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4063 | |
4064 return 1; | |
4065 } | |
4066 | |
4067 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4068 { | |
2086 | 4069 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4070 fu16_t id; |
2086 | 4071 va_list ap; |
4072 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4073 va_start(ap, fr); |
4199 | 4074 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4075 msg = va_arg(ap, char *); |
4076 va_end(ap); | |
4077 | |
8660 | 4078 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4079 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4080 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4081 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4082 _("Your AIM connection may be lost."), NULL); |
2086 | 4083 |
4084 return 1; | |
4085 } | |
4086 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4087 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4088 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4089 fu16_t type; |
5575 | 4090 GaimConnection *gc = sess->aux_data; |
7283 | 4091 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4092 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4093 va_start(ap, fr); |
4199 | 4094 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4095 |
4096 switch(type) { | |
4097 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4098 fu8_t maxrooms; |
2086 | 4099 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4100 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4101 |
4199 | 4102 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4103 exchangecount = va_arg(ap, int); |
4104 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4105 | |
8660 | 4106 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4107 "chat info: Chat Rights:\n"); |
8660 | 4108 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4109 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4110 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4111 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4112 for (i = 0; i < exchangecount; i++) |
8660 | 4113 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4114 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4115 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4116 while (od->create_rooms) { |
4117 struct create_room *cr = od->create_rooms->data; | |
8660 | 4118 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4119 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4120 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4121 g_free(cr->name); |
4617 | 4122 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4123 g_free(cr); |
2086 | 4124 } |
4125 } | |
4126 break; | |
4127 case 0x0008: { | |
4128 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4129 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4130 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4131 fu32_t createtime; |
2086 | 4132 |
4133 fqcn = va_arg(ap, char *); | |
4200 | 4134 instance = (fu16_t)va_arg(ap, unsigned int); |
4135 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4136 flags = (fu16_t)va_arg(ap, unsigned int); | |
4137 createtime = va_arg(ap, fu32_t); | |
4138 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4139 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4140 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4141 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4142 name = va_arg(ap, char *); | |
4143 ck = va_arg(ap, char *); | |
4194 | 4144 |
8660 | 4145 gaim_debug_misc("oscar", |
5556 | 4146 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4147 fqcn, |
4148 exchange, instance, flags, | |
4149 createtime, | |
4150 maxmsglen, maxoccupancy, createperms, unknown, | |
4151 name, ck); | |
4617 | 4152 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4153 } |
4154 break; | |
4155 default: | |
8660 | 4156 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4157 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4158 break; |
4159 } | |
4194 | 4160 |
4161 va_end(ap); | |
4162 | |
2086 | 4163 return 1; |
4164 } | |
4165 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4166 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4167 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4168 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4169 aim_userinfo_t *info; |
5575 | 4170 GaimConnection *g = sess->aux_data; |
2086 | 4171 |
4172 struct chat_connection *c = NULL; | |
4173 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4174 va_start(ap, fr); |
2086 | 4175 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4176 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4177 va_end(ap); |
4178 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4179 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4180 if (!c) |
4181 return 1; | |
4182 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4183 for (i = 0; i < count; i++) |
9554 | 4184 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE); |
2086 | 4185 |
4186 return 1; | |
4187 } | |
4188 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4189 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4190 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4191 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4192 aim_userinfo_t *info; |
5575 | 4193 GaimConnection *g = sess->aux_data; |
2086 | 4194 |
4195 struct chat_connection *c = NULL; | |
4196 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4197 va_start(ap, fr); |
2086 | 4198 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4199 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4200 va_end(ap); |
4201 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4202 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4203 if (!c) |
4204 return 1; | |
4205 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4206 for (i = 0; i < count; i++) |
8733 | 4207 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4208 |
4209 return 1; | |
4210 } | |
4211 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4212 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
|
4213 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4214 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4215 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4216 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4217 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4218 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4219 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4220 fu32_t creationtime; |
5575 | 4221 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4222 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
|
4223 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4224 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4225 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4226 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4227 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4228 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4229 roomdesc = va_arg(ap, char *); |
4200 | 4230 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4231 creationtime = va_arg(ap, fu32_t); | |
4232 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4233 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4234 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4235 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4236 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4237 |
8660 | 4238 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4239 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4240 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4241 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4242 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4243 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4244 |
2086 | 4245 return 1; |
4246 } | |
4247 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4248 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4249 GaimConnection *gc = sess->aux_data; |
8225 | 4250 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4251 gchar *utf8; | |
2086 | 4252 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4253 aim_userinfo_t *info; |
8225 | 4254 int len; |
2086 | 4255 char *msg; |
8219 | 4256 char *charset; |
2086 | 4257 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4258 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4259 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4260 len = va_arg(ap, int); |
4194 | 4261 msg = va_arg(ap, char *); |
8219 | 4262 charset = va_arg(ap, char *); |
4194 | 4263 va_end(ap); |
2086 | 4264 |
8225 | 4265 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4266 if (utf8 == NULL) |
4267 /* The conversion failed! */ | |
8668 | 4268 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4269 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4270 g_free(utf8); | |
2086 | 4271 |
4272 return 1; | |
4273 } | |
4274 | |
3694 | 4275 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4276 va_list ap; | |
5575 | 4277 GaimConnection *gc = sess->aux_data; |
3694 | 4278 struct aim_emailinfo *emailinfo; |
3725 | 4279 int havenewmail; |
7297 | 4280 char *alertitle, *alerturl; |
3694 | 4281 |
4282 va_start(ap, fr); | |
4283 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4284 havenewmail = va_arg(ap, int); |
7301 | 4285 alertitle = va_arg(ap, char *); |
4286 alerturl = va_arg(ap, char *); | |
3694 | 4287 va_end(ap); |
4288 | |
5628 | 4289 if (emailinfo && gaim_account_get_check_mail(gc->account)) { |
5575 | 4290 gchar *to = g_strdup_printf("%s@%s", gaim_account_get_username(gaim_connection_get_account(gc)), emailinfo->domain); |
5542 | 4291 if (emailinfo->unread && havenewmail) |
4292 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4293 g_free(to); |
3694 | 4294 } |
7297 | 4295 |
7301 | 4296 if (alertitle) |
8660 | 4297 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4298 |
4299 return 1; | |
4300 } | |
4301 | |
4804 | 4302 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4303 GaimConnection *gc = sess->aux_data; |
7283 | 4304 OscarData *od = gc->proto_data; |
4804 | 4305 char *sn; |
4306 | |
4307 sn = od->requesticon->data; | |
8660 | 4308 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4309 "removing %s from hash table\n", sn); |
4804 | 4310 od->requesticon = g_slist_remove(od->requesticon, sn); |
4311 free(sn); | |
4312 | |
4313 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4314 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4315 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4316 |
4317 return 1; | |
4318 } | |
4319 | |
4320 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4321 GaimConnection *gc = sess->aux_data; |
7283 | 4322 OscarData *od = gc->proto_data; |
4804 | 4323 GSList *cur; |
4324 va_list ap; | |
4325 char *sn; | |
4853 | 4326 fu8_t *iconcsum, *icon; |
4327 fu16_t iconcsumlen, iconlen; | |
4804 | 4328 |
4329 va_start(ap, fr); | |
4330 sn = va_arg(ap, char *); | |
4853 | 4331 iconcsum = va_arg(ap, fu8_t *); |
4332 iconcsumlen = va_arg(ap, int); | |
4804 | 4333 icon = va_arg(ap, fu8_t *); |
4334 iconlen = va_arg(ap, int); | |
4335 va_end(ap); | |
4336 | |
4853 | 4337 if (iconlen > 0) { |
4338 char *b16; | |
6695 | 4339 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4340 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4341 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4342 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4343 if (b16) { |
7693 | 4344 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4345 g_free(b16); |
5129 | 4346 } |
4853 | 4347 } |
4804 | 4348 |
4349 cur = od->requesticon; | |
4350 while (cur) { | |
4351 char *cursn = cur->data; | |
4352 if (!aim_sncmp(cursn, sn)) { | |
4353 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4354 free(cursn); | |
4355 cur = od->requesticon; | |
4356 } else | |
4357 cur = cur->next; | |
4358 } | |
4359 | |
4360 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4361 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4362 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4363 |
4364 return 1; | |
4365 } | |
4366 | |
4367 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4368 GaimConnection *gc = data; |
7283 | 4369 OscarData *od = gc->proto_data; |
7011 | 4370 aim_userinfo_t *userinfo; |
4804 | 4371 aim_conn_t *conn; |
4372 | |
4373 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4374 if (!conn) { |
4375 if (!od->iconconnecting) { | |
4376 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4377 od->iconconnecting = TRUE; | |
4378 } | |
4804 | 4379 return FALSE; |
4380 } | |
4381 | |
5842 | 4382 if (od->set_icon) { |
6039 | 4383 struct stat st; |
4384 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4385 if (iconfile == NULL) { | |
8363 | 4386 aim_ssi_delicon(od->sess); |
6039 | 4387 } else if (!stat(iconfile, &st)) { |
4388 char *buf = g_malloc(st.st_size); | |
4389 FILE *file = fopen(iconfile, "rb"); | |
4390 if (file) { | |
9532 | 4391 /* XXX - Use g_file_get_contents()? */ |
6039 | 4392 fread(buf, 1, st.st_size, file); |
4393 fclose(file); | |
8660 | 4394 gaim_debug_info("oscar", |
6039 | 4395 "Uploading icon to icon server\n"); |
6879 | 4396 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4397 } else |
8660 | 4398 gaim_debug_error("oscar", |
6039 | 4399 "Can't open buddy icon file!\n"); |
4400 g_free(buf); | |
4401 } else { | |
8660 | 4402 gaim_debug_error("oscar", |
6039 | 4403 "Can't stat buddy icon file!\n"); |
5842 | 4404 } |
4405 od->set_icon = FALSE; | |
4406 } | |
4407 | |
4408 if (!od->requesticon) { | |
8660 | 4409 gaim_debug_misc("oscar", |
5842 | 4410 "no more icons to request\n"); |
4411 return FALSE; | |
4412 } | |
4413 | |
7045 | 4414 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4415 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4416 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4417 return FALSE; |
4418 } else { | |
4419 char *sn = od->requesticon->data; | |
4420 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4421 free(sn); | |
4422 } | |
4423 | |
4424 return TRUE; | |
4425 } | |
4426 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4427 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4428 * 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
|
4429 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4430 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4431 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4432 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4433 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4434 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4435 va_start(ap, fr); |
4199 | 4436 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4437 sn = va_arg(ap, char *); |
4438 va_end(ap); | |
4439 | |
8660 | 4440 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4441 |
4442 return 1; | |
4443 } | |
4444 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4445 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
|
4446 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4447 "invalid", |
4194 | 4448 "change", |
4449 "warning", | |
4450 "limit", | |
4451 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4452 }; |
2086 | 4453 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4454 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4455 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4456 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4457 va_start(ap, fr); |
4200 | 4458 code = (fu16_t)va_arg(ap, unsigned int); |
4459 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4460 windowsize = va_arg(ap, fu32_t); | |
4461 clear = va_arg(ap, fu32_t); | |
4462 alert = va_arg(ap, fu32_t); | |
4463 limit = va_arg(ap, fu32_t); | |
4464 disconnect = va_arg(ap, fu32_t); | |
4465 currentavg = va_arg(ap, fu32_t); | |
4466 maxavg = va_arg(ap, fu32_t); | |
2086 | 4467 va_end(ap); |
4468 | |
8660 | 4469 gaim_debug_misc("oscar", |
5556 | 4470 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4471 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4472 (code < 5) ? codes[code] : codes[0], |
4473 rateclass, | |
4474 currentavg, maxavg, | |
4475 alert, clear, | |
4476 limit, disconnect, | |
4477 windowsize); | |
4478 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4479 /* XXX fix these values */ |
2086 | 4480 if (code == AIM_RATE_CODE_CHANGE) { |
4481 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4482 aim_conn_setlatency(fr->conn, 0); |
2086 | 4483 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4484 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4485 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4486 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4487 _("The last action you attempted could not be " |
4488 "performed because you are over the rate limit. " | |
4489 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4490 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4491 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4492 aim_conn_setlatency(fr->conn, 0); |
2086 | 4493 } |
4494 | |
4495 return 1; | |
4496 } | |
4497 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4498 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4499 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4500 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4501 aim_userinfo_t *userinfo; |
5575 | 4502 GaimConnection *gc = sess->aux_data; |
2086 | 4503 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4504 va_start(ap, fr); |
4199 | 4505 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4506 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4507 va_end(ap); |
4508 | |
7111 | 4509 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 4510 |
4511 return 1; | |
4512 } | |
4513 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4514 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
|
4515 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4516 aim_userinfo_t *info; |
5575 | 4517 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4518 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4519 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4520 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4521 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4522 |
5628 | 4523 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 4524 |
7872 | 4525 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 4526 gc->login_time_official = info->onlinesince; |
7872 | 4527 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
4528 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4529 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4530 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4531 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4532 |
4649 | 4533 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4534 GaimConnection *gc = sess->aux_data; |
7283 | 4535 OscarData *od = gc->proto_data; |
4649 | 4536 va_list ap; |
4537 fu16_t code; | |
4538 char *msg; | |
4539 | |
4540 va_start(ap, fr); | |
4541 code = (fu16_t)va_arg(ap, int); | |
4542 msg = va_arg(ap, char *); | |
4543 va_end(ap); | |
4544 | |
8660 | 4545 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4546 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4547 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4548 if (code == 0x0001) { |
6113 | 4549 gc->wants_to_die = TRUE; |
5579 | 4550 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4551 } else { |
5579 | 4552 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4553 } |
4666 | 4554 od->killme = TRUE; |
4649 | 4555 } |
4556 | |
4557 return 1; | |
4558 } | |
4559 | |
2675 | 4560 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4561 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4562 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4563 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4564 |
4565 #ifndef NOSSI | |
8660 | 4566 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4567 aim_ssi_reqrights(sess); |
6350 | 4568 aim_ssi_reqdata(sess); |
4230 | 4569 #endif |
4570 | |
7011 | 4571 aim_locate_reqrights(sess); |
7285 | 4572 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4573 aim_im_reqparams(sess); |
7334 | 4574 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4575 |
4576 #ifdef NOSSI | |
8660 | 4577 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4578 aim_bos_reqrights(sess, fr->conn); |
4230 | 4579 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4580 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4581 #endif | |
2086 | 4582 |
7283 | 4583 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4584 | |
2086 | 4585 return 1; |
4586 } | |
4587 | |
2675 | 4588 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4589 GaimConnection *gc = sess->aux_data; |
7283 | 4590 OscarData *od = gc->proto_data; |
2647 | 4591 |
6905 | 4592 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4593 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4594 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4595 | |
2672 | 4596 aim_clientready(sess, fr->conn); |
8660 | 4597 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4598 |
2647 | 4599 if (od->chpass) { |
8660 | 4600 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4601 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4602 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4603 od->oldp = NULL; |
2647 | 4604 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4605 od->newp = NULL; |
2647 | 4606 od->chpass = FALSE; |
4607 } | |
2979 | 4608 if (od->setnick) { |
8660 | 4609 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4610 aim_admin_setnick(sess, fr->conn, od->newsn); |
4611 g_free(od->newsn); | |
4612 od->newsn = NULL; | |
4613 od->setnick = FALSE; | |
4614 } | |
2647 | 4615 if (od->conf) { |
8660 | 4616 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4617 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4618 od->conf = FALSE; |
4619 } | |
4620 if (od->reqemail) { | |
8660 | 4621 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4622 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4623 od->reqemail = FALSE; |
4624 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4625 if (od->setemail) { |
8660 | 4626 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4627 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4628 g_free(od->email); |
5497 | 4629 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4630 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4631 } |
2647 | 4632 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4633 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4634 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4635 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4636 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
|
4637 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4638 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4639 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4640 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4641 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4642 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4643 |
4194 | 4644 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4645 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4646 "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
|
4647 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4648 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4649 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4650 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4651 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4652 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4653 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4654 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4655 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4656 |
4617 | 4657 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4658 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4659 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4660 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4661 |
2993 | 4662 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4663 { | |
5575 | 4664 GaimConnection *gc = sess->aux_data; |
7283 | 4665 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4666 va_list ap; |
4667 fu16_t maxsiglen; | |
2993 | 4668 |
4669 va_start(ap, fr); | |
4199 | 4670 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4671 va_end(ap); |
4672 | |
8660 | 4673 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4674 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4675 |
4617 | 4676 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4677 | |
4678 if (od->icq) | |
7334 | 4679 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4680 else |
7334 | 4681 aim_locate_setcaps(od->sess, caps_aim); |
4682 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4683 |
4684 return 1; | |
4685 } | |
4686 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4687 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
|
4688 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4689 fu16_t maxbuddies, maxwatchers; |
5575 | 4690 GaimConnection *gc = sess->aux_data; |
7283 | 4691 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4692 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4693 va_start(ap, fr); |
4199 | 4694 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4695 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4696 va_end(ap); |
4697 | |
8660 | 4698 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4699 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4700 |
4617 | 4701 od->rights.maxbuddies = (guint)maxbuddies; |
4702 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4703 |
2086 | 4704 return 1; |
4705 } | |
4706 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4707 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4708 GaimConnection *gc = sess->aux_data; |
7283 | 4709 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4710 va_list ap; |
4711 fu16_t maxpermits, maxdenies; | |
2086 | 4712 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4713 va_start(ap, fr); |
4199 | 4714 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4715 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4716 va_end(ap); |
4717 | |
8660 | 4718 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4719 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4720 |
4617 | 4721 od->rights.maxpermits = (guint)maxpermits; |
4722 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4723 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4724 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4725 serv_finish_login(gc); |
4726 | |
8660 | 4727 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4728 |
2672 | 4729 aim_clientready(sess, fr->conn); |
5948 | 4730 aim_srv_setavailmsg(sess, NULL); |
7474 | 4731 aim_srv_setidle(sess, 0); |
4617 | 4732 |
4664 | 4733 if (od->icq) { |
4734 aim_icq_reqofflinemsgs(sess); | |
4735 aim_icq_hideip(sess); | |
4736 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4737 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4738 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4739 if (sess->authinfo->email) |
4740 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4741 |
4742 return 1; | |
4743 } | |
4744 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4745 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
|
4746 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4747 struct aim_icq_offlinemsg *msg; |
4075 | 4748 struct aim_incomingim_ch4_args args; |
4749 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4750 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4751 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4752 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4753 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4754 |
8660 | 4755 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4756 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4757 args.uin = msg->sender; |
4758 args.type = msg->type; | |
4173 | 4759 args.flags = msg->flags; |
4076 | 4760 args.msglen = msg->msglen; |
4075 | 4761 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4762 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4763 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4764 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4765 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4766 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4767 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4768 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
|
4769 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4770 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4771 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4772 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4773 |
7388 | 4774 #if 0 |
4775 /* | |
7465 | 4776 * Update, 2003-11-09: |
4777 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4778 * | |
7388 | 4779 * It may not be my place to do this, but... |
4780 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4781 * stupid, and should not exist for % switches (%x in our case) that request | |
4782 * a year in the preferred representation for the current locale. For that | |
4783 * reason I've chosen to not use this workaround (n., see kluge). | |
4784 * | |
4785 * I have a date. I want to show it to the user in the "preferred" way. | |
4786 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4787 * what the locale wanted. | |
4788 * | |
4789 * If I have a necessity for a full representation of the year in the current | |
4790 * locale, then I'll use a switch that returns a full representation of the | |
4791 * year. | |
4792 * | |
4793 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4794 * (because you're anal, or whatever), then change the f***ing locale. | |
4795 * | |
4796 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4797 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4798 * |
4799 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4800 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4801 */ |
4802 | |
4803 /* | |
4804 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4805 * "last 2 digits" warning. |
4806 */ | |
4807 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4808 const struct tm *tm) | |
4809 { | |
4810 return strftime(s, max, fmt, tm); | |
4811 } | |
7388 | 4812 #endif |
7386 | 4813 |
4624 | 4814 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
|
4815 { |
5575 | 4816 GaimConnection *gc = sess->aux_data; |
8670 | 4817 OscarData *od = (OscarData *)gc->proto_data; |
4818 GaimBuddy *buddy; | |
8853 | 4819 struct buddyinfo *bi = NULL; |
4624 | 4820 gchar who[16]; |
8670 | 4821 GString *str; |
4822 gchar *primary, *utf8; | |
9634 | 4823 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4824 va_list ap; |
4151 | 4825 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4826 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4827 va_start(ap, fr); |
4151 | 4828 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4829 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4830 |
4664 | 4831 if (!info->uin) |
4832 return 0; | |
4833 | |
8670 | 4834 str = g_string_sized_new(100); |
5556 | 4835 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 4836 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
4837 if (buddy != NULL) | |
4838 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
4839 | |
4840 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 4841 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 4842 if ((bi != NULL) && (bi->ipaddr != 0)) { |
4843 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
4844 (bi->ipaddr & 0xff000000) >> 24, | |
4845 (bi->ipaddr & 0x00ff0000) >> 16, | |
4846 (bi->ipaddr & 0x0000ff00) >> 8, | |
4847 (bi->ipaddr & 0x000000ff)); | |
8701 | 4848 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 4849 g_free(tstr); |
4850 } | |
8701 | 4851 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
4852 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4853 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 4854 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
4855 g_free(utf8); | |
4625 | 4856 } |
4857 if (info->numaddresses && info->email2) { | |
4858 int i; | |
4859 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4860 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 4861 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
4862 g_free(utf8); | |
4643 | 4863 } |
4625 | 4864 } |
4624 | 4865 } |
8701 | 4866 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
8902 | 4867 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
4868 info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 4869 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 4870 char date[30]; |
4871 struct tm tm; | |
4872 tm.tm_mday = (int)info->birthday; | |
4873 tm.tm_mon = (int)info->birthmonth-1; | |
4874 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 4875 strftime(date, sizeof(date), "%x", &tm); |
8701 | 4876 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 4877 } |
4624 | 4878 if (info->age) { |
4879 char age[5]; | |
4880 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 4881 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 4882 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4883 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 4884 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
4885 g_free(utf8); | |
4819 | 4886 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4887 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 4888 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
4889 g_free(utf8); | |
4890 } | |
4891 g_string_append_printf(str, "<hr>\n"); | |
4641 | 4892 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 4893 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 4894 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
4895 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
4896 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
4897 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 4898 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 4899 } |
4641 | 4900 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 4901 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 4902 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
4903 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
4904 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
4905 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 4906 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 4907 } |
4641 | 4908 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 4909 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 4910 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
4911 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
4912 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4913 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 4914 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
4915 g_free(utf8); | |
4624 | 4916 } |
8670 | 4917 g_string_append_printf(str, "\n<hr>\n"); |
4918 } | |
4919 | |
9634 | 4920 if (buddy != NULL) |
4921 alias = gaim_buddy_get_alias(buddy); | |
4922 else | |
4923 alias = who; | |
4924 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
8670 | 4925 gaim_notify_formatted(gc, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 4926 g_free(primary); |
8670 | 4927 g_string_free(str, TRUE); |
4151 | 4928 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4929 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4930 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4931 |
4759 | 4932 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
4933 { | |
5575 | 4934 GaimConnection *gc = sess->aux_data; |
4820 | 4935 gchar who[16], *utf8; |
6695 | 4936 GaimBuddy *b; |
4759 | 4937 va_list ap; |
4938 struct aim_icq_info *info; | |
4939 | |
4940 va_start(ap, fr); | |
4941 info = va_arg(ap, struct aim_icq_info *); | |
4942 va_end(ap); | |
4943 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4944 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 4945 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 4946 serv_got_alias(gc, who, utf8); |
4759 | 4947 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 4948 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 4949 } |
4820 | 4950 g_free(utf8); |
4759 | 4951 } |
4952 | |
4953 return 1; | |
4954 } | |
4955 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4956 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
|
4957 { |
7032 | 4958 GaimConnection *gc = sess->aux_data; |
4959 gchar *text; | |
4960 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4961 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4962 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4963 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4964 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4965 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4966 url = va_arg(ap, char *); |
4199 | 4967 wid = (fu16_t) va_arg(ap, int); |
4968 hei = (fu16_t) va_arg(ap, int); | |
4969 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4970 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4971 |
7032 | 4972 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
4973 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
4974 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4975 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4976 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4977 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4978 |
7032 | 4979 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
4980 { | |
6873 | 4981 GaimConnection *gc = sess->aux_data; |
4982 gchar *secondary; | |
4983 GString *text; | |
4984 int i, num; | |
2086 | 4985 va_list ap; |
6873 | 4986 char *email, *SNs; |
2086 | 4987 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4988 va_start(ap, fr); |
6873 | 4989 email = va_arg(ap, char *); |
2086 | 4990 num = va_arg(ap, int); |
4991 SNs = va_arg(ap, char *); | |
4992 va_end(ap); | |
4993 | |
8152 | 4994 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 4995 text = g_string_new(""); |
2086 | 4996 for (i = 0; i < num; i++) |
6873 | 4997 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
4998 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
4999 | |
5000 g_free(secondary); | |
5001 g_string_free(text, TRUE); | |
2086 | 5002 |
5003 return 1; | |
5004 } | |
5005 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5006 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5007 va_list ap; |
6873 | 5008 char *email; |
5420 | 5009 char *buf; |
2086 | 5010 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5011 va_start(ap, fr); |
6873 | 5012 email = va_arg(ap, char *); |
2086 | 5013 va_end(ap); |
5014 | |
6873 | 5015 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
|
5016 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5017 g_free(buf); |
2086 | 5018 |
5019 return 1; | |
5020 } | |
5021 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5022 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5023 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5024 fu16_t status; |
2086 | 5025 va_list ap; |
5026 char msg[256]; | |
5027 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5028 va_start(ap, fr); |
4199 | 5029 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5030 va_end(ap); |
5031 | |
8660 | 5032 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5033 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5034 status ? "unknown" : "email sent"); |
5035 if (!status) { | |
5302 | 5036 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5037 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5038 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5039 } |
5040 | |
5041 return 1; | |
5042 } | |
5043 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5044 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5045 GaimConnection *gc = sess->aux_data; |
2086 | 5046 va_list ap; |
3912 | 5047 fu16_t perms, err; |
5048 char *url, *sn, *email; | |
5049 int change; | |
2086 | 5050 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5051 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5052 change = va_arg(ap, int); |
4199 | 5053 perms = (fu16_t) va_arg(ap, unsigned int); |
5054 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5055 url = va_arg(ap, char *); |
5056 sn = va_arg(ap, char *); | |
5057 email = va_arg(ap, char *); | |
2086 | 5058 va_end(ap); |
5059 | |
8660 | 5060 gaim_debug_misc("oscar", |
9626 | 5061 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5062 change ? "change" : "request", perms, err, | |
5063 (url != NULL) ? url : "(null)", | |
5064 (sn != NULL) ? sn : "(null)", | |
5065 (email != NULL) ? email : "(null)"); | |
5066 | |
5067 if ((err > 0) && (url != NULL)) { | |
3912 | 5068 char *dialog_msg; |
5069 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5070 switch (err) { | |
5071 case 0x0001: { | |
5072 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5073 } break; | |
5074 case 0x0006: { | |
5075 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5076 } break; | |
5077 case 0x000b: { | |
5078 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5079 } break; | |
5080 case 0x001d: { | |
5081 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); | |
5082 } break; | |
5083 case 0x0021: { | |
5084 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); | |
5085 } break; | |
5086 case 0x0023: { | |
5087 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5088 } break; | |
5089 default: { | |
5090 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5091 } break; | |
5092 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5093 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5094 g_free(dialog_top); |
5095 g_free(dialog_msg); | |
5096 return 1; | |
5097 } | |
5098 | |
9626 | 5099 if (sn != NULL) { |
4585 | 5100 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
|
5101 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5102 g_free(dialog_msg); |
5103 } | |
5104 | |
9626 | 5105 if (email != NULL) { |
5575 | 5106 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5107 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5108 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5109 g_free(dialog_msg); |
2086 | 5110 } |
5111 | |
5112 return 1; | |
5113 } | |
5114 | |
5575 | 5115 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5116 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5117 aim_flap_nop(od->sess, od->conn); |
2086 | 5118 } |
5119 | |
6059 | 5120 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5121 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5122 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5123 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5124 if (typing == GAIM_TYPING) |
4870 | 5125 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5126 else if (typing == GAIM_TYPED) |
4870 | 5127 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5128 else | |
5129 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5130 else { |
5300 | 5131 /* Don't send if this turkey is in our deny list */ |
5132 GSList *list; | |
5133 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5134 if (!list) { | |
7261 | 5135 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5136 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5137 if (typing == GAIM_TYPING) |
5300 | 5138 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5139 else if (typing == GAIM_TYPED) |
5300 | 5140 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5141 else | |
5142 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5143 } | |
3595 | 5144 } |
5145 } | |
2993 | 5146 return 0; |
5147 } | |
9030 | 5148 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5149 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
|
5150 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5151 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5152 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5153 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
|
5154 int ret = 0; |
3659 | 5155 GError *err = NULL; |
5575 | 5156 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5157 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5158 |
4838 | 5159 if (dim && dim->connected) { |
5160 /* If we're directly connected, send a direct IM */ | |
6982 | 5161 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5162 } else { |
4738 | 5163 struct buddyinfo *bi; |
3008 | 5164 struct aim_sendimext_args args; |
5165 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5166 gsize len; |
8962 | 5167 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5168 | |
5169 if (strstr(message, "<IMG ")) | |
5170 gaim_conversation_write(conv, "", | |
5171 _("Your IM Image was not sent. " | |
5172 "You must be Direct Connected to send IM Images."), | |
5173 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5174 |
7261 | 5175 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5176 if (!bi) { |
5177 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5178 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5179 } |
5180 | |
3008 | 5181 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5182 if (od->icq) { |
5183 args.features = features_icq; | |
5184 args.featureslen = sizeof(features_icq); | |
3008 | 5185 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5186 } else { |
5187 args.features = features_aim; | |
5188 args.featureslen = sizeof(features_aim); | |
4972 | 5189 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5190 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5191 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5192 } |
4269 | 5193 |
4738 | 5194 if (bi->ico_need) { |
8660 | 5195 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5196 "Sending buddy icon request with message\n"); |
3008 | 5197 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5198 bi->ico_need = FALSE; |
3008 | 5199 } |
4269 | 5200 |
5575 | 5201 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5202 FILE *file = fopen(iconfile, "rb"); |
3008 | 5203 if (file) { |
5204 char *buf = g_malloc(st.st_size); | |
9532 | 5205 /* XXX - Use g_file_get_contents()? */ |
3008 | 5206 fread(buf, 1, st.st_size, file); |
6039 | 5207 fclose(file); |
4269 | 5208 |
3008 | 5209 args.iconlen = st.st_size; |
4617 | 5210 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5211 args.iconstamp = st.st_mtime; |
5212 | |
7406 | 5213 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5214 bi->ico_informed = FALSE; |
7406 | 5215 bi->ico_sent = FALSE; |
5216 } | |
4738 | 5217 |
5218 if (!bi->ico_informed) { | |
8660 | 5219 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5220 "Claiming to have a buddy icon\n"); |
4738 | 5221 args.flags |= AIM_IMFLAGS_HASICON; |
5222 bi->ico_me_len = args.iconlen; | |
5223 bi->ico_me_csum = args.iconsum; | |
5224 bi->ico_me_time = args.iconstamp; | |
5225 bi->ico_informed = TRUE; | |
5226 } | |
5227 | |
3008 | 5228 g_free(buf); |
2086 | 5229 } |
5230 } | |
4269 | 5231 |
3008 | 5232 args.destsn = name; |
4269 | 5233 |
8985 | 5234 /* |
5235 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5236 * strip all HTML | |
5237 */ | |
8995 | 5238 if (isdigit(name[0]) ) { |
5239 /* being sent to an ICQ user */ | |
5240 if (!isdigit(gaim_account_get_username(gc->account)[0])) { | |
5241 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ | |
5242 tmpmsg = gaim_str_add_cr(message); | |
5243 } else { | |
5244 /* from an ICQ user - do nothing */ | |
5245 tmpmsg = g_strdup(message); | |
5246 } | |
5247 } else { | |
5248 /* being sent to an AIM user */ | |
5249 if (isdigit(gaim_account_get_username(gc->account)[0])) { | |
5250 /* from an ICQ user */ | |
5251 tmpmsg2 = gaim_strdup_withhtml(message); | |
5252 tmpmsg = gaim_escape_html(tmpmsg2); | |
5253 g_free(tmpmsg2); | |
5254 } else | |
5255 tmpmsg = gaim_strdup_withhtml(message); | |
5256 } | |
6310 | 5257 len = strlen(tmpmsg); |
5258 | |
5259 args.flags |= oscar_encoding_check(tmpmsg); | |
3642 | 5260 if (args.flags & AIM_IMFLAGS_UNICODE) { |
8660 | 5261 gaim_debug_info("oscar", "Sending Unicode IM\n"); |
4662 | 5262 args.charset = 0x0002; |
4665 | 5263 args.charsubset = 0x0000; |
6310 | 5264 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3659 | 5265 if (err) { |
8660 | 5266 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5267 "Error converting a unicode message: %s\n", err->message); |
8660 | 5268 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5269 "This really shouldn't happen!\n"); |
3659 | 5270 /* We really shouldn't try to send the |
5271 * IM now, but I'm not sure what to do */ | |
4800 | 5272 g_error_free(err); |
3659 | 5273 } |
3850 | 5274 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
8660 | 5275 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5276 "Sending ISO-8859-1 IM\n"); |
4662 | 5277 args.charset = 0x0003; |
4665 | 5278 args.charsubset = 0x0000; |
6310 | 5279 args.msg = g_convert(tmpmsg, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3659 | 5280 if (err) { |
8660 | 5281 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5282 "conversion error: %s\n", err->message); |
8660 | 5283 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5284 "Someone tell Ethan his 8859-1 detection is wrong\n"); |
3642 | 5285 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
6310 | 5286 len = strlen(tmpmsg); |
4800 | 5287 g_error_free(err); |
6310 | 5288 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3659 | 5289 if (err) { |
8660 | 5290 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5291 "Error in unicode fallback: %s\n", err->message); |
4800 | 5292 g_error_free(err); |
3659 | 5293 } |
3642 | 5294 } |
5295 } else { | |
4662 | 5296 args.charset = 0x0000; |
5297 args.charsubset = 0x0000; | |
6310 | 5298 args.msg = tmpmsg; |
3642 | 5299 } |
5300 args.msglen = len; | |
4269 | 5301 |
4617 | 5302 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 5303 } |
4838 | 5304 |
6310 | 5305 g_free(tmpmsg); |
5306 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5307 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5308 return 1; |
6310 | 5309 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5310 return ret; |
2086 | 5311 } |
5312 | |
7011 | 5313 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5314 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5315 |
7173 | 5316 if (od->icq && isdigit(name[0])) |
4624 | 5317 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5318 else |
7235 | 5319 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5320 } |
5321 | |
8950 | 5322 #if 0 |
7011 | 5323 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5324 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5325 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5326 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5327 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5328 maiden, NULL, NULL, city, state, NULL, 0, web); |
5329 } | |
8950 | 5330 #endif |
2086 | 5331 |
5575 | 5332 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5333 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5334 aim_srv_setidle(od->sess, time); |
2086 | 5335 } |
5336 | |
5954 | 5337 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5338 OscarData *od = (OscarData *)gc->proto_data; |
5129 | 5339 fu32_t flags = 0; |
6019 | 5340 char *text_html = NULL; |
5129 | 5341 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5342 gsize msglen = 0; |
2993 | 5343 |
4617 | 5344 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5345 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5346 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5347 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5348 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5349 "again when you are fully connected.")); |
4617 | 5350 |
7334 | 5351 if (!text) { |
5352 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5353 return; | |
5354 } | |
6019 | 5355 |
7334 | 5356 text_html = gaim_strdup_withhtml(text); |
5357 flags = oscar_encoding_check(text_html); | |
5358 if (flags & AIM_IMFLAGS_UNICODE) { | |
5359 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5360 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5361 g_free(msg); | |
5362 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
5363 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5364 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5365 g_free(msg); | |
5366 } else { | |
5367 msglen = strlen(text_html); | |
5368 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5369 } | |
5370 | |
5371 if (msglen > od->rights.maxsiglen) { | |
5372 gchar *errstr; | |
5373 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5374 "has been exceeded. Gaim has truncated it for you.", | |
5375 "The maximum profile length of %d bytes " | |
5376 "has been exceeded. Gaim has truncated it for you.", | |
5377 od->rights.maxsiglen), od->rights.maxsiglen); | |
5378 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5379 g_free(errstr); | |
5380 } | |
5381 | |
5382 g_free(text_html); | |
2993 | 5383 |
5384 return; | |
2086 | 5385 } |
5386 | |
8257 | 5387 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 5388 { |
5129 | 5389 fu32_t flags = 0; |
6019 | 5390 gchar *text_html = NULL; |
5129 | 5391 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5392 gsize msglen = 0; |
2993 | 5393 |
8257 | 5394 if (!strcmp(state, _("Visible"))) { |
5395 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5396 return; | |
5397 } else if (!strcmp(state, _("Invisible"))) { | |
5398 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5399 return; | |
5400 } /* else... */ | |
5401 | |
8476 | 5402 if (!strcmp(state, _("Back"))) { |
5403 /* If this is our only online account then globally set Gaim not-away */ | |
5404 GList *gcs = gaim_connections_get_all(); | |
5405 if (gcs->next == NULL) | |
5406 do_im_back(NULL, NULL); | |
5407 } | |
5408 | |
8257 | 5409 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5410 | |
2993 | 5411 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5412 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5413 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5414 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5415 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5416 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5417 "fully connected.")); |
5129 | 5418 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5419 if (gc->away) { |
2993 | 5420 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5421 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5422 } |
2993 | 5423 |
5129 | 5424 if (!text) { |
7334 | 5425 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5426 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5427 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5428 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5429 text_html = gaim_strdup_withhtml(text); |
6019 | 5430 flags = oscar_encoding_check(text_html); |
5129 | 5431 if (flags & AIM_IMFLAGS_UNICODE) { |
6019 | 5432 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5433 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5434 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5435 g_free(msg); |
5436 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
5437 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
6019 | 5438 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5439 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5440 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5441 g_free(msg); |
6019 | 5442 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5443 } else { |
6019 | 5444 msglen = strlen(text_html); |
7011 | 5445 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5446 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 5447 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5448 } |
5449 | |
5450 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5451 gchar *errstr; |
5452 | |
6308 | 5453 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5454 "has been exceeded. Gaim has truncated it for you.", | |
5455 "The maximum away message length of %d bytes " | |
5456 "has been exceeded. Gaim has truncated it for you.", | |
5457 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5458 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5459 g_free(errstr); |
5460 } | |
6019 | 5461 |
5462 g_free(text_html); | |
8257 | 5463 |
2993 | 5464 return; |
5465 } | |
5466 | |
7283 | 5467 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 5468 { |
5575 | 5469 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5470 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5471 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5472 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5473 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5474 |
8265 | 5475 if (strcmp(state, _("Invisible"))) |
5575 | 5476 account->perm_deny = 4; |
8265 | 5477 else |
5575 | 5478 account->perm_deny = 3; |
8265 | 5479 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5480 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5481 |
5482 if (!strcmp(state, _("Online"))) | |
4901 | 5483 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 5484 else if (!strcmp(state, _("Away"))) { |
4901 | 5485 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5486 gc->away = g_strdup(""); |
4342 | 5487 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 5488 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
|
5489 gc->away = g_strdup(""); |
4342 | 5490 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 5491 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
|
5492 gc->away = g_strdup(""); |
4342 | 5493 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 5494 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
|
5495 gc->away = g_strdup(""); |
4342 | 5496 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 5497 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5498 gc->away = g_strdup(""); |
4342 | 5499 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 5500 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5501 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5502 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 5503 if (message) { |
4901 | 5504 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
|
5505 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5506 } else { |
4901 | 5507 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5508 } |
2086 | 5509 } |
2993 | 5510 |
5511 return; | |
5512 } | |
5513 | |
6059 | 5514 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 5515 { |
7283 | 5516 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 5517 |
5518 if (od->icq) | |
5519 oscar_set_away_icq(gc, od, state, message); | |
5520 else | |
8257 | 5521 oscar_set_away_aim(gc, od, state, message); |
2993 | 5522 |
5523 return; | |
2086 | 5524 } |
5525 | |
6059 | 5526 static void oscar_warn(GaimConnection *gc, const char *name, int anon) { |
7283 | 5527 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5528 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); |
2086 | 5529 } |
5530 | |
9285 | 5531 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5532 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5533 |
5534 if (!aim_snvalid(buddy->name)) { | |
8092 | 5535 gchar *buf; |
9285 | 5536 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 | 5537 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5538 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5539 g_free(buf); |
8150 | 5540 |
5541 /* Remove from local list */ | |
9285 | 5542 gaim_blist_remove_buddy(buddy); |
8150 | 5543 |
8092 | 5544 return; |
5545 } | |
5546 | |
4230 | 5547 #ifdef NOSSI |
9285 | 5548 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5549 #else |
9285 | 5550 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5551 if (buddy && group) { | |
8660 | 5552 gaim_debug_info("oscar", |
9285 | 5553 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5554 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5555 } |
5556 } | |
5557 #endif | |
8150 | 5558 |
4759 | 5559 if (od->icq) |
9285 | 5560 aim_icq_getalias(od->sess, buddy->name); |
5561 } | |
5562 | |
5563 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5564 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5565 #ifdef NOSSI |
5566 char buf[MSG_LEN]; | |
5567 int n=0; | |
9285 | 5568 |
4230 | 5569 while (buddies) { |
9381 | 5570 GaimBuddy *buddy = buddies->data; |
4230 | 5571 if (n > MSG_LEN - 18) { |
7285 | 5572 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5573 n = 0; |
3092 | 5574 } |
9381 | 5575 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5576 buddies = buddies->next; |
5577 } | |
7285 | 5578 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5579 #else |
9285 | 5580 |
4230 | 5581 if (od->sess->ssi.received_data) { |
9285 | 5582 GList *curb = buddies; |
5583 GList *curg = groups; | |
5584 while ((curb != NULL) && (curg != NULL)) { | |
5585 GaimBuddy *buddy = curb->data; | |
5586 GaimGroup *group = curg->data; | |
5587 oscar_add_buddy(gc, buddy, group); | |
5588 curb = curb->next; | |
5589 curg = curg->next; | |
4230 | 5590 } |
5591 } | |
5592 #endif | |
5593 } | |
5594 | |
9285 | 5595 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5596 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5597 |
4230 | 5598 #ifdef NOSSI |
9285 | 5599 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5600 #else |
5601 if (od->sess->ssi.received_data) { | |
8660 | 5602 gaim_debug_info("oscar", |
9285 | 5603 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5604 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5605 } |
5606 #endif | |
5607 } | |
5608 | |
9285 | 5609 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5610 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5611 |
4230 | 5612 #ifdef NOSSI |
9285 | 5613 for (cur = buddies; cur != NULL; cur = cur->next) { |
5614 GaimBuddy *buddy = cur->data; | |
5615 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5616 } | |
4230 | 5617 #else |
5618 if (od->sess->ssi.received_data) { | |
9285 | 5619 GList *curb = buddies; |
5620 GList *curg = groups; | |
5621 while ((curb != NULL) && (curg != NULL)) { | |
5622 GaimBuddy *buddy = curb->data; | |
5623 GaimGroup *group = curg->data; | |
5624 oscar_remove_buddy(gc, buddy, group); | |
5625 curb = curb->next; | |
5626 curg = curg->next; | |
3092 | 5627 } |
4230 | 5628 } |
5629 #endif | |
5630 } | |
5631 | |
5632 #ifndef NOSSI | |
5575 | 5633 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5634 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5635 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5636 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5637 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5638 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5639 } |
5640 } | |
5641 | |
5575 | 5642 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5643 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5644 if (od->sess->ssi.received_data) { |
5645 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5646 if (gname) { | |
8660 | 5647 gaim_debug_info("oscar", |
9586 | 5648 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5649 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5650 } |
5651 } | |
5652 } | |
5653 | |
9285 | 5654 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5655 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5656 |
5657 if (od->sess->ssi.received_data) { | |
9285 | 5658 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5659 GList *cur, *groups = NULL; | |
5660 | |
5661 /* Make a list of what the groups each buddy is in */ | |
5662 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5663 GaimBlistNode *node = cur->data; | |
5664 groups = g_list_append(groups, node->parent); | |
5665 } | |
5666 | |
5667 oscar_remove_buddies(gc, moved_buddies, groups); | |
5668 oscar_add_buddies(gc, moved_buddies, groups); | |
5669 g_list_free(groups); | |
8660 | 5670 gaim_debug_info("oscar", |
9285 | 5671 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5672 } else { |
9285 | 5673 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5674 gaim_debug_info("oscar", |
9285 | 5675 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5676 } |
5677 } | |
5678 } | |
5679 | |
5968 | 5680 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5681 aim_session_t *sess = data; | |
6350 | 5682 aim_ssi_reqdata(sess); |
5968 | 5683 return FALSE; |
5684 } | |
5685 | |
4642 | 5686 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5687 GaimConnection *gc = sess->aux_data; |
7283 | 5688 OscarData *od = gc->proto_data; |
4642 | 5689 va_list ap; |
5690 fu16_t reason; | |
5691 | |
5692 va_start(ap, fr); | |
5693 reason = (fu16_t)va_arg(ap, unsigned int); | |
5694 va_end(ap); | |
5695 | |
8660 | 5696 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5697 |
5698 if (reason == 0x0005) { | |
5892 | 5699 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5700 _("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
|
5701 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5702 } |
5703 | |
5704 /* Activate SSI */ | |
5705 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5706 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5707 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5708 aim_ssi_enable(od->sess); |
5709 | |
5710 return 1; | |
5711 } | |
5712 | |
2991 | 5713 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5714 GaimConnection *gc = sess->aux_data; |
7283 | 5715 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5716 int numtypes, i; |
5717 fu16_t *maxitems; | |
2991 | 5718 va_list ap; |
5719 | |
5720 va_start(ap, fr); | |
4230 | 5721 numtypes = va_arg(ap, int); |
5722 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5723 va_end(ap); |
5724 | |
8660 | 5725 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5726 |
4230 | 5727 for (i=0; i<numtypes; i++) |
8660 | 5728 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5729 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5730 |
8660 | 5731 gaim_debug_misc(NULL, "\n"); |
4230 | 5732 |
5733 if (numtypes >= 0) | |
5734 od->rights.maxbuddies = maxitems[0]; | |
5735 if (numtypes >= 1) | |
5736 od->rights.maxgroups = maxitems[1]; | |
5737 if (numtypes >= 2) | |
5738 od->rights.maxpermits = maxitems[2]; | |
5739 if (numtypes >= 3) | |
5740 od->rights.maxdenies = maxitems[3]; | |
2991 | 5741 |
5742 return 1; | |
5743 } | |
5744 | |
5745 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5746 GaimConnection *gc = sess->aux_data; |
5747 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5748 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5749 GaimGroup *g; |
5750 GaimBuddy *b; | |
2995 | 5751 struct aim_ssi_item *curitem; |
2991 | 5752 int tmp; |
4230 | 5753 va_list ap; |
8219 | 5754 fu16_t fmtver, numitems; |
5755 struct aim_ssi_item *items; | |
5756 fu32_t timestamp; | |
4230 | 5757 |
5758 va_start(ap, fr); | |
5759 fmtver = (fu16_t)va_arg(ap, int); | |
5760 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5761 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5762 timestamp = va_arg(ap, fu32_t); |
8219 | 5763 va_end(ap); |
2991 | 5764 |
8660 | 5765 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5766 "ssi: syncing local list and server list\n"); |
2991 | 5767 |
8219 | 5768 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5769 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 | 5770 return 1; |
5771 } | |
5772 | |
2991 | 5773 /* Clean the buddy list */ |
4889 | 5774 aim_ssi_cleanlist(sess); |
2991 | 5775 |
8150 | 5776 { /* If not in server list then prune from local list */ |
5777 GaimBlistNode *gnode, *cnode, *bnode; | |
5778 GaimBuddyList *blist; | |
9539 | 5779 GSList *cur, *next; |
8150 | 5780 |
5781 /* Buddies */ | |
5782 cur = NULL; | |
5783 if ((blist = gaim_get_blist()) != NULL) { | |
5784 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5785 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5786 continue; | |
5787 g = (GaimGroup *)gnode; | |
5788 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5789 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5790 continue; | |
5791 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5792 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5793 continue; | |
5794 b = (GaimBuddy *)bnode; | |
5795 if (b->account == gc->account) { | |
5796 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5797 /* If the buddy is an ICQ user then load his nickname */ | |
5798 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5799 char *alias; |
8150 | 5800 if (servernick) |
5801 serv_got_alias(gc, b->name, servernick); | |
5802 | |
5803 /* Store local alias on server */ | |
8214 | 5804 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5805 if (!alias && b->alias && strlen(b->alias)) |
5806 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5807 free(alias); | |
5808 } else { | |
8660 | 5809 gaim_debug_info("oscar", |
8150 | 5810 "ssi: removing buddy %s from local list\n", b->name); |
5811 /* We can't actually remove now because it will screw up our looping */ | |
5812 cur = g_slist_prepend(cur, b); | |
5813 } | |
5814 } | |
5815 } | |
5816 } | |
5817 } | |
5818 } | |
8175 | 5819 |
8150 | 5820 while (cur != NULL) { |
5821 b = cur->data; | |
5822 cur = g_slist_remove(cur, b); | |
5823 gaim_blist_remove_buddy(b); | |
5824 } | |
5825 | |
5826 /* Permit list */ | |
5827 if (gc->account->permit) { | |
9539 | 5828 next = gc->account->permit; |
5829 while (next != NULL) { | |
5830 cur = next; | |
5831 next = next->next; | |
8150 | 5832 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5833 gaim_debug_info("oscar", |
8150 | 5834 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5835 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5836 } | |
9539 | 5837 } |
8150 | 5838 } |
5839 | |
5840 /* Deny list */ | |
5841 if (gc->account->deny) { | |
9539 | 5842 next = gc->account->deny; |
5843 while (next != NULL) { | |
5844 cur = next; | |
5845 next = next->next; | |
8150 | 5846 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 5847 gaim_debug_info("oscar", |
8150 | 5848 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5849 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5850 } | |
9539 | 5851 } |
8150 | 5852 } |
5853 /* Presence settings (idle time visibility) */ | |
5854 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5855 if (!(tmp & 0x400)) | |
5856 aim_ssi_setpresence(sess, tmp | 0x400); | |
5857 } /* end pruning buddies from local list */ | |
5858 | |
2991 | 5859 /* Add from server list to local list */ |
4230 | 5860 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 5861 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 5862 switch (curitem->type) { |
4230 | 5863 case 0x0000: { /* Buddy */ |
4251 | 5864 if (curitem->name) { |
4292 | 5865 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 5866 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 5867 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 5868 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 5869 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 5870 /* Should gname be freed here? -- elb */ |
4754 | 5871 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 5872 free(alias); |
8150 | 5873 if (b) { |
4292 | 5874 /* Get server stored alias */ |
4705 | 5875 if (alias_utf8) { |
8150 | 5876 g_free(b->alias); |
5877 b->alias = g_strdup(alias_utf8); | |
4705 | 5878 } |
4282 | 5879 } else { |
8150 | 5880 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 5881 |
4754 | 5882 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 5883 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 5884 gaim_blist_add_group(g, NULL); |
5885 } | |
5146 | 5886 |
8660 | 5887 gaim_debug_info("oscar", |
9285 | 5888 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 5889 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 5890 } |
8341 | 5891 if (!aim_sncmp(curitem->name, account->username)) { |
5892 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
5893 gaim_check_comment(od, comment); | |
5894 free(comment); | |
5895 } | |
7162 | 5896 g_free(gname_utf8); |
5897 g_free(alias_utf8); | |
2991 | 5898 } |
4230 | 5899 } break; |
5900 | |
5901 case 0x0001: { /* Group */ | |
4282 | 5902 /* Shouldn't add empty groups */ |
4230 | 5903 } break; |
5904 | |
5905 case 0x0002: { /* Permit buddy */ | |
2991 | 5906 if (curitem->name) { |
4230 | 5907 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 5908 GSList *list; |
5575 | 5909 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5910 if (!list) { |
8660 | 5911 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5912 "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
|
5913 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 5914 } |
5915 } | |
4230 | 5916 } break; |
5917 | |
5918 case 0x0003: { /* Deny buddy */ | |
2991 | 5919 if (curitem->name) { |
5920 GSList *list; | |
5575 | 5921 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5922 if (!list) { |
8660 | 5923 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5924 "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
|
5925 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 5926 } |
5927 } | |
4230 | 5928 } break; |
5929 | |
5930 case 0x0004: { /* Permit/deny setting */ | |
2991 | 5931 if (curitem->data) { |
5932 fu8_t permdeny; | |
5575 | 5933 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 5934 gaim_debug_info("oscar", |
5575 | 5935 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
5936 account->perm_deny = permdeny; | |
5937 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 5938 serv_set_away(gc, "Invisible", ""); |
5939 } | |
2991 | 5940 } |
5941 } | |
4230 | 5942 } break; |
5943 | |
5944 case 0x0005: { /* Presence setting */ | |
3109 | 5945 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 5946 } break; |
2991 | 5947 } /* End of switch on curitem->type */ |
5948 } /* End of for loop */ | |
4230 | 5949 |
4901 | 5950 /* Set our ICQ status */ |
8257 | 5951 if (!gc->away) { |
4901 | 5952 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
5953 } | |
5954 | |
4342 | 5955 /* Activate SSI */ |
5956 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5957 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5958 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5959 "ssi: activating server-stored buddy list\n"); |
4642 | 5960 aim_ssi_enable(sess); |
4342 | 5961 |
2991 | 5962 return 1; |
2086 | 5963 } |
4230 | 5964 |
5965 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5966 GaimConnection *gc = sess->aux_data; |
4230 | 5967 va_list ap; |
5968 struct aim_ssi_tmp *retval; | |
5969 | |
5970 va_start(ap, fr); | |
5971 retval = va_arg(ap, struct aim_ssi_tmp *); | |
5972 va_end(ap); | |
5973 | |
5974 while (retval) { | |
8660 | 5975 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5976 "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 | 5977 |
5978 if (retval->ack != 0xffff) | |
5979 switch (retval->ack) { | |
5980 case 0x0000: { /* added successfully */ | |
5981 } break; | |
5982 | |
4829 | 5983 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
5984 gchar *buf; | |
5985 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 | 5986 if (!gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
5987 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
4829 | 5988 g_free(buf); |
5989 } | |
5990 | |
7023 | 5991 case 0x000e: { /* buddy requires authorization */ |
4828 | 5992 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 5993 gaim_auth_sendrequest(gc, retval->name); |
4230 | 5994 } break; |
5995 | |
5996 default: { /* La la la */ | |
5197 | 5997 gchar *buf; |
8660 | 5998 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 5999 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 | 6000 if (!gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
6001 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
5197 | 6002 g_free(buf); |
4230 | 6003 } break; |
6004 } | |
6005 | |
6006 retval = retval->next; | |
6007 } | |
6008 | |
6009 return 1; | |
6010 } | |
6011 | |
8227 | 6012 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6013 GaimConnection *gc = sess->aux_data; | |
6014 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6015 GaimBuddy *b; | |
6016 GaimGroup *g; | |
6017 va_list ap; | |
6018 fu16_t type; | |
6019 const char *name; | |
6020 | |
6021 va_start(ap, fr); | |
6022 type = (fu16_t)va_arg(ap, int); | |
6023 name = va_arg(ap, char *); | |
6024 va_end(ap); | |
6025 | |
6026 if ((type != 0x0000) || (name == NULL)) | |
6027 return 1; | |
6028 | |
6029 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6030 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6031 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6032 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6033 b = gaim_find_buddy(gc->account, name); | |
6034 free(alias); | |
6035 | |
6036 if (b) { | |
6037 /* Get server stored alias */ | |
6038 if (alias_utf8) { | |
6039 g_free(b->alias); | |
6040 b->alias = g_strdup(alias_utf8); | |
6041 } | |
6042 } else { | |
6043 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6044 | |
6045 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6046 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6047 gaim_blist_add_group(g, NULL); | |
6048 } | |
6049 | |
8660 | 6050 gaim_debug_info("oscar", |
9285 | 6051 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6052 gaim_blist_add_buddy(b, NULL, g, NULL); |
6053 } | |
6054 g_free(gname_utf8); | |
6055 g_free(alias_utf8); | |
6056 | |
6057 return 1; | |
6058 } | |
6059 | |
4230 | 6060 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6061 GaimConnection *gc = sess->aux_data; |
4230 | 6062 va_list ap; |
6063 char *sn, *msg; | |
4236 | 6064 gchar *dialog_msg, *nombre; |
4230 | 6065 struct name_data *data; |
6695 | 6066 GaimBuddy *buddy; |
4230 | 6067 |
6068 va_start(ap, fr); | |
6069 sn = va_arg(ap, char *); | |
6070 msg = va_arg(ap, char *); | |
6071 va_end(ap); | |
6072 | |
8660 | 6073 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6074 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6075 |
4687 | 6076 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6077 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6078 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6079 else |
6080 nombre = g_strdup(sn); | |
6081 | |
6082 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 | 6083 data = g_new(struct name_data, 1); |
6084 data->gc = gc; | |
6085 data->name = g_strdup(sn); | |
6086 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6087 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6088 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6089 0, data, |
7023 | 6090 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6091 G_CALLBACK(oscar_free_name_data)); |
4236 | 6092 |
4230 | 6093 g_free(dialog_msg); |
4236 | 6094 g_free(nombre); |
4230 | 6095 |
6096 return 1; | |
6097 } | |
6098 | |
6099 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6100 GaimConnection *gc = sess->aux_data; |
4230 | 6101 va_list ap; |
6102 char *sn, *msg; | |
4236 | 6103 gchar *dialog_msg, *nombre; |
4230 | 6104 struct name_data *data; |
6695 | 6105 GaimBuddy *buddy; |
4230 | 6106 |
6107 va_start(ap, fr); | |
6108 sn = va_arg(ap, char *); | |
6109 msg = va_arg(ap, char *); | |
6110 va_end(ap); | |
6111 | |
8660 | 6112 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6113 "ssi: received authorization request from %s\n", sn); |
4230 | 6114 |
4687 | 6115 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6116 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6117 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6118 else |
6119 nombre = g_strdup(sn); | |
6120 | |
4337 | 6121 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 | 6122 data = g_new(struct name_data, 1); |
6123 data->gc = gc; | |
6124 data->name = g_strdup(sn); | |
6125 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6126 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6127 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6128 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6129 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6130 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6131 |
4230 | 6132 g_free(dialog_msg); |
4236 | 6133 g_free(nombre); |
4230 | 6134 |
6135 return 1; | |
6136 } | |
6137 | |
6138 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6139 GaimConnection *gc = sess->aux_data; |
4230 | 6140 va_list ap; |
6141 char *sn, *msg; | |
4236 | 6142 gchar *dialog_msg, *nombre; |
4230 | 6143 fu8_t reply; |
6695 | 6144 GaimBuddy *buddy; |
4230 | 6145 |
6146 va_start(ap, fr); | |
6147 sn = va_arg(ap, char *); | |
6148 reply = (fu8_t)va_arg(ap, int); | |
6149 msg = va_arg(ap, char *); | |
6150 va_end(ap); | |
6151 | |
8660 | 6152 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6153 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6154 |
4687 | 6155 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6156 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6157 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6158 else |
6159 nombre = g_strdup(sn); | |
6160 | |
4230 | 6161 if (reply) { |
6162 /* Granted */ | |
7023 | 6163 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
|
6164 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6165 } else { |
6166 /* Denied */ | |
7023 | 6167 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
|
6168 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6169 } |
6170 g_free(dialog_msg); | |
4236 | 6171 g_free(nombre); |
4230 | 6172 |
6173 return 1; | |
6174 } | |
6175 | |
6176 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6177 GaimConnection *gc = sess->aux_data; |
4230 | 6178 va_list ap; |
6179 char *sn; | |
6695 | 6180 GaimBuddy *buddy; |
4230 | 6181 |
6182 va_start(ap, fr); | |
6183 sn = va_arg(ap, char *); | |
6184 va_end(ap); | |
6185 | |
4687 | 6186 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6187 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6188 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6189 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6190 |
6191 return 1; | |
6192 } | |
4269 | 6193 #endif |
2086 | 6194 |
5575 | 6195 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6196 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6197 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6198 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6199 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6200 pce->label = _("_Group:"); |
5234 | 6201 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6202 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6203 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6204 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6205 pce->label = _("_Exchange:"); |
5234 | 6206 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6207 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6208 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6209 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6210 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6211 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6212 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6213 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6214 |
8308 | 6215 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6216 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6217 aim_conn_t *cur; |
5234 | 6218 char *name, *exchange; |
6219 | |
6220 name = g_hash_table_lookup(data, "room"); | |
6221 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6222 |
8660 | 6223 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6224 "Attempting to join chat room %s.\n", name); |
8308 | 6225 |
6226 if ((name == NULL) || (*name == '\0')) { | |
6227 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6228 return; | |
6229 } | |
6230 | |
4617 | 6231 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6232 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6233 "chatnav exists, creating room\n"); |
5234 | 6234 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6235 } else { |
6236 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6237 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6238 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6239 "chatnav does not exist, opening chatnav\n"); |
5234 | 6240 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6241 cr->name = g_strdup(name); |
4617 | 6242 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6243 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6244 } |
6245 } | |
6246 | |
8308 | 6247 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6248 OscarData *od = (OscarData *)gc->proto_data; | |
6249 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6250 |
6251 if (!ccon) | |
6252 return; | |
6253 | |
8225 | 6254 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6255 ccon->exchange, ccon->name, 0x0); |
6256 } | |
6257 | |
8308 | 6258 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6259 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6260 GSList *bcs = gc->buddy_chats; | |
5679 | 6261 GaimConversation *b = NULL; |
2086 | 6262 struct chat_connection *c = NULL; |
6263 int count = 0; | |
6264 | |
6265 while (bcs) { | |
6266 count++; | |
5679 | 6267 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6268 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6269 break; |
6270 bcs = bcs->next; | |
6271 b = NULL; | |
6272 } | |
6273 | |
6274 if (!b) | |
6275 return; | |
6276 | |
8660 | 6277 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6278 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6279 |
8308 | 6280 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6281 if (c != NULL) { |
4617 | 6282 if (od) |
6283 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6284 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6285 gaim_input_remove(c->inpa); |
8308 | 6286 if (gc && od->sess) |
4617 | 6287 aim_conn_kill(od->sess, &c->conn); |
2086 | 6288 g_free(c->name); |
6289 g_free(c->show); | |
6290 g_free(c); | |
6291 } | |
6292 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6293 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6294 } |
6295 | |
8219 | 6296 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6297 OscarData *od = (OscarData *)gc->proto_data; | |
6298 GError *err = NULL; | |
6299 GaimConversation *conv = NULL; | |
2086 | 6300 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6301 char *buf, *buf2; |
8219 | 6302 char *charset = NULL; |
6303 int encoding; | |
8907 | 6304 gsize len; |
8219 | 6305 |
6306 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6307 return -EINVAL; |
2086 | 6308 |
8219 | 6309 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6310 return -EINVAL; |
2086 | 6311 |
8219 | 6312 buf = gaim_strdup_withhtml(message); |
6313 len = strlen(buf); | |
6314 | |
8962 | 6315 if (strstr(buf, "<IMG ")) |
6316 gaim_conversation_write(conv, "", | |
6317 _("Your IM Image was not sent. " | |
6318 "You cannot send IM Images in AIM chats."), | |
6319 GAIM_MESSAGE_ERROR, time(NULL)); | |
6320 | |
8219 | 6321 encoding = oscar_encoding_check(buf); |
8233 | 6322 if (encoding & AIM_IMFLAGS_UNICODE) { |
8660 | 6323 gaim_debug_info("oscar", "Sending Unicode chat\n"); |
8219 | 6324 charset = "unicode-2-0"; |
6325 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
6326 if (err) { | |
8660 | 6327 gaim_debug_error("oscar", |
8359 | 6328 "Error converting to unicode-2-0: %s\n", err->message); |
6329 g_error_free(err); | |
6330 } | |
8219 | 6331 } else if (encoding & AIM_IMFLAGS_ISO_8859_1) { |
8660 | 6332 gaim_debug_info("oscar", "Sending ISO-8859-1 chat\n"); |
8219 | 6333 charset = "iso-8859-1"; |
6334 buf2 = g_convert(buf, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); | |
6335 if (err) { | |
8660 | 6336 gaim_debug_error("oscar", |
8359 | 6337 "Error converting to iso-8859-1: %s\n", err->message); |
8219 | 6338 g_error_free(err); |
8359 | 6339 err = NULL; |
6340 | |
8660 | 6341 gaim_debug_info("oscar", "Falling back to Unicode\n"); |
8359 | 6342 charset = "unicode-2-0"; |
6343 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
8219 | 6344 if (err) { |
8660 | 6345 gaim_debug_error("oscar", |
8359 | 6346 "Error converting to unicode-2-0: %s\n", |
6347 err->message); | |
8219 | 6348 g_error_free(err); |
6349 } | |
2086 | 6350 } |
8219 | 6351 } else { |
6352 charset = "us-ascii"; | |
6353 buf2 = g_strdup(buf); | |
6354 } | |
8359 | 6355 g_free(buf); |
6356 | |
6357 if ((len > c->maxlen) || (len > c->maxvis)) { | |
6358 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6359 return -E2BIG; |
8359 | 6360 } |
6361 | |
6362 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charset, "en"); | |
8219 | 6363 g_free(buf2); |
8359 | 6364 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6365 return 0; |
2086 | 6366 } |
6367 | |
6695 | 6368 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6369 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6370 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 6371 return "icq"; |
6372 else | |
6373 return "aim"; | |
6374 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6375 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6376 if (b != NULL && isdigit(b->name[0])) |
4687 | 6377 return "icq"; |
6378 return "aim"; | |
6379 } | |
6380 | |
6695 | 6381 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 6382 { |
7334 | 6383 GaimAccount *account = NULL; |
6384 GaimConnection *gc = NULL; | |
6385 OscarData *od = NULL; | |
4687 | 6386 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6387 int i = 0; | |
7334 | 6388 aim_userinfo_t *userinfo = NULL; |
6389 | |
6390 if (b != NULL) | |
6391 account = b->account; | |
6392 if (account != NULL) | |
6393 gc = account->gc; | |
6394 if (gc != NULL) | |
6395 od = gc->proto_data; | |
7945 | 6396 if (od != NULL) |
6397 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6398 |
5131 | 6399 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6400 char *gname; | |
7334 | 6401 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6402 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6403 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6404 emblems[i++] = "notauthorized"; | |
6405 } else { | |
6406 emblems[i++] = "offline"; | |
6407 } | |
6408 } | |
4916 | 6409 |
4766 | 6410 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 6411 int uc = b->uc >> 16; |
4766 | 6412 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6413 emblems[i++] = "invisible"; |
4766 | 6414 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6415 emblems[i++] = "freeforchat"; |
4766 | 6416 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6417 emblems[i++] = "dnd"; |
4766 | 6418 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6419 emblems[i++] = "na"; |
4766 | 6420 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6421 emblems[i++] = "occupied"; |
4766 | 6422 else if (uc & AIM_ICQ_STATE_AWAY) |
6423 emblems[i++] = "away"; | |
6424 } else { | |
6425 if (b->uc & UC_UNAVAILABLE) | |
6426 emblems[i++] = "away"; | |
6427 } | |
4687 | 6428 if (b->uc & UC_WIRELESS) |
6429 emblems[i++] = "wireless"; | |
6430 if (b->uc & UC_AOL) | |
6431 emblems[i++] = "aol"; | |
6432 if (b->uc & UC_ADMIN) | |
6433 emblems[i++] = "admin"; | |
6434 if (b->uc & UC_AB && i < 4) | |
6435 emblems[i++] = "activebuddy"; | |
4766 | 6436 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6437 emblems[i++] = "unconfirmed"; */ | |
7334 | 6438 |
7945 | 6439 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6440 emblems[i++] = "hiptop"; | |
6441 | |
6442 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6443 emblems[i++] = "secure"; |
6444 | |
4687 | 6445 *se = emblems[0]; |
6446 *sw = emblems[1]; | |
6447 *nw = emblems[2]; | |
6448 *ne = emblems[3]; | |
6449 } | |
6450 | |
6695 | 6451 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6452 GaimConnection *gc = b->account->gc; |
7283 | 6453 OscarData *od = gc->proto_data; |
7045 | 6454 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6455 GString *str = g_string_new(""); |
5131 | 6456 |
6457 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6458 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6459 |
6460 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6461 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6462 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6463 g_free(charset); |
7011 | 6464 if (away_utf8 != NULL) { |
7091 | 6465 gchar *tmp1, *tmp2; |
9627 | 6466 /* tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); This replacement is handled in strip_html. |
6467 * g_free(away_utf8); | |
6468 */ | |
6469 tmp2 = gaim_markup_strip_html(away_utf8); | |
8341 | 6470 g_free(away_utf8); |
8571 | 6471 tmp1 = gaim_escape_html(tmp2); |
7091 | 6472 g_free(tmp2); |
8700 | 6473 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6474 g_free(tmp1); |
8701 | 6475 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
9627 | 6476 |
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 |
7650 | 6805 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { |
9030 | 6806 act = gaim_blist_node_action_new(_("Send File"), |
6807 oscar_ask_sendfile, NULL); | |
6808 m = g_list_append(m, act); | |
7650 | 6809 } |
7011 | 6810 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6811 act = gaim_blist_node_action_new(_("Get File"), |
6812 oscar_ask_getfile, NULL); | |
6813 m = g_list_append(m, act); | |
5917 | 6814 } |
4826 | 6815 #endif |
4333 | 6816 } |
5131 | 6817 } |
5197 | 6818 |
5131 | 6819 if (od->sess->ssi.received_data) { |
9030 | 6820 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6821 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
6822 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
6823 gaim_auth_sendrequest_menu, NULL); | |
6824 m = g_list_append(m, act); | |
4333 | 6825 } |
4916 | 6826 } |
6827 | |
4333 | 6828 return m; |
6829 } | |
6830 | |
9030 | 6831 |
6832 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6833 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6834 return oscar_buddy_menu((GaimBuddy *) node); | |
6835 } else { | |
6836 return NULL; | |
6837 } | |
6838 } | |
6839 | |
6840 | |
5575 | 6841 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6842 OscarData *od = gc->proto_data; |
5575 | 6843 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6844 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6845 od->setnick = TRUE; | |
6846 od->newsn = g_strdup(nick); | |
6847 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6848 } else { | |
6849 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6850 } | |
6851 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6852 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6853 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6854 } |
6855 } | |
6856 | |
9015 | 6857 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 6858 { |
9015 | 6859 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 6860 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 6861 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6862 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6863 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6864 gc); |
4333 | 6865 } |
6866 | |
9015 | 6867 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 6868 { |
9015 | 6869 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6870 OscarData *od = gc->proto_data; |
4333 | 6871 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6872 | |
6873 if (conn) { | |
6874 aim_admin_reqconfirm(od->sess, conn); | |
6875 } else { | |
6876 od->conf = TRUE; | |
6877 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6878 } | |
6879 } | |
6880 | |
9015 | 6881 static void oscar_show_email(GaimPluginAction *action) |
4333 | 6882 { |
9015 | 6883 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6884 OscarData *od = gc->proto_data; |
4333 | 6885 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6886 | |
6887 if (conn) { | |
6888 aim_admin_getinfo(od->sess, conn, 0x11); | |
6889 } else { | |
6890 od->reqemail = TRUE; | |
6891 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6892 } | |
6893 } | |
6894 | |
5575 | 6895 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6896 { |
7283 | 6897 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6898 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
|
6899 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6900 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6901 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6902 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6903 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6904 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6905 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6906 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6907 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6908 |
9015 | 6909 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 6910 { |
9015 | 6911 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6912 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 6913 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6914 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6915 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6916 gc); |
4333 | 6917 } |
6918 | |
9015 | 6919 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 6920 { |
9015 | 6921 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6922 OscarData *od = gc->proto_data; |
4333 | 6923 gchar *nombre, *text, *tmp; |
6695 | 6924 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 6925 int num=0; |
6926 | |
6873 | 6927 text = g_strdup(""); |
4333 | 6928 |
4785 | 6929 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 6930 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 6931 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
6932 continue; | |
6695 | 6933 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
6934 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 6935 continue; |
6695 | 6936 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
6937 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
6938 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6939 continue; | |
6940 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 6941 if (gaim_buddy_get_alias_only(buddy)) |
6942 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 6943 else |
6944 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 6945 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 6946 g_free(text); |
6947 text = tmp; | |
6948 g_free(nombre); | |
6949 num++; | |
6950 } | |
4333 | 6951 } |
2979 | 6952 } |
4333 | 6953 } |
6954 | |
6955 if (!num) { | |
6956 g_free(text); | |
6873 | 6957 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
6958 } | |
6959 | |
6960 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
6961 "the following buddies"), _("You can re-request " | |
6962 "authorization from these buddies by " | |
6963 "right-clicking on them and selecting " | |
6964 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 6965 g_free(text); |
2979 | 6966 } |
6967 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6968 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6969 { |
8950 | 6970 OscarData *od = (OscarData *)gc->proto_data; |
6971 | |
6972 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6973 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6974 |
9015 | 6975 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6976 { |
9015 | 6977 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6978 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6979 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6980 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6981 "searching for."), |
8697 | 6982 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6983 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6984 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6985 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6986 |
7366 | 6987 #if 0 |
5917 | 6988 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 6989 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 6990 |
7334 | 6991 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 6992 aim_srv_setavailmsg(od->sess, text); |
6993 } | |
6994 | |
6995 static void oscar_show_setavailmsg(GaimConnection *gc) | |
6996 { | |
7313 | 6997 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
6998 _("I'm doing work and hoping for a distraction--IM me!"), | |
8697 | 6999 TRUE, FALSE, NULL, |
5917 | 7000 _("OK"), G_CALLBACK(oscar_setavailmsg), |
7001 _("Cancel"), NULL, | |
7002 gc); | |
7003 } | |
7366 | 7004 #endif |
5917 | 7005 |
9015 | 7006 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7007 { |
9015 | 7008 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7009 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7010 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7011 |
9015 | 7012 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7013 { |
9015 | 7014 GaimConnection *gc = (GaimConnection *) action->context; |
8576 | 7015 gaim_notify_uri(gc, "http://web.icq.com/whitepages/login/1,,,00.html"); |
7016 } | |
7017 | |
9015 | 7018 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7019 { |
9015 | 7020 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7021 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7022 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7023 |
9015 | 7024 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7025 { |
9015 | 7026 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7027 OscarData *od = gc->proto_data; |
5575 | 7028 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
|
7029 gaim_notify_uri(gc, substituted); |
5517 | 7030 g_free(substituted); |
4333 | 7031 } |
7032 | |
9015 | 7033 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7034 { |
9015 | 7035 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7036 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7037 } | |
7038 | |
5842 | 7039 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7040 { | |
7283 | 7041 OscarData *od = gc->proto_data; |
5844 | 7042 aim_session_t *sess = od->sess; |
5842 | 7043 FILE *file; |
7044 struct stat st; | |
5844 | 7045 |
6039 | 7046 if (iconfile == NULL) { |
8363 | 7047 aim_ssi_delicon(od->sess); |
6039 | 7048 } else if (!stat(iconfile, &st)) { |
5842 | 7049 char *buf = g_malloc(st.st_size); |
7050 file = fopen(iconfile, "rb"); | |
7051 if (file) { | |
6052 | 7052 md5_state_t *state; |
6039 | 7053 char md5[16]; |
9532 | 7054 /* XXX - Use g_file_get_contents()? */ |
5842 | 7055 int len = fread(buf, 1, st.st_size, file); |
6039 | 7056 fclose(file); |
6052 | 7057 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7058 md5_init(state); |
7059 md5_append(state, buf, len); | |
7060 md5_finish(state, md5); | |
7061 g_free(state); | |
7062 aim_ssi_seticon(sess, md5, 16); | |
7063 } else | |
8660 | 7064 gaim_debug_error("oscar", |
5842 | 7065 "Can't open buddy icon file!\n"); |
7066 g_free(buf); | |
7067 } else | |
8660 | 7068 gaim_debug_error("oscar", |
5842 | 7069 "Can't stat buddy icon file!\n"); |
7070 } | |
7071 | |
7072 | |
9015 | 7073 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7074 { |
9015 | 7075 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7076 OscarData *od = gc->proto_data; |
4333 | 7077 GList *m = NULL; |
9015 | 7078 GaimPluginAction *act; |
7079 | |
7080 act = gaim_plugin_action_new(_("Set User Info..."), | |
7081 oscar_show_set_info); | |
7082 m = g_list_append(m, act); | |
4333 | 7083 |
8576 | 7084 if (od->icq) { |
9015 | 7085 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7086 oscar_show_set_info_icqurl); | |
7087 m = g_list_append(m, act); | |
8576 | 7088 } |
7089 | |
7366 | 7090 #if 0 |
9015 | 7091 act = gaim_plugin_action_new(_("Set Available Message..."), |
7092 oscar_show_setavailmsg); | |
7093 m = g_list_append(m, act); | |
7366 | 7094 #endif |
5917 | 7095 |
9015 | 7096 act = gaim_plugin_action_new(_("Change Password..."), |
7097 oscar_change_pass); | |
7098 m = g_list_append(m, act); | |
4617 | 7099 |
7100 if (od->sess->authinfo->chpassurl) { | |
9015 | 7101 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7102 oscar_show_chpassurl); | |
7103 m = g_list_append(m, act); | |
7104 | |
7105 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7106 oscar_show_imforwardingurl); | |
7107 m = g_list_append(m, act); | |
7026 | 7108 } |
7109 | |
5238 | 7110 if (!od->icq) { |
4617 | 7111 /* AIM actions */ |
7112 m = g_list_append(m, NULL); | |
4333 | 7113 |
9015 | 7114 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7115 oscar_show_format_screenname); | |
7116 m = g_list_append(m, act); | |
7117 | |
7118 act = gaim_plugin_action_new(_("Confirm Account"), | |
7119 oscar_confirm_account); | |
7120 m = g_list_append(m, act); | |
7121 | |
7122 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7123 oscar_show_email); | |
7124 m = g_list_append(m, act); | |
7125 | |
7126 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7127 oscar_show_change_email); | |
7128 m = g_list_append(m, act); | |
2086 | 7129 } |
4333 | 7130 |
7131 m = g_list_append(m, NULL); | |
7132 | |
9015 | 7133 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7134 oscar_show_awaitingauth); | |
7135 m = g_list_append(m, act); | |
4333 | 7136 |
2086 | 7137 m = g_list_append(m, NULL); |
4333 | 7138 |
9015 | 7139 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7140 oscar_show_find_email); | |
7141 m = g_list_append(m, act); | |
4333 | 7142 |
8591 | 7143 #if 0 |
9015 | 7144 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7145 show_find_info); | |
7146 m = g_list_append(m, act); | |
8591 | 7147 #endif |
2086 | 7148 |
7149 return m; | |
7150 } | |
7151 | |
5575 | 7152 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7153 { |
7283 | 7154 OscarData *od = gc->proto_data; |
4617 | 7155 |
7156 if (od->icq) { | |
7157 aim_icq_changepasswd(od->sess, new); | |
2086 | 7158 } else { |
4617 | 7159 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7160 if (conn) { | |
7161 aim_admin_changepasswd(od->sess, conn, new, old); | |
7162 } else { | |
7163 od->chpass = TRUE; | |
7164 od->oldp = g_strdup(old); | |
7165 od->newp = g_strdup(new); | |
7166 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7167 } | |
2086 | 7168 } |
7169 } | |
7170 | |
6059 | 7171 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7172 { |
7283 | 7173 OscarData *od = gc->proto_data; |
8971 | 7174 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
|
7175 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7176 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7177 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7178 |
8971 | 7179 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7180 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7181 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7182 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7183 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7184 GAIM_PRPL_API_VERSION, |
9308 | 7185 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7186 NULL, /* user_splits */ |
7187 NULL, /* protocol_options */ | |
7188 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7189 oscar_list_icon, /* list_icon */ | |
7190 oscar_list_emblems, /* list_emblems */ | |
7191 oscar_status_text, /* status_text */ | |
7192 oscar_tooltip_text, /* tooltip_text */ | |
7193 oscar_away_states, /* away_states */ | |
7194 oscar_blist_node_menu, /* blist_node_menu */ | |
7195 oscar_chat_info, /* chat_info */ | |
7196 oscar_login, /* login */ | |
7197 oscar_close, /* close */ | |
7198 oscar_send_im, /* send_im */ | |
7199 oscar_set_info, /* set_info */ | |
7200 oscar_send_typing, /* send_typing */ | |
7201 oscar_get_info, /* get_info */ | |
7202 oscar_set_away, /* set_away */ | |
7203 oscar_set_idle, /* set_idle */ | |
7204 oscar_change_passwd, /* change_passwd */ | |
7205 oscar_add_buddy, /* add_buddy */ | |
7206 oscar_add_buddies, /* add_buddies */ | |
7207 oscar_remove_buddy, /* remove_buddy */ | |
7208 oscar_remove_buddies, /* remove_buddies */ | |
7209 oscar_add_permit, /* add_permit */ | |
7210 oscar_add_deny, /* add_deny */ | |
7211 oscar_rem_permit, /* rem_permit */ | |
7212 oscar_rem_deny, /* rem_deny */ | |
7213 oscar_set_permit_deny, /* set_permit_deny */ | |
7214 oscar_warn, /* warn */ | |
7215 oscar_join_chat, /* join_chat */ | |
7216 NULL, /* reject_chat */ | |
7217 oscar_chat_invite, /* chat_invite */ | |
7218 oscar_chat_leave, /* chat_leave */ | |
7219 NULL, /* chat_whisper */ | |
7220 oscar_send_chat, /* chat_send */ | |
7221 oscar_keepalive, /* keepalive */ | |
7222 NULL, /* register_user */ | |
7223 NULL, /* get_cb_info */ | |
7224 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7225 #ifndef NOSSI |
9475 | 7226 oscar_alias_buddy, /* alias_buddy */ |
7227 oscar_move_buddy, /* group_buddy */ | |
7228 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7229 #else |
9475 | 7230 NULL, /* alias_buddy */ |
7231 NULL, /* group_buddy */ | |
7232 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7233 #endif |
9475 | 7234 NULL, /* buddy_free */ |
7235 oscar_convo_closed, /* convo_closed */ | |
7236 NULL, /* normalize */ | |
7237 oscar_set_icon, /* set_buddy_icon */ | |
7238 NULL, /* remove_group */ | |
7239 NULL, /* get_cb_real_name */ | |
7240 NULL, /* set_chat_topic */ | |
7241 NULL, /* find_blist_chat */ | |
7242 NULL, /* roomlist_get_list */ | |
7243 NULL, /* roomlist_cancel */ | |
7244 NULL, /* roomlist_expand_category */ | |
7245 oscar_can_receive_file, /* can_receive_file */ | |
7246 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7247 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7248 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7249 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7250 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7251 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7252 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7253 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7254 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7255 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7256 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7257 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7258 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7259 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7260 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7261 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7262 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7263 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7264 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7265 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7266 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7267 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7268 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7269 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7270 NULL, /**< destroy */ |
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 NULL, /**< ui_info */ |
8993 | 7273 &prpl_info, /**< extra_info */ |
7274 NULL, | |
9015 | 7275 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7276 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7277 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7278 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7279 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7280 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7281 GaimAccountOption *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_string_new(_("Auth host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7284 "login.oscar.aol.com"); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7285 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7286 option); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7287 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7288 option = gaim_account_option_int_new(_("Auth port"), "port", 5190); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7289 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7290 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7291 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7292 my_protocol = plugin; |
2086 | 7293 } |
7294 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7295 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |