Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 9976:f4ff7d2b9b2c
[gaim-migrate @ 10887]
Dave West fixed a few things from his patch to remove the
default action for certain dialogs that pop-up
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 08 Sep 2004 03:59:17 +0000 |
parents | c66345b33b88 |
children | 8db453e87678 |
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 |
9976 | 49 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
50 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
51 #define OSCAR_STATUS_ID_ONLINE "online" | |
52 #define OSCAR_STATUS_ID_AWAY "away" | |
53 #define OSCAR_STATUS_ID_DND "dnd" | |
54 #define OSCAR_STATUS_ID_NA "na" | |
55 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
56 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
57 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 58 |
59 #define UC_UNAVAILABLE 0x01 | |
60 #define UC_AOL 0x02 | |
61 #define UC_ADMIN 0x04 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
62 #define UC_UNCONFIRMED 0x08 |
9975 | 63 #define UC_NORMAL 0x10 |
64 #define UC_AB 0x20 | |
65 #define UC_WIRELESS 0x40 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
66 |
2086 | 67 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
68 | |
7283 | 69 #define OSCAR_CONNECT_STEPS 6 |
9830 | 70 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 71 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
72 static GaimPlugin *my_protocol = NULL; |
4249 | 73 |
7376 | 74 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
75 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 76 |
4665 | 77 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
78 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 79 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 80 |
7283 | 81 typedef struct _OscarData OscarData; |
82 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
83 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
84 aim_conn_t *conn; |
2086 | 85 |
86 guint cnpa; | |
87 guint paspa; | |
3694 | 88 guint emlpa; |
4804 | 89 guint icopa; |
2086 | 90 |
4823 | 91 gboolean iconconnecting; |
5842 | 92 gboolean set_icon; |
4823 | 93 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
94 GSList *create_rooms; |
2086 | 95 |
96 gboolean conf; | |
97 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
98 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
99 char *email; |
2979 | 100 gboolean setnick; |
101 char *newsn; | |
2086 | 102 gboolean chpass; |
103 char *oldp; | |
104 char *newp; | |
9971 | 105 |
2086 | 106 GSList *oscar_chats; |
107 GSList *direct_ims; | |
3630 | 108 GSList *file_transfers; |
4738 | 109 GHashTable *buddyinfo; |
4804 | 110 GSList *requesticon; |
2086 | 111 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
112 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
113 gboolean icq; |
4804 | 114 guint icontimer; |
5968 | 115 guint getblisttimer; |
8341 | 116 guint getinfotimer; |
9971 | 117 guint recentbuddies_cbid; |
2993 | 118 |
119 struct { | |
4230 | 120 guint maxwatchers; /* max users who can watch you */ |
2993 | 121 guint maxbuddies; /* max users you can watch */ |
4230 | 122 guint maxgroups; /* max groups in server list */ |
2993 | 123 guint maxpermits; /* max users on permit list */ |
124 guint maxdenies; /* max users on deny list */ | |
125 guint maxsiglen; /* max size (bytes) of profile */ | |
126 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
127 } rights; | |
2086 | 128 }; |
129 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
130 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
133 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
134 |
2086 | 135 struct chat_connection { |
136 char *name; | |
137 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
138 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
139 fu16_t instance; |
2086 | 140 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
|
141 aim_conn_t *conn; |
2086 | 142 int inpa; |
143 int id; | |
5575 | 144 GaimConnection *gc; /* i hate this. */ |
8733 | 145 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
146 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
147 int maxvis; |
2086 | 148 }; |
149 | |
8971 | 150 struct oscar_direct_im { |
5575 | 151 GaimConnection *gc; |
2086 | 152 char name[80]; |
153 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
154 aim_conn_t *conn; |
3008 | 155 gboolean connected; |
8978 | 156 gboolean gpc_pend; |
157 gboolean killme; | |
8984 | 158 gboolean donttryagain; |
2086 | 159 }; |
160 | |
161 struct ask_direct { | |
5575 | 162 GaimConnection *gc; |
2086 | 163 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
164 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
165 fu8_t cookie[8]; |
8984 | 166 gboolean donttryagain; |
2086 | 167 }; |
168 | |
7011 | 169 /* |
170 * Various PRPL-specific buddy info that we want to keep track of | |
171 * Some other info is maintained by locate.c, and I'd like to move | |
172 * the rest of this to libfaim, mostly im.c | |
173 */ | |
4738 | 174 struct buddyinfo { |
175 gboolean typingnot; | |
6292 | 176 gchar *availmsg; |
6857 | 177 fu32_t ipaddr; |
5836 | 178 |
179 unsigned long ico_me_len; | |
180 unsigned long ico_me_csum; | |
181 time_t ico_me_time; | |
182 gboolean ico_informed; | |
4738 | 183 |
184 unsigned long ico_len; | |
185 unsigned long ico_csum; | |
186 time_t ico_time; | |
187 gboolean ico_need; | |
7406 | 188 gboolean ico_sent; |
2086 | 189 }; |
190 | |
4230 | 191 struct name_data { |
5575 | 192 GaimConnection *gc; |
4230 | 193 gchar *name; |
3453 | 194 gchar *nick; |
3141 | 195 }; |
196 | |
5129 | 197 static char *msgerrreason[] = { |
198 N_("Invalid error"), | |
199 N_("Invalid SNAC"), | |
200 N_("Rate to host"), | |
201 N_("Rate to client"), | |
202 N_("Not logged in"), | |
203 N_("Service unavailable"), | |
204 N_("Service not defined"), | |
205 N_("Obsolete SNAC"), | |
206 N_("Not supported by host"), | |
207 N_("Not supported by client"), | |
208 N_("Refused by client"), | |
209 N_("Reply too big"), | |
210 N_("Responses lost"), | |
211 N_("Request denied"), | |
212 N_("Busted SNAC payload"), | |
213 N_("Insufficient rights"), | |
214 N_("In local permit/deny"), | |
215 N_("Too evil (sender)"), | |
216 N_("Too evil (receiver)"), | |
217 N_("User temporarily unavailable"), | |
218 N_("No match"), | |
219 N_("List overflow"), | |
220 N_("Request ambiguous"), | |
221 N_("Queue full"), | |
222 N_("Not while on AOL") | |
223 }; | |
224 static int msgerrreasonlen = 25; | |
225 | |
226 /* All the libfaim->gaim callback functions */ | |
227 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 237 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 238 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 239 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
240 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
|
241 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
|
242 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
|
243 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
|
244 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 245 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
246 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 248 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 249 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
250 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
256 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
259 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
260 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
261 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
276 #ifndef NOSSI | |
277 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
280 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 281 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 282 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
283 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
284 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
286 #endif | |
287 | |
288 /* for DirectIM/image transfer */ | |
289 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
290 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
291 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 292 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 293 |
294 /* for file transfer */ | |
295 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
296 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
297 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
298 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
299 | |
300 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 301 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 302 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 303 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 304 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
305 | |
5836 | 306 static void oscar_free_name_data(struct name_data *data) { |
4230 | 307 g_free(data->name); |
308 g_free(data->nick); | |
309 g_free(data); | |
310 } | |
311 | |
5836 | 312 static void oscar_free_buddyinfo(void *data) { |
313 struct buddyinfo *bi = data; | |
6292 | 314 g_free(bi->availmsg); |
5836 | 315 g_free(bi); |
316 } | |
317 | |
9807 | 318 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 319 { |
320 int i = 0; | |
9826 | 321 int charset = AIM_CHARSET_ASCII; |
5129 | 322 |
323 /* Determine how we can send this message. Per the warnings elsewhere | |
324 * in this file, these little checks determine the simplest encoding | |
325 * we can use for a given message send using it. */ | |
326 while (utf8[i]) { | |
327 if ((unsigned char)utf8[i] > 0x7f) { | |
328 /* not ASCII! */ | |
9826 | 329 charset = AIM_CHARSET_CUSTOM; |
5129 | 330 break; |
331 } | |
332 i++; | |
333 } | |
334 while (utf8[i]) { | |
335 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
336 * followed by 0xc0-0xc3 in the second */ | |
337 if ((unsigned char)utf8[i] < 0x80) { | |
338 i++; | |
339 continue; | |
340 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
341 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
342 i += 2; | |
343 continue; | |
344 } | |
9826 | 345 charset = AIM_CHARSET_UNICODE; |
5129 | 346 break; |
347 } | |
348 | |
9807 | 349 return charset; |
5129 | 350 } |
351 | |
8225 | 352 /* |
353 * Take a string of the form charset="bleh" where bleh is | |
354 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
355 * return a newly allocated string containing bleh. | |
356 */ | |
357 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 358 { |
8225 | 359 gchar *ret = NULL; |
360 char *begin, *end; | |
361 | |
9933 | 362 g_return_val_if_fail(encoding != NULL, NULL); |
363 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
364 /* Make sure encoding begins with charset= */ |
8225 | 365 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
366 return NULL; | |
367 | |
368 begin = strchr(encoding, '"'); | |
369 end = strrchr(encoding, '"'); | |
370 | |
371 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
372 return NULL; | |
373 | |
374 ret = g_strndup(begin+1, (end-1) - begin); | |
375 | |
376 return ret; | |
377 } | |
378 | |
9830 | 379 static gchar * |
380 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 381 { |
382 gchar *utf8 = NULL; | |
9595 | 383 |
384 if ((encoding == NULL) || encoding[0] == '\0') { | |
385 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
386 | |
9639 | 387 } else if (!strcmp(encoding, "iso-8859-1") |
388 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 389 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
390 | |
391 } else if (!strcmp(encoding, "unicode-2-0")) { | |
392 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
393 | |
394 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
395 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
396 "attempting to convert to UTF-8 anyway\n"); | |
397 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
398 } | |
399 | |
400 /* | |
401 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
402 * we have been unable to convert the text to utf-8 from the encoding | |
403 * that was specified. So we check if the text is valid utf-8 then | |
404 * just copy it. | |
405 */ | |
406 if (utf8 == NULL) { | |
9638 | 407 if (textlen != 0 && *text != '\0' |
408 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 409 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 410 else |
9481 | 411 utf8 = g_strndup(text, textlen); |
5129 | 412 } |
413 | |
414 return utf8; | |
415 } | |
416 | |
9830 | 417 static gchar * |
9908 | 418 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 419 { |
420 gchar *ret = NULL; | |
421 GError *err = NULL; | |
422 | |
9908 | 423 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
424 return NULL; | |
425 | |
426 if (strcasecmp("UTF-8", charsetstr)) { | |
427 if (fallback) | |
428 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
429 else | |
430 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
431 if (err != NULL) { | |
432 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
433 charsetstr, err->message); | |
434 g_error_free(err); | |
435 } | |
436 } else { | |
437 if (g_utf8_validate(data, datalen, NULL)) | |
438 ret = g_strndup(data, datalen); | |
439 else | |
440 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
441 } | |
442 | |
443 return ret; | |
444 } | |
445 | |
446 /* | |
447 * We try decoding using two different character sets. The charset | |
448 * specified in the IM determines the order in which we attempt to | |
449 * decode. We do this because there are lots of broken ICQ clients | |
450 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
451 * able to deal with that crap, then people complain like banshees. | |
452 * charsetstr1 is always set to what the correct encoding should be. | |
453 */ | |
454 static gchar * | |
455 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
456 { | |
457 gchar *ret = NULL; | |
458 const gchar *charsetstr1, *charsetstr2; | |
459 | |
460 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 461 |
462 if ((datalen == 0) || (data == NULL)) | |
463 return NULL; | |
464 | |
9908 | 465 if (charset == AIM_CHARSET_UNICODE) { |
466 charsetstr1 = "UCS-2BE"; | |
467 charsetstr2 = "UTF-8"; | |
468 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 469 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 470 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 471 else |
9908 | 472 charsetstr1 = "ISO-8859-1"; |
473 charsetstr2 = "UTF-8"; | |
474 } else if (charset == AIM_CHARSET_ASCII) { | |
475 /* Should just be "ASCII" */ | |
9914 | 476 charsetstr1 = "ASCII"; |
9908 | 477 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
478 } else if (charset == 0x000d) { | |
9830 | 479 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 480 charsetstr1 = "ISO-8859-1"; |
481 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
482 } else { | |
9830 | 483 /* Unknown, hope for valid UTF-8... */ |
9908 | 484 charsetstr1 = "UTF-8"; |
485 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
486 } | |
487 | |
488 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
489 if (ret == NULL) | |
490 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
491 if (ret == NULL) | |
492 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 493 |
494 return ret; | |
495 } | |
496 | |
497 static void | |
498 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
499 gchar **msg, int *msglen, | |
500 fu16_t *charset, fu16_t *charsubset) | |
501 { | |
502 OscarData *od = gc->proto_data; | |
503 GaimAccount *account = gaim_connection_get_account(gc); | |
504 GError *err = NULL; | |
505 aim_userinfo_t *userinfo = NULL; | |
506 const gchar *charsetstr; | |
507 | |
508 /* Attempt to send as ASCII */ | |
509 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, msglen, NULL); | |
510 if (*msg != NULL) { | |
511 *charset = AIM_CHARSET_ASCII; | |
512 *charsubset = 0x0000; | |
513 return; | |
514 } | |
515 | |
516 /* | |
9908 | 517 * If we're sending to an ICQ user, and they are advertising the |
518 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 519 */ |
9975 | 520 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 521 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
522 | |
523 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
9908 | 524 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, NULL); |
9830 | 525 if (*msg != NULL) { |
526 *charset = AIM_CHARSET_UNICODE; | |
527 *charsubset = 0x0000; | |
528 return; | |
529 } | |
530 } | |
531 | |
532 /* | |
533 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
534 * ICQ then attempt to send as the user specified character encoding. | |
535 */ | |
536 charsetstr = "ISO-8859-1"; | |
9975 | 537 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 538 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
539 | |
540 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, msglen, NULL); | |
541 if (*msg != NULL) { | |
542 *charset = AIM_CHARSET_CUSTOM; | |
543 *charsubset = 0x0000; | |
544 return; | |
545 } | |
546 | |
547 /* | |
548 * Nothing else worked, so send as UCS-2BE. | |
549 */ | |
550 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, &err); | |
551 if (*msg != NULL) { | |
552 *charset = AIM_CHARSET_UNICODE; | |
553 *charsubset = 0x0000; | |
554 return; | |
555 } | |
556 | |
9908 | 557 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 558 g_error_free(err); |
559 | |
560 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
561 *msg = g_strdup(from); | |
562 *msglen = strlen(*msg); | |
563 *charset = AIM_CHARSET_ASCII; | |
564 *charsubset = 0x0000; | |
565 return; | |
566 } | |
567 | |
9407 | 568 gchar *oscar_caps_to_string(guint caps) |
8701 | 569 { |
9407 | 570 GString *str; |
571 gchar *tmp; | |
8701 | 572 guint bit = 1; |
573 | |
9407 | 574 str = g_string_new(""); |
575 | |
8701 | 576 if (!caps) { |
577 return NULL; | |
578 } else while (bit <= AIM_CAPS_LAST) { | |
579 if (bit & caps) { | |
580 switch (bit) { | |
581 case AIM_CAPS_BUDDYICON: | |
582 tmp = _("Buddy Icon"); | |
583 break; | |
584 case AIM_CAPS_TALK: | |
585 tmp = _("Voice"); | |
586 break; | |
587 case AIM_CAPS_DIRECTIM: | |
588 tmp = _("AIM Direct IM"); | |
589 break; | |
590 case AIM_CAPS_CHAT: | |
591 tmp = _("Chat"); | |
592 break; | |
593 case AIM_CAPS_GETFILE: | |
594 tmp = _("Get File"); | |
595 break; | |
596 case AIM_CAPS_SENDFILE: | |
597 tmp = _("Send File"); | |
598 break; | |
599 case AIM_CAPS_GAMES: | |
600 case AIM_CAPS_GAMES2: | |
601 tmp = _("Games"); | |
602 break; | |
603 case AIM_CAPS_ADDINS: | |
604 tmp = _("Add-Ins"); | |
605 break; | |
606 case AIM_CAPS_SENDBUDDYLIST: | |
607 tmp = _("Send Buddy List"); | |
608 break; | |
609 case AIM_CAPS_ICQ_DIRECT: | |
610 tmp = _("ICQ Direct Connect"); | |
611 break; | |
612 case AIM_CAPS_APINFO: | |
613 tmp = _("AP User"); | |
614 break; | |
615 case AIM_CAPS_ICQRTF: | |
616 tmp = _("ICQ RTF"); | |
617 break; | |
618 case AIM_CAPS_EMPTY: | |
619 tmp = _("Nihilist"); | |
620 break; | |
621 case AIM_CAPS_ICQSERVERRELAY: | |
622 tmp = _("ICQ Server Relay"); | |
623 break; | |
624 case AIM_CAPS_ICQUTF8OLD: | |
625 tmp = _("Old ICQ UTF8"); | |
626 break; | |
627 case AIM_CAPS_TRILLIANCRYPT: | |
628 tmp = _("Trillian Encryption"); | |
629 break; | |
630 case AIM_CAPS_ICQUTF8: | |
631 tmp = _("ICQ UTF8"); | |
632 break; | |
633 case AIM_CAPS_HIPTOP: | |
634 tmp = _("Hiptop"); | |
635 break; | |
636 case AIM_CAPS_SECUREIM: | |
637 tmp = _("Security Enabled"); | |
638 break; | |
639 case AIM_CAPS_VIDEO: | |
640 tmp = _("Video Chat"); | |
641 break; | |
642 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
643 case AIM_CAPS_ICHATAV: | |
644 tmp = _("iChat AV"); | |
645 break; | |
646 case AIM_CAPS_LIVEVIDEO: | |
647 tmp = _("Live Video"); | |
648 break; | |
649 case AIM_CAPS_CAMERA: | |
650 tmp = _("Camera"); | |
651 break; | |
652 default: | |
653 tmp = NULL; | |
654 break; | |
655 } | |
656 if (tmp) | |
9532 | 657 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 658 } |
659 bit <<= 1; | |
660 } | |
9407 | 661 |
662 return g_string_free(str, FALSE); | |
8701 | 663 } |
664 | |
665 static char *oscar_icqstatus(int state) { | |
666 /* Make a cute little string that shows the status of the dude or dudet */ | |
667 if (state & AIM_ICQ_STATE_CHAT) | |
668 return g_strdup_printf(_("Free For Chat")); | |
669 else if (state & AIM_ICQ_STATE_DND) | |
670 return g_strdup_printf(_("Do Not Disturb")); | |
671 else if (state & AIM_ICQ_STATE_OUT) | |
672 return g_strdup_printf(_("Not Available")); | |
673 else if (state & AIM_ICQ_STATE_BUSY) | |
674 return g_strdup_printf(_("Occupied")); | |
675 else if (state & AIM_ICQ_STATE_AWAY) | |
676 return g_strdup_printf(_("Away")); | |
677 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
678 return g_strdup_printf(_("Web Aware")); | |
679 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
680 return g_strdup_printf(_("Invisible")); | |
681 else | |
682 return g_strdup_printf(_("Online")); | |
683 } | |
684 | |
9973 | 685 static void |
686 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 687 { |
688 gchar *utf8; | |
689 | |
690 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 691 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 692 g_free(utf8); |
693 } | |
694 } | |
695 | |
9973 | 696 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 697 { |
698 OscarData *od = gc->proto_data; | |
699 GaimAccount *account = gaim_connection_get_account(gc); | |
700 GaimGroup *g = NULL; | |
701 struct buddyinfo *bi = NULL; | |
702 char *tmp; | |
703 | |
704 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
705 return; | |
706 | |
707 if (userinfo == NULL) | |
708 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
709 | |
710 if (b == NULL) | |
711 b = gaim_find_buddy(gc->account, userinfo->sn); | |
712 | |
713 if (b != NULL) | |
714 g = gaim_find_buddys_group(b); | |
715 | |
716 if (userinfo != NULL) | |
717 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
718 | |
8733 | 719 if (b != NULL) { |
720 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
9975 | 721 if (aim_sn_is_icq(b->name)) { |
8733 | 722 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
723 oscar_string_append(str, newline, _("Status"), tmp); | |
724 g_free(tmp); | |
725 } | |
726 } else { | |
9625 | 727 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 728 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
729 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
730 else | |
731 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 732 } |
8733 | 733 } |
8701 | 734 |
735 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 736 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 737 (bi->ipaddr & 0xff000000) >> 24, |
738 (bi->ipaddr & 0x00ff0000) >> 16, | |
739 (bi->ipaddr & 0x0000ff00) >> 8, | |
740 (bi->ipaddr & 0x000000ff)); | |
741 oscar_string_append(str, newline, _("IP Address"), tmp); | |
742 g_free(tmp); | |
743 } | |
744 | |
745 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
746 tmp = oscar_caps_to_string(userinfo->capabilities); | |
747 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 748 g_free(tmp); |
8701 | 749 } |
750 | |
751 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
752 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
753 if (tmp != NULL) { | |
9625 | 754 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 755 g_free(tmp); |
9625 | 756 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
757 g_free(tmp2); | |
8701 | 758 } |
759 } | |
760 | |
761 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
762 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
763 oscar_string_append(str, newline, _("Available"), tmp); | |
764 g_free(tmp); | |
765 } | |
766 } | |
767 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
768 static char *extract_name(const char *name) { |
4121 | 769 char *tmp, *x; |
2086 | 770 int i, j; |
4120 | 771 |
772 if (!name) | |
4121 | 773 return NULL; |
774 | |
4120 | 775 x = strchr(name, '-'); |
4121 | 776 |
2086 | 777 if (!x) return NULL; |
778 x = strchr(++x, '-'); | |
779 if (!x) return NULL; | |
780 tmp = g_strdup(++x); | |
781 | |
782 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
783 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
784 if (x[i] != '%') { |
2086 | 785 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
786 continue; |
2086 | 787 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
788 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
789 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
790 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 791 } |
792 | |
793 tmp[j] = 0; | |
794 return tmp; | |
795 } | |
796 | |
5575 | 797 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 798 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 799 struct chat_connection *c = NULL; |
800 | |
801 while (g) { | |
802 c = (struct chat_connection *)g->data; | |
803 if (c->id == id) | |
804 break; | |
805 g = g->next; | |
806 c = NULL; | |
807 } | |
808 | |
809 return c; | |
810 } | |
811 | |
5575 | 812 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
|
813 aim_conn_t *conn) { |
7283 | 814 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 815 struct chat_connection *c = NULL; |
816 | |
817 while (g) { | |
818 c = (struct chat_connection *)g->data; | |
819 if (c->conn == conn) | |
820 break; | |
821 g = g->next; | |
822 c = NULL; | |
823 } | |
824 | |
825 return c; | |
826 } | |
827 | |
8219 | 828 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
829 GaimConversation *conv) { | |
830 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
831 struct chat_connection *c = NULL; | |
832 | |
833 while (g) { | |
834 c = (struct chat_connection *)g->data; | |
8733 | 835 if (c->conv == conv) |
8219 | 836 break; |
837 g = g->next; | |
838 c = NULL; | |
839 } | |
840 | |
841 return c; | |
842 } | |
843 | |
8971 | 844 /***************************************************************************** |
845 * Begin scary direct im stuff | |
846 *****************************************************************************/ | |
847 | |
848 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
849 GSList *d = od->direct_ims; | |
850 struct oscar_direct_im *m = NULL; | |
851 | |
852 while (d) { | |
853 m = (struct oscar_direct_im *)d->data; | |
854 if (!aim_sncmp(who, m->name)) | |
855 return m; | |
856 d = d->next; | |
857 } | |
858 | |
859 return NULL; | |
860 } | |
861 | |
862 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
863 { | |
864 gaim_debug_info("oscar", | |
865 "destroying Direct IM for %s.\n", dim->name); | |
866 | |
867 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 868 if (dim->gpc_pend) { |
869 dim->killme = TRUE; | |
870 return; | |
871 } | |
8971 | 872 if (dim->watcher) |
873 gaim_input_remove(dim->watcher); | |
874 if (dim->conn) { | |
875 aim_conn_close(dim->conn); | |
876 aim_conn_kill(od->sess, &dim->conn); | |
877 } | |
878 g_free(dim); | |
879 } | |
880 | |
881 /* the only difference between this and destroy is this writes a conv message */ | |
882 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
883 { | |
884 GaimConversation *conv; | |
885 char buf[256]; | |
886 | |
887 gaim_debug_info("oscar", | |
888 "%s disconnected Direct IM.\n", dim->name); | |
889 | |
890 if (dim->connected) | |
891 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 892 else |
8971 | 893 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
894 | |
895 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
896 if (conv) { | |
897 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 898 gaim_conversation_update_progress(conv, 0); |
8971 | 899 } else { |
900 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
901 } | |
902 | |
903 oscar_direct_im_destroy(od, dim); | |
904 | |
905 return; | |
906 } | |
907 | |
908 /* oops i made two of these. this one just calls the other one. */ | |
909 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
910 { | |
911 GaimConnection *gc = sess->aux_data; | |
912 OscarData *od = (OscarData *)gc->proto_data; | |
913 struct oscar_direct_im *dim; | |
914 char *sn; | |
915 | |
916 sn = g_strdup(aim_odc_getsn(conn)); | |
917 dim = oscar_direct_im_find(od, sn); | |
918 oscar_direct_im_disconnect(od, dim); | |
919 g_free(sn); | |
920 } | |
921 | |
922 static void destroy_direct_im_request(struct ask_direct *d) { | |
923 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
924 | |
925 g_free(d->sn); | |
926 g_free(d); | |
927 } | |
928 | |
929 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
930 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
931 struct oscar_direct_im *dim = data; | |
932 GaimConnection *gc = dim->gc; | |
933 OscarData *od = gc->proto_data; | |
934 GaimConversation *conv; | |
935 char buf[256]; | |
936 struct sockaddr name; | |
937 socklen_t name_len = 1; | |
938 | |
939 g_return_if_fail(gc != NULL); | |
940 | |
8978 | 941 dim->gpc_pend = FALSE; |
942 if (dim->killme) { | |
943 oscar_direct_im_destroy(od, dim); | |
944 return; | |
945 } | |
946 | |
8971 | 947 if (!g_list_find(gaim_connections_get_all(), gc)) { |
948 oscar_direct_im_destroy(od, dim); | |
949 return; | |
950 } | |
951 | |
952 if (source < 0) { | |
8984 | 953 if (dim->donttryagain) { |
954 oscar_direct_im_disconnect(od, dim); | |
955 return; | |
956 } else { | |
957 fu8_t cookie[8]; | |
958 char *who = g_strdup(dim->name); | |
959 const char *tmp = aim_odc_getcookie(dim->conn); | |
960 | |
961 memcpy(cookie, tmp, 8); | |
962 oscar_direct_im_destroy(od, dim); | |
963 oscar_direct_im_initiate(gc, who, cookie); | |
964 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
965 g_free(who); | |
966 return; | |
967 } | |
8971 | 968 } |
969 | |
970 dim->conn->fd = source; | |
971 aim_conn_completeconnect(od->sess, dim->conn); | |
972 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
973 | |
974 /* This is the best way to see if we're connected or not */ | |
8983 | 975 /* Is this really needed? */ |
8971 | 976 if (getpeername(source, &name, &name_len) == 0) { |
977 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
978 dim->connected = TRUE; | |
979 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 980 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
981 } else { | |
8984 | 982 if (dim->donttryagain) { |
983 oscar_direct_im_disconnect(od, dim); | |
984 return; | |
985 } else { | |
986 fu8_t cookie[8]; | |
987 char *who = g_strdup(dim->name); | |
988 const char *tmp = aim_odc_getcookie(dim->conn); | |
989 | |
990 memcpy(cookie, tmp, 8); | |
991 oscar_direct_im_destroy(od, dim); | |
992 oscar_direct_im_initiate(gc, who, cookie); | |
993 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
994 g_free(who); | |
995 return; | |
996 } | |
8983 | 997 } |
998 | |
999 | |
8971 | 1000 } |
1001 | |
1002 static void accept_direct_im_request(struct ask_direct *d) { | |
1003 GaimConnection *gc = d->gc; | |
1004 OscarData *od; | |
1005 struct oscar_direct_im *dim; | |
1006 char *host; int port = 5190; | |
1007 int i, rc; | |
8982 | 1008 char *tmp; |
1009 GaimConversation *conv; | |
8971 | 1010 |
1011 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1012 destroy_direct_im_request(d); | |
1013 return; | |
1014 } | |
1015 | |
1016 od = (OscarData *)gc->proto_data; | |
1017 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1018 | |
1019 dim = oscar_direct_im_find(od, d->sn); | |
1020 if (dim && dim->connected) { | |
1021 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1022 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1023 return; | |
1024 } | |
1025 dim = g_new0(struct oscar_direct_im, 1); | |
1026 dim->gc = d->gc; | |
8984 | 1027 dim->donttryagain = d->donttryagain; |
8971 | 1028 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1029 | |
1030 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1031 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1032 if (!dim->conn) { | |
1033 oscar_direct_im_disconnect(od, dim); | |
1034 destroy_direct_im_request(d); | |
1035 return; | |
1036 } | |
1037 | |
1038 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1039 gaim_odc_incoming, 0); | |
1040 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1041 gaim_odc_typing, 0); | |
1042 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1043 gaim_odc_update_ui, 0); | |
1044 | |
1045 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1046 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1047 if (d->ip[i] == ':') { | |
1048 port = atoi(&(d->ip[i+1])); | |
1049 break; | |
1050 } | |
1051 } | |
1052 host = g_strndup(d->ip, i); | |
1053 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1054 dim->gpc_pend = TRUE; |
8971 | 1055 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1056 |
1057 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1058 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1059 port); | |
1060 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1061 g_free(tmp); | |
8983 | 1062 |
8971 | 1063 g_free(host); |
1064 if (rc < 0) { | |
8978 | 1065 dim->gpc_pend = FALSE; |
8971 | 1066 oscar_direct_im_disconnect(od, dim); |
1067 destroy_direct_im_request(d); | |
1068 return; | |
1069 } | |
1070 | |
1071 destroy_direct_im_request(d); | |
1072 | |
1073 return; | |
1074 } | |
1075 | |
1076 /* | |
1077 * We have just established a socket with the other dude, so set up some handlers. | |
1078 */ | |
1079 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1080 GaimConnection *gc = sess->aux_data; |
7283 | 1081 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1082 GaimConversation *conv; |
8971 | 1083 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1084 char buf[256]; |
8971 | 1085 char *sn; |
1086 va_list ap; | |
1087 aim_conn_t *newconn, *listenerconn; | |
1088 | |
1089 va_start(ap, fr); | |
1090 newconn = va_arg(ap, aim_conn_t *); | |
1091 listenerconn = va_arg(ap, aim_conn_t *); | |
1092 va_end(ap); | |
1093 | |
1094 aim_conn_close(listenerconn); | |
1095 aim_conn_kill(sess, &listenerconn); | |
1096 | |
1097 sn = g_strdup(aim_odc_getsn(newconn)); | |
1098 | |
1099 gaim_debug_info("oscar", | |
1100 "DirectIM: initiate success to %s\n", sn); | |
1101 dim = oscar_direct_im_find(od, sn); | |
1102 | |
1103 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1104 gaim_input_remove(dim->watcher); | |
1105 dim->conn = newconn; | |
1106 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1107 dim->connected = TRUE; | |
1108 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1109 g_free(sn); | |
1110 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1111 | |
1112 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1113 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1114 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1115 | |
1116 return 1; | |
1117 } | |
1118 | |
1119 /* | |
1120 * This is called when each chunk of an image is received. It can be used to | |
1121 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1122 * nasty, you sicko. | |
1123 */ | |
1124 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1125 va_list ap; | |
1126 char *sn; | |
1127 double percent; | |
1128 GaimConnection *gc = sess->aux_data; | |
1129 OscarData *od = (OscarData *)gc->proto_data; | |
1130 GaimConversation *c; | |
1131 struct oscar_direct_im *dim; | |
1132 | |
1133 va_start(ap, fr); | |
1134 sn = va_arg(ap, char *); | |
1135 percent = va_arg(ap, double); | |
1136 va_end(ap); | |
1137 | |
1138 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1139 return 1; | |
1140 if (dim->watcher) { | |
1141 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1142 /* The callback will callback? I don't get how that would happen here. */ | |
1143 dim->watcher = 0; | |
1144 } | |
1145 | |
1146 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
1147 if (c != NULL) | |
1148 gaim_conversation_update_progress(c, percent); | |
1149 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1150 oscar_callback, dim->conn); | |
1151 | |
1152 return 1; | |
1153 } | |
1154 | |
1155 /* | |
1156 * This is called after a direct IM has been received in its entirety. This | |
1157 * function is passed a long chunk of data which contains the IM with any | |
1158 * data chunks (images) appended to it. | |
1159 * | |
1160 * This function rips out all the data chunks and creates an imgstore for | |
1161 * each one. In order to do this, it first goes through the IM and takes | |
1162 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1163 * with one compatible with the imgstore Gaim core code. For each one, we | |
1164 * then read in chunks of data from the end of the message and actually | |
1165 * create the img store using the given data. | |
1166 * | |
1167 * For somewhat easy reference, here's a sample message | |
1168 * (without the whitespace and asterisks): | |
1169 * | |
1170 * <HTML><BODY BGCOLOR="#ffffff"> | |
1171 * <FONT LANG="0"> | |
1172 * This is a really stupid picture:<BR> | |
1173 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1174 * Yeah it is<BR> | |
1175 * Here is another one:<BR> | |
1176 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1177 * </FONT> | |
1178 * </BODY></HTML> | |
1179 * <BINARY> | |
1180 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1181 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1182 * </BINARY> | |
1183 */ | |
1184 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1185 GaimConnection *gc = sess->aux_data; | |
1186 GaimConvImFlags imflags = 0; | |
1187 gchar *utf8; | |
1188 GString *newmsg = g_string_new(""); | |
1189 GSList *images = NULL; | |
1190 va_list ap; | |
1191 const char *sn, *msg, *msgend, *binary; | |
1192 size_t len; | |
1193 int encoding, isawaymsg; | |
1194 | |
1195 va_start(ap, fr); | |
1196 sn = va_arg(ap, const char *); | |
1197 msg = va_arg(ap, const char *); | |
1198 len = va_arg(ap, size_t); | |
1199 encoding = va_arg(ap, int); | |
1200 isawaymsg = va_arg(ap, int); | |
1201 va_end(ap); | |
1202 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1203 |
8660 | 1204 gaim_debug_info("oscar", |
8971 | 1205 "Got DirectIM message from %s\n", sn); |
1206 | |
1207 if (isawaymsg) | |
1208 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1209 | |
1210 /* message has a binary trailer */ | |
1211 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1212 GData *attribs; | |
1213 const char *tmp, *start, *end, *last = NULL; | |
1214 | |
1215 tmp = msg; | |
1216 | |
1217 /* for each valid image tag... */ | |
1218 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1219 const char *id, *src, *datasize; | |
1220 const char *tag = NULL, *data = NULL; | |
1221 size_t size; | |
1222 int imgid = 0; | |
1223 | |
1224 /* update the location of the last img tag */ | |
1225 last = end; | |
1226 | |
1227 /* grab attributes */ | |
1228 id = g_datalist_get_data(&attribs, "id"); | |
1229 src = g_datalist_get_data(&attribs, "src"); | |
1230 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1231 | |
1232 /* if we have id & datasize, build the data tag */ | |
1233 if (id && datasize) | |
1234 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1235 | |
1236 /* if we have a tag, find the start of the data */ | |
1237 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1238 data += strlen(tag); | |
1239 | |
1240 /* check the data is here and store it */ | |
1241 if (data + (size = atoi(datasize)) <= msgend) | |
1242 imgid = gaim_imgstore_add(data, size, src); | |
1243 | |
1244 /* | |
1245 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1246 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1247 */ | |
1248 /* if we have a stored image... */ | |
1249 if (imgid) { | |
1250 /* append the message up to the tag */ | |
1251 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1252 if (utf8 != NULL) { | |
1253 newmsg = g_string_append(newmsg, utf8); | |
1254 g_free(utf8); | |
1255 } | |
1256 | |
1257 /* write the new image tag */ | |
1258 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1259 | |
1260 /* and record the image number */ | |
1261 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1262 } else { | |
1263 /* otherwise, copy up to the end of the tag */ | |
1264 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1265 if (utf8 != NULL) { | |
1266 newmsg = g_string_append(newmsg, utf8); | |
1267 g_free(utf8); | |
1268 } | |
1269 } | |
1270 | |
1271 /* clear the attribute list */ | |
1272 g_datalist_clear(&attribs); | |
1273 | |
1274 /* continue from the end of the tag */ | |
1275 tmp = end + 1; | |
1276 } | |
1277 | |
1278 /* append any remaining message data (without the > :-) */ | |
1279 if (last++ && (last < binary)) | |
1280 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1281 | |
1282 /* set the flag if we caught any images */ | |
1283 if (images) | |
1284 imflags |= GAIM_CONV_IM_IMAGES; | |
1285 } else { | |
1286 g_string_append_len(newmsg, msg, len); | |
1287 } | |
1288 | |
1289 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1290 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1291 | |
1292 /* free up the message */ | |
1293 g_string_free(newmsg, TRUE); | |
1294 | |
1295 /* unref any images we allocated */ | |
1296 if (images) { | |
1297 GSList *tmp; | |
1298 int id; | |
1299 | |
1300 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1301 id = GPOINTER_TO_INT(tmp->data); | |
1302 gaim_imgstore_unref(id); | |
1303 } | |
1304 | |
1305 g_slist_free(images); | |
1306 } | |
1307 | |
1308 return 1; | |
1309 } | |
1310 | |
1311 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1312 va_list ap; | |
1313 char *sn; | |
1314 int typing; | |
1315 GaimConnection *gc = sess->aux_data; | |
1316 | |
1317 va_start(ap, fr); | |
1318 sn = va_arg(ap, char *); | |
1319 typing = va_arg(ap, int); | |
1320 va_end(ap); | |
1321 | |
1322 if (typing == 0x0002) { | |
1323 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1324 gaim_debug_info("oscar", | |
1325 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1326 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1327 } else if (typing == 0x0001) | |
1328 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1329 else | |
1330 serv_got_typing_stopped(gc, sn); | |
1331 return 1; | |
1332 } | |
1333 | |
1334 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1335 char *buf; | |
1336 size_t len; | |
1337 int ret; | |
1338 GString *msg = g_string_new("<HTML><BODY>"); | |
1339 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1340 GData *attribs; | |
1341 const char *start, *end, *last; | |
1342 int oscar_id = 0; | |
1343 | |
1344 last = message; | |
1345 | |
1346 /* for each valid IMG tag... */ | |
1347 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1348 GaimStoredImage *image = NULL; | |
1349 const char *id; | |
1350 | |
1351 if (start - last) { | |
1352 g_string_append_len(msg, last, start - last); | |
1353 } | |
1354 | |
1355 id = g_datalist_get_data(&attribs, "id"); | |
1356 | |
1357 /* ... if it refers to a valid gaim image ... */ | |
1358 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1359 /* ... append the message from start to the tag ... */ | |
9126 | 1360 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1361 const char *filename = gaim_imgstore_get_filename(image); |
1362 gpointer imgdata = gaim_imgstore_get_data(image); | |
1363 | |
1364 oscar_id++; | |
1365 | |
1366 /* ... insert a new img tag with the oscar id ... */ | |
1367 if (filename) | |
1368 g_string_append_printf(msg, | |
9126 | 1369 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1370 filename, oscar_id, size); |
1371 else | |
1372 g_string_append_printf(msg, | |
9126 | 1373 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1374 oscar_id, size); |
1375 | |
1376 /* ... and append the data to the binary section ... */ | |
9126 | 1377 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1378 oscar_id, size); |
1379 data = g_string_append_len(data, imgdata, size); | |
1380 data = g_string_append(data, "</DATA>"); | |
1381 } | |
1382 /* If the tag is invalid, skip it, thus no else here */ | |
1383 | |
1384 g_datalist_clear(&attribs); | |
1385 | |
1386 /* continue from the end of the tag */ | |
1387 last = end + 1; | |
1388 } | |
1389 | |
1390 /* append any remaining message data (without the > :-) */ | |
1391 if (last && *last) | |
1392 msg = g_string_append(msg, last); | |
1393 | |
1394 /* if we inserted any images in the binary section, append it */ | |
1395 if (oscar_id) { | |
1396 msg = g_string_append_len(msg, data->str, data->len); | |
1397 msg = g_string_append(msg, "</BINARY>"); | |
1398 } | |
1399 | |
1400 len = msg->len; | |
1401 buf = msg->str; | |
1402 g_string_free(msg, FALSE); | |
1403 g_string_free(data, TRUE); | |
1404 | |
1405 | |
1406 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1407 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1408 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1409 else | |
1410 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1411 | |
1412 g_free(buf); | |
1413 | |
1414 return ret; | |
1415 } | |
1416 | |
1417 struct ask_do_dir_im { | |
1418 char *who; | |
1419 GaimConnection *gc; | |
1420 }; | |
1421 | |
1422 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1423 g_free(data->who); | |
1424 g_free(data); | |
1425 } | |
1426 | |
8983 | 1427 /* this function is used to initiate a direct im session with someone. |
1428 * we start listening on a port and send a request. they either connect | |
1429 * or send some kind of reply. If they can't connect, they ask us to | |
1430 * connect to them, and so we do that. | |
1431 * | |
1432 * this function will also get called if the other side initiate's a direct | |
1433 * im and we try to connect and fail. in that case cookie will not be null. | |
1434 * | |
1435 * note that cookie is an 8 byte string that isn't NULL terminated | |
1436 */ | |
1437 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1438 OscarData *od; |
1439 struct oscar_direct_im *dim; | |
1440 int listenfd; | |
8982 | 1441 const char *ip; |
8971 | 1442 |
1443 od = (OscarData *)gc->proto_data; | |
1444 | |
8983 | 1445 dim = oscar_direct_im_find(od, who); |
8971 | 1446 if (dim) { |
1447 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1448 oscar_direct_im_disconnect(od, dim); | |
1449 gaim_debug_info("oscar", | |
1450 "Gave up on old direct IM, trying again\n"); | |
1451 } else { | |
1452 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1453 return; |
8971 | 1454 } |
1455 } | |
1456 dim = g_new0(struct oscar_direct_im, 1); | |
1457 dim->gc = gc; | |
8983 | 1458 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1459 |
1460 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1461 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1462 if (listenfd >= 0) |
1463 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1464 if (dim->conn != NULL) { |
8982 | 1465 char *tmp; |
1466 GaimConversation *conv; | |
1467 | |
8971 | 1468 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1469 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1470 oscar_callback, dim->conn); | |
1471 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1472 gaim_odc_initiate, 0); | |
8982 | 1473 |
8983 | 1474 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1475 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1476 gaim_network_get_port_from_fd(listenfd)); |
1477 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1478 g_free(tmp); | |
8971 | 1479 } else { |
1480 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1481 oscar_direct_im_destroy(od, dim); | |
1482 } | |
8983 | 1483 } |
1484 | |
1485 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1486 GaimConnection *gc = data->gc; | |
1487 | |
1488 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1489 g_free(data->who); | |
1490 g_free(data); | |
1491 return; | |
1492 } | |
1493 | |
1494 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1495 g_free(data->who); |
1496 g_free(data); | |
1497 } | |
1498 | |
1499 /* this is the right click menu cb thingy */ | |
9030 | 1500 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1501 | |
1502 GaimBuddy *buddy; | |
1503 GaimConnection *gc; | |
8971 | 1504 gchar *buf; |
9030 | 1505 struct ask_do_dir_im *data; |
1506 | |
1507 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1508 | |
1509 buddy = (GaimBuddy *) node; | |
1510 gc = gaim_account_get_connection(buddy->account); | |
1511 | |
1512 data = g_new0(struct ask_do_dir_im, 1); | |
1513 data->who = g_strdup(buddy->name); | |
8971 | 1514 data->gc = gc; |
9030 | 1515 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1516 buddy->name); | |
8971 | 1517 |
1518 gaim_request_action(gc, NULL, buf, | |
9030 | 1519 _("Because this reveals your IP address, it " |
1520 "may be considered a privacy risk. Do you " | |
1521 "wish to continue?"), | |
1522 0, data, 2, | |
1523 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1524 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1525 g_free(buf); |
1526 } | |
1527 | |
1528 /***************************************************************************** | |
1529 * End scary direct im stuff | |
1530 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1531 |
4617 | 1532 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1533 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1534 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1535 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1536 OscarData *od; |
2086 | 1537 |
1538 if (!gc) { | |
8660 | 1539 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1540 "oscar callback for closed connection (1).\n"); |
2086 | 1541 return; |
1542 } | |
1543 | |
7283 | 1544 od = (OscarData *)gc->proto_data; |
2086 | 1545 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1546 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1547 /* oh boy. this is probably bad. i guess the only thing we |
1548 * can really do is return? */ | |
8660 | 1549 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1550 "oscar callback for closed connection (2).\n"); |
8660 | 1551 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1552 return; |
1553 } | |
1554 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1555 if (condition & GAIM_INPUT_READ) { |
4617 | 1556 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1557 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1558 "got information on rendezvous listener\n"); |
4617 | 1559 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1560 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1561 "connection error (rendezvous listener)\n"); |
4617 | 1562 aim_conn_kill(od->sess, &conn); |
8446 | 1563 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1564 } |
1565 } else { | |
4617 | 1566 if (aim_get_command(od->sess, conn) >= 0) { |
1567 aim_rxdispatch(od->sess); | |
6029 | 1568 if (od->killme) { |
8660 | 1569 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1570 return; |
1571 } | |
2086 | 1572 } else { |
1573 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1574 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1575 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1576 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1577 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1578 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1579 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1580 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1581 char *buf; |
8660 | 1582 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1583 "disconnected from chat room %s\n", c->name); |
2086 | 1584 c->conn = NULL; |
1585 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1586 gaim_input_remove(c->inpa); |
2086 | 1587 c->inpa = 0; |
1588 c->fd = -1; | |
4617 | 1589 aim_conn_kill(od->sess, &conn); |
5420 | 1590 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1591 if (conv) |
1592 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1593 else | |
1594 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1595 g_free(buf); |
2086 | 1596 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1597 if (od->cnpa > 0) |
1598 gaim_input_remove(od->cnpa); | |
1599 od->cnpa = 0; | |
8660 | 1600 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1601 "removing chatnav input watcher\n"); |
4617 | 1602 while (od->create_rooms) { |
1603 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1604 g_free(cr->name); |
4617 | 1605 od->create_rooms = |
1606 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1607 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1608 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1609 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1610 NULL); |
2086 | 1611 } |
4617 | 1612 aim_conn_kill(od->sess, &conn); |
2086 | 1613 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1614 if (od->paspa > 0) |
1615 gaim_input_remove(od->paspa); | |
1616 od->paspa = 0; | |
8660 | 1617 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1618 "removing authconn input watcher\n"); |
4617 | 1619 aim_conn_kill(od->sess, &conn); |
3694 | 1620 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1621 if (od->emlpa > 0) |
1622 gaim_input_remove(od->emlpa); | |
1623 od->emlpa = 0; | |
8660 | 1624 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1625 "removing email input watcher\n"); |
4617 | 1626 aim_conn_kill(od->sess, &conn); |
4804 | 1627 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1628 if (od->icopa > 0) | |
1629 gaim_input_remove(od->icopa); | |
1630 od->icopa = 0; | |
8660 | 1631 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1632 "removing icon input watcher\n"); |
4804 | 1633 aim_conn_kill(od->sess, &conn); |
2086 | 1634 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1635 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1636 gaim_odc_disconnect(od->sess, conn); |
1637 aim_conn_kill(od->sess, &conn); | |
2086 | 1638 } else { |
8660 | 1639 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1640 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1641 conn->type); |
4617 | 1642 aim_conn_kill(od->sess, &conn); |
2086 | 1643 } |
1644 } | |
1645 } | |
1646 } | |
1647 } | |
1648 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1649 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1650 GaimConnection *gc = sess->aux_data; |
7285 | 1651 gchar *s = g_strdup_vprintf(format, va); |
1652 gchar *buf; | |
1653 | |
1654 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1655 gaim_debug_info("oscar", buf); |
7285 | 1656 if (buf[strlen(buf)-1] != '\n') |
8660 | 1657 gaim_debug_info(NULL, "\n"); |
7285 | 1658 g_free(buf); |
2086 | 1659 g_free(s); |
1660 } | |
1661 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1662 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1663 { |
5575 | 1664 GaimConnection *gc = data; |
7283 | 1665 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1666 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1667 aim_conn_t *conn; |
2086 | 1668 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1669 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1670 close(source); |
1671 return; | |
1672 } | |
1673 | |
4617 | 1674 od = gc->proto_data; |
1675 sess = od->sess; | |
2086 | 1676 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1677 conn->fd = source; |
2086 | 1678 |
1679 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1680 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1681 return; |
1682 } | |
1683 | |
1684 aim_conn_completeconnect(sess, conn); | |
4617 | 1685 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1686 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1687 | |
8660 | 1688 gaim_debug_info("oscar", |
7282 | 1689 "Screen name sent, waiting for response\n"); |
7283 | 1690 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1691 ck[1] = 0x65; |
2086 | 1692 } |
1693 | |
5575 | 1694 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1695 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1696 aim_conn_t *conn; |
5575 | 1697 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1698 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1699 |
8660 | 1700 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1701 |
8437 | 1702 if (!aim_snvalid(gaim_account_get_username(account))) { |
1703 gchar *buf; | |
8590 | 1704 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 | 1705 gaim_connection_error(gc, buf); |
1706 g_free(buf); | |
1707 } | |
1708 | |
9975 | 1709 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1710 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1711 } else { |
6622 | 1712 gc->flags |= GAIM_CONNECTION_HTML; |
1713 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1714 } |
5836 | 1715 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1716 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1717 sess = g_new0(aim_session_t, 1); |
7285 | 1718 aim_session_init(sess, TRUE, 0); |
2086 | 1719 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1720 /* |
1721 * We need an immediate queue because we don't use a while-loop | |
1722 * to see if things need to be sent. | |
1723 */ | |
2086 | 1724 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1725 od->sess = sess; |
2086 | 1726 sess->aux_data = gc; |
1727 | |
9935 | 1728 /* Connect to core Gaim signals */ |
9971 | 1729 od->recentbuddies_cbid = gaim_prefs_connect_callback("/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1730 |
2086 | 1731 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1732 if (conn == NULL) { | |
8660 | 1733 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1734 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1735 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1736 return; |
1737 } | |
1738 | |
4649 | 1739 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1740 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1741 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1742 | |
1743 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1744 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1745 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1746 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1747 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1748 return; |
1749 } | |
7282 | 1750 |
7283 | 1751 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1752 ck[0] = 0x5a; |
5575 | 1753 } |
1754 | |
1755 static void oscar_close(GaimConnection *gc) { | |
7283 | 1756 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1757 |
1758 while (od->oscar_chats) { | |
1759 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1760 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1761 gaim_input_remove(n->inpa); |
2086 | 1762 g_free(n->name); |
1763 g_free(n->show); | |
4617 | 1764 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1765 g_free(n); |
1766 } | |
4617 | 1767 while (od->direct_ims) { |
8971 | 1768 struct oscar_direct_im *n = od->direct_ims->data; |
1769 oscar_direct_im_destroy(od, n); | |
2086 | 1770 } |
4617 | 1771 /* BBB */ |
1772 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1773 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1774 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1775 gaim_xfer_cancel_local(xfer); |
3630 | 1776 } |
4804 | 1777 while (od->requesticon) { |
1778 char *sn = od->requesticon->data; | |
1779 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1780 free(sn); | |
1781 } | |
4738 | 1782 g_hash_table_destroy(od->buddyinfo); |
4617 | 1783 while (od->create_rooms) { |
1784 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1785 g_free(cr->name); |
4617 | 1786 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1787 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1788 } |
4617 | 1789 if (od->email) |
1790 g_free(od->email); | |
1791 if (od->newp) | |
1792 g_free(od->newp); | |
1793 if (od->oldp) | |
1794 g_free(od->oldp); | |
2086 | 1795 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1796 gaim_input_remove(gc->inpa); |
4617 | 1797 if (od->cnpa > 0) |
1798 gaim_input_remove(od->cnpa); | |
1799 if (od->paspa > 0) | |
1800 gaim_input_remove(od->paspa); | |
1801 if (od->emlpa > 0) | |
1802 gaim_input_remove(od->emlpa); | |
4804 | 1803 if (od->icopa > 0) |
1804 gaim_input_remove(od->icopa); | |
6907 | 1805 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1806 gaim_timeout_remove(od->icontimer); |
8341 | 1807 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1808 gaim_timeout_remove(od->getblisttimer); |
8341 | 1809 if (od->getinfotimer > 0) |
1810 gaim_timeout_remove(od->getinfotimer); | |
9975 | 1811 gaim_prefs_disconnect_callback(od->recentbuddies_cbid); |
9971 | 1812 |
4617 | 1813 aim_session_kill(od->sess); |
1814 g_free(od->sess); | |
1815 od->sess = NULL; | |
2086 | 1816 g_free(gc->proto_data); |
1817 gc->proto_data = NULL; | |
8660 | 1818 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1819 } |
1820 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1821 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1822 GaimConnection *gc = data; |
7283 | 1823 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1824 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1825 aim_conn_t *bosconn; |
2086 | 1826 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1827 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1828 close(source); |
1829 return; | |
1830 } | |
1831 | |
4617 | 1832 od = gc->proto_data; |
1833 sess = od->sess; | |
1834 bosconn = od->conn; | |
4366 | 1835 bosconn->fd = source; |
2086 | 1836 |
1837 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1838 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1839 return; |
1840 } | |
1841 | |
1842 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1843 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1844 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1845 gaim_connection_update_progress(gc, |
7283 | 1846 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1847 ck[4] = 0x61; |
2086 | 1848 } |
1849 | |
4617 | 1850 /* BBB */ |
4656 | 1851 /* |
1852 * This little area in oscar.c is the nexus of file transfer code, | |
1853 * so I wrote a little explanation of what happens. I am such a | |
1854 * ninja. | |
1855 * | |
1856 * The series of events for a file send is: | |
1857 * -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
|
1858 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1859 * listening socket, then asks the remote user to connect to us (and |
1860 * gives them the file name, port, IP, etc.) | |
1861 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1862 * in oscar_sendfile_estblsh) | |
1863 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1864 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1865 * connection. | |
1866 * -We get drunk because file transfer kicks ass. | |
1867 * | |
1868 * The series of events for a file receive is: | |
1869 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1870 * -Gaim user selects file to name and location to save file to and | |
1871 * oscar_xfer_init is called | |
1872 * -It connects to the remote user using the IP they gave us earlier | |
1873 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1874 * them an AIM_CB_OFT_ACK. | |
1875 * -They begin to send us lots of raw data. | |
1876 * -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
|
1877 * the connection. |
4656 | 1878 */ |
1879 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1880 | |
8446 | 1881 /* |
1882 * Miscellaneous xfer functions | |
1883 */ | |
1884 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1885 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1886 GaimXfer *xfer; |
5146 | 1887 struct aim_oft_info *oft_info; |
4656 | 1888 |
1889 while (fts) { | |
1890 xfer = fts->data; | |
5146 | 1891 oft_info = xfer->data; |
1892 | |
8446 | 1893 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1894 return xfer; |
1895 | |
1896 fts = g_slist_next(fts); | |
1897 } | |
1898 | |
1899 return NULL; | |
1900 } | |
1901 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1902 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1903 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1904 GaimXfer *xfer; |
5146 | 1905 struct aim_oft_info *oft_info; |
4656 | 1906 |
1907 while (fts) { | |
1908 xfer = fts->data; | |
5146 | 1909 oft_info = xfer->data; |
1910 | |
1911 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1912 return xfer; |
1913 | |
1914 fts = g_slist_next(fts); | |
1915 } | |
1916 | |
1917 return NULL; | |
1918 } | |
1919 | |
8446 | 1920 static void oscar_xfer_end(GaimXfer *xfer) |
1921 { | |
1922 struct aim_oft_info *oft_info = xfer->data; | |
1923 GaimConnection *gc = oft_info->sess->aux_data; | |
1924 OscarData *od = gc->proto_data; | |
1925 | |
8660 | 1926 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1927 |
1928 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1929 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1930 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1931 } | |
1932 | |
1933 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1934 aim_oft_destroyinfo(oft_info); | |
1935 xfer->data = NULL; | |
1936 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1937 } | |
1938 | |
1939 /* | |
1940 * xfer functions used when receiving files | |
1941 */ | |
1942 | |
1943 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1944 { | |
1945 struct aim_oft_info *oft_info = xfer->data; | |
1946 GaimConnection *gc = oft_info->sess->aux_data; | |
1947 OscarData *od = gc->proto_data; | |
1948 | |
8660 | 1949 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1950 |
1951 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1952 if (oft_info->conn) { | |
1953 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1954 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1955 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1956 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1957 if (xfer->fd == -1) { | |
1958 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1959 _("Unable to establish file descriptor.")); | |
1960 gaim_xfer_cancel_local(xfer); | |
1961 } | |
1962 } else { | |
1963 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1964 _("Unable to create new connection.")); | |
1965 gaim_xfer_cancel_local(xfer); | |
1966 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1967 } | |
1968 | |
1969 } | |
1970 | |
1971 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1972 { | |
1973 struct aim_oft_info *oft_info = xfer->data; | |
1974 GaimConnection *gc = oft_info->sess->aux_data; | |
1975 OscarData *od = gc->proto_data; | |
1976 | |
8660 | 1977 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1978 |
9771 | 1979 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1980 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1981 |
1982 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1983 aim_oft_destroyinfo(oft_info); | |
1984 xfer->data = NULL; | |
1985 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1986 } | |
1987 | |
1988 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1989 { | |
1990 struct aim_oft_info *oft_info = xfer->data; | |
1991 | |
1992 /* Update our rolling checksum. Like Walmart, yo. */ | |
1993 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
1994 } | |
1995 | |
1996 /* | |
1997 * xfer functions used when sending files | |
1998 */ | |
1999 | |
2000 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2001 { | |
2002 struct aim_oft_info *oft_info = xfer->data; | |
2003 GaimConnection *gc = oft_info->sess->aux_data; | |
2004 OscarData *od = gc->proto_data; | |
2005 int listenfd; | |
2006 | |
8660 | 2007 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2008 |
2009 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2010 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2011 oft_info->fh.name[63] = '\0'; | |
2012 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2013 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2014 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2015 | |
2016 /* Create a listening socket and an associated libfaim conn */ | |
2017 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2018 gaim_xfer_cancel_local(xfer); | |
2019 return; | |
2020 } | |
2021 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2022 oft_info->port = xfer->local_port; | |
2023 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2024 gaim_xfer_cancel_local(xfer); | |
2025 return; | |
2026 } | |
8660 | 2027 gaim_debug_misc("oscar", |
8446 | 2028 "port is %hu, ip is %s\n", |
2029 xfer->local_port, oft_info->clientip); | |
2030 if (oft_info->conn) { | |
2031 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2032 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2033 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2034 } else { | |
2035 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2036 _("Unable to establish listener socket.")); | |
2037 gaim_xfer_cancel_local(xfer); | |
2038 } | |
2039 } | |
2040 | |
2041 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2042 { | |
2043 struct aim_oft_info *oft_info = xfer->data; | |
2044 GaimConnection *gc = oft_info->sess->aux_data; | |
2045 OscarData *od = gc->proto_data; | |
2046 | |
8660 | 2047 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2048 |
9771 | 2049 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2050 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2051 |
2052 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2053 aim_oft_destroyinfo(oft_info); | |
2054 xfer->data = NULL; | |
2055 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2056 } | |
2057 | |
2058 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2059 { | |
2060 struct aim_oft_info *oft_info = xfer->data; | |
2061 | |
2062 /* I'm not sure I like how we do this. --marv | |
2063 * I do. AIM file transfers aren't really meant to be thought | |
2064 * of as a transferring just a single file. The rendezvous | |
2065 * establishes a connection between two computers, and then | |
2066 * those computers can use the same connection for transferring | |
2067 * multiple files. So we don't want the Gaim core up and closing | |
2068 * the socket all willy-nilly. We want to do that in the oscar | |
2069 * prpl, whenever one side or the other says they're finished | |
2070 * using the connection. There might be a better way to intercept | |
2071 * the socket from the core, however... --KingAnt | |
2072 */ | |
2073 | |
2074 /* | |
2075 * If we're done sending, intercept the socket from the core ft code | |
2076 * and wait for the other guy to send the "done" OFT packet. | |
2077 */ | |
2078 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2079 gaim_input_remove(xfer->watcher); | |
2080 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2081 xfer->fd = 0; | |
2082 gaim_xfer_set_completed(xfer, TRUE); | |
2083 } | |
2084 } | |
2085 | |
9466 | 2086 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2087 gboolean can_receive = FALSE; | |
2088 OscarData *od = gc->proto_data; | |
2089 | |
2090 if (!od->icq) { | |
2091 aim_userinfo_t *userinfo; | |
2092 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2093 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2094 can_receive = TRUE; | |
2095 } | |
2096 | |
2097 return can_receive; | |
2098 } | |
2099 | |
2100 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2101 |
2102 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2103 GaimXfer *xfer; |
5146 | 2104 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2105 const char *ip; |
3752 | 2106 |
9030 | 2107 od = (OscarData *)gc->proto_data; |
2108 | |
4617 | 2109 /* You want to send a file to someone else, you're so generous */ |
2110 | |
2111 /* Build the file transfer handle */ | |
9466 | 2112 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2113 |
5146 | 2114 /* Create the oscar-specific data */ |
8838 | 2115 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2116 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2117 xfer->data = oft_info; |
2118 | |
4617 | 2119 /* Setup our I/O op functions */ |
8446 | 2120 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2121 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2122 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2123 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2124 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2125 |
2126 /* Keep track of this transfer for later */ | |
2127 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2128 | |
2129 /* Now perform the request */ | |
9466 | 2130 if (file) |
2131 gaim_xfer_request_accepted(xfer, file); | |
2132 else | |
2133 gaim_xfer_request(xfer); | |
3630 | 2134 } |
2135 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2136 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2137 GaimConnection *gc = sess->aux_data; |
7283 | 2138 OscarData *od = gc->proto_data; |
6029 | 2139 GaimAccount *account = gc->account; |
2140 aim_conn_t *bosconn; | |
2141 char *host; int port; | |
2142 int i, rc; | |
2086 | 2143 va_list ap; |
2704 | 2144 struct aim_authresp_info *info; |
6029 | 2145 |
5575 | 2146 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2147 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2148 va_start(ap, fr); |
2704 | 2149 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2150 va_end(ap); |
2151 | |
8660 | 2152 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2153 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2154 |
4293 | 2155 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2156 char buf[256]; |
2704 | 2157 switch (info->errorcode) { |
2086 | 2158 case 0x05: |
2159 /* Incorrect nick/password */ | |
6498 | 2160 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2161 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2162 break; |
2163 case 0x11: | |
2164 /* Suspended account */ | |
6498 | 2165 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2166 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2167 break; |
3498 | 2168 case 0x14: |
2169 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2170 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2171 break; |
2086 | 2172 case 0x18: |
2173 /* connecting too frequently */ | |
6498 | 2174 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2175 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 | 2176 break; |
2177 case 0x1c: | |
2178 /* client too old */ | |
6498 | 2179 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2180 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
|
2181 gaim_connection_error(gc, buf); |
2086 | 2182 break; |
2183 default: | |
6623 | 2184 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2185 break; |
2186 } | |
8660 | 2187 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2188 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2189 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2190 "Error URL: %s\n", info->errorurl); |
2086 | 2191 od->killme = TRUE; |
2192 return 1; | |
2193 } | |
2194 | |
2195 | |
8660 | 2196 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2197 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2198 |
2704 | 2199 if (info->email) { |
8660 | 2200 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2201 } else { |
8660 | 2202 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2203 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2204 |
8660 | 2205 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2206 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2207 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2208 aim_conn_kill(sess, &fr->conn); |
2086 | 2209 |
2210 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2211 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2212 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2213 od->killme = TRUE; |
2214 return 0; | |
2215 } | |
2216 | |
4649 | 2217 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2218 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2219 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2220 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2221 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2222 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2223 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2224 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2225 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2226 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2227 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2228 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2229 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2230 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2231 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2232 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2234 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2235 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2237 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2239 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
|
2240 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2241 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2242 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2243 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2244 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2245 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2246 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
|
2247 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
|
2248 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
|
2249 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2250 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2251 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2252 #ifndef NOSSI |
4642 | 2253 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2254 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2255 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2256 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2257 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2258 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2259 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2260 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2261 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2262 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2263 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2264 |
7283 | 2265 od->conn = bosconn; |
2704 | 2266 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2267 if (info->bosip[i] == ':') { | |
2268 port = atoi(&(info->bosip[i+1])); | |
2086 | 2269 break; |
2270 } | |
2271 } | |
2704 | 2272 host = g_strndup(info->bosip, i); |
2086 | 2273 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2274 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2275 g_free(host); |
4366 | 2276 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2277 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2278 od->killme = TRUE; |
2279 return 0; | |
2280 } | |
4293 | 2281 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2282 gaim_input_remove(gc->inpa); |
2704 | 2283 |
7283 | 2284 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2285 ck[3] = 0x64; |
7282 | 2286 |
2086 | 2287 return 1; |
2288 } | |
2289 | |
7285 | 2290 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2291 struct pieceofcrap { |
5575 | 2292 GaimConnection *gc; |
2086 | 2293 unsigned long offset; |
2294 unsigned long len; | |
2295 char *modname; | |
2296 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2297 aim_conn_t *conn; |
2086 | 2298 unsigned int inpa; |
2299 }; | |
2300 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2301 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2302 { |
2303 struct pieceofcrap *pos = data; | |
7283 | 2304 OscarData *od = pos->gc->proto_data; |
2086 | 2305 char in = '\0'; |
2306 int x = 0; | |
2307 unsigned char m[17]; | |
2308 | |
2309 while (read(pos->fd, &in, 1) == 1) { | |
2310 if (in == '\n') | |
2311 x++; | |
2312 else if (in != '\r') | |
2313 x = 0; | |
2314 if (x == 2) | |
2315 break; | |
2316 in = '\0'; | |
2317 } | |
2318 if (in != '\n') { | |
4056 | 2319 char buf[256]; |
2320 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
|
2321 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2322 gaim_notify_warning(pos->gc, NULL, |
7422 | 2323 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2324 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2325 gaim_input_remove(pos->inpa); |
2086 | 2326 close(pos->fd); |
2327 g_free(pos); | |
2328 return; | |
2329 } | |
2330 read(pos->fd, m, 16); | |
2331 m[16] = '\0'; | |
8660 | 2332 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2333 for (x = 0; x < 16; x++) |
8660 | 2334 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2335 | |
2336 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2337 gaim_input_remove(pos->inpa); |
2086 | 2338 close(pos->fd); |
2339 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2340 g_free(pos); | |
2341 } | |
2342 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2343 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2344 struct pieceofcrap *pos = data; |
5420 | 2345 gchar *buf; |
2086 | 2346 |
4366 | 2347 pos->fd = source; |
2348 | |
2086 | 2349 if (source < 0) { |
5420 | 2350 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
|
2351 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2352 gaim_notify_warning(pos->gc, NULL, |
7422 | 2353 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2354 buf); |
5420 | 2355 g_free(buf); |
2086 | 2356 if (pos->modname) |
2357 g_free(pos->modname); | |
2358 g_free(pos); | |
2359 return; | |
2360 } | |
2361 | |
5420 | 2362 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2363 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2364 write(pos->fd, buf, strlen(buf)); | |
5420 | 2365 g_free(buf); |
2086 | 2366 if (pos->modname) |
2367 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2368 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2369 return; |
2370 } | |
2371 | |
2372 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2373 #define AIM_MAX_FILE_SIZE 98304 | |
2374 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2375 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2376 va_list ap; |
2377 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2378 fu32_t offset, len; |
2086 | 2379 char *modname; |
2380 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2381 va_start(ap, fr); |
4200 | 2382 offset = va_arg(ap, fu32_t); |
2383 len = va_arg(ap, fu32_t); | |
2086 | 2384 modname = va_arg(ap, char *); |
2385 va_end(ap); | |
2386 | |
8660 | 2387 gaim_debug_misc("oscar", |
5556 | 2388 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2389 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2390 |
2086 | 2391 if (len == 0) { |
8660 | 2392 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2393 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2394 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2395 return 1; | |
2396 } | |
9625 | 2397 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2398 #if 0 | |
2086 | 2399 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2400 char *buf; | |
2401 int i = 8; | |
2402 if (modname) | |
2403 i += strlen(modname); | |
2404 buf = g_malloc(i); | |
2405 i = 0; | |
2406 if (modname) { | |
2407 memcpy(buf, modname, strlen(modname)); | |
2408 i += strlen(modname); | |
2409 } | |
2410 buf[i++] = offset & 0xff; | |
2411 buf[i++] = (offset >> 8) & 0xff; | |
2412 buf[i++] = (offset >> 16) & 0xff; | |
2413 buf[i++] = (offset >> 24) & 0xff; | |
2414 buf[i++] = len & 0xff; | |
2415 buf[i++] = (len >> 8) & 0xff; | |
2416 buf[i++] = (len >> 16) & 0xff; | |
2417 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2418 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2419 "hashing request\n"); |
2086 | 2420 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2421 g_free(buf); | |
2422 return 1; | |
2423 } | |
9625 | 2424 #endif |
2086 | 2425 |
2426 pos = g_new0(struct pieceofcrap, 1); | |
2427 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2428 pos->conn = fr->conn; |
2086 | 2429 |
2430 pos->offset = offset; | |
2431 pos->len = len; | |
2432 pos->modname = modname ? g_strdup(modname) : NULL; | |
2433 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2434 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2435 char buf[256]; |
2086 | 2436 if (pos->modname) |
2437 g_free(pos->modname); | |
2438 g_free(pos); | |
4056 | 2439 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
|
2440 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2441 gaim_notify_warning(pos->gc, NULL, |
7422 | 2442 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2443 buf); |
2086 | 2444 } |
2445 | |
2446 return 1; | |
2447 } | |
2448 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2449 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2450 GaimConnection *gc = sess->aux_data; |
7283 | 2451 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2452 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2453 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2454 #if 0 |
2455 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2456 #endif | |
7011 | 2457 va_list ap; |
2458 char *key; | |
2086 | 2459 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2460 va_start(ap, fr); |
2086 | 2461 key = va_arg(ap, char *); |
2462 va_end(ap); | |
2463 | |
4617 | 2464 if (od->icq) { |
3458 | 2465 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2466 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2467 gaim_account_get_password(account), &info, key); |
3458 | 2468 } else { |
2469 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2470 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2471 gaim_account_get_password(account), &info, key); |
3458 | 2472 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2473 |
7283 | 2474 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2475 ck[2] = 0x6c; |
7282 | 2476 |
2086 | 2477 return 1; |
2478 } | |
2479 | |
2675 | 2480 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2481 GaimConnection *gc = sess->aux_data; |
2647 | 2482 struct chat_connection *chatcon; |
2483 static int id = 1; | |
2484 | |
6905 | 2485 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
|
2486 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
|
2487 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
|
2488 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
|
2489 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2490 |
2672 | 2491 aim_clientready(sess, fr->conn); |
2675 | 2492 |
2647 | 2493 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2494 chatcon->id = id; | |
8733 | 2495 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2496 |
2497 return 1; | |
2498 } | |
2499 | |
2675 | 2500 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2501 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2502 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2503 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2504 |
2505 aim_clientready(sess, fr->conn); | |
2506 | |
2507 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2508 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2509 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2510 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2511 |
3694 | 2512 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2513 | |
2514 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2515 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2516 | |
7282 | 2517 aim_email_sendcookies(sess); |
2518 aim_email_activate(sess); | |
3694 | 2519 aim_clientready(sess, fr->conn); |
2520 | |
2521 return 1; | |
2522 } | |
2523 | |
4804 | 2524 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2525 GaimConnection *gc = sess->aux_data; |
7283 | 2526 OscarData *od = gc->proto_data; |
4804 | 2527 |
2528 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2529 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2530 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2531 | |
2532 aim_clientready(sess, fr->conn); | |
2533 | |
4823 | 2534 od->iconconnecting = FALSE; |
2535 | |
4804 | 2536 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2537 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2538 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2539 |
2540 return 1; | |
2541 } | |
2542 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2543 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2544 GaimConnection *gc = data; |
7283 | 2545 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2546 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2547 aim_conn_t *tstconn; |
2086 | 2548 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2549 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2550 close(source); |
2551 return; | |
2552 } | |
2553 | |
4617 | 2554 od = gc->proto_data; |
2555 sess = od->sess; | |
2086 | 2556 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2557 tstconn->fd = source; |
2086 | 2558 |
2559 if (source < 0) { | |
2560 aim_conn_kill(sess, &tstconn); | |
8660 | 2561 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2562 "unable to connect to chatnav server\n"); |
2086 | 2563 return; |
2564 } | |
2565 | |
2566 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2567 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2568 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2569 } |
2570 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2571 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2572 { |
5575 | 2573 GaimConnection *gc = data; |
7283 | 2574 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2575 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2576 aim_conn_t *tstconn; |
2086 | 2577 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2578 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2579 close(source); |
2580 return; | |
2581 } | |
2582 | |
4617 | 2583 od = gc->proto_data; |
2584 sess = od->sess; | |
2086 | 2585 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2586 tstconn->fd = source; |
2086 | 2587 |
2588 if (source < 0) { | |
2589 aim_conn_kill(sess, &tstconn); | |
8660 | 2590 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2591 "unable to connect to authorizer\n"); |
2086 | 2592 return; |
2593 } | |
2594 | |
2595 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2596 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2597 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2598 } |
2599 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2600 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2601 { |
2602 struct chat_connection *ccon = data; | |
5575 | 2603 GaimConnection *gc = ccon->gc; |
7283 | 2604 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2605 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2606 aim_conn_t *tstconn; |
2086 | 2607 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2608 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2609 close(source); |
2610 g_free(ccon->show); | |
2611 g_free(ccon->name); | |
2612 g_free(ccon); | |
2613 return; | |
2614 } | |
2615 | |
4617 | 2616 od = gc->proto_data; |
2617 sess = od->sess; | |
2086 | 2618 tstconn = ccon->conn; |
4366 | 2619 tstconn->fd = source; |
2086 | 2620 |
2621 if (source < 0) { | |
2622 aim_conn_kill(sess, &tstconn); | |
2623 g_free(ccon->show); | |
2624 g_free(ccon->name); | |
2625 g_free(ccon); | |
2626 return; | |
2627 } | |
2628 | |
2629 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2630 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2631 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2632 } |
2633 | |
3694 | 2634 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2635 GaimConnection *gc = data; |
7283 | 2636 OscarData *od; |
3694 | 2637 aim_session_t *sess; |
2638 aim_conn_t *tstconn; | |
2639 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2640 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2641 close(source); |
2642 return; | |
2643 } | |
2644 | |
4617 | 2645 od = gc->proto_data; |
2646 sess = od->sess; | |
3694 | 2647 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2648 tstconn->fd = source; |
3694 | 2649 |
2650 if (source < 0) { | |
2651 aim_conn_kill(sess, &tstconn); | |
8660 | 2652 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2653 "unable to connect to email server\n"); |
3694 | 2654 return; |
2655 } | |
2656 | |
2657 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2658 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2659 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2660 "email: connected\n"); |
3694 | 2661 } |
2662 | |
4804 | 2663 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2664 GaimConnection *gc = data; |
7283 | 2665 OscarData *od; |
4804 | 2666 aim_session_t *sess; |
2667 aim_conn_t *tstconn; | |
2668 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2669 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2670 close(source); |
2671 return; | |
2672 } | |
2673 | |
2674 od = gc->proto_data; | |
2675 sess = od->sess; | |
2676 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2677 tstconn->fd = source; | |
2678 | |
2679 if (source < 0) { | |
2680 aim_conn_kill(sess, &tstconn); | |
8660 | 2681 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2682 "unable to connect to icon server\n"); |
4804 | 2683 return; |
2684 } | |
2685 | |
2686 aim_conn_completeconnect(sess, tstconn); | |
2687 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2688 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2689 } |
2690 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2691 /* 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
|
2692 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2693 GaimConnection *gc = sess->aux_data; |
2694 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2695 aim_conn_t *tstconn; |
4452 | 2696 int i; |
2086 | 2697 char *host; |
2698 int port; | |
4821 | 2699 va_list ap; |
2700 struct aim_redirect_data *redir; | |
2086 | 2701 |
5575 | 2702 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2703 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2704 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2705 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2706 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2707 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2708 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2709 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2710 port = atoi(&(redir->ip[i+1])); |
2086 | 2711 break; |
2712 } | |
2713 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2714 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2715 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2716 switch(redir->group) { |
2086 | 2717 case 0x7: /* Authorizer */ |
8660 | 2718 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2719 "Reconnecting with authorizor...\n"); |
2086 | 2720 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2721 if (tstconn == NULL) { | |
8660 | 2722 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2723 "unable to reconnect with authorizer\n"); |
2086 | 2724 g_free(host); |
2725 return 1; | |
2726 } | |
4649 | 2727 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2728 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2729 |
2730 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2731 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2732 aim_conn_kill(sess, &tstconn); |
8660 | 2733 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2734 "unable to reconnect with authorizer\n"); |
2086 | 2735 g_free(host); |
2736 return 1; | |
2737 } | |
4293 | 2738 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2739 break; |
2740 | |
2086 | 2741 case 0xd: /* ChatNav */ |
2742 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2743 if (tstconn == NULL) { | |
8660 | 2744 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2745 "unable to connect to chatnav server\n"); |
2086 | 2746 g_free(host); |
2747 return 1; | |
2748 } | |
4649 | 2749 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2750 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2751 |
2752 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2753 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2754 aim_conn_kill(sess, &tstconn); |
8660 | 2755 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2756 "unable to connect to chatnav server\n"); |
2086 | 2757 g_free(host); |
2758 return 1; | |
2759 } | |
4293 | 2760 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2761 break; |
2762 | |
2763 case 0xe: { /* Chat */ | |
2086 | 2764 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2765 |
2086 | 2766 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2767 if (tstconn == NULL) { | |
8660 | 2768 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2769 "unable to connect to chat server\n"); |
2086 | 2770 g_free(host); |
2771 return 1; | |
2772 } | |
2773 | |
4649 | 2774 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2775 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2776 | |
2086 | 2777 ccon = g_new0(struct chat_connection, 1); |
2778 ccon->conn = tstconn; | |
2779 ccon->gc = gc; | |
2780 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2781 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2782 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2783 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2784 ccon->show = extract_name(redir->chat.room); |
4634 | 2785 |
2086 | 2786 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2787 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2788 aim_conn_kill(sess, &tstconn); |
8660 | 2789 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2790 "unable to connect to chat server\n"); |
2086 | 2791 g_free(host); |
2792 g_free(ccon->show); | |
2793 g_free(ccon->name); | |
2794 g_free(ccon); | |
2795 return 1; | |
2796 } | |
4293 | 2797 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2798 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2799 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2800 ccon->name, ccon->exchange); |
4194 | 2801 } break; |
3694 | 2802 |
4804 | 2803 case 0x0010: { /* icon */ |
2804 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2805 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2806 "unable to connect to icon server\n"); |
4804 | 2807 g_free(host); |
2808 return 1; | |
2809 } | |
2810 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2811 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2812 | |
2813 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2814 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2815 aim_conn_kill(sess, &tstconn); |
8660 | 2816 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2817 "unable to connect to icon server\n"); |
4804 | 2818 g_free(host); |
2819 return 1; | |
2820 } | |
2821 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2822 } break; | |
2823 | |
3694 | 2824 case 0x0018: { /* email */ |
2825 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2826 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2827 "unable to connect to email server\n"); |
3694 | 2828 g_free(host); |
2829 return 1; | |
2830 } | |
4649 | 2831 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2832 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2833 | |
2834 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2835 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2836 aim_conn_kill(sess, &tstconn); |
8660 | 2837 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2838 "unable to connect to email server\n"); |
3694 | 2839 g_free(host); |
2840 return 1; | |
2841 } | |
4293 | 2842 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2843 } break; |
2844 | |
2086 | 2845 default: /* huh? */ |
8660 | 2846 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2847 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2848 redir->group); |
2086 | 2849 break; |
2850 } | |
2851 | |
2852 g_free(host); | |
2853 return 1; | |
2854 } | |
2855 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2856 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2857 GaimConnection *gc = sess->aux_data; |
9058 | 2858 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 2859 OscarData *od = gc->proto_data; |
4738 | 2860 struct buddyinfo *bi; |
2993 | 2861 time_t time_idle = 0, signon = 0; |
2862 int type = 0; | |
2863 int caps = 0; | |
2086 | 2864 va_list ap; |
4738 | 2865 aim_userinfo_t *info; |
4194 | 2866 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2867 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2868 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2869 va_end(ap); |
2870 | |
2993 | 2871 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2872 caps = info->capabilities; | |
3267 | 2873 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
2874 type |= UC_AB; | |
2875 | |
4766 | 2876 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2877 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
2878 type |= UC_UNCONFIRMED; | |
2879 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
2880 type |= UC_ADMIN; | |
2881 if (info->flags & AIM_FLAG_AOL) | |
2882 type |= UC_AOL; | |
2883 if (info->flags & AIM_FLAG_FREE) | |
2884 type |= UC_NORMAL; | |
2885 if (info->flags & AIM_FLAG_AWAY) | |
2886 type |= UC_UNAVAILABLE; | |
2887 if (info->flags & AIM_FLAG_WIRELESS) | |
2888 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2889 } |
2993 | 2890 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2891 type = (info->icqinfo.status << 16); |
3013 | 2892 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2893 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 2894 type |= UC_UNAVAILABLE; |
3013 | 2895 } |
2993 | 2896 } |
2897 | |
7141 | 2898 if (caps & AIM_CAPS_ICQ_DIRECT) |
2899 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2900 |
2901 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2902 time(&time_idle); |
2903 time_idle -= info->idletime*60; | |
9295 | 2904 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2905 } |
2906 | |
5836 | 2907 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2908 signon = info->onlinesince; | |
2909 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2910 signon = time(NULL) - info->sessionlen; |
2086 | 2911 |
5575 | 2912 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
2913 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2914 |
7261 | 2915 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
4738 | 2916 if (!bi) { |
2917 bi = g_new0(struct buddyinfo, 1); | |
7261 | 2918 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
4738 | 2919 } |
4739 | 2920 bi->typingnot = FALSE; |
2921 bi->ico_informed = FALSE; | |
6857 | 2922 bi->ipaddr = info->icqinfo.ipaddr; |
2923 | |
2924 /* Available message stuff */ | |
6292 | 2925 free(bi->availmsg); |
7011 | 2926 if (info->avail != NULL) |
8225 | 2927 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2928 else |
6292 | 2929 bi->availmsg = NULL; |
4732 | 2930 |
4804 | 2931 /* Server stored icon stuff */ |
4853 | 2932 if (info->iconcsumlen) { |
7125 | 2933 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2934 char *b16 = NULL, *filepath = NULL; |
7093 | 2935 GaimBuddy *b = NULL; |
4853 | 2936 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2937 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
4853 | 2938 b = gaim_find_buddy(gc->account, info->sn); |
7093 | 2939 /* |
2940 * If for some reason the checksum is valid, but cached file is not.. | |
2941 * we want to know. | |
2942 */ | |
7693 | 2943 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2944 if (filename != NULL) { |
2945 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2946 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2947 "icon_checksum"); | |
9801 | 2948 else { |
2949 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2950 filename, NULL); | |
2951 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2952 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2953 "icon_checksum"); | |
2954 g_free(filepath); | |
2955 } | |
7093 | 2956 } else |
2957 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2958 |
4853 | 2959 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2960 GSList *cur = od->requesticon; | |
2961 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2962 cur = cur->next; | |
2963 if (!cur) { | |
7475 | 2964 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
4853 | 2965 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2966 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2967 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2968 } |
2969 } | |
6053 | 2970 g_free(b16); |
4853 | 2971 } |
2972 | |
9058 | 2973 /* |
2974 * If we have info for ourselves, then update our local warning | |
2975 * level and set our official time of login. Is this necessary? | |
2976 * XXX - This needs to be changed some how. evil should not be | |
2977 * handled by the core at all? | |
2978 */ | |
2979 if (!aim_sncmp(info->sn, gaim_account_get_username(account))) { | |
2980 gc->evil = (info->warnlevel/10.0); | |
2981 gc->login_time_official = signon; | |
2982 } | |
2983 | |
9976 | 2984 /* STATUS - time_idle is idle time, type is type, info->warnlevel/10.0 is warning level */ |
2985 serv_got_update(gc, info->sn, TRUE, signon); | |
2086 | 2986 |
2987 return 1; | |
2988 } | |
2989 | |
8341 | 2990 static void gaim_check_comment(OscarData *od, const char *str) { |
2991 if ((str == NULL) || strcmp(str, ck)) | |
2992 aim_locate_setcaps(od->sess, caps_aim); | |
2993 else | |
2994 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2995 } | |
2996 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2997 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2998 GaimConnection *gc = sess->aux_data; |
7283 | 2999 OscarData *od = gc->proto_data; |
2086 | 3000 va_list ap; |
4739 | 3001 aim_userinfo_t *info; |
2086 | 3002 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3003 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3004 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3005 va_end(ap); |
3006 | |
9976 | 3007 serv_got_update(gc, info->sn, FALSE, 0); |
2086 | 3008 |
7261 | 3009 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3010 |
2086 | 3011 return 1; |
3012 } | |
3013 | |
4617 | 3014 /* BBB */ |
3952 | 3015 /* |
4617 | 3016 * This is called after a remote AIM user has connected to us. We |
3017 * want to do some voodoo with the socket file descriptors, add a | |
3018 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3019 */ |
4656 | 3020 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3021 GaimConnection *gc = sess->aux_data; |
7283 | 3022 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3023 GaimXfer *xfer; |
5146 | 3024 struct aim_oft_info *oft_info; |
3630 | 3025 va_list ap; |
3026 aim_conn_t *conn, *listenerconn; | |
4656 | 3027 |
8660 | 3028 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3029 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3030 va_start(ap, fr); |
3031 conn = va_arg(ap, aim_conn_t *); | |
3032 listenerconn = va_arg(ap, aim_conn_t *); | |
3033 va_end(ap); | |
3034 | |
4617 | 3035 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3036 return 1; | |
3037 | |
5146 | 3038 if (!(oft_info = xfer->data)) |
4617 | 3039 return 1; |
3040 | |
3630 | 3041 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3042 gaim_input_remove(xfer->watcher); |
3630 | 3043 aim_conn_kill(sess, &listenerconn); |
3044 | |
5146 | 3045 oft_info->conn = conn; |
3046 xfer->fd = oft_info->conn->fd; | |
3047 | |
3048 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3049 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3050 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3051 |
3052 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3053 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3054 |
3055 return 0; | |
3056 } | |
3057 | |
3952 | 3058 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3059 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3060 * user in order to transfer a file. |
3952 | 3061 */ |
4617 | 3062 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
|
3063 GaimXfer *xfer; |
5146 | 3064 struct aim_oft_info *oft_info; |
4656 | 3065 |
8660 | 3066 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3067 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3068 if (!(xfer = data)) |
3069 return; | |
5146 | 3070 if (!(oft_info = xfer->data)) |
3630 | 3071 return; |
8446 | 3072 if (source < 0) { |
3073 gaim_xfer_cancel_remote(xfer); | |
4617 | 3074 return; |
8446 | 3075 } |
4617 | 3076 |
3077 xfer->fd = source; | |
5146 | 3078 oft_info->conn->fd = source; |
3079 | |
3080 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3081 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3082 |
3083 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3084 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3085 |
3086 return; | |
3630 | 3087 } |
3088 | |
3952 | 3089 /* |
4617 | 3090 * This is called when a buddy sends us some file info. This happens when they |
3091 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3092 * You should send them the exact same info except use the real cookie. We also |
4617 | 3093 * get like totally ready to like, receive the file, kay? |
3952 | 3094 */ |
4617 | 3095 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3096 GaimConnection *gc = sess->aux_data; |
7283 | 3097 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3098 GaimXfer *xfer; |
5146 | 3099 struct aim_oft_info *oft_info; |
4617 | 3100 va_list ap; |
3101 aim_conn_t *conn; | |
3102 fu8_t *cookie; | |
3103 struct aim_fileheader_t *fh; | |
4656 | 3104 |
8660 | 3105 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3106 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3107 va_start(ap, fr); |
3108 conn = va_arg(ap, aim_conn_t *); | |
3109 cookie = va_arg(ap, fu8_t *); | |
3110 fh = va_arg(ap, struct aim_fileheader_t *); | |
3111 va_end(ap); | |
3112 | |
3113 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3114 return 1; | |
3115 | |
5146 | 3116 if (!(oft_info = xfer->data)) |
4617 | 3117 return 1; |
3118 | |
3119 /* We want to stop listening with a normal thingy */ | |
3120 gaim_input_remove(xfer->watcher); | |
3121 xfer->watcher = 0; | |
3122 | |
5146 | 3123 /* They sent us some information about the file they're sending */ |
3124 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3125 | |
3126 /* Fill in the cookie */ | |
3127 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3128 | |
4617 | 3129 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3130 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3131 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3132 | |
3133 return 0; | |
3630 | 3134 } |
3135 | |
3952 | 3136 /* |
4657 | 3137 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3138 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3139 */ |
4617 | 3140 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3141 GaimConnection *gc = sess->aux_data; |
7283 | 3142 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3143 GaimXfer *xfer; |
4617 | 3144 va_list ap; |
3145 aim_conn_t *conn; | |
3146 fu8_t *cookie; | |
3147 struct aim_fileheader_t *fh; | |
4656 | 3148 |
8660 | 3149 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3150 va_start(ap, fr); |
3151 conn = va_arg(ap, aim_conn_t *); | |
3152 cookie = va_arg(ap, fu8_t *); | |
3153 fh = va_arg(ap, struct aim_fileheader_t *); | |
3154 va_end(ap); | |
3155 | |
3156 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3157 return 1; | |
3158 | |
4656 | 3159 /* We want to stop listening with a normal thingy */ |
3160 gaim_input_remove(xfer->watcher); | |
3161 xfer->watcher = 0; | |
3162 | |
4617 | 3163 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3164 | |
3165 return 0; | |
3630 | 3166 } |
4617 | 3167 |
3168 /* | |
3169 * We just sent a file to someone. They said they got it and everything, | |
3170 * so we can close our direct connection and what not. | |
3171 */ | |
3172 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3173 GaimConnection *gc = sess->aux_data; |
7283 | 3174 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3175 GaimXfer *xfer; |
4617 | 3176 va_list ap; |
3177 aim_conn_t *conn; | |
3178 fu8_t *cookie; | |
3179 struct aim_fileheader_t *fh; | |
4656 | 3180 |
8660 | 3181 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3182 va_start(ap, fr); |
3183 conn = va_arg(ap, aim_conn_t *); | |
3184 cookie = va_arg(ap, fu8_t *); | |
3185 fh = va_arg(ap, struct aim_fileheader_t *); | |
3186 va_end(ap); | |
3187 | |
3188 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3189 return 1; | |
3190 | |
4656 | 3191 xfer->fd = conn->fd; |
4617 | 3192 gaim_xfer_end(xfer); |
3193 | |
3194 return 0; | |
3195 } | |
3630 | 3196 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3197 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3198 GaimConnection *gc = sess->aux_data; |
7283 | 3199 OscarData *od = gc->proto_data; |
8708 | 3200 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3201 GaimConvImFlags flags = 0; |
4738 | 3202 struct buddyinfo *bi; |
5575 | 3203 const char *iconfile; |
9806 | 3204 GString *message; |
3205 gchar *tmp; | |
3206 aim_mpmsg_section_t *curpart; | |
3207 | |
3208 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3209 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3210 |
8708 | 3211 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3212 if (!bi) { |
3213 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3214 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3215 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3216 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3217 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3218 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3219 |
4738 | 3220 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3221 bi->typingnot = TRUE; | |
3222 else | |
3223 bi->typingnot = FALSE; | |
3224 | |
4380 | 3225 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3226 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3227 "%s has an icon\n", userinfo->sn); |
4738 | 3228 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3229 bi->ico_need = TRUE; | |
3230 bi->ico_len = args->iconlen; | |
3231 bi->ico_csum = args->iconsum; | |
3232 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3233 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3234 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3235 |
8708 | 3236 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3237 (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
|
3238 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3239 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3240 |
5575 | 3241 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3242 char *buf = g_malloc(st.st_size); |
5575 | 3243 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3244 if (file) { |
9532 | 3245 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3246 int len = fread(buf, 1, st.st_size, file); |
8660 | 3247 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3248 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3249 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3250 userinfo->sn, len, st.st_size); |
4617 | 3251 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3252 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3253 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3254 } else |
8660 | 3255 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3256 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3257 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3258 } else |
8660 | 3259 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3260 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3261 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3262 |
9806 | 3263 message = g_string_new(""); |
3264 curpart = args->mpmsg.parts; | |
3265 while (curpart != NULL) { | |
9908 | 3266 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3267 curpart->data, curpart->datalen); |
3268 if (tmp != NULL) { | |
3269 g_string_append(message, tmp); | |
3270 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3271 } |
9806 | 3272 |
3273 curpart = curpart->next; | |
3274 } | |
3275 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3276 |
8666 | 3277 /* |
8995 | 3278 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3279 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3280 * so any HTML we receive is intended to be displayed |
3281 * | |
3282 * Note: There *may* be some clients which send messages as HTML formatted - | |
3283 * they need to be special-cased somehow. | |
8666 | 3284 */ |
9975 | 3285 if (aim_sn_is_icq(gaim_account_get_username(account) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3286 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3287 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3288 g_free(tmp); |
3289 tmp = tmp2; | |
3290 } | |
3291 | |
6982 | 3292 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3293 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3294 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3295 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3296 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3297 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3298 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3299 GaimConnection *gc; |
9933 | 3300 GaimAccount *account; |
9070 | 3301 OscarData *od; |
9933 | 3302 const char *username = NULL; |
3303 char *message = NULL; | |
9070 | 3304 |
3305 g_return_val_if_fail(sess != NULL, 0); | |
3306 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3307 | |
3308 gc = sess->aux_data; | |
9933 | 3309 account = gaim_connection_get_account(gc); |
9070 | 3310 od = gc->proto_data; |
9933 | 3311 username = gaim_account_get_username(account); |
3312 | |
3313 if (args == NULL) | |
4121 | 3314 return 0; |
4194 | 3315 |
9933 | 3316 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3317 userinfo->sn, args->status); | |
3318 | |
3319 if (args->msg != NULL) | |
3320 { | |
3321 if (args->encoding != NULL) | |
3322 { | |
3323 char *encoding = NULL; | |
3324 encoding = oscar_encoding_extract(args->encoding); | |
3325 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3326 g_free(encoding); | |
3327 } else { | |
3328 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3329 message = g_strdup(args->msg); | |
3330 } | |
3331 } | |
2869 | 3332 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3333 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3334 char *name; |
5234 | 3335 GHashTable *components; |
3336 | |
9933 | 3337 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3338 g_free(message); | |
4121 | 3339 return 1; |
9933 | 3340 } |
5234 | 3341 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3342 g_free); | |
4121 | 3343 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3344 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3345 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
|
3346 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3347 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3348 userinfo->sn, |
9933 | 3349 message, |
5234 | 3350 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3351 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3352 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3353 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3354 /* BBB */ |
3355 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3356 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3357 GaimXfer *xfer; |
5146 | 3358 struct aim_oft_info *oft_info; |
3359 | |
3360 if (!args->cookie || !args->port || !args->verifiedip || | |
3361 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3362 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3363 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3364 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3365 "information.\n", userinfo->sn); |
5146 | 3366 if (args->proxyip) |
8660 | 3367 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3368 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3369 "does not support this yet.\n"); |
9933 | 3370 g_free(message); |
4617 | 3371 return 1; |
4656 | 3372 } |
4617 | 3373 |
3374 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3375 /* 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
|
3376 * directory -- remove the star and trailing slash so we don't save |
4617 | 3377 * directories that look like 'dirname\*' -- arl */ |
3378 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3379 if (tmp && (tmp[1] == '*')) { | |
3380 tmp[0] = '\0'; | |
3381 } | |
8660 | 3382 gaim_debug_warning("oscar", |
8446 | 3383 "We're receiving a whole directory! What fun! " |
3384 "Especially since we don't support that!\n"); | |
4617 | 3385 } |
3386 | |
3387 /* Build the file transfer handle */ | |
3388 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3389 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3390 xfer->remote_port = args->port; |
4617 | 3391 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3392 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3393 gaim_xfer_set_message(xfer, message); |
5146 | 3394 |
3395 /* Create the oscar-specific data */ | |
5163 | 3396 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3397 if (args->proxyip) |
5146 | 3398 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3399 if (args->verifiedip) |
5146 | 3400 oft_info->verifiedip = g_strdup(args->verifiedip); |
3401 xfer->data = oft_info; | |
4617 | 3402 |
3403 /* Setup our I/O op functions */ | |
8446 | 3404 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3405 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3406 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
|
3407 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3408 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3409 |
3410 /* Keep track of this transfer for later */ | |
3411 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3412 | |
3413 /* Now perform the request */ | |
3414 gaim_xfer_request(xfer); | |
3415 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3416 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3417 GaimXfer *xfer; |
8660 | 3418 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3419 "AAA - File transfer canceled by remote user\n"); |
4617 | 3420 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
|
3421 gaim_xfer_cancel_remote(xfer); |
4617 | 3422 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3423 /* | |
3424 * This gets sent by the receiver of a file | |
3425 * as they connect directly to us. If we don't | |
3426 * get this, then maybe a third party connected | |
3427 * to us, and we shouldn't send them anything. | |
3428 */ | |
3429 } else { | |
8660 | 3430 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3431 "unknown rendezvous status!\n"); |
3630 | 3432 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3433 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3434 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3435 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3436 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3437 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3438 args->info.icon.length); |
6871 | 3439 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3440 /* 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
|
3441 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3442 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
|
3443 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3444 |
4212 | 3445 if (!args->verifiedip) { |
8983 | 3446 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3447 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3448 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3449 g_free(message); |
4650 | 3450 return 1; |
4212 | 3451 } |
3452 | |
8660 | 3453 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3454 "%s received direct im request from %s (%s)\n", |
8983 | 3455 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3456 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3457 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3458 d->sn = g_strdup(userinfo->sn); |
8983 | 3459 /* Let's use the clientip here, because I think that's what AIM does. |
3460 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3461 * and then ask them to connect to us. */ | |
3462 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
|
3463 memcpy(d->cookie, args->cookie, 8); |
9070 | 3464 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3465 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3466 | |
8971 | 3467 oscar_direct_im_destroy(od, dim); |
8984 | 3468 d->donttryagain = TRUE; |
8971 | 3469 accept_direct_im_request(d); |
3470 } else { | |
8983 | 3471 if (dim && !dim->connected) |
8971 | 3472 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3473 "already connected to that buddy!"); | |
5575 | 3474 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
|
3475 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3476 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3477 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3478 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3479 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3480 "revealed, this may be considered a privacy " |
9972 | 3481 "risk."), |
3482 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3483 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3484 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3485 /* FIXME: we should actually send a packet on cancel */ | |
3486 } | |
8708 | 3487 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3488 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
|
3489 } else { |
8660 | 3490 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3491 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3492 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3493 |
9933 | 3494 g_free(message); |
3495 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3496 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3497 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3498 |
3453 | 3499 /* |
4230 | 3500 * Authorization Functions |
3501 * Most of these are callbacks from dialogs. They're used by both | |
3502 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3503 */ |
4269 | 3504 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3505 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3506 GaimConnection *gc = data->gc; |
4244 | 3507 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3508 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3509 OscarData *od = gc->proto_data; |
6695 | 3510 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3511 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3512 if (buddy && group) { |
8660 | 3513 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3514 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3515 buddy->name, group->name); |
4889 | 3516 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3517 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3518 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3519 } |
4230 | 3520 } |
4337 | 3521 } |
3522 | |
3523 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3524 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3525 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3526 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3527 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3528 data); |
4230 | 3529 } |
3530 | |
3531 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3532 GaimConnection *gc = data->gc; |
4244 | 3533 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3534 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3535 /* Remove from local list */ |
3536 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3537 gaim_blist_remove_buddy(b); | |
4244 | 3538 } |
3539 | |
5836 | 3540 oscar_free_name_data(data); |
4230 | 3541 } |
3542 | |
9030 | 3543 |
3544 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3545 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3546 GaimBuddy *buddy; |
4269 | 3547 gchar *dialog_msg, *nombre; |
3548 | |
4687 | 3549 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3550 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3551 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3552 else |
4830 | 3553 nombre = NULL; |
3554 | |
3555 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 | 3556 data->gc = gc; |
3557 data->name = g_strdup(name); | |
3558 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3559 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3560 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3561 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3562 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3563 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3564 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3565 |
3566 g_free(dialog_msg); | |
3567 g_free(nombre); | |
3568 } | |
3569 | |
9030 | 3570 |
3571 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3572 GaimBuddy *buddy; | |
3573 GaimConnection *gc; | |
3574 | |
3575 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3576 | |
3577 buddy = (GaimBuddy *) node; | |
3578 gc = gaim_account_get_connection(buddy->account); | |
3579 gaim_auth_sendrequest(gc, buddy->name); | |
3580 } | |
3581 | |
4230 | 3582 /* When other people ask you for authorization */ |
3583 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3584 GaimConnection *gc = data->gc; |
4244 | 3585 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3586 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3587 OscarData *od = gc->proto_data; |
4236 | 3588 #ifdef NOSSI |
6695 | 3589 GaimBuddy *buddy; |
4244 | 3590 gchar message; |
3591 message = 0; | |
4687 | 3592 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3593 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3594 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3595 #else |
4889 | 3596 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3597 #endif |
4244 | 3598 } |
3599 | |
5836 | 3600 oscar_free_name_data(data); |
3141 | 3601 } |
3602 | |
4230 | 3603 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3604 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3605 GaimConnection *gc = data->gc; |
4244 | 3606 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3607 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3608 OscarData *od = gc->proto_data; |
4230 | 3609 #ifdef NOSSI |
4617 | 3610 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3611 #else |
4889 | 3612 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3613 #endif |
4244 | 3614 } |
4337 | 3615 } |
3616 | |
3617 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3618 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3619 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3620 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3621 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3622 data); |
3141 | 3623 } |
3624 | |
7023 | 3625 /* When someone sends you buddies */ |
3626 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3627 GaimConnection *gc = data->gc; |
4244 | 3628 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3629 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3630 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3631 } |
3632 | |
5836 | 3633 oscar_free_name_data(data); |
3453 | 3634 } |
3635 | |
4075 | 3636 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 | 3637 GaimConnection *gc = sess->aux_data; |
9908 | 3638 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3639 gchar **msg1, **msg2; |
6051 | 3640 int i, numtoks; |
4076 | 3641 |
4121 | 3642 if (!args->type || !args->msg || !args->uin) |
3643 return 1; | |
4194 | 3644 |
8660 | 3645 gaim_debug_info("oscar", |
9908 | 3646 "Received a channel 4 message of type 0x%02hhx.\n", |
3647 args->type); | |
4076 | 3648 |
9919 | 3649 /* |
3650 * Split up the message at the delimeter character, then convert each | |
3651 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3652 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3653 * character in whatever encoding the message was sent in. Type 1 | |
3654 * messages are always made up of only one part, so we can easily account | |
3655 * for this suck-ass part of the protocol by splitting the string into at | |
3656 * most 1 baby string. | |
3657 */ | |
3658 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3659 for (numtoks=0; msg1[numtoks]; numtoks++); |
3660 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3661 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3662 gaim_str_strip_cr(msg1[i]); |
9908 | 3663 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3664 } |
3665 msg2[i] = NULL; | |
3666 | |
3952 | 3667 switch (args->type) { |
4173 | 3668 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3669 if (i >= 1) { |
5556 | 3670 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3671 gchar *tmp; |
3672 | |
3673 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3674 tmp = gaim_escape_html(msg2[0]); |
8493 | 3675 |
4076 | 3676 if (t) { /* This is an offline message */ |
9680 | 3677 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3678 #ifdef HAVE_TM_GMTOFF |
9724 | 3679 time_t now; |
3680 struct tm *tm; | |
3681 now = time(NULL); | |
3682 tm = localtime(&now); | |
3683 t += tm->tm_gmtoff; | |
9698 | 3684 #else |
3685 # ifdef HAVE_TIMEZONE | |
9680 | 3686 tzset(); |
3687 t -= timezone; | |
9698 | 3688 # endif |
3689 #endif | |
8514 | 3690 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3691 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3692 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3693 } |
3694 g_free(uin); | |
8493 | 3695 g_free(tmp); |
4075 | 3696 } |
3316 | 3697 } break; |
3698 | |
4173 | 3699 case 0x04: { /* Someone sent you a URL */ |
4076 | 3700 if (i >= 2) { |
7385 | 3701 if (msg2[1] != NULL) { |
3702 gchar *uin = g_strdup_printf("%u", args->uin); | |
3703 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3704 msg2[1], | |
3705 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3706 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3707 g_free(uin); | |
3708 g_free(message); | |
3709 } | |
3453 | 3710 } |
3711 } break; | |
3712 | |
4173 | 3713 case 0x06: { /* Someone requested authorization */ |
4076 | 3714 if (i >= 6) { |
4230 | 3715 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3716 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 | 3717 gaim_debug_info("oscar", |
5556 | 3718 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3719 args->uin); |
4076 | 3720 data->gc = gc; |
5556 | 3721 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3722 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3723 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3724 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3725 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3726 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3727 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3728 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3729 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3730 g_free(dialog_msg); |
3731 } | |
3141 | 3732 } break; |
3733 | |
4173 | 3734 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3735 if (i >= 1) { |
7023 | 3736 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
|
3737 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3738 dialog_msg); |
4076 | 3739 g_free(dialog_msg); |
3740 } | |
3141 | 3741 } break; |
3742 | |
4173 | 3743 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3744 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
|
3745 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3746 dialog_msg); |
3141 | 3747 g_free(dialog_msg); |
3748 } break; | |
3749 | |
4333 | 3750 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3751 if (i >= 5) { | |
3752 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
|
3753 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3754 g_free(dialog_msg); |
3755 } | |
3756 } break; | |
3757 | |
4173 | 3758 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3759 if (i >= 6) { |
4194 | 3760 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
|
3761 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3762 g_free(dialog_msg); |
3763 } | |
4075 | 3764 } break; |
3765 | |
4173 | 3766 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3767 if (i >= 6) { |
4308 | 3768 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
|
3769 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3770 g_free(dialog_msg); |
3771 } | |
4075 | 3772 } break; |
3773 | |
4173 | 3774 case 0x12: { |
3141 | 3775 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3776 /* Someone added you to their buddy list? */ |
3141 | 3777 } break; |
3778 | |
7023 | 3779 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3780 guint i, num; |
3453 | 3781 gchar **text; |
4173 | 3782 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3783 if (text) { |
3784 num = 0; | |
3785 for (i=0; i<strlen(text[0]); i++) | |
3786 num = num*10 + text[0][i]-48; | |
3787 for (i=0; i<num; i++) { | |
4230 | 3788 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3789 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 | 3790 data->gc = gc; |
4790 | 3791 data->name = g_strdup(text[i*2+1]); |
3792 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3793 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3794 gaim_request_action(gc, NULL, message, |
7023 | 3795 _("Do you want to add this buddy " |
3796 "to your buddy list?"), | |
9972 | 3797 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3798 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3799 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3800 g_free(message); |
3801 } | |
3802 g_strfreev(text); | |
3803 } | |
3804 } break; | |
3805 | |
7023 | 3806 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3807 /* This is boring and silly. */ |
3808 } break; | |
3809 | |
3141 | 3810 default: { |
8660 | 3811 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3812 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3813 "(type 0x%02hhx).\n", args->type); |
3141 | 3814 } break; |
3815 } | |
3816 | |
4076 | 3817 g_strfreev(msg1); |
3818 g_strfreev(msg2); | |
3819 | |
3141 | 3820 return 1; |
3821 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3822 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3823 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3824 fu16_t channel; |
3825 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3826 aim_userinfo_t *userinfo; |
2086 | 3827 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3828 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3829 va_start(ap, fr); |
4200 | 3830 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3831 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3832 |
3141 | 3833 switch (channel) { |
3834 case 1: { /* standard message */ | |
3835 struct aim_incomingim_ch1_args *args; | |
3836 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3837 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3838 } break; | |
3839 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3840 case 2: { /* rendezvous */ |
3141 | 3841 struct aim_incomingim_ch2_args *args; |
3842 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3843 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3844 } break; | |
3845 | |
3846 case 4: { /* ICQ */ | |
3847 struct aim_incomingim_ch4_args *args; | |
3848 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3849 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3850 } break; |
3851 | |
3852 default: { | |
8660 | 3853 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3854 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3855 "0x%04hx).", channel); |
3141 | 3856 } break; |
2086 | 3857 } |
3858 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3859 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3860 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3861 return ret; |
2086 | 3862 } |
3863 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3864 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3865 GaimConnection *gc = sess->aux_data; |
3866 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3867 char *buf; |
2086 | 3868 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3869 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3870 aim_userinfo_t *userinfo; |
2086 | 3871 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3872 va_start(ap, fr); |
4200 | 3873 chan = (fu16_t)va_arg(ap, unsigned int); |
3874 userinfo = va_arg(ap, aim_userinfo_t *); | |
3875 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3876 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3877 va_end(ap); |
3878 | |
3879 switch(reason) { | |
5420 | 3880 case 0: /* Invalid (0) */ |
3881 buf = g_strdup_printf( | |
3882 ngettext( | |
4276 | 3883 "You missed %hu message from %s because it was invalid.", |
3884 "You missed %hu messages from %s because they were invalid.", | |
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 1: /* Message too large */ |
3890 buf = g_strdup_printf( | |
3891 ngettext( | |
4276 | 3892 "You missed %hu message from %s because it was too large.", |
3893 "You missed %hu messages from %s because they were too large.", | |
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 2: /* Rate exceeded */ |
3899 buf = g_strdup_printf( | |
3900 ngettext( | |
4276 | 3901 "You missed %hu message from %s because the rate limit has been exceeded.", |
3902 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
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 3: /* Evil Sender */ |
3908 buf = g_strdup_printf( | |
3909 ngettext( | |
4276 | 3910 "You missed %hu message from %s because he/she was too evil.", |
3911 "You missed %hu messages from %s because he/she was too evil.", | |
3912 nummissed), | |
4282 | 3913 nummissed, |
3914 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3915 break; |
5420 | 3916 case 4: /* Evil Receiver */ |
3917 buf = g_strdup_printf( | |
3918 ngettext( | |
4276 | 3919 "You missed %hu message from %s because you are too evil.", |
3920 "You missed %hu messages from %s because you are too evil.", | |
3921 nummissed), | |
4282 | 3922 nummissed, |
3923 userinfo->sn); | |
2086 | 3924 break; |
3925 default: | |
5420 | 3926 buf = g_strdup_printf( |
3927 ngettext( | |
4276 | 3928 "You missed %hu message from %s for an unknown reason.", |
3929 "You missed %hu messages from %s for an unknown reason.", | |
3930 nummissed), | |
4282 | 3931 nummissed, |
3932 userinfo->sn); | |
2086 | 3933 break; |
3934 } | |
8733 | 3935 |
9627 | 3936 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3937 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3938 g_free(buf); |
2086 | 3939 |
3940 return 1; | |
3941 } | |
3942 | |
4194 | 3943 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3944 GaimConnection *gc = sess->aux_data; |
7283 | 3945 OscarData *od = gc->proto_data; |
4617 | 3946 |
3947 /* BBB */ | |
3630 | 3948 switch (reason) { |
4151 | 3949 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3950 GaimXfer *xfer; |
8971 | 3951 struct oscar_direct_im *dim; |
3952 | |
8660 | 3953 gaim_debug_info("oscar", |
9070 | 3954 "AAA - Other user declined some sort of direct " |
8971 | 3955 "connect attempt (automaticly?)\n"); |
4617 | 3956 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
|
3957 gaim_xfer_cancel_remote(xfer); |
8971 | 3958 else if ((dim = oscar_direct_im_find(od, who))) { |
3959 /* AAA should use find by cookie or something here */ | |
3960 oscar_direct_im_disconnect(od, dim); | |
3961 } | |
4151 | 3962 } break; |
3963 | |
3964 default: { | |
8660 | 3965 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3966 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3967 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3968 } |
3630 | 3969 |
3970 } | |
3971 | |
3972 return 0; | |
3973 } | |
3974 | |
4194 | 3975 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3976 GaimConnection *gc = sess->aux_data; |
4151 | 3977 |
3978 switch(reason) { | |
3979 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3980 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3981 | |
3982 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3983 |
3984 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3985 statusmsg = oscar_icqstatus(state); |
4151 | 3986 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3987 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3988 g_free(statusmsg); | |
4151 | 3989 g_strfreev(splitmsg); |
9244 | 3990 |
9797 | 3991 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 3992 |
3993 g_free(title); | |
3994 g_free(dialogmsg); | |
4151 | 3995 } break; |
3996 | |
3997 default: { | |
8660 | 3998 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3999 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4000 "Type 0x%04hx\n", who, reason); |
4151 | 4001 } break; |
4002 } /* end of switch */ | |
4003 | |
4004 return 0; | |
4005 } | |
4006 | |
3212 | 4007 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4008 va_list ap; | |
4009 fu16_t chan, reason; | |
4010 char *who; | |
4011 | |
4012 va_start(ap, fr); | |
4200 | 4013 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4014 who = va_arg(ap, char *); |
4200 | 4015 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4016 |
3952 | 4017 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4018 char *cookie = va_arg(ap, char *); |
4151 | 4019 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4020 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4021 fu32_t state = 0; |
4151 | 4022 char *msg = NULL; |
4023 if (reason == 0x0003) { | |
4200 | 4024 state = va_arg(ap, fu32_t); |
4151 | 4025 msg = va_arg(ap, char *); |
4026 } | |
4027 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4028 } | |
3952 | 4029 |
3212 | 4030 va_end(ap); |
4031 | |
4032 return 1; | |
4033 } | |
4034 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4035 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4036 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4037 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4038 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4039 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4040 va_start(ap, fr); |
4199 | 4041 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4042 va_end(ap); |
4043 | |
8660 | 4044 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4045 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4046 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4047 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4048 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4049 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4050 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4051 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4052 |
2086 | 4053 return 1; |
4054 } | |
4055 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4056 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4057 GaimConnection *gc = sess->aux_data; |
4617 | 4058 #if 0 |
7283 | 4059 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4060 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4061 #endif |
4617 | 4062 va_list ap; |
4063 fu16_t reason; | |
4064 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4065 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4066 va_start(ap, fr); |
4617 | 4067 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4068 data = va_arg(ap, char *); |
2086 | 4069 va_end(ap); |
4070 | |
8660 | 4071 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4072 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 4073 |
4074 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4075 #if 0 |
4617 | 4076 /* If this was a file transfer request, data is a cookie */ |
4077 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
|
4078 gaim_xfer_cancel_remote(xfer); |
3630 | 4079 return 1; |
4080 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4081 #endif |
3630 | 4082 |
4617 | 4083 /* Data is assumed to be the destination sn */ |
9826 | 4084 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4085 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4086 g_free(buf); | |
4087 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4088 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4089 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4090 } | |
4091 g_free(buf); | |
4092 | |
2086 | 4093 return 1; |
4094 } | |
4095 | |
3595 | 4096 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4097 GaimConnection *gc = sess->aux_data; |
3595 | 4098 va_list ap; |
4099 fu16_t type1, type2; | |
4100 char *sn; | |
4101 | |
4102 va_start(ap, fr); | |
4199 | 4103 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4104 sn = va_arg(ap, char *); |
4199 | 4105 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4106 va_end(ap); |
4107 | |
4108 switch (type2) { | |
4109 case 0x0000: { /* Text has been cleared */ | |
4110 serv_got_typing_stopped(gc, sn); | |
4111 } break; | |
4112 | |
4113 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4114 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4115 } break; |
4116 | |
4117 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4118 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4119 } break; |
4120 | |
4121 default: { | |
8660 | 4122 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 | 4123 } break; |
4124 } | |
4125 | |
4126 return 1; | |
4127 } | |
4128 | |
7141 | 4129 /* |
4130 * We get this error when there was an error in the locate family. This | |
7259 | 4131 * happens when you request info of someone who is offline. |
7141 | 4132 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4133 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4134 gchar *buf; |
2086 | 4135 va_list ap; |
5420 | 4136 fu16_t reason; |
2086 | 4137 char *destn; |
4138 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4139 va_start(ap, fr); |
4199 | 4140 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4141 destn = va_arg(ap, char *); |
4142 va_end(ap); | |
4143 | |
7781 | 4144 if (destn == NULL) |
7793 | 4145 return 1; |
9627 | 4146 |
9826 | 4147 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4148 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4149 g_free(buf); | |
9627 | 4150 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4151 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4152 } | |
4153 g_free(buf); | |
2086 | 4154 |
4155 return 1; | |
4156 } | |
4157 | |
7011 | 4158 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4159 GaimConnection *gc = sess->aux_data; |
8700 | 4160 GaimAccount *account = gaim_connection_get_account(gc); |
4161 GString *str; | |
9244 | 4162 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4163 va_list ap; |
7011 | 4164 aim_userinfo_t *userinfo; |
2086 | 4165 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4166 va_start(ap, fr); |
7011 | 4167 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4168 va_end(ap); |
4169 | |
8700 | 4170 str = g_string_new(""); |
4171 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4172 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4173 |
4174 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 4175 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 4176 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 4177 |
4178 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 4179 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 4180 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 4181 |
4182 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4183 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4184 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4185 g_free(tmp); |
4186 } | |
4187 | |
8701 | 4188 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4189 |
4190 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4191 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4192 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4193 g_free(tmp); | |
7011 | 4194 if (away_utf8 != NULL) { |
8700 | 4195 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4196 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4197 } |
7011 | 4198 } |
4199 | |
4200 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4201 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4202 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4203 g_free(tmp); | |
7011 | 4204 if (info_utf8 != NULL) { |
8700 | 4205 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4206 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4207 } |
7011 | 4208 } |
4209 | |
8701 | 4210 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4211 g_string_free(str, TRUE); |
9244 | 4212 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4213 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4214 g_free(title); |
8700 | 4215 g_free(tmp); |
4151 | 4216 |
2086 | 4217 return 1; |
4218 } | |
4219 | |
8341 | 4220 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4221 { | |
4222 aim_session_t *sess = data; | |
4223 GaimConnection *gc = sess->aux_data; | |
4224 OscarData *od = (OscarData *)gc->proto_data; | |
4225 | |
4226 aim_locate_dorequest(data); | |
4227 od->getinfotimer = 0; | |
4228 | |
4229 return FALSE; | |
4230 } | |
4231 | |
4232 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4233 { | |
4234 GaimConnection *gc = sess->aux_data; | |
4235 OscarData *od = (OscarData *)gc->proto_data; | |
4236 | |
4237 /* | |
4238 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4239 * us from hitting the rate limit due to request away messages and info | |
4240 * too quickly. | |
4241 */ | |
4242 if (od->getinfotimer == 0) | |
4243 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4244 | |
4245 return 1; | |
4246 } | |
4247 | |
4248 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4249 { | |
2086 | 4250 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4251 fu16_t id; |
2086 | 4252 va_list ap; |
4253 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4254 va_start(ap, fr); |
4199 | 4255 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4256 msg = va_arg(ap, char *); |
4257 va_end(ap); | |
4258 | |
8660 | 4259 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4260 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4261 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4262 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4263 _("Your AIM connection may be lost."), NULL); |
2086 | 4264 |
4265 return 1; | |
4266 } | |
4267 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4268 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4269 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4270 fu16_t type; |
5575 | 4271 GaimConnection *gc = sess->aux_data; |
7283 | 4272 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4273 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4274 va_start(ap, fr); |
4199 | 4275 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4276 |
4277 switch(type) { | |
4278 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4279 fu8_t maxrooms; |
2086 | 4280 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4281 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4282 |
4199 | 4283 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4284 exchangecount = va_arg(ap, int); |
4285 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4286 | |
8660 | 4287 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4288 "chat info: Chat Rights:\n"); |
8660 | 4289 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4290 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4291 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4292 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4293 for (i = 0; i < exchangecount; i++) |
8660 | 4294 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4295 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4296 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4297 while (od->create_rooms) { |
4298 struct create_room *cr = od->create_rooms->data; | |
8660 | 4299 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4300 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4301 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4302 g_free(cr->name); |
4617 | 4303 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4304 g_free(cr); |
2086 | 4305 } |
4306 } | |
4307 break; | |
4308 case 0x0008: { | |
4309 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4310 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4311 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4312 fu32_t createtime; |
2086 | 4313 |
4314 fqcn = va_arg(ap, char *); | |
4200 | 4315 instance = (fu16_t)va_arg(ap, unsigned int); |
4316 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4317 flags = (fu16_t)va_arg(ap, unsigned int); | |
4318 createtime = va_arg(ap, fu32_t); | |
4319 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4320 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4321 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4322 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4323 name = va_arg(ap, char *); | |
4324 ck = va_arg(ap, char *); | |
4194 | 4325 |
8660 | 4326 gaim_debug_misc("oscar", |
5556 | 4327 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4328 fqcn, |
4329 exchange, instance, flags, | |
4330 createtime, | |
4331 maxmsglen, maxoccupancy, createperms, unknown, | |
4332 name, ck); | |
4617 | 4333 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4334 } |
4335 break; | |
4336 default: | |
8660 | 4337 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4338 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4339 break; |
4340 } | |
4194 | 4341 |
4342 va_end(ap); | |
4343 | |
2086 | 4344 return 1; |
4345 } | |
4346 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4347 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4348 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4349 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4350 aim_userinfo_t *info; |
5575 | 4351 GaimConnection *g = sess->aux_data; |
2086 | 4352 |
4353 struct chat_connection *c = NULL; | |
4354 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4355 va_start(ap, fr); |
2086 | 4356 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4357 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4358 va_end(ap); |
4359 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4360 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4361 if (!c) |
4362 return 1; | |
4363 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4364 for (i = 0; i < count; i++) |
9846 | 4365 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4366 |
4367 return 1; | |
4368 } | |
4369 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4370 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4371 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4372 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4373 aim_userinfo_t *info; |
5575 | 4374 GaimConnection *g = sess->aux_data; |
2086 | 4375 |
4376 struct chat_connection *c = NULL; | |
4377 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4378 va_start(ap, fr); |
2086 | 4379 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4380 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4381 va_end(ap); |
4382 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4383 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4384 if (!c) |
4385 return 1; | |
4386 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4387 for (i = 0; i < count; i++) |
8733 | 4388 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4389 |
4390 return 1; | |
4391 } | |
4392 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4393 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
|
4394 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4395 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4396 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4397 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4398 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4399 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4400 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4401 fu32_t creationtime; |
5575 | 4402 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4403 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
|
4404 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4405 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4406 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4407 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4408 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4409 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4410 roomdesc = va_arg(ap, char *); |
4200 | 4411 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4412 creationtime = va_arg(ap, fu32_t); | |
4413 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4414 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4415 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4416 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4417 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4418 |
8660 | 4419 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4420 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4421 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4422 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4423 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4424 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4425 |
2086 | 4426 return 1; |
4427 } | |
4428 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4429 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4430 GaimConnection *gc = sess->aux_data; |
8225 | 4431 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4432 gchar *utf8; | |
2086 | 4433 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4434 aim_userinfo_t *info; |
8225 | 4435 int len; |
2086 | 4436 char *msg; |
8219 | 4437 char *charset; |
2086 | 4438 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4439 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4440 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4441 len = va_arg(ap, int); |
4194 | 4442 msg = va_arg(ap, char *); |
8219 | 4443 charset = va_arg(ap, char *); |
4194 | 4444 va_end(ap); |
2086 | 4445 |
8225 | 4446 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4447 if (utf8 == NULL) |
4448 /* The conversion failed! */ | |
8668 | 4449 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4450 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4451 g_free(utf8); | |
2086 | 4452 |
4453 return 1; | |
4454 } | |
4455 | |
3694 | 4456 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4457 va_list ap; | |
5575 | 4458 GaimConnection *gc = sess->aux_data; |
3694 | 4459 struct aim_emailinfo *emailinfo; |
3725 | 4460 int havenewmail; |
7297 | 4461 char *alertitle, *alerturl; |
3694 | 4462 |
4463 va_start(ap, fr); | |
4464 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4465 havenewmail = va_arg(ap, int); |
7301 | 4466 alertitle = va_arg(ap, char *); |
4467 alerturl = va_arg(ap, char *); | |
3694 | 4468 va_end(ap); |
4469 | |
9661 | 4470 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4471 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4472 emailinfo->domain ? "@" : "", | |
4473 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4474 if (emailinfo->unread && havenewmail) |
4475 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4476 g_free(to); |
3694 | 4477 } |
7297 | 4478 |
7301 | 4479 if (alertitle) |
8660 | 4480 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4481 |
4482 return 1; | |
4483 } | |
4484 | |
4804 | 4485 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4486 GaimConnection *gc = sess->aux_data; |
7283 | 4487 OscarData *od = gc->proto_data; |
4804 | 4488 char *sn; |
4489 | |
4490 sn = od->requesticon->data; | |
8660 | 4491 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4492 "removing %s from hash table\n", sn); |
4804 | 4493 od->requesticon = g_slist_remove(od->requesticon, sn); |
4494 free(sn); | |
4495 | |
4496 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4497 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4498 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4499 |
4500 return 1; | |
4501 } | |
4502 | |
4503 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4504 GaimConnection *gc = sess->aux_data; |
7283 | 4505 OscarData *od = gc->proto_data; |
4804 | 4506 GSList *cur; |
4507 va_list ap; | |
4508 char *sn; | |
4853 | 4509 fu8_t *iconcsum, *icon; |
4510 fu16_t iconcsumlen, iconlen; | |
4804 | 4511 |
4512 va_start(ap, fr); | |
4513 sn = va_arg(ap, char *); | |
4853 | 4514 iconcsum = va_arg(ap, fu8_t *); |
4515 iconcsumlen = va_arg(ap, int); | |
4804 | 4516 icon = va_arg(ap, fu8_t *); |
4517 iconlen = va_arg(ap, int); | |
4518 va_end(ap); | |
4519 | |
4853 | 4520 if (iconlen > 0) { |
4521 char *b16; | |
6695 | 4522 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4523 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4524 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4525 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4526 if (b16) { |
7693 | 4527 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4528 g_free(b16); |
5129 | 4529 } |
4853 | 4530 } |
4804 | 4531 |
4532 cur = od->requesticon; | |
4533 while (cur) { | |
4534 char *cursn = cur->data; | |
4535 if (!aim_sncmp(cursn, sn)) { | |
4536 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4537 free(cursn); | |
4538 cur = od->requesticon; | |
4539 } else | |
4540 cur = cur->next; | |
4541 } | |
4542 | |
4543 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4544 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4545 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4546 |
4547 return 1; | |
4548 } | |
4549 | |
4550 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4551 GaimConnection *gc = data; |
7283 | 4552 OscarData *od = gc->proto_data; |
7011 | 4553 aim_userinfo_t *userinfo; |
4804 | 4554 aim_conn_t *conn; |
4555 | |
4556 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4557 if (!conn) { |
4558 if (!od->iconconnecting) { | |
4559 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4560 od->iconconnecting = TRUE; | |
4561 } | |
4804 | 4562 return FALSE; |
4563 } | |
4564 | |
5842 | 4565 if (od->set_icon) { |
6039 | 4566 struct stat st; |
4567 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4568 if (iconfile == NULL) { | |
8363 | 4569 aim_ssi_delicon(od->sess); |
6039 | 4570 } else if (!stat(iconfile, &st)) { |
4571 char *buf = g_malloc(st.st_size); | |
4572 FILE *file = fopen(iconfile, "rb"); | |
4573 if (file) { | |
9532 | 4574 /* XXX - Use g_file_get_contents()? */ |
6039 | 4575 fread(buf, 1, st.st_size, file); |
4576 fclose(file); | |
8660 | 4577 gaim_debug_info("oscar", |
6039 | 4578 "Uploading icon to icon server\n"); |
6879 | 4579 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4580 } else |
8660 | 4581 gaim_debug_error("oscar", |
6039 | 4582 "Can't open buddy icon file!\n"); |
4583 g_free(buf); | |
4584 } else { | |
8660 | 4585 gaim_debug_error("oscar", |
6039 | 4586 "Can't stat buddy icon file!\n"); |
5842 | 4587 } |
4588 od->set_icon = FALSE; | |
4589 } | |
4590 | |
4591 if (!od->requesticon) { | |
8660 | 4592 gaim_debug_misc("oscar", |
5842 | 4593 "no more icons to request\n"); |
4594 return FALSE; | |
4595 } | |
4596 | |
7045 | 4597 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4598 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4599 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4600 return FALSE; |
4601 } else { | |
4602 char *sn = od->requesticon->data; | |
4603 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4604 free(sn); | |
4605 } | |
4606 | |
4607 return TRUE; | |
4608 } | |
4609 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4610 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4611 * 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
|
4612 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4613 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4614 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4615 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4616 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4617 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4618 va_start(ap, fr); |
4199 | 4619 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4620 sn = va_arg(ap, char *); |
4621 va_end(ap); | |
4622 | |
8660 | 4623 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4624 |
4625 return 1; | |
4626 } | |
4627 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4628 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
|
4629 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4630 "invalid", |
4194 | 4631 "change", |
4632 "warning", | |
4633 "limit", | |
4634 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4635 }; |
2086 | 4636 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4637 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4638 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4639 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4640 va_start(ap, fr); |
4200 | 4641 code = (fu16_t)va_arg(ap, unsigned int); |
4642 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4643 windowsize = va_arg(ap, fu32_t); | |
4644 clear = va_arg(ap, fu32_t); | |
4645 alert = va_arg(ap, fu32_t); | |
4646 limit = va_arg(ap, fu32_t); | |
4647 disconnect = va_arg(ap, fu32_t); | |
4648 currentavg = va_arg(ap, fu32_t); | |
4649 maxavg = va_arg(ap, fu32_t); | |
2086 | 4650 va_end(ap); |
4651 | |
8660 | 4652 gaim_debug_misc("oscar", |
5556 | 4653 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4654 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4655 (code < 5) ? codes[code] : codes[0], |
4656 rateclass, | |
4657 currentavg, maxavg, | |
4658 alert, clear, | |
4659 limit, disconnect, | |
4660 windowsize); | |
4661 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4662 /* XXX fix these values */ |
2086 | 4663 if (code == AIM_RATE_CODE_CHANGE) { |
4664 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4665 aim_conn_setlatency(fr->conn, 0); |
2086 | 4666 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4667 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4668 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4669 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4670 _("The last action you attempted could not be " |
4671 "performed because you are over the rate limit. " | |
4672 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4673 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4674 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4675 aim_conn_setlatency(fr->conn, 0); |
2086 | 4676 } |
4677 | |
4678 return 1; | |
4679 } | |
4680 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4681 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4682 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4683 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4684 aim_userinfo_t *userinfo; |
5575 | 4685 GaimConnection *gc = sess->aux_data; |
2086 | 4686 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4687 va_start(ap, fr); |
4199 | 4688 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4689 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4690 va_end(ap); |
4691 | |
7111 | 4692 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 4693 |
4694 return 1; | |
4695 } | |
4696 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4697 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
|
4698 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4699 aim_userinfo_t *info; |
5575 | 4700 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4701 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4702 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4703 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4704 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4705 |
5628 | 4706 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 4707 |
7872 | 4708 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 4709 gc->login_time_official = info->onlinesince; |
7872 | 4710 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
4711 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4712 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4713 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4714 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4715 |
4649 | 4716 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4717 GaimConnection *gc = sess->aux_data; |
7283 | 4718 OscarData *od = gc->proto_data; |
4649 | 4719 va_list ap; |
4720 fu16_t code; | |
4721 char *msg; | |
4722 | |
4723 va_start(ap, fr); | |
4724 code = (fu16_t)va_arg(ap, int); | |
4725 msg = va_arg(ap, char *); | |
4726 va_end(ap); | |
4727 | |
8660 | 4728 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4729 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4730 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4731 if (code == 0x0001) { |
6113 | 4732 gc->wants_to_die = TRUE; |
5579 | 4733 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4734 } else { |
5579 | 4735 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4736 } |
4666 | 4737 od->killme = TRUE; |
4649 | 4738 } |
4739 | |
4740 return 1; | |
4741 } | |
4742 | |
2675 | 4743 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4744 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4745 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4746 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4747 |
4748 #ifndef NOSSI | |
8660 | 4749 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4750 aim_ssi_reqrights(sess); |
6350 | 4751 aim_ssi_reqdata(sess); |
4230 | 4752 #endif |
4753 | |
7011 | 4754 aim_locate_reqrights(sess); |
7285 | 4755 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4756 aim_im_reqparams(sess); |
7334 | 4757 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4758 |
4759 #ifdef NOSSI | |
8660 | 4760 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4761 aim_bos_reqrights(sess, fr->conn); |
4230 | 4762 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4763 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4764 #endif | |
2086 | 4765 |
7283 | 4766 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4767 | |
2086 | 4768 return 1; |
4769 } | |
4770 | |
2675 | 4771 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4772 GaimConnection *gc = sess->aux_data; |
7283 | 4773 OscarData *od = gc->proto_data; |
2647 | 4774 |
6905 | 4775 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4776 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4777 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4778 | |
2672 | 4779 aim_clientready(sess, fr->conn); |
8660 | 4780 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4781 |
2647 | 4782 if (od->chpass) { |
8660 | 4783 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4784 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4785 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4786 od->oldp = NULL; |
2647 | 4787 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4788 od->newp = NULL; |
2647 | 4789 od->chpass = FALSE; |
4790 } | |
2979 | 4791 if (od->setnick) { |
8660 | 4792 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4793 aim_admin_setnick(sess, fr->conn, od->newsn); |
4794 g_free(od->newsn); | |
4795 od->newsn = NULL; | |
4796 od->setnick = FALSE; | |
4797 } | |
2647 | 4798 if (od->conf) { |
8660 | 4799 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4800 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4801 od->conf = FALSE; |
4802 } | |
4803 if (od->reqemail) { | |
8660 | 4804 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4805 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4806 od->reqemail = FALSE; |
4807 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4808 if (od->setemail) { |
8660 | 4809 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4810 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4811 g_free(od->email); |
5497 | 4812 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4813 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4814 } |
2647 | 4815 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4816 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4817 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4818 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4819 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
|
4820 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4821 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4822 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4823 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4824 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4825 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4826 |
4194 | 4827 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4828 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4829 "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
|
4830 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4831 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4832 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4833 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4834 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4835 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4836 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4837 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4838 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4839 |
4617 | 4840 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4841 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4842 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4843 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4844 |
2993 | 4845 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4846 { | |
5575 | 4847 GaimConnection *gc = sess->aux_data; |
7283 | 4848 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4849 va_list ap; |
4850 fu16_t maxsiglen; | |
2993 | 4851 |
4852 va_start(ap, fr); | |
4199 | 4853 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4854 va_end(ap); |
4855 | |
8660 | 4856 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4857 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4858 |
4617 | 4859 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4860 | |
4861 if (od->icq) | |
7334 | 4862 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4863 else |
7334 | 4864 aim_locate_setcaps(od->sess, caps_aim); |
4865 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4866 |
4867 return 1; | |
4868 } | |
4869 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4870 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
|
4871 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4872 fu16_t maxbuddies, maxwatchers; |
5575 | 4873 GaimConnection *gc = sess->aux_data; |
7283 | 4874 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4875 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4876 va_start(ap, fr); |
4199 | 4877 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4878 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4879 va_end(ap); |
4880 | |
8660 | 4881 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4882 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4883 |
4617 | 4884 od->rights.maxbuddies = (guint)maxbuddies; |
4885 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4886 |
2086 | 4887 return 1; |
4888 } | |
4889 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4890 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4891 GaimConnection *gc = sess->aux_data; |
7283 | 4892 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4893 va_list ap; |
4894 fu16_t maxpermits, maxdenies; | |
2086 | 4895 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4896 va_start(ap, fr); |
4199 | 4897 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4898 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4899 va_end(ap); |
4900 | |
8660 | 4901 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4902 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4903 |
4617 | 4904 od->rights.maxpermits = (guint)maxpermits; |
4905 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4906 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4907 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4908 serv_finish_login(gc); |
4909 | |
8660 | 4910 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4911 |
2672 | 4912 aim_clientready(sess, fr->conn); |
5948 | 4913 aim_srv_setavailmsg(sess, NULL); |
7474 | 4914 aim_srv_setidle(sess, 0); |
4617 | 4915 |
4664 | 4916 if (od->icq) { |
4917 aim_icq_reqofflinemsgs(sess); | |
4918 aim_icq_hideip(sess); | |
4919 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4920 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4921 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4922 if (sess->authinfo->email) |
4923 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4924 |
4925 return 1; | |
4926 } | |
4927 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4928 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
|
4929 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4930 struct aim_icq_offlinemsg *msg; |
4075 | 4931 struct aim_incomingim_ch4_args args; |
4932 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4933 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4934 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4935 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4936 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4937 |
8660 | 4938 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4939 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4940 args.uin = msg->sender; |
4941 args.type = msg->type; | |
4173 | 4942 args.flags = msg->flags; |
4076 | 4943 args.msglen = msg->msglen; |
4075 | 4944 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4945 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4946 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4947 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4948 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4949 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4950 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4951 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
|
4952 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4953 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4954 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4955 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4956 |
7388 | 4957 #if 0 |
4958 /* | |
7465 | 4959 * Update, 2003-11-09: |
4960 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4961 * | |
7388 | 4962 * It may not be my place to do this, but... |
4963 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4964 * stupid, and should not exist for % switches (%x in our case) that request | |
4965 * a year in the preferred representation for the current locale. For that | |
4966 * reason I've chosen to not use this workaround (n., see kluge). | |
4967 * | |
4968 * I have a date. I want to show it to the user in the "preferred" way. | |
4969 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4970 * what the locale wanted. | |
4971 * | |
4972 * If I have a necessity for a full representation of the year in the current | |
4973 * locale, then I'll use a switch that returns a full representation of the | |
4974 * year. | |
4975 * | |
4976 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4977 * (because you're anal, or whatever), then change the f***ing locale. | |
4978 * | |
4979 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4980 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4981 * |
4982 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4983 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4984 */ |
4985 | |
4986 /* | |
4987 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4988 * "last 2 digits" warning. |
4989 */ | |
4990 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4991 const struct tm *tm) | |
4992 { | |
4993 return strftime(s, max, fmt, tm); | |
4994 } | |
7388 | 4995 #endif |
7386 | 4996 |
4624 | 4997 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
|
4998 { |
5575 | 4999 GaimConnection *gc = sess->aux_data; |
8670 | 5000 OscarData *od = (OscarData *)gc->proto_data; |
5001 GaimBuddy *buddy; | |
8853 | 5002 struct buddyinfo *bi = NULL; |
4624 | 5003 gchar who[16]; |
8670 | 5004 GString *str; |
5005 gchar *primary, *utf8; | |
9634 | 5006 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5007 va_list ap; |
4151 | 5008 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5009 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5010 va_start(ap, fr); |
4151 | 5011 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5012 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5013 |
4664 | 5014 if (!info->uin) |
5015 return 0; | |
5016 | |
8670 | 5017 str = g_string_sized_new(100); |
5556 | 5018 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5019 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5020 if (buddy != NULL) | |
5021 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5022 | |
5023 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5024 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5025 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5026 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5027 (bi->ipaddr & 0xff000000) >> 24, | |
5028 (bi->ipaddr & 0x00ff0000) >> 16, | |
5029 (bi->ipaddr & 0x0000ff00) >> 8, | |
5030 (bi->ipaddr & 0x000000ff)); | |
8701 | 5031 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5032 g_free(tstr); |
5033 } | |
8701 | 5034 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5035 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5036 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5037 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5038 g_free(utf8); | |
4625 | 5039 } |
5040 if (info->numaddresses && info->email2) { | |
5041 int i; | |
5042 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5043 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5044 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5045 g_free(utf8); | |
4643 | 5046 } |
4625 | 5047 } |
4624 | 5048 } |
8701 | 5049 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
8902 | 5050 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
5051 info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5052 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5053 char date[30]; |
5054 struct tm tm; | |
5055 tm.tm_mday = (int)info->birthday; | |
5056 tm.tm_mon = (int)info->birthmonth-1; | |
5057 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5058 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5059 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5060 } |
4624 | 5061 if (info->age) { |
5062 char age[5]; | |
5063 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5064 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5065 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5066 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5067 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5068 g_free(utf8); | |
4819 | 5069 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5070 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5071 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5072 g_free(utf8); | |
5073 } | |
5074 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5075 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5076 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5077 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5078 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5079 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5080 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5081 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5082 } |
4641 | 5083 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5084 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5085 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5086 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5087 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5088 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5089 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5090 } |
4641 | 5091 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5092 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5093 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5094 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5095 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5096 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5097 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5098 g_free(utf8); | |
4624 | 5099 } |
8670 | 5100 g_string_append_printf(str, "\n<hr>\n"); |
5101 } | |
5102 | |
9634 | 5103 if (buddy != NULL) |
5104 alias = gaim_buddy_get_alias(buddy); | |
5105 else | |
5106 alias = who; | |
5107 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5108 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5109 g_free(primary); |
8670 | 5110 g_string_free(str, TRUE); |
4151 | 5111 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5112 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5113 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5114 |
4759 | 5115 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5116 { | |
5575 | 5117 GaimConnection *gc = sess->aux_data; |
4820 | 5118 gchar who[16], *utf8; |
6695 | 5119 GaimBuddy *b; |
4759 | 5120 va_list ap; |
5121 struct aim_icq_info *info; | |
5122 | |
5123 va_start(ap, fr); | |
5124 info = va_arg(ap, struct aim_icq_info *); | |
5125 va_end(ap); | |
5126 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5127 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5128 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5129 serv_got_alias(gc, who, utf8); |
4759 | 5130 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5131 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5132 } |
4820 | 5133 g_free(utf8); |
4759 | 5134 } |
5135 | |
5136 return 1; | |
5137 } | |
5138 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5139 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
|
5140 { |
7032 | 5141 GaimConnection *gc = sess->aux_data; |
5142 gchar *text; | |
5143 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5144 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5145 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5146 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5147 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5148 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5149 url = va_arg(ap, char *); |
4199 | 5150 wid = (fu16_t) va_arg(ap, int); |
5151 hei = (fu16_t) va_arg(ap, int); | |
5152 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5153 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5154 |
7032 | 5155 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5156 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5157 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5158 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5159 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5160 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5161 |
7032 | 5162 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5163 { | |
6873 | 5164 GaimConnection *gc = sess->aux_data; |
5165 gchar *secondary; | |
5166 GString *text; | |
5167 int i, num; | |
2086 | 5168 va_list ap; |
6873 | 5169 char *email, *SNs; |
2086 | 5170 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5171 va_start(ap, fr); |
6873 | 5172 email = va_arg(ap, char *); |
2086 | 5173 num = va_arg(ap, int); |
5174 SNs = va_arg(ap, char *); | |
5175 va_end(ap); | |
5176 | |
8152 | 5177 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5178 text = g_string_new(""); |
2086 | 5179 for (i = 0; i < num; i++) |
6873 | 5180 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5181 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5182 | |
5183 g_free(secondary); | |
5184 g_string_free(text, TRUE); | |
2086 | 5185 |
5186 return 1; | |
5187 } | |
5188 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5189 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5190 va_list ap; |
6873 | 5191 char *email; |
5420 | 5192 char *buf; |
2086 | 5193 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5194 va_start(ap, fr); |
6873 | 5195 email = va_arg(ap, char *); |
2086 | 5196 va_end(ap); |
5197 | |
6873 | 5198 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
|
5199 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5200 g_free(buf); |
2086 | 5201 |
5202 return 1; | |
5203 } | |
5204 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5205 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5206 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5207 fu16_t status; |
2086 | 5208 va_list ap; |
5209 char msg[256]; | |
5210 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5211 va_start(ap, fr); |
4199 | 5212 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5213 va_end(ap); |
5214 | |
8660 | 5215 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5216 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5217 status ? "unknown" : "email sent"); |
5218 if (!status) { | |
5302 | 5219 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5220 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5221 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5222 } |
5223 | |
5224 return 1; | |
5225 } | |
5226 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5227 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5228 GaimConnection *gc = sess->aux_data; |
2086 | 5229 va_list ap; |
3912 | 5230 fu16_t perms, err; |
5231 char *url, *sn, *email; | |
5232 int change; | |
2086 | 5233 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5234 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5235 change = va_arg(ap, int); |
4199 | 5236 perms = (fu16_t) va_arg(ap, unsigned int); |
5237 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5238 url = va_arg(ap, char *); |
5239 sn = va_arg(ap, char *); | |
5240 email = va_arg(ap, char *); | |
2086 | 5241 va_end(ap); |
5242 | |
8660 | 5243 gaim_debug_misc("oscar", |
9626 | 5244 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5245 change ? "change" : "request", perms, err, | |
5246 (url != NULL) ? url : "(null)", | |
5247 (sn != NULL) ? sn : "(null)", | |
5248 (email != NULL) ? email : "(null)"); | |
5249 | |
5250 if ((err > 0) && (url != NULL)) { | |
3912 | 5251 char *dialog_msg; |
5252 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5253 switch (err) { | |
5254 case 0x0001: { | |
5255 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5256 } break; | |
5257 case 0x0006: { | |
5258 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5259 } break; | |
5260 case 0x000b: { | |
5261 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5262 } break; | |
5263 case 0x001d: { | |
5264 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); | |
5265 } break; | |
5266 case 0x0021: { | |
5267 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); | |
5268 } break; | |
5269 case 0x0023: { | |
5270 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5271 } break; | |
5272 default: { | |
5273 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5274 } break; | |
5275 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5276 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5277 g_free(dialog_top); |
5278 g_free(dialog_msg); | |
5279 return 1; | |
5280 } | |
5281 | |
9626 | 5282 if (sn != NULL) { |
4585 | 5283 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
|
5284 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5285 g_free(dialog_msg); |
5286 } | |
5287 | |
9626 | 5288 if (email != NULL) { |
5575 | 5289 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5290 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5291 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5292 g_free(dialog_msg); |
2086 | 5293 } |
5294 | |
5295 return 1; | |
5296 } | |
5297 | |
5575 | 5298 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5299 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5300 aim_flap_nop(od->sess, od->conn); |
2086 | 5301 } |
5302 | |
6059 | 5303 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5304 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5305 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5306 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5307 if (typing == GAIM_TYPING) |
4870 | 5308 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5309 else if (typing == GAIM_TYPED) |
4870 | 5310 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5311 else | |
5312 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5313 else { |
5300 | 5314 /* Don't send if this turkey is in our deny list */ |
5315 GSList *list; | |
5316 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5317 if (!list) { | |
7261 | 5318 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5319 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5320 if (typing == GAIM_TYPING) |
5300 | 5321 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5322 else if (typing == GAIM_TYPED) |
5300 | 5323 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5324 else | |
5325 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5326 } | |
3595 | 5327 } |
5328 } | |
2993 | 5329 return 0; |
5330 } | |
9030 | 5331 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5332 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
|
5333 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5334 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5335 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5336 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
|
5337 int ret = 0; |
5575 | 5338 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5339 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5340 |
4838 | 5341 if (dim && dim->connected) { |
5342 /* If we're directly connected, send a direct IM */ | |
6982 | 5343 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5344 } else { |
4738 | 5345 struct buddyinfo *bi; |
3008 | 5346 struct aim_sendimext_args args; |
5347 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5348 gsize len; |
8962 | 5349 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5350 | |
5351 if (strstr(message, "<IMG ")) | |
5352 gaim_conversation_write(conv, "", | |
5353 _("Your IM Image was not sent. " | |
5354 "You must be Direct Connected to send IM Images."), | |
5355 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5356 |
7261 | 5357 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5358 if (!bi) { |
5359 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5360 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5361 } |
5362 | |
3008 | 5363 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5364 if (od->icq) { |
5365 args.features = features_icq; | |
5366 args.featureslen = sizeof(features_icq); | |
3008 | 5367 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5368 } else { |
5369 args.features = features_aim; | |
5370 args.featureslen = sizeof(features_aim); | |
4972 | 5371 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5372 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5373 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5374 } |
4269 | 5375 |
4738 | 5376 if (bi->ico_need) { |
8660 | 5377 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5378 "Sending buddy icon request with message\n"); |
3008 | 5379 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5380 bi->ico_need = FALSE; |
3008 | 5381 } |
4269 | 5382 |
5575 | 5383 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5384 FILE *file = fopen(iconfile, "rb"); |
3008 | 5385 if (file) { |
5386 char *buf = g_malloc(st.st_size); | |
9532 | 5387 /* XXX - Use g_file_get_contents()? */ |
3008 | 5388 fread(buf, 1, st.st_size, file); |
6039 | 5389 fclose(file); |
4269 | 5390 |
3008 | 5391 args.iconlen = st.st_size; |
4617 | 5392 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5393 args.iconstamp = st.st_mtime; |
5394 | |
7406 | 5395 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5396 bi->ico_informed = FALSE; |
7406 | 5397 bi->ico_sent = FALSE; |
5398 } | |
4738 | 5399 |
5400 if (!bi->ico_informed) { | |
8660 | 5401 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5402 "Claiming to have a buddy icon\n"); |
4738 | 5403 args.flags |= AIM_IMFLAGS_HASICON; |
5404 bi->ico_me_len = args.iconlen; | |
5405 bi->ico_me_csum = args.iconsum; | |
5406 bi->ico_me_time = args.iconstamp; | |
5407 bi->ico_informed = TRUE; | |
5408 } | |
5409 | |
3008 | 5410 g_free(buf); |
2086 | 5411 } |
5412 } | |
4269 | 5413 |
3008 | 5414 args.destsn = name; |
4269 | 5415 |
8985 | 5416 /* |
5417 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5418 * strip all HTML | |
5419 */ | |
9975 | 5420 if (aim_sn_is_icq(name) ) { |
8995 | 5421 /* being sent to an ICQ user */ |
9975 | 5422 if (!aim_sn_is_icq(gaim_account_get_username(gc->account))) { |
8995 | 5423 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5424 tmpmsg = gaim_str_add_cr(message); | |
5425 } else { | |
5426 /* from an ICQ user - do nothing */ | |
5427 tmpmsg = g_strdup(message); | |
5428 } | |
5429 } else { | |
5430 /* being sent to an AIM user */ | |
9975 | 5431 if (aim_sn_is_icq(gaim_account_get_username(gc->account))) { |
8995 | 5432 /* from an ICQ user */ |
5433 tmpmsg2 = gaim_strdup_withhtml(message); | |
5434 tmpmsg = gaim_escape_html(tmpmsg2); | |
5435 g_free(tmpmsg2); | |
5436 } else | |
5437 tmpmsg = gaim_strdup_withhtml(message); | |
5438 } | |
6310 | 5439 len = strlen(tmpmsg); |
5440 | |
9830 | 5441 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5442 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5443 args.charset, args.charsubset, args.msglen); | |
4617 | 5444 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5445 g_free((char *)args.msg); |
2086 | 5446 } |
4838 | 5447 |
6310 | 5448 g_free(tmpmsg); |
5449 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5450 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5451 return 1; |
6310 | 5452 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5453 return ret; |
2086 | 5454 } |
5455 | |
7011 | 5456 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5457 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5458 |
9975 | 5459 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5460 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5461 else |
7235 | 5462 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5463 } |
5464 | |
8950 | 5465 #if 0 |
7011 | 5466 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5467 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5468 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5469 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5470 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5471 maiden, NULL, NULL, city, state, NULL, 0, web); |
5472 } | |
8950 | 5473 #endif |
2086 | 5474 |
5575 | 5475 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5476 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5477 aim_srv_setidle(od->sess, time); |
2086 | 5478 } |
5479 | |
5954 | 5480 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5481 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5482 int charset = 0; |
6019 | 5483 char *text_html = NULL; |
5129 | 5484 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5485 gsize msglen = 0; |
2993 | 5486 |
4617 | 5487 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5488 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5489 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5490 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5491 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5492 "again when you are fully connected.")); |
4617 | 5493 |
7334 | 5494 if (!text) { |
5495 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5496 return; | |
5497 } | |
6019 | 5498 |
7334 | 5499 text_html = gaim_strdup_withhtml(text); |
9807 | 5500 charset = oscar_charset_check(text_html); |
9826 | 5501 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5502 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5503 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5504 g_free(msg); | |
9826 | 5505 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5506 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5507 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5508 g_free(msg); | |
5509 } else { | |
5510 msglen = strlen(text_html); | |
5511 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5512 } | |
5513 | |
5514 if (msglen > od->rights.maxsiglen) { | |
5515 gchar *errstr; | |
5516 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5517 "has been exceeded. Gaim has truncated it for you.", | |
5518 "The maximum profile length of %d bytes " | |
5519 "has been exceeded. Gaim has truncated it for you.", | |
5520 od->rights.maxsiglen), od->rights.maxsiglen); | |
5521 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5522 g_free(errstr); | |
5523 } | |
5524 | |
5525 g_free(text_html); | |
2993 | 5526 |
5527 return; | |
2086 | 5528 } |
5529 | |
9973 | 5530 static void oscar_set_status_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 5531 { |
9807 | 5532 int charset = 0; |
6019 | 5533 gchar *text_html = NULL; |
5129 | 5534 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5535 gsize msglen = 0; |
2993 | 5536 |
8257 | 5537 if (!strcmp(state, _("Visible"))) { |
5538 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5539 return; | |
5540 } else if (!strcmp(state, _("Invisible"))) { | |
5541 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5542 return; | |
5543 } /* else... */ | |
5544 | |
8476 | 5545 if (!strcmp(state, _("Back"))) { |
5546 /* If this is our only online account then globally set Gaim not-away */ | |
5547 GList *gcs = gaim_connections_get_all(); | |
5548 if (gcs->next == NULL) | |
9730 | 5549 ; /* XXX do_im_back(NULL, NULL); */ |
8476 | 5550 } |
5551 | |
8257 | 5552 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5553 | |
2993 | 5554 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5555 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5556 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5557 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5558 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5559 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5560 "fully connected.")); |
5129 | 5561 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5562 if (gc->away) { |
2993 | 5563 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5564 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5565 } |
2993 | 5566 |
5129 | 5567 if (!text) { |
7334 | 5568 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5569 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5570 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5571 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5572 text_html = gaim_strdup_withhtml(text); |
9807 | 5573 charset = oscar_charset_check(text_html); |
9826 | 5574 if (charset == AIM_CHARSET_UNICODE) { |
6019 | 5575 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5576 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5577 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5578 g_free(msg); |
5579 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
9826 | 5580 } else if (charset == AIM_CHARSET_CUSTOM) { |
6019 | 5581 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5582 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5583 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5584 g_free(msg); |
6019 | 5585 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5586 } else { |
6019 | 5587 msglen = strlen(text_html); |
7011 | 5588 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5589 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 5590 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5591 } |
5592 | |
5593 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5594 gchar *errstr; |
5595 | |
6308 | 5596 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5597 "has been exceeded. Gaim has truncated it for you.", | |
5598 "The maximum away message length of %d bytes " | |
5599 "has been exceeded. Gaim has truncated it for you.", | |
5600 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5601 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5602 g_free(errstr); |
5603 } | |
6019 | 5604 |
5605 g_free(text_html); | |
8257 | 5606 |
2993 | 5607 return; |
5608 } | |
5609 | |
9973 | 5610 static void oscar_set_status_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 5611 { |
5575 | 5612 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5613 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5614 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5615 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5616 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5617 |
8265 | 5618 if (strcmp(state, _("Invisible"))) |
5575 | 5619 account->perm_deny = 4; |
8265 | 5620 else |
5575 | 5621 account->perm_deny = 3; |
8265 | 5622 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5623 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5624 |
5625 if (!strcmp(state, _("Online"))) | |
4901 | 5626 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 5627 else if (!strcmp(state, _("Away"))) { |
4901 | 5628 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5629 gc->away = g_strdup(""); |
4342 | 5630 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 5631 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
|
5632 gc->away = g_strdup(""); |
4342 | 5633 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 5634 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
|
5635 gc->away = g_strdup(""); |
4342 | 5636 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 5637 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
|
5638 gc->away = g_strdup(""); |
4342 | 5639 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 5640 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5641 gc->away = g_strdup(""); |
4342 | 5642 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 5643 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5644 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5645 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 5646 if (message) { |
4901 | 5647 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
|
5648 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5649 } else { |
4901 | 5650 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5651 } |
2086 | 5652 } |
2993 | 5653 |
5654 return; | |
5655 } | |
5656 | |
9973 | 5657 static void oscar_set_status(GaimConnection *gc, const char *state, const char *message) |
2993 | 5658 { |
7283 | 5659 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 5660 |
5661 if (od->icq) | |
9973 | 5662 oscar_set_status_icq(gc, od, state, message); |
2993 | 5663 else |
9973 | 5664 oscar_set_status_aim(gc, od, state, message); |
2993 | 5665 |
5666 return; | |
2086 | 5667 } |
5668 | |
9753 | 5669 static void oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { |
7283 | 5670 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5671 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5672 } |
5673 | |
9285 | 5674 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5675 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5676 |
5677 if (!aim_snvalid(buddy->name)) { | |
8092 | 5678 gchar *buf; |
9285 | 5679 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 | 5680 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5681 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5682 g_free(buf); |
8150 | 5683 |
5684 /* Remove from local list */ | |
9285 | 5685 gaim_blist_remove_buddy(buddy); |
8150 | 5686 |
8092 | 5687 return; |
5688 } | |
5689 | |
4230 | 5690 #ifdef NOSSI |
9285 | 5691 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5692 #else |
9285 | 5693 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5694 if (buddy && group) { | |
8660 | 5695 gaim_debug_info("oscar", |
9285 | 5696 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5697 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5698 } |
5699 } | |
5700 #endif | |
8150 | 5701 |
4759 | 5702 if (od->icq) |
9285 | 5703 aim_icq_getalias(od->sess, buddy->name); |
5704 } | |
5705 | |
5706 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5707 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5708 #ifdef NOSSI |
5709 char buf[MSG_LEN]; | |
5710 int n=0; | |
9285 | 5711 |
4230 | 5712 while (buddies) { |
9381 | 5713 GaimBuddy *buddy = buddies->data; |
4230 | 5714 if (n > MSG_LEN - 18) { |
7285 | 5715 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5716 n = 0; |
3092 | 5717 } |
9381 | 5718 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5719 buddies = buddies->next; |
5720 } | |
7285 | 5721 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5722 #else |
9285 | 5723 |
4230 | 5724 if (od->sess->ssi.received_data) { |
9285 | 5725 GList *curb = buddies; |
5726 GList *curg = groups; | |
5727 while ((curb != NULL) && (curg != NULL)) { | |
5728 GaimBuddy *buddy = curb->data; | |
5729 GaimGroup *group = curg->data; | |
5730 oscar_add_buddy(gc, buddy, group); | |
5731 curb = curb->next; | |
5732 curg = curg->next; | |
4230 | 5733 } |
5734 } | |
5735 #endif | |
5736 } | |
5737 | |
9285 | 5738 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5739 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5740 |
4230 | 5741 #ifdef NOSSI |
9285 | 5742 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5743 #else |
5744 if (od->sess->ssi.received_data) { | |
8660 | 5745 gaim_debug_info("oscar", |
9285 | 5746 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5747 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5748 } |
5749 #endif | |
5750 } | |
5751 | |
9285 | 5752 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5753 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5754 |
4230 | 5755 #ifdef NOSSI |
9285 | 5756 for (cur = buddies; cur != NULL; cur = cur->next) { |
5757 GaimBuddy *buddy = cur->data; | |
5758 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5759 } | |
4230 | 5760 #else |
5761 if (od->sess->ssi.received_data) { | |
9285 | 5762 GList *curb = buddies; |
5763 GList *curg = groups; | |
5764 while ((curb != NULL) && (curg != NULL)) { | |
5765 GaimBuddy *buddy = curb->data; | |
5766 GaimGroup *group = curg->data; | |
5767 oscar_remove_buddy(gc, buddy, group); | |
5768 curb = curb->next; | |
5769 curg = curg->next; | |
3092 | 5770 } |
4230 | 5771 } |
5772 #endif | |
5773 } | |
5774 | |
5775 #ifndef NOSSI | |
5575 | 5776 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5777 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5778 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5779 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5780 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5781 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5782 } |
5783 } | |
5784 | |
5575 | 5785 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5786 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5787 if (od->sess->ssi.received_data) { |
5788 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5789 if (gname) { | |
8660 | 5790 gaim_debug_info("oscar", |
9586 | 5791 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5792 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5793 } |
5794 } | |
5795 } | |
5796 | |
9285 | 5797 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5798 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5799 |
5800 if (od->sess->ssi.received_data) { | |
9285 | 5801 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5802 GList *cur, *groups = NULL; | |
5803 | |
5804 /* Make a list of what the groups each buddy is in */ | |
5805 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5806 GaimBlistNode *node = cur->data; | |
5807 groups = g_list_append(groups, node->parent); | |
5808 } | |
5809 | |
5810 oscar_remove_buddies(gc, moved_buddies, groups); | |
5811 oscar_add_buddies(gc, moved_buddies, groups); | |
5812 g_list_free(groups); | |
8660 | 5813 gaim_debug_info("oscar", |
9285 | 5814 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5815 } else { |
9285 | 5816 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5817 gaim_debug_info("oscar", |
9285 | 5818 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5819 } |
5820 } | |
5821 } | |
5822 | |
5968 | 5823 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5824 aim_session_t *sess = data; | |
6350 | 5825 aim_ssi_reqdata(sess); |
5968 | 5826 return FALSE; |
5827 } | |
5828 | |
4642 | 5829 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5830 GaimConnection *gc = sess->aux_data; |
7283 | 5831 OscarData *od = gc->proto_data; |
4642 | 5832 va_list ap; |
5833 fu16_t reason; | |
5834 | |
5835 va_start(ap, fr); | |
5836 reason = (fu16_t)va_arg(ap, unsigned int); | |
5837 va_end(ap); | |
5838 | |
8660 | 5839 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5840 |
5841 if (reason == 0x0005) { | |
5892 | 5842 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5843 _("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
|
5844 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5845 } |
5846 | |
5847 /* Activate SSI */ | |
5848 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5849 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5850 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5851 aim_ssi_enable(od->sess); |
5852 | |
5853 return 1; | |
5854 } | |
5855 | |
2991 | 5856 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5857 GaimConnection *gc = sess->aux_data; |
7283 | 5858 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5859 int numtypes, i; |
5860 fu16_t *maxitems; | |
2991 | 5861 va_list ap; |
5862 | |
5863 va_start(ap, fr); | |
4230 | 5864 numtypes = va_arg(ap, int); |
5865 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5866 va_end(ap); |
5867 | |
8660 | 5868 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5869 |
4230 | 5870 for (i=0; i<numtypes; i++) |
8660 | 5871 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5872 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5873 |
8660 | 5874 gaim_debug_misc(NULL, "\n"); |
4230 | 5875 |
5876 if (numtypes >= 0) | |
5877 od->rights.maxbuddies = maxitems[0]; | |
5878 if (numtypes >= 1) | |
5879 od->rights.maxgroups = maxitems[1]; | |
5880 if (numtypes >= 2) | |
5881 od->rights.maxpermits = maxitems[2]; | |
5882 if (numtypes >= 3) | |
5883 od->rights.maxdenies = maxitems[3]; | |
2991 | 5884 |
5885 return 1; | |
5886 } | |
5887 | |
5888 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5889 GaimConnection *gc = sess->aux_data; |
5890 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5891 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5892 GaimGroup *g; |
5893 GaimBuddy *b; | |
2995 | 5894 struct aim_ssi_item *curitem; |
2991 | 5895 int tmp; |
4230 | 5896 va_list ap; |
8219 | 5897 fu16_t fmtver, numitems; |
5898 struct aim_ssi_item *items; | |
5899 fu32_t timestamp; | |
4230 | 5900 |
5901 va_start(ap, fr); | |
5902 fmtver = (fu16_t)va_arg(ap, int); | |
5903 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5904 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5905 timestamp = va_arg(ap, fu32_t); |
8219 | 5906 va_end(ap); |
2991 | 5907 |
8660 | 5908 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5909 "ssi: syncing local list and server list\n"); |
2991 | 5910 |
8219 | 5911 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5912 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 | 5913 return 1; |
5914 } | |
5915 | |
2991 | 5916 /* Clean the buddy list */ |
4889 | 5917 aim_ssi_cleanlist(sess); |
2991 | 5918 |
8150 | 5919 { /* If not in server list then prune from local list */ |
5920 GaimBlistNode *gnode, *cnode, *bnode; | |
5921 GaimBuddyList *blist; | |
9539 | 5922 GSList *cur, *next; |
8150 | 5923 |
5924 /* Buddies */ | |
5925 cur = NULL; | |
5926 if ((blist = gaim_get_blist()) != NULL) { | |
5927 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5928 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5929 continue; | |
5930 g = (GaimGroup *)gnode; | |
5931 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5932 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5933 continue; | |
5934 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5935 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5936 continue; | |
5937 b = (GaimBuddy *)bnode; | |
5938 if (b->account == gc->account) { | |
5939 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5940 /* If the buddy is an ICQ user then load his nickname */ | |
5941 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5942 char *alias; |
8150 | 5943 if (servernick) |
5944 serv_got_alias(gc, b->name, servernick); | |
5945 | |
5946 /* Store local alias on server */ | |
8214 | 5947 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5948 if (!alias && b->alias && strlen(b->alias)) |
5949 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5950 free(alias); | |
5951 } else { | |
8660 | 5952 gaim_debug_info("oscar", |
8150 | 5953 "ssi: removing buddy %s from local list\n", b->name); |
5954 /* We can't actually remove now because it will screw up our looping */ | |
5955 cur = g_slist_prepend(cur, b); | |
5956 } | |
5957 } | |
5958 } | |
5959 } | |
5960 } | |
5961 } | |
8175 | 5962 |
8150 | 5963 while (cur != NULL) { |
5964 b = cur->data; | |
5965 cur = g_slist_remove(cur, b); | |
5966 gaim_blist_remove_buddy(b); | |
5967 } | |
5968 | |
5969 /* Permit list */ | |
5970 if (gc->account->permit) { | |
9539 | 5971 next = gc->account->permit; |
5972 while (next != NULL) { | |
5973 cur = next; | |
5974 next = next->next; | |
8150 | 5975 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5976 gaim_debug_info("oscar", |
8150 | 5977 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5978 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5979 } | |
9539 | 5980 } |
8150 | 5981 } |
5982 | |
5983 /* Deny list */ | |
5984 if (gc->account->deny) { | |
9539 | 5985 next = gc->account->deny; |
5986 while (next != NULL) { | |
5987 cur = next; | |
5988 next = next->next; | |
8150 | 5989 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 5990 gaim_debug_info("oscar", |
8150 | 5991 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5992 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5993 } | |
9539 | 5994 } |
8150 | 5995 } |
5996 /* Presence settings (idle time visibility) */ | |
5997 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5998 if (!(tmp & 0x400)) | |
5999 aim_ssi_setpresence(sess, tmp | 0x400); | |
6000 } /* end pruning buddies from local list */ | |
6001 | |
2991 | 6002 /* Add from server list to local list */ |
4230 | 6003 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6004 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6005 switch (curitem->type) { |
4230 | 6006 case 0x0000: { /* Buddy */ |
4251 | 6007 if (curitem->name) { |
4292 | 6008 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6009 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6010 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6011 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6012 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6013 /* Should gname be freed here? -- elb */ |
4754 | 6014 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6015 free(alias); |
8150 | 6016 if (b) { |
4292 | 6017 /* Get server stored alias */ |
4705 | 6018 if (alias_utf8) { |
8150 | 6019 g_free(b->alias); |
6020 b->alias = g_strdup(alias_utf8); | |
4705 | 6021 } |
4282 | 6022 } else { |
8150 | 6023 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6024 |
4754 | 6025 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6026 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6027 gaim_blist_add_group(g, NULL); |
6028 } | |
5146 | 6029 |
8660 | 6030 gaim_debug_info("oscar", |
9285 | 6031 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6032 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6033 } |
8341 | 6034 if (!aim_sncmp(curitem->name, account->username)) { |
6035 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6036 gaim_check_comment(od, comment); | |
6037 free(comment); | |
6038 } | |
7162 | 6039 g_free(gname_utf8); |
6040 g_free(alias_utf8); | |
2991 | 6041 } |
4230 | 6042 } break; |
6043 | |
6044 case 0x0001: { /* Group */ | |
4282 | 6045 /* Shouldn't add empty groups */ |
4230 | 6046 } break; |
6047 | |
6048 case 0x0002: { /* Permit buddy */ | |
2991 | 6049 if (curitem->name) { |
4230 | 6050 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6051 GSList *list; |
5575 | 6052 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6053 if (!list) { |
8660 | 6054 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6055 "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
|
6056 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6057 } |
6058 } | |
4230 | 6059 } break; |
6060 | |
6061 case 0x0003: { /* Deny buddy */ | |
2991 | 6062 if (curitem->name) { |
6063 GSList *list; | |
5575 | 6064 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6065 if (!list) { |
8660 | 6066 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6067 "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
|
6068 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6069 } |
6070 } | |
4230 | 6071 } break; |
6072 | |
6073 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6074 if (curitem->data) { |
6075 fu8_t permdeny; | |
5575 | 6076 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6077 gaim_debug_info("oscar", |
5575 | 6078 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6079 account->perm_deny = permdeny; | |
6080 if (od->icq && account->perm_deny == 0x03) { | |
9973 | 6081 serv_set_status(gc, "Invisible", ""); |
4342 | 6082 } |
2991 | 6083 } |
6084 } | |
4230 | 6085 } break; |
6086 | |
6087 case 0x0005: { /* Presence setting */ | |
3109 | 6088 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6089 } break; |
2991 | 6090 } /* End of switch on curitem->type */ |
6091 } /* End of for loop */ | |
4230 | 6092 |
4901 | 6093 /* Set our ICQ status */ |
8257 | 6094 if (!gc->away) { |
4901 | 6095 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6096 } | |
6097 | |
4342 | 6098 /* Activate SSI */ |
6099 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6100 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6101 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6102 "ssi: activating server-stored buddy list\n"); |
4642 | 6103 aim_ssi_enable(sess); |
4342 | 6104 |
2991 | 6105 return 1; |
2086 | 6106 } |
4230 | 6107 |
6108 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6109 GaimConnection *gc = sess->aux_data; |
4230 | 6110 va_list ap; |
6111 struct aim_ssi_tmp *retval; | |
6112 | |
6113 va_start(ap, fr); | |
6114 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6115 va_end(ap); | |
6116 | |
6117 while (retval) { | |
8660 | 6118 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6119 "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 | 6120 |
6121 if (retval->ack != 0xffff) | |
6122 switch (retval->ack) { | |
6123 case 0x0000: { /* added successfully */ | |
6124 } break; | |
6125 | |
4829 | 6126 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6127 gchar *buf; | |
6128 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 | 6129 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6130 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6131 g_free(buf); |
6132 } | |
6133 | |
7023 | 6134 case 0x000e: { /* buddy requires authorization */ |
4828 | 6135 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6136 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6137 } break; |
6138 | |
6139 default: { /* La la la */ | |
5197 | 6140 gchar *buf; |
8660 | 6141 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6142 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 | 6143 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6144 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6145 g_free(buf); |
4230 | 6146 } break; |
6147 } | |
6148 | |
6149 retval = retval->next; | |
6150 } | |
6151 | |
6152 return 1; | |
6153 } | |
6154 | |
8227 | 6155 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6156 GaimConnection *gc = sess->aux_data; | |
6157 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6158 GaimBuddy *b; | |
6159 GaimGroup *g; | |
6160 va_list ap; | |
6161 fu16_t type; | |
6162 const char *name; | |
6163 | |
6164 va_start(ap, fr); | |
6165 type = (fu16_t)va_arg(ap, int); | |
6166 name = va_arg(ap, char *); | |
6167 va_end(ap); | |
6168 | |
6169 if ((type != 0x0000) || (name == NULL)) | |
6170 return 1; | |
6171 | |
6172 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6173 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6174 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6175 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6176 b = gaim_find_buddy(gc->account, name); | |
6177 free(alias); | |
6178 | |
6179 if (b) { | |
6180 /* Get server stored alias */ | |
6181 if (alias_utf8) { | |
6182 g_free(b->alias); | |
6183 b->alias = g_strdup(alias_utf8); | |
6184 } | |
6185 } else { | |
6186 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6187 | |
6188 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6189 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6190 gaim_blist_add_group(g, NULL); | |
6191 } | |
6192 | |
8660 | 6193 gaim_debug_info("oscar", |
9285 | 6194 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6195 gaim_blist_add_buddy(b, NULL, g, NULL); |
6196 } | |
6197 g_free(gname_utf8); | |
6198 g_free(alias_utf8); | |
6199 | |
6200 return 1; | |
6201 } | |
6202 | |
4230 | 6203 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6204 GaimConnection *gc = sess->aux_data; |
4230 | 6205 va_list ap; |
6206 char *sn, *msg; | |
4236 | 6207 gchar *dialog_msg, *nombre; |
4230 | 6208 struct name_data *data; |
6695 | 6209 GaimBuddy *buddy; |
4230 | 6210 |
6211 va_start(ap, fr); | |
6212 sn = va_arg(ap, char *); | |
6213 msg = va_arg(ap, char *); | |
6214 va_end(ap); | |
6215 | |
8660 | 6216 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6217 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6218 |
4687 | 6219 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6220 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6221 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6222 else |
6223 nombre = g_strdup(sn); | |
6224 | |
6225 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 | 6226 data = g_new(struct name_data, 1); |
6227 data->gc = gc; | |
6228 data->name = g_strdup(sn); | |
6229 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6230 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6231 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6232 0, data, |
7023 | 6233 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6234 G_CALLBACK(oscar_free_name_data)); |
4236 | 6235 |
4230 | 6236 g_free(dialog_msg); |
4236 | 6237 g_free(nombre); |
4230 | 6238 |
6239 return 1; | |
6240 } | |
6241 | |
6242 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6243 GaimConnection *gc = sess->aux_data; |
4230 | 6244 va_list ap; |
6245 char *sn, *msg; | |
4236 | 6246 gchar *dialog_msg, *nombre; |
4230 | 6247 struct name_data *data; |
6695 | 6248 GaimBuddy *buddy; |
4230 | 6249 |
6250 va_start(ap, fr); | |
6251 sn = va_arg(ap, char *); | |
6252 msg = va_arg(ap, char *); | |
6253 va_end(ap); | |
6254 | |
8660 | 6255 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6256 "ssi: received authorization request from %s\n", sn); |
4230 | 6257 |
4687 | 6258 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6259 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6260 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6261 else |
6262 nombre = g_strdup(sn); | |
6263 | |
4337 | 6264 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 | 6265 data = g_new(struct name_data, 1); |
6266 data->gc = gc; | |
6267 data->name = g_strdup(sn); | |
6268 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6269 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6270 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6271 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6272 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6273 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6274 |
4230 | 6275 g_free(dialog_msg); |
4236 | 6276 g_free(nombre); |
4230 | 6277 |
6278 return 1; | |
6279 } | |
6280 | |
6281 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6282 GaimConnection *gc = sess->aux_data; |
4230 | 6283 va_list ap; |
6284 char *sn, *msg; | |
4236 | 6285 gchar *dialog_msg, *nombre; |
4230 | 6286 fu8_t reply; |
6695 | 6287 GaimBuddy *buddy; |
4230 | 6288 |
6289 va_start(ap, fr); | |
6290 sn = va_arg(ap, char *); | |
6291 reply = (fu8_t)va_arg(ap, int); | |
6292 msg = va_arg(ap, char *); | |
6293 va_end(ap); | |
6294 | |
8660 | 6295 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6296 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6297 |
4687 | 6298 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6299 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6300 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6301 else |
6302 nombre = g_strdup(sn); | |
6303 | |
4230 | 6304 if (reply) { |
6305 /* Granted */ | |
7023 | 6306 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
|
6307 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6308 } else { |
6309 /* Denied */ | |
7023 | 6310 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
|
6311 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6312 } |
6313 g_free(dialog_msg); | |
4236 | 6314 g_free(nombre); |
4230 | 6315 |
6316 return 1; | |
6317 } | |
6318 | |
6319 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6320 GaimConnection *gc = sess->aux_data; |
4230 | 6321 va_list ap; |
6322 char *sn; | |
6695 | 6323 GaimBuddy *buddy; |
4230 | 6324 |
6325 va_start(ap, fr); | |
6326 sn = va_arg(ap, char *); | |
6327 va_end(ap); | |
6328 | |
4687 | 6329 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6330 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6331 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6332 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6333 |
6334 return 1; | |
6335 } | |
4269 | 6336 #endif |
2086 | 6337 |
5575 | 6338 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6339 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6340 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6341 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6342 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6343 pce->label = _("_Room:"); |
5234 | 6344 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6345 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6346 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6347 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6348 pce->label = _("_Exchange:"); |
5234 | 6349 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6350 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6351 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6352 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6353 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6354 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6355 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6356 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6357 |
9754 | 6358 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6359 { | |
6360 GHashTable *defaults; | |
6361 | |
6362 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6363 | |
6364 if (chat_name != NULL) | |
6365 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6366 | |
6367 return defaults; | |
6368 } | |
6369 | |
9917 | 6370 static char *oscar_get_chat_name(GHashTable *data) { |
6371 return g_strdup(g_hash_table_lookup(data, "room")); | |
6372 } | |
6373 | |
8308 | 6374 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6375 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6376 aim_conn_t *cur; |
5234 | 6377 char *name, *exchange; |
6378 | |
6379 name = g_hash_table_lookup(data, "room"); | |
6380 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6381 |
8660 | 6382 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6383 "Attempting to join chat room %s.\n", name); |
8308 | 6384 |
6385 if ((name == NULL) || (*name == '\0')) { | |
6386 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6387 return; | |
6388 } | |
6389 | |
4617 | 6390 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6391 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6392 "chatnav exists, creating room\n"); |
5234 | 6393 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6394 } else { |
6395 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6396 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6397 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6398 "chatnav does not exist, opening chatnav\n"); |
5234 | 6399 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6400 cr->name = g_strdup(name); |
4617 | 6401 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6402 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6403 } |
6404 } | |
6405 | |
8308 | 6406 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6407 OscarData *od = (OscarData *)gc->proto_data; | |
6408 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6409 |
6410 if (!ccon) | |
6411 return; | |
6412 | |
8225 | 6413 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6414 ccon->exchange, ccon->name, 0x0); |
6415 } | |
6416 | |
8308 | 6417 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6418 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6419 GSList *bcs = gc->buddy_chats; | |
5679 | 6420 GaimConversation *b = NULL; |
2086 | 6421 struct chat_connection *c = NULL; |
6422 int count = 0; | |
6423 | |
6424 while (bcs) { | |
6425 count++; | |
5679 | 6426 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6427 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6428 break; |
6429 bcs = bcs->next; | |
6430 b = NULL; | |
6431 } | |
6432 | |
6433 if (!b) | |
6434 return; | |
6435 | |
8660 | 6436 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6437 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6438 |
8308 | 6439 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6440 if (c != NULL) { |
4617 | 6441 if (od) |
6442 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6443 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6444 gaim_input_remove(c->inpa); |
8308 | 6445 if (gc && od->sess) |
4617 | 6446 aim_conn_kill(od->sess, &c->conn); |
2086 | 6447 g_free(c->name); |
6448 g_free(c->show); | |
6449 g_free(c); | |
6450 } | |
6451 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6452 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6453 } |
6454 | |
8219 | 6455 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6456 OscarData *od = (OscarData *)gc->proto_data; | |
6457 GaimConversation *conv = NULL; | |
2086 | 6458 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6459 char *buf, *buf2; |
9830 | 6460 fu16_t charset, charsubset; |
9807 | 6461 char *charsetstr = NULL; |
8907 | 6462 gsize len; |
8219 | 6463 |
6464 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6465 return -EINVAL; |
2086 | 6466 |
8219 | 6467 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6468 return -EINVAL; |
2086 | 6469 |
8219 | 6470 buf = gaim_strdup_withhtml(message); |
6471 len = strlen(buf); | |
6472 | |
8962 | 6473 if (strstr(buf, "<IMG ")) |
6474 gaim_conversation_write(conv, "", | |
6475 _("Your IM Image was not sent. " | |
6476 "You cannot send IM Images in AIM chats."), | |
6477 GAIM_MESSAGE_ERROR, time(NULL)); | |
6478 | |
9830 | 6479 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6480 if ((len > c->maxlen) || (len > c->maxvis)) { |
6481 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6482 return -E2BIG; |
8359 | 6483 } |
6484 | |
9831 | 6485 if (charset == AIM_CHARSET_ASCII) |
6486 charsetstr = "us-ascii"; | |
6487 else if (charset == AIM_CHARSET_UNICODE) | |
6488 charsetstr = "unicode-2-0"; | |
6489 else if (charset == AIM_CHARSET_CUSTOM) | |
6490 charsetstr = "iso-8859-1"; | |
9807 | 6491 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6492 g_free(buf2); |
8359 | 6493 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6494 return 0; |
2086 | 6495 } |
6496 | |
6695 | 6497 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6498 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6499 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6500 return "icq"; |
6501 else | |
6502 return "aim"; | |
6503 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6504 |
9975 | 6505 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6506 return "icq"; |
6507 return "aim"; | |
6508 } | |
6509 | |
9972 | 6510 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6511 { |
7334 | 6512 GaimAccount *account = NULL; |
6513 GaimConnection *gc = NULL; | |
6514 OscarData *od = NULL; | |
4687 | 6515 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6516 int i = 0; | |
7334 | 6517 aim_userinfo_t *userinfo = NULL; |
6518 | |
6519 if (b != NULL) | |
6520 account = b->account; | |
6521 if (account != NULL) | |
6522 gc = account->gc; | |
6523 if (gc != NULL) | |
6524 od = gc->proto_data; | |
7945 | 6525 if (od != NULL) |
6526 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6527 |
5131 | 6528 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6529 char *gname; | |
7334 | 6530 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6531 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6532 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6533 emblems[i++] = "notauthorized"; | |
6534 } else { | |
6535 emblems[i++] = "offline"; | |
6536 } | |
6537 } | |
4916 | 6538 |
9975 | 6539 if (b->name && (b->uc & 0xffff0000) && aim_sn_is_icq(b->name)) { |
4960 | 6540 int uc = b->uc >> 16; |
4766 | 6541 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6542 emblems[i++] = "invisible"; |
4766 | 6543 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6544 emblems[i++] = "freeforchat"; |
4766 | 6545 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6546 emblems[i++] = "dnd"; |
4766 | 6547 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6548 emblems[i++] = "na"; |
4766 | 6549 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6550 emblems[i++] = "occupied"; |
4766 | 6551 else if (uc & AIM_ICQ_STATE_AWAY) |
6552 emblems[i++] = "away"; | |
6553 } else { | |
6554 if (b->uc & UC_UNAVAILABLE) | |
6555 emblems[i++] = "away"; | |
6556 } | |
4687 | 6557 if (b->uc & UC_WIRELESS) |
6558 emblems[i++] = "wireless"; | |
6559 if (b->uc & UC_AOL) | |
6560 emblems[i++] = "aol"; | |
6561 if (b->uc & UC_ADMIN) | |
6562 emblems[i++] = "admin"; | |
6563 if (b->uc & UC_AB && i < 4) | |
6564 emblems[i++] = "activebuddy"; | |
4766 | 6565 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6566 emblems[i++] = "unconfirmed"; */ | |
7334 | 6567 |
7945 | 6568 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6569 emblems[i++] = "hiptop"; | |
6570 | |
6571 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6572 emblems[i++] = "secure"; |
6573 | |
4687 | 6574 *se = emblems[0]; |
6575 *sw = emblems[1]; | |
6576 *nw = emblems[2]; | |
6577 *ne = emblems[3]; | |
6578 } | |
6579 | |
6695 | 6580 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6581 GaimConnection *gc = b->account->gc; |
7283 | 6582 OscarData *od = gc->proto_data; |
7045 | 6583 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6584 GString *str = g_string_new(""); |
5131 | 6585 |
6586 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6587 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6588 |
6589 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6590 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6591 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6592 g_free(charset); |
7011 | 6593 if (away_utf8 != NULL) { |
7091 | 6594 gchar *tmp1, *tmp2; |
9627 | 6595 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6596 g_free(away_utf8); |
8571 | 6597 tmp1 = gaim_escape_html(tmp2); |
7091 | 6598 g_free(tmp2); |
8700 | 6599 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6600 g_free(tmp1); |
8701 | 6601 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6602 g_free(tmp2); |
5836 | 6603 } |
5131 | 6604 } |
8701 | 6605 } |
6606 | |
6607 return g_string_free(str, FALSE); | |
5131 | 6608 } |
6609 | |
6695 | 6610 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 6611 GaimConnection *gc = b->account->gc; |
7283 | 6612 OscarData *od = gc->proto_data; |
5167 | 6613 gchar *ret = NULL; |
6614 | |
6615 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6616 if (aim_sn_is_icq(b->name)) |
8701 | 6617 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6618 else |
6619 ret = g_strdup(_("Away")); | |
5836 | 6620 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6621 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 6622 if (bi->availmsg) |
6623 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 6624 } else { |
5167 | 6625 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6626 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6627 ret = g_strdup(_("Not Authorized")); | |
6628 else | |
6629 ret = g_strdup(_("Offline")); | |
6630 } | |
6631 | |
6632 return ret; | |
6633 } | |
6634 | |
5842 | 6635 |
5844 | 6636 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6637 GaimConnection *gc = sess->aux_data; |
7283 | 6638 OscarData *od = gc->proto_data; |
5892 | 6639 va_list ap; |
5842 | 6640 fu16_t type; |
5892 | 6641 fu8_t flags = 0, length = 0; |
6642 char *md5 = NULL; | |
6643 | |
7334 | 6644 |
5842 | 6645 va_start(ap, fr); |
6646 type = va_arg(ap, int); | |
5892 | 6647 |
6648 switch(type) { | |
6649 case 0x0000: | |
6650 case 0x0001: { | |
6651 flags = va_arg(ap, int); | |
6652 length = va_arg(ap, int); | |
6653 md5 = va_arg(ap, char *); | |
6654 | |
6655 if (flags == 0x41) { | |
6656 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6657 od->iconconnecting = TRUE; | |
6658 od->set_icon = TRUE; | |
6659 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6660 } else { | |
6039 | 6661 struct stat st; |
6662 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6663 if (iconfile == NULL) { | |
8363 | 6664 aim_ssi_delicon(od->sess); |
6039 | 6665 } else if (!stat(iconfile, &st)) { |
6666 char *buf = g_malloc(st.st_size); | |
6667 FILE *file = fopen(iconfile, "rb"); | |
6668 if (file) { | |
9532 | 6669 /* XXX - Use g_file_get_contents()? */ |
6039 | 6670 fread(buf, 1, st.st_size, file); |
6671 fclose(file); | |
8660 | 6672 gaim_debug_info("oscar", |
6039 | 6673 "Uploading icon to icon server\n"); |
6879 | 6674 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6675 } else |
8660 | 6676 gaim_debug_error("oscar", |
6039 | 6677 "Can't open buddy icon file!\n"); |
6678 g_free(buf); | |
6679 } else { | |
8660 | 6680 gaim_debug_error("oscar", |
6039 | 6681 "Can't stat buddy icon file!\n"); |
5892 | 6682 } |
6683 } | |
8363 | 6684 } else if (flags == 0x81) { |
6685 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6686 if (iconfile == NULL) | |
6687 aim_ssi_delicon(od->sess); | |
6688 else | |
6689 aim_ssi_seticon(od->sess, md5, length); | |
6690 } | |
5892 | 6691 } break; |
6692 | |
6693 case 0x0002: { /* We just set an "available" message? */ | |
6694 } break; | |
6695 } | |
6696 | |
5842 | 6697 va_end(ap); |
5844 | 6698 |
6699 return 0; | |
5842 | 6700 } |
5892 | 6701 |
5575 | 6702 static void oscar_set_permit_deny(GaimConnection *gc) { |
6703 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6704 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6705 #ifdef NOSSI |
8143 | 6706 GSList *list; |
4230 | 6707 char buf[MAXMSGLEN]; |
6708 int at; | |
6709 | |
5575 | 6710 switch(account->perm_deny) { |
8175 | 6711 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6712 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6713 break; |
8175 | 6714 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6715 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6716 break; |
8175 | 6717 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6718 list = account->permit; |
4230 | 6719 at = 0; |
6720 while (list) { | |
6721 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6722 list = list->next; | |
6723 } | |
6724 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6725 break; | |
8175 | 6726 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6727 list = account->deny; |
4230 | 6728 at = 0; |
6729 while (list) { | |
6730 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6731 list = list->next; | |
6732 } | |
6733 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6734 break; | |
6735 default: | |
6736 break; | |
2086 | 6737 } |
4230 | 6738 #else |
8175 | 6739 if (od->sess->ssi.received_data) { |
6740 switch (account->perm_deny) { | |
6741 case GAIM_PRIVACY_ALLOW_ALL: | |
6742 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6743 break; | |
6744 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6745 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6746 break; | |
6747 case GAIM_PRIVACY_ALLOW_USERS: | |
6748 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6749 break; | |
6750 case GAIM_PRIVACY_DENY_ALL: | |
6751 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6752 break; | |
6753 case GAIM_PRIVACY_DENY_USERS: | |
6754 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6755 break; | |
6756 default: | |
6757 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6758 break; | |
6759 } | |
6760 } | |
4230 | 6761 #endif |
2086 | 6762 } |
6763 | |
5575 | 6764 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6765 #ifdef NOSSI |
8143 | 6766 if (gc->account->perm_deny == 3) |
4269 | 6767 oscar_set_permit_deny(gc); |
6768 #else | |
7283 | 6769 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6770 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6771 if (od->sess->ssi.received_data) |
4889 | 6772 aim_ssi_addpermit(od->sess, who); |
4230 | 6773 #endif |
2086 | 6774 } |
6775 | |
5575 | 6776 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6777 #ifdef NOSSI |
8143 | 6778 if (gc->account->perm_deny == 4) |
4269 | 6779 oscar_set_permit_deny(gc); |
6780 #else | |
7283 | 6781 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6782 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6783 if (od->sess->ssi.received_data) |
4889 | 6784 aim_ssi_adddeny(od->sess, who); |
4230 | 6785 #endif |
2086 | 6786 } |
6787 | |
5575 | 6788 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6789 #ifdef NOSSI |
8143 | 6790 if (gc->account->perm_deny == 3) |
4269 | 6791 oscar_set_permit_deny(gc); |
6792 #else | |
7283 | 6793 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6794 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6795 if (od->sess->ssi.received_data) |
4889 | 6796 aim_ssi_delpermit(od->sess, who); |
4230 | 6797 #endif |
2086 | 6798 } |
6799 | |
5575 | 6800 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6801 #ifdef NOSSI |
8143 | 6802 if (gc->account->perm_deny == 4) |
4269 | 6803 oscar_set_permit_deny(gc); |
6804 #else | |
7283 | 6805 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6806 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6807 if (od->sess->ssi.received_data) |
4889 | 6808 aim_ssi_deldeny(od->sess, who); |
4230 | 6809 #endif |
2086 | 6810 } |
6811 | |
9975 | 6812 static GList * |
6813 oscar_status_types(GaimAccount *account) | |
2086 | 6814 { |
9975 | 6815 GList *status_types = NULL; |
6816 GaimStatusType *type; | |
6817 gboolean is_icq; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6818 |
9973 | 6819 g_return_val_if_fail(account != NULL, NULL); |
6820 | |
9975 | 6821 is_icq = aim_sn_is_icq(gaim_account_get_username(account)); |
6822 | |
9976 | 6823 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, OSCAR_STATUS_ID_INVISIBLE, _("Invisible"), FALSE, TRUE, FALSE); |
6824 status_types = g_list_append(status_types, type); | |
6825 | |
6826 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, OSCAR_STATUS_ID_OFFLINE, _("Offline"), FALSE, FALSE, FALSE); | |
6827 status_types = g_list_append(status_types, type); | |
6828 | |
6829 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, OSCAR_STATUS_ID_ONLINE, _("Online"), FALSE, FALSE, FALSE); | |
6830 status_types = g_list_append(status_types, type); | |
6831 | |
6832 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, OSCAR_STATUS_ID_AWAY, _("Away"), FALSE, TRUE, FALSE); | |
6833 status_types = g_list_append(status_types, type); | |
6834 | |
6835 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, OSCAR_STATUS_ID_DND, _("Do Not Disturb"), FALSE, TRUE, FALSE); | |
6836 status_types = g_list_append(status_types, type); | |
6837 | |
6838 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, OSCAR_STATUS_ID_NA, _("Not Available"), FALSE, TRUE, FALSE); | |
6839 status_types = g_list_append(status_types, type); | |
6840 | |
6841 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, OSCAR_STATUS_ID_OCCUPIED, _("Occupied"), FALSE, TRUE, FALSE); | |
6842 status_types = g_list_append(status_types, type); | |
6843 | |
6844 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, OSCAR_STATUS_ID_FREE4CHAT, _("Free For Chat"), FALSE, TRUE, FALSE); | |
6845 status_types = g_list_append(status_types, type); | |
9975 | 6846 |
6847 return status_types; | |
6848 | |
9976 | 6849 /* |
6850 * Do something with: | |
6851 * #define OSCAR_STATUS_ID_CUSTOM "custom" | |
6852 */ | |
6853 | |
9975 | 6854 #if 0 /* STATUS - old stuff that should be removed */ |
8257 | 6855 if (od->icq) { |
6856 m = g_list_append(m, _("Online")); | |
6857 m = g_list_append(m, _("Away")); | |
6858 m = g_list_append(m, _("Do Not Disturb")); | |
6859 m = g_list_append(m, _("Not Available")); | |
6860 m = g_list_append(m, _("Occupied")); | |
6861 m = g_list_append(m, _("Free For Chat")); | |
6862 m = g_list_append(m, _("Invisible")); | |
6863 } else { | |
6864 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6865 m = g_list_append(m, _("Back")); |
8257 | 6866 m = g_list_append(m, _("Visible")); |
6867 m = g_list_append(m, _("Invisible")); | |
6868 } | |
4333 | 6869 |
6870 return m; | |
9975 | 6871 #endif |
4333 | 6872 } |
6873 | |
7172 | 6874 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6875 GaimConnection *gc = data->gc; |
6876 OscarData *od = gc->proto_data; | |
7172 | 6877 GaimBuddy *b; |
6878 GaimGroup *g; | |
6879 | |
6880 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6881 oscar_free_name_data(data); | |
6882 return; | |
6883 } | |
6884 | |
6885 if (!(g = gaim_find_buddys_group(b))) { | |
6886 oscar_free_name_data(data); | |
6887 return; | |
6888 } | |
6889 | |
6890 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6891 |
6892 if (!aim_sncmp(data->name, gc->account->username)) | |
6893 gaim_check_comment(od, text); | |
6894 | |
7172 | 6895 oscar_free_name_data(data); |
6896 } | |
6897 | |
9030 | 6898 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6899 | |
6900 GaimBuddy *buddy; | |
6901 GaimConnection *gc; | |
6902 OscarData *od; | |
6903 struct name_data *data; | |
7172 | 6904 GaimGroup *g; |
6905 char *comment; | |
6906 gchar *comment_utf8; | |
9631 | 6907 gchar *title; |
7172 | 6908 |
9030 | 6909 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6910 | |
6911 buddy = (GaimBuddy *) node; | |
6912 gc = gaim_account_get_connection(buddy->account); | |
6913 od = gc->proto_data; | |
6914 | |
6915 data = g_new(struct name_data, 1); | |
6916 | |
6917 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6918 return; |
9030 | 6919 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6920 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6921 | |
6922 data->gc = gc; | |
9030 | 6923 data->name = g_strdup(buddy->name); |
7172 | 6924 data->nick = NULL; |
6925 | |
9631 | 6926 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6927 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6928 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6929 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6930 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6931 data); | |
9631 | 6932 g_free(title); |
7172 | 6933 |
6934 free(comment); | |
6935 g_free(comment_utf8); | |
6936 } | |
6937 | |
9030 | 6938 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6939 | |
6940 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6941 OscarData *od = gc->proto_data; |
9030 | 6942 |
4333 | 6943 GList *m = NULL; |
9030 | 6944 GaimBlistNodeAction *act; |
6945 | |
6946 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6947 oscar_buddycb_edit_comment, NULL); | |
6948 m = g_list_append(m, act); | |
7172 | 6949 |
4333 | 6950 if (od->icq) { |
4624 | 6951 #if 0 |
9030 | 6952 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6953 oscar_get_icqstatusmsg, NULL); | |
6954 m = g_list_append(m, act); | |
4624 | 6955 #endif |
4333 | 6956 } else { |
7011 | 6957 aim_userinfo_t *userinfo; |
9030 | 6958 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6959 | |
6960 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
6961 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
6962 | |
7011 | 6963 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 6964 act = gaim_blist_node_action_new(_("Direct IM"), |
6965 oscar_ask_direct_im, NULL); | |
6966 m = g_list_append(m, act); | |
5917 | 6967 } |
9466 | 6968 #if 0 |
7011 | 6969 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6970 act = gaim_blist_node_action_new(_("Get File"), |
6971 oscar_ask_getfile, NULL); | |
6972 m = g_list_append(m, act); | |
5917 | 6973 } |
4826 | 6974 #endif |
4333 | 6975 } |
5131 | 6976 } |
5197 | 6977 |
5131 | 6978 if (od->sess->ssi.received_data) { |
9030 | 6979 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6980 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
6981 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
6982 gaim_auth_sendrequest_menu, NULL); | |
6983 m = g_list_append(m, act); | |
4333 | 6984 } |
4916 | 6985 } |
6986 | |
4333 | 6987 return m; |
6988 } | |
6989 | |
9030 | 6990 |
6991 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6992 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6993 return oscar_buddy_menu((GaimBuddy *) node); | |
6994 } else { | |
6995 return NULL; | |
6996 } | |
6997 } | |
6998 | |
6999 | |
5575 | 7000 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7001 OscarData *od = gc->proto_data; |
5575 | 7002 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7003 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7004 od->setnick = TRUE; | |
7005 od->newsn = g_strdup(nick); | |
7006 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7007 } else { | |
7008 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7009 } | |
7010 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7011 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7012 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7013 } |
7014 } | |
7015 | |
9015 | 7016 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7017 { |
9015 | 7018 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7019 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7020 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7021 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7022 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7023 gc); |
4333 | 7024 } |
7025 | |
9015 | 7026 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7027 { |
9015 | 7028 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7029 OscarData *od = gc->proto_data; |
4333 | 7030 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7031 | |
7032 if (conn) { | |
7033 aim_admin_reqconfirm(od->sess, conn); | |
7034 } else { | |
7035 od->conf = TRUE; | |
7036 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7037 } | |
7038 } | |
7039 | |
9015 | 7040 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7041 { |
9015 | 7042 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7043 OscarData *od = gc->proto_data; |
4333 | 7044 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7045 | |
7046 if (conn) { | |
7047 aim_admin_getinfo(od->sess, conn, 0x11); | |
7048 } else { | |
7049 od->reqemail = TRUE; | |
7050 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7051 } | |
7052 } | |
7053 | |
5575 | 7054 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7055 { |
7283 | 7056 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7057 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
|
7058 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7059 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7060 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7061 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7062 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7063 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7064 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7065 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7066 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7067 |
9015 | 7068 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7069 { |
9015 | 7070 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7071 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7072 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7073 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7074 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7075 gc); |
4333 | 7076 } |
7077 | |
9015 | 7078 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7079 { |
9015 | 7080 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7081 OscarData *od = gc->proto_data; |
4333 | 7082 gchar *nombre, *text, *tmp; |
6695 | 7083 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7084 int num=0; |
7085 | |
6873 | 7086 text = g_strdup(""); |
4333 | 7087 |
4785 | 7088 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7089 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7090 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7091 continue; | |
6695 | 7092 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7093 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7094 continue; |
6695 | 7095 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7096 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7097 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7098 continue; | |
7099 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7100 if (gaim_buddy_get_alias_only(buddy)) |
7101 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7102 else |
7103 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7104 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7105 g_free(text); |
7106 text = tmp; | |
7107 g_free(nombre); | |
7108 num++; | |
7109 } | |
4333 | 7110 } |
2979 | 7111 } |
4333 | 7112 } |
7113 | |
7114 if (!num) { | |
7115 g_free(text); | |
6873 | 7116 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7117 } | |
7118 | |
7119 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7120 "the following buddies"), _("You can re-request " | |
7121 "authorization from these buddies by " | |
7122 "right-clicking on them and selecting " | |
7123 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7124 g_free(text); |
2979 | 7125 } |
7126 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7127 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7128 { |
8950 | 7129 OscarData *od = (OscarData *)gc->proto_data; |
7130 | |
7131 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7132 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7133 |
9015 | 7134 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7135 { |
9015 | 7136 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7137 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7138 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7139 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7140 "searching for."), |
8697 | 7141 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7142 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7143 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7144 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7145 |
5917 | 7146 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 7147 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 7148 |
7334 | 7149 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 7150 aim_srv_setavailmsg(od->sess, text); |
7151 } | |
7152 | |
9879 | 7153 static void oscar_show_setavailmsg(GaimPluginAction *action) |
5917 | 7154 { |
9879 | 7155 GaimConnection *gc = (GaimConnection *) action->context; |
7313 | 7156 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
7157 _("I'm doing work and hoping for a distraction--IM me!"), | |
8697 | 7158 TRUE, FALSE, NULL, |
5917 | 7159 _("OK"), G_CALLBACK(oscar_setavailmsg), |
7160 _("Cancel"), NULL, | |
7161 gc); | |
7162 } | |
7163 | |
9015 | 7164 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7165 { |
9015 | 7166 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7167 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7168 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7169 |
9015 | 7170 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7171 { |
9015 | 7172 GaimConnection *gc = (GaimConnection *) action->context; |
9809 | 7173 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7174 } |
7175 | |
9015 | 7176 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7177 { |
9015 | 7178 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7179 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7180 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7181 |
9015 | 7182 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7183 { |
9015 | 7184 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7185 OscarData *od = gc->proto_data; |
5575 | 7186 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
|
7187 gaim_notify_uri(gc, substituted); |
5517 | 7188 g_free(substituted); |
4333 | 7189 } |
7190 | |
9015 | 7191 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7192 { |
9015 | 7193 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7194 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7195 } | |
7196 | |
5842 | 7197 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7198 { | |
7283 | 7199 OscarData *od = gc->proto_data; |
5844 | 7200 aim_session_t *sess = od->sess; |
5842 | 7201 FILE *file; |
7202 struct stat st; | |
5844 | 7203 |
6039 | 7204 if (iconfile == NULL) { |
8363 | 7205 aim_ssi_delicon(od->sess); |
6039 | 7206 } else if (!stat(iconfile, &st)) { |
5842 | 7207 char *buf = g_malloc(st.st_size); |
7208 file = fopen(iconfile, "rb"); | |
7209 if (file) { | |
6052 | 7210 md5_state_t *state; |
6039 | 7211 char md5[16]; |
9532 | 7212 /* XXX - Use g_file_get_contents()? */ |
5842 | 7213 int len = fread(buf, 1, st.st_size, file); |
6039 | 7214 fclose(file); |
6052 | 7215 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7216 md5_init(state); |
7217 md5_append(state, buf, len); | |
7218 md5_finish(state, md5); | |
7219 g_free(state); | |
7220 aim_ssi_seticon(sess, md5, 16); | |
7221 } else | |
8660 | 7222 gaim_debug_error("oscar", |
5842 | 7223 "Can't open buddy icon file!\n"); |
7224 g_free(buf); | |
7225 } else | |
8660 | 7226 gaim_debug_error("oscar", |
5842 | 7227 "Can't stat buddy icon file!\n"); |
7228 } | |
7229 | |
7230 | |
9015 | 7231 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7232 { |
9015 | 7233 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7234 OscarData *od = gc->proto_data; |
4333 | 7235 GList *m = NULL; |
9015 | 7236 GaimPluginAction *act; |
7237 | |
7238 act = gaim_plugin_action_new(_("Set User Info..."), | |
7239 oscar_show_set_info); | |
7240 m = g_list_append(m, act); | |
4333 | 7241 |
8576 | 7242 if (od->icq) { |
9015 | 7243 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7244 oscar_show_set_info_icqurl); | |
7245 m = g_list_append(m, act); | |
8576 | 7246 } |
7247 | |
9879 | 7248 if (!od->icq) { |
7249 act = gaim_plugin_action_new(_("Set Available Message..."), | |
7250 oscar_show_setavailmsg); | |
7251 m = g_list_append(m, act); | |
7252 } | |
5917 | 7253 |
9015 | 7254 act = gaim_plugin_action_new(_("Change Password..."), |
7255 oscar_change_pass); | |
7256 m = g_list_append(m, act); | |
4617 | 7257 |
7258 if (od->sess->authinfo->chpassurl) { | |
9015 | 7259 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7260 oscar_show_chpassurl); | |
7261 m = g_list_append(m, act); | |
7262 | |
7263 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7264 oscar_show_imforwardingurl); | |
7265 m = g_list_append(m, act); | |
7026 | 7266 } |
7267 | |
5238 | 7268 if (!od->icq) { |
4617 | 7269 /* AIM actions */ |
7270 m = g_list_append(m, NULL); | |
4333 | 7271 |
9015 | 7272 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7273 oscar_show_format_screenname); | |
7274 m = g_list_append(m, act); | |
7275 | |
7276 act = gaim_plugin_action_new(_("Confirm Account"), | |
7277 oscar_confirm_account); | |
7278 m = g_list_append(m, act); | |
7279 | |
7280 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7281 oscar_show_email); | |
7282 m = g_list_append(m, act); | |
7283 | |
7284 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7285 oscar_show_change_email); | |
7286 m = g_list_append(m, act); | |
2086 | 7287 } |
4333 | 7288 |
7289 m = g_list_append(m, NULL); | |
7290 | |
9015 | 7291 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7292 oscar_show_awaitingauth); | |
7293 m = g_list_append(m, act); | |
4333 | 7294 |
2086 | 7295 m = g_list_append(m, NULL); |
4333 | 7296 |
9015 | 7297 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7298 oscar_show_find_email); | |
7299 m = g_list_append(m, act); | |
4333 | 7300 |
8591 | 7301 #if 0 |
9015 | 7302 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7303 show_find_info); | |
7304 m = g_list_append(m, act); | |
8591 | 7305 #endif |
2086 | 7306 |
7307 return m; | |
7308 } | |
7309 | |
5575 | 7310 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7311 { |
7283 | 7312 OscarData *od = gc->proto_data; |
4617 | 7313 |
7314 if (od->icq) { | |
7315 aim_icq_changepasswd(od->sess, new); | |
2086 | 7316 } else { |
4617 | 7317 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7318 if (conn) { | |
7319 aim_admin_changepasswd(od->sess, conn, new, old); | |
7320 } else { | |
7321 od->chpass = TRUE; | |
7322 od->oldp = g_strdup(old); | |
7323 od->newp = g_strdup(new); | |
7324 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7325 } | |
2086 | 7326 } |
7327 } | |
7328 | |
6059 | 7329 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7330 { |
7283 | 7331 OscarData *od = gc->proto_data; |
8971 | 7332 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
|
7333 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7334 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7335 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7336 |
8971 | 7337 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7338 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7339 |
9935 | 7340 static void |
7341 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7342 { | |
7343 GaimConnection *gc = data; | |
7344 OscarData *od = gc->proto_data; | |
7345 aim_session_t *sess = od->sess; | |
7346 fu32_t presence; | |
7347 | |
7348 presence = aim_ssi_getpresence(sess->ssi.local); | |
7349 | |
7350 if (value) { | |
9971 | 7351 // presence |= 0x00400000; |
7352 presence &= ~0x00020000; | |
9935 | 7353 aim_ssi_setpresence(sess, presence); |
7354 } else { | |
9971 | 7355 // presence &= ~0x00400000; |
7356 presence |= 0x00020000; | |
9935 | 7357 aim_ssi_setpresence(sess, presence); |
7358 } | |
7359 } | |
7360 | |
7361 static GaimPluginPrefFrame * | |
9936 | 7362 get_plugin_pref_frame(GaimPlugin *plugin) |
7363 { | |
9935 | 7364 GaimPluginPrefFrame *frame; |
7365 GaimPluginPref *ppref; | |
7366 | |
7367 frame = gaim_plugin_pref_frame_new(); | |
7368 | |
7369 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7370 gaim_plugin_pref_frame_add(frame, ppref); | |
7371 | |
7372 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7373 gaim_plugin_pref_frame_add(frame, ppref); | |
7374 | |
7375 return frame; | |
7376 } | |
7377 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7378 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7379 { |
9308 | 7380 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7381 NULL, /* user_splits */ |
7382 NULL, /* protocol_options */ | |
7383 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7384 oscar_list_icon, /* list_icon */ | |
7385 oscar_list_emblems, /* list_emblems */ | |
7386 oscar_status_text, /* status_text */ | |
7387 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7388 oscar_status_types, /* status_types */ |
9475 | 7389 oscar_blist_node_menu, /* blist_node_menu */ |
7390 oscar_chat_info, /* chat_info */ | |
9754 | 7391 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7392 oscar_login, /* login */ |
7393 oscar_close, /* close */ | |
7394 oscar_send_im, /* send_im */ | |
7395 oscar_set_info, /* set_info */ | |
7396 oscar_send_typing, /* send_typing */ | |
7397 oscar_get_info, /* get_info */ | |
9973 | 7398 oscar_set_status, /* set_status */ |
9475 | 7399 oscar_set_idle, /* set_idle */ |
7400 oscar_change_passwd, /* change_passwd */ | |
7401 oscar_add_buddy, /* add_buddy */ | |
7402 oscar_add_buddies, /* add_buddies */ | |
7403 oscar_remove_buddy, /* remove_buddy */ | |
7404 oscar_remove_buddies, /* remove_buddies */ | |
7405 oscar_add_permit, /* add_permit */ | |
7406 oscar_add_deny, /* add_deny */ | |
7407 oscar_rem_permit, /* rem_permit */ | |
7408 oscar_rem_deny, /* rem_deny */ | |
7409 oscar_set_permit_deny, /* set_permit_deny */ | |
7410 oscar_warn, /* warn */ | |
7411 oscar_join_chat, /* join_chat */ | |
7412 NULL, /* reject_chat */ | |
9973 | 7413 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7414 oscar_chat_invite, /* chat_invite */ |
7415 oscar_chat_leave, /* chat_leave */ | |
7416 NULL, /* chat_whisper */ | |
7417 oscar_send_chat, /* chat_send */ | |
7418 oscar_keepalive, /* keepalive */ | |
7419 NULL, /* register_user */ | |
7420 NULL, /* get_cb_info */ | |
7421 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7422 #ifndef NOSSI |
9475 | 7423 oscar_alias_buddy, /* alias_buddy */ |
7424 oscar_move_buddy, /* group_buddy */ | |
7425 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7426 #else |
9475 | 7427 NULL, /* alias_buddy */ |
7428 NULL, /* group_buddy */ | |
7429 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7430 #endif |
9475 | 7431 NULL, /* buddy_free */ |
7432 oscar_convo_closed, /* convo_closed */ | |
7433 NULL, /* normalize */ | |
7434 oscar_set_icon, /* set_buddy_icon */ | |
7435 NULL, /* remove_group */ | |
7436 NULL, /* get_cb_real_name */ | |
7437 NULL, /* set_chat_topic */ | |
7438 NULL, /* find_blist_chat */ | |
7439 NULL, /* roomlist_get_list */ | |
7440 NULL, /* roomlist_cancel */ | |
7441 NULL, /* roomlist_expand_category */ | |
7442 oscar_can_receive_file, /* can_receive_file */ | |
7443 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7444 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7445 |
9935 | 7446 static GaimPluginUiInfo prefs_info = { |
7447 get_plugin_pref_frame | |
7448 }; | |
7449 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7450 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7451 { |
9943 | 7452 GAIM_PLUGIN_MAGIC, |
7453 GAIM_MAJOR_VERSION, | |
7454 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7455 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7456 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7457 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7458 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7459 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7460 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7461 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7462 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7463 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7464 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7465 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7466 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7467 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7468 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7469 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7470 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7471 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7472 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7473 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7474 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7475 NULL, /**< ui_info */ |
8993 | 7476 &prpl_info, /**< extra_info */ |
9935 | 7477 &prefs_info, /**< prefs_info */ |
9015 | 7478 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7479 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7480 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7481 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7482 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7483 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7484 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7485 |
9830 | 7486 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7487 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7488 | |
7489 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7490 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7491 | |
7492 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7493 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
|
7494 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7495 my_protocol = plugin; |
9935 | 7496 |
7497 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7498 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7499 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7500 } |
7501 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7502 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |