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