Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 9944:e4a27c9aec4c
[gaim-migrate @ 10838]
with much rejoicing, and massive thanks to the efforts of Christian, and
all who have helped him, I present to you the incomplete status
rewrite!
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 03 Sep 2004 21:35:52 +0000 |
parents | f8e395a054e2 |
children | b13013595c08 |
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" |
9943 | 44 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 |
2086 | 46 #include "aim.h" |
5842 | 47 #include "md5.h" |
2086 | 48 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
49 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
50 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
51 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
52 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
53 #define UC_AB 0x20 |
3079 | 54 #define UC_WIRELESS 0x40 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
55 |
2086 | 56 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
57 | |
7283 | 58 #define OSCAR_CONNECT_STEPS 6 |
9830 | 59 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 60 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
61 static GaimPlugin *my_protocol = NULL; |
4249 | 62 |
7376 | 63 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
64 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 65 |
4665 | 66 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
67 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 68 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 69 |
7283 | 70 typedef struct _OscarData OscarData; |
71 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
72 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
73 aim_conn_t *conn; |
2086 | 74 |
75 guint cnpa; | |
76 guint paspa; | |
3694 | 77 guint emlpa; |
4804 | 78 guint icopa; |
2086 | 79 |
4823 | 80 gboolean iconconnecting; |
5842 | 81 gboolean set_icon; |
4823 | 82 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
83 GSList *create_rooms; |
2086 | 84 |
85 gboolean conf; | |
86 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
87 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
88 char *email; |
2979 | 89 gboolean setnick; |
90 char *newsn; | |
2086 | 91 gboolean chpass; |
92 char *oldp; | |
93 char *newp; | |
5842 | 94 |
2086 | 95 GSList *oscar_chats; |
96 GSList *direct_ims; | |
3630 | 97 GSList *file_transfers; |
4738 | 98 GHashTable *buddyinfo; |
4804 | 99 GSList *requesticon; |
2086 | 100 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
101 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
102 gboolean icq; |
4804 | 103 guint icontimer; |
5968 | 104 guint getblisttimer; |
8341 | 105 guint getinfotimer; |
2993 | 106 |
107 struct { | |
4230 | 108 guint maxwatchers; /* max users who can watch you */ |
2993 | 109 guint maxbuddies; /* max users you can watch */ |
4230 | 110 guint maxgroups; /* max groups in server list */ |
2993 | 111 guint maxpermits; /* max users on permit list */ |
112 guint maxdenies; /* max users on deny list */ | |
113 guint maxsiglen; /* max size (bytes) of profile */ | |
114 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
115 } rights; | |
2086 | 116 }; |
117 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
118 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
119 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
120 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
121 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
122 |
2086 | 123 struct chat_connection { |
124 char *name; | |
125 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
126 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
127 fu16_t instance; |
2086 | 128 int fd; /* this is redundant since we have the conn below */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
129 aim_conn_t *conn; |
2086 | 130 int inpa; |
131 int id; | |
5575 | 132 GaimConnection *gc; /* i hate this. */ |
8733 | 133 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
134 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
135 int maxvis; |
2086 | 136 }; |
137 | |
8971 | 138 struct oscar_direct_im { |
5575 | 139 GaimConnection *gc; |
2086 | 140 char name[80]; |
141 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
142 aim_conn_t *conn; |
3008 | 143 gboolean connected; |
8978 | 144 gboolean gpc_pend; |
145 gboolean killme; | |
8984 | 146 gboolean donttryagain; |
2086 | 147 }; |
148 | |
149 struct ask_direct { | |
5575 | 150 GaimConnection *gc; |
2086 | 151 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
152 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
153 fu8_t cookie[8]; |
8984 | 154 gboolean donttryagain; |
2086 | 155 }; |
156 | |
7011 | 157 /* |
158 * Various PRPL-specific buddy info that we want to keep track of | |
159 * Some other info is maintained by locate.c, and I'd like to move | |
160 * the rest of this to libfaim, mostly im.c | |
161 */ | |
4738 | 162 struct buddyinfo { |
163 gboolean typingnot; | |
6292 | 164 gchar *availmsg; |
6857 | 165 fu32_t ipaddr; |
5836 | 166 |
167 unsigned long ico_me_len; | |
168 unsigned long ico_me_csum; | |
169 time_t ico_me_time; | |
170 gboolean ico_informed; | |
4738 | 171 |
172 unsigned long ico_len; | |
173 unsigned long ico_csum; | |
174 time_t ico_time; | |
175 gboolean ico_need; | |
7406 | 176 gboolean ico_sent; |
2086 | 177 }; |
178 | |
4230 | 179 struct name_data { |
5575 | 180 GaimConnection *gc; |
4230 | 181 gchar *name; |
3453 | 182 gchar *nick; |
3141 | 183 }; |
184 | |
5129 | 185 static char *msgerrreason[] = { |
186 N_("Invalid error"), | |
187 N_("Invalid SNAC"), | |
188 N_("Rate to host"), | |
189 N_("Rate to client"), | |
190 N_("Not logged in"), | |
191 N_("Service unavailable"), | |
192 N_("Service not defined"), | |
193 N_("Obsolete SNAC"), | |
194 N_("Not supported by host"), | |
195 N_("Not supported by client"), | |
196 N_("Refused by client"), | |
197 N_("Reply too big"), | |
198 N_("Responses lost"), | |
199 N_("Request denied"), | |
200 N_("Busted SNAC payload"), | |
201 N_("Insufficient rights"), | |
202 N_("In local permit/deny"), | |
203 N_("Too evil (sender)"), | |
204 N_("Too evil (receiver)"), | |
205 N_("User temporarily unavailable"), | |
206 N_("No match"), | |
207 N_("List overflow"), | |
208 N_("Request ambiguous"), | |
209 N_("Queue full"), | |
210 N_("Not while on AOL") | |
211 }; | |
212 static int msgerrreasonlen = 25; | |
213 | |
214 /* All the libfaim->gaim callback functions */ | |
215 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
216 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
217 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
218 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
219 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
220 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
221 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
224 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 225 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 226 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 227 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
228 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
229 static int gaim_conv_chat_join (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
230 static int gaim_conv_chat_leave (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
231 static int gaim_conv_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
232 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 233 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
234 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 236 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 237 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
238 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
240 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
241 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
242 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
243 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
244 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
245 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
246 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
247 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
248 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
249 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
264 #ifndef NOSSI | |
265 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 269 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 270 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
271 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
274 #endif | |
275 | |
276 /* for DirectIM/image transfer */ | |
277 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 280 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 281 |
282 /* for file transfer */ | |
283 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
284 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
285 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
286 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
287 | |
288 /* for icons */ | |
289 static gboolean gaim_icon_timerfunc(gpointer data); | |
290 | |
8971 | 291 /* just because */ |
292 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); | |
8983 | 293 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
8971 | 294 |
8076 | 295 /* remove these at some point? */ |
7282 | 296 /* Because I don't like forward declarations? I think that was why... */ |
5954 | 297 static void oscar_set_info(GaimConnection *gc, const char *text); |
8076 | 298 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message); |
5306 | 299 |
9935 | 300 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
301 | |
5836 | 302 static void oscar_free_name_data(struct name_data *data) { |
4230 | 303 g_free(data->name); |
304 g_free(data->nick); | |
305 g_free(data); | |
306 } | |
307 | |
5836 | 308 static void oscar_free_buddyinfo(void *data) { |
309 struct buddyinfo *bi = data; | |
6292 | 310 g_free(bi->availmsg); |
5836 | 311 g_free(bi); |
312 } | |
313 | |
9807 | 314 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 315 { |
316 int i = 0; | |
9826 | 317 int charset = AIM_CHARSET_ASCII; |
5129 | 318 |
319 /* Determine how we can send this message. Per the warnings elsewhere | |
320 * in this file, these little checks determine the simplest encoding | |
321 * we can use for a given message send using it. */ | |
322 while (utf8[i]) { | |
323 if ((unsigned char)utf8[i] > 0x7f) { | |
324 /* not ASCII! */ | |
9826 | 325 charset = AIM_CHARSET_CUSTOM; |
5129 | 326 break; |
327 } | |
328 i++; | |
329 } | |
330 while (utf8[i]) { | |
331 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
332 * followed by 0xc0-0xc3 in the second */ | |
333 if ((unsigned char)utf8[i] < 0x80) { | |
334 i++; | |
335 continue; | |
336 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
337 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
338 i += 2; | |
339 continue; | |
340 } | |
9826 | 341 charset = AIM_CHARSET_UNICODE; |
5129 | 342 break; |
343 } | |
344 | |
9807 | 345 return charset; |
5129 | 346 } |
347 | |
8225 | 348 /* |
349 * Take a string of the form charset="bleh" where bleh is | |
350 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
351 * return a newly allocated string containing bleh. | |
352 */ | |
353 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 354 { |
8225 | 355 gchar *ret = NULL; |
356 char *begin, *end; | |
357 | |
9933 | 358 g_return_val_if_fail(encoding != NULL, NULL); |
359 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
360 /* Make sure encoding begins with charset= */ |
8225 | 361 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
362 return NULL; | |
363 | |
364 begin = strchr(encoding, '"'); | |
365 end = strrchr(encoding, '"'); | |
366 | |
367 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
368 return NULL; | |
369 | |
370 ret = g_strndup(begin+1, (end-1) - begin); | |
371 | |
372 return ret; | |
373 } | |
374 | |
9830 | 375 static gchar * |
376 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 377 { |
378 gchar *utf8 = NULL; | |
9595 | 379 |
380 if ((encoding == NULL) || encoding[0] == '\0') { | |
381 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
382 | |
9639 | 383 } else if (!strcmp(encoding, "iso-8859-1") |
384 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 385 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
386 | |
387 } else if (!strcmp(encoding, "unicode-2-0")) { | |
388 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
389 | |
390 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
391 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
392 "attempting to convert to UTF-8 anyway\n"); | |
393 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
394 } | |
395 | |
396 /* | |
397 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
398 * we have been unable to convert the text to utf-8 from the encoding | |
399 * that was specified. So we check if the text is valid utf-8 then | |
400 * just copy it. | |
401 */ | |
402 if (utf8 == NULL) { | |
9638 | 403 if (textlen != 0 && *text != '\0' |
404 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 405 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 406 else |
9481 | 407 utf8 = g_strndup(text, textlen); |
5129 | 408 } |
409 | |
410 return utf8; | |
411 } | |
412 | |
9830 | 413 static gchar * |
9908 | 414 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 415 { |
416 gchar *ret = NULL; | |
417 GError *err = NULL; | |
418 | |
9908 | 419 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
420 return NULL; | |
421 | |
422 if (strcasecmp("UTF-8", charsetstr)) { | |
423 if (fallback) | |
424 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
425 else | |
426 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
427 if (err != NULL) { | |
428 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
429 charsetstr, err->message); | |
430 g_error_free(err); | |
431 } | |
432 } else { | |
433 if (g_utf8_validate(data, datalen, NULL)) | |
434 ret = g_strndup(data, datalen); | |
435 else | |
436 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
437 } | |
438 | |
439 return ret; | |
440 } | |
441 | |
442 /* | |
443 * We try decoding using two different character sets. The charset | |
444 * specified in the IM determines the order in which we attempt to | |
445 * decode. We do this because there are lots of broken ICQ clients | |
446 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
447 * able to deal with that crap, then people complain like banshees. | |
448 * charsetstr1 is always set to what the correct encoding should be. | |
449 */ | |
450 static gchar * | |
451 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
452 { | |
453 gchar *ret = NULL; | |
454 const gchar *charsetstr1, *charsetstr2; | |
455 | |
456 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 457 |
458 if ((datalen == 0) || (data == NULL)) | |
459 return NULL; | |
460 | |
9908 | 461 if (charset == AIM_CHARSET_UNICODE) { |
462 charsetstr1 = "UCS-2BE"; | |
463 charsetstr2 = "UTF-8"; | |
464 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9830 | 465 if ((sourcesn != NULL) && isdigit(sourcesn[0])) |
9908 | 466 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 467 else |
9908 | 468 charsetstr1 = "ISO-8859-1"; |
469 charsetstr2 = "UTF-8"; | |
470 } else if (charset == AIM_CHARSET_ASCII) { | |
471 /* Should just be "ASCII" */ | |
9914 | 472 charsetstr1 = "ASCII"; |
9908 | 473 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
474 } else if (charset == 0x000d) { | |
9830 | 475 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 476 charsetstr1 = "ISO-8859-1"; |
477 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
478 } else { | |
9830 | 479 /* Unknown, hope for valid UTF-8... */ |
9908 | 480 charsetstr1 = "UTF-8"; |
481 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
482 } | |
483 | |
484 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
485 if (ret == NULL) | |
486 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
487 if (ret == NULL) | |
488 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 489 |
490 return ret; | |
491 } | |
492 | |
493 static void | |
494 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
495 gchar **msg, int *msglen, | |
496 fu16_t *charset, fu16_t *charsubset) | |
497 { | |
498 OscarData *od = gc->proto_data; | |
499 GaimAccount *account = gaim_connection_get_account(gc); | |
500 GError *err = NULL; | |
501 aim_userinfo_t *userinfo = NULL; | |
502 const gchar *charsetstr; | |
503 | |
504 /* Attempt to send as ASCII */ | |
505 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, msglen, NULL); | |
506 if (*msg != NULL) { | |
507 *charset = AIM_CHARSET_ASCII; | |
508 *charsubset = 0x0000; | |
509 return; | |
510 } | |
511 | |
512 /* | |
9908 | 513 * If we're sending to an ICQ user, and they are advertising the |
514 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 515 */ |
516 if ((destsn != NULL) && isdigit(destsn[0])) | |
517 userinfo = aim_locate_finduserinfo(od->sess, destsn); | |
518 | |
519 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
9908 | 520 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, NULL); |
9830 | 521 if (*msg != NULL) { |
522 *charset = AIM_CHARSET_UNICODE; | |
523 *charsubset = 0x0000; | |
524 return; | |
525 } | |
526 } | |
527 | |
528 /* | |
529 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
530 * ICQ then attempt to send as the user specified character encoding. | |
531 */ | |
532 charsetstr = "ISO-8859-1"; | |
533 if ((destsn != NULL) && isdigit(destsn[0])) | |
534 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
535 | |
536 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, msglen, NULL); | |
537 if (*msg != NULL) { | |
538 *charset = AIM_CHARSET_CUSTOM; | |
539 *charsubset = 0x0000; | |
540 return; | |
541 } | |
542 | |
543 /* | |
544 * Nothing else worked, so send as UCS-2BE. | |
545 */ | |
546 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, &err); | |
547 if (*msg != NULL) { | |
548 *charset = AIM_CHARSET_UNICODE; | |
549 *charsubset = 0x0000; | |
550 return; | |
551 } | |
552 | |
9908 | 553 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 554 g_error_free(err); |
555 | |
556 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
557 *msg = g_strdup(from); | |
558 *msglen = strlen(*msg); | |
559 *charset = AIM_CHARSET_ASCII; | |
560 *charsubset = 0x0000; | |
561 return; | |
562 } | |
563 | |
9407 | 564 gchar *oscar_caps_to_string(guint caps) |
8701 | 565 { |
9407 | 566 GString *str; |
567 gchar *tmp; | |
8701 | 568 guint bit = 1; |
569 | |
9407 | 570 str = g_string_new(""); |
571 | |
8701 | 572 if (!caps) { |
573 return NULL; | |
574 } else while (bit <= AIM_CAPS_LAST) { | |
575 if (bit & caps) { | |
576 switch (bit) { | |
577 case AIM_CAPS_BUDDYICON: | |
578 tmp = _("Buddy Icon"); | |
579 break; | |
580 case AIM_CAPS_TALK: | |
581 tmp = _("Voice"); | |
582 break; | |
583 case AIM_CAPS_DIRECTIM: | |
584 tmp = _("AIM Direct IM"); | |
585 break; | |
586 case AIM_CAPS_CHAT: | |
587 tmp = _("Chat"); | |
588 break; | |
589 case AIM_CAPS_GETFILE: | |
590 tmp = _("Get File"); | |
591 break; | |
592 case AIM_CAPS_SENDFILE: | |
593 tmp = _("Send File"); | |
594 break; | |
595 case AIM_CAPS_GAMES: | |
596 case AIM_CAPS_GAMES2: | |
597 tmp = _("Games"); | |
598 break; | |
599 case AIM_CAPS_ADDINS: | |
600 tmp = _("Add-Ins"); | |
601 break; | |
602 case AIM_CAPS_SENDBUDDYLIST: | |
603 tmp = _("Send Buddy List"); | |
604 break; | |
605 case AIM_CAPS_ICQ_DIRECT: | |
606 tmp = _("ICQ Direct Connect"); | |
607 break; | |
608 case AIM_CAPS_APINFO: | |
609 tmp = _("AP User"); | |
610 break; | |
611 case AIM_CAPS_ICQRTF: | |
612 tmp = _("ICQ RTF"); | |
613 break; | |
614 case AIM_CAPS_EMPTY: | |
615 tmp = _("Nihilist"); | |
616 break; | |
617 case AIM_CAPS_ICQSERVERRELAY: | |
618 tmp = _("ICQ Server Relay"); | |
619 break; | |
620 case AIM_CAPS_ICQUTF8OLD: | |
621 tmp = _("Old ICQ UTF8"); | |
622 break; | |
623 case AIM_CAPS_TRILLIANCRYPT: | |
624 tmp = _("Trillian Encryption"); | |
625 break; | |
626 case AIM_CAPS_ICQUTF8: | |
627 tmp = _("ICQ UTF8"); | |
628 break; | |
629 case AIM_CAPS_HIPTOP: | |
630 tmp = _("Hiptop"); | |
631 break; | |
632 case AIM_CAPS_SECUREIM: | |
633 tmp = _("Security Enabled"); | |
634 break; | |
635 case AIM_CAPS_VIDEO: | |
636 tmp = _("Video Chat"); | |
637 break; | |
638 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
639 case AIM_CAPS_ICHATAV: | |
640 tmp = _("iChat AV"); | |
641 break; | |
642 case AIM_CAPS_LIVEVIDEO: | |
643 tmp = _("Live Video"); | |
644 break; | |
645 case AIM_CAPS_CAMERA: | |
646 tmp = _("Camera"); | |
647 break; | |
648 default: | |
649 tmp = NULL; | |
650 break; | |
651 } | |
652 if (tmp) | |
9532 | 653 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 654 } |
655 bit <<= 1; | |
656 } | |
9407 | 657 |
658 return g_string_free(str, FALSE); | |
8701 | 659 } |
660 | |
661 static char *oscar_icqstatus(int state) { | |
662 /* Make a cute little string that shows the status of the dude or dudet */ | |
663 if (state & AIM_ICQ_STATE_CHAT) | |
664 return g_strdup_printf(_("Free For Chat")); | |
665 else if (state & AIM_ICQ_STATE_DND) | |
666 return g_strdup_printf(_("Do Not Disturb")); | |
667 else if (state & AIM_ICQ_STATE_OUT) | |
668 return g_strdup_printf(_("Not Available")); | |
669 else if (state & AIM_ICQ_STATE_BUSY) | |
670 return g_strdup_printf(_("Occupied")); | |
671 else if (state & AIM_ICQ_STATE_AWAY) | |
672 return g_strdup_printf(_("Away")); | |
673 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
674 return g_strdup_printf(_("Web Aware")); | |
675 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
676 return g_strdup_printf(_("Invisible")); | |
677 else | |
678 return g_strdup_printf(_("Online")); | |
679 } | |
680 | |
681 static void oscar_string_append(GString *str, char *newline, char *name, char *value) | |
8700 | 682 { |
683 gchar *utf8; | |
684 | |
685 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 686 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 687 g_free(utf8); |
688 } | |
689 } | |
690 | |
8701 | 691 static void oscar_string_append_info(GaimConnection *gc, GString *str, char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
692 { | |
693 OscarData *od = gc->proto_data; | |
694 GaimAccount *account = gaim_connection_get_account(gc); | |
695 GaimGroup *g = NULL; | |
696 struct buddyinfo *bi = NULL; | |
697 char *tmp; | |
698 | |
699 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
700 return; | |
701 | |
702 if (userinfo == NULL) | |
703 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
704 | |
705 if (b == NULL) | |
706 b = gaim_find_buddy(gc->account, userinfo->sn); | |
707 | |
708 if (b != NULL) | |
709 g = gaim_find_buddys_group(b); | |
710 | |
711 if (userinfo != NULL) | |
712 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
713 | |
8733 | 714 if (b != NULL) { |
715 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
716 if (isdigit(b->name[0])) { | |
717 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
718 oscar_string_append(str, newline, _("Status"), tmp); | |
719 g_free(tmp); | |
720 } | |
721 } else { | |
9625 | 722 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 723 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
724 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
725 else | |
726 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 727 } |
8733 | 728 } |
8701 | 729 |
730 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 731 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 732 (bi->ipaddr & 0xff000000) >> 24, |
733 (bi->ipaddr & 0x00ff0000) >> 16, | |
734 (bi->ipaddr & 0x0000ff00) >> 8, | |
735 (bi->ipaddr & 0x000000ff)); | |
736 oscar_string_append(str, newline, _("IP Address"), tmp); | |
737 g_free(tmp); | |
738 } | |
739 | |
740 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
741 tmp = oscar_caps_to_string(userinfo->capabilities); | |
742 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 743 g_free(tmp); |
8701 | 744 } |
745 | |
746 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
747 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
748 if (tmp != NULL) { | |
9625 | 749 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 750 g_free(tmp); |
9625 | 751 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
752 g_free(tmp2); | |
8701 | 753 } |
754 } | |
755 | |
756 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
757 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
758 oscar_string_append(str, newline, _("Available"), tmp); | |
759 g_free(tmp); | |
760 } | |
761 } | |
762 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
763 static char *extract_name(const char *name) { |
4121 | 764 char *tmp, *x; |
2086 | 765 int i, j; |
4120 | 766 |
767 if (!name) | |
4121 | 768 return NULL; |
769 | |
4120 | 770 x = strchr(name, '-'); |
4121 | 771 |
2086 | 772 if (!x) return NULL; |
773 x = strchr(++x, '-'); | |
774 if (!x) return NULL; | |
775 tmp = g_strdup(++x); | |
776 | |
777 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
778 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
779 if (x[i] != '%') { |
2086 | 780 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
781 continue; |
2086 | 782 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
783 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
784 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
785 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 786 } |
787 | |
788 tmp[j] = 0; | |
789 return tmp; | |
790 } | |
791 | |
5575 | 792 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 793 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 794 struct chat_connection *c = NULL; |
795 | |
796 while (g) { | |
797 c = (struct chat_connection *)g->data; | |
798 if (c->id == id) | |
799 break; | |
800 g = g->next; | |
801 c = NULL; | |
802 } | |
803 | |
804 return c; | |
805 } | |
806 | |
5575 | 807 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
|
808 aim_conn_t *conn) { |
7283 | 809 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 810 struct chat_connection *c = NULL; |
811 | |
812 while (g) { | |
813 c = (struct chat_connection *)g->data; | |
814 if (c->conn == conn) | |
815 break; | |
816 g = g->next; | |
817 c = NULL; | |
818 } | |
819 | |
820 return c; | |
821 } | |
822 | |
8219 | 823 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
824 GaimConversation *conv) { | |
825 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
826 struct chat_connection *c = NULL; | |
827 | |
828 while (g) { | |
829 c = (struct chat_connection *)g->data; | |
8733 | 830 if (c->conv == conv) |
8219 | 831 break; |
832 g = g->next; | |
833 c = NULL; | |
834 } | |
835 | |
836 return c; | |
837 } | |
838 | |
8971 | 839 /***************************************************************************** |
840 * Begin scary direct im stuff | |
841 *****************************************************************************/ | |
842 | |
843 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
844 GSList *d = od->direct_ims; | |
845 struct oscar_direct_im *m = NULL; | |
846 | |
847 while (d) { | |
848 m = (struct oscar_direct_im *)d->data; | |
849 if (!aim_sncmp(who, m->name)) | |
850 return m; | |
851 d = d->next; | |
852 } | |
853 | |
854 return NULL; | |
855 } | |
856 | |
857 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
858 { | |
859 gaim_debug_info("oscar", | |
860 "destroying Direct IM for %s.\n", dim->name); | |
861 | |
862 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 863 if (dim->gpc_pend) { |
864 dim->killme = TRUE; | |
865 return; | |
866 } | |
8971 | 867 if (dim->watcher) |
868 gaim_input_remove(dim->watcher); | |
869 if (dim->conn) { | |
870 aim_conn_close(dim->conn); | |
871 aim_conn_kill(od->sess, &dim->conn); | |
872 } | |
873 g_free(dim); | |
874 } | |
875 | |
876 /* the only difference between this and destroy is this writes a conv message */ | |
877 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
878 { | |
879 GaimConversation *conv; | |
880 char buf[256]; | |
881 | |
882 gaim_debug_info("oscar", | |
883 "%s disconnected Direct IM.\n", dim->name); | |
884 | |
885 if (dim->connected) | |
886 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 887 else |
8971 | 888 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
889 | |
890 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
891 if (conv) { | |
892 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 893 gaim_conversation_update_progress(conv, 0); |
8971 | 894 } else { |
895 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
896 } | |
897 | |
898 oscar_direct_im_destroy(od, dim); | |
899 | |
900 return; | |
901 } | |
902 | |
903 /* oops i made two of these. this one just calls the other one. */ | |
904 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
905 { | |
906 GaimConnection *gc = sess->aux_data; | |
907 OscarData *od = (OscarData *)gc->proto_data; | |
908 struct oscar_direct_im *dim; | |
909 char *sn; | |
910 | |
911 sn = g_strdup(aim_odc_getsn(conn)); | |
912 dim = oscar_direct_im_find(od, sn); | |
913 oscar_direct_im_disconnect(od, dim); | |
914 g_free(sn); | |
915 } | |
916 | |
917 static void destroy_direct_im_request(struct ask_direct *d) { | |
918 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
919 | |
920 g_free(d->sn); | |
921 g_free(d); | |
922 } | |
923 | |
924 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
925 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
926 struct oscar_direct_im *dim = data; | |
927 GaimConnection *gc = dim->gc; | |
928 OscarData *od = gc->proto_data; | |
929 GaimConversation *conv; | |
930 char buf[256]; | |
931 struct sockaddr name; | |
932 socklen_t name_len = 1; | |
933 | |
934 g_return_if_fail(gc != NULL); | |
935 | |
8978 | 936 dim->gpc_pend = FALSE; |
937 if (dim->killme) { | |
938 oscar_direct_im_destroy(od, dim); | |
939 return; | |
940 } | |
941 | |
8971 | 942 if (!g_list_find(gaim_connections_get_all(), gc)) { |
943 oscar_direct_im_destroy(od, dim); | |
944 return; | |
945 } | |
946 | |
947 if (source < 0) { | |
8984 | 948 if (dim->donttryagain) { |
949 oscar_direct_im_disconnect(od, dim); | |
950 return; | |
951 } else { | |
952 fu8_t cookie[8]; | |
953 char *who = g_strdup(dim->name); | |
954 const char *tmp = aim_odc_getcookie(dim->conn); | |
955 | |
956 memcpy(cookie, tmp, 8); | |
957 oscar_direct_im_destroy(od, dim); | |
958 oscar_direct_im_initiate(gc, who, cookie); | |
959 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
960 g_free(who); | |
961 return; | |
962 } | |
8971 | 963 } |
964 | |
965 dim->conn->fd = source; | |
966 aim_conn_completeconnect(od->sess, dim->conn); | |
967 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
968 | |
969 /* This is the best way to see if we're connected or not */ | |
8983 | 970 /* Is this really needed? */ |
8971 | 971 if (getpeername(source, &name, &name_len) == 0) { |
972 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
973 dim->connected = TRUE; | |
974 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 975 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
976 } else { | |
8984 | 977 if (dim->donttryagain) { |
978 oscar_direct_im_disconnect(od, dim); | |
979 return; | |
980 } else { | |
981 fu8_t cookie[8]; | |
982 char *who = g_strdup(dim->name); | |
983 const char *tmp = aim_odc_getcookie(dim->conn); | |
984 | |
985 memcpy(cookie, tmp, 8); | |
986 oscar_direct_im_destroy(od, dim); | |
987 oscar_direct_im_initiate(gc, who, cookie); | |
988 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
989 g_free(who); | |
990 return; | |
991 } | |
8983 | 992 } |
993 | |
994 | |
8971 | 995 } |
996 | |
997 static void accept_direct_im_request(struct ask_direct *d) { | |
998 GaimConnection *gc = d->gc; | |
999 OscarData *od; | |
1000 struct oscar_direct_im *dim; | |
1001 char *host; int port = 5190; | |
1002 int i, rc; | |
8982 | 1003 char *tmp; |
1004 GaimConversation *conv; | |
8971 | 1005 |
1006 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1007 destroy_direct_im_request(d); | |
1008 return; | |
1009 } | |
1010 | |
1011 od = (OscarData *)gc->proto_data; | |
1012 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1013 | |
1014 dim = oscar_direct_im_find(od, d->sn); | |
1015 if (dim && dim->connected) { | |
1016 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1017 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1018 return; | |
1019 } | |
1020 dim = g_new0(struct oscar_direct_im, 1); | |
1021 dim->gc = d->gc; | |
8984 | 1022 dim->donttryagain = d->donttryagain; |
8971 | 1023 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1024 | |
1025 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1026 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1027 if (!dim->conn) { | |
1028 oscar_direct_im_disconnect(od, dim); | |
1029 destroy_direct_im_request(d); | |
1030 return; | |
1031 } | |
1032 | |
1033 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1034 gaim_odc_incoming, 0); | |
1035 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1036 gaim_odc_typing, 0); | |
1037 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1038 gaim_odc_update_ui, 0); | |
1039 | |
1040 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1041 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1042 if (d->ip[i] == ':') { | |
1043 port = atoi(&(d->ip[i+1])); | |
1044 break; | |
1045 } | |
1046 } | |
1047 host = g_strndup(d->ip, i); | |
1048 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1049 dim->gpc_pend = TRUE; |
8971 | 1050 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1051 |
1052 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1053 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1054 port); | |
1055 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1056 g_free(tmp); | |
8983 | 1057 |
8971 | 1058 g_free(host); |
1059 if (rc < 0) { | |
8978 | 1060 dim->gpc_pend = FALSE; |
8971 | 1061 oscar_direct_im_disconnect(od, dim); |
1062 destroy_direct_im_request(d); | |
1063 return; | |
1064 } | |
1065 | |
1066 destroy_direct_im_request(d); | |
1067 | |
1068 return; | |
1069 } | |
1070 | |
1071 /* | |
1072 * We have just established a socket with the other dude, so set up some handlers. | |
1073 */ | |
1074 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1075 GaimConnection *gc = sess->aux_data; |
7283 | 1076 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1077 GaimConversation *conv; |
8971 | 1078 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1079 char buf[256]; |
8971 | 1080 char *sn; |
1081 va_list ap; | |
1082 aim_conn_t *newconn, *listenerconn; | |
1083 | |
1084 va_start(ap, fr); | |
1085 newconn = va_arg(ap, aim_conn_t *); | |
1086 listenerconn = va_arg(ap, aim_conn_t *); | |
1087 va_end(ap); | |
1088 | |
1089 aim_conn_close(listenerconn); | |
1090 aim_conn_kill(sess, &listenerconn); | |
1091 | |
1092 sn = g_strdup(aim_odc_getsn(newconn)); | |
1093 | |
1094 gaim_debug_info("oscar", | |
1095 "DirectIM: initiate success to %s\n", sn); | |
1096 dim = oscar_direct_im_find(od, sn); | |
1097 | |
1098 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1099 gaim_input_remove(dim->watcher); | |
1100 dim->conn = newconn; | |
1101 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1102 dim->connected = TRUE; | |
1103 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1104 g_free(sn); | |
1105 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1106 | |
1107 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1108 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1109 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1110 | |
1111 return 1; | |
1112 } | |
1113 | |
1114 /* | |
1115 * This is called when each chunk of an image is received. It can be used to | |
1116 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1117 * nasty, you sicko. | |
1118 */ | |
1119 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1120 va_list ap; | |
1121 char *sn; | |
1122 double percent; | |
1123 GaimConnection *gc = sess->aux_data; | |
1124 OscarData *od = (OscarData *)gc->proto_data; | |
1125 GaimConversation *c; | |
1126 struct oscar_direct_im *dim; | |
1127 | |
1128 va_start(ap, fr); | |
1129 sn = va_arg(ap, char *); | |
1130 percent = va_arg(ap, double); | |
1131 va_end(ap); | |
1132 | |
1133 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1134 return 1; | |
1135 if (dim->watcher) { | |
1136 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1137 /* The callback will callback? I don't get how that would happen here. */ | |
1138 dim->watcher = 0; | |
1139 } | |
1140 | |
1141 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
1142 if (c != NULL) | |
1143 gaim_conversation_update_progress(c, percent); | |
1144 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1145 oscar_callback, dim->conn); | |
1146 | |
1147 return 1; | |
1148 } | |
1149 | |
1150 /* | |
1151 * This is called after a direct IM has been received in its entirety. This | |
1152 * function is passed a long chunk of data which contains the IM with any | |
1153 * data chunks (images) appended to it. | |
1154 * | |
1155 * This function rips out all the data chunks and creates an imgstore for | |
1156 * each one. In order to do this, it first goes through the IM and takes | |
1157 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1158 * with one compatible with the imgstore Gaim core code. For each one, we | |
1159 * then read in chunks of data from the end of the message and actually | |
1160 * create the img store using the given data. | |
1161 * | |
1162 * For somewhat easy reference, here's a sample message | |
1163 * (without the whitespace and asterisks): | |
1164 * | |
1165 * <HTML><BODY BGCOLOR="#ffffff"> | |
1166 * <FONT LANG="0"> | |
1167 * This is a really stupid picture:<BR> | |
1168 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1169 * Yeah it is<BR> | |
1170 * Here is another one:<BR> | |
1171 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1172 * </FONT> | |
1173 * </BODY></HTML> | |
1174 * <BINARY> | |
1175 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1176 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1177 * </BINARY> | |
1178 */ | |
1179 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1180 GaimConnection *gc = sess->aux_data; | |
1181 GaimConvImFlags imflags = 0; | |
1182 gchar *utf8; | |
1183 GString *newmsg = g_string_new(""); | |
1184 GSList *images = NULL; | |
1185 va_list ap; | |
1186 const char *sn, *msg, *msgend, *binary; | |
1187 size_t len; | |
1188 int encoding, isawaymsg; | |
1189 | |
1190 va_start(ap, fr); | |
1191 sn = va_arg(ap, const char *); | |
1192 msg = va_arg(ap, const char *); | |
1193 len = va_arg(ap, size_t); | |
1194 encoding = va_arg(ap, int); | |
1195 isawaymsg = va_arg(ap, int); | |
1196 va_end(ap); | |
1197 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1198 |
8660 | 1199 gaim_debug_info("oscar", |
8971 | 1200 "Got DirectIM message from %s\n", sn); |
1201 | |
1202 if (isawaymsg) | |
1203 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1204 | |
1205 /* message has a binary trailer */ | |
1206 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1207 GData *attribs; | |
1208 const char *tmp, *start, *end, *last = NULL; | |
1209 | |
1210 tmp = msg; | |
1211 | |
1212 /* for each valid image tag... */ | |
1213 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1214 const char *id, *src, *datasize; | |
1215 const char *tag = NULL, *data = NULL; | |
1216 size_t size; | |
1217 int imgid = 0; | |
1218 | |
1219 /* update the location of the last img tag */ | |
1220 last = end; | |
1221 | |
1222 /* grab attributes */ | |
1223 id = g_datalist_get_data(&attribs, "id"); | |
1224 src = g_datalist_get_data(&attribs, "src"); | |
1225 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1226 | |
1227 /* if we have id & datasize, build the data tag */ | |
1228 if (id && datasize) | |
1229 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1230 | |
1231 /* if we have a tag, find the start of the data */ | |
1232 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1233 data += strlen(tag); | |
1234 | |
1235 /* check the data is here and store it */ | |
1236 if (data + (size = atoi(datasize)) <= msgend) | |
1237 imgid = gaim_imgstore_add(data, size, src); | |
1238 | |
1239 /* | |
1240 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1241 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1242 */ | |
1243 /* if we have a stored image... */ | |
1244 if (imgid) { | |
1245 /* append the message up to the tag */ | |
1246 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1247 if (utf8 != NULL) { | |
1248 newmsg = g_string_append(newmsg, utf8); | |
1249 g_free(utf8); | |
1250 } | |
1251 | |
1252 /* write the new image tag */ | |
1253 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1254 | |
1255 /* and record the image number */ | |
1256 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1257 } else { | |
1258 /* otherwise, copy up to the end of the tag */ | |
1259 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1260 if (utf8 != NULL) { | |
1261 newmsg = g_string_append(newmsg, utf8); | |
1262 g_free(utf8); | |
1263 } | |
1264 } | |
1265 | |
1266 /* clear the attribute list */ | |
1267 g_datalist_clear(&attribs); | |
1268 | |
1269 /* continue from the end of the tag */ | |
1270 tmp = end + 1; | |
1271 } | |
1272 | |
1273 /* append any remaining message data (without the > :-) */ | |
1274 if (last++ && (last < binary)) | |
1275 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1276 | |
1277 /* set the flag if we caught any images */ | |
1278 if (images) | |
1279 imflags |= GAIM_CONV_IM_IMAGES; | |
1280 } else { | |
1281 g_string_append_len(newmsg, msg, len); | |
1282 } | |
1283 | |
1284 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1285 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1286 | |
1287 /* free up the message */ | |
1288 g_string_free(newmsg, TRUE); | |
1289 | |
1290 /* unref any images we allocated */ | |
1291 if (images) { | |
1292 GSList *tmp; | |
1293 int id; | |
1294 | |
1295 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1296 id = GPOINTER_TO_INT(tmp->data); | |
1297 gaim_imgstore_unref(id); | |
1298 } | |
1299 | |
1300 g_slist_free(images); | |
1301 } | |
1302 | |
1303 return 1; | |
1304 } | |
1305 | |
1306 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1307 va_list ap; | |
1308 char *sn; | |
1309 int typing; | |
1310 GaimConnection *gc = sess->aux_data; | |
1311 | |
1312 va_start(ap, fr); | |
1313 sn = va_arg(ap, char *); | |
1314 typing = va_arg(ap, int); | |
1315 va_end(ap); | |
1316 | |
1317 if (typing == 0x0002) { | |
1318 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1319 gaim_debug_info("oscar", | |
1320 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1321 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1322 } else if (typing == 0x0001) | |
1323 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1324 else | |
1325 serv_got_typing_stopped(gc, sn); | |
1326 return 1; | |
1327 } | |
1328 | |
1329 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1330 char *buf; | |
1331 size_t len; | |
1332 int ret; | |
1333 GString *msg = g_string_new("<HTML><BODY>"); | |
1334 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1335 GData *attribs; | |
1336 const char *start, *end, *last; | |
1337 int oscar_id = 0; | |
1338 | |
1339 last = message; | |
1340 | |
1341 /* for each valid IMG tag... */ | |
1342 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1343 GaimStoredImage *image = NULL; | |
1344 const char *id; | |
1345 | |
1346 if (start - last) { | |
1347 g_string_append_len(msg, last, start - last); | |
1348 } | |
1349 | |
1350 id = g_datalist_get_data(&attribs, "id"); | |
1351 | |
1352 /* ... if it refers to a valid gaim image ... */ | |
1353 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1354 /* ... append the message from start to the tag ... */ | |
9126 | 1355 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1356 const char *filename = gaim_imgstore_get_filename(image); |
1357 gpointer imgdata = gaim_imgstore_get_data(image); | |
1358 | |
1359 oscar_id++; | |
1360 | |
1361 /* ... insert a new img tag with the oscar id ... */ | |
1362 if (filename) | |
1363 g_string_append_printf(msg, | |
9126 | 1364 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1365 filename, oscar_id, size); |
1366 else | |
1367 g_string_append_printf(msg, | |
9126 | 1368 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1369 oscar_id, size); |
1370 | |
1371 /* ... and append the data to the binary section ... */ | |
9126 | 1372 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1373 oscar_id, size); |
1374 data = g_string_append_len(data, imgdata, size); | |
1375 data = g_string_append(data, "</DATA>"); | |
1376 } | |
1377 /* If the tag is invalid, skip it, thus no else here */ | |
1378 | |
1379 g_datalist_clear(&attribs); | |
1380 | |
1381 /* continue from the end of the tag */ | |
1382 last = end + 1; | |
1383 } | |
1384 | |
1385 /* append any remaining message data (without the > :-) */ | |
1386 if (last && *last) | |
1387 msg = g_string_append(msg, last); | |
1388 | |
1389 /* if we inserted any images in the binary section, append it */ | |
1390 if (oscar_id) { | |
1391 msg = g_string_append_len(msg, data->str, data->len); | |
1392 msg = g_string_append(msg, "</BINARY>"); | |
1393 } | |
1394 | |
1395 len = msg->len; | |
1396 buf = msg->str; | |
1397 g_string_free(msg, FALSE); | |
1398 g_string_free(data, TRUE); | |
1399 | |
1400 | |
1401 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1402 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1403 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1404 else | |
1405 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1406 | |
1407 g_free(buf); | |
1408 | |
1409 return ret; | |
1410 } | |
1411 | |
1412 struct ask_do_dir_im { | |
1413 char *who; | |
1414 GaimConnection *gc; | |
1415 }; | |
1416 | |
1417 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1418 g_free(data->who); | |
1419 g_free(data); | |
1420 } | |
1421 | |
8983 | 1422 /* this function is used to initiate a direct im session with someone. |
1423 * we start listening on a port and send a request. they either connect | |
1424 * or send some kind of reply. If they can't connect, they ask us to | |
1425 * connect to them, and so we do that. | |
1426 * | |
1427 * this function will also get called if the other side initiate's a direct | |
1428 * im and we try to connect and fail. in that case cookie will not be null. | |
1429 * | |
1430 * note that cookie is an 8 byte string that isn't NULL terminated | |
1431 */ | |
1432 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1433 OscarData *od; |
1434 struct oscar_direct_im *dim; | |
1435 int listenfd; | |
8982 | 1436 const char *ip; |
8971 | 1437 |
1438 od = (OscarData *)gc->proto_data; | |
1439 | |
8983 | 1440 dim = oscar_direct_im_find(od, who); |
8971 | 1441 if (dim) { |
1442 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1443 oscar_direct_im_disconnect(od, dim); | |
1444 gaim_debug_info("oscar", | |
1445 "Gave up on old direct IM, trying again\n"); | |
1446 } else { | |
1447 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1448 return; |
8971 | 1449 } |
1450 } | |
1451 dim = g_new0(struct oscar_direct_im, 1); | |
1452 dim->gc = gc; | |
8983 | 1453 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1454 |
1455 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1456 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1457 if (listenfd >= 0) |
1458 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1459 if (dim->conn != NULL) { |
8982 | 1460 char *tmp; |
1461 GaimConversation *conv; | |
1462 | |
8971 | 1463 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1464 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1465 oscar_callback, dim->conn); | |
1466 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1467 gaim_odc_initiate, 0); | |
8982 | 1468 |
8983 | 1469 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1470 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1471 gaim_network_get_port_from_fd(listenfd)); |
1472 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1473 g_free(tmp); | |
8971 | 1474 } else { |
1475 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1476 oscar_direct_im_destroy(od, dim); | |
1477 } | |
8983 | 1478 } |
1479 | |
1480 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1481 GaimConnection *gc = data->gc; | |
1482 | |
1483 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1484 g_free(data->who); | |
1485 g_free(data); | |
1486 return; | |
1487 } | |
1488 | |
1489 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1490 g_free(data->who); |
1491 g_free(data); | |
1492 } | |
1493 | |
1494 /* this is the right click menu cb thingy */ | |
9030 | 1495 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1496 | |
1497 GaimBuddy *buddy; | |
1498 GaimConnection *gc; | |
8971 | 1499 gchar *buf; |
9030 | 1500 struct ask_do_dir_im *data; |
1501 | |
1502 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1503 | |
1504 buddy = (GaimBuddy *) node; | |
1505 gc = gaim_account_get_connection(buddy->account); | |
1506 | |
1507 data = g_new0(struct ask_do_dir_im, 1); | |
1508 data->who = g_strdup(buddy->name); | |
8971 | 1509 data->gc = gc; |
9030 | 1510 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1511 buddy->name); | |
8971 | 1512 |
1513 gaim_request_action(gc, NULL, buf, | |
9030 | 1514 _("Because this reveals your IP address, it " |
1515 "may be considered a privacy risk. Do you " | |
1516 "wish to continue?"), | |
1517 0, data, 2, | |
1518 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1519 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1520 g_free(buf); |
1521 } | |
1522 | |
1523 /***************************************************************************** | |
1524 * End scary direct im stuff | |
1525 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1526 |
4617 | 1527 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1528 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1529 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1530 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1531 OscarData *od; |
2086 | 1532 |
1533 if (!gc) { | |
8660 | 1534 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1535 "oscar callback for closed connection (1).\n"); |
2086 | 1536 return; |
1537 } | |
1538 | |
7283 | 1539 od = (OscarData *)gc->proto_data; |
2086 | 1540 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1541 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1542 /* oh boy. this is probably bad. i guess the only thing we |
1543 * can really do is return? */ | |
8660 | 1544 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1545 "oscar callback for closed connection (2).\n"); |
8660 | 1546 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1547 return; |
1548 } | |
1549 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1550 if (condition & GAIM_INPUT_READ) { |
4617 | 1551 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1552 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1553 "got information on rendezvous listener\n"); |
4617 | 1554 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1555 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1556 "connection error (rendezvous listener)\n"); |
4617 | 1557 aim_conn_kill(od->sess, &conn); |
8446 | 1558 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1559 } |
1560 } else { | |
4617 | 1561 if (aim_get_command(od->sess, conn) >= 0) { |
1562 aim_rxdispatch(od->sess); | |
6029 | 1563 if (od->killme) { |
8660 | 1564 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1565 return; |
1566 } | |
2086 | 1567 } else { |
1568 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1569 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1570 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1571 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1572 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1573 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1574 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1575 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1576 char *buf; |
8660 | 1577 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1578 "disconnected from chat room %s\n", c->name); |
2086 | 1579 c->conn = NULL; |
1580 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1581 gaim_input_remove(c->inpa); |
2086 | 1582 c->inpa = 0; |
1583 c->fd = -1; | |
4617 | 1584 aim_conn_kill(od->sess, &conn); |
5420 | 1585 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1586 if (conv) |
1587 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1588 else | |
1589 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1590 g_free(buf); |
2086 | 1591 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1592 if (od->cnpa > 0) |
1593 gaim_input_remove(od->cnpa); | |
1594 od->cnpa = 0; | |
8660 | 1595 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1596 "removing chatnav input watcher\n"); |
4617 | 1597 while (od->create_rooms) { |
1598 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1599 g_free(cr->name); |
4617 | 1600 od->create_rooms = |
1601 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1602 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1603 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1604 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1605 NULL); |
2086 | 1606 } |
4617 | 1607 aim_conn_kill(od->sess, &conn); |
2086 | 1608 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1609 if (od->paspa > 0) |
1610 gaim_input_remove(od->paspa); | |
1611 od->paspa = 0; | |
8660 | 1612 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1613 "removing authconn input watcher\n"); |
4617 | 1614 aim_conn_kill(od->sess, &conn); |
3694 | 1615 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1616 if (od->emlpa > 0) |
1617 gaim_input_remove(od->emlpa); | |
1618 od->emlpa = 0; | |
8660 | 1619 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1620 "removing email input watcher\n"); |
4617 | 1621 aim_conn_kill(od->sess, &conn); |
4804 | 1622 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1623 if (od->icopa > 0) | |
1624 gaim_input_remove(od->icopa); | |
1625 od->icopa = 0; | |
8660 | 1626 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1627 "removing icon input watcher\n"); |
4804 | 1628 aim_conn_kill(od->sess, &conn); |
2086 | 1629 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1630 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1631 gaim_odc_disconnect(od->sess, conn); |
1632 aim_conn_kill(od->sess, &conn); | |
2086 | 1633 } else { |
8660 | 1634 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1635 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1636 conn->type); |
4617 | 1637 aim_conn_kill(od->sess, &conn); |
2086 | 1638 } |
1639 } | |
1640 } | |
1641 } | |
1642 } | |
1643 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1644 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1645 GaimConnection *gc = sess->aux_data; |
7285 | 1646 gchar *s = g_strdup_vprintf(format, va); |
1647 gchar *buf; | |
1648 | |
1649 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1650 gaim_debug_info("oscar", buf); |
7285 | 1651 if (buf[strlen(buf)-1] != '\n') |
8660 | 1652 gaim_debug_info(NULL, "\n"); |
7285 | 1653 g_free(buf); |
2086 | 1654 g_free(s); |
1655 } | |
1656 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1657 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1658 { |
5575 | 1659 GaimConnection *gc = data; |
7283 | 1660 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1661 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1662 aim_conn_t *conn; |
2086 | 1663 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1664 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1665 close(source); |
1666 return; | |
1667 } | |
1668 | |
4617 | 1669 od = gc->proto_data; |
1670 sess = od->sess; | |
2086 | 1671 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1672 conn->fd = source; |
2086 | 1673 |
1674 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1675 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1676 return; |
1677 } | |
1678 | |
1679 aim_conn_completeconnect(sess, conn); | |
4617 | 1680 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1681 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1682 | |
8660 | 1683 gaim_debug_info("oscar", |
7282 | 1684 "Screen name sent, waiting for response\n"); |
7283 | 1685 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1686 ck[1] = 0x65; |
2086 | 1687 } |
1688 | |
5575 | 1689 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1690 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1691 aim_conn_t *conn; |
5575 | 1692 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1693 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1694 |
8660 | 1695 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1696 |
8437 | 1697 if (!aim_snvalid(gaim_account_get_username(account))) { |
1698 gchar *buf; | |
8590 | 1699 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 | 1700 gaim_connection_error(gc, buf); |
1701 g_free(buf); | |
1702 } | |
1703 | |
5575 | 1704 if (isdigit(*(gaim_account_get_username(account)))) { |
4617 | 1705 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1706 } else { |
6622 | 1707 gc->flags |= GAIM_CONNECTION_HTML; |
1708 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1709 } |
5836 | 1710 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1711 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1712 sess = g_new0(aim_session_t, 1); |
7285 | 1713 aim_session_init(sess, TRUE, 0); |
2086 | 1714 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1715 /* |
1716 * We need an immediate queue because we don't use a while-loop | |
1717 * to see if things need to be sent. | |
1718 */ | |
2086 | 1719 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1720 od->sess = sess; |
2086 | 1721 sess->aux_data = gc; |
1722 | |
9935 | 1723 /* Connect to core Gaim signals */ |
1724 gaim_prefs_connect_callback("/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); | |
1725 | |
2086 | 1726 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1727 if (conn == NULL) { | |
8660 | 1728 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1729 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1730 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1731 return; |
1732 } | |
1733 | |
4649 | 1734 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1735 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1736 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1737 | |
1738 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1739 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1740 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1741 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1742 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1743 return; |
1744 } | |
7282 | 1745 |
7283 | 1746 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1747 ck[0] = 0x5a; |
5575 | 1748 } |
1749 | |
1750 static void oscar_close(GaimConnection *gc) { | |
7283 | 1751 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1752 |
1753 while (od->oscar_chats) { | |
1754 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1755 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1756 gaim_input_remove(n->inpa); |
2086 | 1757 g_free(n->name); |
1758 g_free(n->show); | |
4617 | 1759 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1760 g_free(n); |
1761 } | |
4617 | 1762 while (od->direct_ims) { |
8971 | 1763 struct oscar_direct_im *n = od->direct_ims->data; |
1764 oscar_direct_im_destroy(od, n); | |
2086 | 1765 } |
4617 | 1766 /* BBB */ |
1767 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1768 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1769 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1770 gaim_xfer_cancel_local(xfer); |
3630 | 1771 } |
4804 | 1772 while (od->requesticon) { |
1773 char *sn = od->requesticon->data; | |
1774 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1775 free(sn); | |
1776 } | |
4738 | 1777 g_hash_table_destroy(od->buddyinfo); |
4617 | 1778 while (od->create_rooms) { |
1779 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1780 g_free(cr->name); |
4617 | 1781 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1782 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1783 } |
4617 | 1784 if (od->email) |
1785 g_free(od->email); | |
1786 if (od->newp) | |
1787 g_free(od->newp); | |
1788 if (od->oldp) | |
1789 g_free(od->oldp); | |
2086 | 1790 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1791 gaim_input_remove(gc->inpa); |
4617 | 1792 if (od->cnpa > 0) |
1793 gaim_input_remove(od->cnpa); | |
1794 if (od->paspa > 0) | |
1795 gaim_input_remove(od->paspa); | |
1796 if (od->emlpa > 0) | |
1797 gaim_input_remove(od->emlpa); | |
4804 | 1798 if (od->icopa > 0) |
1799 gaim_input_remove(od->icopa); | |
6907 | 1800 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1801 gaim_timeout_remove(od->icontimer); |
8341 | 1802 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1803 gaim_timeout_remove(od->getblisttimer); |
8341 | 1804 if (od->getinfotimer > 0) |
1805 gaim_timeout_remove(od->getinfotimer); | |
4617 | 1806 aim_session_kill(od->sess); |
1807 g_free(od->sess); | |
1808 od->sess = NULL; | |
2086 | 1809 g_free(gc->proto_data); |
1810 gc->proto_data = NULL; | |
8660 | 1811 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1812 } |
1813 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1814 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1815 GaimConnection *gc = data; |
7283 | 1816 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1817 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1818 aim_conn_t *bosconn; |
2086 | 1819 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1820 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1821 close(source); |
1822 return; | |
1823 } | |
1824 | |
4617 | 1825 od = gc->proto_data; |
1826 sess = od->sess; | |
1827 bosconn = od->conn; | |
4366 | 1828 bosconn->fd = source; |
2086 | 1829 |
1830 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1831 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1832 return; |
1833 } | |
1834 | |
1835 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1836 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1837 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1838 gaim_connection_update_progress(gc, |
7283 | 1839 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1840 ck[4] = 0x61; |
2086 | 1841 } |
1842 | |
4617 | 1843 /* BBB */ |
4656 | 1844 /* |
1845 * This little area in oscar.c is the nexus of file transfer code, | |
1846 * so I wrote a little explanation of what happens. I am such a | |
1847 * ninja. | |
1848 * | |
1849 * The series of events for a file send is: | |
1850 * -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
|
1851 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1852 * listening socket, then asks the remote user to connect to us (and |
1853 * gives them the file name, port, IP, etc.) | |
1854 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1855 * in oscar_sendfile_estblsh) | |
1856 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1857 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1858 * connection. | |
1859 * -We get drunk because file transfer kicks ass. | |
1860 * | |
1861 * The series of events for a file receive is: | |
1862 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1863 * -Gaim user selects file to name and location to save file to and | |
1864 * oscar_xfer_init is called | |
1865 * -It connects to the remote user using the IP they gave us earlier | |
1866 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1867 * them an AIM_CB_OFT_ACK. | |
1868 * -They begin to send us lots of raw data. | |
1869 * -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
|
1870 * the connection. |
4656 | 1871 */ |
1872 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1873 | |
8446 | 1874 /* |
1875 * Miscellaneous xfer functions | |
1876 */ | |
1877 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1878 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1879 GaimXfer *xfer; |
5146 | 1880 struct aim_oft_info *oft_info; |
4656 | 1881 |
1882 while (fts) { | |
1883 xfer = fts->data; | |
5146 | 1884 oft_info = xfer->data; |
1885 | |
8446 | 1886 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1887 return xfer; |
1888 | |
1889 fts = g_slist_next(fts); | |
1890 } | |
1891 | |
1892 return NULL; | |
1893 } | |
1894 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1895 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1896 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1897 GaimXfer *xfer; |
5146 | 1898 struct aim_oft_info *oft_info; |
4656 | 1899 |
1900 while (fts) { | |
1901 xfer = fts->data; | |
5146 | 1902 oft_info = xfer->data; |
1903 | |
1904 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1905 return xfer; |
1906 | |
1907 fts = g_slist_next(fts); | |
1908 } | |
1909 | |
1910 return NULL; | |
1911 } | |
1912 | |
8446 | 1913 static void oscar_xfer_end(GaimXfer *xfer) |
1914 { | |
1915 struct aim_oft_info *oft_info = xfer->data; | |
1916 GaimConnection *gc = oft_info->sess->aux_data; | |
1917 OscarData *od = gc->proto_data; | |
1918 | |
8660 | 1919 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1920 |
1921 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1922 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1923 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1924 } | |
1925 | |
1926 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1927 aim_oft_destroyinfo(oft_info); | |
1928 xfer->data = NULL; | |
1929 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1930 } | |
1931 | |
1932 /* | |
1933 * xfer functions used when receiving files | |
1934 */ | |
1935 | |
1936 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1937 { | |
1938 struct aim_oft_info *oft_info = xfer->data; | |
1939 GaimConnection *gc = oft_info->sess->aux_data; | |
1940 OscarData *od = gc->proto_data; | |
1941 | |
8660 | 1942 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1943 |
1944 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1945 if (oft_info->conn) { | |
1946 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1947 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1948 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1949 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1950 if (xfer->fd == -1) { | |
1951 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1952 _("Unable to establish file descriptor.")); | |
1953 gaim_xfer_cancel_local(xfer); | |
1954 } | |
1955 } else { | |
1956 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1957 _("Unable to create new connection.")); | |
1958 gaim_xfer_cancel_local(xfer); | |
1959 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1960 } | |
1961 | |
1962 } | |
1963 | |
1964 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1965 { | |
1966 struct aim_oft_info *oft_info = xfer->data; | |
1967 GaimConnection *gc = oft_info->sess->aux_data; | |
1968 OscarData *od = gc->proto_data; | |
1969 | |
8660 | 1970 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1971 |
9771 | 1972 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1973 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1974 |
1975 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1976 aim_oft_destroyinfo(oft_info); | |
1977 xfer->data = NULL; | |
1978 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1979 } | |
1980 | |
1981 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1982 { | |
1983 struct aim_oft_info *oft_info = xfer->data; | |
1984 | |
1985 /* Update our rolling checksum. Like Walmart, yo. */ | |
1986 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
1987 } | |
1988 | |
1989 /* | |
1990 * xfer functions used when sending files | |
1991 */ | |
1992 | |
1993 static void oscar_xfer_init_send(GaimXfer *xfer) | |
1994 { | |
1995 struct aim_oft_info *oft_info = xfer->data; | |
1996 GaimConnection *gc = oft_info->sess->aux_data; | |
1997 OscarData *od = gc->proto_data; | |
1998 int listenfd; | |
1999 | |
8660 | 2000 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2001 |
2002 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2003 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2004 oft_info->fh.name[63] = '\0'; | |
2005 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2006 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2007 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2008 | |
2009 /* Create a listening socket and an associated libfaim conn */ | |
2010 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2011 gaim_xfer_cancel_local(xfer); | |
2012 return; | |
2013 } | |
2014 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2015 oft_info->port = xfer->local_port; | |
2016 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2017 gaim_xfer_cancel_local(xfer); | |
2018 return; | |
2019 } | |
8660 | 2020 gaim_debug_misc("oscar", |
8446 | 2021 "port is %hu, ip is %s\n", |
2022 xfer->local_port, oft_info->clientip); | |
2023 if (oft_info->conn) { | |
2024 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2025 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2026 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2027 } else { | |
2028 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2029 _("Unable to establish listener socket.")); | |
2030 gaim_xfer_cancel_local(xfer); | |
2031 } | |
2032 } | |
2033 | |
2034 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2035 { | |
2036 struct aim_oft_info *oft_info = xfer->data; | |
2037 GaimConnection *gc = oft_info->sess->aux_data; | |
2038 OscarData *od = gc->proto_data; | |
2039 | |
8660 | 2040 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2041 |
9771 | 2042 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2043 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2044 |
2045 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2046 aim_oft_destroyinfo(oft_info); | |
2047 xfer->data = NULL; | |
2048 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2049 } | |
2050 | |
2051 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2052 { | |
2053 struct aim_oft_info *oft_info = xfer->data; | |
2054 | |
2055 /* I'm not sure I like how we do this. --marv | |
2056 * I do. AIM file transfers aren't really meant to be thought | |
2057 * of as a transferring just a single file. The rendezvous | |
2058 * establishes a connection between two computers, and then | |
2059 * those computers can use the same connection for transferring | |
2060 * multiple files. So we don't want the Gaim core up and closing | |
2061 * the socket all willy-nilly. We want to do that in the oscar | |
2062 * prpl, whenever one side or the other says they're finished | |
2063 * using the connection. There might be a better way to intercept | |
2064 * the socket from the core, however... --KingAnt | |
2065 */ | |
2066 | |
2067 /* | |
2068 * If we're done sending, intercept the socket from the core ft code | |
2069 * and wait for the other guy to send the "done" OFT packet. | |
2070 */ | |
2071 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2072 gaim_input_remove(xfer->watcher); | |
2073 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2074 xfer->fd = 0; | |
2075 gaim_xfer_set_completed(xfer, TRUE); | |
2076 } | |
2077 } | |
2078 | |
9466 | 2079 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2080 gboolean can_receive = FALSE; | |
2081 OscarData *od = gc->proto_data; | |
2082 | |
2083 if (!od->icq) { | |
2084 aim_userinfo_t *userinfo; | |
2085 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2086 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2087 can_receive = TRUE; | |
2088 } | |
2089 | |
2090 return can_receive; | |
2091 } | |
2092 | |
2093 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2094 |
2095 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2096 GaimXfer *xfer; |
5146 | 2097 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2098 const char *ip; |
3752 | 2099 |
9030 | 2100 od = (OscarData *)gc->proto_data; |
2101 | |
4617 | 2102 /* You want to send a file to someone else, you're so generous */ |
2103 | |
2104 /* Build the file transfer handle */ | |
9466 | 2105 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2106 |
5146 | 2107 /* Create the oscar-specific data */ |
8838 | 2108 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2109 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2110 xfer->data = oft_info; |
2111 | |
4617 | 2112 /* Setup our I/O op functions */ |
8446 | 2113 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2114 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2115 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2116 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2117 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2118 |
2119 /* Keep track of this transfer for later */ | |
2120 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2121 | |
2122 /* Now perform the request */ | |
9466 | 2123 if (file) |
2124 gaim_xfer_request_accepted(xfer, file); | |
2125 else | |
2126 gaim_xfer_request(xfer); | |
3630 | 2127 } |
2128 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2129 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2130 GaimConnection *gc = sess->aux_data; |
7283 | 2131 OscarData *od = gc->proto_data; |
6029 | 2132 GaimAccount *account = gc->account; |
2133 aim_conn_t *bosconn; | |
2134 char *host; int port; | |
2135 int i, rc; | |
2086 | 2136 va_list ap; |
2704 | 2137 struct aim_authresp_info *info; |
6029 | 2138 |
5575 | 2139 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2140 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2141 va_start(ap, fr); |
2704 | 2142 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2143 va_end(ap); |
2144 | |
8660 | 2145 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2146 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2147 |
4293 | 2148 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2149 char buf[256]; |
2704 | 2150 switch (info->errorcode) { |
2086 | 2151 case 0x05: |
2152 /* Incorrect nick/password */ | |
6498 | 2153 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2154 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2155 break; |
2156 case 0x11: | |
2157 /* Suspended account */ | |
6498 | 2158 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2159 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2160 break; |
3498 | 2161 case 0x14: |
2162 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2163 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2164 break; |
2086 | 2165 case 0x18: |
2166 /* connecting too frequently */ | |
6498 | 2167 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2168 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 | 2169 break; |
2170 case 0x1c: | |
2171 /* client too old */ | |
6498 | 2172 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2173 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
|
2174 gaim_connection_error(gc, buf); |
2086 | 2175 break; |
2176 default: | |
6623 | 2177 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2178 break; |
2179 } | |
8660 | 2180 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2181 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2182 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2183 "Error URL: %s\n", info->errorurl); |
2086 | 2184 od->killme = TRUE; |
2185 return 1; | |
2186 } | |
2187 | |
2188 | |
8660 | 2189 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2190 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2191 |
2704 | 2192 if (info->email) { |
8660 | 2193 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2194 } else { |
8660 | 2195 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2196 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2197 |
8660 | 2198 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2199 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2200 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2201 aim_conn_kill(sess, &fr->conn); |
2086 | 2202 |
2203 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2204 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2205 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2206 od->killme = TRUE; |
2207 return 0; | |
2208 } | |
2209 | |
4649 | 2210 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2211 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2212 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2213 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2214 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2215 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2216 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2217 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2218 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2219 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2220 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2221 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2222 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2223 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2224 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2225 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2226 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2227 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2228 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2229 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2230 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2231 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2232 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
|
2233 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2234 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2235 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2236 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2237 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2238 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2239 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
|
2240 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
|
2241 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
|
2242 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2243 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2244 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2245 #ifndef NOSSI |
4642 | 2246 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2247 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2248 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2249 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2250 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2251 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2252 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2253 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2254 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2255 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2256 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2257 |
7283 | 2258 od->conn = bosconn; |
2704 | 2259 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2260 if (info->bosip[i] == ':') { | |
2261 port = atoi(&(info->bosip[i+1])); | |
2086 | 2262 break; |
2263 } | |
2264 } | |
2704 | 2265 host = g_strndup(info->bosip, i); |
2086 | 2266 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2267 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2268 g_free(host); |
4366 | 2269 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2270 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2271 od->killme = TRUE; |
2272 return 0; | |
2273 } | |
4293 | 2274 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2275 gaim_input_remove(gc->inpa); |
2704 | 2276 |
7283 | 2277 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2278 ck[3] = 0x64; |
7282 | 2279 |
2086 | 2280 return 1; |
2281 } | |
2282 | |
7285 | 2283 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2284 struct pieceofcrap { |
5575 | 2285 GaimConnection *gc; |
2086 | 2286 unsigned long offset; |
2287 unsigned long len; | |
2288 char *modname; | |
2289 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2290 aim_conn_t *conn; |
2086 | 2291 unsigned int inpa; |
2292 }; | |
2293 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2294 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2295 { |
2296 struct pieceofcrap *pos = data; | |
7283 | 2297 OscarData *od = pos->gc->proto_data; |
2086 | 2298 char in = '\0'; |
2299 int x = 0; | |
2300 unsigned char m[17]; | |
2301 | |
2302 while (read(pos->fd, &in, 1) == 1) { | |
2303 if (in == '\n') | |
2304 x++; | |
2305 else if (in != '\r') | |
2306 x = 0; | |
2307 if (x == 2) | |
2308 break; | |
2309 in = '\0'; | |
2310 } | |
2311 if (in != '\n') { | |
4056 | 2312 char buf[256]; |
2313 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
|
2314 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2315 gaim_notify_warning(pos->gc, NULL, |
7422 | 2316 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2317 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2318 gaim_input_remove(pos->inpa); |
2086 | 2319 close(pos->fd); |
2320 g_free(pos); | |
2321 return; | |
2322 } | |
2323 read(pos->fd, m, 16); | |
2324 m[16] = '\0'; | |
8660 | 2325 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2326 for (x = 0; x < 16; x++) |
8660 | 2327 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2328 | |
2329 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2330 gaim_input_remove(pos->inpa); |
2086 | 2331 close(pos->fd); |
2332 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2333 g_free(pos); | |
2334 } | |
2335 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2336 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2337 struct pieceofcrap *pos = data; |
5420 | 2338 gchar *buf; |
2086 | 2339 |
4366 | 2340 pos->fd = source; |
2341 | |
2086 | 2342 if (source < 0) { |
5420 | 2343 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
|
2344 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2345 gaim_notify_warning(pos->gc, NULL, |
7422 | 2346 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2347 buf); |
5420 | 2348 g_free(buf); |
2086 | 2349 if (pos->modname) |
2350 g_free(pos->modname); | |
2351 g_free(pos); | |
2352 return; | |
2353 } | |
2354 | |
5420 | 2355 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2356 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2357 write(pos->fd, buf, strlen(buf)); | |
5420 | 2358 g_free(buf); |
2086 | 2359 if (pos->modname) |
2360 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2361 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2362 return; |
2363 } | |
2364 | |
2365 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2366 #define AIM_MAX_FILE_SIZE 98304 | |
2367 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2368 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2369 va_list ap; |
2370 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2371 fu32_t offset, len; |
2086 | 2372 char *modname; |
2373 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2374 va_start(ap, fr); |
4200 | 2375 offset = va_arg(ap, fu32_t); |
2376 len = va_arg(ap, fu32_t); | |
2086 | 2377 modname = va_arg(ap, char *); |
2378 va_end(ap); | |
2379 | |
8660 | 2380 gaim_debug_misc("oscar", |
5556 | 2381 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2382 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2383 |
2086 | 2384 if (len == 0) { |
8660 | 2385 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2386 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2387 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2388 return 1; | |
2389 } | |
9625 | 2390 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2391 #if 0 | |
2086 | 2392 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2393 char *buf; | |
2394 int i = 8; | |
2395 if (modname) | |
2396 i += strlen(modname); | |
2397 buf = g_malloc(i); | |
2398 i = 0; | |
2399 if (modname) { | |
2400 memcpy(buf, modname, strlen(modname)); | |
2401 i += strlen(modname); | |
2402 } | |
2403 buf[i++] = offset & 0xff; | |
2404 buf[i++] = (offset >> 8) & 0xff; | |
2405 buf[i++] = (offset >> 16) & 0xff; | |
2406 buf[i++] = (offset >> 24) & 0xff; | |
2407 buf[i++] = len & 0xff; | |
2408 buf[i++] = (len >> 8) & 0xff; | |
2409 buf[i++] = (len >> 16) & 0xff; | |
2410 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2411 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2412 "hashing request\n"); |
2086 | 2413 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2414 g_free(buf); | |
2415 return 1; | |
2416 } | |
9625 | 2417 #endif |
2086 | 2418 |
2419 pos = g_new0(struct pieceofcrap, 1); | |
2420 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2421 pos->conn = fr->conn; |
2086 | 2422 |
2423 pos->offset = offset; | |
2424 pos->len = len; | |
2425 pos->modname = modname ? g_strdup(modname) : NULL; | |
2426 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2427 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2428 char buf[256]; |
2086 | 2429 if (pos->modname) |
2430 g_free(pos->modname); | |
2431 g_free(pos); | |
4056 | 2432 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
|
2433 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2434 gaim_notify_warning(pos->gc, NULL, |
7422 | 2435 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2436 buf); |
2086 | 2437 } |
2438 | |
2439 return 1; | |
2440 } | |
2441 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2442 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2443 GaimConnection *gc = sess->aux_data; |
7283 | 2444 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2445 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2446 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2447 #if 0 |
2448 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2449 #endif | |
7011 | 2450 va_list ap; |
2451 char *key; | |
2086 | 2452 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2453 va_start(ap, fr); |
2086 | 2454 key = va_arg(ap, char *); |
2455 va_end(ap); | |
2456 | |
4617 | 2457 if (od->icq) { |
3458 | 2458 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2459 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2460 gaim_account_get_password(account), &info, key); |
3458 | 2461 } else { |
2462 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2463 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2464 gaim_account_get_password(account), &info, key); |
3458 | 2465 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2466 |
7283 | 2467 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2468 ck[2] = 0x6c; |
7282 | 2469 |
2086 | 2470 return 1; |
2471 } | |
2472 | |
2675 | 2473 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2474 GaimConnection *gc = sess->aux_data; |
2647 | 2475 struct chat_connection *chatcon; |
2476 static int id = 1; | |
2477 | |
6905 | 2478 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
|
2479 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
|
2480 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
|
2481 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
|
2482 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2483 |
2672 | 2484 aim_clientready(sess, fr->conn); |
2675 | 2485 |
2647 | 2486 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2487 chatcon->id = id; | |
8733 | 2488 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2489 |
2490 return 1; | |
2491 } | |
2492 | |
2675 | 2493 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2494 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2495 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2496 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2497 |
2498 aim_clientready(sess, fr->conn); | |
2499 | |
2500 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2501 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2502 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2503 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2504 |
3694 | 2505 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2506 | |
2507 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2508 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2509 | |
7282 | 2510 aim_email_sendcookies(sess); |
2511 aim_email_activate(sess); | |
3694 | 2512 aim_clientready(sess, fr->conn); |
2513 | |
2514 return 1; | |
2515 } | |
2516 | |
4804 | 2517 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2518 GaimConnection *gc = sess->aux_data; |
7283 | 2519 OscarData *od = gc->proto_data; |
4804 | 2520 |
2521 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2522 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2523 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2524 | |
2525 aim_clientready(sess, fr->conn); | |
2526 | |
4823 | 2527 od->iconconnecting = FALSE; |
2528 | |
4804 | 2529 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2530 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2531 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2532 |
2533 return 1; | |
2534 } | |
2535 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2536 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2537 GaimConnection *gc = data; |
7283 | 2538 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2539 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2540 aim_conn_t *tstconn; |
2086 | 2541 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2542 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2543 close(source); |
2544 return; | |
2545 } | |
2546 | |
4617 | 2547 od = gc->proto_data; |
2548 sess = od->sess; | |
2086 | 2549 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2550 tstconn->fd = source; |
2086 | 2551 |
2552 if (source < 0) { | |
2553 aim_conn_kill(sess, &tstconn); | |
8660 | 2554 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2555 "unable to connect to chatnav server\n"); |
2086 | 2556 return; |
2557 } | |
2558 | |
2559 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2560 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2561 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2562 } |
2563 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2564 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2565 { |
5575 | 2566 GaimConnection *gc = data; |
7283 | 2567 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2568 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2569 aim_conn_t *tstconn; |
2086 | 2570 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2571 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2572 close(source); |
2573 return; | |
2574 } | |
2575 | |
4617 | 2576 od = gc->proto_data; |
2577 sess = od->sess; | |
2086 | 2578 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2579 tstconn->fd = source; |
2086 | 2580 |
2581 if (source < 0) { | |
2582 aim_conn_kill(sess, &tstconn); | |
8660 | 2583 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2584 "unable to connect to authorizer\n"); |
2086 | 2585 return; |
2586 } | |
2587 | |
2588 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2589 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2590 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2591 } |
2592 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2593 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2594 { |
2595 struct chat_connection *ccon = data; | |
5575 | 2596 GaimConnection *gc = ccon->gc; |
7283 | 2597 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2598 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2599 aim_conn_t *tstconn; |
2086 | 2600 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2601 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2602 close(source); |
2603 g_free(ccon->show); | |
2604 g_free(ccon->name); | |
2605 g_free(ccon); | |
2606 return; | |
2607 } | |
2608 | |
4617 | 2609 od = gc->proto_data; |
2610 sess = od->sess; | |
2086 | 2611 tstconn = ccon->conn; |
4366 | 2612 tstconn->fd = source; |
2086 | 2613 |
2614 if (source < 0) { | |
2615 aim_conn_kill(sess, &tstconn); | |
2616 g_free(ccon->show); | |
2617 g_free(ccon->name); | |
2618 g_free(ccon); | |
2619 return; | |
2620 } | |
2621 | |
2622 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2623 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2624 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2625 } |
2626 | |
3694 | 2627 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2628 GaimConnection *gc = data; |
7283 | 2629 OscarData *od; |
3694 | 2630 aim_session_t *sess; |
2631 aim_conn_t *tstconn; | |
2632 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2633 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2634 close(source); |
2635 return; | |
2636 } | |
2637 | |
4617 | 2638 od = gc->proto_data; |
2639 sess = od->sess; | |
3694 | 2640 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2641 tstconn->fd = source; |
3694 | 2642 |
2643 if (source < 0) { | |
2644 aim_conn_kill(sess, &tstconn); | |
8660 | 2645 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2646 "unable to connect to email server\n"); |
3694 | 2647 return; |
2648 } | |
2649 | |
2650 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2651 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2652 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2653 "email: connected\n"); |
3694 | 2654 } |
2655 | |
4804 | 2656 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2657 GaimConnection *gc = data; |
7283 | 2658 OscarData *od; |
4804 | 2659 aim_session_t *sess; |
2660 aim_conn_t *tstconn; | |
2661 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2662 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2663 close(source); |
2664 return; | |
2665 } | |
2666 | |
2667 od = gc->proto_data; | |
2668 sess = od->sess; | |
2669 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2670 tstconn->fd = source; | |
2671 | |
2672 if (source < 0) { | |
2673 aim_conn_kill(sess, &tstconn); | |
8660 | 2674 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2675 "unable to connect to icon server\n"); |
4804 | 2676 return; |
2677 } | |
2678 | |
2679 aim_conn_completeconnect(sess, tstconn); | |
2680 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2681 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2682 } |
2683 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2684 /* 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
|
2685 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2686 GaimConnection *gc = sess->aux_data; |
2687 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2688 aim_conn_t *tstconn; |
4452 | 2689 int i; |
2086 | 2690 char *host; |
2691 int port; | |
4821 | 2692 va_list ap; |
2693 struct aim_redirect_data *redir; | |
2086 | 2694 |
5575 | 2695 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2696 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2697 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2698 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2699 va_end(ap); |
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 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2702 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2703 port = atoi(&(redir->ip[i+1])); |
2086 | 2704 break; |
2705 } | |
2706 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2707 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2708 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2709 switch(redir->group) { |
2086 | 2710 case 0x7: /* Authorizer */ |
8660 | 2711 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2712 "Reconnecting with authorizor...\n"); |
2086 | 2713 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2714 if (tstconn == NULL) { | |
8660 | 2715 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2716 "unable to reconnect with authorizer\n"); |
2086 | 2717 g_free(host); |
2718 return 1; | |
2719 } | |
4649 | 2720 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2721 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2722 |
2723 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2724 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2725 aim_conn_kill(sess, &tstconn); |
8660 | 2726 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2727 "unable to reconnect with authorizer\n"); |
2086 | 2728 g_free(host); |
2729 return 1; | |
2730 } | |
4293 | 2731 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2732 break; |
2733 | |
2086 | 2734 case 0xd: /* ChatNav */ |
2735 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2736 if (tstconn == NULL) { | |
8660 | 2737 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2738 "unable to connect to chatnav server\n"); |
2086 | 2739 g_free(host); |
2740 return 1; | |
2741 } | |
4649 | 2742 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2743 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2744 |
2745 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2746 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2747 aim_conn_kill(sess, &tstconn); |
8660 | 2748 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2749 "unable to connect to chatnav server\n"); |
2086 | 2750 g_free(host); |
2751 return 1; | |
2752 } | |
4293 | 2753 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2754 break; |
2755 | |
2756 case 0xe: { /* Chat */ | |
2086 | 2757 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2758 |
2086 | 2759 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2760 if (tstconn == NULL) { | |
8660 | 2761 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2762 "unable to connect to chat server\n"); |
2086 | 2763 g_free(host); |
2764 return 1; | |
2765 } | |
2766 | |
4649 | 2767 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2768 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2769 | |
2086 | 2770 ccon = g_new0(struct chat_connection, 1); |
2771 ccon->conn = tstconn; | |
2772 ccon->gc = gc; | |
2773 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2774 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2775 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2776 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2777 ccon->show = extract_name(redir->chat.room); |
4634 | 2778 |
2086 | 2779 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2780 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2781 aim_conn_kill(sess, &tstconn); |
8660 | 2782 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2783 "unable to connect to chat server\n"); |
2086 | 2784 g_free(host); |
2785 g_free(ccon->show); | |
2786 g_free(ccon->name); | |
2787 g_free(ccon); | |
2788 return 1; | |
2789 } | |
4293 | 2790 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2791 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2792 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2793 ccon->name, ccon->exchange); |
4194 | 2794 } break; |
3694 | 2795 |
4804 | 2796 case 0x0010: { /* icon */ |
2797 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2798 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2799 "unable to connect to icon server\n"); |
4804 | 2800 g_free(host); |
2801 return 1; | |
2802 } | |
2803 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2804 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2805 | |
2806 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2807 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2808 aim_conn_kill(sess, &tstconn); |
8660 | 2809 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2810 "unable to connect to icon server\n"); |
4804 | 2811 g_free(host); |
2812 return 1; | |
2813 } | |
2814 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2815 } break; | |
2816 | |
3694 | 2817 case 0x0018: { /* email */ |
2818 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2819 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2820 "unable to connect to email server\n"); |
3694 | 2821 g_free(host); |
2822 return 1; | |
2823 } | |
4649 | 2824 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2825 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2826 | |
2827 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2828 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2829 aim_conn_kill(sess, &tstconn); |
8660 | 2830 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2831 "unable to connect to email server\n"); |
3694 | 2832 g_free(host); |
2833 return 1; | |
2834 } | |
4293 | 2835 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2836 } break; |
2837 | |
2086 | 2838 default: /* huh? */ |
8660 | 2839 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2840 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2841 redir->group); |
2086 | 2842 break; |
2843 } | |
2844 | |
2845 g_free(host); | |
2846 return 1; | |
2847 } | |
2848 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2849 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2850 GaimConnection *gc = sess->aux_data; |
9058 | 2851 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 2852 OscarData *od = gc->proto_data; |
4738 | 2853 struct buddyinfo *bi; |
2993 | 2854 time_t time_idle = 0, signon = 0; |
2855 int type = 0; | |
2856 int caps = 0; | |
2086 | 2857 va_list ap; |
4738 | 2858 aim_userinfo_t *info; |
4194 | 2859 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2860 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2861 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2862 va_end(ap); |
2863 | |
2993 | 2864 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2865 caps = info->capabilities; | |
3267 | 2866 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
2867 type |= UC_AB; | |
2868 | |
4766 | 2869 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2870 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
2871 type |= UC_UNCONFIRMED; | |
2872 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
2873 type |= UC_ADMIN; | |
2874 if (info->flags & AIM_FLAG_AOL) | |
2875 type |= UC_AOL; | |
2876 if (info->flags & AIM_FLAG_FREE) | |
2877 type |= UC_NORMAL; | |
2878 if (info->flags & AIM_FLAG_AWAY) | |
2879 type |= UC_UNAVAILABLE; | |
2880 if (info->flags & AIM_FLAG_WIRELESS) | |
2881 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2882 } |
2993 | 2883 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2884 type = (info->icqinfo.status << 16); |
3013 | 2885 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2886 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 2887 type |= UC_UNAVAILABLE; |
3013 | 2888 } |
2993 | 2889 } |
2890 | |
7141 | 2891 if (caps & AIM_CAPS_ICQ_DIRECT) |
2892 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2893 |
2894 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2895 time(&time_idle); |
2896 time_idle -= info->idletime*60; | |
9295 | 2897 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2898 } |
2899 | |
5836 | 2900 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2901 signon = info->onlinesince; | |
2902 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2903 signon = time(NULL) - info->sessionlen; |
2086 | 2904 |
5575 | 2905 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
2906 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2907 |
7261 | 2908 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
4738 | 2909 if (!bi) { |
2910 bi = g_new0(struct buddyinfo, 1); | |
7261 | 2911 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
4738 | 2912 } |
4739 | 2913 bi->typingnot = FALSE; |
2914 bi->ico_informed = FALSE; | |
6857 | 2915 bi->ipaddr = info->icqinfo.ipaddr; |
2916 | |
2917 /* Available message stuff */ | |
6292 | 2918 free(bi->availmsg); |
7011 | 2919 if (info->avail != NULL) |
8225 | 2920 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2921 else |
6292 | 2922 bi->availmsg = NULL; |
4732 | 2923 |
4804 | 2924 /* Server stored icon stuff */ |
4853 | 2925 if (info->iconcsumlen) { |
7125 | 2926 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2927 char *b16 = NULL, *filepath = NULL; |
7093 | 2928 GaimBuddy *b = NULL; |
4853 | 2929 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2930 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
4853 | 2931 b = gaim_find_buddy(gc->account, info->sn); |
7093 | 2932 /* |
2933 * If for some reason the checksum is valid, but cached file is not.. | |
2934 * we want to know. | |
2935 */ | |
7693 | 2936 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2937 if (filename != NULL) { |
2938 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2939 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2940 "icon_checksum"); | |
9801 | 2941 else { |
2942 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2943 filename, NULL); | |
2944 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2945 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2946 "icon_checksum"); | |
2947 g_free(filepath); | |
2948 } | |
7093 | 2949 } else |
2950 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2951 |
4853 | 2952 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2953 GSList *cur = od->requesticon; | |
2954 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2955 cur = cur->next; | |
2956 if (!cur) { | |
7475 | 2957 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
4853 | 2958 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2959 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2960 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2961 } |
2962 } | |
6053 | 2963 g_free(b16); |
4853 | 2964 } |
2965 | |
9058 | 2966 /* |
2967 * If we have info for ourselves, then update our local warning | |
2968 * level and set our official time of login. Is this necessary? | |
2969 * XXX - This needs to be changed some how. evil should not be | |
2970 * handled by the core at all? | |
2971 */ | |
2972 if (!aim_sncmp(info->sn, gaim_account_get_username(account))) { | |
2973 gc->evil = (info->warnlevel/10.0); | |
2974 gc->login_time_official = signon; | |
2975 } | |
2976 | |
9927 | 2977 serv_got_update(gc, info->sn, TRUE, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 2978 |
2979 return 1; | |
2980 } | |
2981 | |
8341 | 2982 static void gaim_check_comment(OscarData *od, const char *str) { |
2983 if ((str == NULL) || strcmp(str, ck)) | |
2984 aim_locate_setcaps(od->sess, caps_aim); | |
2985 else | |
2986 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2987 } | |
2988 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2989 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2990 GaimConnection *gc = sess->aux_data; |
7283 | 2991 OscarData *od = gc->proto_data; |
2086 | 2992 va_list ap; |
4739 | 2993 aim_userinfo_t *info; |
2086 | 2994 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2995 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2996 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2997 va_end(ap); |
2998 | |
9927 | 2999 serv_got_update(gc, info->sn, FALSE, 0, 0, 0, 0); |
2086 | 3000 |
7261 | 3001 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3002 |
2086 | 3003 return 1; |
3004 } | |
3005 | |
4617 | 3006 /* BBB */ |
3952 | 3007 /* |
4617 | 3008 * This is called after a remote AIM user has connected to us. We |
3009 * want to do some voodoo with the socket file descriptors, add a | |
3010 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3011 */ |
4656 | 3012 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3013 GaimConnection *gc = sess->aux_data; |
7283 | 3014 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3015 GaimXfer *xfer; |
5146 | 3016 struct aim_oft_info *oft_info; |
3630 | 3017 va_list ap; |
3018 aim_conn_t *conn, *listenerconn; | |
4656 | 3019 |
8660 | 3020 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3021 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3022 va_start(ap, fr); |
3023 conn = va_arg(ap, aim_conn_t *); | |
3024 listenerconn = va_arg(ap, aim_conn_t *); | |
3025 va_end(ap); | |
3026 | |
4617 | 3027 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3028 return 1; | |
3029 | |
5146 | 3030 if (!(oft_info = xfer->data)) |
4617 | 3031 return 1; |
3032 | |
3630 | 3033 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3034 gaim_input_remove(xfer->watcher); |
3630 | 3035 aim_conn_kill(sess, &listenerconn); |
3036 | |
5146 | 3037 oft_info->conn = conn; |
3038 xfer->fd = oft_info->conn->fd; | |
3039 | |
3040 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3041 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3042 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3043 |
3044 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3045 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3046 |
3047 return 0; | |
3048 } | |
3049 | |
3952 | 3050 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3051 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3052 * user in order to transfer a file. |
3952 | 3053 */ |
4617 | 3054 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
|
3055 GaimXfer *xfer; |
5146 | 3056 struct aim_oft_info *oft_info; |
4656 | 3057 |
8660 | 3058 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3059 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3060 if (!(xfer = data)) |
3061 return; | |
5146 | 3062 if (!(oft_info = xfer->data)) |
3630 | 3063 return; |
8446 | 3064 if (source < 0) { |
3065 gaim_xfer_cancel_remote(xfer); | |
4617 | 3066 return; |
8446 | 3067 } |
4617 | 3068 |
3069 xfer->fd = source; | |
5146 | 3070 oft_info->conn->fd = source; |
3071 | |
3072 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3073 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3074 |
3075 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3076 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3077 |
3078 return; | |
3630 | 3079 } |
3080 | |
3952 | 3081 /* |
4617 | 3082 * This is called when a buddy sends us some file info. This happens when they |
3083 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3084 * You should send them the exact same info except use the real cookie. We also |
4617 | 3085 * get like totally ready to like, receive the file, kay? |
3952 | 3086 */ |
4617 | 3087 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3088 GaimConnection *gc = sess->aux_data; |
7283 | 3089 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3090 GaimXfer *xfer; |
5146 | 3091 struct aim_oft_info *oft_info; |
4617 | 3092 va_list ap; |
3093 aim_conn_t *conn; | |
3094 fu8_t *cookie; | |
3095 struct aim_fileheader_t *fh; | |
4656 | 3096 |
8660 | 3097 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3098 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3099 va_start(ap, fr); |
3100 conn = va_arg(ap, aim_conn_t *); | |
3101 cookie = va_arg(ap, fu8_t *); | |
3102 fh = va_arg(ap, struct aim_fileheader_t *); | |
3103 va_end(ap); | |
3104 | |
3105 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3106 return 1; | |
3107 | |
5146 | 3108 if (!(oft_info = xfer->data)) |
4617 | 3109 return 1; |
3110 | |
3111 /* We want to stop listening with a normal thingy */ | |
3112 gaim_input_remove(xfer->watcher); | |
3113 xfer->watcher = 0; | |
3114 | |
5146 | 3115 /* They sent us some information about the file they're sending */ |
3116 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3117 | |
3118 /* Fill in the cookie */ | |
3119 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3120 | |
4617 | 3121 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3122 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3123 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3124 | |
3125 return 0; | |
3630 | 3126 } |
3127 | |
3952 | 3128 /* |
4657 | 3129 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3130 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3131 */ |
4617 | 3132 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3133 GaimConnection *gc = sess->aux_data; |
7283 | 3134 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3135 GaimXfer *xfer; |
4617 | 3136 va_list ap; |
3137 aim_conn_t *conn; | |
3138 fu8_t *cookie; | |
3139 struct aim_fileheader_t *fh; | |
4656 | 3140 |
8660 | 3141 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3142 va_start(ap, fr); |
3143 conn = va_arg(ap, aim_conn_t *); | |
3144 cookie = va_arg(ap, fu8_t *); | |
3145 fh = va_arg(ap, struct aim_fileheader_t *); | |
3146 va_end(ap); | |
3147 | |
3148 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3149 return 1; | |
3150 | |
4656 | 3151 /* We want to stop listening with a normal thingy */ |
3152 gaim_input_remove(xfer->watcher); | |
3153 xfer->watcher = 0; | |
3154 | |
4617 | 3155 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3156 | |
3157 return 0; | |
3630 | 3158 } |
4617 | 3159 |
3160 /* | |
3161 * We just sent a file to someone. They said they got it and everything, | |
3162 * so we can close our direct connection and what not. | |
3163 */ | |
3164 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3165 GaimConnection *gc = sess->aux_data; |
7283 | 3166 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3167 GaimXfer *xfer; |
4617 | 3168 va_list ap; |
3169 aim_conn_t *conn; | |
3170 fu8_t *cookie; | |
3171 struct aim_fileheader_t *fh; | |
4656 | 3172 |
8660 | 3173 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3174 va_start(ap, fr); |
3175 conn = va_arg(ap, aim_conn_t *); | |
3176 cookie = va_arg(ap, fu8_t *); | |
3177 fh = va_arg(ap, struct aim_fileheader_t *); | |
3178 va_end(ap); | |
3179 | |
3180 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3181 return 1; | |
3182 | |
4656 | 3183 xfer->fd = conn->fd; |
4617 | 3184 gaim_xfer_end(xfer); |
3185 | |
3186 return 0; | |
3187 } | |
3630 | 3188 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3189 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3190 GaimConnection *gc = sess->aux_data; |
7283 | 3191 OscarData *od = gc->proto_data; |
8708 | 3192 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3193 GaimConvImFlags flags = 0; |
4738 | 3194 struct buddyinfo *bi; |
5575 | 3195 const char *iconfile; |
9806 | 3196 GString *message; |
3197 gchar *tmp; | |
3198 aim_mpmsg_section_t *curpart; | |
3199 | |
3200 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3201 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3202 |
8708 | 3203 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3204 if (!bi) { |
3205 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3206 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3207 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3208 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3209 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3210 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3211 |
4738 | 3212 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3213 bi->typingnot = TRUE; | |
3214 else | |
3215 bi->typingnot = FALSE; | |
3216 | |
4380 | 3217 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3218 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3219 "%s has an icon\n", userinfo->sn); |
4738 | 3220 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3221 bi->ico_need = TRUE; | |
3222 bi->ico_len = args->iconlen; | |
3223 bi->ico_csum = args->iconsum; | |
3224 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3225 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3226 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3227 |
8708 | 3228 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3229 (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
|
3230 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3231 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3232 |
5575 | 3233 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3234 char *buf = g_malloc(st.st_size); |
5575 | 3235 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3236 if (file) { |
9532 | 3237 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3238 int len = fread(buf, 1, st.st_size, file); |
8660 | 3239 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3240 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3241 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3242 userinfo->sn, len, st.st_size); |
4617 | 3243 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3244 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3245 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3246 } else |
8660 | 3247 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3248 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3249 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3250 } else |
8660 | 3251 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3252 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3253 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3254 |
9806 | 3255 message = g_string_new(""); |
3256 curpart = args->mpmsg.parts; | |
3257 while (curpart != NULL) { | |
9908 | 3258 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3259 curpart->data, curpart->datalen); |
3260 if (tmp != NULL) { | |
3261 g_string_append(message, tmp); | |
3262 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3263 } |
9806 | 3264 |
3265 curpart = curpart->next; | |
3266 } | |
3267 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3268 |
8666 | 3269 /* |
8995 | 3270 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3271 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3272 * so any HTML we receive is intended to be displayed |
3273 * | |
3274 * Note: There *may* be some clients which send messages as HTML formatted - | |
3275 * they need to be special-cased somehow. | |
8666 | 3276 */ |
8995 | 3277 if (isdigit(gaim_account_get_username(account)[0]) && isdigit(userinfo->sn[0])) { |
3278 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ | |
3279 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3280 g_free(tmp); |
3281 tmp = tmp2; | |
3282 } | |
3283 | |
6982 | 3284 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3285 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3286 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3287 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3288 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3289 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3290 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3291 GaimConnection *gc; |
9933 | 3292 GaimAccount *account; |
9070 | 3293 OscarData *od; |
9933 | 3294 const char *username = NULL; |
3295 char *message = NULL; | |
9070 | 3296 |
3297 g_return_val_if_fail(sess != NULL, 0); | |
3298 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3299 | |
3300 gc = sess->aux_data; | |
9933 | 3301 account = gaim_connection_get_account(gc); |
9070 | 3302 od = gc->proto_data; |
9933 | 3303 username = gaim_account_get_username(account); |
3304 | |
3305 if (args == NULL) | |
4121 | 3306 return 0; |
4194 | 3307 |
9933 | 3308 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3309 userinfo->sn, args->status); | |
3310 | |
3311 if (args->msg != NULL) | |
3312 { | |
3313 if (args->encoding != NULL) | |
3314 { | |
3315 char *encoding = NULL; | |
3316 encoding = oscar_encoding_extract(args->encoding); | |
3317 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3318 g_free(encoding); | |
3319 } else { | |
3320 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3321 message = g_strdup(args->msg); | |
3322 } | |
3323 } | |
2869 | 3324 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3325 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3326 char *name; |
5234 | 3327 GHashTable *components; |
3328 | |
9933 | 3329 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3330 g_free(message); | |
4121 | 3331 return 1; |
9933 | 3332 } |
5234 | 3333 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3334 g_free); | |
4121 | 3335 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3336 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3337 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
|
3338 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3339 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3340 userinfo->sn, |
9933 | 3341 message, |
5234 | 3342 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3343 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3344 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3345 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3346 /* BBB */ |
3347 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3348 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3349 GaimXfer *xfer; |
5146 | 3350 struct aim_oft_info *oft_info; |
3351 | |
3352 if (!args->cookie || !args->port || !args->verifiedip || | |
3353 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3354 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3355 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3356 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3357 "information.\n", userinfo->sn); |
5146 | 3358 if (args->proxyip) |
8660 | 3359 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3360 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3361 "does not support this yet.\n"); |
9933 | 3362 g_free(message); |
4617 | 3363 return 1; |
4656 | 3364 } |
4617 | 3365 |
3366 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3367 /* 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
|
3368 * directory -- remove the star and trailing slash so we don't save |
4617 | 3369 * directories that look like 'dirname\*' -- arl */ |
3370 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3371 if (tmp && (tmp[1] == '*')) { | |
3372 tmp[0] = '\0'; | |
3373 } | |
8660 | 3374 gaim_debug_warning("oscar", |
8446 | 3375 "We're receiving a whole directory! What fun! " |
3376 "Especially since we don't support that!\n"); | |
4617 | 3377 } |
3378 | |
3379 /* Build the file transfer handle */ | |
3380 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3381 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3382 xfer->remote_port = args->port; |
4617 | 3383 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3384 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3385 gaim_xfer_set_message(xfer, message); |
5146 | 3386 |
3387 /* Create the oscar-specific data */ | |
5163 | 3388 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3389 if (args->proxyip) |
5146 | 3390 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3391 if (args->verifiedip) |
5146 | 3392 oft_info->verifiedip = g_strdup(args->verifiedip); |
3393 xfer->data = oft_info; | |
4617 | 3394 |
3395 /* Setup our I/O op functions */ | |
8446 | 3396 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3397 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3398 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
|
3399 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3400 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3401 |
3402 /* Keep track of this transfer for later */ | |
3403 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3404 | |
3405 /* Now perform the request */ | |
3406 gaim_xfer_request(xfer); | |
3407 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3408 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3409 GaimXfer *xfer; |
8660 | 3410 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3411 "AAA - File transfer canceled by remote user\n"); |
4617 | 3412 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
|
3413 gaim_xfer_cancel_remote(xfer); |
4617 | 3414 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3415 /* | |
3416 * This gets sent by the receiver of a file | |
3417 * as they connect directly to us. If we don't | |
3418 * get this, then maybe a third party connected | |
3419 * to us, and we shouldn't send them anything. | |
3420 */ | |
3421 } else { | |
8660 | 3422 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3423 "unknown rendezvous status!\n"); |
3630 | 3424 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3425 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3426 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3427 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3428 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3429 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3430 args->info.icon.length); |
6871 | 3431 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3432 /* 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
|
3433 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3434 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
|
3435 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3436 |
4212 | 3437 if (!args->verifiedip) { |
8983 | 3438 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3439 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3440 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3441 g_free(message); |
4650 | 3442 return 1; |
4212 | 3443 } |
3444 | |
8660 | 3445 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3446 "%s received direct im request from %s (%s)\n", |
8983 | 3447 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3448 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3449 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3450 d->sn = g_strdup(userinfo->sn); |
8983 | 3451 /* Let's use the clientip here, because I think that's what AIM does. |
3452 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3453 * and then ask them to connect to us. */ | |
3454 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
|
3455 memcpy(d->cookie, args->cookie, 8); |
9070 | 3456 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3457 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3458 | |
8971 | 3459 oscar_direct_im_destroy(od, dim); |
8984 | 3460 d->donttryagain = TRUE; |
8971 | 3461 accept_direct_im_request(d); |
3462 } else { | |
8983 | 3463 if (dim && !dim->connected) |
8971 | 3464 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3465 "already connected to that buddy!"); | |
5575 | 3466 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
|
3467 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3468 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3469 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3470 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3471 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3472 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3473 "risk."), 0, d, 2, |
8971 | 3474 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3475 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3476 /* FIXME: we should actually send a packet on cancel */ | |
3477 } | |
8708 | 3478 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3479 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
|
3480 } else { |
8660 | 3481 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3482 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3483 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3484 |
9933 | 3485 g_free(message); |
3486 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3487 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3488 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3489 |
3453 | 3490 /* |
4230 | 3491 * Authorization Functions |
3492 * Most of these are callbacks from dialogs. They're used by both | |
3493 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3494 */ |
4269 | 3495 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3496 static void gaim_auth_request(struct name_data *data, char *msg) { |
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)) { |
7283 | 3500 OscarData *od = gc->proto_data; |
6695 | 3501 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3502 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3503 if (buddy && group) { |
8660 | 3504 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3505 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3506 buddy->name, group->name); |
4889 | 3507 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3508 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3509 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3510 } |
4230 | 3511 } |
4337 | 3512 } |
3513 | |
3514 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3515 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3516 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3517 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3518 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3519 data); |
4230 | 3520 } |
3521 | |
3522 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3523 GaimConnection *gc = data->gc; |
4244 | 3524 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3525 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3526 /* Remove from local list */ |
3527 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3528 gaim_blist_remove_buddy(b); | |
4244 | 3529 } |
3530 | |
5836 | 3531 oscar_free_name_data(data); |
4230 | 3532 } |
3533 | |
9030 | 3534 |
3535 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3536 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3537 GaimBuddy *buddy; |
4269 | 3538 gchar *dialog_msg, *nombre; |
3539 | |
4687 | 3540 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3541 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3542 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3543 else |
4830 | 3544 nombre = NULL; |
3545 | |
3546 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 | 3547 data->gc = gc; |
3548 data->name = g_strdup(name); | |
3549 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3550 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3551 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3552 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3553 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3554 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3555 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3556 |
3557 g_free(dialog_msg); | |
3558 g_free(nombre); | |
3559 } | |
3560 | |
9030 | 3561 |
3562 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3563 GaimBuddy *buddy; | |
3564 GaimConnection *gc; | |
3565 | |
3566 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3567 | |
3568 buddy = (GaimBuddy *) node; | |
3569 gc = gaim_account_get_connection(buddy->account); | |
3570 gaim_auth_sendrequest(gc, buddy->name); | |
3571 } | |
3572 | |
4230 | 3573 /* When other people ask you for authorization */ |
3574 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3575 GaimConnection *gc = data->gc; |
4244 | 3576 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3577 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3578 OscarData *od = gc->proto_data; |
4236 | 3579 #ifdef NOSSI |
6695 | 3580 GaimBuddy *buddy; |
4244 | 3581 gchar message; |
3582 message = 0; | |
4687 | 3583 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3584 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3585 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3586 #else |
4889 | 3587 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3588 #endif |
4244 | 3589 } |
3590 | |
5836 | 3591 oscar_free_name_data(data); |
3141 | 3592 } |
3593 | |
4230 | 3594 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3595 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3596 GaimConnection *gc = data->gc; |
4244 | 3597 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3598 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3599 OscarData *od = gc->proto_data; |
4230 | 3600 #ifdef NOSSI |
4617 | 3601 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3602 #else |
4889 | 3603 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3604 #endif |
4244 | 3605 } |
4337 | 3606 } |
3607 | |
3608 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3609 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3610 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3611 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3612 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3613 data); |
3141 | 3614 } |
3615 | |
7023 | 3616 /* When someone sends you buddies */ |
3617 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3618 GaimConnection *gc = data->gc; |
4244 | 3619 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3620 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3621 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3622 } |
3623 | |
5836 | 3624 oscar_free_name_data(data); |
3453 | 3625 } |
3626 | |
4075 | 3627 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 | 3628 GaimConnection *gc = sess->aux_data; |
9908 | 3629 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3630 gchar **msg1, **msg2; |
6051 | 3631 int i, numtoks; |
4076 | 3632 |
4121 | 3633 if (!args->type || !args->msg || !args->uin) |
3634 return 1; | |
4194 | 3635 |
8660 | 3636 gaim_debug_info("oscar", |
9908 | 3637 "Received a channel 4 message of type 0x%02hhx.\n", |
3638 args->type); | |
4076 | 3639 |
9919 | 3640 /* |
3641 * Split up the message at the delimeter character, then convert each | |
3642 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3643 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3644 * character in whatever encoding the message was sent in. Type 1 | |
3645 * messages are always made up of only one part, so we can easily account | |
3646 * for this suck-ass part of the protocol by splitting the string into at | |
3647 * most 1 baby string. | |
3648 */ | |
3649 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3650 for (numtoks=0; msg1[numtoks]; numtoks++); |
3651 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3652 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3653 gaim_str_strip_cr(msg1[i]); |
9908 | 3654 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3655 } |
3656 msg2[i] = NULL; | |
3657 | |
3952 | 3658 switch (args->type) { |
4173 | 3659 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3660 if (i >= 1) { |
5556 | 3661 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3662 gchar *tmp; |
3663 | |
3664 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3665 tmp = gaim_escape_html(msg2[0]); |
8493 | 3666 |
4076 | 3667 if (t) { /* This is an offline message */ |
9680 | 3668 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3669 #ifdef HAVE_TM_GMTOFF |
9724 | 3670 time_t now; |
3671 struct tm *tm; | |
3672 now = time(NULL); | |
3673 tm = localtime(&now); | |
3674 t += tm->tm_gmtoff; | |
9698 | 3675 #else |
3676 # ifdef HAVE_TIMEZONE | |
9680 | 3677 tzset(); |
3678 t -= timezone; | |
9698 | 3679 # endif |
3680 #endif | |
8514 | 3681 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3682 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3683 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3684 } |
3685 g_free(uin); | |
8493 | 3686 g_free(tmp); |
4075 | 3687 } |
3316 | 3688 } break; |
3689 | |
4173 | 3690 case 0x04: { /* Someone sent you a URL */ |
4076 | 3691 if (i >= 2) { |
7385 | 3692 if (msg2[1] != NULL) { |
3693 gchar *uin = g_strdup_printf("%u", args->uin); | |
3694 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3695 msg2[1], | |
3696 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3697 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3698 g_free(uin); | |
3699 g_free(message); | |
3700 } | |
3453 | 3701 } |
3702 } break; | |
3703 | |
4173 | 3704 case 0x06: { /* Someone requested authorization */ |
4076 | 3705 if (i >= 6) { |
4230 | 3706 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3707 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 | 3708 gaim_debug_info("oscar", |
5556 | 3709 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3710 args->uin); |
4076 | 3711 data->gc = gc; |
5556 | 3712 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3713 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3714 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3715 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3716 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3717 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3718 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3719 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3720 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3721 g_free(dialog_msg); |
3722 } | |
3141 | 3723 } break; |
3724 | |
4173 | 3725 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3726 if (i >= 1) { |
7023 | 3727 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
|
3728 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3729 dialog_msg); |
4076 | 3730 g_free(dialog_msg); |
3731 } | |
3141 | 3732 } break; |
3733 | |
4173 | 3734 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3735 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
|
3736 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3737 dialog_msg); |
3141 | 3738 g_free(dialog_msg); |
3739 } break; | |
3740 | |
4333 | 3741 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3742 if (i >= 5) { | |
3743 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
|
3744 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3745 g_free(dialog_msg); |
3746 } | |
3747 } break; | |
3748 | |
4173 | 3749 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3750 if (i >= 6) { |
4194 | 3751 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
|
3752 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3753 g_free(dialog_msg); |
3754 } | |
4075 | 3755 } break; |
3756 | |
4173 | 3757 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3758 if (i >= 6) { |
4308 | 3759 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
|
3760 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3761 g_free(dialog_msg); |
3762 } | |
4075 | 3763 } break; |
3764 | |
4173 | 3765 case 0x12: { |
3141 | 3766 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3767 /* Someone added you to their buddy list? */ |
3141 | 3768 } break; |
3769 | |
7023 | 3770 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3771 guint i, num; |
3453 | 3772 gchar **text; |
4173 | 3773 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3774 if (text) { |
3775 num = 0; | |
3776 for (i=0; i<strlen(text[0]); i++) | |
3777 num = num*10 + text[0][i]-48; | |
3778 for (i=0; i<num; i++) { | |
4230 | 3779 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3780 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 | 3781 data->gc = gc; |
4790 | 3782 data->name = g_strdup(text[i*2+1]); |
3783 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3784 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3785 gaim_request_action(gc, NULL, message, |
7023 | 3786 _("Do you want to add this buddy " |
3787 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3788 0, data, 2, |
7023 | 3789 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3790 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3791 g_free(message); |
3792 } | |
3793 g_strfreev(text); | |
3794 } | |
3795 } break; | |
3796 | |
7023 | 3797 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3798 /* This is boring and silly. */ |
3799 } break; | |
3800 | |
3141 | 3801 default: { |
8660 | 3802 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3803 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3804 "(type 0x%02hhx).\n", args->type); |
3141 | 3805 } break; |
3806 } | |
3807 | |
4076 | 3808 g_strfreev(msg1); |
3809 g_strfreev(msg2); | |
3810 | |
3141 | 3811 return 1; |
3812 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3813 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3814 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3815 fu16_t channel; |
3816 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3817 aim_userinfo_t *userinfo; |
2086 | 3818 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3819 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3820 va_start(ap, fr); |
4200 | 3821 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3822 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3823 |
3141 | 3824 switch (channel) { |
3825 case 1: { /* standard message */ | |
3826 struct aim_incomingim_ch1_args *args; | |
3827 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3828 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3829 } break; | |
3830 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3831 case 2: { /* rendezvous */ |
3141 | 3832 struct aim_incomingim_ch2_args *args; |
3833 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3834 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3835 } break; | |
3836 | |
3837 case 4: { /* ICQ */ | |
3838 struct aim_incomingim_ch4_args *args; | |
3839 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3840 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3841 } break; |
3842 | |
3843 default: { | |
8660 | 3844 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3845 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3846 "0x%04hx).", channel); |
3141 | 3847 } break; |
2086 | 3848 } |
3849 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3850 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3851 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3852 return ret; |
2086 | 3853 } |
3854 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3855 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3856 GaimConnection *gc = sess->aux_data; |
3857 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3858 char *buf; |
2086 | 3859 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3860 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3861 aim_userinfo_t *userinfo; |
2086 | 3862 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3863 va_start(ap, fr); |
4200 | 3864 chan = (fu16_t)va_arg(ap, unsigned int); |
3865 userinfo = va_arg(ap, aim_userinfo_t *); | |
3866 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3867 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3868 va_end(ap); |
3869 | |
3870 switch(reason) { | |
5420 | 3871 case 0: /* Invalid (0) */ |
3872 buf = g_strdup_printf( | |
3873 ngettext( | |
4276 | 3874 "You missed %hu message from %s because it was invalid.", |
3875 "You missed %hu messages from %s because they were invalid.", | |
3876 nummissed), | |
4282 | 3877 nummissed, |
3878 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3879 break; |
5420 | 3880 case 1: /* Message too large */ |
3881 buf = g_strdup_printf( | |
3882 ngettext( | |
4276 | 3883 "You missed %hu message from %s because it was too large.", |
3884 "You missed %hu messages from %s because they were too large.", | |
3885 nummissed), | |
4282 | 3886 nummissed, |
3887 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3888 break; |
5420 | 3889 case 2: /* Rate exceeded */ |
3890 buf = g_strdup_printf( | |
3891 ngettext( | |
4276 | 3892 "You missed %hu message from %s because the rate limit has been exceeded.", |
3893 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3894 nummissed), | |
4282 | 3895 nummissed, |
3896 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3897 break; |
5420 | 3898 case 3: /* Evil Sender */ |
3899 buf = g_strdup_printf( | |
3900 ngettext( | |
4276 | 3901 "You missed %hu message from %s because he/she was too evil.", |
3902 "You missed %hu messages from %s because he/she was too evil.", | |
3903 nummissed), | |
4282 | 3904 nummissed, |
3905 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3906 break; |
5420 | 3907 case 4: /* Evil Receiver */ |
3908 buf = g_strdup_printf( | |
3909 ngettext( | |
4276 | 3910 "You missed %hu message from %s because you are too evil.", |
3911 "You missed %hu messages from %s because you are too evil.", | |
3912 nummissed), | |
4282 | 3913 nummissed, |
3914 userinfo->sn); | |
2086 | 3915 break; |
3916 default: | |
5420 | 3917 buf = g_strdup_printf( |
3918 ngettext( | |
4276 | 3919 "You missed %hu message from %s for an unknown reason.", |
3920 "You missed %hu messages from %s for an unknown reason.", | |
3921 nummissed), | |
4282 | 3922 nummissed, |
3923 userinfo->sn); | |
2086 | 3924 break; |
3925 } | |
8733 | 3926 |
9627 | 3927 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3928 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3929 g_free(buf); |
2086 | 3930 |
3931 return 1; | |
3932 } | |
3933 | |
4194 | 3934 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3935 GaimConnection *gc = sess->aux_data; |
7283 | 3936 OscarData *od = gc->proto_data; |
4617 | 3937 |
3938 /* BBB */ | |
3630 | 3939 switch (reason) { |
4151 | 3940 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3941 GaimXfer *xfer; |
8971 | 3942 struct oscar_direct_im *dim; |
3943 | |
8660 | 3944 gaim_debug_info("oscar", |
9070 | 3945 "AAA - Other user declined some sort of direct " |
8971 | 3946 "connect attempt (automaticly?)\n"); |
4617 | 3947 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
|
3948 gaim_xfer_cancel_remote(xfer); |
8971 | 3949 else if ((dim = oscar_direct_im_find(od, who))) { |
3950 /* AAA should use find by cookie or something here */ | |
3951 oscar_direct_im_disconnect(od, dim); | |
3952 } | |
4151 | 3953 } break; |
3954 | |
3955 default: { | |
8660 | 3956 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3957 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3958 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3959 } |
3630 | 3960 |
3961 } | |
3962 | |
3963 return 0; | |
3964 } | |
3965 | |
4194 | 3966 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3967 GaimConnection *gc = sess->aux_data; |
4151 | 3968 |
3969 switch(reason) { | |
3970 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3971 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3972 | |
3973 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3974 |
3975 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3976 statusmsg = oscar_icqstatus(state); |
4151 | 3977 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3978 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3979 g_free(statusmsg); | |
4151 | 3980 g_strfreev(splitmsg); |
9244 | 3981 |
9797 | 3982 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 3983 |
3984 g_free(title); | |
3985 g_free(dialogmsg); | |
4151 | 3986 } break; |
3987 | |
3988 default: { | |
8660 | 3989 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3990 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3991 "Type 0x%04hx\n", who, reason); |
4151 | 3992 } break; |
3993 } /* end of switch */ | |
3994 | |
3995 return 0; | |
3996 } | |
3997 | |
3212 | 3998 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
3999 va_list ap; | |
4000 fu16_t chan, reason; | |
4001 char *who; | |
4002 | |
4003 va_start(ap, fr); | |
4200 | 4004 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4005 who = va_arg(ap, char *); |
4200 | 4006 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4007 |
3952 | 4008 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4009 char *cookie = va_arg(ap, char *); |
4151 | 4010 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4011 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4012 fu32_t state = 0; |
4151 | 4013 char *msg = NULL; |
4014 if (reason == 0x0003) { | |
4200 | 4015 state = va_arg(ap, fu32_t); |
4151 | 4016 msg = va_arg(ap, char *); |
4017 } | |
4018 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4019 } | |
3952 | 4020 |
3212 | 4021 va_end(ap); |
4022 | |
4023 return 1; | |
4024 } | |
4025 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4026 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4027 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4028 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4029 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4030 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4031 va_start(ap, fr); |
4199 | 4032 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4033 va_end(ap); |
4034 | |
8660 | 4035 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4036 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4037 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4038 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4039 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4040 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4041 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4042 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4043 |
2086 | 4044 return 1; |
4045 } | |
4046 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4047 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4048 GaimConnection *gc = sess->aux_data; |
4617 | 4049 #if 0 |
7283 | 4050 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4051 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4052 #endif |
4617 | 4053 va_list ap; |
4054 fu16_t reason; | |
4055 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4056 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4057 va_start(ap, fr); |
4617 | 4058 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4059 data = va_arg(ap, char *); |
2086 | 4060 va_end(ap); |
4061 | |
8660 | 4062 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4063 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 4064 |
4065 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4066 #if 0 |
4617 | 4067 /* If this was a file transfer request, data is a cookie */ |
4068 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
|
4069 gaim_xfer_cancel_remote(xfer); |
3630 | 4070 return 1; |
4071 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4072 #endif |
3630 | 4073 |
4617 | 4074 /* Data is assumed to be the destination sn */ |
9826 | 4075 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4076 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4077 g_free(buf); | |
4078 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4079 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4080 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4081 } | |
4082 g_free(buf); | |
4083 | |
2086 | 4084 return 1; |
4085 } | |
4086 | |
3595 | 4087 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4088 GaimConnection *gc = sess->aux_data; |
3595 | 4089 va_list ap; |
4090 fu16_t type1, type2; | |
4091 char *sn; | |
4092 | |
4093 va_start(ap, fr); | |
4199 | 4094 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4095 sn = va_arg(ap, char *); |
4199 | 4096 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4097 va_end(ap); |
4098 | |
4099 switch (type2) { | |
4100 case 0x0000: { /* Text has been cleared */ | |
4101 serv_got_typing_stopped(gc, sn); | |
4102 } break; | |
4103 | |
4104 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4105 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4106 } break; |
4107 | |
4108 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4109 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4110 } break; |
4111 | |
4112 default: { | |
8660 | 4113 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 | 4114 } break; |
4115 } | |
4116 | |
4117 return 1; | |
4118 } | |
4119 | |
7141 | 4120 /* |
4121 * We get this error when there was an error in the locate family. This | |
7259 | 4122 * happens when you request info of someone who is offline. |
7141 | 4123 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4124 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4125 gchar *buf; |
2086 | 4126 va_list ap; |
5420 | 4127 fu16_t reason; |
2086 | 4128 char *destn; |
4129 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4130 va_start(ap, fr); |
4199 | 4131 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4132 destn = va_arg(ap, char *); |
4133 va_end(ap); | |
4134 | |
7781 | 4135 if (destn == NULL) |
7793 | 4136 return 1; |
9627 | 4137 |
9826 | 4138 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4139 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4140 g_free(buf); | |
9627 | 4141 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4142 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4143 } | |
4144 g_free(buf); | |
2086 | 4145 |
4146 return 1; | |
4147 } | |
4148 | |
7011 | 4149 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4150 GaimConnection *gc = sess->aux_data; |
8700 | 4151 GaimAccount *account = gaim_connection_get_account(gc); |
4152 GString *str; | |
9244 | 4153 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4154 va_list ap; |
7011 | 4155 aim_userinfo_t *userinfo; |
2086 | 4156 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4157 va_start(ap, fr); |
7011 | 4158 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4159 va_end(ap); |
4160 | |
8700 | 4161 str = g_string_new(""); |
4162 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4163 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4164 |
4165 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 4166 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 4167 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 4168 |
4169 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 4170 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 4171 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 4172 |
4173 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4174 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4175 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4176 g_free(tmp); |
4177 } | |
4178 | |
8701 | 4179 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4180 |
4181 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4182 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4183 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4184 g_free(tmp); | |
7011 | 4185 if (away_utf8 != NULL) { |
8700 | 4186 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4187 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4188 } |
7011 | 4189 } |
4190 | |
4191 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4192 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4193 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4194 g_free(tmp); | |
7011 | 4195 if (info_utf8 != NULL) { |
8700 | 4196 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4197 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4198 } |
7011 | 4199 } |
4200 | |
8701 | 4201 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4202 g_string_free(str, TRUE); |
9244 | 4203 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4204 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4205 g_free(title); |
8700 | 4206 g_free(tmp); |
4151 | 4207 |
2086 | 4208 return 1; |
4209 } | |
4210 | |
8341 | 4211 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4212 { | |
4213 aim_session_t *sess = data; | |
4214 GaimConnection *gc = sess->aux_data; | |
4215 OscarData *od = (OscarData *)gc->proto_data; | |
4216 | |
4217 aim_locate_dorequest(data); | |
4218 od->getinfotimer = 0; | |
4219 | |
4220 return FALSE; | |
4221 } | |
4222 | |
4223 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4224 { | |
4225 GaimConnection *gc = sess->aux_data; | |
4226 OscarData *od = (OscarData *)gc->proto_data; | |
4227 | |
4228 /* | |
4229 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4230 * us from hitting the rate limit due to request away messages and info | |
4231 * too quickly. | |
4232 */ | |
4233 if (od->getinfotimer == 0) | |
4234 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4235 | |
4236 return 1; | |
4237 } | |
4238 | |
4239 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4240 { | |
2086 | 4241 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4242 fu16_t id; |
2086 | 4243 va_list ap; |
4244 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4245 va_start(ap, fr); |
4199 | 4246 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4247 msg = va_arg(ap, char *); |
4248 va_end(ap); | |
4249 | |
8660 | 4250 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4251 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4252 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4253 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4254 _("Your AIM connection may be lost."), NULL); |
2086 | 4255 |
4256 return 1; | |
4257 } | |
4258 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4259 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4260 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4261 fu16_t type; |
5575 | 4262 GaimConnection *gc = sess->aux_data; |
7283 | 4263 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4264 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4265 va_start(ap, fr); |
4199 | 4266 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4267 |
4268 switch(type) { | |
4269 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4270 fu8_t maxrooms; |
2086 | 4271 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4272 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4273 |
4199 | 4274 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4275 exchangecount = va_arg(ap, int); |
4276 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4277 | |
8660 | 4278 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4279 "chat info: Chat Rights:\n"); |
8660 | 4280 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4281 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4282 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4283 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4284 for (i = 0; i < exchangecount; i++) |
8660 | 4285 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4286 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4287 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4288 while (od->create_rooms) { |
4289 struct create_room *cr = od->create_rooms->data; | |
8660 | 4290 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4291 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4292 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4293 g_free(cr->name); |
4617 | 4294 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4295 g_free(cr); |
2086 | 4296 } |
4297 } | |
4298 break; | |
4299 case 0x0008: { | |
4300 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4301 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4302 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4303 fu32_t createtime; |
2086 | 4304 |
4305 fqcn = va_arg(ap, char *); | |
4200 | 4306 instance = (fu16_t)va_arg(ap, unsigned int); |
4307 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4308 flags = (fu16_t)va_arg(ap, unsigned int); | |
4309 createtime = va_arg(ap, fu32_t); | |
4310 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4311 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4312 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4313 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4314 name = va_arg(ap, char *); | |
4315 ck = va_arg(ap, char *); | |
4194 | 4316 |
8660 | 4317 gaim_debug_misc("oscar", |
5556 | 4318 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4319 fqcn, |
4320 exchange, instance, flags, | |
4321 createtime, | |
4322 maxmsglen, maxoccupancy, createperms, unknown, | |
4323 name, ck); | |
4617 | 4324 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4325 } |
4326 break; | |
4327 default: | |
8660 | 4328 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4329 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4330 break; |
4331 } | |
4194 | 4332 |
4333 va_end(ap); | |
4334 | |
2086 | 4335 return 1; |
4336 } | |
4337 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4338 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4339 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4340 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4341 aim_userinfo_t *info; |
5575 | 4342 GaimConnection *g = sess->aux_data; |
2086 | 4343 |
4344 struct chat_connection *c = NULL; | |
4345 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4346 va_start(ap, fr); |
2086 | 4347 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4348 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4349 va_end(ap); |
4350 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4351 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4352 if (!c) |
4353 return 1; | |
4354 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4355 for (i = 0; i < count; i++) |
9846 | 4356 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4357 |
4358 return 1; | |
4359 } | |
4360 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4361 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4362 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4363 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4364 aim_userinfo_t *info; |
5575 | 4365 GaimConnection *g = sess->aux_data; |
2086 | 4366 |
4367 struct chat_connection *c = NULL; | |
4368 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4369 va_start(ap, fr); |
2086 | 4370 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4371 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4372 va_end(ap); |
4373 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4374 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4375 if (!c) |
4376 return 1; | |
4377 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4378 for (i = 0; i < count; i++) |
8733 | 4379 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4380 |
4381 return 1; | |
4382 } | |
4383 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4384 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
|
4385 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4386 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4387 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4388 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4389 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4390 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4391 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4392 fu32_t creationtime; |
5575 | 4393 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4394 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
|
4395 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4396 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4397 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4398 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4399 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4400 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4401 roomdesc = va_arg(ap, char *); |
4200 | 4402 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4403 creationtime = va_arg(ap, fu32_t); | |
4404 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4405 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4406 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4407 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4408 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4409 |
8660 | 4410 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4411 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4412 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4413 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4414 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4415 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4416 |
2086 | 4417 return 1; |
4418 } | |
4419 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4420 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4421 GaimConnection *gc = sess->aux_data; |
8225 | 4422 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4423 gchar *utf8; | |
2086 | 4424 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4425 aim_userinfo_t *info; |
8225 | 4426 int len; |
2086 | 4427 char *msg; |
8219 | 4428 char *charset; |
2086 | 4429 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4430 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4431 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4432 len = va_arg(ap, int); |
4194 | 4433 msg = va_arg(ap, char *); |
8219 | 4434 charset = va_arg(ap, char *); |
4194 | 4435 va_end(ap); |
2086 | 4436 |
8225 | 4437 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4438 if (utf8 == NULL) |
4439 /* The conversion failed! */ | |
8668 | 4440 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4441 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4442 g_free(utf8); | |
2086 | 4443 |
4444 return 1; | |
4445 } | |
4446 | |
3694 | 4447 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4448 va_list ap; | |
5575 | 4449 GaimConnection *gc = sess->aux_data; |
3694 | 4450 struct aim_emailinfo *emailinfo; |
3725 | 4451 int havenewmail; |
7297 | 4452 char *alertitle, *alerturl; |
3694 | 4453 |
4454 va_start(ap, fr); | |
4455 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4456 havenewmail = va_arg(ap, int); |
7301 | 4457 alertitle = va_arg(ap, char *); |
4458 alerturl = va_arg(ap, char *); | |
3694 | 4459 va_end(ap); |
4460 | |
9661 | 4461 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4462 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4463 emailinfo->domain ? "@" : "", | |
4464 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4465 if (emailinfo->unread && havenewmail) |
4466 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4467 g_free(to); |
3694 | 4468 } |
7297 | 4469 |
7301 | 4470 if (alertitle) |
8660 | 4471 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4472 |
4473 return 1; | |
4474 } | |
4475 | |
4804 | 4476 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4477 GaimConnection *gc = sess->aux_data; |
7283 | 4478 OscarData *od = gc->proto_data; |
4804 | 4479 char *sn; |
4480 | |
4481 sn = od->requesticon->data; | |
8660 | 4482 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4483 "removing %s from hash table\n", sn); |
4804 | 4484 od->requesticon = g_slist_remove(od->requesticon, sn); |
4485 free(sn); | |
4486 | |
4487 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4488 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4489 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4490 |
4491 return 1; | |
4492 } | |
4493 | |
4494 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4495 GaimConnection *gc = sess->aux_data; |
7283 | 4496 OscarData *od = gc->proto_data; |
4804 | 4497 GSList *cur; |
4498 va_list ap; | |
4499 char *sn; | |
4853 | 4500 fu8_t *iconcsum, *icon; |
4501 fu16_t iconcsumlen, iconlen; | |
4804 | 4502 |
4503 va_start(ap, fr); | |
4504 sn = va_arg(ap, char *); | |
4853 | 4505 iconcsum = va_arg(ap, fu8_t *); |
4506 iconcsumlen = va_arg(ap, int); | |
4804 | 4507 icon = va_arg(ap, fu8_t *); |
4508 iconlen = va_arg(ap, int); | |
4509 va_end(ap); | |
4510 | |
4853 | 4511 if (iconlen > 0) { |
4512 char *b16; | |
6695 | 4513 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4514 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4515 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4516 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4517 if (b16) { |
7693 | 4518 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4519 g_free(b16); |
5129 | 4520 } |
4853 | 4521 } |
4804 | 4522 |
4523 cur = od->requesticon; | |
4524 while (cur) { | |
4525 char *cursn = cur->data; | |
4526 if (!aim_sncmp(cursn, sn)) { | |
4527 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4528 free(cursn); | |
4529 cur = od->requesticon; | |
4530 } else | |
4531 cur = cur->next; | |
4532 } | |
4533 | |
4534 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4535 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4536 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4537 |
4538 return 1; | |
4539 } | |
4540 | |
4541 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4542 GaimConnection *gc = data; |
7283 | 4543 OscarData *od = gc->proto_data; |
7011 | 4544 aim_userinfo_t *userinfo; |
4804 | 4545 aim_conn_t *conn; |
4546 | |
4547 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4548 if (!conn) { |
4549 if (!od->iconconnecting) { | |
4550 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4551 od->iconconnecting = TRUE; | |
4552 } | |
4804 | 4553 return FALSE; |
4554 } | |
4555 | |
5842 | 4556 if (od->set_icon) { |
6039 | 4557 struct stat st; |
4558 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4559 if (iconfile == NULL) { | |
8363 | 4560 aim_ssi_delicon(od->sess); |
6039 | 4561 } else if (!stat(iconfile, &st)) { |
4562 char *buf = g_malloc(st.st_size); | |
4563 FILE *file = fopen(iconfile, "rb"); | |
4564 if (file) { | |
9532 | 4565 /* XXX - Use g_file_get_contents()? */ |
6039 | 4566 fread(buf, 1, st.st_size, file); |
4567 fclose(file); | |
8660 | 4568 gaim_debug_info("oscar", |
6039 | 4569 "Uploading icon to icon server\n"); |
6879 | 4570 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4571 } else |
8660 | 4572 gaim_debug_error("oscar", |
6039 | 4573 "Can't open buddy icon file!\n"); |
4574 g_free(buf); | |
4575 } else { | |
8660 | 4576 gaim_debug_error("oscar", |
6039 | 4577 "Can't stat buddy icon file!\n"); |
5842 | 4578 } |
4579 od->set_icon = FALSE; | |
4580 } | |
4581 | |
4582 if (!od->requesticon) { | |
8660 | 4583 gaim_debug_misc("oscar", |
5842 | 4584 "no more icons to request\n"); |
4585 return FALSE; | |
4586 } | |
4587 | |
7045 | 4588 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4589 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4590 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4591 return FALSE; |
4592 } else { | |
4593 char *sn = od->requesticon->data; | |
4594 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4595 free(sn); | |
4596 } | |
4597 | |
4598 return TRUE; | |
4599 } | |
4600 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4601 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4602 * 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
|
4603 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4604 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4605 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4606 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4607 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4608 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4609 va_start(ap, fr); |
4199 | 4610 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4611 sn = va_arg(ap, char *); |
4612 va_end(ap); | |
4613 | |
8660 | 4614 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4615 |
4616 return 1; | |
4617 } | |
4618 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4619 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
|
4620 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4621 "invalid", |
4194 | 4622 "change", |
4623 "warning", | |
4624 "limit", | |
4625 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4626 }; |
2086 | 4627 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4628 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4629 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4630 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4631 va_start(ap, fr); |
4200 | 4632 code = (fu16_t)va_arg(ap, unsigned int); |
4633 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4634 windowsize = va_arg(ap, fu32_t); | |
4635 clear = va_arg(ap, fu32_t); | |
4636 alert = va_arg(ap, fu32_t); | |
4637 limit = va_arg(ap, fu32_t); | |
4638 disconnect = va_arg(ap, fu32_t); | |
4639 currentavg = va_arg(ap, fu32_t); | |
4640 maxavg = va_arg(ap, fu32_t); | |
2086 | 4641 va_end(ap); |
4642 | |
8660 | 4643 gaim_debug_misc("oscar", |
5556 | 4644 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4645 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4646 (code < 5) ? codes[code] : codes[0], |
4647 rateclass, | |
4648 currentavg, maxavg, | |
4649 alert, clear, | |
4650 limit, disconnect, | |
4651 windowsize); | |
4652 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4653 /* XXX fix these values */ |
2086 | 4654 if (code == AIM_RATE_CODE_CHANGE) { |
4655 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4656 aim_conn_setlatency(fr->conn, 0); |
2086 | 4657 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4658 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4659 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4660 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4661 _("The last action you attempted could not be " |
4662 "performed because you are over the rate limit. " | |
4663 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4664 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4665 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4666 aim_conn_setlatency(fr->conn, 0); |
2086 | 4667 } |
4668 | |
4669 return 1; | |
4670 } | |
4671 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4672 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4673 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4674 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4675 aim_userinfo_t *userinfo; |
5575 | 4676 GaimConnection *gc = sess->aux_data; |
2086 | 4677 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4678 va_start(ap, fr); |
4199 | 4679 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4680 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4681 va_end(ap); |
4682 | |
7111 | 4683 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 4684 |
4685 return 1; | |
4686 } | |
4687 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4688 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
|
4689 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4690 aim_userinfo_t *info; |
5575 | 4691 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4692 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4693 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4694 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4695 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4696 |
5628 | 4697 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 4698 |
7872 | 4699 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 4700 gc->login_time_official = info->onlinesince; |
7872 | 4701 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
4702 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4703 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4704 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4705 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4706 |
4649 | 4707 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4708 GaimConnection *gc = sess->aux_data; |
7283 | 4709 OscarData *od = gc->proto_data; |
4649 | 4710 va_list ap; |
4711 fu16_t code; | |
4712 char *msg; | |
4713 | |
4714 va_start(ap, fr); | |
4715 code = (fu16_t)va_arg(ap, int); | |
4716 msg = va_arg(ap, char *); | |
4717 va_end(ap); | |
4718 | |
8660 | 4719 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4720 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4721 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4722 if (code == 0x0001) { |
6113 | 4723 gc->wants_to_die = TRUE; |
5579 | 4724 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4725 } else { |
5579 | 4726 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4727 } |
4666 | 4728 od->killme = TRUE; |
4649 | 4729 } |
4730 | |
4731 return 1; | |
4732 } | |
4733 | |
2675 | 4734 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4735 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4736 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4737 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4738 |
4739 #ifndef NOSSI | |
8660 | 4740 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4741 aim_ssi_reqrights(sess); |
6350 | 4742 aim_ssi_reqdata(sess); |
4230 | 4743 #endif |
4744 | |
7011 | 4745 aim_locate_reqrights(sess); |
7285 | 4746 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4747 aim_im_reqparams(sess); |
7334 | 4748 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4749 |
4750 #ifdef NOSSI | |
8660 | 4751 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4752 aim_bos_reqrights(sess, fr->conn); |
4230 | 4753 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4754 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4755 #endif | |
2086 | 4756 |
7283 | 4757 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4758 | |
2086 | 4759 return 1; |
4760 } | |
4761 | |
2675 | 4762 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4763 GaimConnection *gc = sess->aux_data; |
7283 | 4764 OscarData *od = gc->proto_data; |
2647 | 4765 |
6905 | 4766 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4767 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4768 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4769 | |
2672 | 4770 aim_clientready(sess, fr->conn); |
8660 | 4771 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4772 |
2647 | 4773 if (od->chpass) { |
8660 | 4774 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4775 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4776 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4777 od->oldp = NULL; |
2647 | 4778 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4779 od->newp = NULL; |
2647 | 4780 od->chpass = FALSE; |
4781 } | |
2979 | 4782 if (od->setnick) { |
8660 | 4783 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4784 aim_admin_setnick(sess, fr->conn, od->newsn); |
4785 g_free(od->newsn); | |
4786 od->newsn = NULL; | |
4787 od->setnick = FALSE; | |
4788 } | |
2647 | 4789 if (od->conf) { |
8660 | 4790 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4791 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4792 od->conf = FALSE; |
4793 } | |
4794 if (od->reqemail) { | |
8660 | 4795 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4796 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4797 od->reqemail = FALSE; |
4798 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4799 if (od->setemail) { |
8660 | 4800 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4801 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4802 g_free(od->email); |
5497 | 4803 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4804 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4805 } |
2647 | 4806 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4807 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4808 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4809 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4810 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
|
4811 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4812 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4813 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4814 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4815 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4816 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4817 |
4194 | 4818 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4819 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4820 "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
|
4821 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4822 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4823 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4824 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4825 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4826 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4827 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4828 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4829 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4830 |
4617 | 4831 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4832 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4833 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4834 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4835 |
2993 | 4836 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4837 { | |
5575 | 4838 GaimConnection *gc = sess->aux_data; |
7283 | 4839 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4840 va_list ap; |
4841 fu16_t maxsiglen; | |
2993 | 4842 |
4843 va_start(ap, fr); | |
4199 | 4844 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4845 va_end(ap); |
4846 | |
8660 | 4847 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4848 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4849 |
4617 | 4850 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4851 | |
4852 if (od->icq) | |
7334 | 4853 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4854 else |
7334 | 4855 aim_locate_setcaps(od->sess, caps_aim); |
4856 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4857 |
4858 return 1; | |
4859 } | |
4860 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4861 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
|
4862 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4863 fu16_t maxbuddies, maxwatchers; |
5575 | 4864 GaimConnection *gc = sess->aux_data; |
7283 | 4865 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4866 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4867 va_start(ap, fr); |
4199 | 4868 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4869 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4870 va_end(ap); |
4871 | |
8660 | 4872 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4873 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4874 |
4617 | 4875 od->rights.maxbuddies = (guint)maxbuddies; |
4876 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4877 |
2086 | 4878 return 1; |
4879 } | |
4880 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4881 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4882 GaimConnection *gc = sess->aux_data; |
7283 | 4883 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4884 va_list ap; |
4885 fu16_t maxpermits, maxdenies; | |
2086 | 4886 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4887 va_start(ap, fr); |
4199 | 4888 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4889 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4890 va_end(ap); |
4891 | |
8660 | 4892 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4893 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4894 |
4617 | 4895 od->rights.maxpermits = (guint)maxpermits; |
4896 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4897 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4898 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4899 serv_finish_login(gc); |
4900 | |
8660 | 4901 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4902 |
2672 | 4903 aim_clientready(sess, fr->conn); |
5948 | 4904 aim_srv_setavailmsg(sess, NULL); |
7474 | 4905 aim_srv_setidle(sess, 0); |
4617 | 4906 |
4664 | 4907 if (od->icq) { |
4908 aim_icq_reqofflinemsgs(sess); | |
4909 aim_icq_hideip(sess); | |
4910 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4911 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4912 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4913 if (sess->authinfo->email) |
4914 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4915 |
4916 return 1; | |
4917 } | |
4918 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4919 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
|
4920 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4921 struct aim_icq_offlinemsg *msg; |
4075 | 4922 struct aim_incomingim_ch4_args args; |
4923 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4924 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4925 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4926 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4927 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4928 |
8660 | 4929 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4930 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4931 args.uin = msg->sender; |
4932 args.type = msg->type; | |
4173 | 4933 args.flags = msg->flags; |
4076 | 4934 args.msglen = msg->msglen; |
4075 | 4935 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4936 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4937 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4938 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4939 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4940 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4941 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4942 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
|
4943 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4944 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4945 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4946 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4947 |
7388 | 4948 #if 0 |
4949 /* | |
7465 | 4950 * Update, 2003-11-09: |
4951 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4952 * | |
7388 | 4953 * It may not be my place to do this, but... |
4954 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4955 * stupid, and should not exist for % switches (%x in our case) that request | |
4956 * a year in the preferred representation for the current locale. For that | |
4957 * reason I've chosen to not use this workaround (n., see kluge). | |
4958 * | |
4959 * I have a date. I want to show it to the user in the "preferred" way. | |
4960 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4961 * what the locale wanted. | |
4962 * | |
4963 * If I have a necessity for a full representation of the year in the current | |
4964 * locale, then I'll use a switch that returns a full representation of the | |
4965 * year. | |
4966 * | |
4967 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4968 * (because you're anal, or whatever), then change the f***ing locale. | |
4969 * | |
4970 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4971 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4972 * |
4973 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4974 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4975 */ |
4976 | |
4977 /* | |
4978 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4979 * "last 2 digits" warning. |
4980 */ | |
4981 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4982 const struct tm *tm) | |
4983 { | |
4984 return strftime(s, max, fmt, tm); | |
4985 } | |
7388 | 4986 #endif |
7386 | 4987 |
9944 | 4988 static void oscar_string_append(GString *str, char *name, char *value) |
4989 { | |
4990 gchar *utf8; | |
4991 | |
4992 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
4993 g_string_append_printf(str, "\n<br><b>%s:</b> %s", name, utf8); | |
4994 g_free(utf8); | |
4995 } | |
4996 } | |
4997 | |
4624 | 4998 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
|
4999 { |
5575 | 5000 GaimConnection *gc = sess->aux_data; |
8670 | 5001 OscarData *od = (OscarData *)gc->proto_data; |
5002 GaimBuddy *buddy; | |
8853 | 5003 struct buddyinfo *bi = NULL; |
4624 | 5004 gchar who[16]; |
8670 | 5005 GString *str; |
5006 gchar *primary, *utf8; | |
9634 | 5007 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5008 va_list ap; |
4151 | 5009 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5010 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5011 va_start(ap, fr); |
4151 | 5012 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5013 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5014 |
4664 | 5015 if (!info->uin) |
5016 return 0; | |
5017 | |
8670 | 5018 str = g_string_sized_new(100); |
5556 | 5019 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5020 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5021 if (buddy != NULL) | |
5022 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5023 | |
5024 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5025 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5026 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5027 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5028 (bi->ipaddr & 0xff000000) >> 24, | |
5029 (bi->ipaddr & 0x00ff0000) >> 16, | |
5030 (bi->ipaddr & 0x0000ff00) >> 8, | |
5031 (bi->ipaddr & 0x000000ff)); | |
8701 | 5032 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5033 g_free(tstr); |
5034 } | |
8701 | 5035 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5036 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5037 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5038 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5039 g_free(utf8); | |
4625 | 5040 } |
5041 if (info->numaddresses && info->email2) { | |
5042 int i; | |
5043 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5044 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5045 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5046 g_free(utf8); | |
4643 | 5047 } |
4625 | 5048 } |
4624 | 5049 } |
8701 | 5050 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
8902 | 5051 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
5052 info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5053 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5054 char date[30]; |
5055 struct tm tm; | |
5056 tm.tm_mday = (int)info->birthday; | |
5057 tm.tm_mon = (int)info->birthmonth-1; | |
5058 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5059 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5060 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5061 } |
4624 | 5062 if (info->age) { |
5063 char age[5]; | |
5064 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5065 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5066 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5067 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5068 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5069 g_free(utf8); | |
4819 | 5070 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5071 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5072 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5073 g_free(utf8); | |
5074 } | |
5075 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5076 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5077 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5078 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5079 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5080 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5081 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5082 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5083 } |
4641 | 5084 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5085 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5086 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5087 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5088 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5089 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5090 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5091 } |
4641 | 5092 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5093 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5094 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5095 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5096 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5097 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5098 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5099 g_free(utf8); | |
4624 | 5100 } |
8670 | 5101 g_string_append_printf(str, "\n<hr>\n"); |
5102 } | |
5103 | |
9634 | 5104 if (buddy != NULL) |
5105 alias = gaim_buddy_get_alias(buddy); | |
5106 else | |
5107 alias = who; | |
5108 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5109 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5110 g_free(primary); |
8670 | 5111 g_string_free(str, TRUE); |
4151 | 5112 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5113 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5114 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5115 |
4759 | 5116 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5117 { | |
5575 | 5118 GaimConnection *gc = sess->aux_data; |
4820 | 5119 gchar who[16], *utf8; |
6695 | 5120 GaimBuddy *b; |
4759 | 5121 va_list ap; |
5122 struct aim_icq_info *info; | |
5123 | |
5124 va_start(ap, fr); | |
5125 info = va_arg(ap, struct aim_icq_info *); | |
5126 va_end(ap); | |
5127 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5128 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5129 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5130 serv_got_alias(gc, who, utf8); |
4759 | 5131 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5132 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5133 } |
4820 | 5134 g_free(utf8); |
4759 | 5135 } |
5136 | |
5137 return 1; | |
5138 } | |
5139 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5140 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
|
5141 { |
7032 | 5142 GaimConnection *gc = sess->aux_data; |
5143 gchar *text; | |
5144 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5145 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5146 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5147 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5148 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5149 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5150 url = va_arg(ap, char *); |
4199 | 5151 wid = (fu16_t) va_arg(ap, int); |
5152 hei = (fu16_t) va_arg(ap, int); | |
5153 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5154 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5155 |
7032 | 5156 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5157 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5158 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5159 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5160 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5161 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5162 |
7032 | 5163 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5164 { | |
6873 | 5165 GaimConnection *gc = sess->aux_data; |
5166 gchar *secondary; | |
5167 GString *text; | |
5168 int i, num; | |
2086 | 5169 va_list ap; |
6873 | 5170 char *email, *SNs; |
2086 | 5171 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5172 va_start(ap, fr); |
6873 | 5173 email = va_arg(ap, char *); |
2086 | 5174 num = va_arg(ap, int); |
5175 SNs = va_arg(ap, char *); | |
5176 va_end(ap); | |
5177 | |
8152 | 5178 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5179 text = g_string_new(""); |
2086 | 5180 for (i = 0; i < num; i++) |
6873 | 5181 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5182 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5183 | |
5184 g_free(secondary); | |
5185 g_string_free(text, TRUE); | |
2086 | 5186 |
5187 return 1; | |
5188 } | |
5189 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5190 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5191 va_list ap; |
6873 | 5192 char *email; |
5420 | 5193 char *buf; |
2086 | 5194 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5195 va_start(ap, fr); |
6873 | 5196 email = va_arg(ap, char *); |
2086 | 5197 va_end(ap); |
5198 | |
6873 | 5199 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
|
5200 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5201 g_free(buf); |
2086 | 5202 |
5203 return 1; | |
5204 } | |
5205 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5206 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5207 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5208 fu16_t status; |
2086 | 5209 va_list ap; |
5210 char msg[256]; | |
5211 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5212 va_start(ap, fr); |
4199 | 5213 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5214 va_end(ap); |
5215 | |
8660 | 5216 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5217 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5218 status ? "unknown" : "email sent"); |
5219 if (!status) { | |
5302 | 5220 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5221 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5222 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5223 } |
5224 | |
5225 return 1; | |
5226 } | |
5227 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5228 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5229 GaimConnection *gc = sess->aux_data; |
2086 | 5230 va_list ap; |
3912 | 5231 fu16_t perms, err; |
5232 char *url, *sn, *email; | |
5233 int change; | |
2086 | 5234 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5235 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5236 change = va_arg(ap, int); |
4199 | 5237 perms = (fu16_t) va_arg(ap, unsigned int); |
5238 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5239 url = va_arg(ap, char *); |
5240 sn = va_arg(ap, char *); | |
5241 email = va_arg(ap, char *); | |
2086 | 5242 va_end(ap); |
5243 | |
8660 | 5244 gaim_debug_misc("oscar", |
9626 | 5245 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5246 change ? "change" : "request", perms, err, | |
5247 (url != NULL) ? url : "(null)", | |
5248 (sn != NULL) ? sn : "(null)", | |
5249 (email != NULL) ? email : "(null)"); | |
5250 | |
5251 if ((err > 0) && (url != NULL)) { | |
3912 | 5252 char *dialog_msg; |
5253 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5254 switch (err) { | |
5255 case 0x0001: { | |
5256 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5257 } break; | |
5258 case 0x0006: { | |
5259 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5260 } break; | |
5261 case 0x000b: { | |
5262 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5263 } break; | |
5264 case 0x001d: { | |
5265 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); | |
5266 } break; | |
5267 case 0x0021: { | |
5268 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); | |
5269 } break; | |
5270 case 0x0023: { | |
5271 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5272 } break; | |
5273 default: { | |
5274 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5275 } break; | |
5276 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5277 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5278 g_free(dialog_top); |
5279 g_free(dialog_msg); | |
5280 return 1; | |
5281 } | |
5282 | |
9626 | 5283 if (sn != NULL) { |
4585 | 5284 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
|
5285 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5286 g_free(dialog_msg); |
5287 } | |
5288 | |
9626 | 5289 if (email != NULL) { |
5575 | 5290 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5291 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5292 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5293 g_free(dialog_msg); |
2086 | 5294 } |
5295 | |
5296 return 1; | |
5297 } | |
5298 | |
5575 | 5299 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5300 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5301 aim_flap_nop(od->sess, od->conn); |
2086 | 5302 } |
5303 | |
6059 | 5304 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5305 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5306 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5307 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5308 if (typing == GAIM_TYPING) |
4870 | 5309 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5310 else if (typing == GAIM_TYPED) |
4870 | 5311 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5312 else | |
5313 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5314 else { |
5300 | 5315 /* Don't send if this turkey is in our deny list */ |
5316 GSList *list; | |
5317 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5318 if (!list) { | |
7261 | 5319 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5320 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5321 if (typing == GAIM_TYPING) |
5300 | 5322 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5323 else if (typing == GAIM_TYPED) |
5300 | 5324 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5325 else | |
5326 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5327 } | |
3595 | 5328 } |
5329 } | |
2993 | 5330 return 0; |
5331 } | |
9030 | 5332 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5333 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
|
5334 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5335 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5336 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5337 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
|
5338 int ret = 0; |
5575 | 5339 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5340 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5341 |
4838 | 5342 if (dim && dim->connected) { |
5343 /* If we're directly connected, send a direct IM */ | |
6982 | 5344 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5345 } else { |
4738 | 5346 struct buddyinfo *bi; |
3008 | 5347 struct aim_sendimext_args args; |
5348 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5349 gsize len; |
8962 | 5350 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5351 | |
5352 if (strstr(message, "<IMG ")) | |
5353 gaim_conversation_write(conv, "", | |
5354 _("Your IM Image was not sent. " | |
5355 "You must be Direct Connected to send IM Images."), | |
5356 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5357 |
7261 | 5358 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5359 if (!bi) { |
5360 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5361 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5362 } |
5363 | |
3008 | 5364 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5365 if (od->icq) { |
5366 args.features = features_icq; | |
5367 args.featureslen = sizeof(features_icq); | |
3008 | 5368 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5369 } else { |
5370 args.features = features_aim; | |
5371 args.featureslen = sizeof(features_aim); | |
4972 | 5372 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5373 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5374 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5375 } |
4269 | 5376 |
4738 | 5377 if (bi->ico_need) { |
8660 | 5378 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5379 "Sending buddy icon request with message\n"); |
3008 | 5380 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5381 bi->ico_need = FALSE; |
3008 | 5382 } |
4269 | 5383 |
5575 | 5384 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5385 FILE *file = fopen(iconfile, "rb"); |
3008 | 5386 if (file) { |
5387 char *buf = g_malloc(st.st_size); | |
9532 | 5388 /* XXX - Use g_file_get_contents()? */ |
3008 | 5389 fread(buf, 1, st.st_size, file); |
6039 | 5390 fclose(file); |
4269 | 5391 |
3008 | 5392 args.iconlen = st.st_size; |
4617 | 5393 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5394 args.iconstamp = st.st_mtime; |
5395 | |
7406 | 5396 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5397 bi->ico_informed = FALSE; |
7406 | 5398 bi->ico_sent = FALSE; |
5399 } | |
4738 | 5400 |
5401 if (!bi->ico_informed) { | |
8660 | 5402 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5403 "Claiming to have a buddy icon\n"); |
4738 | 5404 args.flags |= AIM_IMFLAGS_HASICON; |
5405 bi->ico_me_len = args.iconlen; | |
5406 bi->ico_me_csum = args.iconsum; | |
5407 bi->ico_me_time = args.iconstamp; | |
5408 bi->ico_informed = TRUE; | |
5409 } | |
5410 | |
3008 | 5411 g_free(buf); |
2086 | 5412 } |
5413 } | |
4269 | 5414 |
3008 | 5415 args.destsn = name; |
4269 | 5416 |
8985 | 5417 /* |
5418 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5419 * strip all HTML | |
5420 */ | |
8995 | 5421 if (isdigit(name[0]) ) { |
5422 /* being sent to an ICQ user */ | |
5423 if (!isdigit(gaim_account_get_username(gc->account)[0])) { | |
5424 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ | |
5425 tmpmsg = gaim_str_add_cr(message); | |
5426 } else { | |
5427 /* from an ICQ user - do nothing */ | |
5428 tmpmsg = g_strdup(message); | |
5429 } | |
5430 } else { | |
5431 /* being sent to an AIM user */ | |
5432 if (isdigit(gaim_account_get_username(gc->account)[0])) { | |
5433 /* from an ICQ user */ | |
5434 tmpmsg2 = gaim_strdup_withhtml(message); | |
5435 tmpmsg = gaim_escape_html(tmpmsg2); | |
5436 g_free(tmpmsg2); | |
5437 } else | |
5438 tmpmsg = gaim_strdup_withhtml(message); | |
5439 } | |
6310 | 5440 len = strlen(tmpmsg); |
5441 | |
9830 | 5442 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5443 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5444 args.charset, args.charsubset, args.msglen); | |
4617 | 5445 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5446 g_free((char *)args.msg); |
2086 | 5447 } |
4838 | 5448 |
6310 | 5449 g_free(tmpmsg); |
5450 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5451 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5452 return 1; |
6310 | 5453 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5454 return ret; |
2086 | 5455 } |
5456 | |
7011 | 5457 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5458 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5459 |
7173 | 5460 if (od->icq && isdigit(name[0])) |
4624 | 5461 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5462 else |
7235 | 5463 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5464 } |
5465 | |
8950 | 5466 #if 0 |
7011 | 5467 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5468 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5469 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5470 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5471 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5472 maiden, NULL, NULL, city, state, NULL, 0, web); |
5473 } | |
8950 | 5474 #endif |
2086 | 5475 |
5575 | 5476 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5477 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5478 aim_srv_setidle(od->sess, time); |
2086 | 5479 } |
5480 | |
5954 | 5481 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5482 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5483 int charset = 0; |
6019 | 5484 char *text_html = NULL; |
5129 | 5485 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5486 gsize msglen = 0; |
2993 | 5487 |
4617 | 5488 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5489 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5490 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5491 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5492 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5493 "again when you are fully connected.")); |
4617 | 5494 |
7334 | 5495 if (!text) { |
5496 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5497 return; | |
5498 } | |
6019 | 5499 |
7334 | 5500 text_html = gaim_strdup_withhtml(text); |
9807 | 5501 charset = oscar_charset_check(text_html); |
9826 | 5502 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5503 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5504 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5505 g_free(msg); | |
9826 | 5506 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5507 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5508 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5509 g_free(msg); | |
5510 } else { | |
5511 msglen = strlen(text_html); | |
5512 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5513 } | |
5514 | |
5515 if (msglen > od->rights.maxsiglen) { | |
5516 gchar *errstr; | |
5517 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5518 "has been exceeded. Gaim has truncated it for you.", | |
5519 "The maximum profile length of %d bytes " | |
5520 "has been exceeded. Gaim has truncated it for you.", | |
5521 od->rights.maxsiglen), od->rights.maxsiglen); | |
5522 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5523 g_free(errstr); | |
5524 } | |
5525 | |
5526 g_free(text_html); | |
2993 | 5527 |
5528 return; | |
2086 | 5529 } |
5530 | |
8257 | 5531 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 5532 { |
9807 | 5533 int charset = 0; |
6019 | 5534 gchar *text_html = NULL; |
5129 | 5535 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5536 gsize msglen = 0; |
2993 | 5537 |
8257 | 5538 if (!strcmp(state, _("Visible"))) { |
5539 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5540 return; | |
5541 } else if (!strcmp(state, _("Invisible"))) { | |
5542 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5543 return; | |
5544 } /* else... */ | |
5545 | |
8476 | 5546 if (!strcmp(state, _("Back"))) { |
5547 /* If this is our only online account then globally set Gaim not-away */ | |
5548 GList *gcs = gaim_connections_get_all(); | |
5549 if (gcs->next == NULL) | |
9730 | 5550 ; /* XXX do_im_back(NULL, NULL); */ |
8476 | 5551 } |
5552 | |
8257 | 5553 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5554 | |
2993 | 5555 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5556 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5557 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5558 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5559 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5560 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5561 "fully connected.")); |
5129 | 5562 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5563 if (gc->away) { |
2993 | 5564 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5565 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5566 } |
2993 | 5567 |
5129 | 5568 if (!text) { |
7334 | 5569 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5570 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5571 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5572 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5573 text_html = gaim_strdup_withhtml(text); |
9807 | 5574 charset = oscar_charset_check(text_html); |
9826 | 5575 if (charset == AIM_CHARSET_UNICODE) { |
6019 | 5576 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5577 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5578 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5579 g_free(msg); |
5580 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
9826 | 5581 } else if (charset == AIM_CHARSET_CUSTOM) { |
6019 | 5582 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5583 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5584 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5585 g_free(msg); |
6019 | 5586 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5587 } else { |
6019 | 5588 msglen = strlen(text_html); |
7011 | 5589 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5590 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 5591 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5592 } |
5593 | |
5594 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5595 gchar *errstr; |
5596 | |
6308 | 5597 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5598 "has been exceeded. Gaim has truncated it for you.", | |
5599 "The maximum away message length of %d bytes " | |
5600 "has been exceeded. Gaim has truncated it for you.", | |
5601 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5602 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5603 g_free(errstr); |
5604 } | |
6019 | 5605 |
5606 g_free(text_html); | |
8257 | 5607 |
2993 | 5608 return; |
5609 } | |
5610 | |
7283 | 5611 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 5612 { |
5575 | 5613 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5614 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5615 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5616 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5617 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5618 |
8265 | 5619 if (strcmp(state, _("Invisible"))) |
5575 | 5620 account->perm_deny = 4; |
8265 | 5621 else |
5575 | 5622 account->perm_deny = 3; |
8265 | 5623 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5624 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5625 |
5626 if (!strcmp(state, _("Online"))) | |
4901 | 5627 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 5628 else if (!strcmp(state, _("Away"))) { |
4901 | 5629 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5630 gc->away = g_strdup(""); |
4342 | 5631 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 5632 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
|
5633 gc->away = g_strdup(""); |
4342 | 5634 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 5635 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
|
5636 gc->away = g_strdup(""); |
4342 | 5637 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 5638 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
|
5639 gc->away = g_strdup(""); |
4342 | 5640 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 5641 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5642 gc->away = g_strdup(""); |
4342 | 5643 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 5644 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5645 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5646 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 5647 if (message) { |
4901 | 5648 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
|
5649 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5650 } else { |
4901 | 5651 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5652 } |
2086 | 5653 } |
2993 | 5654 |
5655 return; | |
5656 } | |
5657 | |
6059 | 5658 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 5659 { |
7283 | 5660 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 5661 |
5662 if (od->icq) | |
5663 oscar_set_away_icq(gc, od, state, message); | |
5664 else | |
8257 | 5665 oscar_set_away_aim(gc, od, state, message); |
2993 | 5666 |
5667 return; | |
2086 | 5668 } |
5669 | |
9753 | 5670 static void oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { |
7283 | 5671 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5672 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5673 } |
5674 | |
9285 | 5675 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5676 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5677 |
5678 if (!aim_snvalid(buddy->name)) { | |
8092 | 5679 gchar *buf; |
9285 | 5680 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 | 5681 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5682 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5683 g_free(buf); |
8150 | 5684 |
5685 /* Remove from local list */ | |
9285 | 5686 gaim_blist_remove_buddy(buddy); |
8150 | 5687 |
8092 | 5688 return; |
5689 } | |
5690 | |
4230 | 5691 #ifdef NOSSI |
9285 | 5692 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5693 #else |
9285 | 5694 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5695 if (buddy && group) { | |
8660 | 5696 gaim_debug_info("oscar", |
9285 | 5697 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5698 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5699 } |
5700 } | |
5701 #endif | |
8150 | 5702 |
4759 | 5703 if (od->icq) |
9285 | 5704 aim_icq_getalias(od->sess, buddy->name); |
5705 } | |
5706 | |
5707 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5708 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5709 #ifdef NOSSI |
5710 char buf[MSG_LEN]; | |
5711 int n=0; | |
9285 | 5712 |
4230 | 5713 while (buddies) { |
9381 | 5714 GaimBuddy *buddy = buddies->data; |
4230 | 5715 if (n > MSG_LEN - 18) { |
7285 | 5716 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5717 n = 0; |
3092 | 5718 } |
9381 | 5719 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5720 buddies = buddies->next; |
5721 } | |
7285 | 5722 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5723 #else |
9285 | 5724 |
4230 | 5725 if (od->sess->ssi.received_data) { |
9285 | 5726 GList *curb = buddies; |
5727 GList *curg = groups; | |
5728 while ((curb != NULL) && (curg != NULL)) { | |
5729 GaimBuddy *buddy = curb->data; | |
5730 GaimGroup *group = curg->data; | |
5731 oscar_add_buddy(gc, buddy, group); | |
5732 curb = curb->next; | |
5733 curg = curg->next; | |
4230 | 5734 } |
5735 } | |
5736 #endif | |
5737 } | |
5738 | |
9285 | 5739 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5740 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5741 |
4230 | 5742 #ifdef NOSSI |
9285 | 5743 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5744 #else |
5745 if (od->sess->ssi.received_data) { | |
8660 | 5746 gaim_debug_info("oscar", |
9285 | 5747 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5748 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5749 } |
5750 #endif | |
5751 } | |
5752 | |
9285 | 5753 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5754 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5755 |
4230 | 5756 #ifdef NOSSI |
9285 | 5757 for (cur = buddies; cur != NULL; cur = cur->next) { |
5758 GaimBuddy *buddy = cur->data; | |
5759 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5760 } | |
4230 | 5761 #else |
5762 if (od->sess->ssi.received_data) { | |
9285 | 5763 GList *curb = buddies; |
5764 GList *curg = groups; | |
5765 while ((curb != NULL) && (curg != NULL)) { | |
5766 GaimBuddy *buddy = curb->data; | |
5767 GaimGroup *group = curg->data; | |
5768 oscar_remove_buddy(gc, buddy, group); | |
5769 curb = curb->next; | |
5770 curg = curg->next; | |
3092 | 5771 } |
4230 | 5772 } |
5773 #endif | |
5774 } | |
5775 | |
5776 #ifndef NOSSI | |
5575 | 5777 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5778 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5779 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5780 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5781 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5782 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5783 } |
5784 } | |
5785 | |
5575 | 5786 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5787 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5788 if (od->sess->ssi.received_data) { |
5789 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5790 if (gname) { | |
8660 | 5791 gaim_debug_info("oscar", |
9586 | 5792 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5793 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5794 } |
5795 } | |
5796 } | |
5797 | |
9285 | 5798 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5799 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5800 |
5801 if (od->sess->ssi.received_data) { | |
9285 | 5802 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5803 GList *cur, *groups = NULL; | |
5804 | |
5805 /* Make a list of what the groups each buddy is in */ | |
5806 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5807 GaimBlistNode *node = cur->data; | |
5808 groups = g_list_append(groups, node->parent); | |
5809 } | |
5810 | |
5811 oscar_remove_buddies(gc, moved_buddies, groups); | |
5812 oscar_add_buddies(gc, moved_buddies, groups); | |
5813 g_list_free(groups); | |
8660 | 5814 gaim_debug_info("oscar", |
9285 | 5815 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5816 } else { |
9285 | 5817 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5818 gaim_debug_info("oscar", |
9285 | 5819 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5820 } |
5821 } | |
5822 } | |
5823 | |
5968 | 5824 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5825 aim_session_t *sess = data; | |
6350 | 5826 aim_ssi_reqdata(sess); |
5968 | 5827 return FALSE; |
5828 } | |
5829 | |
4642 | 5830 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5831 GaimConnection *gc = sess->aux_data; |
7283 | 5832 OscarData *od = gc->proto_data; |
4642 | 5833 va_list ap; |
5834 fu16_t reason; | |
5835 | |
5836 va_start(ap, fr); | |
5837 reason = (fu16_t)va_arg(ap, unsigned int); | |
5838 va_end(ap); | |
5839 | |
8660 | 5840 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5841 |
5842 if (reason == 0x0005) { | |
5892 | 5843 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5844 _("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
|
5845 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5846 } |
5847 | |
5848 /* Activate SSI */ | |
5849 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5850 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5851 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5852 aim_ssi_enable(od->sess); |
5853 | |
5854 return 1; | |
5855 } | |
5856 | |
2991 | 5857 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5858 GaimConnection *gc = sess->aux_data; |
7283 | 5859 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5860 int numtypes, i; |
5861 fu16_t *maxitems; | |
2991 | 5862 va_list ap; |
5863 | |
5864 va_start(ap, fr); | |
4230 | 5865 numtypes = va_arg(ap, int); |
5866 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5867 va_end(ap); |
5868 | |
8660 | 5869 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5870 |
4230 | 5871 for (i=0; i<numtypes; i++) |
8660 | 5872 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5873 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5874 |
8660 | 5875 gaim_debug_misc(NULL, "\n"); |
4230 | 5876 |
5877 if (numtypes >= 0) | |
5878 od->rights.maxbuddies = maxitems[0]; | |
5879 if (numtypes >= 1) | |
5880 od->rights.maxgroups = maxitems[1]; | |
5881 if (numtypes >= 2) | |
5882 od->rights.maxpermits = maxitems[2]; | |
5883 if (numtypes >= 3) | |
5884 od->rights.maxdenies = maxitems[3]; | |
2991 | 5885 |
5886 return 1; | |
5887 } | |
5888 | |
5889 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5890 GaimConnection *gc = sess->aux_data; |
5891 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5892 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5893 GaimGroup *g; |
5894 GaimBuddy *b; | |
2995 | 5895 struct aim_ssi_item *curitem; |
2991 | 5896 int tmp; |
4230 | 5897 va_list ap; |
8219 | 5898 fu16_t fmtver, numitems; |
5899 struct aim_ssi_item *items; | |
5900 fu32_t timestamp; | |
4230 | 5901 |
5902 va_start(ap, fr); | |
5903 fmtver = (fu16_t)va_arg(ap, int); | |
5904 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5905 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5906 timestamp = va_arg(ap, fu32_t); |
8219 | 5907 va_end(ap); |
2991 | 5908 |
8660 | 5909 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5910 "ssi: syncing local list and server list\n"); |
2991 | 5911 |
8219 | 5912 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5913 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 | 5914 return 1; |
5915 } | |
5916 | |
2991 | 5917 /* Clean the buddy list */ |
4889 | 5918 aim_ssi_cleanlist(sess); |
2991 | 5919 |
8150 | 5920 { /* If not in server list then prune from local list */ |
5921 GaimBlistNode *gnode, *cnode, *bnode; | |
5922 GaimBuddyList *blist; | |
9539 | 5923 GSList *cur, *next; |
8150 | 5924 |
5925 /* Buddies */ | |
5926 cur = NULL; | |
5927 if ((blist = gaim_get_blist()) != NULL) { | |
5928 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5929 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5930 continue; | |
5931 g = (GaimGroup *)gnode; | |
5932 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5933 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5934 continue; | |
5935 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5936 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5937 continue; | |
5938 b = (GaimBuddy *)bnode; | |
5939 if (b->account == gc->account) { | |
5940 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5941 /* If the buddy is an ICQ user then load his nickname */ | |
5942 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5943 char *alias; |
8150 | 5944 if (servernick) |
5945 serv_got_alias(gc, b->name, servernick); | |
5946 | |
5947 /* Store local alias on server */ | |
8214 | 5948 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5949 if (!alias && b->alias && strlen(b->alias)) |
5950 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5951 free(alias); | |
5952 } else { | |
8660 | 5953 gaim_debug_info("oscar", |
8150 | 5954 "ssi: removing buddy %s from local list\n", b->name); |
5955 /* We can't actually remove now because it will screw up our looping */ | |
5956 cur = g_slist_prepend(cur, b); | |
5957 } | |
5958 } | |
5959 } | |
5960 } | |
5961 } | |
5962 } | |
8175 | 5963 |
8150 | 5964 while (cur != NULL) { |
5965 b = cur->data; | |
5966 cur = g_slist_remove(cur, b); | |
5967 gaim_blist_remove_buddy(b); | |
5968 } | |
5969 | |
5970 /* Permit list */ | |
5971 if (gc->account->permit) { | |
9539 | 5972 next = gc->account->permit; |
5973 while (next != NULL) { | |
5974 cur = next; | |
5975 next = next->next; | |
8150 | 5976 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5977 gaim_debug_info("oscar", |
8150 | 5978 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5979 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5980 } | |
9539 | 5981 } |
8150 | 5982 } |
5983 | |
5984 /* Deny list */ | |
5985 if (gc->account->deny) { | |
9539 | 5986 next = gc->account->deny; |
5987 while (next != NULL) { | |
5988 cur = next; | |
5989 next = next->next; | |
8150 | 5990 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 5991 gaim_debug_info("oscar", |
8150 | 5992 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5993 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5994 } | |
9539 | 5995 } |
8150 | 5996 } |
5997 /* Presence settings (idle time visibility) */ | |
5998 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5999 if (!(tmp & 0x400)) | |
6000 aim_ssi_setpresence(sess, tmp | 0x400); | |
6001 } /* end pruning buddies from local list */ | |
6002 | |
2991 | 6003 /* Add from server list to local list */ |
4230 | 6004 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6005 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6006 switch (curitem->type) { |
4230 | 6007 case 0x0000: { /* Buddy */ |
4251 | 6008 if (curitem->name) { |
4292 | 6009 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6010 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6011 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6012 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6013 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6014 /* Should gname be freed here? -- elb */ |
4754 | 6015 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6016 free(alias); |
8150 | 6017 if (b) { |
4292 | 6018 /* Get server stored alias */ |
4705 | 6019 if (alias_utf8) { |
8150 | 6020 g_free(b->alias); |
6021 b->alias = g_strdup(alias_utf8); | |
4705 | 6022 } |
4282 | 6023 } else { |
8150 | 6024 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6025 |
4754 | 6026 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6027 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6028 gaim_blist_add_group(g, NULL); |
6029 } | |
5146 | 6030 |
8660 | 6031 gaim_debug_info("oscar", |
9285 | 6032 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6033 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6034 } |
8341 | 6035 if (!aim_sncmp(curitem->name, account->username)) { |
6036 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6037 gaim_check_comment(od, comment); | |
6038 free(comment); | |
6039 } | |
7162 | 6040 g_free(gname_utf8); |
6041 g_free(alias_utf8); | |
2991 | 6042 } |
4230 | 6043 } break; |
6044 | |
6045 case 0x0001: { /* Group */ | |
4282 | 6046 /* Shouldn't add empty groups */ |
4230 | 6047 } break; |
6048 | |
6049 case 0x0002: { /* Permit buddy */ | |
2991 | 6050 if (curitem->name) { |
4230 | 6051 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6052 GSList *list; |
5575 | 6053 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6054 if (!list) { |
8660 | 6055 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6056 "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
|
6057 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6058 } |
6059 } | |
4230 | 6060 } break; |
6061 | |
6062 case 0x0003: { /* Deny buddy */ | |
2991 | 6063 if (curitem->name) { |
6064 GSList *list; | |
5575 | 6065 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6066 if (!list) { |
8660 | 6067 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6068 "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
|
6069 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6070 } |
6071 } | |
4230 | 6072 } break; |
6073 | |
6074 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6075 if (curitem->data) { |
6076 fu8_t permdeny; | |
5575 | 6077 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6078 gaim_debug_info("oscar", |
5575 | 6079 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6080 account->perm_deny = permdeny; | |
6081 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 6082 serv_set_away(gc, "Invisible", ""); |
6083 } | |
2991 | 6084 } |
6085 } | |
4230 | 6086 } break; |
6087 | |
6088 case 0x0005: { /* Presence setting */ | |
3109 | 6089 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6090 } break; |
2991 | 6091 } /* End of switch on curitem->type */ |
6092 } /* End of for loop */ | |
4230 | 6093 |
4901 | 6094 /* Set our ICQ status */ |
8257 | 6095 if (!gc->away) { |
4901 | 6096 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6097 } | |
6098 | |
4342 | 6099 /* Activate SSI */ |
6100 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6101 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6102 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6103 "ssi: activating server-stored buddy list\n"); |
4642 | 6104 aim_ssi_enable(sess); |
4342 | 6105 |
2991 | 6106 return 1; |
2086 | 6107 } |
4230 | 6108 |
6109 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6110 GaimConnection *gc = sess->aux_data; |
4230 | 6111 va_list ap; |
6112 struct aim_ssi_tmp *retval; | |
6113 | |
6114 va_start(ap, fr); | |
6115 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6116 va_end(ap); | |
6117 | |
6118 while (retval) { | |
8660 | 6119 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6120 "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 | 6121 |
6122 if (retval->ack != 0xffff) | |
6123 switch (retval->ack) { | |
6124 case 0x0000: { /* added successfully */ | |
6125 } break; | |
6126 | |
4829 | 6127 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6128 gchar *buf; | |
6129 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 | 6130 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6131 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6132 g_free(buf); |
6133 } | |
6134 | |
7023 | 6135 case 0x000e: { /* buddy requires authorization */ |
4828 | 6136 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6137 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6138 } break; |
6139 | |
6140 default: { /* La la la */ | |
5197 | 6141 gchar *buf; |
8660 | 6142 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6143 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 | 6144 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6145 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6146 g_free(buf); |
4230 | 6147 } break; |
6148 } | |
6149 | |
6150 retval = retval->next; | |
6151 } | |
6152 | |
6153 return 1; | |
6154 } | |
6155 | |
8227 | 6156 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6157 GaimConnection *gc = sess->aux_data; | |
6158 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6159 GaimBuddy *b; | |
6160 GaimGroup *g; | |
6161 va_list ap; | |
6162 fu16_t type; | |
6163 const char *name; | |
6164 | |
6165 va_start(ap, fr); | |
6166 type = (fu16_t)va_arg(ap, int); | |
6167 name = va_arg(ap, char *); | |
6168 va_end(ap); | |
6169 | |
6170 if ((type != 0x0000) || (name == NULL)) | |
6171 return 1; | |
6172 | |
6173 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6174 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6175 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6176 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6177 b = gaim_find_buddy(gc->account, name); | |
6178 free(alias); | |
6179 | |
6180 if (b) { | |
6181 /* Get server stored alias */ | |
6182 if (alias_utf8) { | |
6183 g_free(b->alias); | |
6184 b->alias = g_strdup(alias_utf8); | |
6185 } | |
6186 } else { | |
6187 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6188 | |
6189 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6190 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6191 gaim_blist_add_group(g, NULL); | |
6192 } | |
6193 | |
8660 | 6194 gaim_debug_info("oscar", |
9285 | 6195 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6196 gaim_blist_add_buddy(b, NULL, g, NULL); |
6197 } | |
6198 g_free(gname_utf8); | |
6199 g_free(alias_utf8); | |
6200 | |
6201 return 1; | |
6202 } | |
6203 | |
4230 | 6204 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6205 GaimConnection *gc = sess->aux_data; |
4230 | 6206 va_list ap; |
6207 char *sn, *msg; | |
4236 | 6208 gchar *dialog_msg, *nombre; |
4230 | 6209 struct name_data *data; |
6695 | 6210 GaimBuddy *buddy; |
4230 | 6211 |
6212 va_start(ap, fr); | |
6213 sn = va_arg(ap, char *); | |
6214 msg = va_arg(ap, char *); | |
6215 va_end(ap); | |
6216 | |
8660 | 6217 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6218 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6219 |
4687 | 6220 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6221 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6222 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6223 else |
6224 nombre = g_strdup(sn); | |
6225 | |
6226 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 | 6227 data = g_new(struct name_data, 1); |
6228 data->gc = gc; | |
6229 data->name = g_strdup(sn); | |
6230 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6231 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6232 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6233 0, data, |
7023 | 6234 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6235 G_CALLBACK(oscar_free_name_data)); |
4236 | 6236 |
4230 | 6237 g_free(dialog_msg); |
4236 | 6238 g_free(nombre); |
4230 | 6239 |
6240 return 1; | |
6241 } | |
6242 | |
6243 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6244 GaimConnection *gc = sess->aux_data; |
4230 | 6245 va_list ap; |
6246 char *sn, *msg; | |
4236 | 6247 gchar *dialog_msg, *nombre; |
4230 | 6248 struct name_data *data; |
6695 | 6249 GaimBuddy *buddy; |
4230 | 6250 |
6251 va_start(ap, fr); | |
6252 sn = va_arg(ap, char *); | |
6253 msg = va_arg(ap, char *); | |
6254 va_end(ap); | |
6255 | |
8660 | 6256 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6257 "ssi: received authorization request from %s\n", sn); |
4230 | 6258 |
4687 | 6259 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6260 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6261 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6262 else |
6263 nombre = g_strdup(sn); | |
6264 | |
4337 | 6265 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 | 6266 data = g_new(struct name_data, 1); |
6267 data->gc = gc; | |
6268 data->name = g_strdup(sn); | |
6269 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6270 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6271 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6272 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6273 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6274 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6275 |
4230 | 6276 g_free(dialog_msg); |
4236 | 6277 g_free(nombre); |
4230 | 6278 |
6279 return 1; | |
6280 } | |
6281 | |
6282 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6283 GaimConnection *gc = sess->aux_data; |
4230 | 6284 va_list ap; |
6285 char *sn, *msg; | |
4236 | 6286 gchar *dialog_msg, *nombre; |
4230 | 6287 fu8_t reply; |
6695 | 6288 GaimBuddy *buddy; |
4230 | 6289 |
6290 va_start(ap, fr); | |
6291 sn = va_arg(ap, char *); | |
6292 reply = (fu8_t)va_arg(ap, int); | |
6293 msg = va_arg(ap, char *); | |
6294 va_end(ap); | |
6295 | |
8660 | 6296 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6297 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6298 |
4687 | 6299 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6300 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6301 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6302 else |
6303 nombre = g_strdup(sn); | |
6304 | |
4230 | 6305 if (reply) { |
6306 /* Granted */ | |
7023 | 6307 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
|
6308 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6309 } else { |
6310 /* Denied */ | |
7023 | 6311 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
|
6312 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6313 } |
6314 g_free(dialog_msg); | |
4236 | 6315 g_free(nombre); |
4230 | 6316 |
6317 return 1; | |
6318 } | |
6319 | |
6320 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6321 GaimConnection *gc = sess->aux_data; |
4230 | 6322 va_list ap; |
6323 char *sn; | |
6695 | 6324 GaimBuddy *buddy; |
4230 | 6325 |
6326 va_start(ap, fr); | |
6327 sn = va_arg(ap, char *); | |
6328 va_end(ap); | |
6329 | |
4687 | 6330 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6331 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6332 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6333 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6334 |
6335 return 1; | |
6336 } | |
4269 | 6337 #endif |
2086 | 6338 |
5575 | 6339 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6340 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6341 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6342 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6343 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6344 pce->label = _("_Room:"); |
5234 | 6345 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6346 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6347 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6348 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6349 pce->label = _("_Exchange:"); |
5234 | 6350 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6351 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6352 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6353 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6354 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6355 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6356 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6357 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6358 |
9754 | 6359 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6360 { | |
6361 GHashTable *defaults; | |
6362 | |
6363 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6364 | |
6365 if (chat_name != NULL) | |
6366 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6367 | |
6368 return defaults; | |
6369 } | |
6370 | |
9917 | 6371 static char *oscar_get_chat_name(GHashTable *data) { |
6372 return g_strdup(g_hash_table_lookup(data, "room")); | |
6373 } | |
6374 | |
8308 | 6375 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6376 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6377 aim_conn_t *cur; |
5234 | 6378 char *name, *exchange; |
6379 | |
6380 name = g_hash_table_lookup(data, "room"); | |
6381 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6382 |
8660 | 6383 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6384 "Attempting to join chat room %s.\n", name); |
8308 | 6385 |
6386 if ((name == NULL) || (*name == '\0')) { | |
6387 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6388 return; | |
6389 } | |
6390 | |
4617 | 6391 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6392 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6393 "chatnav exists, creating room\n"); |
5234 | 6394 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6395 } else { |
6396 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6397 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6398 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6399 "chatnav does not exist, opening chatnav\n"); |
5234 | 6400 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6401 cr->name = g_strdup(name); |
4617 | 6402 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6403 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6404 } |
6405 } | |
6406 | |
8308 | 6407 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6408 OscarData *od = (OscarData *)gc->proto_data; | |
6409 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6410 |
6411 if (!ccon) | |
6412 return; | |
6413 | |
8225 | 6414 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6415 ccon->exchange, ccon->name, 0x0); |
6416 } | |
6417 | |
8308 | 6418 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6419 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6420 GSList *bcs = gc->buddy_chats; | |
5679 | 6421 GaimConversation *b = NULL; |
2086 | 6422 struct chat_connection *c = NULL; |
6423 int count = 0; | |
6424 | |
6425 while (bcs) { | |
6426 count++; | |
5679 | 6427 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6428 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6429 break; |
6430 bcs = bcs->next; | |
6431 b = NULL; | |
6432 } | |
6433 | |
6434 if (!b) | |
6435 return; | |
6436 | |
8660 | 6437 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6438 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6439 |
8308 | 6440 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6441 if (c != NULL) { |
4617 | 6442 if (od) |
6443 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6444 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6445 gaim_input_remove(c->inpa); |
8308 | 6446 if (gc && od->sess) |
4617 | 6447 aim_conn_kill(od->sess, &c->conn); |
2086 | 6448 g_free(c->name); |
6449 g_free(c->show); | |
6450 g_free(c); | |
6451 } | |
6452 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6453 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6454 } |
6455 | |
8219 | 6456 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6457 OscarData *od = (OscarData *)gc->proto_data; | |
6458 GaimConversation *conv = NULL; | |
2086 | 6459 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6460 char *buf, *buf2; |
9830 | 6461 fu16_t charset, charsubset; |
9807 | 6462 char *charsetstr = NULL; |
8907 | 6463 gsize len; |
8219 | 6464 |
6465 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6466 return -EINVAL; |
2086 | 6467 |
8219 | 6468 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6469 return -EINVAL; |
2086 | 6470 |
8219 | 6471 buf = gaim_strdup_withhtml(message); |
6472 len = strlen(buf); | |
6473 | |
8962 | 6474 if (strstr(buf, "<IMG ")) |
6475 gaim_conversation_write(conv, "", | |
6476 _("Your IM Image was not sent. " | |
6477 "You cannot send IM Images in AIM chats."), | |
6478 GAIM_MESSAGE_ERROR, time(NULL)); | |
6479 | |
9830 | 6480 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6481 if ((len > c->maxlen) || (len > c->maxvis)) { |
6482 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6483 return -E2BIG; |
8359 | 6484 } |
6485 | |
9831 | 6486 if (charset == AIM_CHARSET_ASCII) |
6487 charsetstr = "us-ascii"; | |
6488 else if (charset == AIM_CHARSET_UNICODE) | |
6489 charsetstr = "unicode-2-0"; | |
6490 else if (charset == AIM_CHARSET_CUSTOM) | |
6491 charsetstr = "iso-8859-1"; | |
9807 | 6492 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6493 g_free(buf2); |
8359 | 6494 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6495 return 0; |
2086 | 6496 } |
6497 | |
6695 | 6498 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6499 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6500 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 6501 return "icq"; |
6502 else | |
6503 return "aim"; | |
6504 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6505 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6506 if (b != NULL && isdigit(b->name[0])) |
4687 | 6507 return "icq"; |
6508 return "aim"; | |
6509 } | |
6510 | |
6695 | 6511 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 6512 { |
7334 | 6513 GaimAccount *account = NULL; |
6514 GaimConnection *gc = NULL; | |
6515 OscarData *od = NULL; | |
4687 | 6516 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6517 int i = 0; | |
7334 | 6518 aim_userinfo_t *userinfo = NULL; |
6519 | |
6520 if (b != NULL) | |
6521 account = b->account; | |
6522 if (account != NULL) | |
6523 gc = account->gc; | |
6524 if (gc != NULL) | |
6525 od = gc->proto_data; | |
7945 | 6526 if (od != NULL) |
6527 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6528 |
5131 | 6529 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6530 char *gname; | |
7334 | 6531 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6532 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6533 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6534 emblems[i++] = "notauthorized"; | |
6535 } else { | |
6536 emblems[i++] = "offline"; | |
6537 } | |
6538 } | |
4916 | 6539 |
4766 | 6540 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 6541 int uc = b->uc >> 16; |
4766 | 6542 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6543 emblems[i++] = "invisible"; |
4766 | 6544 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6545 emblems[i++] = "freeforchat"; |
4766 | 6546 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6547 emblems[i++] = "dnd"; |
4766 | 6548 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6549 emblems[i++] = "na"; |
4766 | 6550 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6551 emblems[i++] = "occupied"; |
4766 | 6552 else if (uc & AIM_ICQ_STATE_AWAY) |
6553 emblems[i++] = "away"; | |
6554 } else { | |
6555 if (b->uc & UC_UNAVAILABLE) | |
6556 emblems[i++] = "away"; | |
6557 } | |
4687 | 6558 if (b->uc & UC_WIRELESS) |
6559 emblems[i++] = "wireless"; | |
6560 if (b->uc & UC_AOL) | |
6561 emblems[i++] = "aol"; | |
6562 if (b->uc & UC_ADMIN) | |
6563 emblems[i++] = "admin"; | |
6564 if (b->uc & UC_AB && i < 4) | |
6565 emblems[i++] = "activebuddy"; | |
4766 | 6566 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6567 emblems[i++] = "unconfirmed"; */ | |
7334 | 6568 |
7945 | 6569 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6570 emblems[i++] = "hiptop"; | |
6571 | |
6572 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6573 emblems[i++] = "secure"; |
6574 | |
4687 | 6575 *se = emblems[0]; |
6576 *sw = emblems[1]; | |
6577 *nw = emblems[2]; | |
6578 *ne = emblems[3]; | |
6579 } | |
6580 | |
6695 | 6581 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6582 GaimConnection *gc = b->account->gc; |
7283 | 6583 OscarData *od = gc->proto_data; |
7045 | 6584 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6585 GString *str = g_string_new(""); |
5131 | 6586 |
6587 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6588 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6589 |
6590 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6591 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6592 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6593 g_free(charset); |
7011 | 6594 if (away_utf8 != NULL) { |
7091 | 6595 gchar *tmp1, *tmp2; |
9627 | 6596 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6597 g_free(away_utf8); |
8571 | 6598 tmp1 = gaim_escape_html(tmp2); |
7091 | 6599 g_free(tmp2); |
8700 | 6600 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6601 g_free(tmp1); |
8701 | 6602 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6603 g_free(tmp2); |
5836 | 6604 } |
5131 | 6605 } |
8701 | 6606 } |
6607 | |
6608 return g_string_free(str, FALSE); | |
5131 | 6609 } |
6610 | |
6695 | 6611 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 6612 GaimConnection *gc = b->account->gc; |
7283 | 6613 OscarData *od = gc->proto_data; |
5167 | 6614 gchar *ret = NULL; |
6615 | |
6616 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
6617 if (isdigit(b->name[0])) | |
8701 | 6618 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6619 else |
6620 ret = g_strdup(_("Away")); | |
5836 | 6621 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6622 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 6623 if (bi->availmsg) |
6624 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 6625 } else { |
5167 | 6626 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6627 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6628 ret = g_strdup(_("Not Authorized")); | |
6629 else | |
6630 ret = g_strdup(_("Offline")); | |
6631 } | |
6632 | |
6633 return ret; | |
6634 } | |
6635 | |
5842 | 6636 |
5844 | 6637 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6638 GaimConnection *gc = sess->aux_data; |
7283 | 6639 OscarData *od = gc->proto_data; |
5892 | 6640 va_list ap; |
5842 | 6641 fu16_t type; |
5892 | 6642 fu8_t flags = 0, length = 0; |
6643 char *md5 = NULL; | |
6644 | |
7334 | 6645 |
5842 | 6646 va_start(ap, fr); |
6647 type = va_arg(ap, int); | |
5892 | 6648 |
6649 switch(type) { | |
6650 case 0x0000: | |
6651 case 0x0001: { | |
6652 flags = va_arg(ap, int); | |
6653 length = va_arg(ap, int); | |
6654 md5 = va_arg(ap, char *); | |
6655 | |
6656 if (flags == 0x41) { | |
6657 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6658 od->iconconnecting = TRUE; | |
6659 od->set_icon = TRUE; | |
6660 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6661 } else { | |
6039 | 6662 struct stat st; |
6663 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6664 if (iconfile == NULL) { | |
8363 | 6665 aim_ssi_delicon(od->sess); |
6039 | 6666 } else if (!stat(iconfile, &st)) { |
6667 char *buf = g_malloc(st.st_size); | |
6668 FILE *file = fopen(iconfile, "rb"); | |
6669 if (file) { | |
9532 | 6670 /* XXX - Use g_file_get_contents()? */ |
6039 | 6671 fread(buf, 1, st.st_size, file); |
6672 fclose(file); | |
8660 | 6673 gaim_debug_info("oscar", |
6039 | 6674 "Uploading icon to icon server\n"); |
6879 | 6675 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6676 } else |
8660 | 6677 gaim_debug_error("oscar", |
6039 | 6678 "Can't open buddy icon file!\n"); |
6679 g_free(buf); | |
6680 } else { | |
8660 | 6681 gaim_debug_error("oscar", |
6039 | 6682 "Can't stat buddy icon file!\n"); |
5892 | 6683 } |
6684 } | |
8363 | 6685 } else if (flags == 0x81) { |
6686 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6687 if (iconfile == NULL) | |
6688 aim_ssi_delicon(od->sess); | |
6689 else | |
6690 aim_ssi_seticon(od->sess, md5, length); | |
6691 } | |
5892 | 6692 } break; |
6693 | |
6694 case 0x0002: { /* We just set an "available" message? */ | |
6695 } break; | |
6696 } | |
6697 | |
5842 | 6698 va_end(ap); |
5844 | 6699 |
6700 return 0; | |
5842 | 6701 } |
5892 | 6702 |
5575 | 6703 static void oscar_set_permit_deny(GaimConnection *gc) { |
6704 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6705 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6706 #ifdef NOSSI |
8143 | 6707 GSList *list; |
4230 | 6708 char buf[MAXMSGLEN]; |
6709 int at; | |
6710 | |
5575 | 6711 switch(account->perm_deny) { |
8175 | 6712 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6713 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6714 break; |
8175 | 6715 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6716 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6717 break; |
8175 | 6718 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6719 list = account->permit; |
4230 | 6720 at = 0; |
6721 while (list) { | |
6722 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6723 list = list->next; | |
6724 } | |
6725 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6726 break; | |
8175 | 6727 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6728 list = account->deny; |
4230 | 6729 at = 0; |
6730 while (list) { | |
6731 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6732 list = list->next; | |
6733 } | |
6734 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6735 break; | |
6736 default: | |
6737 break; | |
2086 | 6738 } |
4230 | 6739 #else |
8175 | 6740 if (od->sess->ssi.received_data) { |
6741 switch (account->perm_deny) { | |
6742 case GAIM_PRIVACY_ALLOW_ALL: | |
6743 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6744 break; | |
6745 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6746 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6747 break; | |
6748 case GAIM_PRIVACY_ALLOW_USERS: | |
6749 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6750 break; | |
6751 case GAIM_PRIVACY_DENY_ALL: | |
6752 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6753 break; | |
6754 case GAIM_PRIVACY_DENY_USERS: | |
6755 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6756 break; | |
6757 default: | |
6758 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6759 break; | |
6760 } | |
6761 } | |
4230 | 6762 #endif |
2086 | 6763 } |
6764 | |
5575 | 6765 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6766 #ifdef NOSSI |
8143 | 6767 if (gc->account->perm_deny == 3) |
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 add a permit\n"); |
4230 | 6772 if (od->sess->ssi.received_data) |
4889 | 6773 aim_ssi_addpermit(od->sess, who); |
4230 | 6774 #endif |
2086 | 6775 } |
6776 | |
5575 | 6777 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6778 #ifdef NOSSI |
8143 | 6779 if (gc->account->perm_deny == 4) |
4269 | 6780 oscar_set_permit_deny(gc); |
6781 #else | |
7283 | 6782 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6783 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6784 if (od->sess->ssi.received_data) |
4889 | 6785 aim_ssi_adddeny(od->sess, who); |
4230 | 6786 #endif |
2086 | 6787 } |
6788 | |
5575 | 6789 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6790 #ifdef NOSSI |
8143 | 6791 if (gc->account->perm_deny == 3) |
4269 | 6792 oscar_set_permit_deny(gc); |
6793 #else | |
7283 | 6794 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6795 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6796 if (od->sess->ssi.received_data) |
4889 | 6797 aim_ssi_delpermit(od->sess, who); |
4230 | 6798 #endif |
2086 | 6799 } |
6800 | |
5575 | 6801 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6802 #ifdef NOSSI |
8143 | 6803 if (gc->account->perm_deny == 4) |
4269 | 6804 oscar_set_permit_deny(gc); |
6805 #else | |
7283 | 6806 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6807 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6808 if (od->sess->ssi.received_data) |
4889 | 6809 aim_ssi_deldeny(od->sess, who); |
4230 | 6810 #endif |
2086 | 6811 } |
6812 | |
5575 | 6813 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 6814 { |
7283 | 6815 OscarData *od = gc->proto_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6816 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6817 |
8257 | 6818 if (od->icq) { |
6819 m = g_list_append(m, _("Online")); | |
6820 m = g_list_append(m, _("Away")); | |
6821 m = g_list_append(m, _("Do Not Disturb")); | |
6822 m = g_list_append(m, _("Not Available")); | |
6823 m = g_list_append(m, _("Occupied")); | |
6824 m = g_list_append(m, _("Free For Chat")); | |
6825 m = g_list_append(m, _("Invisible")); | |
6826 } else { | |
6827 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6828 m = g_list_append(m, _("Back")); |
8257 | 6829 m = g_list_append(m, _("Visible")); |
6830 m = g_list_append(m, _("Invisible")); | |
6831 } | |
4333 | 6832 |
6833 return m; | |
6834 } | |
6835 | |
7172 | 6836 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6837 GaimConnection *gc = data->gc; |
6838 OscarData *od = gc->proto_data; | |
7172 | 6839 GaimBuddy *b; |
6840 GaimGroup *g; | |
6841 | |
6842 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6843 oscar_free_name_data(data); | |
6844 return; | |
6845 } | |
6846 | |
6847 if (!(g = gaim_find_buddys_group(b))) { | |
6848 oscar_free_name_data(data); | |
6849 return; | |
6850 } | |
6851 | |
6852 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6853 |
6854 if (!aim_sncmp(data->name, gc->account->username)) | |
6855 gaim_check_comment(od, text); | |
6856 | |
7172 | 6857 oscar_free_name_data(data); |
6858 } | |
6859 | |
9030 | 6860 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6861 | |
6862 GaimBuddy *buddy; | |
6863 GaimConnection *gc; | |
6864 OscarData *od; | |
6865 struct name_data *data; | |
7172 | 6866 GaimGroup *g; |
6867 char *comment; | |
6868 gchar *comment_utf8; | |
9631 | 6869 gchar *title; |
7172 | 6870 |
9030 | 6871 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6872 | |
6873 buddy = (GaimBuddy *) node; | |
6874 gc = gaim_account_get_connection(buddy->account); | |
6875 od = gc->proto_data; | |
6876 | |
6877 data = g_new(struct name_data, 1); | |
6878 | |
6879 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6880 return; |
9030 | 6881 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6882 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6883 | |
6884 data->gc = gc; | |
9030 | 6885 data->name = g_strdup(buddy->name); |
7172 | 6886 data->nick = NULL; |
6887 | |
9631 | 6888 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6889 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6890 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6891 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6892 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6893 data); | |
9631 | 6894 g_free(title); |
7172 | 6895 |
6896 free(comment); | |
6897 g_free(comment_utf8); | |
6898 } | |
6899 | |
9030 | 6900 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6901 | |
6902 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6903 OscarData *od = gc->proto_data; |
9030 | 6904 |
4333 | 6905 GList *m = NULL; |
9030 | 6906 GaimBlistNodeAction *act; |
6907 | |
6908 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6909 oscar_buddycb_edit_comment, NULL); | |
6910 m = g_list_append(m, act); | |
7172 | 6911 |
4333 | 6912 if (od->icq) { |
4624 | 6913 #if 0 |
9030 | 6914 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6915 oscar_get_icqstatusmsg, NULL); | |
6916 m = g_list_append(m, act); | |
4624 | 6917 #endif |
4333 | 6918 } else { |
7011 | 6919 aim_userinfo_t *userinfo; |
9030 | 6920 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6921 | |
6922 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
6923 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
6924 | |
7011 | 6925 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 6926 act = gaim_blist_node_action_new(_("Direct IM"), |
6927 oscar_ask_direct_im, NULL); | |
6928 m = g_list_append(m, act); | |
5917 | 6929 } |
9466 | 6930 #if 0 |
7011 | 6931 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6932 act = gaim_blist_node_action_new(_("Get File"), |
6933 oscar_ask_getfile, NULL); | |
6934 m = g_list_append(m, act); | |
5917 | 6935 } |
4826 | 6936 #endif |
4333 | 6937 } |
5131 | 6938 } |
5197 | 6939 |
5131 | 6940 if (od->sess->ssi.received_data) { |
9030 | 6941 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6942 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
6943 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
6944 gaim_auth_sendrequest_menu, NULL); | |
6945 m = g_list_append(m, act); | |
4333 | 6946 } |
4916 | 6947 } |
6948 | |
4333 | 6949 return m; |
6950 } | |
6951 | |
9030 | 6952 |
6953 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6954 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6955 return oscar_buddy_menu((GaimBuddy *) node); | |
6956 } else { | |
6957 return NULL; | |
6958 } | |
6959 } | |
6960 | |
6961 | |
5575 | 6962 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6963 OscarData *od = gc->proto_data; |
5575 | 6964 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6965 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6966 od->setnick = TRUE; | |
6967 od->newsn = g_strdup(nick); | |
6968 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6969 } else { | |
6970 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6971 } | |
6972 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6973 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6974 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6975 } |
6976 } | |
6977 | |
9015 | 6978 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 6979 { |
9015 | 6980 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 6981 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 6982 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6983 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6984 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6985 gc); |
4333 | 6986 } |
6987 | |
9015 | 6988 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 6989 { |
9015 | 6990 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 6991 OscarData *od = gc->proto_data; |
4333 | 6992 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6993 | |
6994 if (conn) { | |
6995 aim_admin_reqconfirm(od->sess, conn); | |
6996 } else { | |
6997 od->conf = TRUE; | |
6998 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6999 } | |
7000 } | |
7001 | |
9015 | 7002 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7003 { |
9015 | 7004 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7005 OscarData *od = gc->proto_data; |
4333 | 7006 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7007 | |
7008 if (conn) { | |
7009 aim_admin_getinfo(od->sess, conn, 0x11); | |
7010 } else { | |
7011 od->reqemail = TRUE; | |
7012 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7013 } | |
7014 } | |
7015 | |
5575 | 7016 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7017 { |
7283 | 7018 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7019 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
|
7020 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7021 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7022 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7023 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7024 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7025 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7026 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7027 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7028 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7029 |
9015 | 7030 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7031 { |
9015 | 7032 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7033 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7034 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7035 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7036 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7037 gc); |
4333 | 7038 } |
7039 | |
9015 | 7040 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7041 { |
9015 | 7042 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7043 OscarData *od = gc->proto_data; |
4333 | 7044 gchar *nombre, *text, *tmp; |
6695 | 7045 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7046 int num=0; |
7047 | |
6873 | 7048 text = g_strdup(""); |
4333 | 7049 |
4785 | 7050 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7051 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7052 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7053 continue; | |
6695 | 7054 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7055 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7056 continue; |
6695 | 7057 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7058 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7059 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7060 continue; | |
7061 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7062 if (gaim_buddy_get_alias_only(buddy)) |
7063 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7064 else |
7065 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7066 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7067 g_free(text); |
7068 text = tmp; | |
7069 g_free(nombre); | |
7070 num++; | |
7071 } | |
4333 | 7072 } |
2979 | 7073 } |
4333 | 7074 } |
7075 | |
7076 if (!num) { | |
7077 g_free(text); | |
6873 | 7078 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7079 } | |
7080 | |
7081 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7082 "the following buddies"), _("You can re-request " | |
7083 "authorization from these buddies by " | |
7084 "right-clicking on them and selecting " | |
7085 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7086 g_free(text); |
2979 | 7087 } |
7088 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7089 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7090 { |
8950 | 7091 OscarData *od = (OscarData *)gc->proto_data; |
7092 | |
7093 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7094 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7095 |
9015 | 7096 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7097 { |
9015 | 7098 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7099 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7100 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7101 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7102 "searching for."), |
8697 | 7103 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7104 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7105 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7106 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7107 |
5917 | 7108 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 7109 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 7110 |
7334 | 7111 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 7112 aim_srv_setavailmsg(od->sess, text); |
7113 } | |
7114 | |
9879 | 7115 static void oscar_show_setavailmsg(GaimPluginAction *action) |
5917 | 7116 { |
9879 | 7117 GaimConnection *gc = (GaimConnection *) action->context; |
7313 | 7118 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
7119 _("I'm doing work and hoping for a distraction--IM me!"), | |
8697 | 7120 TRUE, FALSE, NULL, |
5917 | 7121 _("OK"), G_CALLBACK(oscar_setavailmsg), |
7122 _("Cancel"), NULL, | |
7123 gc); | |
7124 } | |
7125 | |
9015 | 7126 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7127 { |
9015 | 7128 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7129 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7130 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7131 |
9015 | 7132 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7133 { |
9015 | 7134 GaimConnection *gc = (GaimConnection *) action->context; |
9809 | 7135 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7136 } |
7137 | |
9015 | 7138 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7139 { |
9015 | 7140 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7141 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7142 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7143 |
9015 | 7144 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7145 { |
9015 | 7146 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7147 OscarData *od = gc->proto_data; |
5575 | 7148 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
|
7149 gaim_notify_uri(gc, substituted); |
5517 | 7150 g_free(substituted); |
4333 | 7151 } |
7152 | |
9015 | 7153 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7154 { |
9015 | 7155 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7156 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7157 } | |
7158 | |
5842 | 7159 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7160 { | |
7283 | 7161 OscarData *od = gc->proto_data; |
5844 | 7162 aim_session_t *sess = od->sess; |
5842 | 7163 FILE *file; |
7164 struct stat st; | |
5844 | 7165 |
6039 | 7166 if (iconfile == NULL) { |
8363 | 7167 aim_ssi_delicon(od->sess); |
6039 | 7168 } else if (!stat(iconfile, &st)) { |
5842 | 7169 char *buf = g_malloc(st.st_size); |
7170 file = fopen(iconfile, "rb"); | |
7171 if (file) { | |
6052 | 7172 md5_state_t *state; |
6039 | 7173 char md5[16]; |
9532 | 7174 /* XXX - Use g_file_get_contents()? */ |
5842 | 7175 int len = fread(buf, 1, st.st_size, file); |
6039 | 7176 fclose(file); |
6052 | 7177 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7178 md5_init(state); |
7179 md5_append(state, buf, len); | |
7180 md5_finish(state, md5); | |
7181 g_free(state); | |
7182 aim_ssi_seticon(sess, md5, 16); | |
7183 } else | |
8660 | 7184 gaim_debug_error("oscar", |
5842 | 7185 "Can't open buddy icon file!\n"); |
7186 g_free(buf); | |
7187 } else | |
8660 | 7188 gaim_debug_error("oscar", |
5842 | 7189 "Can't stat buddy icon file!\n"); |
7190 } | |
7191 | |
7192 | |
9015 | 7193 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7194 { |
9015 | 7195 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7196 OscarData *od = gc->proto_data; |
4333 | 7197 GList *m = NULL; |
9015 | 7198 GaimPluginAction *act; |
7199 | |
7200 act = gaim_plugin_action_new(_("Set User Info..."), | |
7201 oscar_show_set_info); | |
7202 m = g_list_append(m, act); | |
4333 | 7203 |
8576 | 7204 if (od->icq) { |
9015 | 7205 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7206 oscar_show_set_info_icqurl); | |
7207 m = g_list_append(m, act); | |
8576 | 7208 } |
7209 | |
9879 | 7210 if (!od->icq) { |
7211 act = gaim_plugin_action_new(_("Set Available Message..."), | |
7212 oscar_show_setavailmsg); | |
7213 m = g_list_append(m, act); | |
7214 } | |
5917 | 7215 |
9015 | 7216 act = gaim_plugin_action_new(_("Change Password..."), |
7217 oscar_change_pass); | |
7218 m = g_list_append(m, act); | |
4617 | 7219 |
7220 if (od->sess->authinfo->chpassurl) { | |
9015 | 7221 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7222 oscar_show_chpassurl); | |
7223 m = g_list_append(m, act); | |
7224 | |
7225 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7226 oscar_show_imforwardingurl); | |
7227 m = g_list_append(m, act); | |
7026 | 7228 } |
7229 | |
5238 | 7230 if (!od->icq) { |
4617 | 7231 /* AIM actions */ |
7232 m = g_list_append(m, NULL); | |
4333 | 7233 |
9015 | 7234 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7235 oscar_show_format_screenname); | |
7236 m = g_list_append(m, act); | |
7237 | |
7238 act = gaim_plugin_action_new(_("Confirm Account"), | |
7239 oscar_confirm_account); | |
7240 m = g_list_append(m, act); | |
7241 | |
7242 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7243 oscar_show_email); | |
7244 m = g_list_append(m, act); | |
7245 | |
7246 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7247 oscar_show_change_email); | |
7248 m = g_list_append(m, act); | |
2086 | 7249 } |
4333 | 7250 |
7251 m = g_list_append(m, NULL); | |
7252 | |
9015 | 7253 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7254 oscar_show_awaitingauth); | |
7255 m = g_list_append(m, act); | |
4333 | 7256 |
2086 | 7257 m = g_list_append(m, NULL); |
4333 | 7258 |
9015 | 7259 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7260 oscar_show_find_email); | |
7261 m = g_list_append(m, act); | |
4333 | 7262 |
8591 | 7263 #if 0 |
9015 | 7264 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7265 show_find_info); | |
7266 m = g_list_append(m, act); | |
8591 | 7267 #endif |
2086 | 7268 |
7269 return m; | |
7270 } | |
7271 | |
5575 | 7272 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7273 { |
7283 | 7274 OscarData *od = gc->proto_data; |
4617 | 7275 |
7276 if (od->icq) { | |
7277 aim_icq_changepasswd(od->sess, new); | |
2086 | 7278 } else { |
4617 | 7279 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7280 if (conn) { | |
7281 aim_admin_changepasswd(od->sess, conn, new, old); | |
7282 } else { | |
7283 od->chpass = TRUE; | |
7284 od->oldp = g_strdup(old); | |
7285 od->newp = g_strdup(new); | |
7286 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7287 } | |
2086 | 7288 } |
7289 } | |
7290 | |
6059 | 7291 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7292 { |
7283 | 7293 OscarData *od = gc->proto_data; |
8971 | 7294 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
|
7295 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7296 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7297 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7298 |
8971 | 7299 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7300 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7301 |
9935 | 7302 static void |
7303 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7304 { | |
7305 GaimConnection *gc = data; | |
7306 OscarData *od = gc->proto_data; | |
7307 aim_session_t *sess = od->sess; | |
7308 fu32_t presence; | |
7309 | |
7310 presence = aim_ssi_getpresence(sess->ssi.local); | |
7311 | |
7312 if (value) { | |
7313 presence |= 0x00400000; | |
7314 aim_ssi_setpresence(sess, presence); | |
7315 } else { | |
9936 | 7316 presence &= ~0x00400000; |
9935 | 7317 aim_ssi_setpresence(sess, presence); |
7318 } | |
7319 } | |
7320 | |
7321 static GaimPluginPrefFrame * | |
9936 | 7322 get_plugin_pref_frame(GaimPlugin *plugin) |
7323 { | |
9935 | 7324 GaimPluginPrefFrame *frame; |
7325 GaimPluginPref *ppref; | |
7326 | |
7327 frame = gaim_plugin_pref_frame_new(); | |
7328 | |
7329 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7330 gaim_plugin_pref_frame_add(frame, ppref); | |
7331 | |
7332 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7333 gaim_plugin_pref_frame_add(frame, ppref); | |
7334 | |
7335 return frame; | |
7336 } | |
7337 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7338 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7339 { |
9308 | 7340 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7341 NULL, /* user_splits */ |
7342 NULL, /* protocol_options */ | |
7343 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7344 oscar_list_icon, /* list_icon */ | |
7345 oscar_list_emblems, /* list_emblems */ | |
7346 oscar_status_text, /* status_text */ | |
7347 oscar_tooltip_text, /* tooltip_text */ | |
7348 oscar_away_states, /* away_states */ | |
7349 oscar_blist_node_menu, /* blist_node_menu */ | |
7350 oscar_chat_info, /* chat_info */ | |
9754 | 7351 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7352 oscar_login, /* login */ |
7353 oscar_close, /* close */ | |
7354 oscar_send_im, /* send_im */ | |
7355 oscar_set_info, /* set_info */ | |
7356 oscar_send_typing, /* send_typing */ | |
7357 oscar_get_info, /* get_info */ | |
7358 oscar_set_away, /* set_away */ | |
7359 oscar_set_idle, /* set_idle */ | |
7360 oscar_change_passwd, /* change_passwd */ | |
7361 oscar_add_buddy, /* add_buddy */ | |
7362 oscar_add_buddies, /* add_buddies */ | |
7363 oscar_remove_buddy, /* remove_buddy */ | |
7364 oscar_remove_buddies, /* remove_buddies */ | |
7365 oscar_add_permit, /* add_permit */ | |
7366 oscar_add_deny, /* add_deny */ | |
7367 oscar_rem_permit, /* rem_permit */ | |
7368 oscar_rem_deny, /* rem_deny */ | |
7369 oscar_set_permit_deny, /* set_permit_deny */ | |
7370 oscar_warn, /* warn */ | |
7371 oscar_join_chat, /* join_chat */ | |
7372 NULL, /* reject_chat */ | |
9917 | 7373 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7374 oscar_chat_invite, /* chat_invite */ |
7375 oscar_chat_leave, /* chat_leave */ | |
7376 NULL, /* chat_whisper */ | |
7377 oscar_send_chat, /* chat_send */ | |
7378 oscar_keepalive, /* keepalive */ | |
7379 NULL, /* register_user */ | |
7380 NULL, /* get_cb_info */ | |
7381 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7382 #ifndef NOSSI |
9475 | 7383 oscar_alias_buddy, /* alias_buddy */ |
7384 oscar_move_buddy, /* group_buddy */ | |
7385 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7386 #else |
9475 | 7387 NULL, /* alias_buddy */ |
7388 NULL, /* group_buddy */ | |
7389 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7390 #endif |
9475 | 7391 NULL, /* buddy_free */ |
7392 oscar_convo_closed, /* convo_closed */ | |
7393 NULL, /* normalize */ | |
7394 oscar_set_icon, /* set_buddy_icon */ | |
7395 NULL, /* remove_group */ | |
7396 NULL, /* get_cb_real_name */ | |
7397 NULL, /* set_chat_topic */ | |
7398 NULL, /* find_blist_chat */ | |
7399 NULL, /* roomlist_get_list */ | |
7400 NULL, /* roomlist_cancel */ | |
7401 NULL, /* roomlist_expand_category */ | |
7402 oscar_can_receive_file, /* can_receive_file */ | |
7403 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7404 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7405 |
9935 | 7406 static GaimPluginUiInfo prefs_info = { |
7407 get_plugin_pref_frame | |
7408 }; | |
7409 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7410 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7411 { |
9943 | 7412 GAIM_PLUGIN_MAGIC, |
7413 GAIM_MAJOR_VERSION, | |
7414 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7415 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7416 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7417 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7418 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7419 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7420 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7421 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7422 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7423 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7424 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7425 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7426 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7427 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7428 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7429 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7430 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7431 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7432 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7433 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7434 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7435 NULL, /**< ui_info */ |
8993 | 7436 &prpl_info, /**< extra_info */ |
9935 | 7437 &prefs_info, /**< prefs_info */ |
9015 | 7438 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7439 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7440 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7441 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7442 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7443 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7444 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7445 |
9830 | 7446 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7447 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7448 | |
7449 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7450 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7451 | |
7452 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7453 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
|
7454 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7455 my_protocol = plugin; |
9935 | 7456 |
7457 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7458 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7459 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7460 } |
7461 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7462 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |