Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 9936:3578cec797db
[gaim-migrate @ 10828]
<faceprint> KingAnt: &= ~0x00400000 would have been a little more straightforward
It doesn't actually disable the recent buddies group.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 02 Sep 2004 12:14:11 +0000 |
parents | bb0c04ebcdef |
children | 3941c39ccff5 |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
6 * Some code copyright (C) 2001-2003, Sean Egan | |
8151 | 7 * Some code copyright (C) 2001-2004, Mark Doliner <thekingant@users.sourceforge.net> |
6302 | 8 * |
9 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 10 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 11 * |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 * | |
26 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
31 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
32 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
33 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "ft.h" |
6982 | 36 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
37 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
38 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "privacy.h" |
2086 | 40 #include "prpl.h" |
4889 | 41 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
42 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 |
2086 | 45 #include "aim.h" |
5842 | 46 #include "md5.h" |
2086 | 47 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
48 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
49 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
50 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
51 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
52 #define UC_AB 0x20 |
3079 | 53 #define UC_WIRELESS 0x40 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
54 |
2086 | 55 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
56 | |
7283 | 57 #define OSCAR_CONNECT_STEPS 6 |
9830 | 58 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 59 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
60 static GaimPlugin *my_protocol = NULL; |
4249 | 61 |
7376 | 62 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
63 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 64 |
4665 | 65 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
66 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 67 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 68 |
7283 | 69 typedef struct _OscarData OscarData; |
70 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
71 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
72 aim_conn_t *conn; |
2086 | 73 |
74 guint cnpa; | |
75 guint paspa; | |
3694 | 76 guint emlpa; |
4804 | 77 guint icopa; |
2086 | 78 |
4823 | 79 gboolean iconconnecting; |
5842 | 80 gboolean set_icon; |
4823 | 81 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
82 GSList *create_rooms; |
2086 | 83 |
84 gboolean conf; | |
85 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
86 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
87 char *email; |
2979 | 88 gboolean setnick; |
89 char *newsn; | |
2086 | 90 gboolean chpass; |
91 char *oldp; | |
92 char *newp; | |
5842 | 93 |
2086 | 94 GSList *oscar_chats; |
95 GSList *direct_ims; | |
3630 | 96 GSList *file_transfers; |
4738 | 97 GHashTable *buddyinfo; |
4804 | 98 GSList *requesticon; |
2086 | 99 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
100 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
101 gboolean icq; |
4804 | 102 guint icontimer; |
5968 | 103 guint getblisttimer; |
8341 | 104 guint getinfotimer; |
2993 | 105 |
106 struct { | |
4230 | 107 guint maxwatchers; /* max users who can watch you */ |
2993 | 108 guint maxbuddies; /* max users you can watch */ |
4230 | 109 guint maxgroups; /* max groups in server list */ |
2993 | 110 guint maxpermits; /* max users on permit list */ |
111 guint maxdenies; /* max users on deny list */ | |
112 guint maxsiglen; /* max size (bytes) of profile */ | |
113 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
114 } rights; | |
2086 | 115 }; |
116 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
117 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
118 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
119 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
120 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
121 |
2086 | 122 struct chat_connection { |
123 char *name; | |
124 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
125 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
126 fu16_t instance; |
2086 | 127 int fd; /* this is redundant since we have the conn below */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
128 aim_conn_t *conn; |
2086 | 129 int inpa; |
130 int id; | |
5575 | 131 GaimConnection *gc; /* i hate this. */ |
8733 | 132 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
133 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
134 int maxvis; |
2086 | 135 }; |
136 | |
8971 | 137 struct oscar_direct_im { |
5575 | 138 GaimConnection *gc; |
2086 | 139 char name[80]; |
140 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
141 aim_conn_t *conn; |
3008 | 142 gboolean connected; |
8978 | 143 gboolean gpc_pend; |
144 gboolean killme; | |
8984 | 145 gboolean donttryagain; |
2086 | 146 }; |
147 | |
148 struct ask_direct { | |
5575 | 149 GaimConnection *gc; |
2086 | 150 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
151 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
152 fu8_t cookie[8]; |
8984 | 153 gboolean donttryagain; |
2086 | 154 }; |
155 | |
7011 | 156 /* |
157 * Various PRPL-specific buddy info that we want to keep track of | |
158 * Some other info is maintained by locate.c, and I'd like to move | |
159 * the rest of this to libfaim, mostly im.c | |
160 */ | |
4738 | 161 struct buddyinfo { |
162 gboolean typingnot; | |
6292 | 163 gchar *availmsg; |
6857 | 164 fu32_t ipaddr; |
5836 | 165 |
166 unsigned long ico_me_len; | |
167 unsigned long ico_me_csum; | |
168 time_t ico_me_time; | |
169 gboolean ico_informed; | |
4738 | 170 |
171 unsigned long ico_len; | |
172 unsigned long ico_csum; | |
173 time_t ico_time; | |
174 gboolean ico_need; | |
7406 | 175 gboolean ico_sent; |
2086 | 176 }; |
177 | |
4230 | 178 struct name_data { |
5575 | 179 GaimConnection *gc; |
4230 | 180 gchar *name; |
3453 | 181 gchar *nick; |
3141 | 182 }; |
183 | |
5129 | 184 static char *msgerrreason[] = { |
185 N_("Invalid error"), | |
186 N_("Invalid SNAC"), | |
187 N_("Rate to host"), | |
188 N_("Rate to client"), | |
189 N_("Not logged in"), | |
190 N_("Service unavailable"), | |
191 N_("Service not defined"), | |
192 N_("Obsolete SNAC"), | |
193 N_("Not supported by host"), | |
194 N_("Not supported by client"), | |
195 N_("Refused by client"), | |
196 N_("Reply too big"), | |
197 N_("Responses lost"), | |
198 N_("Request denied"), | |
199 N_("Busted SNAC payload"), | |
200 N_("Insufficient rights"), | |
201 N_("In local permit/deny"), | |
202 N_("Too evil (sender)"), | |
203 N_("Too evil (receiver)"), | |
204 N_("User temporarily unavailable"), | |
205 N_("No match"), | |
206 N_("List overflow"), | |
207 N_("Request ambiguous"), | |
208 N_("Queue full"), | |
209 N_("Not while on AOL") | |
210 }; | |
211 static int msgerrreasonlen = 25; | |
212 | |
213 /* All the libfaim->gaim callback functions */ | |
214 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
215 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
216 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
217 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
218 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
219 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
220 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
221 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 224 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 225 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 226 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
227 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
228 static int gaim_conv_chat_join (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
229 static int gaim_conv_chat_leave (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
230 static int gaim_conv_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
231 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 232 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
233 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 235 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 236 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
237 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
238 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
240 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
241 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
242 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
243 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
244 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
245 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
246 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
247 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
248 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
263 #ifndef NOSSI | |
264 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 268 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 269 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
270 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
273 #endif | |
274 | |
275 /* for DirectIM/image transfer */ | |
276 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 279 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 280 |
281 /* for file transfer */ | |
282 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
283 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
284 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
285 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
286 | |
287 /* for icons */ | |
288 static gboolean gaim_icon_timerfunc(gpointer data); | |
289 | |
8971 | 290 /* just because */ |
291 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); | |
8983 | 292 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
8971 | 293 |
8076 | 294 /* remove these at some point? */ |
7282 | 295 /* Because I don't like forward declarations? I think that was why... */ |
5954 | 296 static void oscar_set_info(GaimConnection *gc, const char *text); |
8076 | 297 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message); |
5306 | 298 |
9935 | 299 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
300 | |
5836 | 301 static void oscar_free_name_data(struct name_data *data) { |
4230 | 302 g_free(data->name); |
303 g_free(data->nick); | |
304 g_free(data); | |
305 } | |
306 | |
5836 | 307 static void oscar_free_buddyinfo(void *data) { |
308 struct buddyinfo *bi = data; | |
6292 | 309 g_free(bi->availmsg); |
5836 | 310 g_free(bi); |
311 } | |
312 | |
9807 | 313 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 314 { |
315 int i = 0; | |
9826 | 316 int charset = AIM_CHARSET_ASCII; |
5129 | 317 |
318 /* Determine how we can send this message. Per the warnings elsewhere | |
319 * in this file, these little checks determine the simplest encoding | |
320 * we can use for a given message send using it. */ | |
321 while (utf8[i]) { | |
322 if ((unsigned char)utf8[i] > 0x7f) { | |
323 /* not ASCII! */ | |
9826 | 324 charset = AIM_CHARSET_CUSTOM; |
5129 | 325 break; |
326 } | |
327 i++; | |
328 } | |
329 while (utf8[i]) { | |
330 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
331 * followed by 0xc0-0xc3 in the second */ | |
332 if ((unsigned char)utf8[i] < 0x80) { | |
333 i++; | |
334 continue; | |
335 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
336 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
337 i += 2; | |
338 continue; | |
339 } | |
9826 | 340 charset = AIM_CHARSET_UNICODE; |
5129 | 341 break; |
342 } | |
343 | |
9807 | 344 return charset; |
5129 | 345 } |
346 | |
8225 | 347 /* |
348 * Take a string of the form charset="bleh" where bleh is | |
349 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
350 * return a newly allocated string containing bleh. | |
351 */ | |
352 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 353 { |
8225 | 354 gchar *ret = NULL; |
355 char *begin, *end; | |
356 | |
9933 | 357 g_return_val_if_fail(encoding != NULL, NULL); |
358 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
359 /* Make sure encoding begins with charset= */ |
8225 | 360 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
361 return NULL; | |
362 | |
363 begin = strchr(encoding, '"'); | |
364 end = strrchr(encoding, '"'); | |
365 | |
366 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
367 return NULL; | |
368 | |
369 ret = g_strndup(begin+1, (end-1) - begin); | |
370 | |
371 return ret; | |
372 } | |
373 | |
9830 | 374 static gchar * |
375 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 376 { |
377 gchar *utf8 = NULL; | |
9595 | 378 |
379 if ((encoding == NULL) || encoding[0] == '\0') { | |
380 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
381 | |
9639 | 382 } else if (!strcmp(encoding, "iso-8859-1") |
383 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 384 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
385 | |
386 } else if (!strcmp(encoding, "unicode-2-0")) { | |
387 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
388 | |
389 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
390 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
391 "attempting to convert to UTF-8 anyway\n"); | |
392 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
393 } | |
394 | |
395 /* | |
396 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
397 * we have been unable to convert the text to utf-8 from the encoding | |
398 * that was specified. So we check if the text is valid utf-8 then | |
399 * just copy it. | |
400 */ | |
401 if (utf8 == NULL) { | |
9638 | 402 if (textlen != 0 && *text != '\0' |
403 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 404 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 405 else |
9481 | 406 utf8 = g_strndup(text, textlen); |
5129 | 407 } |
408 | |
409 return utf8; | |
410 } | |
411 | |
9830 | 412 static gchar * |
9908 | 413 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 414 { |
415 gchar *ret = NULL; | |
416 GError *err = NULL; | |
417 | |
9908 | 418 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
419 return NULL; | |
420 | |
421 if (strcasecmp("UTF-8", charsetstr)) { | |
422 if (fallback) | |
423 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
424 else | |
425 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
426 if (err != NULL) { | |
427 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
428 charsetstr, err->message); | |
429 g_error_free(err); | |
430 } | |
431 } else { | |
432 if (g_utf8_validate(data, datalen, NULL)) | |
433 ret = g_strndup(data, datalen); | |
434 else | |
435 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
436 } | |
437 | |
438 return ret; | |
439 } | |
440 | |
441 /* | |
442 * We try decoding using two different character sets. The charset | |
443 * specified in the IM determines the order in which we attempt to | |
444 * decode. We do this because there are lots of broken ICQ clients | |
445 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
446 * able to deal with that crap, then people complain like banshees. | |
447 * charsetstr1 is always set to what the correct encoding should be. | |
448 */ | |
449 static gchar * | |
450 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
451 { | |
452 gchar *ret = NULL; | |
453 const gchar *charsetstr1, *charsetstr2; | |
454 | |
455 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 456 |
457 if ((datalen == 0) || (data == NULL)) | |
458 return NULL; | |
459 | |
9908 | 460 if (charset == AIM_CHARSET_UNICODE) { |
461 charsetstr1 = "UCS-2BE"; | |
462 charsetstr2 = "UTF-8"; | |
463 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9830 | 464 if ((sourcesn != NULL) && isdigit(sourcesn[0])) |
9908 | 465 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 466 else |
9908 | 467 charsetstr1 = "ISO-8859-1"; |
468 charsetstr2 = "UTF-8"; | |
469 } else if (charset == AIM_CHARSET_ASCII) { | |
470 /* Should just be "ASCII" */ | |
9914 | 471 charsetstr1 = "ASCII"; |
9908 | 472 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
473 } else if (charset == 0x000d) { | |
9830 | 474 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 475 charsetstr1 = "ISO-8859-1"; |
476 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
477 } else { | |
9830 | 478 /* Unknown, hope for valid UTF-8... */ |
9908 | 479 charsetstr1 = "UTF-8"; |
480 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
481 } | |
482 | |
483 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
484 if (ret == NULL) | |
485 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
486 if (ret == NULL) | |
487 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 488 |
489 return ret; | |
490 } | |
491 | |
492 static void | |
493 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
494 gchar **msg, int *msglen, | |
495 fu16_t *charset, fu16_t *charsubset) | |
496 { | |
497 OscarData *od = gc->proto_data; | |
498 GaimAccount *account = gaim_connection_get_account(gc); | |
499 GError *err = NULL; | |
500 aim_userinfo_t *userinfo = NULL; | |
501 const gchar *charsetstr; | |
502 | |
503 /* Attempt to send as ASCII */ | |
504 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, msglen, NULL); | |
505 if (*msg != NULL) { | |
506 *charset = AIM_CHARSET_ASCII; | |
507 *charsubset = 0x0000; | |
508 return; | |
509 } | |
510 | |
511 /* | |
9908 | 512 * If we're sending to an ICQ user, and they are advertising the |
513 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 514 */ |
515 if ((destsn != NULL) && isdigit(destsn[0])) | |
516 userinfo = aim_locate_finduserinfo(od->sess, destsn); | |
517 | |
518 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
9908 | 519 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, NULL); |
9830 | 520 if (*msg != NULL) { |
521 *charset = AIM_CHARSET_UNICODE; | |
522 *charsubset = 0x0000; | |
523 return; | |
524 } | |
525 } | |
526 | |
527 /* | |
528 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
529 * ICQ then attempt to send as the user specified character encoding. | |
530 */ | |
531 charsetstr = "ISO-8859-1"; | |
532 if ((destsn != NULL) && isdigit(destsn[0])) | |
533 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
534 | |
535 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, msglen, NULL); | |
536 if (*msg != NULL) { | |
537 *charset = AIM_CHARSET_CUSTOM; | |
538 *charsubset = 0x0000; | |
539 return; | |
540 } | |
541 | |
542 /* | |
543 * Nothing else worked, so send as UCS-2BE. | |
544 */ | |
545 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, &err); | |
546 if (*msg != NULL) { | |
547 *charset = AIM_CHARSET_UNICODE; | |
548 *charsubset = 0x0000; | |
549 return; | |
550 } | |
551 | |
9908 | 552 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 553 g_error_free(err); |
554 | |
555 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
556 *msg = g_strdup(from); | |
557 *msglen = strlen(*msg); | |
558 *charset = AIM_CHARSET_ASCII; | |
559 *charsubset = 0x0000; | |
560 return; | |
561 } | |
562 | |
9407 | 563 gchar *oscar_caps_to_string(guint caps) |
8701 | 564 { |
9407 | 565 GString *str; |
566 gchar *tmp; | |
8701 | 567 guint bit = 1; |
568 | |
9407 | 569 str = g_string_new(""); |
570 | |
8701 | 571 if (!caps) { |
572 return NULL; | |
573 } else while (bit <= AIM_CAPS_LAST) { | |
574 if (bit & caps) { | |
575 switch (bit) { | |
576 case AIM_CAPS_BUDDYICON: | |
577 tmp = _("Buddy Icon"); | |
578 break; | |
579 case AIM_CAPS_TALK: | |
580 tmp = _("Voice"); | |
581 break; | |
582 case AIM_CAPS_DIRECTIM: | |
583 tmp = _("AIM Direct IM"); | |
584 break; | |
585 case AIM_CAPS_CHAT: | |
586 tmp = _("Chat"); | |
587 break; | |
588 case AIM_CAPS_GETFILE: | |
589 tmp = _("Get File"); | |
590 break; | |
591 case AIM_CAPS_SENDFILE: | |
592 tmp = _("Send File"); | |
593 break; | |
594 case AIM_CAPS_GAMES: | |
595 case AIM_CAPS_GAMES2: | |
596 tmp = _("Games"); | |
597 break; | |
598 case AIM_CAPS_ADDINS: | |
599 tmp = _("Add-Ins"); | |
600 break; | |
601 case AIM_CAPS_SENDBUDDYLIST: | |
602 tmp = _("Send Buddy List"); | |
603 break; | |
604 case AIM_CAPS_ICQ_DIRECT: | |
605 tmp = _("ICQ Direct Connect"); | |
606 break; | |
607 case AIM_CAPS_APINFO: | |
608 tmp = _("AP User"); | |
609 break; | |
610 case AIM_CAPS_ICQRTF: | |
611 tmp = _("ICQ RTF"); | |
612 break; | |
613 case AIM_CAPS_EMPTY: | |
614 tmp = _("Nihilist"); | |
615 break; | |
616 case AIM_CAPS_ICQSERVERRELAY: | |
617 tmp = _("ICQ Server Relay"); | |
618 break; | |
619 case AIM_CAPS_ICQUTF8OLD: | |
620 tmp = _("Old ICQ UTF8"); | |
621 break; | |
622 case AIM_CAPS_TRILLIANCRYPT: | |
623 tmp = _("Trillian Encryption"); | |
624 break; | |
625 case AIM_CAPS_ICQUTF8: | |
626 tmp = _("ICQ UTF8"); | |
627 break; | |
628 case AIM_CAPS_HIPTOP: | |
629 tmp = _("Hiptop"); | |
630 break; | |
631 case AIM_CAPS_SECUREIM: | |
632 tmp = _("Security Enabled"); | |
633 break; | |
634 case AIM_CAPS_VIDEO: | |
635 tmp = _("Video Chat"); | |
636 break; | |
637 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
638 case AIM_CAPS_ICHATAV: | |
639 tmp = _("iChat AV"); | |
640 break; | |
641 case AIM_CAPS_LIVEVIDEO: | |
642 tmp = _("Live Video"); | |
643 break; | |
644 case AIM_CAPS_CAMERA: | |
645 tmp = _("Camera"); | |
646 break; | |
647 default: | |
648 tmp = NULL; | |
649 break; | |
650 } | |
651 if (tmp) | |
9532 | 652 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 653 } |
654 bit <<= 1; | |
655 } | |
9407 | 656 |
657 return g_string_free(str, FALSE); | |
8701 | 658 } |
659 | |
660 static char *oscar_icqstatus(int state) { | |
661 /* Make a cute little string that shows the status of the dude or dudet */ | |
662 if (state & AIM_ICQ_STATE_CHAT) | |
663 return g_strdup_printf(_("Free For Chat")); | |
664 else if (state & AIM_ICQ_STATE_DND) | |
665 return g_strdup_printf(_("Do Not Disturb")); | |
666 else if (state & AIM_ICQ_STATE_OUT) | |
667 return g_strdup_printf(_("Not Available")); | |
668 else if (state & AIM_ICQ_STATE_BUSY) | |
669 return g_strdup_printf(_("Occupied")); | |
670 else if (state & AIM_ICQ_STATE_AWAY) | |
671 return g_strdup_printf(_("Away")); | |
672 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
673 return g_strdup_printf(_("Web Aware")); | |
674 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
675 return g_strdup_printf(_("Invisible")); | |
676 else | |
677 return g_strdup_printf(_("Online")); | |
678 } | |
679 | |
680 static void oscar_string_append(GString *str, char *newline, char *name, char *value) | |
8700 | 681 { |
682 gchar *utf8; | |
683 | |
684 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 685 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 686 g_free(utf8); |
687 } | |
688 } | |
689 | |
8701 | 690 static void oscar_string_append_info(GaimConnection *gc, GString *str, char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
691 { | |
692 OscarData *od = gc->proto_data; | |
693 GaimAccount *account = gaim_connection_get_account(gc); | |
694 GaimGroup *g = NULL; | |
695 struct buddyinfo *bi = NULL; | |
696 char *tmp; | |
697 | |
698 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
699 return; | |
700 | |
701 if (userinfo == NULL) | |
702 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
703 | |
704 if (b == NULL) | |
705 b = gaim_find_buddy(gc->account, userinfo->sn); | |
706 | |
707 if (b != NULL) | |
708 g = gaim_find_buddys_group(b); | |
709 | |
710 if (userinfo != NULL) | |
711 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
712 | |
8733 | 713 if (b != NULL) { |
714 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
715 if (isdigit(b->name[0])) { | |
716 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
717 oscar_string_append(str, newline, _("Status"), tmp); | |
718 g_free(tmp); | |
719 } | |
720 } else { | |
9625 | 721 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 722 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
723 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
724 else | |
725 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 726 } |
8733 | 727 } |
8701 | 728 |
729 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 730 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 731 (bi->ipaddr & 0xff000000) >> 24, |
732 (bi->ipaddr & 0x00ff0000) >> 16, | |
733 (bi->ipaddr & 0x0000ff00) >> 8, | |
734 (bi->ipaddr & 0x000000ff)); | |
735 oscar_string_append(str, newline, _("IP Address"), tmp); | |
736 g_free(tmp); | |
737 } | |
738 | |
739 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
740 tmp = oscar_caps_to_string(userinfo->capabilities); | |
741 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 742 g_free(tmp); |
8701 | 743 } |
744 | |
745 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
746 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
747 if (tmp != NULL) { | |
9625 | 748 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 749 g_free(tmp); |
9625 | 750 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
751 g_free(tmp2); | |
8701 | 752 } |
753 } | |
754 | |
755 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
756 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
757 oscar_string_append(str, newline, _("Available"), tmp); | |
758 g_free(tmp); | |
759 } | |
760 } | |
761 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
762 static char *extract_name(const char *name) { |
4121 | 763 char *tmp, *x; |
2086 | 764 int i, j; |
4120 | 765 |
766 if (!name) | |
4121 | 767 return NULL; |
768 | |
4120 | 769 x = strchr(name, '-'); |
4121 | 770 |
2086 | 771 if (!x) return NULL; |
772 x = strchr(++x, '-'); | |
773 if (!x) return NULL; | |
774 tmp = g_strdup(++x); | |
775 | |
776 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
777 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
778 if (x[i] != '%') { |
2086 | 779 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
780 continue; |
2086 | 781 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
782 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
783 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
784 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 785 } |
786 | |
787 tmp[j] = 0; | |
788 return tmp; | |
789 } | |
790 | |
5575 | 791 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 792 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 793 struct chat_connection *c = NULL; |
794 | |
795 while (g) { | |
796 c = (struct chat_connection *)g->data; | |
797 if (c->id == id) | |
798 break; | |
799 g = g->next; | |
800 c = NULL; | |
801 } | |
802 | |
803 return c; | |
804 } | |
805 | |
5575 | 806 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
|
807 aim_conn_t *conn) { |
7283 | 808 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 809 struct chat_connection *c = NULL; |
810 | |
811 while (g) { | |
812 c = (struct chat_connection *)g->data; | |
813 if (c->conn == conn) | |
814 break; | |
815 g = g->next; | |
816 c = NULL; | |
817 } | |
818 | |
819 return c; | |
820 } | |
821 | |
8219 | 822 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
823 GaimConversation *conv) { | |
824 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
825 struct chat_connection *c = NULL; | |
826 | |
827 while (g) { | |
828 c = (struct chat_connection *)g->data; | |
8733 | 829 if (c->conv == conv) |
8219 | 830 break; |
831 g = g->next; | |
832 c = NULL; | |
833 } | |
834 | |
835 return c; | |
836 } | |
837 | |
8971 | 838 /***************************************************************************** |
839 * Begin scary direct im stuff | |
840 *****************************************************************************/ | |
841 | |
842 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
843 GSList *d = od->direct_ims; | |
844 struct oscar_direct_im *m = NULL; | |
845 | |
846 while (d) { | |
847 m = (struct oscar_direct_im *)d->data; | |
848 if (!aim_sncmp(who, m->name)) | |
849 return m; | |
850 d = d->next; | |
851 } | |
852 | |
853 return NULL; | |
854 } | |
855 | |
856 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
857 { | |
858 gaim_debug_info("oscar", | |
859 "destroying Direct IM for %s.\n", dim->name); | |
860 | |
861 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 862 if (dim->gpc_pend) { |
863 dim->killme = TRUE; | |
864 return; | |
865 } | |
8971 | 866 if (dim->watcher) |
867 gaim_input_remove(dim->watcher); | |
868 if (dim->conn) { | |
869 aim_conn_close(dim->conn); | |
870 aim_conn_kill(od->sess, &dim->conn); | |
871 } | |
872 g_free(dim); | |
873 } | |
874 | |
875 /* the only difference between this and destroy is this writes a conv message */ | |
876 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
877 { | |
878 GaimConversation *conv; | |
879 char buf[256]; | |
880 | |
881 gaim_debug_info("oscar", | |
882 "%s disconnected Direct IM.\n", dim->name); | |
883 | |
884 if (dim->connected) | |
885 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 886 else |
8971 | 887 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
888 | |
889 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
890 if (conv) { | |
891 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 892 gaim_conversation_update_progress(conv, 0); |
8971 | 893 } else { |
894 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
895 } | |
896 | |
897 oscar_direct_im_destroy(od, dim); | |
898 | |
899 return; | |
900 } | |
901 | |
902 /* oops i made two of these. this one just calls the other one. */ | |
903 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
904 { | |
905 GaimConnection *gc = sess->aux_data; | |
906 OscarData *od = (OscarData *)gc->proto_data; | |
907 struct oscar_direct_im *dim; | |
908 char *sn; | |
909 | |
910 sn = g_strdup(aim_odc_getsn(conn)); | |
911 dim = oscar_direct_im_find(od, sn); | |
912 oscar_direct_im_disconnect(od, dim); | |
913 g_free(sn); | |
914 } | |
915 | |
916 static void destroy_direct_im_request(struct ask_direct *d) { | |
917 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
918 | |
919 g_free(d->sn); | |
920 g_free(d); | |
921 } | |
922 | |
923 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
924 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
925 struct oscar_direct_im *dim = data; | |
926 GaimConnection *gc = dim->gc; | |
927 OscarData *od = gc->proto_data; | |
928 GaimConversation *conv; | |
929 char buf[256]; | |
930 struct sockaddr name; | |
931 socklen_t name_len = 1; | |
932 | |
933 g_return_if_fail(gc != NULL); | |
934 | |
8978 | 935 dim->gpc_pend = FALSE; |
936 if (dim->killme) { | |
937 oscar_direct_im_destroy(od, dim); | |
938 return; | |
939 } | |
940 | |
8971 | 941 if (!g_list_find(gaim_connections_get_all(), gc)) { |
942 oscar_direct_im_destroy(od, dim); | |
943 return; | |
944 } | |
945 | |
946 if (source < 0) { | |
8984 | 947 if (dim->donttryagain) { |
948 oscar_direct_im_disconnect(od, dim); | |
949 return; | |
950 } else { | |
951 fu8_t cookie[8]; | |
952 char *who = g_strdup(dim->name); | |
953 const char *tmp = aim_odc_getcookie(dim->conn); | |
954 | |
955 memcpy(cookie, tmp, 8); | |
956 oscar_direct_im_destroy(od, dim); | |
957 oscar_direct_im_initiate(gc, who, cookie); | |
958 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
959 g_free(who); | |
960 return; | |
961 } | |
8971 | 962 } |
963 | |
964 dim->conn->fd = source; | |
965 aim_conn_completeconnect(od->sess, dim->conn); | |
966 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
967 | |
968 /* This is the best way to see if we're connected or not */ | |
8983 | 969 /* Is this really needed? */ |
8971 | 970 if (getpeername(source, &name, &name_len) == 0) { |
971 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
972 dim->connected = TRUE; | |
973 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 974 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
975 } else { | |
8984 | 976 if (dim->donttryagain) { |
977 oscar_direct_im_disconnect(od, dim); | |
978 return; | |
979 } else { | |
980 fu8_t cookie[8]; | |
981 char *who = g_strdup(dim->name); | |
982 const char *tmp = aim_odc_getcookie(dim->conn); | |
983 | |
984 memcpy(cookie, tmp, 8); | |
985 oscar_direct_im_destroy(od, dim); | |
986 oscar_direct_im_initiate(gc, who, cookie); | |
987 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
988 g_free(who); | |
989 return; | |
990 } | |
8983 | 991 } |
992 | |
993 | |
8971 | 994 } |
995 | |
996 static void accept_direct_im_request(struct ask_direct *d) { | |
997 GaimConnection *gc = d->gc; | |
998 OscarData *od; | |
999 struct oscar_direct_im *dim; | |
1000 char *host; int port = 5190; | |
1001 int i, rc; | |
8982 | 1002 char *tmp; |
1003 GaimConversation *conv; | |
8971 | 1004 |
1005 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1006 destroy_direct_im_request(d); | |
1007 return; | |
1008 } | |
1009 | |
1010 od = (OscarData *)gc->proto_data; | |
1011 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1012 | |
1013 dim = oscar_direct_im_find(od, d->sn); | |
1014 if (dim && dim->connected) { | |
1015 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1016 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1017 return; | |
1018 } | |
1019 dim = g_new0(struct oscar_direct_im, 1); | |
1020 dim->gc = d->gc; | |
8984 | 1021 dim->donttryagain = d->donttryagain; |
8971 | 1022 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1023 | |
1024 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1025 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1026 if (!dim->conn) { | |
1027 oscar_direct_im_disconnect(od, dim); | |
1028 destroy_direct_im_request(d); | |
1029 return; | |
1030 } | |
1031 | |
1032 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1033 gaim_odc_incoming, 0); | |
1034 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1035 gaim_odc_typing, 0); | |
1036 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1037 gaim_odc_update_ui, 0); | |
1038 | |
1039 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1040 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1041 if (d->ip[i] == ':') { | |
1042 port = atoi(&(d->ip[i+1])); | |
1043 break; | |
1044 } | |
1045 } | |
1046 host = g_strndup(d->ip, i); | |
1047 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1048 dim->gpc_pend = TRUE; |
8971 | 1049 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1050 |
1051 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1052 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1053 port); | |
1054 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1055 g_free(tmp); | |
8983 | 1056 |
8971 | 1057 g_free(host); |
1058 if (rc < 0) { | |
8978 | 1059 dim->gpc_pend = FALSE; |
8971 | 1060 oscar_direct_im_disconnect(od, dim); |
1061 destroy_direct_im_request(d); | |
1062 return; | |
1063 } | |
1064 | |
1065 destroy_direct_im_request(d); | |
1066 | |
1067 return; | |
1068 } | |
1069 | |
1070 /* | |
1071 * We have just established a socket with the other dude, so set up some handlers. | |
1072 */ | |
1073 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1074 GaimConnection *gc = sess->aux_data; |
7283 | 1075 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1076 GaimConversation *conv; |
8971 | 1077 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1078 char buf[256]; |
8971 | 1079 char *sn; |
1080 va_list ap; | |
1081 aim_conn_t *newconn, *listenerconn; | |
1082 | |
1083 va_start(ap, fr); | |
1084 newconn = va_arg(ap, aim_conn_t *); | |
1085 listenerconn = va_arg(ap, aim_conn_t *); | |
1086 va_end(ap); | |
1087 | |
1088 aim_conn_close(listenerconn); | |
1089 aim_conn_kill(sess, &listenerconn); | |
1090 | |
1091 sn = g_strdup(aim_odc_getsn(newconn)); | |
1092 | |
1093 gaim_debug_info("oscar", | |
1094 "DirectIM: initiate success to %s\n", sn); | |
1095 dim = oscar_direct_im_find(od, sn); | |
1096 | |
1097 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1098 gaim_input_remove(dim->watcher); | |
1099 dim->conn = newconn; | |
1100 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1101 dim->connected = TRUE; | |
1102 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1103 g_free(sn); | |
1104 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1105 | |
1106 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1107 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1108 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1109 | |
1110 return 1; | |
1111 } | |
1112 | |
1113 /* | |
1114 * This is called when each chunk of an image is received. It can be used to | |
1115 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1116 * nasty, you sicko. | |
1117 */ | |
1118 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1119 va_list ap; | |
1120 char *sn; | |
1121 double percent; | |
1122 GaimConnection *gc = sess->aux_data; | |
1123 OscarData *od = (OscarData *)gc->proto_data; | |
1124 GaimConversation *c; | |
1125 struct oscar_direct_im *dim; | |
1126 | |
1127 va_start(ap, fr); | |
1128 sn = va_arg(ap, char *); | |
1129 percent = va_arg(ap, double); | |
1130 va_end(ap); | |
1131 | |
1132 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1133 return 1; | |
1134 if (dim->watcher) { | |
1135 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1136 /* The callback will callback? I don't get how that would happen here. */ | |
1137 dim->watcher = 0; | |
1138 } | |
1139 | |
1140 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
1141 if (c != NULL) | |
1142 gaim_conversation_update_progress(c, percent); | |
1143 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1144 oscar_callback, dim->conn); | |
1145 | |
1146 return 1; | |
1147 } | |
1148 | |
1149 /* | |
1150 * This is called after a direct IM has been received in its entirety. This | |
1151 * function is passed a long chunk of data which contains the IM with any | |
1152 * data chunks (images) appended to it. | |
1153 * | |
1154 * This function rips out all the data chunks and creates an imgstore for | |
1155 * each one. In order to do this, it first goes through the IM and takes | |
1156 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1157 * with one compatible with the imgstore Gaim core code. For each one, we | |
1158 * then read in chunks of data from the end of the message and actually | |
1159 * create the img store using the given data. | |
1160 * | |
1161 * For somewhat easy reference, here's a sample message | |
1162 * (without the whitespace and asterisks): | |
1163 * | |
1164 * <HTML><BODY BGCOLOR="#ffffff"> | |
1165 * <FONT LANG="0"> | |
1166 * This is a really stupid picture:<BR> | |
1167 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1168 * Yeah it is<BR> | |
1169 * Here is another one:<BR> | |
1170 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1171 * </FONT> | |
1172 * </BODY></HTML> | |
1173 * <BINARY> | |
1174 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1175 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1176 * </BINARY> | |
1177 */ | |
1178 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1179 GaimConnection *gc = sess->aux_data; | |
1180 GaimConvImFlags imflags = 0; | |
1181 gchar *utf8; | |
1182 GString *newmsg = g_string_new(""); | |
1183 GSList *images = NULL; | |
1184 va_list ap; | |
1185 const char *sn, *msg, *msgend, *binary; | |
1186 size_t len; | |
1187 int encoding, isawaymsg; | |
1188 | |
1189 va_start(ap, fr); | |
1190 sn = va_arg(ap, const char *); | |
1191 msg = va_arg(ap, const char *); | |
1192 len = va_arg(ap, size_t); | |
1193 encoding = va_arg(ap, int); | |
1194 isawaymsg = va_arg(ap, int); | |
1195 va_end(ap); | |
1196 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1197 |
8660 | 1198 gaim_debug_info("oscar", |
8971 | 1199 "Got DirectIM message from %s\n", sn); |
1200 | |
1201 if (isawaymsg) | |
1202 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1203 | |
1204 /* message has a binary trailer */ | |
1205 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1206 GData *attribs; | |
1207 const char *tmp, *start, *end, *last = NULL; | |
1208 | |
1209 tmp = msg; | |
1210 | |
1211 /* for each valid image tag... */ | |
1212 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1213 const char *id, *src, *datasize; | |
1214 const char *tag = NULL, *data = NULL; | |
1215 size_t size; | |
1216 int imgid = 0; | |
1217 | |
1218 /* update the location of the last img tag */ | |
1219 last = end; | |
1220 | |
1221 /* grab attributes */ | |
1222 id = g_datalist_get_data(&attribs, "id"); | |
1223 src = g_datalist_get_data(&attribs, "src"); | |
1224 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1225 | |
1226 /* if we have id & datasize, build the data tag */ | |
1227 if (id && datasize) | |
1228 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1229 | |
1230 /* if we have a tag, find the start of the data */ | |
1231 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1232 data += strlen(tag); | |
1233 | |
1234 /* check the data is here and store it */ | |
1235 if (data + (size = atoi(datasize)) <= msgend) | |
1236 imgid = gaim_imgstore_add(data, size, src); | |
1237 | |
1238 /* | |
1239 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1240 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1241 */ | |
1242 /* if we have a stored image... */ | |
1243 if (imgid) { | |
1244 /* append the message up to the tag */ | |
1245 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1246 if (utf8 != NULL) { | |
1247 newmsg = g_string_append(newmsg, utf8); | |
1248 g_free(utf8); | |
1249 } | |
1250 | |
1251 /* write the new image tag */ | |
1252 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1253 | |
1254 /* and record the image number */ | |
1255 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1256 } else { | |
1257 /* otherwise, copy up to the end of the tag */ | |
1258 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1259 if (utf8 != NULL) { | |
1260 newmsg = g_string_append(newmsg, utf8); | |
1261 g_free(utf8); | |
1262 } | |
1263 } | |
1264 | |
1265 /* clear the attribute list */ | |
1266 g_datalist_clear(&attribs); | |
1267 | |
1268 /* continue from the end of the tag */ | |
1269 tmp = end + 1; | |
1270 } | |
1271 | |
1272 /* append any remaining message data (without the > :-) */ | |
1273 if (last++ && (last < binary)) | |
1274 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1275 | |
1276 /* set the flag if we caught any images */ | |
1277 if (images) | |
1278 imflags |= GAIM_CONV_IM_IMAGES; | |
1279 } else { | |
1280 g_string_append_len(newmsg, msg, len); | |
1281 } | |
1282 | |
1283 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1284 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1285 | |
1286 /* free up the message */ | |
1287 g_string_free(newmsg, TRUE); | |
1288 | |
1289 /* unref any images we allocated */ | |
1290 if (images) { | |
1291 GSList *tmp; | |
1292 int id; | |
1293 | |
1294 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1295 id = GPOINTER_TO_INT(tmp->data); | |
1296 gaim_imgstore_unref(id); | |
1297 } | |
1298 | |
1299 g_slist_free(images); | |
1300 } | |
1301 | |
1302 return 1; | |
1303 } | |
1304 | |
1305 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1306 va_list ap; | |
1307 char *sn; | |
1308 int typing; | |
1309 GaimConnection *gc = sess->aux_data; | |
1310 | |
1311 va_start(ap, fr); | |
1312 sn = va_arg(ap, char *); | |
1313 typing = va_arg(ap, int); | |
1314 va_end(ap); | |
1315 | |
1316 if (typing == 0x0002) { | |
1317 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1318 gaim_debug_info("oscar", | |
1319 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1320 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1321 } else if (typing == 0x0001) | |
1322 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1323 else | |
1324 serv_got_typing_stopped(gc, sn); | |
1325 return 1; | |
1326 } | |
1327 | |
1328 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1329 char *buf; | |
1330 size_t len; | |
1331 int ret; | |
1332 GString *msg = g_string_new("<HTML><BODY>"); | |
1333 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1334 GData *attribs; | |
1335 const char *start, *end, *last; | |
1336 int oscar_id = 0; | |
1337 | |
1338 last = message; | |
1339 | |
1340 /* for each valid IMG tag... */ | |
1341 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1342 GaimStoredImage *image = NULL; | |
1343 const char *id; | |
1344 | |
1345 if (start - last) { | |
1346 g_string_append_len(msg, last, start - last); | |
1347 } | |
1348 | |
1349 id = g_datalist_get_data(&attribs, "id"); | |
1350 | |
1351 /* ... if it refers to a valid gaim image ... */ | |
1352 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1353 /* ... append the message from start to the tag ... */ | |
9126 | 1354 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1355 const char *filename = gaim_imgstore_get_filename(image); |
1356 gpointer imgdata = gaim_imgstore_get_data(image); | |
1357 | |
1358 oscar_id++; | |
1359 | |
1360 /* ... insert a new img tag with the oscar id ... */ | |
1361 if (filename) | |
1362 g_string_append_printf(msg, | |
9126 | 1363 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1364 filename, oscar_id, size); |
1365 else | |
1366 g_string_append_printf(msg, | |
9126 | 1367 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1368 oscar_id, size); |
1369 | |
1370 /* ... and append the data to the binary section ... */ | |
9126 | 1371 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1372 oscar_id, size); |
1373 data = g_string_append_len(data, imgdata, size); | |
1374 data = g_string_append(data, "</DATA>"); | |
1375 } | |
1376 /* If the tag is invalid, skip it, thus no else here */ | |
1377 | |
1378 g_datalist_clear(&attribs); | |
1379 | |
1380 /* continue from the end of the tag */ | |
1381 last = end + 1; | |
1382 } | |
1383 | |
1384 /* append any remaining message data (without the > :-) */ | |
1385 if (last && *last) | |
1386 msg = g_string_append(msg, last); | |
1387 | |
1388 /* if we inserted any images in the binary section, append it */ | |
1389 if (oscar_id) { | |
1390 msg = g_string_append_len(msg, data->str, data->len); | |
1391 msg = g_string_append(msg, "</BINARY>"); | |
1392 } | |
1393 | |
1394 len = msg->len; | |
1395 buf = msg->str; | |
1396 g_string_free(msg, FALSE); | |
1397 g_string_free(data, TRUE); | |
1398 | |
1399 | |
1400 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1401 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1402 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1403 else | |
1404 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1405 | |
1406 g_free(buf); | |
1407 | |
1408 return ret; | |
1409 } | |
1410 | |
1411 struct ask_do_dir_im { | |
1412 char *who; | |
1413 GaimConnection *gc; | |
1414 }; | |
1415 | |
1416 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1417 g_free(data->who); | |
1418 g_free(data); | |
1419 } | |
1420 | |
8983 | 1421 /* this function is used to initiate a direct im session with someone. |
1422 * we start listening on a port and send a request. they either connect | |
1423 * or send some kind of reply. If they can't connect, they ask us to | |
1424 * connect to them, and so we do that. | |
1425 * | |
1426 * this function will also get called if the other side initiate's a direct | |
1427 * im and we try to connect and fail. in that case cookie will not be null. | |
1428 * | |
1429 * note that cookie is an 8 byte string that isn't NULL terminated | |
1430 */ | |
1431 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1432 OscarData *od; |
1433 struct oscar_direct_im *dim; | |
1434 int listenfd; | |
8982 | 1435 const char *ip; |
8971 | 1436 |
1437 od = (OscarData *)gc->proto_data; | |
1438 | |
8983 | 1439 dim = oscar_direct_im_find(od, who); |
8971 | 1440 if (dim) { |
1441 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1442 oscar_direct_im_disconnect(od, dim); | |
1443 gaim_debug_info("oscar", | |
1444 "Gave up on old direct IM, trying again\n"); | |
1445 } else { | |
1446 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1447 return; |
8971 | 1448 } |
1449 } | |
1450 dim = g_new0(struct oscar_direct_im, 1); | |
1451 dim->gc = gc; | |
8983 | 1452 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1453 |
1454 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1455 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1456 if (listenfd >= 0) |
1457 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1458 if (dim->conn != NULL) { |
8982 | 1459 char *tmp; |
1460 GaimConversation *conv; | |
1461 | |
8971 | 1462 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1463 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1464 oscar_callback, dim->conn); | |
1465 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1466 gaim_odc_initiate, 0); | |
8982 | 1467 |
8983 | 1468 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1469 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1470 gaim_network_get_port_from_fd(listenfd)); |
1471 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1472 g_free(tmp); | |
8971 | 1473 } else { |
1474 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1475 oscar_direct_im_destroy(od, dim); | |
1476 } | |
8983 | 1477 } |
1478 | |
1479 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1480 GaimConnection *gc = data->gc; | |
1481 | |
1482 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1483 g_free(data->who); | |
1484 g_free(data); | |
1485 return; | |
1486 } | |
1487 | |
1488 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1489 g_free(data->who); |
1490 g_free(data); | |
1491 } | |
1492 | |
1493 /* this is the right click menu cb thingy */ | |
9030 | 1494 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1495 | |
1496 GaimBuddy *buddy; | |
1497 GaimConnection *gc; | |
8971 | 1498 gchar *buf; |
9030 | 1499 struct ask_do_dir_im *data; |
1500 | |
1501 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1502 | |
1503 buddy = (GaimBuddy *) node; | |
1504 gc = gaim_account_get_connection(buddy->account); | |
1505 | |
1506 data = g_new0(struct ask_do_dir_im, 1); | |
1507 data->who = g_strdup(buddy->name); | |
8971 | 1508 data->gc = gc; |
9030 | 1509 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1510 buddy->name); | |
8971 | 1511 |
1512 gaim_request_action(gc, NULL, buf, | |
9030 | 1513 _("Because this reveals your IP address, it " |
1514 "may be considered a privacy risk. Do you " | |
1515 "wish to continue?"), | |
1516 0, data, 2, | |
1517 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1518 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1519 g_free(buf); |
1520 } | |
1521 | |
1522 /***************************************************************************** | |
1523 * End scary direct im stuff | |
1524 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1525 |
4617 | 1526 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1527 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1528 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1529 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1530 OscarData *od; |
2086 | 1531 |
1532 if (!gc) { | |
8660 | 1533 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1534 "oscar callback for closed connection (1).\n"); |
2086 | 1535 return; |
1536 } | |
1537 | |
7283 | 1538 od = (OscarData *)gc->proto_data; |
2086 | 1539 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1540 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1541 /* oh boy. this is probably bad. i guess the only thing we |
1542 * can really do is return? */ | |
8660 | 1543 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1544 "oscar callback for closed connection (2).\n"); |
8660 | 1545 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1546 return; |
1547 } | |
1548 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1549 if (condition & GAIM_INPUT_READ) { |
4617 | 1550 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1551 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1552 "got information on rendezvous listener\n"); |
4617 | 1553 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1554 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1555 "connection error (rendezvous listener)\n"); |
4617 | 1556 aim_conn_kill(od->sess, &conn); |
8446 | 1557 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1558 } |
1559 } else { | |
4617 | 1560 if (aim_get_command(od->sess, conn) >= 0) { |
1561 aim_rxdispatch(od->sess); | |
6029 | 1562 if (od->killme) { |
8660 | 1563 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1564 return; |
1565 } | |
2086 | 1566 } else { |
1567 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1568 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1569 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1570 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1571 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1572 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1573 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1574 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1575 char *buf; |
8660 | 1576 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1577 "disconnected from chat room %s\n", c->name); |
2086 | 1578 c->conn = NULL; |
1579 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1580 gaim_input_remove(c->inpa); |
2086 | 1581 c->inpa = 0; |
1582 c->fd = -1; | |
4617 | 1583 aim_conn_kill(od->sess, &conn); |
5420 | 1584 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1585 if (conv) |
1586 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1587 else | |
1588 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1589 g_free(buf); |
2086 | 1590 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1591 if (od->cnpa > 0) |
1592 gaim_input_remove(od->cnpa); | |
1593 od->cnpa = 0; | |
8660 | 1594 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1595 "removing chatnav input watcher\n"); |
4617 | 1596 while (od->create_rooms) { |
1597 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1598 g_free(cr->name); |
4617 | 1599 od->create_rooms = |
1600 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1601 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1602 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1603 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1604 NULL); |
2086 | 1605 } |
4617 | 1606 aim_conn_kill(od->sess, &conn); |
2086 | 1607 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1608 if (od->paspa > 0) |
1609 gaim_input_remove(od->paspa); | |
1610 od->paspa = 0; | |
8660 | 1611 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1612 "removing authconn input watcher\n"); |
4617 | 1613 aim_conn_kill(od->sess, &conn); |
3694 | 1614 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1615 if (od->emlpa > 0) |
1616 gaim_input_remove(od->emlpa); | |
1617 od->emlpa = 0; | |
8660 | 1618 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1619 "removing email input watcher\n"); |
4617 | 1620 aim_conn_kill(od->sess, &conn); |
4804 | 1621 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1622 if (od->icopa > 0) | |
1623 gaim_input_remove(od->icopa); | |
1624 od->icopa = 0; | |
8660 | 1625 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1626 "removing icon input watcher\n"); |
4804 | 1627 aim_conn_kill(od->sess, &conn); |
2086 | 1628 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1629 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1630 gaim_odc_disconnect(od->sess, conn); |
1631 aim_conn_kill(od->sess, &conn); | |
2086 | 1632 } else { |
8660 | 1633 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1634 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1635 conn->type); |
4617 | 1636 aim_conn_kill(od->sess, &conn); |
2086 | 1637 } |
1638 } | |
1639 } | |
1640 } | |
1641 } | |
1642 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1643 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1644 GaimConnection *gc = sess->aux_data; |
7285 | 1645 gchar *s = g_strdup_vprintf(format, va); |
1646 gchar *buf; | |
1647 | |
1648 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1649 gaim_debug_info("oscar", buf); |
7285 | 1650 if (buf[strlen(buf)-1] != '\n') |
8660 | 1651 gaim_debug_info(NULL, "\n"); |
7285 | 1652 g_free(buf); |
2086 | 1653 g_free(s); |
1654 } | |
1655 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1656 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1657 { |
5575 | 1658 GaimConnection *gc = data; |
7283 | 1659 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1660 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1661 aim_conn_t *conn; |
2086 | 1662 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1663 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1664 close(source); |
1665 return; | |
1666 } | |
1667 | |
4617 | 1668 od = gc->proto_data; |
1669 sess = od->sess; | |
2086 | 1670 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1671 conn->fd = source; |
2086 | 1672 |
1673 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1674 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1675 return; |
1676 } | |
1677 | |
1678 aim_conn_completeconnect(sess, conn); | |
4617 | 1679 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1680 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1681 | |
8660 | 1682 gaim_debug_info("oscar", |
7282 | 1683 "Screen name sent, waiting for response\n"); |
7283 | 1684 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1685 ck[1] = 0x65; |
2086 | 1686 } |
1687 | |
5575 | 1688 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1689 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1690 aim_conn_t *conn; |
5575 | 1691 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1692 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1693 |
8660 | 1694 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1695 |
8437 | 1696 if (!aim_snvalid(gaim_account_get_username(account))) { |
1697 gchar *buf; | |
8590 | 1698 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 | 1699 gaim_connection_error(gc, buf); |
1700 g_free(buf); | |
1701 } | |
1702 | |
5575 | 1703 if (isdigit(*(gaim_account_get_username(account)))) { |
4617 | 1704 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1705 } else { |
6622 | 1706 gc->flags |= GAIM_CONNECTION_HTML; |
1707 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1708 } |
5836 | 1709 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1710 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1711 sess = g_new0(aim_session_t, 1); |
7285 | 1712 aim_session_init(sess, TRUE, 0); |
2086 | 1713 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1714 /* |
1715 * We need an immediate queue because we don't use a while-loop | |
1716 * to see if things need to be sent. | |
1717 */ | |
2086 | 1718 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1719 od->sess = sess; |
2086 | 1720 sess->aux_data = gc; |
1721 | |
9935 | 1722 /* Connect to core Gaim signals */ |
1723 gaim_prefs_connect_callback("/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); | |
1724 | |
2086 | 1725 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1726 if (conn == NULL) { | |
8660 | 1727 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1728 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1729 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1730 return; |
1731 } | |
1732 | |
4649 | 1733 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1734 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1735 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1736 | |
1737 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1738 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1739 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1740 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1741 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1742 return; |
1743 } | |
7282 | 1744 |
7283 | 1745 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1746 ck[0] = 0x5a; |
5575 | 1747 } |
1748 | |
1749 static void oscar_close(GaimConnection *gc) { | |
7283 | 1750 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1751 |
1752 while (od->oscar_chats) { | |
1753 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1754 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1755 gaim_input_remove(n->inpa); |
2086 | 1756 g_free(n->name); |
1757 g_free(n->show); | |
4617 | 1758 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1759 g_free(n); |
1760 } | |
4617 | 1761 while (od->direct_ims) { |
8971 | 1762 struct oscar_direct_im *n = od->direct_ims->data; |
1763 oscar_direct_im_destroy(od, n); | |
2086 | 1764 } |
4617 | 1765 /* BBB */ |
1766 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1767 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1768 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1769 gaim_xfer_cancel_local(xfer); |
3630 | 1770 } |
4804 | 1771 while (od->requesticon) { |
1772 char *sn = od->requesticon->data; | |
1773 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1774 free(sn); | |
1775 } | |
4738 | 1776 g_hash_table_destroy(od->buddyinfo); |
4617 | 1777 while (od->create_rooms) { |
1778 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1779 g_free(cr->name); |
4617 | 1780 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1781 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1782 } |
4617 | 1783 if (od->email) |
1784 g_free(od->email); | |
1785 if (od->newp) | |
1786 g_free(od->newp); | |
1787 if (od->oldp) | |
1788 g_free(od->oldp); | |
2086 | 1789 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1790 gaim_input_remove(gc->inpa); |
4617 | 1791 if (od->cnpa > 0) |
1792 gaim_input_remove(od->cnpa); | |
1793 if (od->paspa > 0) | |
1794 gaim_input_remove(od->paspa); | |
1795 if (od->emlpa > 0) | |
1796 gaim_input_remove(od->emlpa); | |
4804 | 1797 if (od->icopa > 0) |
1798 gaim_input_remove(od->icopa); | |
6907 | 1799 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1800 gaim_timeout_remove(od->icontimer); |
8341 | 1801 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1802 gaim_timeout_remove(od->getblisttimer); |
8341 | 1803 if (od->getinfotimer > 0) |
1804 gaim_timeout_remove(od->getinfotimer); | |
4617 | 1805 aim_session_kill(od->sess); |
1806 g_free(od->sess); | |
1807 od->sess = NULL; | |
2086 | 1808 g_free(gc->proto_data); |
1809 gc->proto_data = NULL; | |
8660 | 1810 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1811 } |
1812 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1813 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1814 GaimConnection *gc = data; |
7283 | 1815 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1816 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1817 aim_conn_t *bosconn; |
2086 | 1818 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1819 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1820 close(source); |
1821 return; | |
1822 } | |
1823 | |
4617 | 1824 od = gc->proto_data; |
1825 sess = od->sess; | |
1826 bosconn = od->conn; | |
4366 | 1827 bosconn->fd = source; |
2086 | 1828 |
1829 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1830 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1831 return; |
1832 } | |
1833 | |
1834 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1835 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1836 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1837 gaim_connection_update_progress(gc, |
7283 | 1838 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1839 ck[4] = 0x61; |
2086 | 1840 } |
1841 | |
4617 | 1842 /* BBB */ |
4656 | 1843 /* |
1844 * This little area in oscar.c is the nexus of file transfer code, | |
1845 * so I wrote a little explanation of what happens. I am such a | |
1846 * ninja. | |
1847 * | |
1848 * The series of events for a file send is: | |
1849 * -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
|
1850 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1851 * listening socket, then asks the remote user to connect to us (and |
1852 * gives them the file name, port, IP, etc.) | |
1853 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1854 * in oscar_sendfile_estblsh) | |
1855 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1856 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1857 * connection. | |
1858 * -We get drunk because file transfer kicks ass. | |
1859 * | |
1860 * The series of events for a file receive is: | |
1861 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1862 * -Gaim user selects file to name and location to save file to and | |
1863 * oscar_xfer_init is called | |
1864 * -It connects to the remote user using the IP they gave us earlier | |
1865 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1866 * them an AIM_CB_OFT_ACK. | |
1867 * -They begin to send us lots of raw data. | |
1868 * -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
|
1869 * the connection. |
4656 | 1870 */ |
1871 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1872 | |
8446 | 1873 /* |
1874 * Miscellaneous xfer functions | |
1875 */ | |
1876 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1877 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1878 GaimXfer *xfer; |
5146 | 1879 struct aim_oft_info *oft_info; |
4656 | 1880 |
1881 while (fts) { | |
1882 xfer = fts->data; | |
5146 | 1883 oft_info = xfer->data; |
1884 | |
8446 | 1885 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1886 return xfer; |
1887 | |
1888 fts = g_slist_next(fts); | |
1889 } | |
1890 | |
1891 return NULL; | |
1892 } | |
1893 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1894 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1895 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1896 GaimXfer *xfer; |
5146 | 1897 struct aim_oft_info *oft_info; |
4656 | 1898 |
1899 while (fts) { | |
1900 xfer = fts->data; | |
5146 | 1901 oft_info = xfer->data; |
1902 | |
1903 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1904 return xfer; |
1905 | |
1906 fts = g_slist_next(fts); | |
1907 } | |
1908 | |
1909 return NULL; | |
1910 } | |
1911 | |
8446 | 1912 static void oscar_xfer_end(GaimXfer *xfer) |
1913 { | |
1914 struct aim_oft_info *oft_info = xfer->data; | |
1915 GaimConnection *gc = oft_info->sess->aux_data; | |
1916 OscarData *od = gc->proto_data; | |
1917 | |
8660 | 1918 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1919 |
1920 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1921 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1922 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1923 } | |
1924 | |
1925 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1926 aim_oft_destroyinfo(oft_info); | |
1927 xfer->data = NULL; | |
1928 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1929 } | |
1930 | |
1931 /* | |
1932 * xfer functions used when receiving files | |
1933 */ | |
1934 | |
1935 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1936 { | |
1937 struct aim_oft_info *oft_info = xfer->data; | |
1938 GaimConnection *gc = oft_info->sess->aux_data; | |
1939 OscarData *od = gc->proto_data; | |
1940 | |
8660 | 1941 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1942 |
1943 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1944 if (oft_info->conn) { | |
1945 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1946 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1947 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1948 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1949 if (xfer->fd == -1) { | |
1950 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1951 _("Unable to establish file descriptor.")); | |
1952 gaim_xfer_cancel_local(xfer); | |
1953 } | |
1954 } else { | |
1955 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1956 _("Unable to create new connection.")); | |
1957 gaim_xfer_cancel_local(xfer); | |
1958 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1959 } | |
1960 | |
1961 } | |
1962 | |
1963 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1964 { | |
1965 struct aim_oft_info *oft_info = xfer->data; | |
1966 GaimConnection *gc = oft_info->sess->aux_data; | |
1967 OscarData *od = gc->proto_data; | |
1968 | |
8660 | 1969 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1970 |
9771 | 1971 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1972 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1973 |
1974 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1975 aim_oft_destroyinfo(oft_info); | |
1976 xfer->data = NULL; | |
1977 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1978 } | |
1979 | |
1980 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1981 { | |
1982 struct aim_oft_info *oft_info = xfer->data; | |
1983 | |
1984 /* Update our rolling checksum. Like Walmart, yo. */ | |
1985 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
1986 } | |
1987 | |
1988 /* | |
1989 * xfer functions used when sending files | |
1990 */ | |
1991 | |
1992 static void oscar_xfer_init_send(GaimXfer *xfer) | |
1993 { | |
1994 struct aim_oft_info *oft_info = xfer->data; | |
1995 GaimConnection *gc = oft_info->sess->aux_data; | |
1996 OscarData *od = gc->proto_data; | |
1997 int listenfd; | |
1998 | |
8660 | 1999 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2000 |
2001 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2002 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2003 oft_info->fh.name[63] = '\0'; | |
2004 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2005 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2006 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2007 | |
2008 /* Create a listening socket and an associated libfaim conn */ | |
2009 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2010 gaim_xfer_cancel_local(xfer); | |
2011 return; | |
2012 } | |
2013 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2014 oft_info->port = xfer->local_port; | |
2015 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2016 gaim_xfer_cancel_local(xfer); | |
2017 return; | |
2018 } | |
8660 | 2019 gaim_debug_misc("oscar", |
8446 | 2020 "port is %hu, ip is %s\n", |
2021 xfer->local_port, oft_info->clientip); | |
2022 if (oft_info->conn) { | |
2023 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2024 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2025 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2026 } else { | |
2027 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2028 _("Unable to establish listener socket.")); | |
2029 gaim_xfer_cancel_local(xfer); | |
2030 } | |
2031 } | |
2032 | |
2033 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2034 { | |
2035 struct aim_oft_info *oft_info = xfer->data; | |
2036 GaimConnection *gc = oft_info->sess->aux_data; | |
2037 OscarData *od = gc->proto_data; | |
2038 | |
8660 | 2039 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2040 |
9771 | 2041 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2042 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2043 |
2044 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2045 aim_oft_destroyinfo(oft_info); | |
2046 xfer->data = NULL; | |
2047 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2048 } | |
2049 | |
2050 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2051 { | |
2052 struct aim_oft_info *oft_info = xfer->data; | |
2053 | |
2054 /* I'm not sure I like how we do this. --marv | |
2055 * I do. AIM file transfers aren't really meant to be thought | |
2056 * of as a transferring just a single file. The rendezvous | |
2057 * establishes a connection between two computers, and then | |
2058 * those computers can use the same connection for transferring | |
2059 * multiple files. So we don't want the Gaim core up and closing | |
2060 * the socket all willy-nilly. We want to do that in the oscar | |
2061 * prpl, whenever one side or the other says they're finished | |
2062 * using the connection. There might be a better way to intercept | |
2063 * the socket from the core, however... --KingAnt | |
2064 */ | |
2065 | |
2066 /* | |
2067 * If we're done sending, intercept the socket from the core ft code | |
2068 * and wait for the other guy to send the "done" OFT packet. | |
2069 */ | |
2070 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2071 gaim_input_remove(xfer->watcher); | |
2072 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2073 xfer->fd = 0; | |
2074 gaim_xfer_set_completed(xfer, TRUE); | |
2075 } | |
2076 } | |
2077 | |
9466 | 2078 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2079 gboolean can_receive = FALSE; | |
2080 OscarData *od = gc->proto_data; | |
2081 | |
2082 if (!od->icq) { | |
2083 aim_userinfo_t *userinfo; | |
2084 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2085 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2086 can_receive = TRUE; | |
2087 } | |
2088 | |
2089 return can_receive; | |
2090 } | |
2091 | |
2092 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2093 |
2094 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2095 GaimXfer *xfer; |
5146 | 2096 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2097 const char *ip; |
3752 | 2098 |
9030 | 2099 od = (OscarData *)gc->proto_data; |
2100 | |
4617 | 2101 /* You want to send a file to someone else, you're so generous */ |
2102 | |
2103 /* Build the file transfer handle */ | |
9466 | 2104 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2105 |
5146 | 2106 /* Create the oscar-specific data */ |
8838 | 2107 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2108 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2109 xfer->data = oft_info; |
2110 | |
4617 | 2111 /* Setup our I/O op functions */ |
8446 | 2112 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2113 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2114 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2115 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2116 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2117 |
2118 /* Keep track of this transfer for later */ | |
2119 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2120 | |
2121 /* Now perform the request */ | |
9466 | 2122 if (file) |
2123 gaim_xfer_request_accepted(xfer, file); | |
2124 else | |
2125 gaim_xfer_request(xfer); | |
3630 | 2126 } |
2127 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2128 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2129 GaimConnection *gc = sess->aux_data; |
7283 | 2130 OscarData *od = gc->proto_data; |
6029 | 2131 GaimAccount *account = gc->account; |
2132 aim_conn_t *bosconn; | |
2133 char *host; int port; | |
2134 int i, rc; | |
2086 | 2135 va_list ap; |
2704 | 2136 struct aim_authresp_info *info; |
6029 | 2137 |
5575 | 2138 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2139 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2140 va_start(ap, fr); |
2704 | 2141 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2142 va_end(ap); |
2143 | |
8660 | 2144 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2145 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2146 |
4293 | 2147 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2148 char buf[256]; |
2704 | 2149 switch (info->errorcode) { |
2086 | 2150 case 0x05: |
2151 /* Incorrect nick/password */ | |
6498 | 2152 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2153 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2154 break; |
2155 case 0x11: | |
2156 /* Suspended account */ | |
6498 | 2157 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2158 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2159 break; |
3498 | 2160 case 0x14: |
2161 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2162 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2163 break; |
2086 | 2164 case 0x18: |
2165 /* connecting too frequently */ | |
6498 | 2166 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2167 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 | 2168 break; |
2169 case 0x1c: | |
2170 /* client too old */ | |
6498 | 2171 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2172 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
|
2173 gaim_connection_error(gc, buf); |
2086 | 2174 break; |
2175 default: | |
6623 | 2176 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2177 break; |
2178 } | |
8660 | 2179 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2180 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2181 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2182 "Error URL: %s\n", info->errorurl); |
2086 | 2183 od->killme = TRUE; |
2184 return 1; | |
2185 } | |
2186 | |
2187 | |
8660 | 2188 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2189 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2190 |
2704 | 2191 if (info->email) { |
8660 | 2192 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2193 } else { |
8660 | 2194 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2195 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2196 |
8660 | 2197 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2198 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2199 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2200 aim_conn_kill(sess, &fr->conn); |
2086 | 2201 |
2202 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2203 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2204 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2205 od->killme = TRUE; |
2206 return 0; | |
2207 } | |
2208 | |
4649 | 2209 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2210 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2211 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2212 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2213 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2214 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2215 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2216 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2217 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2218 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2219 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2220 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2221 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2222 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2223 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2224 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2225 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2226 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2227 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2228 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2229 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2230 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2231 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
|
2232 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2233 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2234 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2235 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2236 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2237 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2238 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
|
2239 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
|
2240 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
|
2241 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2242 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2243 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2244 #ifndef NOSSI |
4642 | 2245 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2246 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2247 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2248 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2249 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2250 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2251 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2252 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2253 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2254 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2255 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2256 |
7283 | 2257 od->conn = bosconn; |
2704 | 2258 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2259 if (info->bosip[i] == ':') { | |
2260 port = atoi(&(info->bosip[i+1])); | |
2086 | 2261 break; |
2262 } | |
2263 } | |
2704 | 2264 host = g_strndup(info->bosip, i); |
2086 | 2265 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2266 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2267 g_free(host); |
4366 | 2268 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2269 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2270 od->killme = TRUE; |
2271 return 0; | |
2272 } | |
4293 | 2273 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2274 gaim_input_remove(gc->inpa); |
2704 | 2275 |
7283 | 2276 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2277 ck[3] = 0x64; |
7282 | 2278 |
2086 | 2279 return 1; |
2280 } | |
2281 | |
7285 | 2282 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2283 struct pieceofcrap { |
5575 | 2284 GaimConnection *gc; |
2086 | 2285 unsigned long offset; |
2286 unsigned long len; | |
2287 char *modname; | |
2288 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2289 aim_conn_t *conn; |
2086 | 2290 unsigned int inpa; |
2291 }; | |
2292 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2293 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2294 { |
2295 struct pieceofcrap *pos = data; | |
7283 | 2296 OscarData *od = pos->gc->proto_data; |
2086 | 2297 char in = '\0'; |
2298 int x = 0; | |
2299 unsigned char m[17]; | |
2300 | |
2301 while (read(pos->fd, &in, 1) == 1) { | |
2302 if (in == '\n') | |
2303 x++; | |
2304 else if (in != '\r') | |
2305 x = 0; | |
2306 if (x == 2) | |
2307 break; | |
2308 in = '\0'; | |
2309 } | |
2310 if (in != '\n') { | |
4056 | 2311 char buf[256]; |
2312 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
|
2313 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2314 gaim_notify_warning(pos->gc, NULL, |
7422 | 2315 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2316 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2317 gaim_input_remove(pos->inpa); |
2086 | 2318 close(pos->fd); |
2319 g_free(pos); | |
2320 return; | |
2321 } | |
2322 read(pos->fd, m, 16); | |
2323 m[16] = '\0'; | |
8660 | 2324 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2325 for (x = 0; x < 16; x++) |
8660 | 2326 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2327 | |
2328 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2329 gaim_input_remove(pos->inpa); |
2086 | 2330 close(pos->fd); |
2331 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2332 g_free(pos); | |
2333 } | |
2334 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2335 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2336 struct pieceofcrap *pos = data; |
5420 | 2337 gchar *buf; |
2086 | 2338 |
4366 | 2339 pos->fd = source; |
2340 | |
2086 | 2341 if (source < 0) { |
5420 | 2342 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
|
2343 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2344 gaim_notify_warning(pos->gc, NULL, |
7422 | 2345 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2346 buf); |
5420 | 2347 g_free(buf); |
2086 | 2348 if (pos->modname) |
2349 g_free(pos->modname); | |
2350 g_free(pos); | |
2351 return; | |
2352 } | |
2353 | |
5420 | 2354 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2355 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2356 write(pos->fd, buf, strlen(buf)); | |
5420 | 2357 g_free(buf); |
2086 | 2358 if (pos->modname) |
2359 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2360 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2361 return; |
2362 } | |
2363 | |
2364 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2365 #define AIM_MAX_FILE_SIZE 98304 | |
2366 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2367 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2368 va_list ap; |
2369 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2370 fu32_t offset, len; |
2086 | 2371 char *modname; |
2372 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2373 va_start(ap, fr); |
4200 | 2374 offset = va_arg(ap, fu32_t); |
2375 len = va_arg(ap, fu32_t); | |
2086 | 2376 modname = va_arg(ap, char *); |
2377 va_end(ap); | |
2378 | |
8660 | 2379 gaim_debug_misc("oscar", |
5556 | 2380 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2381 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2382 |
2086 | 2383 if (len == 0) { |
8660 | 2384 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2385 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2386 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2387 return 1; | |
2388 } | |
9625 | 2389 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2390 #if 0 | |
2086 | 2391 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2392 char *buf; | |
2393 int i = 8; | |
2394 if (modname) | |
2395 i += strlen(modname); | |
2396 buf = g_malloc(i); | |
2397 i = 0; | |
2398 if (modname) { | |
2399 memcpy(buf, modname, strlen(modname)); | |
2400 i += strlen(modname); | |
2401 } | |
2402 buf[i++] = offset & 0xff; | |
2403 buf[i++] = (offset >> 8) & 0xff; | |
2404 buf[i++] = (offset >> 16) & 0xff; | |
2405 buf[i++] = (offset >> 24) & 0xff; | |
2406 buf[i++] = len & 0xff; | |
2407 buf[i++] = (len >> 8) & 0xff; | |
2408 buf[i++] = (len >> 16) & 0xff; | |
2409 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2410 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2411 "hashing request\n"); |
2086 | 2412 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2413 g_free(buf); | |
2414 return 1; | |
2415 } | |
9625 | 2416 #endif |
2086 | 2417 |
2418 pos = g_new0(struct pieceofcrap, 1); | |
2419 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2420 pos->conn = fr->conn; |
2086 | 2421 |
2422 pos->offset = offset; | |
2423 pos->len = len; | |
2424 pos->modname = modname ? g_strdup(modname) : NULL; | |
2425 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2426 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2427 char buf[256]; |
2086 | 2428 if (pos->modname) |
2429 g_free(pos->modname); | |
2430 g_free(pos); | |
4056 | 2431 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
|
2432 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2433 gaim_notify_warning(pos->gc, NULL, |
7422 | 2434 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2435 buf); |
2086 | 2436 } |
2437 | |
2438 return 1; | |
2439 } | |
2440 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2441 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2442 GaimConnection *gc = sess->aux_data; |
7283 | 2443 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2444 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2445 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2446 #if 0 |
2447 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2448 #endif | |
7011 | 2449 va_list ap; |
2450 char *key; | |
2086 | 2451 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2452 va_start(ap, fr); |
2086 | 2453 key = va_arg(ap, char *); |
2454 va_end(ap); | |
2455 | |
4617 | 2456 if (od->icq) { |
3458 | 2457 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2458 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2459 gaim_account_get_password(account), &info, key); |
3458 | 2460 } else { |
2461 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2462 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2463 gaim_account_get_password(account), &info, key); |
3458 | 2464 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2465 |
7283 | 2466 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2467 ck[2] = 0x6c; |
7282 | 2468 |
2086 | 2469 return 1; |
2470 } | |
2471 | |
2675 | 2472 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2473 GaimConnection *gc = sess->aux_data; |
2647 | 2474 struct chat_connection *chatcon; |
2475 static int id = 1; | |
2476 | |
6905 | 2477 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
|
2478 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
|
2479 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
|
2480 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
|
2481 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2482 |
2672 | 2483 aim_clientready(sess, fr->conn); |
2675 | 2484 |
2647 | 2485 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2486 chatcon->id = id; | |
8733 | 2487 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2488 |
2489 return 1; | |
2490 } | |
2491 | |
2675 | 2492 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2493 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2494 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2495 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2496 |
2497 aim_clientready(sess, fr->conn); | |
2498 | |
2499 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2500 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2501 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2502 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2503 |
3694 | 2504 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2505 | |
2506 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2507 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2508 | |
7282 | 2509 aim_email_sendcookies(sess); |
2510 aim_email_activate(sess); | |
3694 | 2511 aim_clientready(sess, fr->conn); |
2512 | |
2513 return 1; | |
2514 } | |
2515 | |
4804 | 2516 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2517 GaimConnection *gc = sess->aux_data; |
7283 | 2518 OscarData *od = gc->proto_data; |
4804 | 2519 |
2520 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2521 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2522 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2523 | |
2524 aim_clientready(sess, fr->conn); | |
2525 | |
4823 | 2526 od->iconconnecting = FALSE; |
2527 | |
4804 | 2528 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2529 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2530 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2531 |
2532 return 1; | |
2533 } | |
2534 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2535 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2536 GaimConnection *gc = data; |
7283 | 2537 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2538 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2539 aim_conn_t *tstconn; |
2086 | 2540 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2541 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2542 close(source); |
2543 return; | |
2544 } | |
2545 | |
4617 | 2546 od = gc->proto_data; |
2547 sess = od->sess; | |
2086 | 2548 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2549 tstconn->fd = source; |
2086 | 2550 |
2551 if (source < 0) { | |
2552 aim_conn_kill(sess, &tstconn); | |
8660 | 2553 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2554 "unable to connect to chatnav server\n"); |
2086 | 2555 return; |
2556 } | |
2557 | |
2558 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2559 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2560 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2561 } |
2562 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2563 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2564 { |
5575 | 2565 GaimConnection *gc = data; |
7283 | 2566 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2567 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2568 aim_conn_t *tstconn; |
2086 | 2569 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2570 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2571 close(source); |
2572 return; | |
2573 } | |
2574 | |
4617 | 2575 od = gc->proto_data; |
2576 sess = od->sess; | |
2086 | 2577 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2578 tstconn->fd = source; |
2086 | 2579 |
2580 if (source < 0) { | |
2581 aim_conn_kill(sess, &tstconn); | |
8660 | 2582 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2583 "unable to connect to authorizer\n"); |
2086 | 2584 return; |
2585 } | |
2586 | |
2587 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2588 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2589 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2590 } |
2591 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2592 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2593 { |
2594 struct chat_connection *ccon = data; | |
5575 | 2595 GaimConnection *gc = ccon->gc; |
7283 | 2596 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2597 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2598 aim_conn_t *tstconn; |
2086 | 2599 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2600 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2601 close(source); |
2602 g_free(ccon->show); | |
2603 g_free(ccon->name); | |
2604 g_free(ccon); | |
2605 return; | |
2606 } | |
2607 | |
4617 | 2608 od = gc->proto_data; |
2609 sess = od->sess; | |
2086 | 2610 tstconn = ccon->conn; |
4366 | 2611 tstconn->fd = source; |
2086 | 2612 |
2613 if (source < 0) { | |
2614 aim_conn_kill(sess, &tstconn); | |
2615 g_free(ccon->show); | |
2616 g_free(ccon->name); | |
2617 g_free(ccon); | |
2618 return; | |
2619 } | |
2620 | |
2621 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2622 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2623 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2624 } |
2625 | |
3694 | 2626 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2627 GaimConnection *gc = data; |
7283 | 2628 OscarData *od; |
3694 | 2629 aim_session_t *sess; |
2630 aim_conn_t *tstconn; | |
2631 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2632 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2633 close(source); |
2634 return; | |
2635 } | |
2636 | |
4617 | 2637 od = gc->proto_data; |
2638 sess = od->sess; | |
3694 | 2639 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2640 tstconn->fd = source; |
3694 | 2641 |
2642 if (source < 0) { | |
2643 aim_conn_kill(sess, &tstconn); | |
8660 | 2644 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2645 "unable to connect to email server\n"); |
3694 | 2646 return; |
2647 } | |
2648 | |
2649 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2650 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2651 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2652 "email: connected\n"); |
3694 | 2653 } |
2654 | |
4804 | 2655 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2656 GaimConnection *gc = data; |
7283 | 2657 OscarData *od; |
4804 | 2658 aim_session_t *sess; |
2659 aim_conn_t *tstconn; | |
2660 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2661 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2662 close(source); |
2663 return; | |
2664 } | |
2665 | |
2666 od = gc->proto_data; | |
2667 sess = od->sess; | |
2668 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2669 tstconn->fd = source; | |
2670 | |
2671 if (source < 0) { | |
2672 aim_conn_kill(sess, &tstconn); | |
8660 | 2673 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2674 "unable to connect to icon server\n"); |
4804 | 2675 return; |
2676 } | |
2677 | |
2678 aim_conn_completeconnect(sess, tstconn); | |
2679 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2680 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2681 } |
2682 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2683 /* 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
|
2684 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2685 GaimConnection *gc = sess->aux_data; |
2686 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2687 aim_conn_t *tstconn; |
4452 | 2688 int i; |
2086 | 2689 char *host; |
2690 int port; | |
4821 | 2691 va_list ap; |
2692 struct aim_redirect_data *redir; | |
2086 | 2693 |
5575 | 2694 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2695 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2696 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2697 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2698 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2699 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2700 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2701 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2702 port = atoi(&(redir->ip[i+1])); |
2086 | 2703 break; |
2704 } | |
2705 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2706 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2707 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2708 switch(redir->group) { |
2086 | 2709 case 0x7: /* Authorizer */ |
8660 | 2710 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2711 "Reconnecting with authorizor...\n"); |
2086 | 2712 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2713 if (tstconn == NULL) { | |
8660 | 2714 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2715 "unable to reconnect with authorizer\n"); |
2086 | 2716 g_free(host); |
2717 return 1; | |
2718 } | |
4649 | 2719 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2720 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2721 |
2722 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2723 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2724 aim_conn_kill(sess, &tstconn); |
8660 | 2725 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2726 "unable to reconnect with authorizer\n"); |
2086 | 2727 g_free(host); |
2728 return 1; | |
2729 } | |
4293 | 2730 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2731 break; |
2732 | |
2086 | 2733 case 0xd: /* ChatNav */ |
2734 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2735 if (tstconn == NULL) { | |
8660 | 2736 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2737 "unable to connect to chatnav server\n"); |
2086 | 2738 g_free(host); |
2739 return 1; | |
2740 } | |
4649 | 2741 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2742 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2743 |
2744 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2745 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2746 aim_conn_kill(sess, &tstconn); |
8660 | 2747 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2748 "unable to connect to chatnav server\n"); |
2086 | 2749 g_free(host); |
2750 return 1; | |
2751 } | |
4293 | 2752 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2753 break; |
2754 | |
2755 case 0xe: { /* Chat */ | |
2086 | 2756 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2757 |
2086 | 2758 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2759 if (tstconn == NULL) { | |
8660 | 2760 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2761 "unable to connect to chat server\n"); |
2086 | 2762 g_free(host); |
2763 return 1; | |
2764 } | |
2765 | |
4649 | 2766 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2767 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2768 | |
2086 | 2769 ccon = g_new0(struct chat_connection, 1); |
2770 ccon->conn = tstconn; | |
2771 ccon->gc = gc; | |
2772 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2773 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2774 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2775 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2776 ccon->show = extract_name(redir->chat.room); |
4634 | 2777 |
2086 | 2778 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2779 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2780 aim_conn_kill(sess, &tstconn); |
8660 | 2781 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2782 "unable to connect to chat server\n"); |
2086 | 2783 g_free(host); |
2784 g_free(ccon->show); | |
2785 g_free(ccon->name); | |
2786 g_free(ccon); | |
2787 return 1; | |
2788 } | |
4293 | 2789 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2790 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2791 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2792 ccon->name, ccon->exchange); |
4194 | 2793 } break; |
3694 | 2794 |
4804 | 2795 case 0x0010: { /* icon */ |
2796 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2797 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2798 "unable to connect to icon server\n"); |
4804 | 2799 g_free(host); |
2800 return 1; | |
2801 } | |
2802 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2803 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2804 | |
2805 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2806 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2807 aim_conn_kill(sess, &tstconn); |
8660 | 2808 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2809 "unable to connect to icon server\n"); |
4804 | 2810 g_free(host); |
2811 return 1; | |
2812 } | |
2813 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2814 } break; | |
2815 | |
3694 | 2816 case 0x0018: { /* email */ |
2817 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2818 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2819 "unable to connect to email server\n"); |
3694 | 2820 g_free(host); |
2821 return 1; | |
2822 } | |
4649 | 2823 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2824 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2825 | |
2826 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2827 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2828 aim_conn_kill(sess, &tstconn); |
8660 | 2829 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2830 "unable to connect to email server\n"); |
3694 | 2831 g_free(host); |
2832 return 1; | |
2833 } | |
4293 | 2834 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2835 } break; |
2836 | |
2086 | 2837 default: /* huh? */ |
8660 | 2838 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2839 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2840 redir->group); |
2086 | 2841 break; |
2842 } | |
2843 | |
2844 g_free(host); | |
2845 return 1; | |
2846 } | |
2847 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2848 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2849 GaimConnection *gc = sess->aux_data; |
9058 | 2850 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 2851 OscarData *od = gc->proto_data; |
4738 | 2852 struct buddyinfo *bi; |
2993 | 2853 time_t time_idle = 0, signon = 0; |
2854 int type = 0; | |
2855 int caps = 0; | |
2086 | 2856 va_list ap; |
4738 | 2857 aim_userinfo_t *info; |
4194 | 2858 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2859 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2860 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2861 va_end(ap); |
2862 | |
2993 | 2863 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2864 caps = info->capabilities; | |
3267 | 2865 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
2866 type |= UC_AB; | |
2867 | |
4766 | 2868 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2869 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
2870 type |= UC_UNCONFIRMED; | |
2871 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
2872 type |= UC_ADMIN; | |
2873 if (info->flags & AIM_FLAG_AOL) | |
2874 type |= UC_AOL; | |
2875 if (info->flags & AIM_FLAG_FREE) | |
2876 type |= UC_NORMAL; | |
2877 if (info->flags & AIM_FLAG_AWAY) | |
2878 type |= UC_UNAVAILABLE; | |
2879 if (info->flags & AIM_FLAG_WIRELESS) | |
2880 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2881 } |
2993 | 2882 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2883 type = (info->icqinfo.status << 16); |
3013 | 2884 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2885 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 2886 type |= UC_UNAVAILABLE; |
3013 | 2887 } |
2993 | 2888 } |
2889 | |
7141 | 2890 if (caps & AIM_CAPS_ICQ_DIRECT) |
2891 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2892 |
2893 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2894 time(&time_idle); |
2895 time_idle -= info->idletime*60; | |
9295 | 2896 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2897 } |
2898 | |
5836 | 2899 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2900 signon = info->onlinesince; | |
2901 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2902 signon = time(NULL) - info->sessionlen; |
2086 | 2903 |
5575 | 2904 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
2905 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2906 |
7261 | 2907 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
4738 | 2908 if (!bi) { |
2909 bi = g_new0(struct buddyinfo, 1); | |
7261 | 2910 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
4738 | 2911 } |
4739 | 2912 bi->typingnot = FALSE; |
2913 bi->ico_informed = FALSE; | |
6857 | 2914 bi->ipaddr = info->icqinfo.ipaddr; |
2915 | |
2916 /* Available message stuff */ | |
6292 | 2917 free(bi->availmsg); |
7011 | 2918 if (info->avail != NULL) |
8225 | 2919 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2920 else |
6292 | 2921 bi->availmsg = NULL; |
4732 | 2922 |
4804 | 2923 /* Server stored icon stuff */ |
4853 | 2924 if (info->iconcsumlen) { |
7125 | 2925 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2926 char *b16 = NULL, *filepath = NULL; |
7093 | 2927 GaimBuddy *b = NULL; |
4853 | 2928 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2929 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
4853 | 2930 b = gaim_find_buddy(gc->account, info->sn); |
7093 | 2931 /* |
2932 * If for some reason the checksum is valid, but cached file is not.. | |
2933 * we want to know. | |
2934 */ | |
7693 | 2935 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2936 if (filename != NULL) { |
2937 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2938 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2939 "icon_checksum"); | |
9801 | 2940 else { |
2941 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2942 filename, NULL); | |
2943 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2944 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2945 "icon_checksum"); | |
2946 g_free(filepath); | |
2947 } | |
7093 | 2948 } else |
2949 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2950 |
4853 | 2951 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2952 GSList *cur = od->requesticon; | |
2953 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2954 cur = cur->next; | |
2955 if (!cur) { | |
7475 | 2956 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
4853 | 2957 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2958 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2959 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2960 } |
2961 } | |
6053 | 2962 g_free(b16); |
4853 | 2963 } |
2964 | |
9058 | 2965 /* |
2966 * If we have info for ourselves, then update our local warning | |
2967 * level and set our official time of login. Is this necessary? | |
2968 * XXX - This needs to be changed some how. evil should not be | |
2969 * handled by the core at all? | |
2970 */ | |
2971 if (!aim_sncmp(info->sn, gaim_account_get_username(account))) { | |
2972 gc->evil = (info->warnlevel/10.0); | |
2973 gc->login_time_official = signon; | |
2974 } | |
2975 | |
9927 | 2976 serv_got_update(gc, info->sn, TRUE, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 2977 |
2978 return 1; | |
2979 } | |
2980 | |
8341 | 2981 static void gaim_check_comment(OscarData *od, const char *str) { |
2982 if ((str == NULL) || strcmp(str, ck)) | |
2983 aim_locate_setcaps(od->sess, caps_aim); | |
2984 else | |
2985 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2986 } | |
2987 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2988 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2989 GaimConnection *gc = sess->aux_data; |
7283 | 2990 OscarData *od = gc->proto_data; |
2086 | 2991 va_list ap; |
4739 | 2992 aim_userinfo_t *info; |
2086 | 2993 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2994 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2995 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2996 va_end(ap); |
2997 | |
9927 | 2998 serv_got_update(gc, info->sn, FALSE, 0, 0, 0, 0); |
2086 | 2999 |
7261 | 3000 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3001 |
2086 | 3002 return 1; |
3003 } | |
3004 | |
4617 | 3005 /* BBB */ |
3952 | 3006 /* |
4617 | 3007 * This is called after a remote AIM user has connected to us. We |
3008 * want to do some voodoo with the socket file descriptors, add a | |
3009 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3010 */ |
4656 | 3011 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3012 GaimConnection *gc = sess->aux_data; |
7283 | 3013 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3014 GaimXfer *xfer; |
5146 | 3015 struct aim_oft_info *oft_info; |
3630 | 3016 va_list ap; |
3017 aim_conn_t *conn, *listenerconn; | |
4656 | 3018 |
8660 | 3019 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3020 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3021 va_start(ap, fr); |
3022 conn = va_arg(ap, aim_conn_t *); | |
3023 listenerconn = va_arg(ap, aim_conn_t *); | |
3024 va_end(ap); | |
3025 | |
4617 | 3026 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3027 return 1; | |
3028 | |
5146 | 3029 if (!(oft_info = xfer->data)) |
4617 | 3030 return 1; |
3031 | |
3630 | 3032 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3033 gaim_input_remove(xfer->watcher); |
3630 | 3034 aim_conn_kill(sess, &listenerconn); |
3035 | |
5146 | 3036 oft_info->conn = conn; |
3037 xfer->fd = oft_info->conn->fd; | |
3038 | |
3039 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3040 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3041 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3042 |
3043 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3044 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3045 |
3046 return 0; | |
3047 } | |
3048 | |
3952 | 3049 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3050 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3051 * user in order to transfer a file. |
3952 | 3052 */ |
4617 | 3053 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
|
3054 GaimXfer *xfer; |
5146 | 3055 struct aim_oft_info *oft_info; |
4656 | 3056 |
8660 | 3057 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3058 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3059 if (!(xfer = data)) |
3060 return; | |
5146 | 3061 if (!(oft_info = xfer->data)) |
3630 | 3062 return; |
8446 | 3063 if (source < 0) { |
3064 gaim_xfer_cancel_remote(xfer); | |
4617 | 3065 return; |
8446 | 3066 } |
4617 | 3067 |
3068 xfer->fd = source; | |
5146 | 3069 oft_info->conn->fd = source; |
3070 | |
3071 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3072 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3073 |
3074 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3075 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3076 |
3077 return; | |
3630 | 3078 } |
3079 | |
3952 | 3080 /* |
4617 | 3081 * This is called when a buddy sends us some file info. This happens when they |
3082 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3083 * You should send them the exact same info except use the real cookie. We also |
4617 | 3084 * get like totally ready to like, receive the file, kay? |
3952 | 3085 */ |
4617 | 3086 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3087 GaimConnection *gc = sess->aux_data; |
7283 | 3088 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3089 GaimXfer *xfer; |
5146 | 3090 struct aim_oft_info *oft_info; |
4617 | 3091 va_list ap; |
3092 aim_conn_t *conn; | |
3093 fu8_t *cookie; | |
3094 struct aim_fileheader_t *fh; | |
4656 | 3095 |
8660 | 3096 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3097 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3098 va_start(ap, fr); |
3099 conn = va_arg(ap, aim_conn_t *); | |
3100 cookie = va_arg(ap, fu8_t *); | |
3101 fh = va_arg(ap, struct aim_fileheader_t *); | |
3102 va_end(ap); | |
3103 | |
3104 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3105 return 1; | |
3106 | |
5146 | 3107 if (!(oft_info = xfer->data)) |
4617 | 3108 return 1; |
3109 | |
3110 /* We want to stop listening with a normal thingy */ | |
3111 gaim_input_remove(xfer->watcher); | |
3112 xfer->watcher = 0; | |
3113 | |
5146 | 3114 /* They sent us some information about the file they're sending */ |
3115 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3116 | |
3117 /* Fill in the cookie */ | |
3118 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3119 | |
4617 | 3120 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3121 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3122 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3123 | |
3124 return 0; | |
3630 | 3125 } |
3126 | |
3952 | 3127 /* |
4657 | 3128 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3129 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3130 */ |
4617 | 3131 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3132 GaimConnection *gc = sess->aux_data; |
7283 | 3133 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3134 GaimXfer *xfer; |
4617 | 3135 va_list ap; |
3136 aim_conn_t *conn; | |
3137 fu8_t *cookie; | |
3138 struct aim_fileheader_t *fh; | |
4656 | 3139 |
8660 | 3140 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3141 va_start(ap, fr); |
3142 conn = va_arg(ap, aim_conn_t *); | |
3143 cookie = va_arg(ap, fu8_t *); | |
3144 fh = va_arg(ap, struct aim_fileheader_t *); | |
3145 va_end(ap); | |
3146 | |
3147 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3148 return 1; | |
3149 | |
4656 | 3150 /* We want to stop listening with a normal thingy */ |
3151 gaim_input_remove(xfer->watcher); | |
3152 xfer->watcher = 0; | |
3153 | |
4617 | 3154 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3155 | |
3156 return 0; | |
3630 | 3157 } |
4617 | 3158 |
3159 /* | |
3160 * We just sent a file to someone. They said they got it and everything, | |
3161 * so we can close our direct connection and what not. | |
3162 */ | |
3163 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3164 GaimConnection *gc = sess->aux_data; |
7283 | 3165 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3166 GaimXfer *xfer; |
4617 | 3167 va_list ap; |
3168 aim_conn_t *conn; | |
3169 fu8_t *cookie; | |
3170 struct aim_fileheader_t *fh; | |
4656 | 3171 |
8660 | 3172 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3173 va_start(ap, fr); |
3174 conn = va_arg(ap, aim_conn_t *); | |
3175 cookie = va_arg(ap, fu8_t *); | |
3176 fh = va_arg(ap, struct aim_fileheader_t *); | |
3177 va_end(ap); | |
3178 | |
3179 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3180 return 1; | |
3181 | |
4656 | 3182 xfer->fd = conn->fd; |
4617 | 3183 gaim_xfer_end(xfer); |
3184 | |
3185 return 0; | |
3186 } | |
3630 | 3187 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3188 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3189 GaimConnection *gc = sess->aux_data; |
7283 | 3190 OscarData *od = gc->proto_data; |
8708 | 3191 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3192 GaimConvImFlags flags = 0; |
4738 | 3193 struct buddyinfo *bi; |
5575 | 3194 const char *iconfile; |
9806 | 3195 GString *message; |
3196 gchar *tmp; | |
3197 aim_mpmsg_section_t *curpart; | |
3198 | |
3199 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3200 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3201 |
8708 | 3202 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3203 if (!bi) { |
3204 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3205 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3206 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3207 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3208 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3209 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3210 |
4738 | 3211 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3212 bi->typingnot = TRUE; | |
3213 else | |
3214 bi->typingnot = FALSE; | |
3215 | |
4380 | 3216 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3217 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3218 "%s has an icon\n", userinfo->sn); |
4738 | 3219 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3220 bi->ico_need = TRUE; | |
3221 bi->ico_len = args->iconlen; | |
3222 bi->ico_csum = args->iconsum; | |
3223 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3224 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3225 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3226 |
8708 | 3227 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3228 (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
|
3229 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3230 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3231 |
5575 | 3232 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3233 char *buf = g_malloc(st.st_size); |
5575 | 3234 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3235 if (file) { |
9532 | 3236 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3237 int len = fread(buf, 1, st.st_size, file); |
8660 | 3238 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3239 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3240 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3241 userinfo->sn, len, st.st_size); |
4617 | 3242 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3243 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3244 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3245 } else |
8660 | 3246 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3247 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3248 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3249 } else |
8660 | 3250 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3251 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3252 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3253 |
9806 | 3254 message = g_string_new(""); |
3255 curpart = args->mpmsg.parts; | |
3256 while (curpart != NULL) { | |
9908 | 3257 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3258 curpart->data, curpart->datalen); |
3259 if (tmp != NULL) { | |
3260 g_string_append(message, tmp); | |
3261 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3262 } |
9806 | 3263 |
3264 curpart = curpart->next; | |
3265 } | |
3266 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3267 |
8666 | 3268 /* |
8995 | 3269 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3270 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3271 * so any HTML we receive is intended to be displayed |
3272 * | |
3273 * Note: There *may* be some clients which send messages as HTML formatted - | |
3274 * they need to be special-cased somehow. | |
8666 | 3275 */ |
8995 | 3276 if (isdigit(gaim_account_get_username(account)[0]) && isdigit(userinfo->sn[0])) { |
3277 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ | |
3278 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3279 g_free(tmp); |
3280 tmp = tmp2; | |
3281 } | |
3282 | |
6982 | 3283 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3284 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3285 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3286 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3287 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3288 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3289 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3290 GaimConnection *gc; |
9933 | 3291 GaimAccount *account; |
9070 | 3292 OscarData *od; |
9933 | 3293 const char *username = NULL; |
3294 char *message = NULL; | |
9070 | 3295 |
3296 g_return_val_if_fail(sess != NULL, 0); | |
3297 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3298 | |
3299 gc = sess->aux_data; | |
9933 | 3300 account = gaim_connection_get_account(gc); |
9070 | 3301 od = gc->proto_data; |
9933 | 3302 username = gaim_account_get_username(account); |
3303 | |
3304 if (args == NULL) | |
4121 | 3305 return 0; |
4194 | 3306 |
9933 | 3307 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3308 userinfo->sn, args->status); | |
3309 | |
3310 if (args->msg != NULL) | |
3311 { | |
3312 if (args->encoding != NULL) | |
3313 { | |
3314 char *encoding = NULL; | |
3315 encoding = oscar_encoding_extract(args->encoding); | |
3316 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3317 g_free(encoding); | |
3318 } else { | |
3319 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3320 message = g_strdup(args->msg); | |
3321 } | |
3322 } | |
2869 | 3323 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3324 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3325 char *name; |
5234 | 3326 GHashTable *components; |
3327 | |
9933 | 3328 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3329 g_free(message); | |
4121 | 3330 return 1; |
9933 | 3331 } |
5234 | 3332 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3333 g_free); | |
4121 | 3334 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3335 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3336 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
|
3337 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3338 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3339 userinfo->sn, |
9933 | 3340 message, |
5234 | 3341 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3342 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3343 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3344 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3345 /* BBB */ |
3346 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3347 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3348 GaimXfer *xfer; |
5146 | 3349 struct aim_oft_info *oft_info; |
3350 | |
3351 if (!args->cookie || !args->port || !args->verifiedip || | |
3352 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3353 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3354 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3355 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3356 "information.\n", userinfo->sn); |
5146 | 3357 if (args->proxyip) |
8660 | 3358 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3359 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3360 "does not support this yet.\n"); |
9933 | 3361 g_free(message); |
4617 | 3362 return 1; |
4656 | 3363 } |
4617 | 3364 |
3365 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3366 /* 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
|
3367 * directory -- remove the star and trailing slash so we don't save |
4617 | 3368 * directories that look like 'dirname\*' -- arl */ |
3369 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3370 if (tmp && (tmp[1] == '*')) { | |
3371 tmp[0] = '\0'; | |
3372 } | |
8660 | 3373 gaim_debug_warning("oscar", |
8446 | 3374 "We're receiving a whole directory! What fun! " |
3375 "Especially since we don't support that!\n"); | |
4617 | 3376 } |
3377 | |
3378 /* Build the file transfer handle */ | |
3379 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3380 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3381 xfer->remote_port = args->port; |
4617 | 3382 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3383 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3384 gaim_xfer_set_message(xfer, message); |
5146 | 3385 |
3386 /* Create the oscar-specific data */ | |
5163 | 3387 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3388 if (args->proxyip) |
5146 | 3389 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3390 if (args->verifiedip) |
5146 | 3391 oft_info->verifiedip = g_strdup(args->verifiedip); |
3392 xfer->data = oft_info; | |
4617 | 3393 |
3394 /* Setup our I/O op functions */ | |
8446 | 3395 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3396 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3397 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
|
3398 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3399 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3400 |
3401 /* Keep track of this transfer for later */ | |
3402 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3403 | |
3404 /* Now perform the request */ | |
3405 gaim_xfer_request(xfer); | |
3406 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3407 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3408 GaimXfer *xfer; |
8660 | 3409 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3410 "AAA - File transfer canceled by remote user\n"); |
4617 | 3411 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
|
3412 gaim_xfer_cancel_remote(xfer); |
4617 | 3413 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3414 /* | |
3415 * This gets sent by the receiver of a file | |
3416 * as they connect directly to us. If we don't | |
3417 * get this, then maybe a third party connected | |
3418 * to us, and we shouldn't send them anything. | |
3419 */ | |
3420 } else { | |
8660 | 3421 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3422 "unknown rendezvous status!\n"); |
3630 | 3423 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3424 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3425 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3426 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3427 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3428 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3429 args->info.icon.length); |
6871 | 3430 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3431 /* 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
|
3432 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3433 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
|
3434 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3435 |
4212 | 3436 if (!args->verifiedip) { |
8983 | 3437 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3438 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3439 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3440 g_free(message); |
4650 | 3441 return 1; |
4212 | 3442 } |
3443 | |
8660 | 3444 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3445 "%s received direct im request from %s (%s)\n", |
8983 | 3446 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3447 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3448 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3449 d->sn = g_strdup(userinfo->sn); |
8983 | 3450 /* Let's use the clientip here, because I think that's what AIM does. |
3451 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3452 * and then ask them to connect to us. */ | |
3453 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
|
3454 memcpy(d->cookie, args->cookie, 8); |
9070 | 3455 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3456 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3457 | |
8971 | 3458 oscar_direct_im_destroy(od, dim); |
8984 | 3459 d->donttryagain = TRUE; |
8971 | 3460 accept_direct_im_request(d); |
3461 } else { | |
8983 | 3462 if (dim && !dim->connected) |
8971 | 3463 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3464 "already connected to that buddy!"); | |
5575 | 3465 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
|
3466 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3467 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3468 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3469 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3470 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3471 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3472 "risk."), 0, d, 2, |
8971 | 3473 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3474 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3475 /* FIXME: we should actually send a packet on cancel */ | |
3476 } | |
8708 | 3477 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3478 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
|
3479 } else { |
8660 | 3480 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3481 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3482 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3483 |
9933 | 3484 g_free(message); |
3485 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3486 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3487 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3488 |
3453 | 3489 /* |
4230 | 3490 * Authorization Functions |
3491 * Most of these are callbacks from dialogs. They're used by both | |
3492 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3493 */ |
4269 | 3494 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3495 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3496 GaimConnection *gc = data->gc; |
4244 | 3497 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3498 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3499 OscarData *od = gc->proto_data; |
6695 | 3500 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3501 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3502 if (buddy && group) { |
8660 | 3503 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3504 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3505 buddy->name, group->name); |
4889 | 3506 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3507 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3508 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3509 } |
4230 | 3510 } |
4337 | 3511 } |
3512 | |
3513 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3514 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3515 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3516 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3517 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3518 data); |
4230 | 3519 } |
3520 | |
3521 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3522 GaimConnection *gc = data->gc; |
4244 | 3523 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3524 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3525 /* Remove from local list */ |
3526 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3527 gaim_blist_remove_buddy(b); | |
4244 | 3528 } |
3529 | |
5836 | 3530 oscar_free_name_data(data); |
4230 | 3531 } |
3532 | |
9030 | 3533 |
3534 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3535 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3536 GaimBuddy *buddy; |
4269 | 3537 gchar *dialog_msg, *nombre; |
3538 | |
4687 | 3539 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3540 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3541 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3542 else |
4830 | 3543 nombre = NULL; |
3544 | |
3545 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 | 3546 data->gc = gc; |
3547 data->name = g_strdup(name); | |
3548 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3549 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3550 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3551 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3552 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3553 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3554 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3555 |
3556 g_free(dialog_msg); | |
3557 g_free(nombre); | |
3558 } | |
3559 | |
9030 | 3560 |
3561 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3562 GaimBuddy *buddy; | |
3563 GaimConnection *gc; | |
3564 | |
3565 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3566 | |
3567 buddy = (GaimBuddy *) node; | |
3568 gc = gaim_account_get_connection(buddy->account); | |
3569 gaim_auth_sendrequest(gc, buddy->name); | |
3570 } | |
3571 | |
4230 | 3572 /* When other people ask you for authorization */ |
3573 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3574 GaimConnection *gc = data->gc; |
4244 | 3575 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3576 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3577 OscarData *od = gc->proto_data; |
4236 | 3578 #ifdef NOSSI |
6695 | 3579 GaimBuddy *buddy; |
4244 | 3580 gchar message; |
3581 message = 0; | |
4687 | 3582 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3583 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3584 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3585 #else |
4889 | 3586 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3587 #endif |
4244 | 3588 } |
3589 | |
5836 | 3590 oscar_free_name_data(data); |
3141 | 3591 } |
3592 | |
4230 | 3593 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3594 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3595 GaimConnection *gc = data->gc; |
4244 | 3596 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3597 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3598 OscarData *od = gc->proto_data; |
4230 | 3599 #ifdef NOSSI |
4617 | 3600 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3601 #else |
4889 | 3602 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3603 #endif |
4244 | 3604 } |
4337 | 3605 } |
3606 | |
3607 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3608 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3609 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3610 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3611 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3612 data); |
3141 | 3613 } |
3614 | |
7023 | 3615 /* When someone sends you buddies */ |
3616 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3617 GaimConnection *gc = data->gc; |
4244 | 3618 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3619 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3620 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3621 } |
3622 | |
5836 | 3623 oscar_free_name_data(data); |
3453 | 3624 } |
3625 | |
4075 | 3626 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 | 3627 GaimConnection *gc = sess->aux_data; |
9908 | 3628 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3629 gchar **msg1, **msg2; |
6051 | 3630 int i, numtoks; |
4076 | 3631 |
4121 | 3632 if (!args->type || !args->msg || !args->uin) |
3633 return 1; | |
4194 | 3634 |
8660 | 3635 gaim_debug_info("oscar", |
9908 | 3636 "Received a channel 4 message of type 0x%02hhx.\n", |
3637 args->type); | |
4076 | 3638 |
9919 | 3639 /* |
3640 * Split up the message at the delimeter character, then convert each | |
3641 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3642 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3643 * character in whatever encoding the message was sent in. Type 1 | |
3644 * messages are always made up of only one part, so we can easily account | |
3645 * for this suck-ass part of the protocol by splitting the string into at | |
3646 * most 1 baby string. | |
3647 */ | |
3648 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3649 for (numtoks=0; msg1[numtoks]; numtoks++); |
3650 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3651 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3652 gaim_str_strip_cr(msg1[i]); |
9908 | 3653 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3654 } |
3655 msg2[i] = NULL; | |
3656 | |
3952 | 3657 switch (args->type) { |
4173 | 3658 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3659 if (i >= 1) { |
5556 | 3660 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3661 gchar *tmp; |
3662 | |
3663 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3664 tmp = gaim_escape_html(msg2[0]); |
8493 | 3665 |
4076 | 3666 if (t) { /* This is an offline message */ |
9680 | 3667 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3668 #ifdef HAVE_TM_GMTOFF |
9724 | 3669 time_t now; |
3670 struct tm *tm; | |
3671 now = time(NULL); | |
3672 tm = localtime(&now); | |
3673 t += tm->tm_gmtoff; | |
9698 | 3674 #else |
3675 # ifdef HAVE_TIMEZONE | |
9680 | 3676 tzset(); |
3677 t -= timezone; | |
9698 | 3678 # endif |
3679 #endif | |
8514 | 3680 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3681 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3682 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3683 } |
3684 g_free(uin); | |
8493 | 3685 g_free(tmp); |
4075 | 3686 } |
3316 | 3687 } break; |
3688 | |
4173 | 3689 case 0x04: { /* Someone sent you a URL */ |
4076 | 3690 if (i >= 2) { |
7385 | 3691 if (msg2[1] != NULL) { |
3692 gchar *uin = g_strdup_printf("%u", args->uin); | |
3693 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3694 msg2[1], | |
3695 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3696 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3697 g_free(uin); | |
3698 g_free(message); | |
3699 } | |
3453 | 3700 } |
3701 } break; | |
3702 | |
4173 | 3703 case 0x06: { /* Someone requested authorization */ |
4076 | 3704 if (i >= 6) { |
4230 | 3705 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3706 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 | 3707 gaim_debug_info("oscar", |
5556 | 3708 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3709 args->uin); |
4076 | 3710 data->gc = gc; |
5556 | 3711 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3712 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3713 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3714 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3715 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3716 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3717 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3718 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3719 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3720 g_free(dialog_msg); |
3721 } | |
3141 | 3722 } break; |
3723 | |
4173 | 3724 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3725 if (i >= 1) { |
7023 | 3726 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
|
3727 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3728 dialog_msg); |
4076 | 3729 g_free(dialog_msg); |
3730 } | |
3141 | 3731 } break; |
3732 | |
4173 | 3733 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3734 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
|
3735 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3736 dialog_msg); |
3141 | 3737 g_free(dialog_msg); |
3738 } break; | |
3739 | |
4333 | 3740 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3741 if (i >= 5) { | |
3742 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
|
3743 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3744 g_free(dialog_msg); |
3745 } | |
3746 } break; | |
3747 | |
4173 | 3748 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3749 if (i >= 6) { |
4194 | 3750 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
|
3751 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3752 g_free(dialog_msg); |
3753 } | |
4075 | 3754 } break; |
3755 | |
4173 | 3756 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3757 if (i >= 6) { |
4308 | 3758 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
|
3759 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3760 g_free(dialog_msg); |
3761 } | |
4075 | 3762 } break; |
3763 | |
4173 | 3764 case 0x12: { |
3141 | 3765 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3766 /* Someone added you to their buddy list? */ |
3141 | 3767 } break; |
3768 | |
7023 | 3769 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3770 guint i, num; |
3453 | 3771 gchar **text; |
4173 | 3772 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3773 if (text) { |
3774 num = 0; | |
3775 for (i=0; i<strlen(text[0]); i++) | |
3776 num = num*10 + text[0][i]-48; | |
3777 for (i=0; i<num; i++) { | |
4230 | 3778 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3779 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 | 3780 data->gc = gc; |
4790 | 3781 data->name = g_strdup(text[i*2+1]); |
3782 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3783 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3784 gaim_request_action(gc, NULL, message, |
7023 | 3785 _("Do you want to add this buddy " |
3786 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3787 0, data, 2, |
7023 | 3788 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3789 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3790 g_free(message); |
3791 } | |
3792 g_strfreev(text); | |
3793 } | |
3794 } break; | |
3795 | |
7023 | 3796 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3797 /* This is boring and silly. */ |
3798 } break; | |
3799 | |
3141 | 3800 default: { |
8660 | 3801 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3802 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3803 "(type 0x%02hhx).\n", args->type); |
3141 | 3804 } break; |
3805 } | |
3806 | |
4076 | 3807 g_strfreev(msg1); |
3808 g_strfreev(msg2); | |
3809 | |
3141 | 3810 return 1; |
3811 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3812 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3813 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3814 fu16_t channel; |
3815 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3816 aim_userinfo_t *userinfo; |
2086 | 3817 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3818 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3819 va_start(ap, fr); |
4200 | 3820 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3821 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3822 |
3141 | 3823 switch (channel) { |
3824 case 1: { /* standard message */ | |
3825 struct aim_incomingim_ch1_args *args; | |
3826 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3827 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3828 } break; | |
3829 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3830 case 2: { /* rendezvous */ |
3141 | 3831 struct aim_incomingim_ch2_args *args; |
3832 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3833 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3834 } break; | |
3835 | |
3836 case 4: { /* ICQ */ | |
3837 struct aim_incomingim_ch4_args *args; | |
3838 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3839 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3840 } break; |
3841 | |
3842 default: { | |
8660 | 3843 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3844 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3845 "0x%04hx).", channel); |
3141 | 3846 } break; |
2086 | 3847 } |
3848 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3849 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3850 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3851 return ret; |
2086 | 3852 } |
3853 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3854 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3855 GaimConnection *gc = sess->aux_data; |
3856 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3857 char *buf; |
2086 | 3858 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3859 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3860 aim_userinfo_t *userinfo; |
2086 | 3861 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3862 va_start(ap, fr); |
4200 | 3863 chan = (fu16_t)va_arg(ap, unsigned int); |
3864 userinfo = va_arg(ap, aim_userinfo_t *); | |
3865 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3866 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3867 va_end(ap); |
3868 | |
3869 switch(reason) { | |
5420 | 3870 case 0: /* Invalid (0) */ |
3871 buf = g_strdup_printf( | |
3872 ngettext( | |
4276 | 3873 "You missed %hu message from %s because it was invalid.", |
3874 "You missed %hu messages from %s because they were invalid.", | |
3875 nummissed), | |
4282 | 3876 nummissed, |
3877 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3878 break; |
5420 | 3879 case 1: /* Message too large */ |
3880 buf = g_strdup_printf( | |
3881 ngettext( | |
4276 | 3882 "You missed %hu message from %s because it was too large.", |
3883 "You missed %hu messages from %s because they were too large.", | |
3884 nummissed), | |
4282 | 3885 nummissed, |
3886 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3887 break; |
5420 | 3888 case 2: /* Rate exceeded */ |
3889 buf = g_strdup_printf( | |
3890 ngettext( | |
4276 | 3891 "You missed %hu message from %s because the rate limit has been exceeded.", |
3892 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3893 nummissed), | |
4282 | 3894 nummissed, |
3895 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3896 break; |
5420 | 3897 case 3: /* Evil Sender */ |
3898 buf = g_strdup_printf( | |
3899 ngettext( | |
4276 | 3900 "You missed %hu message from %s because he/she was too evil.", |
3901 "You missed %hu messages from %s because he/she was too evil.", | |
3902 nummissed), | |
4282 | 3903 nummissed, |
3904 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3905 break; |
5420 | 3906 case 4: /* Evil Receiver */ |
3907 buf = g_strdup_printf( | |
3908 ngettext( | |
4276 | 3909 "You missed %hu message from %s because you are too evil.", |
3910 "You missed %hu messages from %s because you are too evil.", | |
3911 nummissed), | |
4282 | 3912 nummissed, |
3913 userinfo->sn); | |
2086 | 3914 break; |
3915 default: | |
5420 | 3916 buf = g_strdup_printf( |
3917 ngettext( | |
4276 | 3918 "You missed %hu message from %s for an unknown reason.", |
3919 "You missed %hu messages from %s for an unknown reason.", | |
3920 nummissed), | |
4282 | 3921 nummissed, |
3922 userinfo->sn); | |
2086 | 3923 break; |
3924 } | |
8733 | 3925 |
9627 | 3926 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3927 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3928 g_free(buf); |
2086 | 3929 |
3930 return 1; | |
3931 } | |
3932 | |
4194 | 3933 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3934 GaimConnection *gc = sess->aux_data; |
7283 | 3935 OscarData *od = gc->proto_data; |
4617 | 3936 |
3937 /* BBB */ | |
3630 | 3938 switch (reason) { |
4151 | 3939 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3940 GaimXfer *xfer; |
8971 | 3941 struct oscar_direct_im *dim; |
3942 | |
8660 | 3943 gaim_debug_info("oscar", |
9070 | 3944 "AAA - Other user declined some sort of direct " |
8971 | 3945 "connect attempt (automaticly?)\n"); |
4617 | 3946 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
|
3947 gaim_xfer_cancel_remote(xfer); |
8971 | 3948 else if ((dim = oscar_direct_im_find(od, who))) { |
3949 /* AAA should use find by cookie or something here */ | |
3950 oscar_direct_im_disconnect(od, dim); | |
3951 } | |
4151 | 3952 } break; |
3953 | |
3954 default: { | |
8660 | 3955 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3956 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3957 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3958 } |
3630 | 3959 |
3960 } | |
3961 | |
3962 return 0; | |
3963 } | |
3964 | |
4194 | 3965 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3966 GaimConnection *gc = sess->aux_data; |
4151 | 3967 |
3968 switch(reason) { | |
3969 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3970 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3971 | |
3972 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3973 |
3974 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3975 statusmsg = oscar_icqstatus(state); |
4151 | 3976 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3977 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3978 g_free(statusmsg); | |
4151 | 3979 g_strfreev(splitmsg); |
9244 | 3980 |
9797 | 3981 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 3982 |
3983 g_free(title); | |
3984 g_free(dialogmsg); | |
4151 | 3985 } break; |
3986 | |
3987 default: { | |
8660 | 3988 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3989 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3990 "Type 0x%04hx\n", who, reason); |
4151 | 3991 } break; |
3992 } /* end of switch */ | |
3993 | |
3994 return 0; | |
3995 } | |
3996 | |
3212 | 3997 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
3998 va_list ap; | |
3999 fu16_t chan, reason; | |
4000 char *who; | |
4001 | |
4002 va_start(ap, fr); | |
4200 | 4003 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4004 who = va_arg(ap, char *); |
4200 | 4005 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4006 |
3952 | 4007 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4008 char *cookie = va_arg(ap, char *); |
4151 | 4009 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4010 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4011 fu32_t state = 0; |
4151 | 4012 char *msg = NULL; |
4013 if (reason == 0x0003) { | |
4200 | 4014 state = va_arg(ap, fu32_t); |
4151 | 4015 msg = va_arg(ap, char *); |
4016 } | |
4017 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4018 } | |
3952 | 4019 |
3212 | 4020 va_end(ap); |
4021 | |
4022 return 1; | |
4023 } | |
4024 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4025 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4026 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4027 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4028 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4029 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4030 va_start(ap, fr); |
4199 | 4031 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4032 va_end(ap); |
4033 | |
8660 | 4034 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4035 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4036 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4037 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4038 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4039 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4040 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4041 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4042 |
2086 | 4043 return 1; |
4044 } | |
4045 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4046 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4047 GaimConnection *gc = sess->aux_data; |
4617 | 4048 #if 0 |
7283 | 4049 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4050 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4051 #endif |
4617 | 4052 va_list ap; |
4053 fu16_t reason; | |
4054 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4055 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4056 va_start(ap, fr); |
4617 | 4057 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4058 data = va_arg(ap, char *); |
2086 | 4059 va_end(ap); |
4060 | |
8660 | 4061 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4062 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 4063 |
4064 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4065 #if 0 |
4617 | 4066 /* If this was a file transfer request, data is a cookie */ |
4067 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
|
4068 gaim_xfer_cancel_remote(xfer); |
3630 | 4069 return 1; |
4070 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4071 #endif |
3630 | 4072 |
4617 | 4073 /* Data is assumed to be the destination sn */ |
9826 | 4074 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4075 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4076 g_free(buf); | |
4077 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4078 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4079 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4080 } | |
4081 g_free(buf); | |
4082 | |
2086 | 4083 return 1; |
4084 } | |
4085 | |
3595 | 4086 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4087 GaimConnection *gc = sess->aux_data; |
3595 | 4088 va_list ap; |
4089 fu16_t type1, type2; | |
4090 char *sn; | |
4091 | |
4092 va_start(ap, fr); | |
4199 | 4093 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4094 sn = va_arg(ap, char *); |
4199 | 4095 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4096 va_end(ap); |
4097 | |
4098 switch (type2) { | |
4099 case 0x0000: { /* Text has been cleared */ | |
4100 serv_got_typing_stopped(gc, sn); | |
4101 } break; | |
4102 | |
4103 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4104 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4105 } break; |
4106 | |
4107 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4108 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4109 } break; |
4110 | |
4111 default: { | |
8660 | 4112 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 | 4113 } break; |
4114 } | |
4115 | |
4116 return 1; | |
4117 } | |
4118 | |
7141 | 4119 /* |
4120 * We get this error when there was an error in the locate family. This | |
7259 | 4121 * happens when you request info of someone who is offline. |
7141 | 4122 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4123 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4124 gchar *buf; |
2086 | 4125 va_list ap; |
5420 | 4126 fu16_t reason; |
2086 | 4127 char *destn; |
4128 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4129 va_start(ap, fr); |
4199 | 4130 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4131 destn = va_arg(ap, char *); |
4132 va_end(ap); | |
4133 | |
7781 | 4134 if (destn == NULL) |
7793 | 4135 return 1; |
9627 | 4136 |
9826 | 4137 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4138 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4139 g_free(buf); | |
9627 | 4140 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4141 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4142 } | |
4143 g_free(buf); | |
2086 | 4144 |
4145 return 1; | |
4146 } | |
4147 | |
7011 | 4148 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4149 GaimConnection *gc = sess->aux_data; |
8700 | 4150 GaimAccount *account = gaim_connection_get_account(gc); |
4151 GString *str; | |
9244 | 4152 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4153 va_list ap; |
7011 | 4154 aim_userinfo_t *userinfo; |
2086 | 4155 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4156 va_start(ap, fr); |
7011 | 4157 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4158 va_end(ap); |
4159 | |
8700 | 4160 str = g_string_new(""); |
4161 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4162 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4163 |
4164 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 4165 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 4166 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 4167 |
4168 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 4169 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 4170 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 4171 |
4172 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4173 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4174 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4175 g_free(tmp); |
4176 } | |
4177 | |
8701 | 4178 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4179 |
4180 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4181 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4182 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4183 g_free(tmp); | |
7011 | 4184 if (away_utf8 != NULL) { |
8700 | 4185 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4186 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4187 } |
7011 | 4188 } |
4189 | |
4190 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4191 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4192 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4193 g_free(tmp); | |
7011 | 4194 if (info_utf8 != NULL) { |
8700 | 4195 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4196 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4197 } |
7011 | 4198 } |
4199 | |
8701 | 4200 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4201 g_string_free(str, TRUE); |
9244 | 4202 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4203 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4204 g_free(title); |
8700 | 4205 g_free(tmp); |
4151 | 4206 |
2086 | 4207 return 1; |
4208 } | |
4209 | |
8341 | 4210 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4211 { | |
4212 aim_session_t *sess = data; | |
4213 GaimConnection *gc = sess->aux_data; | |
4214 OscarData *od = (OscarData *)gc->proto_data; | |
4215 | |
4216 aim_locate_dorequest(data); | |
4217 od->getinfotimer = 0; | |
4218 | |
4219 return FALSE; | |
4220 } | |
4221 | |
4222 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4223 { | |
4224 GaimConnection *gc = sess->aux_data; | |
4225 OscarData *od = (OscarData *)gc->proto_data; | |
4226 | |
4227 /* | |
4228 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4229 * us from hitting the rate limit due to request away messages and info | |
4230 * too quickly. | |
4231 */ | |
4232 if (od->getinfotimer == 0) | |
4233 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4234 | |
4235 return 1; | |
4236 } | |
4237 | |
4238 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4239 { | |
2086 | 4240 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4241 fu16_t id; |
2086 | 4242 va_list ap; |
4243 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4244 va_start(ap, fr); |
4199 | 4245 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4246 msg = va_arg(ap, char *); |
4247 va_end(ap); | |
4248 | |
8660 | 4249 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4250 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4251 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4252 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4253 _("Your AIM connection may be lost."), NULL); |
2086 | 4254 |
4255 return 1; | |
4256 } | |
4257 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4258 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4259 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4260 fu16_t type; |
5575 | 4261 GaimConnection *gc = sess->aux_data; |
7283 | 4262 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4263 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4264 va_start(ap, fr); |
4199 | 4265 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4266 |
4267 switch(type) { | |
4268 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4269 fu8_t maxrooms; |
2086 | 4270 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4271 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4272 |
4199 | 4273 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4274 exchangecount = va_arg(ap, int); |
4275 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4276 | |
8660 | 4277 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4278 "chat info: Chat Rights:\n"); |
8660 | 4279 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4280 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4281 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4282 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4283 for (i = 0; i < exchangecount; i++) |
8660 | 4284 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4285 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4286 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4287 while (od->create_rooms) { |
4288 struct create_room *cr = od->create_rooms->data; | |
8660 | 4289 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4290 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4291 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4292 g_free(cr->name); |
4617 | 4293 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4294 g_free(cr); |
2086 | 4295 } |
4296 } | |
4297 break; | |
4298 case 0x0008: { | |
4299 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4300 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4301 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4302 fu32_t createtime; |
2086 | 4303 |
4304 fqcn = va_arg(ap, char *); | |
4200 | 4305 instance = (fu16_t)va_arg(ap, unsigned int); |
4306 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4307 flags = (fu16_t)va_arg(ap, unsigned int); | |
4308 createtime = va_arg(ap, fu32_t); | |
4309 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4310 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4311 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4312 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4313 name = va_arg(ap, char *); | |
4314 ck = va_arg(ap, char *); | |
4194 | 4315 |
8660 | 4316 gaim_debug_misc("oscar", |
5556 | 4317 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4318 fqcn, |
4319 exchange, instance, flags, | |
4320 createtime, | |
4321 maxmsglen, maxoccupancy, createperms, unknown, | |
4322 name, ck); | |
4617 | 4323 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4324 } |
4325 break; | |
4326 default: | |
8660 | 4327 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4328 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4329 break; |
4330 } | |
4194 | 4331 |
4332 va_end(ap); | |
4333 | |
2086 | 4334 return 1; |
4335 } | |
4336 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4337 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4338 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4339 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4340 aim_userinfo_t *info; |
5575 | 4341 GaimConnection *g = sess->aux_data; |
2086 | 4342 |
4343 struct chat_connection *c = NULL; | |
4344 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4345 va_start(ap, fr); |
2086 | 4346 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4347 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4348 va_end(ap); |
4349 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4350 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4351 if (!c) |
4352 return 1; | |
4353 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4354 for (i = 0; i < count; i++) |
9846 | 4355 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4356 |
4357 return 1; | |
4358 } | |
4359 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4360 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4361 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4362 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4363 aim_userinfo_t *info; |
5575 | 4364 GaimConnection *g = sess->aux_data; |
2086 | 4365 |
4366 struct chat_connection *c = NULL; | |
4367 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4368 va_start(ap, fr); |
2086 | 4369 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4370 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4371 va_end(ap); |
4372 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4373 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4374 if (!c) |
4375 return 1; | |
4376 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4377 for (i = 0; i < count; i++) |
8733 | 4378 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4379 |
4380 return 1; | |
4381 } | |
4382 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4383 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
|
4384 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4385 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4386 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4387 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4388 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4389 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4390 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4391 fu32_t creationtime; |
5575 | 4392 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4393 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
|
4394 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4395 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4396 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4397 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4398 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4399 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4400 roomdesc = va_arg(ap, char *); |
4200 | 4401 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4402 creationtime = va_arg(ap, fu32_t); | |
4403 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4404 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4405 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4406 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4407 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4408 |
8660 | 4409 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4410 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4411 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4412 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4413 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4414 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4415 |
2086 | 4416 return 1; |
4417 } | |
4418 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4419 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4420 GaimConnection *gc = sess->aux_data; |
8225 | 4421 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4422 gchar *utf8; | |
2086 | 4423 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4424 aim_userinfo_t *info; |
8225 | 4425 int len; |
2086 | 4426 char *msg; |
8219 | 4427 char *charset; |
2086 | 4428 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4429 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4430 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4431 len = va_arg(ap, int); |
4194 | 4432 msg = va_arg(ap, char *); |
8219 | 4433 charset = va_arg(ap, char *); |
4194 | 4434 va_end(ap); |
2086 | 4435 |
8225 | 4436 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4437 if (utf8 == NULL) |
4438 /* The conversion failed! */ | |
8668 | 4439 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4440 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4441 g_free(utf8); | |
2086 | 4442 |
4443 return 1; | |
4444 } | |
4445 | |
3694 | 4446 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4447 va_list ap; | |
5575 | 4448 GaimConnection *gc = sess->aux_data; |
3694 | 4449 struct aim_emailinfo *emailinfo; |
3725 | 4450 int havenewmail; |
7297 | 4451 char *alertitle, *alerturl; |
3694 | 4452 |
4453 va_start(ap, fr); | |
4454 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4455 havenewmail = va_arg(ap, int); |
7301 | 4456 alertitle = va_arg(ap, char *); |
4457 alerturl = va_arg(ap, char *); | |
3694 | 4458 va_end(ap); |
4459 | |
9661 | 4460 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4461 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4462 emailinfo->domain ? "@" : "", | |
4463 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4464 if (emailinfo->unread && havenewmail) |
4465 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4466 g_free(to); |
3694 | 4467 } |
7297 | 4468 |
7301 | 4469 if (alertitle) |
8660 | 4470 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4471 |
4472 return 1; | |
4473 } | |
4474 | |
4804 | 4475 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4476 GaimConnection *gc = sess->aux_data; |
7283 | 4477 OscarData *od = gc->proto_data; |
4804 | 4478 char *sn; |
4479 | |
4480 sn = od->requesticon->data; | |
8660 | 4481 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4482 "removing %s from hash table\n", sn); |
4804 | 4483 od->requesticon = g_slist_remove(od->requesticon, sn); |
4484 free(sn); | |
4485 | |
4486 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4487 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4488 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4489 |
4490 return 1; | |
4491 } | |
4492 | |
4493 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4494 GaimConnection *gc = sess->aux_data; |
7283 | 4495 OscarData *od = gc->proto_data; |
4804 | 4496 GSList *cur; |
4497 va_list ap; | |
4498 char *sn; | |
4853 | 4499 fu8_t *iconcsum, *icon; |
4500 fu16_t iconcsumlen, iconlen; | |
4804 | 4501 |
4502 va_start(ap, fr); | |
4503 sn = va_arg(ap, char *); | |
4853 | 4504 iconcsum = va_arg(ap, fu8_t *); |
4505 iconcsumlen = va_arg(ap, int); | |
4804 | 4506 icon = va_arg(ap, fu8_t *); |
4507 iconlen = va_arg(ap, int); | |
4508 va_end(ap); | |
4509 | |
4853 | 4510 if (iconlen > 0) { |
4511 char *b16; | |
6695 | 4512 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4513 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4514 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4515 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4516 if (b16) { |
7693 | 4517 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4518 g_free(b16); |
5129 | 4519 } |
4853 | 4520 } |
4804 | 4521 |
4522 cur = od->requesticon; | |
4523 while (cur) { | |
4524 char *cursn = cur->data; | |
4525 if (!aim_sncmp(cursn, sn)) { | |
4526 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4527 free(cursn); | |
4528 cur = od->requesticon; | |
4529 } else | |
4530 cur = cur->next; | |
4531 } | |
4532 | |
4533 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4534 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4535 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4536 |
4537 return 1; | |
4538 } | |
4539 | |
4540 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4541 GaimConnection *gc = data; |
7283 | 4542 OscarData *od = gc->proto_data; |
7011 | 4543 aim_userinfo_t *userinfo; |
4804 | 4544 aim_conn_t *conn; |
4545 | |
4546 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4547 if (!conn) { |
4548 if (!od->iconconnecting) { | |
4549 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4550 od->iconconnecting = TRUE; | |
4551 } | |
4804 | 4552 return FALSE; |
4553 } | |
4554 | |
5842 | 4555 if (od->set_icon) { |
6039 | 4556 struct stat st; |
4557 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4558 if (iconfile == NULL) { | |
8363 | 4559 aim_ssi_delicon(od->sess); |
6039 | 4560 } else if (!stat(iconfile, &st)) { |
4561 char *buf = g_malloc(st.st_size); | |
4562 FILE *file = fopen(iconfile, "rb"); | |
4563 if (file) { | |
9532 | 4564 /* XXX - Use g_file_get_contents()? */ |
6039 | 4565 fread(buf, 1, st.st_size, file); |
4566 fclose(file); | |
8660 | 4567 gaim_debug_info("oscar", |
6039 | 4568 "Uploading icon to icon server\n"); |
6879 | 4569 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4570 } else |
8660 | 4571 gaim_debug_error("oscar", |
6039 | 4572 "Can't open buddy icon file!\n"); |
4573 g_free(buf); | |
4574 } else { | |
8660 | 4575 gaim_debug_error("oscar", |
6039 | 4576 "Can't stat buddy icon file!\n"); |
5842 | 4577 } |
4578 od->set_icon = FALSE; | |
4579 } | |
4580 | |
4581 if (!od->requesticon) { | |
8660 | 4582 gaim_debug_misc("oscar", |
5842 | 4583 "no more icons to request\n"); |
4584 return FALSE; | |
4585 } | |
4586 | |
7045 | 4587 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4588 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4589 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4590 return FALSE; |
4591 } else { | |
4592 char *sn = od->requesticon->data; | |
4593 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4594 free(sn); | |
4595 } | |
4596 | |
4597 return TRUE; | |
4598 } | |
4599 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4600 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4601 * 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
|
4602 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4603 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4604 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4605 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4606 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4607 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4608 va_start(ap, fr); |
4199 | 4609 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4610 sn = va_arg(ap, char *); |
4611 va_end(ap); | |
4612 | |
8660 | 4613 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4614 |
4615 return 1; | |
4616 } | |
4617 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4618 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
|
4619 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4620 "invalid", |
4194 | 4621 "change", |
4622 "warning", | |
4623 "limit", | |
4624 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4625 }; |
2086 | 4626 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4627 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4628 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4629 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4630 va_start(ap, fr); |
4200 | 4631 code = (fu16_t)va_arg(ap, unsigned int); |
4632 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4633 windowsize = va_arg(ap, fu32_t); | |
4634 clear = va_arg(ap, fu32_t); | |
4635 alert = va_arg(ap, fu32_t); | |
4636 limit = va_arg(ap, fu32_t); | |
4637 disconnect = va_arg(ap, fu32_t); | |
4638 currentavg = va_arg(ap, fu32_t); | |
4639 maxavg = va_arg(ap, fu32_t); | |
2086 | 4640 va_end(ap); |
4641 | |
8660 | 4642 gaim_debug_misc("oscar", |
5556 | 4643 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4644 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4645 (code < 5) ? codes[code] : codes[0], |
4646 rateclass, | |
4647 currentavg, maxavg, | |
4648 alert, clear, | |
4649 limit, disconnect, | |
4650 windowsize); | |
4651 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4652 /* XXX fix these values */ |
2086 | 4653 if (code == AIM_RATE_CODE_CHANGE) { |
4654 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4655 aim_conn_setlatency(fr->conn, 0); |
2086 | 4656 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4657 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4658 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4659 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4660 _("The last action you attempted could not be " |
4661 "performed because you are over the rate limit. " | |
4662 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4663 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4664 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4665 aim_conn_setlatency(fr->conn, 0); |
2086 | 4666 } |
4667 | |
4668 return 1; | |
4669 } | |
4670 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4671 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4672 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4673 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4674 aim_userinfo_t *userinfo; |
5575 | 4675 GaimConnection *gc = sess->aux_data; |
2086 | 4676 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4677 va_start(ap, fr); |
4199 | 4678 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4679 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4680 va_end(ap); |
4681 | |
7111 | 4682 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 4683 |
4684 return 1; | |
4685 } | |
4686 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4687 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
|
4688 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4689 aim_userinfo_t *info; |
5575 | 4690 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4691 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4692 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4693 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4694 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4695 |
5628 | 4696 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 4697 |
7872 | 4698 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 4699 gc->login_time_official = info->onlinesince; |
7872 | 4700 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
4701 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4702 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4703 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4704 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4705 |
4649 | 4706 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4707 GaimConnection *gc = sess->aux_data; |
7283 | 4708 OscarData *od = gc->proto_data; |
4649 | 4709 va_list ap; |
4710 fu16_t code; | |
4711 char *msg; | |
4712 | |
4713 va_start(ap, fr); | |
4714 code = (fu16_t)va_arg(ap, int); | |
4715 msg = va_arg(ap, char *); | |
4716 va_end(ap); | |
4717 | |
8660 | 4718 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4719 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4720 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4721 if (code == 0x0001) { |
6113 | 4722 gc->wants_to_die = TRUE; |
5579 | 4723 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4724 } else { |
5579 | 4725 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4726 } |
4666 | 4727 od->killme = TRUE; |
4649 | 4728 } |
4729 | |
4730 return 1; | |
4731 } | |
4732 | |
2675 | 4733 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4734 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4735 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4736 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4737 |
4738 #ifndef NOSSI | |
8660 | 4739 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4740 aim_ssi_reqrights(sess); |
6350 | 4741 aim_ssi_reqdata(sess); |
4230 | 4742 #endif |
4743 | |
7011 | 4744 aim_locate_reqrights(sess); |
7285 | 4745 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4746 aim_im_reqparams(sess); |
7334 | 4747 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4748 |
4749 #ifdef NOSSI | |
8660 | 4750 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4751 aim_bos_reqrights(sess, fr->conn); |
4230 | 4752 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4753 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4754 #endif | |
2086 | 4755 |
7283 | 4756 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4757 | |
2086 | 4758 return 1; |
4759 } | |
4760 | |
2675 | 4761 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4762 GaimConnection *gc = sess->aux_data; |
7283 | 4763 OscarData *od = gc->proto_data; |
2647 | 4764 |
6905 | 4765 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4766 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4767 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4768 | |
2672 | 4769 aim_clientready(sess, fr->conn); |
8660 | 4770 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4771 |
2647 | 4772 if (od->chpass) { |
8660 | 4773 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4774 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4775 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4776 od->oldp = NULL; |
2647 | 4777 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4778 od->newp = NULL; |
2647 | 4779 od->chpass = FALSE; |
4780 } | |
2979 | 4781 if (od->setnick) { |
8660 | 4782 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4783 aim_admin_setnick(sess, fr->conn, od->newsn); |
4784 g_free(od->newsn); | |
4785 od->newsn = NULL; | |
4786 od->setnick = FALSE; | |
4787 } | |
2647 | 4788 if (od->conf) { |
8660 | 4789 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4790 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4791 od->conf = FALSE; |
4792 } | |
4793 if (od->reqemail) { | |
8660 | 4794 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4795 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4796 od->reqemail = FALSE; |
4797 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4798 if (od->setemail) { |
8660 | 4799 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4800 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4801 g_free(od->email); |
5497 | 4802 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4803 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4804 } |
2647 | 4805 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4806 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4807 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4808 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4809 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
|
4810 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4811 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4812 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4813 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4814 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4815 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4816 |
4194 | 4817 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4818 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4819 "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
|
4820 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4821 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4822 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4823 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4824 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4825 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4826 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4827 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4828 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4829 |
4617 | 4830 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4831 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4832 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4833 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4834 |
2993 | 4835 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4836 { | |
5575 | 4837 GaimConnection *gc = sess->aux_data; |
7283 | 4838 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4839 va_list ap; |
4840 fu16_t maxsiglen; | |
2993 | 4841 |
4842 va_start(ap, fr); | |
4199 | 4843 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4844 va_end(ap); |
4845 | |
8660 | 4846 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4847 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4848 |
4617 | 4849 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4850 | |
4851 if (od->icq) | |
7334 | 4852 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4853 else |
7334 | 4854 aim_locate_setcaps(od->sess, caps_aim); |
4855 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4856 |
4857 return 1; | |
4858 } | |
4859 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4860 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
|
4861 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4862 fu16_t maxbuddies, maxwatchers; |
5575 | 4863 GaimConnection *gc = sess->aux_data; |
7283 | 4864 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4865 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4866 va_start(ap, fr); |
4199 | 4867 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4868 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4869 va_end(ap); |
4870 | |
8660 | 4871 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4872 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4873 |
4617 | 4874 od->rights.maxbuddies = (guint)maxbuddies; |
4875 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4876 |
2086 | 4877 return 1; |
4878 } | |
4879 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4880 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4881 GaimConnection *gc = sess->aux_data; |
7283 | 4882 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4883 va_list ap; |
4884 fu16_t maxpermits, maxdenies; | |
2086 | 4885 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4886 va_start(ap, fr); |
4199 | 4887 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4888 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4889 va_end(ap); |
4890 | |
8660 | 4891 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4892 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4893 |
4617 | 4894 od->rights.maxpermits = (guint)maxpermits; |
4895 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4896 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4897 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4898 serv_finish_login(gc); |
4899 | |
8660 | 4900 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4901 |
2672 | 4902 aim_clientready(sess, fr->conn); |
5948 | 4903 aim_srv_setavailmsg(sess, NULL); |
7474 | 4904 aim_srv_setidle(sess, 0); |
4617 | 4905 |
4664 | 4906 if (od->icq) { |
4907 aim_icq_reqofflinemsgs(sess); | |
4908 aim_icq_hideip(sess); | |
4909 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4910 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4911 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4912 if (sess->authinfo->email) |
4913 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4914 |
4915 return 1; | |
4916 } | |
4917 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4918 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
|
4919 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4920 struct aim_icq_offlinemsg *msg; |
4075 | 4921 struct aim_incomingim_ch4_args args; |
4922 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4923 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4924 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4925 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4926 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4927 |
8660 | 4928 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4929 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4930 args.uin = msg->sender; |
4931 args.type = msg->type; | |
4173 | 4932 args.flags = msg->flags; |
4076 | 4933 args.msglen = msg->msglen; |
4075 | 4934 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4935 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4936 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4937 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4938 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4939 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4940 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4941 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
|
4942 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4943 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4944 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4945 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4946 |
7388 | 4947 #if 0 |
4948 /* | |
7465 | 4949 * Update, 2003-11-09: |
4950 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4951 * | |
7388 | 4952 * It may not be my place to do this, but... |
4953 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4954 * stupid, and should not exist for % switches (%x in our case) that request | |
4955 * a year in the preferred representation for the current locale. For that | |
4956 * reason I've chosen to not use this workaround (n., see kluge). | |
4957 * | |
4958 * I have a date. I want to show it to the user in the "preferred" way. | |
4959 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4960 * what the locale wanted. | |
4961 * | |
4962 * If I have a necessity for a full representation of the year in the current | |
4963 * locale, then I'll use a switch that returns a full representation of the | |
4964 * year. | |
4965 * | |
4966 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4967 * (because you're anal, or whatever), then change the f***ing locale. | |
4968 * | |
4969 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4970 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4971 * |
4972 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4973 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4974 */ |
4975 | |
4976 /* | |
4977 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4978 * "last 2 digits" warning. |
4979 */ | |
4980 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4981 const struct tm *tm) | |
4982 { | |
4983 return strftime(s, max, fmt, tm); | |
4984 } | |
7388 | 4985 #endif |
7386 | 4986 |
4624 | 4987 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
|
4988 { |
5575 | 4989 GaimConnection *gc = sess->aux_data; |
8670 | 4990 OscarData *od = (OscarData *)gc->proto_data; |
4991 GaimBuddy *buddy; | |
8853 | 4992 struct buddyinfo *bi = NULL; |
4624 | 4993 gchar who[16]; |
8670 | 4994 GString *str; |
4995 gchar *primary, *utf8; | |
9634 | 4996 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4997 va_list ap; |
4151 | 4998 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4999 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5000 va_start(ap, fr); |
4151 | 5001 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5002 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5003 |
4664 | 5004 if (!info->uin) |
5005 return 0; | |
5006 | |
8670 | 5007 str = g_string_sized_new(100); |
5556 | 5008 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5009 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5010 if (buddy != NULL) | |
5011 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5012 | |
5013 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5014 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5015 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5016 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5017 (bi->ipaddr & 0xff000000) >> 24, | |
5018 (bi->ipaddr & 0x00ff0000) >> 16, | |
5019 (bi->ipaddr & 0x0000ff00) >> 8, | |
5020 (bi->ipaddr & 0x000000ff)); | |
8701 | 5021 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5022 g_free(tstr); |
5023 } | |
8701 | 5024 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5025 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5026 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5027 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5028 g_free(utf8); | |
4625 | 5029 } |
5030 if (info->numaddresses && info->email2) { | |
5031 int i; | |
5032 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5033 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5034 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5035 g_free(utf8); | |
4643 | 5036 } |
4625 | 5037 } |
4624 | 5038 } |
8701 | 5039 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
8902 | 5040 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
5041 info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5042 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5043 char date[30]; |
5044 struct tm tm; | |
5045 tm.tm_mday = (int)info->birthday; | |
5046 tm.tm_mon = (int)info->birthmonth-1; | |
5047 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5048 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5049 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5050 } |
4624 | 5051 if (info->age) { |
5052 char age[5]; | |
5053 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5054 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5055 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5056 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5057 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5058 g_free(utf8); | |
4819 | 5059 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5060 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5061 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5062 g_free(utf8); | |
5063 } | |
5064 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5065 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5066 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5067 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5068 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5069 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5070 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5071 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5072 } |
4641 | 5073 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5074 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5075 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5076 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5077 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5078 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5079 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5080 } |
4641 | 5081 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5082 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5083 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5084 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5085 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5086 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5087 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5088 g_free(utf8); | |
4624 | 5089 } |
8670 | 5090 g_string_append_printf(str, "\n<hr>\n"); |
5091 } | |
5092 | |
9634 | 5093 if (buddy != NULL) |
5094 alias = gaim_buddy_get_alias(buddy); | |
5095 else | |
5096 alias = who; | |
5097 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5098 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5099 g_free(primary); |
8670 | 5100 g_string_free(str, TRUE); |
4151 | 5101 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5102 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5103 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5104 |
4759 | 5105 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5106 { | |
5575 | 5107 GaimConnection *gc = sess->aux_data; |
4820 | 5108 gchar who[16], *utf8; |
6695 | 5109 GaimBuddy *b; |
4759 | 5110 va_list ap; |
5111 struct aim_icq_info *info; | |
5112 | |
5113 va_start(ap, fr); | |
5114 info = va_arg(ap, struct aim_icq_info *); | |
5115 va_end(ap); | |
5116 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5117 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5118 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5119 serv_got_alias(gc, who, utf8); |
4759 | 5120 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5121 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5122 } |
4820 | 5123 g_free(utf8); |
4759 | 5124 } |
5125 | |
5126 return 1; | |
5127 } | |
5128 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5129 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
|
5130 { |
7032 | 5131 GaimConnection *gc = sess->aux_data; |
5132 gchar *text; | |
5133 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5134 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5135 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5136 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5137 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5138 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5139 url = va_arg(ap, char *); |
4199 | 5140 wid = (fu16_t) va_arg(ap, int); |
5141 hei = (fu16_t) va_arg(ap, int); | |
5142 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5143 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5144 |
7032 | 5145 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5146 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5147 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5148 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5149 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5150 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5151 |
7032 | 5152 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5153 { | |
6873 | 5154 GaimConnection *gc = sess->aux_data; |
5155 gchar *secondary; | |
5156 GString *text; | |
5157 int i, num; | |
2086 | 5158 va_list ap; |
6873 | 5159 char *email, *SNs; |
2086 | 5160 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5161 va_start(ap, fr); |
6873 | 5162 email = va_arg(ap, char *); |
2086 | 5163 num = va_arg(ap, int); |
5164 SNs = va_arg(ap, char *); | |
5165 va_end(ap); | |
5166 | |
8152 | 5167 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5168 text = g_string_new(""); |
2086 | 5169 for (i = 0; i < num; i++) |
6873 | 5170 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5171 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5172 | |
5173 g_free(secondary); | |
5174 g_string_free(text, TRUE); | |
2086 | 5175 |
5176 return 1; | |
5177 } | |
5178 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5179 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5180 va_list ap; |
6873 | 5181 char *email; |
5420 | 5182 char *buf; |
2086 | 5183 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5184 va_start(ap, fr); |
6873 | 5185 email = va_arg(ap, char *); |
2086 | 5186 va_end(ap); |
5187 | |
6873 | 5188 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
|
5189 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5190 g_free(buf); |
2086 | 5191 |
5192 return 1; | |
5193 } | |
5194 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5195 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5196 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5197 fu16_t status; |
2086 | 5198 va_list ap; |
5199 char msg[256]; | |
5200 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5201 va_start(ap, fr); |
4199 | 5202 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5203 va_end(ap); |
5204 | |
8660 | 5205 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5206 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5207 status ? "unknown" : "email sent"); |
5208 if (!status) { | |
5302 | 5209 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5210 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5211 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5212 } |
5213 | |
5214 return 1; | |
5215 } | |
5216 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5217 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5218 GaimConnection *gc = sess->aux_data; |
2086 | 5219 va_list ap; |
3912 | 5220 fu16_t perms, err; |
5221 char *url, *sn, *email; | |
5222 int change; | |
2086 | 5223 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5224 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5225 change = va_arg(ap, int); |
4199 | 5226 perms = (fu16_t) va_arg(ap, unsigned int); |
5227 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5228 url = va_arg(ap, char *); |
5229 sn = va_arg(ap, char *); | |
5230 email = va_arg(ap, char *); | |
2086 | 5231 va_end(ap); |
5232 | |
8660 | 5233 gaim_debug_misc("oscar", |
9626 | 5234 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5235 change ? "change" : "request", perms, err, | |
5236 (url != NULL) ? url : "(null)", | |
5237 (sn != NULL) ? sn : "(null)", | |
5238 (email != NULL) ? email : "(null)"); | |
5239 | |
5240 if ((err > 0) && (url != NULL)) { | |
3912 | 5241 char *dialog_msg; |
5242 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5243 switch (err) { | |
5244 case 0x0001: { | |
5245 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5246 } break; | |
5247 case 0x0006: { | |
5248 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5249 } break; | |
5250 case 0x000b: { | |
5251 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5252 } break; | |
5253 case 0x001d: { | |
5254 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); | |
5255 } break; | |
5256 case 0x0021: { | |
5257 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); | |
5258 } break; | |
5259 case 0x0023: { | |
5260 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5261 } break; | |
5262 default: { | |
5263 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5264 } break; | |
5265 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5266 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5267 g_free(dialog_top); |
5268 g_free(dialog_msg); | |
5269 return 1; | |
5270 } | |
5271 | |
9626 | 5272 if (sn != NULL) { |
4585 | 5273 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
|
5274 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5275 g_free(dialog_msg); |
5276 } | |
5277 | |
9626 | 5278 if (email != NULL) { |
5575 | 5279 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5280 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5281 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5282 g_free(dialog_msg); |
2086 | 5283 } |
5284 | |
5285 return 1; | |
5286 } | |
5287 | |
5575 | 5288 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5289 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5290 aim_flap_nop(od->sess, od->conn); |
2086 | 5291 } |
5292 | |
6059 | 5293 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5294 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5295 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5296 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5297 if (typing == GAIM_TYPING) |
4870 | 5298 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5299 else if (typing == GAIM_TYPED) |
4870 | 5300 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5301 else | |
5302 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5303 else { |
5300 | 5304 /* Don't send if this turkey is in our deny list */ |
5305 GSList *list; | |
5306 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5307 if (!list) { | |
7261 | 5308 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5309 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5310 if (typing == GAIM_TYPING) |
5300 | 5311 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5312 else if (typing == GAIM_TYPED) |
5300 | 5313 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5314 else | |
5315 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5316 } | |
3595 | 5317 } |
5318 } | |
2993 | 5319 return 0; |
5320 } | |
9030 | 5321 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5322 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
|
5323 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5324 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5325 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5326 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
|
5327 int ret = 0; |
5575 | 5328 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5329 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5330 |
4838 | 5331 if (dim && dim->connected) { |
5332 /* If we're directly connected, send a direct IM */ | |
6982 | 5333 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5334 } else { |
4738 | 5335 struct buddyinfo *bi; |
3008 | 5336 struct aim_sendimext_args args; |
5337 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5338 gsize len; |
8962 | 5339 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5340 | |
5341 if (strstr(message, "<IMG ")) | |
5342 gaim_conversation_write(conv, "", | |
5343 _("Your IM Image was not sent. " | |
5344 "You must be Direct Connected to send IM Images."), | |
5345 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5346 |
7261 | 5347 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5348 if (!bi) { |
5349 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5350 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5351 } |
5352 | |
3008 | 5353 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5354 if (od->icq) { |
5355 args.features = features_icq; | |
5356 args.featureslen = sizeof(features_icq); | |
3008 | 5357 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5358 } else { |
5359 args.features = features_aim; | |
5360 args.featureslen = sizeof(features_aim); | |
4972 | 5361 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5362 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5363 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5364 } |
4269 | 5365 |
4738 | 5366 if (bi->ico_need) { |
8660 | 5367 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5368 "Sending buddy icon request with message\n"); |
3008 | 5369 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5370 bi->ico_need = FALSE; |
3008 | 5371 } |
4269 | 5372 |
5575 | 5373 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5374 FILE *file = fopen(iconfile, "rb"); |
3008 | 5375 if (file) { |
5376 char *buf = g_malloc(st.st_size); | |
9532 | 5377 /* XXX - Use g_file_get_contents()? */ |
3008 | 5378 fread(buf, 1, st.st_size, file); |
6039 | 5379 fclose(file); |
4269 | 5380 |
3008 | 5381 args.iconlen = st.st_size; |
4617 | 5382 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5383 args.iconstamp = st.st_mtime; |
5384 | |
7406 | 5385 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5386 bi->ico_informed = FALSE; |
7406 | 5387 bi->ico_sent = FALSE; |
5388 } | |
4738 | 5389 |
5390 if (!bi->ico_informed) { | |
8660 | 5391 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5392 "Claiming to have a buddy icon\n"); |
4738 | 5393 args.flags |= AIM_IMFLAGS_HASICON; |
5394 bi->ico_me_len = args.iconlen; | |
5395 bi->ico_me_csum = args.iconsum; | |
5396 bi->ico_me_time = args.iconstamp; | |
5397 bi->ico_informed = TRUE; | |
5398 } | |
5399 | |
3008 | 5400 g_free(buf); |
2086 | 5401 } |
5402 } | |
4269 | 5403 |
3008 | 5404 args.destsn = name; |
4269 | 5405 |
8985 | 5406 /* |
5407 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5408 * strip all HTML | |
5409 */ | |
8995 | 5410 if (isdigit(name[0]) ) { |
5411 /* being sent to an ICQ user */ | |
5412 if (!isdigit(gaim_account_get_username(gc->account)[0])) { | |
5413 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ | |
5414 tmpmsg = gaim_str_add_cr(message); | |
5415 } else { | |
5416 /* from an ICQ user - do nothing */ | |
5417 tmpmsg = g_strdup(message); | |
5418 } | |
5419 } else { | |
5420 /* being sent to an AIM user */ | |
5421 if (isdigit(gaim_account_get_username(gc->account)[0])) { | |
5422 /* from an ICQ user */ | |
5423 tmpmsg2 = gaim_strdup_withhtml(message); | |
5424 tmpmsg = gaim_escape_html(tmpmsg2); | |
5425 g_free(tmpmsg2); | |
5426 } else | |
5427 tmpmsg = gaim_strdup_withhtml(message); | |
5428 } | |
6310 | 5429 len = strlen(tmpmsg); |
5430 | |
9830 | 5431 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5432 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5433 args.charset, args.charsubset, args.msglen); | |
4617 | 5434 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5435 g_free((char *)args.msg); |
2086 | 5436 } |
4838 | 5437 |
6310 | 5438 g_free(tmpmsg); |
5439 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5440 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5441 return 1; |
6310 | 5442 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5443 return ret; |
2086 | 5444 } |
5445 | |
7011 | 5446 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5447 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5448 |
7173 | 5449 if (od->icq && isdigit(name[0])) |
4624 | 5450 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5451 else |
7235 | 5452 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5453 } |
5454 | |
8950 | 5455 #if 0 |
7011 | 5456 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5457 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5458 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5459 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5460 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5461 maiden, NULL, NULL, city, state, NULL, 0, web); |
5462 } | |
8950 | 5463 #endif |
2086 | 5464 |
5575 | 5465 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5466 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5467 aim_srv_setidle(od->sess, time); |
2086 | 5468 } |
5469 | |
5954 | 5470 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5471 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5472 int charset = 0; |
6019 | 5473 char *text_html = NULL; |
5129 | 5474 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5475 gsize msglen = 0; |
2993 | 5476 |
4617 | 5477 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5478 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5479 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5480 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5481 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5482 "again when you are fully connected.")); |
4617 | 5483 |
7334 | 5484 if (!text) { |
5485 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5486 return; | |
5487 } | |
6019 | 5488 |
7334 | 5489 text_html = gaim_strdup_withhtml(text); |
9807 | 5490 charset = oscar_charset_check(text_html); |
9826 | 5491 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5492 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5493 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5494 g_free(msg); | |
9826 | 5495 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5496 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5497 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5498 g_free(msg); | |
5499 } else { | |
5500 msglen = strlen(text_html); | |
5501 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5502 } | |
5503 | |
5504 if (msglen > od->rights.maxsiglen) { | |
5505 gchar *errstr; | |
5506 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5507 "has been exceeded. Gaim has truncated it for you.", | |
5508 "The maximum profile length of %d bytes " | |
5509 "has been exceeded. Gaim has truncated it for you.", | |
5510 od->rights.maxsiglen), od->rights.maxsiglen); | |
5511 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5512 g_free(errstr); | |
5513 } | |
5514 | |
5515 g_free(text_html); | |
2993 | 5516 |
5517 return; | |
2086 | 5518 } |
5519 | |
8257 | 5520 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 5521 { |
9807 | 5522 int charset = 0; |
6019 | 5523 gchar *text_html = NULL; |
5129 | 5524 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5525 gsize msglen = 0; |
2993 | 5526 |
8257 | 5527 if (!strcmp(state, _("Visible"))) { |
5528 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5529 return; | |
5530 } else if (!strcmp(state, _("Invisible"))) { | |
5531 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5532 return; | |
5533 } /* else... */ | |
5534 | |
8476 | 5535 if (!strcmp(state, _("Back"))) { |
5536 /* If this is our only online account then globally set Gaim not-away */ | |
5537 GList *gcs = gaim_connections_get_all(); | |
5538 if (gcs->next == NULL) | |
9730 | 5539 ; /* XXX do_im_back(NULL, NULL); */ |
8476 | 5540 } |
5541 | |
8257 | 5542 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5543 | |
2993 | 5544 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5545 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5546 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5547 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5548 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5549 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5550 "fully connected.")); |
5129 | 5551 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5552 if (gc->away) { |
2993 | 5553 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5554 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5555 } |
2993 | 5556 |
5129 | 5557 if (!text) { |
7334 | 5558 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5559 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5560 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5561 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5562 text_html = gaim_strdup_withhtml(text); |
9807 | 5563 charset = oscar_charset_check(text_html); |
9826 | 5564 if (charset == AIM_CHARSET_UNICODE) { |
6019 | 5565 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5566 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5567 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5568 g_free(msg); |
5569 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
9826 | 5570 } else if (charset == AIM_CHARSET_CUSTOM) { |
6019 | 5571 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5572 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5573 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5574 g_free(msg); |
6019 | 5575 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5576 } else { |
6019 | 5577 msglen = strlen(text_html); |
7011 | 5578 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5579 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 5580 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5581 } |
5582 | |
5583 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5584 gchar *errstr; |
5585 | |
6308 | 5586 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5587 "has been exceeded. Gaim has truncated it for you.", | |
5588 "The maximum away message length of %d bytes " | |
5589 "has been exceeded. Gaim has truncated it for you.", | |
5590 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5591 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5592 g_free(errstr); |
5593 } | |
6019 | 5594 |
5595 g_free(text_html); | |
8257 | 5596 |
2993 | 5597 return; |
5598 } | |
5599 | |
7283 | 5600 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 5601 { |
5575 | 5602 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5603 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5604 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5605 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5606 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5607 |
8265 | 5608 if (strcmp(state, _("Invisible"))) |
5575 | 5609 account->perm_deny = 4; |
8265 | 5610 else |
5575 | 5611 account->perm_deny = 3; |
8265 | 5612 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5613 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5614 |
5615 if (!strcmp(state, _("Online"))) | |
4901 | 5616 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 5617 else if (!strcmp(state, _("Away"))) { |
4901 | 5618 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5619 gc->away = g_strdup(""); |
4342 | 5620 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 5621 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
|
5622 gc->away = g_strdup(""); |
4342 | 5623 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 5624 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
|
5625 gc->away = g_strdup(""); |
4342 | 5626 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 5627 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
|
5628 gc->away = g_strdup(""); |
4342 | 5629 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 5630 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5631 gc->away = g_strdup(""); |
4342 | 5632 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 5633 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5634 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5635 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 5636 if (message) { |
4901 | 5637 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
|
5638 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5639 } else { |
4901 | 5640 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5641 } |
2086 | 5642 } |
2993 | 5643 |
5644 return; | |
5645 } | |
5646 | |
6059 | 5647 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 5648 { |
7283 | 5649 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 5650 |
5651 if (od->icq) | |
5652 oscar_set_away_icq(gc, od, state, message); | |
5653 else | |
8257 | 5654 oscar_set_away_aim(gc, od, state, message); |
2993 | 5655 |
5656 return; | |
2086 | 5657 } |
5658 | |
9753 | 5659 static void oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { |
7283 | 5660 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5661 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5662 } |
5663 | |
9285 | 5664 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5665 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5666 |
5667 if (!aim_snvalid(buddy->name)) { | |
8092 | 5668 gchar *buf; |
9285 | 5669 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 | 5670 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5671 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5672 g_free(buf); |
8150 | 5673 |
5674 /* Remove from local list */ | |
9285 | 5675 gaim_blist_remove_buddy(buddy); |
8150 | 5676 |
8092 | 5677 return; |
5678 } | |
5679 | |
4230 | 5680 #ifdef NOSSI |
9285 | 5681 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5682 #else |
9285 | 5683 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5684 if (buddy && group) { | |
8660 | 5685 gaim_debug_info("oscar", |
9285 | 5686 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5687 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5688 } |
5689 } | |
5690 #endif | |
8150 | 5691 |
4759 | 5692 if (od->icq) |
9285 | 5693 aim_icq_getalias(od->sess, buddy->name); |
5694 } | |
5695 | |
5696 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5697 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5698 #ifdef NOSSI |
5699 char buf[MSG_LEN]; | |
5700 int n=0; | |
9285 | 5701 |
4230 | 5702 while (buddies) { |
9381 | 5703 GaimBuddy *buddy = buddies->data; |
4230 | 5704 if (n > MSG_LEN - 18) { |
7285 | 5705 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5706 n = 0; |
3092 | 5707 } |
9381 | 5708 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5709 buddies = buddies->next; |
5710 } | |
7285 | 5711 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5712 #else |
9285 | 5713 |
4230 | 5714 if (od->sess->ssi.received_data) { |
9285 | 5715 GList *curb = buddies; |
5716 GList *curg = groups; | |
5717 while ((curb != NULL) && (curg != NULL)) { | |
5718 GaimBuddy *buddy = curb->data; | |
5719 GaimGroup *group = curg->data; | |
5720 oscar_add_buddy(gc, buddy, group); | |
5721 curb = curb->next; | |
5722 curg = curg->next; | |
4230 | 5723 } |
5724 } | |
5725 #endif | |
5726 } | |
5727 | |
9285 | 5728 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5729 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5730 |
4230 | 5731 #ifdef NOSSI |
9285 | 5732 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5733 #else |
5734 if (od->sess->ssi.received_data) { | |
8660 | 5735 gaim_debug_info("oscar", |
9285 | 5736 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5737 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5738 } |
5739 #endif | |
5740 } | |
5741 | |
9285 | 5742 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5743 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5744 |
4230 | 5745 #ifdef NOSSI |
9285 | 5746 for (cur = buddies; cur != NULL; cur = cur->next) { |
5747 GaimBuddy *buddy = cur->data; | |
5748 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5749 } | |
4230 | 5750 #else |
5751 if (od->sess->ssi.received_data) { | |
9285 | 5752 GList *curb = buddies; |
5753 GList *curg = groups; | |
5754 while ((curb != NULL) && (curg != NULL)) { | |
5755 GaimBuddy *buddy = curb->data; | |
5756 GaimGroup *group = curg->data; | |
5757 oscar_remove_buddy(gc, buddy, group); | |
5758 curb = curb->next; | |
5759 curg = curg->next; | |
3092 | 5760 } |
4230 | 5761 } |
5762 #endif | |
5763 } | |
5764 | |
5765 #ifndef NOSSI | |
5575 | 5766 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5767 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5768 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5769 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5770 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5771 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5772 } |
5773 } | |
5774 | |
5575 | 5775 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5776 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5777 if (od->sess->ssi.received_data) { |
5778 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5779 if (gname) { | |
8660 | 5780 gaim_debug_info("oscar", |
9586 | 5781 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5782 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5783 } |
5784 } | |
5785 } | |
5786 | |
9285 | 5787 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5788 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5789 |
5790 if (od->sess->ssi.received_data) { | |
9285 | 5791 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5792 GList *cur, *groups = NULL; | |
5793 | |
5794 /* Make a list of what the groups each buddy is in */ | |
5795 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5796 GaimBlistNode *node = cur->data; | |
5797 groups = g_list_append(groups, node->parent); | |
5798 } | |
5799 | |
5800 oscar_remove_buddies(gc, moved_buddies, groups); | |
5801 oscar_add_buddies(gc, moved_buddies, groups); | |
5802 g_list_free(groups); | |
8660 | 5803 gaim_debug_info("oscar", |
9285 | 5804 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5805 } else { |
9285 | 5806 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5807 gaim_debug_info("oscar", |
9285 | 5808 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5809 } |
5810 } | |
5811 } | |
5812 | |
5968 | 5813 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5814 aim_session_t *sess = data; | |
6350 | 5815 aim_ssi_reqdata(sess); |
5968 | 5816 return FALSE; |
5817 } | |
5818 | |
4642 | 5819 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5820 GaimConnection *gc = sess->aux_data; |
7283 | 5821 OscarData *od = gc->proto_data; |
4642 | 5822 va_list ap; |
5823 fu16_t reason; | |
5824 | |
5825 va_start(ap, fr); | |
5826 reason = (fu16_t)va_arg(ap, unsigned int); | |
5827 va_end(ap); | |
5828 | |
8660 | 5829 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5830 |
5831 if (reason == 0x0005) { | |
5892 | 5832 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5833 _("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
|
5834 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5835 } |
5836 | |
5837 /* Activate SSI */ | |
5838 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5839 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5840 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5841 aim_ssi_enable(od->sess); |
5842 | |
5843 return 1; | |
5844 } | |
5845 | |
2991 | 5846 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5847 GaimConnection *gc = sess->aux_data; |
7283 | 5848 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5849 int numtypes, i; |
5850 fu16_t *maxitems; | |
2991 | 5851 va_list ap; |
5852 | |
5853 va_start(ap, fr); | |
4230 | 5854 numtypes = va_arg(ap, int); |
5855 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5856 va_end(ap); |
5857 | |
8660 | 5858 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5859 |
4230 | 5860 for (i=0; i<numtypes; i++) |
8660 | 5861 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5862 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5863 |
8660 | 5864 gaim_debug_misc(NULL, "\n"); |
4230 | 5865 |
5866 if (numtypes >= 0) | |
5867 od->rights.maxbuddies = maxitems[0]; | |
5868 if (numtypes >= 1) | |
5869 od->rights.maxgroups = maxitems[1]; | |
5870 if (numtypes >= 2) | |
5871 od->rights.maxpermits = maxitems[2]; | |
5872 if (numtypes >= 3) | |
5873 od->rights.maxdenies = maxitems[3]; | |
2991 | 5874 |
5875 return 1; | |
5876 } | |
5877 | |
5878 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5879 GaimConnection *gc = sess->aux_data; |
5880 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5881 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5882 GaimGroup *g; |
5883 GaimBuddy *b; | |
2995 | 5884 struct aim_ssi_item *curitem; |
2991 | 5885 int tmp; |
4230 | 5886 va_list ap; |
8219 | 5887 fu16_t fmtver, numitems; |
5888 struct aim_ssi_item *items; | |
5889 fu32_t timestamp; | |
4230 | 5890 |
5891 va_start(ap, fr); | |
5892 fmtver = (fu16_t)va_arg(ap, int); | |
5893 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5894 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5895 timestamp = va_arg(ap, fu32_t); |
8219 | 5896 va_end(ap); |
2991 | 5897 |
8660 | 5898 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5899 "ssi: syncing local list and server list\n"); |
2991 | 5900 |
8219 | 5901 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5902 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 | 5903 return 1; |
5904 } | |
5905 | |
2991 | 5906 /* Clean the buddy list */ |
4889 | 5907 aim_ssi_cleanlist(sess); |
2991 | 5908 |
8150 | 5909 { /* If not in server list then prune from local list */ |
5910 GaimBlistNode *gnode, *cnode, *bnode; | |
5911 GaimBuddyList *blist; | |
9539 | 5912 GSList *cur, *next; |
8150 | 5913 |
5914 /* Buddies */ | |
5915 cur = NULL; | |
5916 if ((blist = gaim_get_blist()) != NULL) { | |
5917 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5918 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5919 continue; | |
5920 g = (GaimGroup *)gnode; | |
5921 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5922 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5923 continue; | |
5924 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5925 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5926 continue; | |
5927 b = (GaimBuddy *)bnode; | |
5928 if (b->account == gc->account) { | |
5929 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5930 /* If the buddy is an ICQ user then load his nickname */ | |
5931 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5932 char *alias; |
8150 | 5933 if (servernick) |
5934 serv_got_alias(gc, b->name, servernick); | |
5935 | |
5936 /* Store local alias on server */ | |
8214 | 5937 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5938 if (!alias && b->alias && strlen(b->alias)) |
5939 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5940 free(alias); | |
5941 } else { | |
8660 | 5942 gaim_debug_info("oscar", |
8150 | 5943 "ssi: removing buddy %s from local list\n", b->name); |
5944 /* We can't actually remove now because it will screw up our looping */ | |
5945 cur = g_slist_prepend(cur, b); | |
5946 } | |
5947 } | |
5948 } | |
5949 } | |
5950 } | |
5951 } | |
8175 | 5952 |
8150 | 5953 while (cur != NULL) { |
5954 b = cur->data; | |
5955 cur = g_slist_remove(cur, b); | |
5956 gaim_blist_remove_buddy(b); | |
5957 } | |
5958 | |
5959 /* Permit list */ | |
5960 if (gc->account->permit) { | |
9539 | 5961 next = gc->account->permit; |
5962 while (next != NULL) { | |
5963 cur = next; | |
5964 next = next->next; | |
8150 | 5965 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5966 gaim_debug_info("oscar", |
8150 | 5967 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5968 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5969 } | |
9539 | 5970 } |
8150 | 5971 } |
5972 | |
5973 /* Deny list */ | |
5974 if (gc->account->deny) { | |
9539 | 5975 next = gc->account->deny; |
5976 while (next != NULL) { | |
5977 cur = next; | |
5978 next = next->next; | |
8150 | 5979 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 5980 gaim_debug_info("oscar", |
8150 | 5981 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5982 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5983 } | |
9539 | 5984 } |
8150 | 5985 } |
5986 /* Presence settings (idle time visibility) */ | |
5987 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5988 if (!(tmp & 0x400)) | |
5989 aim_ssi_setpresence(sess, tmp | 0x400); | |
5990 } /* end pruning buddies from local list */ | |
5991 | |
2991 | 5992 /* Add from server list to local list */ |
4230 | 5993 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 5994 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 5995 switch (curitem->type) { |
4230 | 5996 case 0x0000: { /* Buddy */ |
4251 | 5997 if (curitem->name) { |
4292 | 5998 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 5999 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6000 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6001 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6002 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6003 /* Should gname be freed here? -- elb */ |
4754 | 6004 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6005 free(alias); |
8150 | 6006 if (b) { |
4292 | 6007 /* Get server stored alias */ |
4705 | 6008 if (alias_utf8) { |
8150 | 6009 g_free(b->alias); |
6010 b->alias = g_strdup(alias_utf8); | |
4705 | 6011 } |
4282 | 6012 } else { |
8150 | 6013 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6014 |
4754 | 6015 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6016 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6017 gaim_blist_add_group(g, NULL); |
6018 } | |
5146 | 6019 |
8660 | 6020 gaim_debug_info("oscar", |
9285 | 6021 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6022 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6023 } |
8341 | 6024 if (!aim_sncmp(curitem->name, account->username)) { |
6025 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6026 gaim_check_comment(od, comment); | |
6027 free(comment); | |
6028 } | |
7162 | 6029 g_free(gname_utf8); |
6030 g_free(alias_utf8); | |
2991 | 6031 } |
4230 | 6032 } break; |
6033 | |
6034 case 0x0001: { /* Group */ | |
4282 | 6035 /* Shouldn't add empty groups */ |
4230 | 6036 } break; |
6037 | |
6038 case 0x0002: { /* Permit buddy */ | |
2991 | 6039 if (curitem->name) { |
4230 | 6040 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6041 GSList *list; |
5575 | 6042 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6043 if (!list) { |
8660 | 6044 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6045 "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
|
6046 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6047 } |
6048 } | |
4230 | 6049 } break; |
6050 | |
6051 case 0x0003: { /* Deny buddy */ | |
2991 | 6052 if (curitem->name) { |
6053 GSList *list; | |
5575 | 6054 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6055 if (!list) { |
8660 | 6056 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6057 "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
|
6058 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6059 } |
6060 } | |
4230 | 6061 } break; |
6062 | |
6063 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6064 if (curitem->data) { |
6065 fu8_t permdeny; | |
5575 | 6066 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6067 gaim_debug_info("oscar", |
5575 | 6068 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6069 account->perm_deny = permdeny; | |
6070 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 6071 serv_set_away(gc, "Invisible", ""); |
6072 } | |
2991 | 6073 } |
6074 } | |
4230 | 6075 } break; |
6076 | |
6077 case 0x0005: { /* Presence setting */ | |
3109 | 6078 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6079 } break; |
2991 | 6080 } /* End of switch on curitem->type */ |
6081 } /* End of for loop */ | |
4230 | 6082 |
4901 | 6083 /* Set our ICQ status */ |
8257 | 6084 if (!gc->away) { |
4901 | 6085 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6086 } | |
6087 | |
4342 | 6088 /* Activate SSI */ |
6089 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6090 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6091 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6092 "ssi: activating server-stored buddy list\n"); |
4642 | 6093 aim_ssi_enable(sess); |
4342 | 6094 |
2991 | 6095 return 1; |
2086 | 6096 } |
4230 | 6097 |
6098 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6099 GaimConnection *gc = sess->aux_data; |
4230 | 6100 va_list ap; |
6101 struct aim_ssi_tmp *retval; | |
6102 | |
6103 va_start(ap, fr); | |
6104 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6105 va_end(ap); | |
6106 | |
6107 while (retval) { | |
8660 | 6108 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6109 "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 | 6110 |
6111 if (retval->ack != 0xffff) | |
6112 switch (retval->ack) { | |
6113 case 0x0000: { /* added successfully */ | |
6114 } break; | |
6115 | |
4829 | 6116 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6117 gchar *buf; | |
6118 buf = g_strdup_printf(_("Could not add the buddy %s because you have too many buddies in your buddy list. Please remove one and try again."), (retval->name ? retval->name : _("(no name)"))); | |
9758 | 6119 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6120 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6121 g_free(buf); |
6122 } | |
6123 | |
7023 | 6124 case 0x000e: { /* buddy requires authorization */ |
4828 | 6125 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6126 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6127 } break; |
6128 | |
6129 default: { /* La la la */ | |
5197 | 6130 gchar *buf; |
8660 | 6131 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6132 buf = g_strdup_printf(_("Could not add the buddy %s for an unknown reason. The most common reason for this is that you have the maximum number of allowed buddies in your buddy list."), (retval->name ? retval->name : _("(no name)"))); |
9758 | 6133 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6134 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6135 g_free(buf); |
4230 | 6136 } break; |
6137 } | |
6138 | |
6139 retval = retval->next; | |
6140 } | |
6141 | |
6142 return 1; | |
6143 } | |
6144 | |
8227 | 6145 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6146 GaimConnection *gc = sess->aux_data; | |
6147 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6148 GaimBuddy *b; | |
6149 GaimGroup *g; | |
6150 va_list ap; | |
6151 fu16_t type; | |
6152 const char *name; | |
6153 | |
6154 va_start(ap, fr); | |
6155 type = (fu16_t)va_arg(ap, int); | |
6156 name = va_arg(ap, char *); | |
6157 va_end(ap); | |
6158 | |
6159 if ((type != 0x0000) || (name == NULL)) | |
6160 return 1; | |
6161 | |
6162 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6163 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6164 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6165 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6166 b = gaim_find_buddy(gc->account, name); | |
6167 free(alias); | |
6168 | |
6169 if (b) { | |
6170 /* Get server stored alias */ | |
6171 if (alias_utf8) { | |
6172 g_free(b->alias); | |
6173 b->alias = g_strdup(alias_utf8); | |
6174 } | |
6175 } else { | |
6176 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6177 | |
6178 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6179 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6180 gaim_blist_add_group(g, NULL); | |
6181 } | |
6182 | |
8660 | 6183 gaim_debug_info("oscar", |
9285 | 6184 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6185 gaim_blist_add_buddy(b, NULL, g, NULL); |
6186 } | |
6187 g_free(gname_utf8); | |
6188 g_free(alias_utf8); | |
6189 | |
6190 return 1; | |
6191 } | |
6192 | |
4230 | 6193 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6194 GaimConnection *gc = sess->aux_data; |
4230 | 6195 va_list ap; |
6196 char *sn, *msg; | |
4236 | 6197 gchar *dialog_msg, *nombre; |
4230 | 6198 struct name_data *data; |
6695 | 6199 GaimBuddy *buddy; |
4230 | 6200 |
6201 va_start(ap, fr); | |
6202 sn = va_arg(ap, char *); | |
6203 msg = va_arg(ap, char *); | |
6204 va_end(ap); | |
6205 | |
8660 | 6206 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6207 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6208 |
4687 | 6209 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6210 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6211 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6212 else |
6213 nombre = g_strdup(sn); | |
6214 | |
6215 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 | 6216 data = g_new(struct name_data, 1); |
6217 data->gc = gc; | |
6218 data->name = g_strdup(sn); | |
6219 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6220 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6221 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6222 0, data, |
7023 | 6223 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6224 G_CALLBACK(oscar_free_name_data)); |
4236 | 6225 |
4230 | 6226 g_free(dialog_msg); |
4236 | 6227 g_free(nombre); |
4230 | 6228 |
6229 return 1; | |
6230 } | |
6231 | |
6232 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6233 GaimConnection *gc = sess->aux_data; |
4230 | 6234 va_list ap; |
6235 char *sn, *msg; | |
4236 | 6236 gchar *dialog_msg, *nombre; |
4230 | 6237 struct name_data *data; |
6695 | 6238 GaimBuddy *buddy; |
4230 | 6239 |
6240 va_start(ap, fr); | |
6241 sn = va_arg(ap, char *); | |
6242 msg = va_arg(ap, char *); | |
6243 va_end(ap); | |
6244 | |
8660 | 6245 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6246 "ssi: received authorization request from %s\n", sn); |
4230 | 6247 |
4687 | 6248 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6249 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6250 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6251 else |
6252 nombre = g_strdup(sn); | |
6253 | |
4337 | 6254 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 | 6255 data = g_new(struct name_data, 1); |
6256 data->gc = gc; | |
6257 data->name = g_strdup(sn); | |
6258 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6259 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6260 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6261 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6262 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6263 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6264 |
4230 | 6265 g_free(dialog_msg); |
4236 | 6266 g_free(nombre); |
4230 | 6267 |
6268 return 1; | |
6269 } | |
6270 | |
6271 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6272 GaimConnection *gc = sess->aux_data; |
4230 | 6273 va_list ap; |
6274 char *sn, *msg; | |
4236 | 6275 gchar *dialog_msg, *nombre; |
4230 | 6276 fu8_t reply; |
6695 | 6277 GaimBuddy *buddy; |
4230 | 6278 |
6279 va_start(ap, fr); | |
6280 sn = va_arg(ap, char *); | |
6281 reply = (fu8_t)va_arg(ap, int); | |
6282 msg = va_arg(ap, char *); | |
6283 va_end(ap); | |
6284 | |
8660 | 6285 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6286 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6287 |
4687 | 6288 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6289 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6290 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6291 else |
6292 nombre = g_strdup(sn); | |
6293 | |
4230 | 6294 if (reply) { |
6295 /* Granted */ | |
7023 | 6296 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
|
6297 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6298 } else { |
6299 /* Denied */ | |
7023 | 6300 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
|
6301 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6302 } |
6303 g_free(dialog_msg); | |
4236 | 6304 g_free(nombre); |
4230 | 6305 |
6306 return 1; | |
6307 } | |
6308 | |
6309 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6310 GaimConnection *gc = sess->aux_data; |
4230 | 6311 va_list ap; |
6312 char *sn; | |
6695 | 6313 GaimBuddy *buddy; |
4230 | 6314 |
6315 va_start(ap, fr); | |
6316 sn = va_arg(ap, char *); | |
6317 va_end(ap); | |
6318 | |
4687 | 6319 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6320 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6321 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6322 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6323 |
6324 return 1; | |
6325 } | |
4269 | 6326 #endif |
2086 | 6327 |
5575 | 6328 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6329 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6330 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6331 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6332 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6333 pce->label = _("_Room:"); |
5234 | 6334 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6335 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6336 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6337 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6338 pce->label = _("_Exchange:"); |
5234 | 6339 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6340 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6341 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6342 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6343 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6344 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6345 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6346 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6347 |
9754 | 6348 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6349 { | |
6350 GHashTable *defaults; | |
6351 | |
6352 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6353 | |
6354 if (chat_name != NULL) | |
6355 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6356 | |
6357 return defaults; | |
6358 } | |
6359 | |
9917 | 6360 static char *oscar_get_chat_name(GHashTable *data) { |
6361 return g_strdup(g_hash_table_lookup(data, "room")); | |
6362 } | |
6363 | |
8308 | 6364 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6365 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6366 aim_conn_t *cur; |
5234 | 6367 char *name, *exchange; |
6368 | |
6369 name = g_hash_table_lookup(data, "room"); | |
6370 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6371 |
8660 | 6372 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6373 "Attempting to join chat room %s.\n", name); |
8308 | 6374 |
6375 if ((name == NULL) || (*name == '\0')) { | |
6376 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6377 return; | |
6378 } | |
6379 | |
4617 | 6380 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6381 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6382 "chatnav exists, creating room\n"); |
5234 | 6383 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6384 } else { |
6385 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6386 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6387 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6388 "chatnav does not exist, opening chatnav\n"); |
5234 | 6389 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6390 cr->name = g_strdup(name); |
4617 | 6391 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6392 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6393 } |
6394 } | |
6395 | |
8308 | 6396 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6397 OscarData *od = (OscarData *)gc->proto_data; | |
6398 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6399 |
6400 if (!ccon) | |
6401 return; | |
6402 | |
8225 | 6403 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6404 ccon->exchange, ccon->name, 0x0); |
6405 } | |
6406 | |
8308 | 6407 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6408 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6409 GSList *bcs = gc->buddy_chats; | |
5679 | 6410 GaimConversation *b = NULL; |
2086 | 6411 struct chat_connection *c = NULL; |
6412 int count = 0; | |
6413 | |
6414 while (bcs) { | |
6415 count++; | |
5679 | 6416 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6417 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6418 break; |
6419 bcs = bcs->next; | |
6420 b = NULL; | |
6421 } | |
6422 | |
6423 if (!b) | |
6424 return; | |
6425 | |
8660 | 6426 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6427 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6428 |
8308 | 6429 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6430 if (c != NULL) { |
4617 | 6431 if (od) |
6432 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6433 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6434 gaim_input_remove(c->inpa); |
8308 | 6435 if (gc && od->sess) |
4617 | 6436 aim_conn_kill(od->sess, &c->conn); |
2086 | 6437 g_free(c->name); |
6438 g_free(c->show); | |
6439 g_free(c); | |
6440 } | |
6441 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6442 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6443 } |
6444 | |
8219 | 6445 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6446 OscarData *od = (OscarData *)gc->proto_data; | |
6447 GaimConversation *conv = NULL; | |
2086 | 6448 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6449 char *buf, *buf2; |
9830 | 6450 fu16_t charset, charsubset; |
9807 | 6451 char *charsetstr = NULL; |
8907 | 6452 gsize len; |
8219 | 6453 |
6454 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6455 return -EINVAL; |
2086 | 6456 |
8219 | 6457 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6458 return -EINVAL; |
2086 | 6459 |
8219 | 6460 buf = gaim_strdup_withhtml(message); |
6461 len = strlen(buf); | |
6462 | |
8962 | 6463 if (strstr(buf, "<IMG ")) |
6464 gaim_conversation_write(conv, "", | |
6465 _("Your IM Image was not sent. " | |
6466 "You cannot send IM Images in AIM chats."), | |
6467 GAIM_MESSAGE_ERROR, time(NULL)); | |
6468 | |
9830 | 6469 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6470 if ((len > c->maxlen) || (len > c->maxvis)) { |
6471 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6472 return -E2BIG; |
8359 | 6473 } |
6474 | |
9831 | 6475 if (charset == AIM_CHARSET_ASCII) |
6476 charsetstr = "us-ascii"; | |
6477 else if (charset == AIM_CHARSET_UNICODE) | |
6478 charsetstr = "unicode-2-0"; | |
6479 else if (charset == AIM_CHARSET_CUSTOM) | |
6480 charsetstr = "iso-8859-1"; | |
9807 | 6481 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6482 g_free(buf2); |
8359 | 6483 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6484 return 0; |
2086 | 6485 } |
6486 | |
6695 | 6487 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6488 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6489 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 6490 return "icq"; |
6491 else | |
6492 return "aim"; | |
6493 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6494 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6495 if (b != NULL && isdigit(b->name[0])) |
4687 | 6496 return "icq"; |
6497 return "aim"; | |
6498 } | |
6499 | |
6695 | 6500 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 6501 { |
7334 | 6502 GaimAccount *account = NULL; |
6503 GaimConnection *gc = NULL; | |
6504 OscarData *od = NULL; | |
4687 | 6505 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6506 int i = 0; | |
7334 | 6507 aim_userinfo_t *userinfo = NULL; |
6508 | |
6509 if (b != NULL) | |
6510 account = b->account; | |
6511 if (account != NULL) | |
6512 gc = account->gc; | |
6513 if (gc != NULL) | |
6514 od = gc->proto_data; | |
7945 | 6515 if (od != NULL) |
6516 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6517 |
5131 | 6518 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6519 char *gname; | |
7334 | 6520 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6521 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6522 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6523 emblems[i++] = "notauthorized"; | |
6524 } else { | |
6525 emblems[i++] = "offline"; | |
6526 } | |
6527 } | |
4916 | 6528 |
4766 | 6529 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 6530 int uc = b->uc >> 16; |
4766 | 6531 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6532 emblems[i++] = "invisible"; |
4766 | 6533 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6534 emblems[i++] = "freeforchat"; |
4766 | 6535 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6536 emblems[i++] = "dnd"; |
4766 | 6537 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6538 emblems[i++] = "na"; |
4766 | 6539 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6540 emblems[i++] = "occupied"; |
4766 | 6541 else if (uc & AIM_ICQ_STATE_AWAY) |
6542 emblems[i++] = "away"; | |
6543 } else { | |
6544 if (b->uc & UC_UNAVAILABLE) | |
6545 emblems[i++] = "away"; | |
6546 } | |
4687 | 6547 if (b->uc & UC_WIRELESS) |
6548 emblems[i++] = "wireless"; | |
6549 if (b->uc & UC_AOL) | |
6550 emblems[i++] = "aol"; | |
6551 if (b->uc & UC_ADMIN) | |
6552 emblems[i++] = "admin"; | |
6553 if (b->uc & UC_AB && i < 4) | |
6554 emblems[i++] = "activebuddy"; | |
4766 | 6555 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6556 emblems[i++] = "unconfirmed"; */ | |
7334 | 6557 |
7945 | 6558 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6559 emblems[i++] = "hiptop"; | |
6560 | |
6561 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6562 emblems[i++] = "secure"; |
6563 | |
4687 | 6564 *se = emblems[0]; |
6565 *sw = emblems[1]; | |
6566 *nw = emblems[2]; | |
6567 *ne = emblems[3]; | |
6568 } | |
6569 | |
6695 | 6570 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6571 GaimConnection *gc = b->account->gc; |
7283 | 6572 OscarData *od = gc->proto_data; |
7045 | 6573 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6574 GString *str = g_string_new(""); |
5131 | 6575 |
6576 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6577 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6578 |
6579 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6580 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6581 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6582 g_free(charset); |
7011 | 6583 if (away_utf8 != NULL) { |
7091 | 6584 gchar *tmp1, *tmp2; |
9627 | 6585 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6586 g_free(away_utf8); |
8571 | 6587 tmp1 = gaim_escape_html(tmp2); |
7091 | 6588 g_free(tmp2); |
8700 | 6589 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6590 g_free(tmp1); |
8701 | 6591 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6592 g_free(tmp2); |
5836 | 6593 } |
5131 | 6594 } |
8701 | 6595 } |
6596 | |
6597 return g_string_free(str, FALSE); | |
5131 | 6598 } |
6599 | |
6695 | 6600 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 6601 GaimConnection *gc = b->account->gc; |
7283 | 6602 OscarData *od = gc->proto_data; |
5167 | 6603 gchar *ret = NULL; |
6604 | |
6605 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
6606 if (isdigit(b->name[0])) | |
8701 | 6607 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6608 else |
6609 ret = g_strdup(_("Away")); | |
5836 | 6610 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6611 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 6612 if (bi->availmsg) |
6613 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 6614 } else { |
5167 | 6615 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6616 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6617 ret = g_strdup(_("Not Authorized")); | |
6618 else | |
6619 ret = g_strdup(_("Offline")); | |
6620 } | |
6621 | |
6622 return ret; | |
6623 } | |
6624 | |
5842 | 6625 |
5844 | 6626 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6627 GaimConnection *gc = sess->aux_data; |
7283 | 6628 OscarData *od = gc->proto_data; |
5892 | 6629 va_list ap; |
5842 | 6630 fu16_t type; |
5892 | 6631 fu8_t flags = 0, length = 0; |
6632 char *md5 = NULL; | |
6633 | |
7334 | 6634 |
5842 | 6635 va_start(ap, fr); |
6636 type = va_arg(ap, int); | |
5892 | 6637 |
6638 switch(type) { | |
6639 case 0x0000: | |
6640 case 0x0001: { | |
6641 flags = va_arg(ap, int); | |
6642 length = va_arg(ap, int); | |
6643 md5 = va_arg(ap, char *); | |
6644 | |
6645 if (flags == 0x41) { | |
6646 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6647 od->iconconnecting = TRUE; | |
6648 od->set_icon = TRUE; | |
6649 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6650 } else { | |
6039 | 6651 struct stat st; |
6652 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6653 if (iconfile == NULL) { | |
8363 | 6654 aim_ssi_delicon(od->sess); |
6039 | 6655 } else if (!stat(iconfile, &st)) { |
6656 char *buf = g_malloc(st.st_size); | |
6657 FILE *file = fopen(iconfile, "rb"); | |
6658 if (file) { | |
9532 | 6659 /* XXX - Use g_file_get_contents()? */ |
6039 | 6660 fread(buf, 1, st.st_size, file); |
6661 fclose(file); | |
8660 | 6662 gaim_debug_info("oscar", |
6039 | 6663 "Uploading icon to icon server\n"); |
6879 | 6664 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6665 } else |
8660 | 6666 gaim_debug_error("oscar", |
6039 | 6667 "Can't open buddy icon file!\n"); |
6668 g_free(buf); | |
6669 } else { | |
8660 | 6670 gaim_debug_error("oscar", |
6039 | 6671 "Can't stat buddy icon file!\n"); |
5892 | 6672 } |
6673 } | |
8363 | 6674 } else if (flags == 0x81) { |
6675 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6676 if (iconfile == NULL) | |
6677 aim_ssi_delicon(od->sess); | |
6678 else | |
6679 aim_ssi_seticon(od->sess, md5, length); | |
6680 } | |
5892 | 6681 } break; |
6682 | |
6683 case 0x0002: { /* We just set an "available" message? */ | |
6684 } break; | |
6685 } | |
6686 | |
5842 | 6687 va_end(ap); |
5844 | 6688 |
6689 return 0; | |
5842 | 6690 } |
5892 | 6691 |
5575 | 6692 static void oscar_set_permit_deny(GaimConnection *gc) { |
6693 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6694 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6695 #ifdef NOSSI |
8143 | 6696 GSList *list; |
4230 | 6697 char buf[MAXMSGLEN]; |
6698 int at; | |
6699 | |
5575 | 6700 switch(account->perm_deny) { |
8175 | 6701 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6702 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6703 break; |
8175 | 6704 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6705 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6706 break; |
8175 | 6707 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6708 list = account->permit; |
4230 | 6709 at = 0; |
6710 while (list) { | |
6711 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6712 list = list->next; | |
6713 } | |
6714 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6715 break; | |
8175 | 6716 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6717 list = account->deny; |
4230 | 6718 at = 0; |
6719 while (list) { | |
6720 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6721 list = list->next; | |
6722 } | |
6723 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6724 break; | |
6725 default: | |
6726 break; | |
2086 | 6727 } |
4230 | 6728 #else |
8175 | 6729 if (od->sess->ssi.received_data) { |
6730 switch (account->perm_deny) { | |
6731 case GAIM_PRIVACY_ALLOW_ALL: | |
6732 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6733 break; | |
6734 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6735 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6736 break; | |
6737 case GAIM_PRIVACY_ALLOW_USERS: | |
6738 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6739 break; | |
6740 case GAIM_PRIVACY_DENY_ALL: | |
6741 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6742 break; | |
6743 case GAIM_PRIVACY_DENY_USERS: | |
6744 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6745 break; | |
6746 default: | |
6747 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6748 break; | |
6749 } | |
6750 } | |
4230 | 6751 #endif |
2086 | 6752 } |
6753 | |
5575 | 6754 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6755 #ifdef NOSSI |
8143 | 6756 if (gc->account->perm_deny == 3) |
4269 | 6757 oscar_set_permit_deny(gc); |
6758 #else | |
7283 | 6759 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6760 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6761 if (od->sess->ssi.received_data) |
4889 | 6762 aim_ssi_addpermit(od->sess, who); |
4230 | 6763 #endif |
2086 | 6764 } |
6765 | |
5575 | 6766 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6767 #ifdef NOSSI |
8143 | 6768 if (gc->account->perm_deny == 4) |
4269 | 6769 oscar_set_permit_deny(gc); |
6770 #else | |
7283 | 6771 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6772 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6773 if (od->sess->ssi.received_data) |
4889 | 6774 aim_ssi_adddeny(od->sess, who); |
4230 | 6775 #endif |
2086 | 6776 } |
6777 | |
5575 | 6778 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6779 #ifdef NOSSI |
8143 | 6780 if (gc->account->perm_deny == 3) |
4269 | 6781 oscar_set_permit_deny(gc); |
6782 #else | |
7283 | 6783 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6784 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6785 if (od->sess->ssi.received_data) |
4889 | 6786 aim_ssi_delpermit(od->sess, who); |
4230 | 6787 #endif |
2086 | 6788 } |
6789 | |
5575 | 6790 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6791 #ifdef NOSSI |
8143 | 6792 if (gc->account->perm_deny == 4) |
4269 | 6793 oscar_set_permit_deny(gc); |
6794 #else | |
7283 | 6795 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6796 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6797 if (od->sess->ssi.received_data) |
4889 | 6798 aim_ssi_deldeny(od->sess, who); |
4230 | 6799 #endif |
2086 | 6800 } |
6801 | |
5575 | 6802 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 6803 { |
7283 | 6804 OscarData *od = gc->proto_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6805 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6806 |
8257 | 6807 if (od->icq) { |
6808 m = g_list_append(m, _("Online")); | |
6809 m = g_list_append(m, _("Away")); | |
6810 m = g_list_append(m, _("Do Not Disturb")); | |
6811 m = g_list_append(m, _("Not Available")); | |
6812 m = g_list_append(m, _("Occupied")); | |
6813 m = g_list_append(m, _("Free For Chat")); | |
6814 m = g_list_append(m, _("Invisible")); | |
6815 } else { | |
6816 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6817 m = g_list_append(m, _("Back")); |
8257 | 6818 m = g_list_append(m, _("Visible")); |
6819 m = g_list_append(m, _("Invisible")); | |
6820 } | |
4333 | 6821 |
6822 return m; | |
6823 } | |
6824 | |
7172 | 6825 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6826 GaimConnection *gc = data->gc; |
6827 OscarData *od = gc->proto_data; | |
7172 | 6828 GaimBuddy *b; |
6829 GaimGroup *g; | |
6830 | |
6831 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6832 oscar_free_name_data(data); | |
6833 return; | |
6834 } | |
6835 | |
6836 if (!(g = gaim_find_buddys_group(b))) { | |
6837 oscar_free_name_data(data); | |
6838 return; | |
6839 } | |
6840 | |
6841 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6842 |
6843 if (!aim_sncmp(data->name, gc->account->username)) | |
6844 gaim_check_comment(od, text); | |
6845 | |
7172 | 6846 oscar_free_name_data(data); |
6847 } | |
6848 | |
9030 | 6849 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6850 | |
6851 GaimBuddy *buddy; | |
6852 GaimConnection *gc; | |
6853 OscarData *od; | |
6854 struct name_data *data; | |
7172 | 6855 GaimGroup *g; |
6856 char *comment; | |
6857 gchar *comment_utf8; | |
9631 | 6858 gchar *title; |
7172 | 6859 |
9030 | 6860 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6861 | |
6862 buddy = (GaimBuddy *) node; | |
6863 gc = gaim_account_get_connection(buddy->account); | |
6864 od = gc->proto_data; | |
6865 | |
6866 data = g_new(struct name_data, 1); | |
6867 | |
6868 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6869 return; |
9030 | 6870 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6871 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6872 | |
6873 data->gc = gc; | |
9030 | 6874 data->name = g_strdup(buddy->name); |
7172 | 6875 data->nick = NULL; |
6876 | |
9631 | 6877 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6878 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6879 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6880 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6881 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6882 data); | |
9631 | 6883 g_free(title); |
7172 | 6884 |
6885 free(comment); | |
6886 g_free(comment_utf8); | |
6887 } | |
6888 | |
9030 | 6889 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6890 | |
6891 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6892 OscarData *od = gc->proto_data; |
9030 | 6893 |
4333 | 6894 GList *m = NULL; |
9030 | 6895 GaimBlistNodeAction *act; |
6896 | |
6897 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6898 oscar_buddycb_edit_comment, NULL); | |
6899 m = g_list_append(m, act); | |
7172 | 6900 |
4333 | 6901 if (od->icq) { |
4624 | 6902 #if 0 |
9030 | 6903 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6904 oscar_get_icqstatusmsg, NULL); | |
6905 m = g_list_append(m, act); | |
4624 | 6906 #endif |
4333 | 6907 } else { |
7011 | 6908 aim_userinfo_t *userinfo; |
9030 | 6909 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6910 | |
6911 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
6912 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
6913 | |
7011 | 6914 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 6915 act = gaim_blist_node_action_new(_("Direct IM"), |
6916 oscar_ask_direct_im, NULL); | |
6917 m = g_list_append(m, act); | |
5917 | 6918 } |
9466 | 6919 #if 0 |
7011 | 6920 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6921 act = gaim_blist_node_action_new(_("Get File"), |
6922 oscar_ask_getfile, NULL); | |
6923 m = g_list_append(m, act); | |
5917 | 6924 } |
4826 | 6925 #endif |
4333 | 6926 } |
5131 | 6927 } |
5197 | 6928 |
5131 | 6929 if (od->sess->ssi.received_data) { |
9030 | 6930 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6931 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
6932 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
6933 gaim_auth_sendrequest_menu, NULL); | |
6934 m = g_list_append(m, act); | |
4333 | 6935 } |
4916 | 6936 } |
6937 | |
4333 | 6938 return m; |
6939 } | |
6940 | |
9030 | 6941 |
6942 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6943 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6944 return oscar_buddy_menu((GaimBuddy *) node); | |
6945 } else { | |
6946 return NULL; | |
6947 } | |
6948 } | |
6949 | |
6950 | |
5575 | 6951 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6952 OscarData *od = gc->proto_data; |
5575 | 6953 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6954 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6955 od->setnick = TRUE; | |
6956 od->newsn = g_strdup(nick); | |
6957 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6958 } else { | |
6959 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6960 } | |
6961 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6962 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6963 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6964 } |
6965 } | |
6966 | |
9015 | 6967 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 6968 { |
9015 | 6969 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 6970 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 6971 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6972 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6973 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6974 gc); |
4333 | 6975 } |
6976 | |
9015 | 6977 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 6978 { |
9015 | 6979 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6980 OscarData *od = gc->proto_data; |
4333 | 6981 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6982 | |
6983 if (conn) { | |
6984 aim_admin_reqconfirm(od->sess, conn); | |
6985 } else { | |
6986 od->conf = TRUE; | |
6987 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6988 } | |
6989 } | |
6990 | |
9015 | 6991 static void oscar_show_email(GaimPluginAction *action) |
4333 | 6992 { |
9015 | 6993 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6994 OscarData *od = gc->proto_data; |
4333 | 6995 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6996 | |
6997 if (conn) { | |
6998 aim_admin_getinfo(od->sess, conn, 0x11); | |
6999 } else { | |
7000 od->reqemail = TRUE; | |
7001 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7002 } | |
7003 } | |
7004 | |
5575 | 7005 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7006 { |
7283 | 7007 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7008 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
|
7009 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7010 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7011 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7012 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7013 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7014 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7015 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7016 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7017 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7018 |
9015 | 7019 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7020 { |
9015 | 7021 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7022 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7023 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7024 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7025 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7026 gc); |
4333 | 7027 } |
7028 | |
9015 | 7029 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7030 { |
9015 | 7031 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7032 OscarData *od = gc->proto_data; |
4333 | 7033 gchar *nombre, *text, *tmp; |
6695 | 7034 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7035 int num=0; |
7036 | |
6873 | 7037 text = g_strdup(""); |
4333 | 7038 |
4785 | 7039 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7040 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7041 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7042 continue; | |
6695 | 7043 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7044 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7045 continue; |
6695 | 7046 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7047 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7048 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7049 continue; | |
7050 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7051 if (gaim_buddy_get_alias_only(buddy)) |
7052 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7053 else |
7054 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7055 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7056 g_free(text); |
7057 text = tmp; | |
7058 g_free(nombre); | |
7059 num++; | |
7060 } | |
4333 | 7061 } |
2979 | 7062 } |
4333 | 7063 } |
7064 | |
7065 if (!num) { | |
7066 g_free(text); | |
6873 | 7067 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7068 } | |
7069 | |
7070 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7071 "the following buddies"), _("You can re-request " | |
7072 "authorization from these buddies by " | |
7073 "right-clicking on them and selecting " | |
7074 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7075 g_free(text); |
2979 | 7076 } |
7077 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7078 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7079 { |
8950 | 7080 OscarData *od = (OscarData *)gc->proto_data; |
7081 | |
7082 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7083 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7084 |
9015 | 7085 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7086 { |
9015 | 7087 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7088 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7089 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7090 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7091 "searching for."), |
8697 | 7092 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7093 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7094 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7095 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7096 |
5917 | 7097 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 7098 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 7099 |
7334 | 7100 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 7101 aim_srv_setavailmsg(od->sess, text); |
7102 } | |
7103 | |
9879 | 7104 static void oscar_show_setavailmsg(GaimPluginAction *action) |
5917 | 7105 { |
9879 | 7106 GaimConnection *gc = (GaimConnection *) action->context; |
7313 | 7107 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
7108 _("I'm doing work and hoping for a distraction--IM me!"), | |
8697 | 7109 TRUE, FALSE, NULL, |
5917 | 7110 _("OK"), G_CALLBACK(oscar_setavailmsg), |
7111 _("Cancel"), NULL, | |
7112 gc); | |
7113 } | |
7114 | |
9015 | 7115 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7116 { |
9015 | 7117 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7118 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7119 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7120 |
9015 | 7121 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7122 { |
9015 | 7123 GaimConnection *gc = (GaimConnection *) action->context; |
9809 | 7124 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7125 } |
7126 | |
9015 | 7127 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7128 { |
9015 | 7129 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7130 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7131 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7132 |
9015 | 7133 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7134 { |
9015 | 7135 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7136 OscarData *od = gc->proto_data; |
5575 | 7137 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
|
7138 gaim_notify_uri(gc, substituted); |
5517 | 7139 g_free(substituted); |
4333 | 7140 } |
7141 | |
9015 | 7142 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7143 { |
9015 | 7144 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7145 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7146 } | |
7147 | |
5842 | 7148 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7149 { | |
7283 | 7150 OscarData *od = gc->proto_data; |
5844 | 7151 aim_session_t *sess = od->sess; |
5842 | 7152 FILE *file; |
7153 struct stat st; | |
5844 | 7154 |
6039 | 7155 if (iconfile == NULL) { |
8363 | 7156 aim_ssi_delicon(od->sess); |
6039 | 7157 } else if (!stat(iconfile, &st)) { |
5842 | 7158 char *buf = g_malloc(st.st_size); |
7159 file = fopen(iconfile, "rb"); | |
7160 if (file) { | |
6052 | 7161 md5_state_t *state; |
6039 | 7162 char md5[16]; |
9532 | 7163 /* XXX - Use g_file_get_contents()? */ |
5842 | 7164 int len = fread(buf, 1, st.st_size, file); |
6039 | 7165 fclose(file); |
6052 | 7166 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7167 md5_init(state); |
7168 md5_append(state, buf, len); | |
7169 md5_finish(state, md5); | |
7170 g_free(state); | |
7171 aim_ssi_seticon(sess, md5, 16); | |
7172 } else | |
8660 | 7173 gaim_debug_error("oscar", |
5842 | 7174 "Can't open buddy icon file!\n"); |
7175 g_free(buf); | |
7176 } else | |
8660 | 7177 gaim_debug_error("oscar", |
5842 | 7178 "Can't stat buddy icon file!\n"); |
7179 } | |
7180 | |
7181 | |
9015 | 7182 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7183 { |
9015 | 7184 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7185 OscarData *od = gc->proto_data; |
4333 | 7186 GList *m = NULL; |
9015 | 7187 GaimPluginAction *act; |
7188 | |
7189 act = gaim_plugin_action_new(_("Set User Info..."), | |
7190 oscar_show_set_info); | |
7191 m = g_list_append(m, act); | |
4333 | 7192 |
8576 | 7193 if (od->icq) { |
9015 | 7194 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7195 oscar_show_set_info_icqurl); | |
7196 m = g_list_append(m, act); | |
8576 | 7197 } |
7198 | |
9879 | 7199 if (!od->icq) { |
7200 act = gaim_plugin_action_new(_("Set Available Message..."), | |
7201 oscar_show_setavailmsg); | |
7202 m = g_list_append(m, act); | |
7203 } | |
5917 | 7204 |
9015 | 7205 act = gaim_plugin_action_new(_("Change Password..."), |
7206 oscar_change_pass); | |
7207 m = g_list_append(m, act); | |
4617 | 7208 |
7209 if (od->sess->authinfo->chpassurl) { | |
9015 | 7210 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7211 oscar_show_chpassurl); | |
7212 m = g_list_append(m, act); | |
7213 | |
7214 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7215 oscar_show_imforwardingurl); | |
7216 m = g_list_append(m, act); | |
7026 | 7217 } |
7218 | |
5238 | 7219 if (!od->icq) { |
4617 | 7220 /* AIM actions */ |
7221 m = g_list_append(m, NULL); | |
4333 | 7222 |
9015 | 7223 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7224 oscar_show_format_screenname); | |
7225 m = g_list_append(m, act); | |
7226 | |
7227 act = gaim_plugin_action_new(_("Confirm Account"), | |
7228 oscar_confirm_account); | |
7229 m = g_list_append(m, act); | |
7230 | |
7231 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7232 oscar_show_email); | |
7233 m = g_list_append(m, act); | |
7234 | |
7235 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7236 oscar_show_change_email); | |
7237 m = g_list_append(m, act); | |
2086 | 7238 } |
4333 | 7239 |
7240 m = g_list_append(m, NULL); | |
7241 | |
9015 | 7242 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7243 oscar_show_awaitingauth); | |
7244 m = g_list_append(m, act); | |
4333 | 7245 |
2086 | 7246 m = g_list_append(m, NULL); |
4333 | 7247 |
9015 | 7248 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7249 oscar_show_find_email); | |
7250 m = g_list_append(m, act); | |
4333 | 7251 |
8591 | 7252 #if 0 |
9015 | 7253 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7254 show_find_info); | |
7255 m = g_list_append(m, act); | |
8591 | 7256 #endif |
2086 | 7257 |
7258 return m; | |
7259 } | |
7260 | |
5575 | 7261 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7262 { |
7283 | 7263 OscarData *od = gc->proto_data; |
4617 | 7264 |
7265 if (od->icq) { | |
7266 aim_icq_changepasswd(od->sess, new); | |
2086 | 7267 } else { |
4617 | 7268 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7269 if (conn) { | |
7270 aim_admin_changepasswd(od->sess, conn, new, old); | |
7271 } else { | |
7272 od->chpass = TRUE; | |
7273 od->oldp = g_strdup(old); | |
7274 od->newp = g_strdup(new); | |
7275 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7276 } | |
2086 | 7277 } |
7278 } | |
7279 | |
6059 | 7280 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7281 { |
7283 | 7282 OscarData *od = gc->proto_data; |
8971 | 7283 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
|
7284 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7285 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7286 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7287 |
8971 | 7288 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7289 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7290 |
9935 | 7291 static void |
7292 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7293 { | |
7294 GaimConnection *gc = data; | |
7295 OscarData *od = gc->proto_data; | |
7296 aim_session_t *sess = od->sess; | |
7297 fu32_t presence; | |
7298 | |
7299 presence = aim_ssi_getpresence(sess->ssi.local); | |
7300 | |
7301 if (value) { | |
7302 presence |= 0x00400000; | |
7303 aim_ssi_setpresence(sess, presence); | |
7304 } else { | |
9936 | 7305 presence &= ~0x00400000; |
9935 | 7306 aim_ssi_setpresence(sess, presence); |
7307 } | |
7308 } | |
7309 | |
7310 static GaimPluginPrefFrame * | |
9936 | 7311 get_plugin_pref_frame(GaimPlugin *plugin) |
7312 { | |
9935 | 7313 GaimPluginPrefFrame *frame; |
7314 GaimPluginPref *ppref; | |
7315 | |
7316 frame = gaim_plugin_pref_frame_new(); | |
7317 | |
7318 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7319 gaim_plugin_pref_frame_add(frame, ppref); | |
7320 | |
7321 /* XXX - Why doesn't the following show up? */ | |
7322 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7323 gaim_plugin_pref_frame_add(frame, ppref); | |
7324 | |
7325 return frame; | |
7326 } | |
7327 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7328 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7329 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7330 GAIM_PRPL_API_VERSION, |
9308 | 7331 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7332 NULL, /* user_splits */ |
7333 NULL, /* protocol_options */ | |
7334 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7335 oscar_list_icon, /* list_icon */ | |
7336 oscar_list_emblems, /* list_emblems */ | |
7337 oscar_status_text, /* status_text */ | |
7338 oscar_tooltip_text, /* tooltip_text */ | |
7339 oscar_away_states, /* away_states */ | |
7340 oscar_blist_node_menu, /* blist_node_menu */ | |
7341 oscar_chat_info, /* chat_info */ | |
9754 | 7342 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7343 oscar_login, /* login */ |
7344 oscar_close, /* close */ | |
7345 oscar_send_im, /* send_im */ | |
7346 oscar_set_info, /* set_info */ | |
7347 oscar_send_typing, /* send_typing */ | |
7348 oscar_get_info, /* get_info */ | |
7349 oscar_set_away, /* set_away */ | |
7350 oscar_set_idle, /* set_idle */ | |
7351 oscar_change_passwd, /* change_passwd */ | |
7352 oscar_add_buddy, /* add_buddy */ | |
7353 oscar_add_buddies, /* add_buddies */ | |
7354 oscar_remove_buddy, /* remove_buddy */ | |
7355 oscar_remove_buddies, /* remove_buddies */ | |
7356 oscar_add_permit, /* add_permit */ | |
7357 oscar_add_deny, /* add_deny */ | |
7358 oscar_rem_permit, /* rem_permit */ | |
7359 oscar_rem_deny, /* rem_deny */ | |
7360 oscar_set_permit_deny, /* set_permit_deny */ | |
7361 oscar_warn, /* warn */ | |
7362 oscar_join_chat, /* join_chat */ | |
7363 NULL, /* reject_chat */ | |
9917 | 7364 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7365 oscar_chat_invite, /* chat_invite */ |
7366 oscar_chat_leave, /* chat_leave */ | |
7367 NULL, /* chat_whisper */ | |
7368 oscar_send_chat, /* chat_send */ | |
7369 oscar_keepalive, /* keepalive */ | |
7370 NULL, /* register_user */ | |
7371 NULL, /* get_cb_info */ | |
7372 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7373 #ifndef NOSSI |
9475 | 7374 oscar_alias_buddy, /* alias_buddy */ |
7375 oscar_move_buddy, /* group_buddy */ | |
7376 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7377 #else |
9475 | 7378 NULL, /* alias_buddy */ |
7379 NULL, /* group_buddy */ | |
7380 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7381 #endif |
9475 | 7382 NULL, /* buddy_free */ |
7383 oscar_convo_closed, /* convo_closed */ | |
7384 NULL, /* normalize */ | |
7385 oscar_set_icon, /* set_buddy_icon */ | |
7386 NULL, /* remove_group */ | |
7387 NULL, /* get_cb_real_name */ | |
7388 NULL, /* set_chat_topic */ | |
7389 NULL, /* find_blist_chat */ | |
7390 NULL, /* roomlist_get_list */ | |
7391 NULL, /* roomlist_cancel */ | |
7392 NULL, /* roomlist_expand_category */ | |
7393 oscar_can_receive_file, /* can_receive_file */ | |
7394 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7395 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7396 |
9935 | 7397 static GaimPluginUiInfo prefs_info = { |
7398 get_plugin_pref_frame | |
7399 }; | |
7400 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7401 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7402 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7403 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7404 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7405 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7406 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7407 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7408 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7409 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7410 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7411 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7412 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7413 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7414 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7415 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7416 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7417 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7418 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7419 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7420 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7421 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7422 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7423 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7424 NULL, /**< ui_info */ |
8993 | 7425 &prpl_info, /**< extra_info */ |
9935 | 7426 &prefs_info, /**< prefs_info */ |
9015 | 7427 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7428 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7429 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7430 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7431 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7432 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7433 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7434 |
9830 | 7435 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7436 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7437 | |
7438 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7439 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7440 | |
7441 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7442 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7443 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7444 my_protocol = plugin; |
9935 | 7445 |
7446 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7447 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
2086 | 7448 } |
7449 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7450 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |