Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 9975:c66345b33b88
[gaim-migrate @ 10886]
Steps in the right direction for oscar
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 08 Sep 2004 03:33:37 +0000 |
parents | 09ed9a574761 |
children | f4ff7d2b9b2c |
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 |
9975 | 49 #define AIM_ICQ_STATUS_ID_ONLINE "online" |
50 #define AIM_ICQ_STATUS_ID_AWAY "away" | |
51 #define AIM_ICQ_STATUS_ID_DND "dnd" | |
52 #define AIM_ICQ_STATUS_ID_NA "na" | |
53 #define AIM_ICQ_STATUS_ID_OCCUPIED "occupied" | |
54 #define AIM_ICQ_STATUS_ID_FREE4CHAT "free4chat" | |
55 #define AIM_ICQ_STATUS_ID_INVISIBLE "invisible" | |
56 #define AIM_ICQ_STATUS_ID_CUSTOM "custom" | |
57 | |
58 #define UC_UNAVAILABLE 0x01 | |
59 #define UC_AOL 0x02 | |
60 #define UC_ADMIN 0x04 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
61 #define UC_UNCONFIRMED 0x08 |
9975 | 62 #define UC_NORMAL 0x10 |
63 #define UC_AB 0x20 | |
64 #define UC_WIRELESS 0x40 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
65 |
2086 | 66 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
67 | |
7283 | 68 #define OSCAR_CONNECT_STEPS 6 |
9830 | 69 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 70 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
71 static GaimPlugin *my_protocol = NULL; |
4249 | 72 |
7376 | 73 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
74 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 75 |
4665 | 76 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
77 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 78 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 79 |
7283 | 80 typedef struct _OscarData OscarData; |
81 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
82 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
83 aim_conn_t *conn; |
2086 | 84 |
85 guint cnpa; | |
86 guint paspa; | |
3694 | 87 guint emlpa; |
4804 | 88 guint icopa; |
2086 | 89 |
4823 | 90 gboolean iconconnecting; |
5842 | 91 gboolean set_icon; |
4823 | 92 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
93 GSList *create_rooms; |
2086 | 94 |
95 gboolean conf; | |
96 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
97 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
98 char *email; |
2979 | 99 gboolean setnick; |
100 char *newsn; | |
2086 | 101 gboolean chpass; |
102 char *oldp; | |
103 char *newp; | |
9971 | 104 |
2086 | 105 GSList *oscar_chats; |
106 GSList *direct_ims; | |
3630 | 107 GSList *file_transfers; |
4738 | 108 GHashTable *buddyinfo; |
4804 | 109 GSList *requesticon; |
2086 | 110 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
111 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
112 gboolean icq; |
4804 | 113 guint icontimer; |
5968 | 114 guint getblisttimer; |
8341 | 115 guint getinfotimer; |
9971 | 116 guint recentbuddies_cbid; |
2993 | 117 |
118 struct { | |
4230 | 119 guint maxwatchers; /* max users who can watch you */ |
2993 | 120 guint maxbuddies; /* max users you can watch */ |
4230 | 121 guint maxgroups; /* max groups in server list */ |
2993 | 122 guint maxpermits; /* max users on permit list */ |
123 guint maxdenies; /* max users on deny list */ | |
124 guint maxsiglen; /* max size (bytes) of profile */ | |
125 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
126 } rights; | |
2086 | 127 }; |
128 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
129 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
130 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
133 |
2086 | 134 struct chat_connection { |
135 char *name; | |
136 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
137 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
138 fu16_t instance; |
2086 | 139 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
|
140 aim_conn_t *conn; |
2086 | 141 int inpa; |
142 int id; | |
5575 | 143 GaimConnection *gc; /* i hate this. */ |
8733 | 144 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
145 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
146 int maxvis; |
2086 | 147 }; |
148 | |
8971 | 149 struct oscar_direct_im { |
5575 | 150 GaimConnection *gc; |
2086 | 151 char name[80]; |
152 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
153 aim_conn_t *conn; |
3008 | 154 gboolean connected; |
8978 | 155 gboolean gpc_pend; |
156 gboolean killme; | |
8984 | 157 gboolean donttryagain; |
2086 | 158 }; |
159 | |
160 struct ask_direct { | |
5575 | 161 GaimConnection *gc; |
2086 | 162 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
163 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
164 fu8_t cookie[8]; |
8984 | 165 gboolean donttryagain; |
2086 | 166 }; |
167 | |
7011 | 168 /* |
169 * Various PRPL-specific buddy info that we want to keep track of | |
170 * Some other info is maintained by locate.c, and I'd like to move | |
171 * the rest of this to libfaim, mostly im.c | |
172 */ | |
4738 | 173 struct buddyinfo { |
174 gboolean typingnot; | |
6292 | 175 gchar *availmsg; |
6857 | 176 fu32_t ipaddr; |
5836 | 177 |
178 unsigned long ico_me_len; | |
179 unsigned long ico_me_csum; | |
180 time_t ico_me_time; | |
181 gboolean ico_informed; | |
4738 | 182 |
183 unsigned long ico_len; | |
184 unsigned long ico_csum; | |
185 time_t ico_time; | |
186 gboolean ico_need; | |
7406 | 187 gboolean ico_sent; |
2086 | 188 }; |
189 | |
4230 | 190 struct name_data { |
5575 | 191 GaimConnection *gc; |
4230 | 192 gchar *name; |
3453 | 193 gchar *nick; |
3141 | 194 }; |
195 | |
5129 | 196 static char *msgerrreason[] = { |
197 N_("Invalid error"), | |
198 N_("Invalid SNAC"), | |
199 N_("Rate to host"), | |
200 N_("Rate to client"), | |
201 N_("Not logged in"), | |
202 N_("Service unavailable"), | |
203 N_("Service not defined"), | |
204 N_("Obsolete SNAC"), | |
205 N_("Not supported by host"), | |
206 N_("Not supported by client"), | |
207 N_("Refused by client"), | |
208 N_("Reply too big"), | |
209 N_("Responses lost"), | |
210 N_("Request denied"), | |
211 N_("Busted SNAC payload"), | |
212 N_("Insufficient rights"), | |
213 N_("In local permit/deny"), | |
214 N_("Too evil (sender)"), | |
215 N_("Too evil (receiver)"), | |
216 N_("User temporarily unavailable"), | |
217 N_("No match"), | |
218 N_("List overflow"), | |
219 N_("Request ambiguous"), | |
220 N_("Queue full"), | |
221 N_("Not while on AOL") | |
222 }; | |
223 static int msgerrreasonlen = 25; | |
224 | |
225 /* All the libfaim->gaim callback functions */ | |
226 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 236 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 237 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 238 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
239 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
|
240 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
|
241 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
|
242 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
|
243 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 244 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
245 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 247 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 248 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
249 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
255 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
256 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
259 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
260 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
275 #ifndef NOSSI | |
276 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 280 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 281 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
282 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
283 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
284 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
285 #endif | |
286 | |
287 /* for DirectIM/image transfer */ | |
288 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
289 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
290 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 291 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 292 |
293 /* for file transfer */ | |
294 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
295 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
296 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
297 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
298 | |
299 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 300 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 301 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 302 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 303 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
304 | |
5836 | 305 static void oscar_free_name_data(struct name_data *data) { |
4230 | 306 g_free(data->name); |
307 g_free(data->nick); | |
308 g_free(data); | |
309 } | |
310 | |
5836 | 311 static void oscar_free_buddyinfo(void *data) { |
312 struct buddyinfo *bi = data; | |
6292 | 313 g_free(bi->availmsg); |
5836 | 314 g_free(bi); |
315 } | |
316 | |
9807 | 317 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 318 { |
319 int i = 0; | |
9826 | 320 int charset = AIM_CHARSET_ASCII; |
5129 | 321 |
322 /* Determine how we can send this message. Per the warnings elsewhere | |
323 * in this file, these little checks determine the simplest encoding | |
324 * we can use for a given message send using it. */ | |
325 while (utf8[i]) { | |
326 if ((unsigned char)utf8[i] > 0x7f) { | |
327 /* not ASCII! */ | |
9826 | 328 charset = AIM_CHARSET_CUSTOM; |
5129 | 329 break; |
330 } | |
331 i++; | |
332 } | |
333 while (utf8[i]) { | |
334 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
335 * followed by 0xc0-0xc3 in the second */ | |
336 if ((unsigned char)utf8[i] < 0x80) { | |
337 i++; | |
338 continue; | |
339 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
340 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
341 i += 2; | |
342 continue; | |
343 } | |
9826 | 344 charset = AIM_CHARSET_UNICODE; |
5129 | 345 break; |
346 } | |
347 | |
9807 | 348 return charset; |
5129 | 349 } |
350 | |
8225 | 351 /* |
352 * Take a string of the form charset="bleh" where bleh is | |
353 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
354 * return a newly allocated string containing bleh. | |
355 */ | |
356 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 357 { |
8225 | 358 gchar *ret = NULL; |
359 char *begin, *end; | |
360 | |
9933 | 361 g_return_val_if_fail(encoding != NULL, NULL); |
362 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
363 /* Make sure encoding begins with charset= */ |
8225 | 364 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
365 return NULL; | |
366 | |
367 begin = strchr(encoding, '"'); | |
368 end = strrchr(encoding, '"'); | |
369 | |
370 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
371 return NULL; | |
372 | |
373 ret = g_strndup(begin+1, (end-1) - begin); | |
374 | |
375 return ret; | |
376 } | |
377 | |
9830 | 378 static gchar * |
379 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 380 { |
381 gchar *utf8 = NULL; | |
9595 | 382 |
383 if ((encoding == NULL) || encoding[0] == '\0') { | |
384 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
385 | |
9639 | 386 } else if (!strcmp(encoding, "iso-8859-1") |
387 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 388 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
389 | |
390 } else if (!strcmp(encoding, "unicode-2-0")) { | |
391 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
392 | |
393 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
394 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
395 "attempting to convert to UTF-8 anyway\n"); | |
396 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
397 } | |
398 | |
399 /* | |
400 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
401 * we have been unable to convert the text to utf-8 from the encoding | |
402 * that was specified. So we check if the text is valid utf-8 then | |
403 * just copy it. | |
404 */ | |
405 if (utf8 == NULL) { | |
9638 | 406 if (textlen != 0 && *text != '\0' |
407 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 408 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 409 else |
9481 | 410 utf8 = g_strndup(text, textlen); |
5129 | 411 } |
412 | |
413 return utf8; | |
414 } | |
415 | |
9830 | 416 static gchar * |
9908 | 417 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 418 { |
419 gchar *ret = NULL; | |
420 GError *err = NULL; | |
421 | |
9908 | 422 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
423 return NULL; | |
424 | |
425 if (strcasecmp("UTF-8", charsetstr)) { | |
426 if (fallback) | |
427 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
428 else | |
429 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
430 if (err != NULL) { | |
431 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
432 charsetstr, err->message); | |
433 g_error_free(err); | |
434 } | |
435 } else { | |
436 if (g_utf8_validate(data, datalen, NULL)) | |
437 ret = g_strndup(data, datalen); | |
438 else | |
439 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
440 } | |
441 | |
442 return ret; | |
443 } | |
444 | |
445 /* | |
446 * We try decoding using two different character sets. The charset | |
447 * specified in the IM determines the order in which we attempt to | |
448 * decode. We do this because there are lots of broken ICQ clients | |
449 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
450 * able to deal with that crap, then people complain like banshees. | |
451 * charsetstr1 is always set to what the correct encoding should be. | |
452 */ | |
453 static gchar * | |
454 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
455 { | |
456 gchar *ret = NULL; | |
457 const gchar *charsetstr1, *charsetstr2; | |
458 | |
459 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 460 |
461 if ((datalen == 0) || (data == NULL)) | |
462 return NULL; | |
463 | |
9908 | 464 if (charset == AIM_CHARSET_UNICODE) { |
465 charsetstr1 = "UCS-2BE"; | |
466 charsetstr2 = "UTF-8"; | |
467 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 468 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 469 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 470 else |
9908 | 471 charsetstr1 = "ISO-8859-1"; |
472 charsetstr2 = "UTF-8"; | |
473 } else if (charset == AIM_CHARSET_ASCII) { | |
474 /* Should just be "ASCII" */ | |
9914 | 475 charsetstr1 = "ASCII"; |
9908 | 476 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
477 } else if (charset == 0x000d) { | |
9830 | 478 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 479 charsetstr1 = "ISO-8859-1"; |
480 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
481 } else { | |
9830 | 482 /* Unknown, hope for valid UTF-8... */ |
9908 | 483 charsetstr1 = "UTF-8"; |
484 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
485 } | |
486 | |
487 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
488 if (ret == NULL) | |
489 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
490 if (ret == NULL) | |
491 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 492 |
493 return ret; | |
494 } | |
495 | |
496 static void | |
497 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
498 gchar **msg, int *msglen, | |
499 fu16_t *charset, fu16_t *charsubset) | |
500 { | |
501 OscarData *od = gc->proto_data; | |
502 GaimAccount *account = gaim_connection_get_account(gc); | |
503 GError *err = NULL; | |
504 aim_userinfo_t *userinfo = NULL; | |
505 const gchar *charsetstr; | |
506 | |
507 /* Attempt to send as ASCII */ | |
508 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, msglen, NULL); | |
509 if (*msg != NULL) { | |
510 *charset = AIM_CHARSET_ASCII; | |
511 *charsubset = 0x0000; | |
512 return; | |
513 } | |
514 | |
515 /* | |
9908 | 516 * If we're sending to an ICQ user, and they are advertising the |
517 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 518 */ |
9975 | 519 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 520 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
521 | |
522 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
9908 | 523 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, NULL); |
9830 | 524 if (*msg != NULL) { |
525 *charset = AIM_CHARSET_UNICODE; | |
526 *charsubset = 0x0000; | |
527 return; | |
528 } | |
529 } | |
530 | |
531 /* | |
532 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
533 * ICQ then attempt to send as the user specified character encoding. | |
534 */ | |
535 charsetstr = "ISO-8859-1"; | |
9975 | 536 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 537 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
538 | |
539 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, msglen, NULL); | |
540 if (*msg != NULL) { | |
541 *charset = AIM_CHARSET_CUSTOM; | |
542 *charsubset = 0x0000; | |
543 return; | |
544 } | |
545 | |
546 /* | |
547 * Nothing else worked, so send as UCS-2BE. | |
548 */ | |
549 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, msglen, &err); | |
550 if (*msg != NULL) { | |
551 *charset = AIM_CHARSET_UNICODE; | |
552 *charsubset = 0x0000; | |
553 return; | |
554 } | |
555 | |
9908 | 556 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 557 g_error_free(err); |
558 | |
559 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
560 *msg = g_strdup(from); | |
561 *msglen = strlen(*msg); | |
562 *charset = AIM_CHARSET_ASCII; | |
563 *charsubset = 0x0000; | |
564 return; | |
565 } | |
566 | |
9407 | 567 gchar *oscar_caps_to_string(guint caps) |
8701 | 568 { |
9407 | 569 GString *str; |
570 gchar *tmp; | |
8701 | 571 guint bit = 1; |
572 | |
9407 | 573 str = g_string_new(""); |
574 | |
8701 | 575 if (!caps) { |
576 return NULL; | |
577 } else while (bit <= AIM_CAPS_LAST) { | |
578 if (bit & caps) { | |
579 switch (bit) { | |
580 case AIM_CAPS_BUDDYICON: | |
581 tmp = _("Buddy Icon"); | |
582 break; | |
583 case AIM_CAPS_TALK: | |
584 tmp = _("Voice"); | |
585 break; | |
586 case AIM_CAPS_DIRECTIM: | |
587 tmp = _("AIM Direct IM"); | |
588 break; | |
589 case AIM_CAPS_CHAT: | |
590 tmp = _("Chat"); | |
591 break; | |
592 case AIM_CAPS_GETFILE: | |
593 tmp = _("Get File"); | |
594 break; | |
595 case AIM_CAPS_SENDFILE: | |
596 tmp = _("Send File"); | |
597 break; | |
598 case AIM_CAPS_GAMES: | |
599 case AIM_CAPS_GAMES2: | |
600 tmp = _("Games"); | |
601 break; | |
602 case AIM_CAPS_ADDINS: | |
603 tmp = _("Add-Ins"); | |
604 break; | |
605 case AIM_CAPS_SENDBUDDYLIST: | |
606 tmp = _("Send Buddy List"); | |
607 break; | |
608 case AIM_CAPS_ICQ_DIRECT: | |
609 tmp = _("ICQ Direct Connect"); | |
610 break; | |
611 case AIM_CAPS_APINFO: | |
612 tmp = _("AP User"); | |
613 break; | |
614 case AIM_CAPS_ICQRTF: | |
615 tmp = _("ICQ RTF"); | |
616 break; | |
617 case AIM_CAPS_EMPTY: | |
618 tmp = _("Nihilist"); | |
619 break; | |
620 case AIM_CAPS_ICQSERVERRELAY: | |
621 tmp = _("ICQ Server Relay"); | |
622 break; | |
623 case AIM_CAPS_ICQUTF8OLD: | |
624 tmp = _("Old ICQ UTF8"); | |
625 break; | |
626 case AIM_CAPS_TRILLIANCRYPT: | |
627 tmp = _("Trillian Encryption"); | |
628 break; | |
629 case AIM_CAPS_ICQUTF8: | |
630 tmp = _("ICQ UTF8"); | |
631 break; | |
632 case AIM_CAPS_HIPTOP: | |
633 tmp = _("Hiptop"); | |
634 break; | |
635 case AIM_CAPS_SECUREIM: | |
636 tmp = _("Security Enabled"); | |
637 break; | |
638 case AIM_CAPS_VIDEO: | |
639 tmp = _("Video Chat"); | |
640 break; | |
641 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
642 case AIM_CAPS_ICHATAV: | |
643 tmp = _("iChat AV"); | |
644 break; | |
645 case AIM_CAPS_LIVEVIDEO: | |
646 tmp = _("Live Video"); | |
647 break; | |
648 case AIM_CAPS_CAMERA: | |
649 tmp = _("Camera"); | |
650 break; | |
651 default: | |
652 tmp = NULL; | |
653 break; | |
654 } | |
655 if (tmp) | |
9532 | 656 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 657 } |
658 bit <<= 1; | |
659 } | |
9407 | 660 |
661 return g_string_free(str, FALSE); | |
8701 | 662 } |
663 | |
664 static char *oscar_icqstatus(int state) { | |
665 /* Make a cute little string that shows the status of the dude or dudet */ | |
666 if (state & AIM_ICQ_STATE_CHAT) | |
667 return g_strdup_printf(_("Free For Chat")); | |
668 else if (state & AIM_ICQ_STATE_DND) | |
669 return g_strdup_printf(_("Do Not Disturb")); | |
670 else if (state & AIM_ICQ_STATE_OUT) | |
671 return g_strdup_printf(_("Not Available")); | |
672 else if (state & AIM_ICQ_STATE_BUSY) | |
673 return g_strdup_printf(_("Occupied")); | |
674 else if (state & AIM_ICQ_STATE_AWAY) | |
675 return g_strdup_printf(_("Away")); | |
676 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
677 return g_strdup_printf(_("Web Aware")); | |
678 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
679 return g_strdup_printf(_("Invisible")); | |
680 else | |
681 return g_strdup_printf(_("Online")); | |
682 } | |
683 | |
9973 | 684 static void |
685 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 686 { |
687 gchar *utf8; | |
688 | |
689 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 690 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 691 g_free(utf8); |
692 } | |
693 } | |
694 | |
9973 | 695 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 696 { |
697 OscarData *od = gc->proto_data; | |
698 GaimAccount *account = gaim_connection_get_account(gc); | |
699 GaimGroup *g = NULL; | |
700 struct buddyinfo *bi = NULL; | |
701 char *tmp; | |
702 | |
703 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
704 return; | |
705 | |
706 if (userinfo == NULL) | |
707 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
708 | |
709 if (b == NULL) | |
710 b = gaim_find_buddy(gc->account, userinfo->sn); | |
711 | |
712 if (b != NULL) | |
713 g = gaim_find_buddys_group(b); | |
714 | |
715 if (userinfo != NULL) | |
716 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
717 | |
8733 | 718 if (b != NULL) { |
719 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
9975 | 720 if (aim_sn_is_icq(b->name)) { |
8733 | 721 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
722 oscar_string_append(str, newline, _("Status"), tmp); | |
723 g_free(tmp); | |
724 } | |
725 } else { | |
9625 | 726 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 727 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
728 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
729 else | |
730 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 731 } |
8733 | 732 } |
8701 | 733 |
734 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 735 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 736 (bi->ipaddr & 0xff000000) >> 24, |
737 (bi->ipaddr & 0x00ff0000) >> 16, | |
738 (bi->ipaddr & 0x0000ff00) >> 8, | |
739 (bi->ipaddr & 0x000000ff)); | |
740 oscar_string_append(str, newline, _("IP Address"), tmp); | |
741 g_free(tmp); | |
742 } | |
743 | |
744 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
745 tmp = oscar_caps_to_string(userinfo->capabilities); | |
746 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 747 g_free(tmp); |
8701 | 748 } |
749 | |
750 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
751 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
752 if (tmp != NULL) { | |
9625 | 753 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 754 g_free(tmp); |
9625 | 755 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
756 g_free(tmp2); | |
8701 | 757 } |
758 } | |
759 | |
760 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
761 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
762 oscar_string_append(str, newline, _("Available"), tmp); | |
763 g_free(tmp); | |
764 } | |
765 } | |
766 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
767 static char *extract_name(const char *name) { |
4121 | 768 char *tmp, *x; |
2086 | 769 int i, j; |
4120 | 770 |
771 if (!name) | |
4121 | 772 return NULL; |
773 | |
4120 | 774 x = strchr(name, '-'); |
4121 | 775 |
2086 | 776 if (!x) return NULL; |
777 x = strchr(++x, '-'); | |
778 if (!x) return NULL; | |
779 tmp = g_strdup(++x); | |
780 | |
781 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
782 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
783 if (x[i] != '%') { |
2086 | 784 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
785 continue; |
2086 | 786 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
787 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
788 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
789 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 790 } |
791 | |
792 tmp[j] = 0; | |
793 return tmp; | |
794 } | |
795 | |
5575 | 796 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 797 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 798 struct chat_connection *c = NULL; |
799 | |
800 while (g) { | |
801 c = (struct chat_connection *)g->data; | |
802 if (c->id == id) | |
803 break; | |
804 g = g->next; | |
805 c = NULL; | |
806 } | |
807 | |
808 return c; | |
809 } | |
810 | |
5575 | 811 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
|
812 aim_conn_t *conn) { |
7283 | 813 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 814 struct chat_connection *c = NULL; |
815 | |
816 while (g) { | |
817 c = (struct chat_connection *)g->data; | |
818 if (c->conn == conn) | |
819 break; | |
820 g = g->next; | |
821 c = NULL; | |
822 } | |
823 | |
824 return c; | |
825 } | |
826 | |
8219 | 827 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
828 GaimConversation *conv) { | |
829 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
830 struct chat_connection *c = NULL; | |
831 | |
832 while (g) { | |
833 c = (struct chat_connection *)g->data; | |
8733 | 834 if (c->conv == conv) |
8219 | 835 break; |
836 g = g->next; | |
837 c = NULL; | |
838 } | |
839 | |
840 return c; | |
841 } | |
842 | |
8971 | 843 /***************************************************************************** |
844 * Begin scary direct im stuff | |
845 *****************************************************************************/ | |
846 | |
847 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
848 GSList *d = od->direct_ims; | |
849 struct oscar_direct_im *m = NULL; | |
850 | |
851 while (d) { | |
852 m = (struct oscar_direct_im *)d->data; | |
853 if (!aim_sncmp(who, m->name)) | |
854 return m; | |
855 d = d->next; | |
856 } | |
857 | |
858 return NULL; | |
859 } | |
860 | |
861 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
862 { | |
863 gaim_debug_info("oscar", | |
864 "destroying Direct IM for %s.\n", dim->name); | |
865 | |
866 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 867 if (dim->gpc_pend) { |
868 dim->killme = TRUE; | |
869 return; | |
870 } | |
8971 | 871 if (dim->watcher) |
872 gaim_input_remove(dim->watcher); | |
873 if (dim->conn) { | |
874 aim_conn_close(dim->conn); | |
875 aim_conn_kill(od->sess, &dim->conn); | |
876 } | |
877 g_free(dim); | |
878 } | |
879 | |
880 /* the only difference between this and destroy is this writes a conv message */ | |
881 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
882 { | |
883 GaimConversation *conv; | |
884 char buf[256]; | |
885 | |
886 gaim_debug_info("oscar", | |
887 "%s disconnected Direct IM.\n", dim->name); | |
888 | |
889 if (dim->connected) | |
890 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 891 else |
8971 | 892 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
893 | |
894 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
895 if (conv) { | |
896 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 897 gaim_conversation_update_progress(conv, 0); |
8971 | 898 } else { |
899 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
900 } | |
901 | |
902 oscar_direct_im_destroy(od, dim); | |
903 | |
904 return; | |
905 } | |
906 | |
907 /* oops i made two of these. this one just calls the other one. */ | |
908 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
909 { | |
910 GaimConnection *gc = sess->aux_data; | |
911 OscarData *od = (OscarData *)gc->proto_data; | |
912 struct oscar_direct_im *dim; | |
913 char *sn; | |
914 | |
915 sn = g_strdup(aim_odc_getsn(conn)); | |
916 dim = oscar_direct_im_find(od, sn); | |
917 oscar_direct_im_disconnect(od, dim); | |
918 g_free(sn); | |
919 } | |
920 | |
921 static void destroy_direct_im_request(struct ask_direct *d) { | |
922 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
923 | |
924 g_free(d->sn); | |
925 g_free(d); | |
926 } | |
927 | |
928 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
929 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
930 struct oscar_direct_im *dim = data; | |
931 GaimConnection *gc = dim->gc; | |
932 OscarData *od = gc->proto_data; | |
933 GaimConversation *conv; | |
934 char buf[256]; | |
935 struct sockaddr name; | |
936 socklen_t name_len = 1; | |
937 | |
938 g_return_if_fail(gc != NULL); | |
939 | |
8978 | 940 dim->gpc_pend = FALSE; |
941 if (dim->killme) { | |
942 oscar_direct_im_destroy(od, dim); | |
943 return; | |
944 } | |
945 | |
8971 | 946 if (!g_list_find(gaim_connections_get_all(), gc)) { |
947 oscar_direct_im_destroy(od, dim); | |
948 return; | |
949 } | |
950 | |
951 if (source < 0) { | |
8984 | 952 if (dim->donttryagain) { |
953 oscar_direct_im_disconnect(od, dim); | |
954 return; | |
955 } else { | |
956 fu8_t cookie[8]; | |
957 char *who = g_strdup(dim->name); | |
958 const char *tmp = aim_odc_getcookie(dim->conn); | |
959 | |
960 memcpy(cookie, tmp, 8); | |
961 oscar_direct_im_destroy(od, dim); | |
962 oscar_direct_im_initiate(gc, who, cookie); | |
963 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
964 g_free(who); | |
965 return; | |
966 } | |
8971 | 967 } |
968 | |
969 dim->conn->fd = source; | |
970 aim_conn_completeconnect(od->sess, dim->conn); | |
971 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
972 | |
973 /* This is the best way to see if we're connected or not */ | |
8983 | 974 /* Is this really needed? */ |
8971 | 975 if (getpeername(source, &name, &name_len) == 0) { |
976 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
977 dim->connected = TRUE; | |
978 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 979 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
980 } else { | |
8984 | 981 if (dim->donttryagain) { |
982 oscar_direct_im_disconnect(od, dim); | |
983 return; | |
984 } else { | |
985 fu8_t cookie[8]; | |
986 char *who = g_strdup(dim->name); | |
987 const char *tmp = aim_odc_getcookie(dim->conn); | |
988 | |
989 memcpy(cookie, tmp, 8); | |
990 oscar_direct_im_destroy(od, dim); | |
991 oscar_direct_im_initiate(gc, who, cookie); | |
992 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
993 g_free(who); | |
994 return; | |
995 } | |
8983 | 996 } |
997 | |
998 | |
8971 | 999 } |
1000 | |
1001 static void accept_direct_im_request(struct ask_direct *d) { | |
1002 GaimConnection *gc = d->gc; | |
1003 OscarData *od; | |
1004 struct oscar_direct_im *dim; | |
1005 char *host; int port = 5190; | |
1006 int i, rc; | |
8982 | 1007 char *tmp; |
1008 GaimConversation *conv; | |
8971 | 1009 |
1010 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1011 destroy_direct_im_request(d); | |
1012 return; | |
1013 } | |
1014 | |
1015 od = (OscarData *)gc->proto_data; | |
1016 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1017 | |
1018 dim = oscar_direct_im_find(od, d->sn); | |
1019 if (dim && dim->connected) { | |
1020 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1021 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1022 return; | |
1023 } | |
1024 dim = g_new0(struct oscar_direct_im, 1); | |
1025 dim->gc = d->gc; | |
8984 | 1026 dim->donttryagain = d->donttryagain; |
8971 | 1027 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1028 | |
1029 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1030 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1031 if (!dim->conn) { | |
1032 oscar_direct_im_disconnect(od, dim); | |
1033 destroy_direct_im_request(d); | |
1034 return; | |
1035 } | |
1036 | |
1037 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1038 gaim_odc_incoming, 0); | |
1039 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1040 gaim_odc_typing, 0); | |
1041 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1042 gaim_odc_update_ui, 0); | |
1043 | |
1044 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1045 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1046 if (d->ip[i] == ':') { | |
1047 port = atoi(&(d->ip[i+1])); | |
1048 break; | |
1049 } | |
1050 } | |
1051 host = g_strndup(d->ip, i); | |
1052 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1053 dim->gpc_pend = TRUE; |
8971 | 1054 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1055 |
1056 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1057 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1058 port); | |
1059 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1060 g_free(tmp); | |
8983 | 1061 |
8971 | 1062 g_free(host); |
1063 if (rc < 0) { | |
8978 | 1064 dim->gpc_pend = FALSE; |
8971 | 1065 oscar_direct_im_disconnect(od, dim); |
1066 destroy_direct_im_request(d); | |
1067 return; | |
1068 } | |
1069 | |
1070 destroy_direct_im_request(d); | |
1071 | |
1072 return; | |
1073 } | |
1074 | |
1075 /* | |
1076 * We have just established a socket with the other dude, so set up some handlers. | |
1077 */ | |
1078 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1079 GaimConnection *gc = sess->aux_data; |
7283 | 1080 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1081 GaimConversation *conv; |
8971 | 1082 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1083 char buf[256]; |
8971 | 1084 char *sn; |
1085 va_list ap; | |
1086 aim_conn_t *newconn, *listenerconn; | |
1087 | |
1088 va_start(ap, fr); | |
1089 newconn = va_arg(ap, aim_conn_t *); | |
1090 listenerconn = va_arg(ap, aim_conn_t *); | |
1091 va_end(ap); | |
1092 | |
1093 aim_conn_close(listenerconn); | |
1094 aim_conn_kill(sess, &listenerconn); | |
1095 | |
1096 sn = g_strdup(aim_odc_getsn(newconn)); | |
1097 | |
1098 gaim_debug_info("oscar", | |
1099 "DirectIM: initiate success to %s\n", sn); | |
1100 dim = oscar_direct_im_find(od, sn); | |
1101 | |
1102 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1103 gaim_input_remove(dim->watcher); | |
1104 dim->conn = newconn; | |
1105 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1106 dim->connected = TRUE; | |
1107 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1108 g_free(sn); | |
1109 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1110 | |
1111 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1112 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1113 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1114 | |
1115 return 1; | |
1116 } | |
1117 | |
1118 /* | |
1119 * This is called when each chunk of an image is received. It can be used to | |
1120 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1121 * nasty, you sicko. | |
1122 */ | |
1123 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1124 va_list ap; | |
1125 char *sn; | |
1126 double percent; | |
1127 GaimConnection *gc = sess->aux_data; | |
1128 OscarData *od = (OscarData *)gc->proto_data; | |
1129 GaimConversation *c; | |
1130 struct oscar_direct_im *dim; | |
1131 | |
1132 va_start(ap, fr); | |
1133 sn = va_arg(ap, char *); | |
1134 percent = va_arg(ap, double); | |
1135 va_end(ap); | |
1136 | |
1137 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1138 return 1; | |
1139 if (dim->watcher) { | |
1140 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1141 /* The callback will callback? I don't get how that would happen here. */ | |
1142 dim->watcher = 0; | |
1143 } | |
1144 | |
1145 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
1146 if (c != NULL) | |
1147 gaim_conversation_update_progress(c, percent); | |
1148 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1149 oscar_callback, dim->conn); | |
1150 | |
1151 return 1; | |
1152 } | |
1153 | |
1154 /* | |
1155 * This is called after a direct IM has been received in its entirety. This | |
1156 * function is passed a long chunk of data which contains the IM with any | |
1157 * data chunks (images) appended to it. | |
1158 * | |
1159 * This function rips out all the data chunks and creates an imgstore for | |
1160 * each one. In order to do this, it first goes through the IM and takes | |
1161 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1162 * with one compatible with the imgstore Gaim core code. For each one, we | |
1163 * then read in chunks of data from the end of the message and actually | |
1164 * create the img store using the given data. | |
1165 * | |
1166 * For somewhat easy reference, here's a sample message | |
1167 * (without the whitespace and asterisks): | |
1168 * | |
1169 * <HTML><BODY BGCOLOR="#ffffff"> | |
1170 * <FONT LANG="0"> | |
1171 * This is a really stupid picture:<BR> | |
1172 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1173 * Yeah it is<BR> | |
1174 * Here is another one:<BR> | |
1175 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1176 * </FONT> | |
1177 * </BODY></HTML> | |
1178 * <BINARY> | |
1179 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1180 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1181 * </BINARY> | |
1182 */ | |
1183 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1184 GaimConnection *gc = sess->aux_data; | |
1185 GaimConvImFlags imflags = 0; | |
1186 gchar *utf8; | |
1187 GString *newmsg = g_string_new(""); | |
1188 GSList *images = NULL; | |
1189 va_list ap; | |
1190 const char *sn, *msg, *msgend, *binary; | |
1191 size_t len; | |
1192 int encoding, isawaymsg; | |
1193 | |
1194 va_start(ap, fr); | |
1195 sn = va_arg(ap, const char *); | |
1196 msg = va_arg(ap, const char *); | |
1197 len = va_arg(ap, size_t); | |
1198 encoding = va_arg(ap, int); | |
1199 isawaymsg = va_arg(ap, int); | |
1200 va_end(ap); | |
1201 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1202 |
8660 | 1203 gaim_debug_info("oscar", |
8971 | 1204 "Got DirectIM message from %s\n", sn); |
1205 | |
1206 if (isawaymsg) | |
1207 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1208 | |
1209 /* message has a binary trailer */ | |
1210 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1211 GData *attribs; | |
1212 const char *tmp, *start, *end, *last = NULL; | |
1213 | |
1214 tmp = msg; | |
1215 | |
1216 /* for each valid image tag... */ | |
1217 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1218 const char *id, *src, *datasize; | |
1219 const char *tag = NULL, *data = NULL; | |
1220 size_t size; | |
1221 int imgid = 0; | |
1222 | |
1223 /* update the location of the last img tag */ | |
1224 last = end; | |
1225 | |
1226 /* grab attributes */ | |
1227 id = g_datalist_get_data(&attribs, "id"); | |
1228 src = g_datalist_get_data(&attribs, "src"); | |
1229 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1230 | |
1231 /* if we have id & datasize, build the data tag */ | |
1232 if (id && datasize) | |
1233 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1234 | |
1235 /* if we have a tag, find the start of the data */ | |
1236 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1237 data += strlen(tag); | |
1238 | |
1239 /* check the data is here and store it */ | |
1240 if (data + (size = atoi(datasize)) <= msgend) | |
1241 imgid = gaim_imgstore_add(data, size, src); | |
1242 | |
1243 /* | |
1244 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1245 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1246 */ | |
1247 /* if we have a stored image... */ | |
1248 if (imgid) { | |
1249 /* append the message up to the tag */ | |
1250 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1251 if (utf8 != NULL) { | |
1252 newmsg = g_string_append(newmsg, utf8); | |
1253 g_free(utf8); | |
1254 } | |
1255 | |
1256 /* write the new image tag */ | |
1257 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1258 | |
1259 /* and record the image number */ | |
1260 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1261 } else { | |
1262 /* otherwise, copy up to the end of the tag */ | |
1263 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1264 if (utf8 != NULL) { | |
1265 newmsg = g_string_append(newmsg, utf8); | |
1266 g_free(utf8); | |
1267 } | |
1268 } | |
1269 | |
1270 /* clear the attribute list */ | |
1271 g_datalist_clear(&attribs); | |
1272 | |
1273 /* continue from the end of the tag */ | |
1274 tmp = end + 1; | |
1275 } | |
1276 | |
1277 /* append any remaining message data (without the > :-) */ | |
1278 if (last++ && (last < binary)) | |
1279 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1280 | |
1281 /* set the flag if we caught any images */ | |
1282 if (images) | |
1283 imflags |= GAIM_CONV_IM_IMAGES; | |
1284 } else { | |
1285 g_string_append_len(newmsg, msg, len); | |
1286 } | |
1287 | |
1288 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1289 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1290 | |
1291 /* free up the message */ | |
1292 g_string_free(newmsg, TRUE); | |
1293 | |
1294 /* unref any images we allocated */ | |
1295 if (images) { | |
1296 GSList *tmp; | |
1297 int id; | |
1298 | |
1299 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1300 id = GPOINTER_TO_INT(tmp->data); | |
1301 gaim_imgstore_unref(id); | |
1302 } | |
1303 | |
1304 g_slist_free(images); | |
1305 } | |
1306 | |
1307 return 1; | |
1308 } | |
1309 | |
1310 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1311 va_list ap; | |
1312 char *sn; | |
1313 int typing; | |
1314 GaimConnection *gc = sess->aux_data; | |
1315 | |
1316 va_start(ap, fr); | |
1317 sn = va_arg(ap, char *); | |
1318 typing = va_arg(ap, int); | |
1319 va_end(ap); | |
1320 | |
1321 if (typing == 0x0002) { | |
1322 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1323 gaim_debug_info("oscar", | |
1324 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1325 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1326 } else if (typing == 0x0001) | |
1327 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1328 else | |
1329 serv_got_typing_stopped(gc, sn); | |
1330 return 1; | |
1331 } | |
1332 | |
1333 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1334 char *buf; | |
1335 size_t len; | |
1336 int ret; | |
1337 GString *msg = g_string_new("<HTML><BODY>"); | |
1338 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1339 GData *attribs; | |
1340 const char *start, *end, *last; | |
1341 int oscar_id = 0; | |
1342 | |
1343 last = message; | |
1344 | |
1345 /* for each valid IMG tag... */ | |
1346 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1347 GaimStoredImage *image = NULL; | |
1348 const char *id; | |
1349 | |
1350 if (start - last) { | |
1351 g_string_append_len(msg, last, start - last); | |
1352 } | |
1353 | |
1354 id = g_datalist_get_data(&attribs, "id"); | |
1355 | |
1356 /* ... if it refers to a valid gaim image ... */ | |
1357 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1358 /* ... append the message from start to the tag ... */ | |
9126 | 1359 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1360 const char *filename = gaim_imgstore_get_filename(image); |
1361 gpointer imgdata = gaim_imgstore_get_data(image); | |
1362 | |
1363 oscar_id++; | |
1364 | |
1365 /* ... insert a new img tag with the oscar id ... */ | |
1366 if (filename) | |
1367 g_string_append_printf(msg, | |
9126 | 1368 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1369 filename, oscar_id, size); |
1370 else | |
1371 g_string_append_printf(msg, | |
9126 | 1372 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1373 oscar_id, size); |
1374 | |
1375 /* ... and append the data to the binary section ... */ | |
9126 | 1376 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1377 oscar_id, size); |
1378 data = g_string_append_len(data, imgdata, size); | |
1379 data = g_string_append(data, "</DATA>"); | |
1380 } | |
1381 /* If the tag is invalid, skip it, thus no else here */ | |
1382 | |
1383 g_datalist_clear(&attribs); | |
1384 | |
1385 /* continue from the end of the tag */ | |
1386 last = end + 1; | |
1387 } | |
1388 | |
1389 /* append any remaining message data (without the > :-) */ | |
1390 if (last && *last) | |
1391 msg = g_string_append(msg, last); | |
1392 | |
1393 /* if we inserted any images in the binary section, append it */ | |
1394 if (oscar_id) { | |
1395 msg = g_string_append_len(msg, data->str, data->len); | |
1396 msg = g_string_append(msg, "</BINARY>"); | |
1397 } | |
1398 | |
1399 len = msg->len; | |
1400 buf = msg->str; | |
1401 g_string_free(msg, FALSE); | |
1402 g_string_free(data, TRUE); | |
1403 | |
1404 | |
1405 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1406 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1407 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1408 else | |
1409 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1410 | |
1411 g_free(buf); | |
1412 | |
1413 return ret; | |
1414 } | |
1415 | |
1416 struct ask_do_dir_im { | |
1417 char *who; | |
1418 GaimConnection *gc; | |
1419 }; | |
1420 | |
1421 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1422 g_free(data->who); | |
1423 g_free(data); | |
1424 } | |
1425 | |
8983 | 1426 /* this function is used to initiate a direct im session with someone. |
1427 * we start listening on a port and send a request. they either connect | |
1428 * or send some kind of reply. If they can't connect, they ask us to | |
1429 * connect to them, and so we do that. | |
1430 * | |
1431 * this function will also get called if the other side initiate's a direct | |
1432 * im and we try to connect and fail. in that case cookie will not be null. | |
1433 * | |
1434 * note that cookie is an 8 byte string that isn't NULL terminated | |
1435 */ | |
1436 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1437 OscarData *od; |
1438 struct oscar_direct_im *dim; | |
1439 int listenfd; | |
8982 | 1440 const char *ip; |
8971 | 1441 |
1442 od = (OscarData *)gc->proto_data; | |
1443 | |
8983 | 1444 dim = oscar_direct_im_find(od, who); |
8971 | 1445 if (dim) { |
1446 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1447 oscar_direct_im_disconnect(od, dim); | |
1448 gaim_debug_info("oscar", | |
1449 "Gave up on old direct IM, trying again\n"); | |
1450 } else { | |
1451 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1452 return; |
8971 | 1453 } |
1454 } | |
1455 dim = g_new0(struct oscar_direct_im, 1); | |
1456 dim->gc = gc; | |
8983 | 1457 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1458 |
1459 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1460 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1461 if (listenfd >= 0) |
1462 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1463 if (dim->conn != NULL) { |
8982 | 1464 char *tmp; |
1465 GaimConversation *conv; | |
1466 | |
8971 | 1467 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1468 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1469 oscar_callback, dim->conn); | |
1470 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1471 gaim_odc_initiate, 0); | |
8982 | 1472 |
8983 | 1473 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1474 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1475 gaim_network_get_port_from_fd(listenfd)); |
1476 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1477 g_free(tmp); | |
8971 | 1478 } else { |
1479 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1480 oscar_direct_im_destroy(od, dim); | |
1481 } | |
8983 | 1482 } |
1483 | |
1484 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1485 GaimConnection *gc = data->gc; | |
1486 | |
1487 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1488 g_free(data->who); | |
1489 g_free(data); | |
1490 return; | |
1491 } | |
1492 | |
1493 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1494 g_free(data->who); |
1495 g_free(data); | |
1496 } | |
1497 | |
1498 /* this is the right click menu cb thingy */ | |
9030 | 1499 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1500 | |
1501 GaimBuddy *buddy; | |
1502 GaimConnection *gc; | |
8971 | 1503 gchar *buf; |
9030 | 1504 struct ask_do_dir_im *data; |
1505 | |
1506 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1507 | |
1508 buddy = (GaimBuddy *) node; | |
1509 gc = gaim_account_get_connection(buddy->account); | |
1510 | |
1511 data = g_new0(struct ask_do_dir_im, 1); | |
1512 data->who = g_strdup(buddy->name); | |
8971 | 1513 data->gc = gc; |
9030 | 1514 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1515 buddy->name); | |
8971 | 1516 |
1517 gaim_request_action(gc, NULL, buf, | |
9030 | 1518 _("Because this reveals your IP address, it " |
1519 "may be considered a privacy risk. Do you " | |
1520 "wish to continue?"), | |
1521 0, data, 2, | |
1522 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1523 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1524 g_free(buf); |
1525 } | |
1526 | |
1527 /***************************************************************************** | |
1528 * End scary direct im stuff | |
1529 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1530 |
4617 | 1531 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1532 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1533 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1534 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1535 OscarData *od; |
2086 | 1536 |
1537 if (!gc) { | |
8660 | 1538 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1539 "oscar callback for closed connection (1).\n"); |
2086 | 1540 return; |
1541 } | |
1542 | |
7283 | 1543 od = (OscarData *)gc->proto_data; |
2086 | 1544 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1545 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1546 /* oh boy. this is probably bad. i guess the only thing we |
1547 * can really do is return? */ | |
8660 | 1548 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1549 "oscar callback for closed connection (2).\n"); |
8660 | 1550 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1551 return; |
1552 } | |
1553 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1554 if (condition & GAIM_INPUT_READ) { |
4617 | 1555 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1556 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1557 "got information on rendezvous listener\n"); |
4617 | 1558 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1559 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1560 "connection error (rendezvous listener)\n"); |
4617 | 1561 aim_conn_kill(od->sess, &conn); |
8446 | 1562 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1563 } |
1564 } else { | |
4617 | 1565 if (aim_get_command(od->sess, conn) >= 0) { |
1566 aim_rxdispatch(od->sess); | |
6029 | 1567 if (od->killme) { |
8660 | 1568 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1569 return; |
1570 } | |
2086 | 1571 } else { |
1572 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1573 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1574 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1575 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1576 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1577 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1578 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1579 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1580 char *buf; |
8660 | 1581 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1582 "disconnected from chat room %s\n", c->name); |
2086 | 1583 c->conn = NULL; |
1584 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1585 gaim_input_remove(c->inpa); |
2086 | 1586 c->inpa = 0; |
1587 c->fd = -1; | |
4617 | 1588 aim_conn_kill(od->sess, &conn); |
5420 | 1589 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1590 if (conv) |
1591 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1592 else | |
1593 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1594 g_free(buf); |
2086 | 1595 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1596 if (od->cnpa > 0) |
1597 gaim_input_remove(od->cnpa); | |
1598 od->cnpa = 0; | |
8660 | 1599 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1600 "removing chatnav input watcher\n"); |
4617 | 1601 while (od->create_rooms) { |
1602 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1603 g_free(cr->name); |
4617 | 1604 od->create_rooms = |
1605 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1606 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1607 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1608 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1609 NULL); |
2086 | 1610 } |
4617 | 1611 aim_conn_kill(od->sess, &conn); |
2086 | 1612 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1613 if (od->paspa > 0) |
1614 gaim_input_remove(od->paspa); | |
1615 od->paspa = 0; | |
8660 | 1616 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1617 "removing authconn input watcher\n"); |
4617 | 1618 aim_conn_kill(od->sess, &conn); |
3694 | 1619 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1620 if (od->emlpa > 0) |
1621 gaim_input_remove(od->emlpa); | |
1622 od->emlpa = 0; | |
8660 | 1623 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1624 "removing email input watcher\n"); |
4617 | 1625 aim_conn_kill(od->sess, &conn); |
4804 | 1626 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1627 if (od->icopa > 0) | |
1628 gaim_input_remove(od->icopa); | |
1629 od->icopa = 0; | |
8660 | 1630 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1631 "removing icon input watcher\n"); |
4804 | 1632 aim_conn_kill(od->sess, &conn); |
2086 | 1633 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1634 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1635 gaim_odc_disconnect(od->sess, conn); |
1636 aim_conn_kill(od->sess, &conn); | |
2086 | 1637 } else { |
8660 | 1638 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1639 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1640 conn->type); |
4617 | 1641 aim_conn_kill(od->sess, &conn); |
2086 | 1642 } |
1643 } | |
1644 } | |
1645 } | |
1646 } | |
1647 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1648 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1649 GaimConnection *gc = sess->aux_data; |
7285 | 1650 gchar *s = g_strdup_vprintf(format, va); |
1651 gchar *buf; | |
1652 | |
1653 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1654 gaim_debug_info("oscar", buf); |
7285 | 1655 if (buf[strlen(buf)-1] != '\n') |
8660 | 1656 gaim_debug_info(NULL, "\n"); |
7285 | 1657 g_free(buf); |
2086 | 1658 g_free(s); |
1659 } | |
1660 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1661 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1662 { |
5575 | 1663 GaimConnection *gc = data; |
7283 | 1664 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1665 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1666 aim_conn_t *conn; |
2086 | 1667 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1668 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1669 close(source); |
1670 return; | |
1671 } | |
1672 | |
4617 | 1673 od = gc->proto_data; |
1674 sess = od->sess; | |
2086 | 1675 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1676 conn->fd = source; |
2086 | 1677 |
1678 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1679 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1680 return; |
1681 } | |
1682 | |
1683 aim_conn_completeconnect(sess, conn); | |
4617 | 1684 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1685 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1686 | |
8660 | 1687 gaim_debug_info("oscar", |
7282 | 1688 "Screen name sent, waiting for response\n"); |
7283 | 1689 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1690 ck[1] = 0x65; |
2086 | 1691 } |
1692 | |
5575 | 1693 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1694 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1695 aim_conn_t *conn; |
5575 | 1696 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1697 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1698 |
8660 | 1699 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1700 |
8437 | 1701 if (!aim_snvalid(gaim_account_get_username(account))) { |
1702 gchar *buf; | |
8590 | 1703 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 | 1704 gaim_connection_error(gc, buf); |
1705 g_free(buf); | |
1706 } | |
1707 | |
9975 | 1708 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1709 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1710 } else { |
6622 | 1711 gc->flags |= GAIM_CONNECTION_HTML; |
1712 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1713 } |
5836 | 1714 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1715 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1716 sess = g_new0(aim_session_t, 1); |
7285 | 1717 aim_session_init(sess, TRUE, 0); |
2086 | 1718 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1719 /* |
1720 * We need an immediate queue because we don't use a while-loop | |
1721 * to see if things need to be sent. | |
1722 */ | |
2086 | 1723 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1724 od->sess = sess; |
2086 | 1725 sess->aux_data = gc; |
1726 | |
9935 | 1727 /* Connect to core Gaim signals */ |
9971 | 1728 od->recentbuddies_cbid = gaim_prefs_connect_callback("/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1729 |
2086 | 1730 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1731 if (conn == NULL) { | |
8660 | 1732 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1733 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1734 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1735 return; |
1736 } | |
1737 | |
4649 | 1738 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1739 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1740 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1741 | |
1742 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1743 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1744 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1745 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1746 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1747 return; |
1748 } | |
7282 | 1749 |
7283 | 1750 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1751 ck[0] = 0x5a; |
5575 | 1752 } |
1753 | |
1754 static void oscar_close(GaimConnection *gc) { | |
7283 | 1755 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1756 |
1757 while (od->oscar_chats) { | |
1758 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1759 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1760 gaim_input_remove(n->inpa); |
2086 | 1761 g_free(n->name); |
1762 g_free(n->show); | |
4617 | 1763 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1764 g_free(n); |
1765 } | |
4617 | 1766 while (od->direct_ims) { |
8971 | 1767 struct oscar_direct_im *n = od->direct_ims->data; |
1768 oscar_direct_im_destroy(od, n); | |
2086 | 1769 } |
4617 | 1770 /* BBB */ |
1771 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1772 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1773 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1774 gaim_xfer_cancel_local(xfer); |
3630 | 1775 } |
4804 | 1776 while (od->requesticon) { |
1777 char *sn = od->requesticon->data; | |
1778 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1779 free(sn); | |
1780 } | |
4738 | 1781 g_hash_table_destroy(od->buddyinfo); |
4617 | 1782 while (od->create_rooms) { |
1783 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1784 g_free(cr->name); |
4617 | 1785 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1786 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1787 } |
4617 | 1788 if (od->email) |
1789 g_free(od->email); | |
1790 if (od->newp) | |
1791 g_free(od->newp); | |
1792 if (od->oldp) | |
1793 g_free(od->oldp); | |
2086 | 1794 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1795 gaim_input_remove(gc->inpa); |
4617 | 1796 if (od->cnpa > 0) |
1797 gaim_input_remove(od->cnpa); | |
1798 if (od->paspa > 0) | |
1799 gaim_input_remove(od->paspa); | |
1800 if (od->emlpa > 0) | |
1801 gaim_input_remove(od->emlpa); | |
4804 | 1802 if (od->icopa > 0) |
1803 gaim_input_remove(od->icopa); | |
6907 | 1804 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1805 gaim_timeout_remove(od->icontimer); |
8341 | 1806 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1807 gaim_timeout_remove(od->getblisttimer); |
8341 | 1808 if (od->getinfotimer > 0) |
1809 gaim_timeout_remove(od->getinfotimer); | |
9975 | 1810 gaim_prefs_disconnect_callback(od->recentbuddies_cbid); |
9971 | 1811 |
4617 | 1812 aim_session_kill(od->sess); |
1813 g_free(od->sess); | |
1814 od->sess = NULL; | |
2086 | 1815 g_free(gc->proto_data); |
1816 gc->proto_data = NULL; | |
8660 | 1817 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1818 } |
1819 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1820 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1821 GaimConnection *gc = data; |
7283 | 1822 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1823 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1824 aim_conn_t *bosconn; |
2086 | 1825 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1826 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1827 close(source); |
1828 return; | |
1829 } | |
1830 | |
4617 | 1831 od = gc->proto_data; |
1832 sess = od->sess; | |
1833 bosconn = od->conn; | |
4366 | 1834 bosconn->fd = source; |
2086 | 1835 |
1836 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1837 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1838 return; |
1839 } | |
1840 | |
1841 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1842 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1843 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1844 gaim_connection_update_progress(gc, |
7283 | 1845 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1846 ck[4] = 0x61; |
2086 | 1847 } |
1848 | |
4617 | 1849 /* BBB */ |
4656 | 1850 /* |
1851 * This little area in oscar.c is the nexus of file transfer code, | |
1852 * so I wrote a little explanation of what happens. I am such a | |
1853 * ninja. | |
1854 * | |
1855 * The series of events for a file send is: | |
1856 * -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
|
1857 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1858 * listening socket, then asks the remote user to connect to us (and |
1859 * gives them the file name, port, IP, etc.) | |
1860 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1861 * in oscar_sendfile_estblsh) | |
1862 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1863 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1864 * connection. | |
1865 * -We get drunk because file transfer kicks ass. | |
1866 * | |
1867 * The series of events for a file receive is: | |
1868 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1869 * -Gaim user selects file to name and location to save file to and | |
1870 * oscar_xfer_init is called | |
1871 * -It connects to the remote user using the IP they gave us earlier | |
1872 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1873 * them an AIM_CB_OFT_ACK. | |
1874 * -They begin to send us lots of raw data. | |
1875 * -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
|
1876 * the connection. |
4656 | 1877 */ |
1878 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1879 | |
8446 | 1880 /* |
1881 * Miscellaneous xfer functions | |
1882 */ | |
1883 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1884 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1885 GaimXfer *xfer; |
5146 | 1886 struct aim_oft_info *oft_info; |
4656 | 1887 |
1888 while (fts) { | |
1889 xfer = fts->data; | |
5146 | 1890 oft_info = xfer->data; |
1891 | |
8446 | 1892 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1893 return xfer; |
1894 | |
1895 fts = g_slist_next(fts); | |
1896 } | |
1897 | |
1898 return NULL; | |
1899 } | |
1900 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1901 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1902 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1903 GaimXfer *xfer; |
5146 | 1904 struct aim_oft_info *oft_info; |
4656 | 1905 |
1906 while (fts) { | |
1907 xfer = fts->data; | |
5146 | 1908 oft_info = xfer->data; |
1909 | |
1910 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1911 return xfer; |
1912 | |
1913 fts = g_slist_next(fts); | |
1914 } | |
1915 | |
1916 return NULL; | |
1917 } | |
1918 | |
8446 | 1919 static void oscar_xfer_end(GaimXfer *xfer) |
1920 { | |
1921 struct aim_oft_info *oft_info = xfer->data; | |
1922 GaimConnection *gc = oft_info->sess->aux_data; | |
1923 OscarData *od = gc->proto_data; | |
1924 | |
8660 | 1925 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1926 |
1927 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1928 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1929 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1930 } | |
1931 | |
1932 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1933 aim_oft_destroyinfo(oft_info); | |
1934 xfer->data = NULL; | |
1935 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1936 } | |
1937 | |
1938 /* | |
1939 * xfer functions used when receiving files | |
1940 */ | |
1941 | |
1942 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1943 { | |
1944 struct aim_oft_info *oft_info = xfer->data; | |
1945 GaimConnection *gc = oft_info->sess->aux_data; | |
1946 OscarData *od = gc->proto_data; | |
1947 | |
8660 | 1948 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1949 |
1950 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1951 if (oft_info->conn) { | |
1952 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1953 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1954 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1955 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1956 if (xfer->fd == -1) { | |
1957 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1958 _("Unable to establish file descriptor.")); | |
1959 gaim_xfer_cancel_local(xfer); | |
1960 } | |
1961 } else { | |
1962 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1963 _("Unable to create new connection.")); | |
1964 gaim_xfer_cancel_local(xfer); | |
1965 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1966 } | |
1967 | |
1968 } | |
1969 | |
1970 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1971 { | |
1972 struct aim_oft_info *oft_info = xfer->data; | |
1973 GaimConnection *gc = oft_info->sess->aux_data; | |
1974 OscarData *od = gc->proto_data; | |
1975 | |
8660 | 1976 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1977 |
9771 | 1978 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1979 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1980 |
1981 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1982 aim_oft_destroyinfo(oft_info); | |
1983 xfer->data = NULL; | |
1984 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1985 } | |
1986 | |
1987 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1988 { | |
1989 struct aim_oft_info *oft_info = xfer->data; | |
1990 | |
1991 /* Update our rolling checksum. Like Walmart, yo. */ | |
1992 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
1993 } | |
1994 | |
1995 /* | |
1996 * xfer functions used when sending files | |
1997 */ | |
1998 | |
1999 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2000 { | |
2001 struct aim_oft_info *oft_info = xfer->data; | |
2002 GaimConnection *gc = oft_info->sess->aux_data; | |
2003 OscarData *od = gc->proto_data; | |
2004 int listenfd; | |
2005 | |
8660 | 2006 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2007 |
2008 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2009 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2010 oft_info->fh.name[63] = '\0'; | |
2011 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2012 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2013 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2014 | |
2015 /* Create a listening socket and an associated libfaim conn */ | |
2016 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2017 gaim_xfer_cancel_local(xfer); | |
2018 return; | |
2019 } | |
2020 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2021 oft_info->port = xfer->local_port; | |
2022 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2023 gaim_xfer_cancel_local(xfer); | |
2024 return; | |
2025 } | |
8660 | 2026 gaim_debug_misc("oscar", |
8446 | 2027 "port is %hu, ip is %s\n", |
2028 xfer->local_port, oft_info->clientip); | |
2029 if (oft_info->conn) { | |
2030 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2031 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2032 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2033 } else { | |
2034 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2035 _("Unable to establish listener socket.")); | |
2036 gaim_xfer_cancel_local(xfer); | |
2037 } | |
2038 } | |
2039 | |
2040 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2041 { | |
2042 struct aim_oft_info *oft_info = xfer->data; | |
2043 GaimConnection *gc = oft_info->sess->aux_data; | |
2044 OscarData *od = gc->proto_data; | |
2045 | |
8660 | 2046 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2047 |
9771 | 2048 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2049 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2050 |
2051 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2052 aim_oft_destroyinfo(oft_info); | |
2053 xfer->data = NULL; | |
2054 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2055 } | |
2056 | |
2057 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2058 { | |
2059 struct aim_oft_info *oft_info = xfer->data; | |
2060 | |
2061 /* I'm not sure I like how we do this. --marv | |
2062 * I do. AIM file transfers aren't really meant to be thought | |
2063 * of as a transferring just a single file. The rendezvous | |
2064 * establishes a connection between two computers, and then | |
2065 * those computers can use the same connection for transferring | |
2066 * multiple files. So we don't want the Gaim core up and closing | |
2067 * the socket all willy-nilly. We want to do that in the oscar | |
2068 * prpl, whenever one side or the other says they're finished | |
2069 * using the connection. There might be a better way to intercept | |
2070 * the socket from the core, however... --KingAnt | |
2071 */ | |
2072 | |
2073 /* | |
2074 * If we're done sending, intercept the socket from the core ft code | |
2075 * and wait for the other guy to send the "done" OFT packet. | |
2076 */ | |
2077 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2078 gaim_input_remove(xfer->watcher); | |
2079 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2080 xfer->fd = 0; | |
2081 gaim_xfer_set_completed(xfer, TRUE); | |
2082 } | |
2083 } | |
2084 | |
9466 | 2085 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2086 gboolean can_receive = FALSE; | |
2087 OscarData *od = gc->proto_data; | |
2088 | |
2089 if (!od->icq) { | |
2090 aim_userinfo_t *userinfo; | |
2091 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2092 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2093 can_receive = TRUE; | |
2094 } | |
2095 | |
2096 return can_receive; | |
2097 } | |
2098 | |
2099 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2100 |
2101 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2102 GaimXfer *xfer; |
5146 | 2103 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2104 const char *ip; |
3752 | 2105 |
9030 | 2106 od = (OscarData *)gc->proto_data; |
2107 | |
4617 | 2108 /* You want to send a file to someone else, you're so generous */ |
2109 | |
2110 /* Build the file transfer handle */ | |
9466 | 2111 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2112 |
5146 | 2113 /* Create the oscar-specific data */ |
8838 | 2114 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2115 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2116 xfer->data = oft_info; |
2117 | |
4617 | 2118 /* Setup our I/O op functions */ |
8446 | 2119 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2120 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2121 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2122 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2123 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2124 |
2125 /* Keep track of this transfer for later */ | |
2126 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2127 | |
2128 /* Now perform the request */ | |
9466 | 2129 if (file) |
2130 gaim_xfer_request_accepted(xfer, file); | |
2131 else | |
2132 gaim_xfer_request(xfer); | |
3630 | 2133 } |
2134 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2135 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2136 GaimConnection *gc = sess->aux_data; |
7283 | 2137 OscarData *od = gc->proto_data; |
6029 | 2138 GaimAccount *account = gc->account; |
2139 aim_conn_t *bosconn; | |
2140 char *host; int port; | |
2141 int i, rc; | |
2086 | 2142 va_list ap; |
2704 | 2143 struct aim_authresp_info *info; |
6029 | 2144 |
5575 | 2145 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2146 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2147 va_start(ap, fr); |
2704 | 2148 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2149 va_end(ap); |
2150 | |
8660 | 2151 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2152 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2153 |
4293 | 2154 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2155 char buf[256]; |
2704 | 2156 switch (info->errorcode) { |
2086 | 2157 case 0x05: |
2158 /* Incorrect nick/password */ | |
6498 | 2159 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2160 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2161 break; |
2162 case 0x11: | |
2163 /* Suspended account */ | |
6498 | 2164 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2165 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2166 break; |
3498 | 2167 case 0x14: |
2168 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2169 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2170 break; |
2086 | 2171 case 0x18: |
2172 /* connecting too frequently */ | |
6498 | 2173 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2174 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 | 2175 break; |
2176 case 0x1c: | |
2177 /* client too old */ | |
6498 | 2178 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2179 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
|
2180 gaim_connection_error(gc, buf); |
2086 | 2181 break; |
2182 default: | |
6623 | 2183 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2184 break; |
2185 } | |
8660 | 2186 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2187 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2188 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2189 "Error URL: %s\n", info->errorurl); |
2086 | 2190 od->killme = TRUE; |
2191 return 1; | |
2192 } | |
2193 | |
2194 | |
8660 | 2195 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2196 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2197 |
2704 | 2198 if (info->email) { |
8660 | 2199 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2200 } else { |
8660 | 2201 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2202 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2203 |
8660 | 2204 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2205 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2206 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2207 aim_conn_kill(sess, &fr->conn); |
2086 | 2208 |
2209 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2210 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2211 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2212 od->killme = TRUE; |
2213 return 0; | |
2214 } | |
2215 | |
4649 | 2216 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2217 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2218 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2219 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2220 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2221 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2222 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2223 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2224 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2225 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2226 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2227 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2228 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2229 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2230 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2231 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2232 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2234 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2235 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2237 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2238 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
|
2239 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2240 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2241 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2242 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2243 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2244 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2245 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
|
2246 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
|
2247 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
|
2248 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2249 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2250 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2251 #ifndef NOSSI |
4642 | 2252 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2253 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2254 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2255 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2256 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2257 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2258 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2259 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2260 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2261 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2262 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2263 |
7283 | 2264 od->conn = bosconn; |
2704 | 2265 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2266 if (info->bosip[i] == ':') { | |
2267 port = atoi(&(info->bosip[i+1])); | |
2086 | 2268 break; |
2269 } | |
2270 } | |
2704 | 2271 host = g_strndup(info->bosip, i); |
2086 | 2272 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2273 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2274 g_free(host); |
4366 | 2275 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2276 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2277 od->killme = TRUE; |
2278 return 0; | |
2279 } | |
4293 | 2280 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2281 gaim_input_remove(gc->inpa); |
2704 | 2282 |
7283 | 2283 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2284 ck[3] = 0x64; |
7282 | 2285 |
2086 | 2286 return 1; |
2287 } | |
2288 | |
7285 | 2289 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2290 struct pieceofcrap { |
5575 | 2291 GaimConnection *gc; |
2086 | 2292 unsigned long offset; |
2293 unsigned long len; | |
2294 char *modname; | |
2295 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2296 aim_conn_t *conn; |
2086 | 2297 unsigned int inpa; |
2298 }; | |
2299 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2300 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2301 { |
2302 struct pieceofcrap *pos = data; | |
7283 | 2303 OscarData *od = pos->gc->proto_data; |
2086 | 2304 char in = '\0'; |
2305 int x = 0; | |
2306 unsigned char m[17]; | |
2307 | |
2308 while (read(pos->fd, &in, 1) == 1) { | |
2309 if (in == '\n') | |
2310 x++; | |
2311 else if (in != '\r') | |
2312 x = 0; | |
2313 if (x == 2) | |
2314 break; | |
2315 in = '\0'; | |
2316 } | |
2317 if (in != '\n') { | |
4056 | 2318 char buf[256]; |
2319 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
|
2320 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2321 gaim_notify_warning(pos->gc, NULL, |
7422 | 2322 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2323 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2324 gaim_input_remove(pos->inpa); |
2086 | 2325 close(pos->fd); |
2326 g_free(pos); | |
2327 return; | |
2328 } | |
2329 read(pos->fd, m, 16); | |
2330 m[16] = '\0'; | |
8660 | 2331 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2332 for (x = 0; x < 16; x++) |
8660 | 2333 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2334 | |
2335 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2336 gaim_input_remove(pos->inpa); |
2086 | 2337 close(pos->fd); |
2338 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2339 g_free(pos); | |
2340 } | |
2341 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2342 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2343 struct pieceofcrap *pos = data; |
5420 | 2344 gchar *buf; |
2086 | 2345 |
4366 | 2346 pos->fd = source; |
2347 | |
2086 | 2348 if (source < 0) { |
5420 | 2349 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
|
2350 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2351 gaim_notify_warning(pos->gc, NULL, |
7422 | 2352 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2353 buf); |
5420 | 2354 g_free(buf); |
2086 | 2355 if (pos->modname) |
2356 g_free(pos->modname); | |
2357 g_free(pos); | |
2358 return; | |
2359 } | |
2360 | |
5420 | 2361 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2362 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2363 write(pos->fd, buf, strlen(buf)); | |
5420 | 2364 g_free(buf); |
2086 | 2365 if (pos->modname) |
2366 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2367 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2368 return; |
2369 } | |
2370 | |
2371 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2372 #define AIM_MAX_FILE_SIZE 98304 | |
2373 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2374 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2375 va_list ap; |
2376 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2377 fu32_t offset, len; |
2086 | 2378 char *modname; |
2379 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2380 va_start(ap, fr); |
4200 | 2381 offset = va_arg(ap, fu32_t); |
2382 len = va_arg(ap, fu32_t); | |
2086 | 2383 modname = va_arg(ap, char *); |
2384 va_end(ap); | |
2385 | |
8660 | 2386 gaim_debug_misc("oscar", |
5556 | 2387 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2388 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2389 |
2086 | 2390 if (len == 0) { |
8660 | 2391 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2392 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2393 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2394 return 1; | |
2395 } | |
9625 | 2396 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2397 #if 0 | |
2086 | 2398 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2399 char *buf; | |
2400 int i = 8; | |
2401 if (modname) | |
2402 i += strlen(modname); | |
2403 buf = g_malloc(i); | |
2404 i = 0; | |
2405 if (modname) { | |
2406 memcpy(buf, modname, strlen(modname)); | |
2407 i += strlen(modname); | |
2408 } | |
2409 buf[i++] = offset & 0xff; | |
2410 buf[i++] = (offset >> 8) & 0xff; | |
2411 buf[i++] = (offset >> 16) & 0xff; | |
2412 buf[i++] = (offset >> 24) & 0xff; | |
2413 buf[i++] = len & 0xff; | |
2414 buf[i++] = (len >> 8) & 0xff; | |
2415 buf[i++] = (len >> 16) & 0xff; | |
2416 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2417 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2418 "hashing request\n"); |
2086 | 2419 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2420 g_free(buf); | |
2421 return 1; | |
2422 } | |
9625 | 2423 #endif |
2086 | 2424 |
2425 pos = g_new0(struct pieceofcrap, 1); | |
2426 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2427 pos->conn = fr->conn; |
2086 | 2428 |
2429 pos->offset = offset; | |
2430 pos->len = len; | |
2431 pos->modname = modname ? g_strdup(modname) : NULL; | |
2432 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2433 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2434 char buf[256]; |
2086 | 2435 if (pos->modname) |
2436 g_free(pos->modname); | |
2437 g_free(pos); | |
4056 | 2438 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
|
2439 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2440 gaim_notify_warning(pos->gc, NULL, |
7422 | 2441 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2442 buf); |
2086 | 2443 } |
2444 | |
2445 return 1; | |
2446 } | |
2447 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2448 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2449 GaimConnection *gc = sess->aux_data; |
7283 | 2450 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2451 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2452 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2453 #if 0 |
2454 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2455 #endif | |
7011 | 2456 va_list ap; |
2457 char *key; | |
2086 | 2458 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2459 va_start(ap, fr); |
2086 | 2460 key = va_arg(ap, char *); |
2461 va_end(ap); | |
2462 | |
4617 | 2463 if (od->icq) { |
3458 | 2464 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2465 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2466 gaim_account_get_password(account), &info, key); |
3458 | 2467 } else { |
2468 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2469 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2470 gaim_account_get_password(account), &info, key); |
3458 | 2471 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2472 |
7283 | 2473 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2474 ck[2] = 0x6c; |
7282 | 2475 |
2086 | 2476 return 1; |
2477 } | |
2478 | |
2675 | 2479 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2480 GaimConnection *gc = sess->aux_data; |
2647 | 2481 struct chat_connection *chatcon; |
2482 static int id = 1; | |
2483 | |
6905 | 2484 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
|
2485 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
|
2486 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
|
2487 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
|
2488 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2489 |
2672 | 2490 aim_clientready(sess, fr->conn); |
2675 | 2491 |
2647 | 2492 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2493 chatcon->id = id; | |
8733 | 2494 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2495 |
2496 return 1; | |
2497 } | |
2498 | |
2675 | 2499 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2500 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2501 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2502 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2503 |
2504 aim_clientready(sess, fr->conn); | |
2505 | |
2506 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2507 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2508 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2509 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2510 |
3694 | 2511 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2512 | |
2513 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2514 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2515 | |
7282 | 2516 aim_email_sendcookies(sess); |
2517 aim_email_activate(sess); | |
3694 | 2518 aim_clientready(sess, fr->conn); |
2519 | |
2520 return 1; | |
2521 } | |
2522 | |
4804 | 2523 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2524 GaimConnection *gc = sess->aux_data; |
7283 | 2525 OscarData *od = gc->proto_data; |
4804 | 2526 |
2527 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2528 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2529 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2530 | |
2531 aim_clientready(sess, fr->conn); | |
2532 | |
4823 | 2533 od->iconconnecting = FALSE; |
2534 | |
4804 | 2535 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2536 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2537 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2538 |
2539 return 1; | |
2540 } | |
2541 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2542 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2543 GaimConnection *gc = data; |
7283 | 2544 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2545 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2546 aim_conn_t *tstconn; |
2086 | 2547 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2548 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2549 close(source); |
2550 return; | |
2551 } | |
2552 | |
4617 | 2553 od = gc->proto_data; |
2554 sess = od->sess; | |
2086 | 2555 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2556 tstconn->fd = source; |
2086 | 2557 |
2558 if (source < 0) { | |
2559 aim_conn_kill(sess, &tstconn); | |
8660 | 2560 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2561 "unable to connect to chatnav server\n"); |
2086 | 2562 return; |
2563 } | |
2564 | |
2565 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2566 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2567 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2568 } |
2569 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2570 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2571 { |
5575 | 2572 GaimConnection *gc = data; |
7283 | 2573 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2574 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2575 aim_conn_t *tstconn; |
2086 | 2576 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2577 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2578 close(source); |
2579 return; | |
2580 } | |
2581 | |
4617 | 2582 od = gc->proto_data; |
2583 sess = od->sess; | |
2086 | 2584 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2585 tstconn->fd = source; |
2086 | 2586 |
2587 if (source < 0) { | |
2588 aim_conn_kill(sess, &tstconn); | |
8660 | 2589 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2590 "unable to connect to authorizer\n"); |
2086 | 2591 return; |
2592 } | |
2593 | |
2594 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2595 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2596 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2597 } |
2598 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2599 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2600 { |
2601 struct chat_connection *ccon = data; | |
5575 | 2602 GaimConnection *gc = ccon->gc; |
7283 | 2603 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2604 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2605 aim_conn_t *tstconn; |
2086 | 2606 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2607 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2608 close(source); |
2609 g_free(ccon->show); | |
2610 g_free(ccon->name); | |
2611 g_free(ccon); | |
2612 return; | |
2613 } | |
2614 | |
4617 | 2615 od = gc->proto_data; |
2616 sess = od->sess; | |
2086 | 2617 tstconn = ccon->conn; |
4366 | 2618 tstconn->fd = source; |
2086 | 2619 |
2620 if (source < 0) { | |
2621 aim_conn_kill(sess, &tstconn); | |
2622 g_free(ccon->show); | |
2623 g_free(ccon->name); | |
2624 g_free(ccon); | |
2625 return; | |
2626 } | |
2627 | |
2628 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2629 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2630 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2631 } |
2632 | |
3694 | 2633 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2634 GaimConnection *gc = data; |
7283 | 2635 OscarData *od; |
3694 | 2636 aim_session_t *sess; |
2637 aim_conn_t *tstconn; | |
2638 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2639 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2640 close(source); |
2641 return; | |
2642 } | |
2643 | |
4617 | 2644 od = gc->proto_data; |
2645 sess = od->sess; | |
3694 | 2646 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2647 tstconn->fd = source; |
3694 | 2648 |
2649 if (source < 0) { | |
2650 aim_conn_kill(sess, &tstconn); | |
8660 | 2651 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2652 "unable to connect to email server\n"); |
3694 | 2653 return; |
2654 } | |
2655 | |
2656 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2657 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2658 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2659 "email: connected\n"); |
3694 | 2660 } |
2661 | |
4804 | 2662 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2663 GaimConnection *gc = data; |
7283 | 2664 OscarData *od; |
4804 | 2665 aim_session_t *sess; |
2666 aim_conn_t *tstconn; | |
2667 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2668 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2669 close(source); |
2670 return; | |
2671 } | |
2672 | |
2673 od = gc->proto_data; | |
2674 sess = od->sess; | |
2675 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2676 tstconn->fd = source; | |
2677 | |
2678 if (source < 0) { | |
2679 aim_conn_kill(sess, &tstconn); | |
8660 | 2680 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2681 "unable to connect to icon server\n"); |
4804 | 2682 return; |
2683 } | |
2684 | |
2685 aim_conn_completeconnect(sess, tstconn); | |
2686 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2687 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2688 } |
2689 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2690 /* 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
|
2691 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2692 GaimConnection *gc = sess->aux_data; |
2693 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2694 aim_conn_t *tstconn; |
4452 | 2695 int i; |
2086 | 2696 char *host; |
2697 int port; | |
4821 | 2698 va_list ap; |
2699 struct aim_redirect_data *redir; | |
2086 | 2700 |
5575 | 2701 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2702 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2703 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2704 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2705 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2706 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2707 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2708 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2709 port = atoi(&(redir->ip[i+1])); |
2086 | 2710 break; |
2711 } | |
2712 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2713 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2714 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2715 switch(redir->group) { |
2086 | 2716 case 0x7: /* Authorizer */ |
8660 | 2717 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2718 "Reconnecting with authorizor...\n"); |
2086 | 2719 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2720 if (tstconn == NULL) { | |
8660 | 2721 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2722 "unable to reconnect with authorizer\n"); |
2086 | 2723 g_free(host); |
2724 return 1; | |
2725 } | |
4649 | 2726 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2727 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2728 |
2729 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2730 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2731 aim_conn_kill(sess, &tstconn); |
8660 | 2732 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2733 "unable to reconnect with authorizer\n"); |
2086 | 2734 g_free(host); |
2735 return 1; | |
2736 } | |
4293 | 2737 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2738 break; |
2739 | |
2086 | 2740 case 0xd: /* ChatNav */ |
2741 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2742 if (tstconn == NULL) { | |
8660 | 2743 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2744 "unable to connect to chatnav server\n"); |
2086 | 2745 g_free(host); |
2746 return 1; | |
2747 } | |
4649 | 2748 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2749 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2750 |
2751 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2752 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2753 aim_conn_kill(sess, &tstconn); |
8660 | 2754 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2755 "unable to connect to chatnav server\n"); |
2086 | 2756 g_free(host); |
2757 return 1; | |
2758 } | |
4293 | 2759 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2760 break; |
2761 | |
2762 case 0xe: { /* Chat */ | |
2086 | 2763 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2764 |
2086 | 2765 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2766 if (tstconn == NULL) { | |
8660 | 2767 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2768 "unable to connect to chat server\n"); |
2086 | 2769 g_free(host); |
2770 return 1; | |
2771 } | |
2772 | |
4649 | 2773 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2774 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2775 | |
2086 | 2776 ccon = g_new0(struct chat_connection, 1); |
2777 ccon->conn = tstconn; | |
2778 ccon->gc = gc; | |
2779 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2780 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2781 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2782 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2783 ccon->show = extract_name(redir->chat.room); |
4634 | 2784 |
2086 | 2785 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2786 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2787 aim_conn_kill(sess, &tstconn); |
8660 | 2788 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2789 "unable to connect to chat server\n"); |
2086 | 2790 g_free(host); |
2791 g_free(ccon->show); | |
2792 g_free(ccon->name); | |
2793 g_free(ccon); | |
2794 return 1; | |
2795 } | |
4293 | 2796 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2797 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2798 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2799 ccon->name, ccon->exchange); |
4194 | 2800 } break; |
3694 | 2801 |
4804 | 2802 case 0x0010: { /* icon */ |
2803 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2804 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2805 "unable to connect to icon server\n"); |
4804 | 2806 g_free(host); |
2807 return 1; | |
2808 } | |
2809 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2810 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2811 | |
2812 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2813 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2814 aim_conn_kill(sess, &tstconn); |
8660 | 2815 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2816 "unable to connect to icon server\n"); |
4804 | 2817 g_free(host); |
2818 return 1; | |
2819 } | |
2820 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2821 } break; | |
2822 | |
3694 | 2823 case 0x0018: { /* email */ |
2824 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2825 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2826 "unable to connect to email server\n"); |
3694 | 2827 g_free(host); |
2828 return 1; | |
2829 } | |
4649 | 2830 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2831 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2832 | |
2833 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2834 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2835 aim_conn_kill(sess, &tstconn); |
8660 | 2836 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2837 "unable to connect to email server\n"); |
3694 | 2838 g_free(host); |
2839 return 1; | |
2840 } | |
4293 | 2841 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2842 } break; |
2843 | |
2086 | 2844 default: /* huh? */ |
8660 | 2845 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2846 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2847 redir->group); |
2086 | 2848 break; |
2849 } | |
2850 | |
2851 g_free(host); | |
2852 return 1; | |
2853 } | |
2854 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2855 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2856 GaimConnection *gc = sess->aux_data; |
9058 | 2857 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 2858 OscarData *od = gc->proto_data; |
4738 | 2859 struct buddyinfo *bi; |
2993 | 2860 time_t time_idle = 0, signon = 0; |
2861 int type = 0; | |
2862 int caps = 0; | |
2086 | 2863 va_list ap; |
4738 | 2864 aim_userinfo_t *info; |
4194 | 2865 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2866 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2867 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2868 va_end(ap); |
2869 | |
2993 | 2870 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2871 caps = info->capabilities; | |
3267 | 2872 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
2873 type |= UC_AB; | |
2874 | |
4766 | 2875 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2876 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
2877 type |= UC_UNCONFIRMED; | |
2878 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
2879 type |= UC_ADMIN; | |
2880 if (info->flags & AIM_FLAG_AOL) | |
2881 type |= UC_AOL; | |
2882 if (info->flags & AIM_FLAG_FREE) | |
2883 type |= UC_NORMAL; | |
2884 if (info->flags & AIM_FLAG_AWAY) | |
2885 type |= UC_UNAVAILABLE; | |
2886 if (info->flags & AIM_FLAG_WIRELESS) | |
2887 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2888 } |
2993 | 2889 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2890 type = (info->icqinfo.status << 16); |
3013 | 2891 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2892 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 2893 type |= UC_UNAVAILABLE; |
3013 | 2894 } |
2993 | 2895 } |
2896 | |
7141 | 2897 if (caps & AIM_CAPS_ICQ_DIRECT) |
2898 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2899 |
2900 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2901 time(&time_idle); |
2902 time_idle -= info->idletime*60; | |
9295 | 2903 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2904 } |
2905 | |
5836 | 2906 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2907 signon = info->onlinesince; | |
2908 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2909 signon = time(NULL) - info->sessionlen; |
2086 | 2910 |
5575 | 2911 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
2912 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2913 |
7261 | 2914 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
4738 | 2915 if (!bi) { |
2916 bi = g_new0(struct buddyinfo, 1); | |
7261 | 2917 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
4738 | 2918 } |
4739 | 2919 bi->typingnot = FALSE; |
2920 bi->ico_informed = FALSE; | |
6857 | 2921 bi->ipaddr = info->icqinfo.ipaddr; |
2922 | |
2923 /* Available message stuff */ | |
6292 | 2924 free(bi->availmsg); |
7011 | 2925 if (info->avail != NULL) |
8225 | 2926 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2927 else |
6292 | 2928 bi->availmsg = NULL; |
4732 | 2929 |
4804 | 2930 /* Server stored icon stuff */ |
4853 | 2931 if (info->iconcsumlen) { |
7125 | 2932 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2933 char *b16 = NULL, *filepath = NULL; |
7093 | 2934 GaimBuddy *b = NULL; |
4853 | 2935 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2936 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
4853 | 2937 b = gaim_find_buddy(gc->account, info->sn); |
7093 | 2938 /* |
2939 * If for some reason the checksum is valid, but cached file is not.. | |
2940 * we want to know. | |
2941 */ | |
7693 | 2942 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2943 if (filename != NULL) { |
2944 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2945 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2946 "icon_checksum"); | |
9801 | 2947 else { |
2948 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2949 filename, NULL); | |
2950 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2951 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2952 "icon_checksum"); | |
2953 g_free(filepath); | |
2954 } | |
7093 | 2955 } else |
2956 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2957 |
4853 | 2958 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2959 GSList *cur = od->requesticon; | |
2960 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2961 cur = cur->next; | |
2962 if (!cur) { | |
7475 | 2963 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
4853 | 2964 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2965 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2966 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2967 } |
2968 } | |
6053 | 2969 g_free(b16); |
4853 | 2970 } |
2971 | |
9058 | 2972 /* |
2973 * If we have info for ourselves, then update our local warning | |
2974 * level and set our official time of login. Is this necessary? | |
2975 * XXX - This needs to be changed some how. evil should not be | |
2976 * handled by the core at all? | |
2977 */ | |
2978 if (!aim_sncmp(info->sn, gaim_account_get_username(account))) { | |
2979 gc->evil = (info->warnlevel/10.0); | |
2980 gc->login_time_official = signon; | |
2981 } | |
2982 | |
9927 | 2983 serv_got_update(gc, info->sn, TRUE, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 2984 |
2985 return 1; | |
2986 } | |
2987 | |
8341 | 2988 static void gaim_check_comment(OscarData *od, const char *str) { |
2989 if ((str == NULL) || strcmp(str, ck)) | |
2990 aim_locate_setcaps(od->sess, caps_aim); | |
2991 else | |
2992 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2993 } | |
2994 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2995 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2996 GaimConnection *gc = sess->aux_data; |
7283 | 2997 OscarData *od = gc->proto_data; |
2086 | 2998 va_list ap; |
4739 | 2999 aim_userinfo_t *info; |
2086 | 3000 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3001 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3002 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3003 va_end(ap); |
3004 | |
9927 | 3005 serv_got_update(gc, info->sn, FALSE, 0, 0, 0, 0); |
2086 | 3006 |
7261 | 3007 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3008 |
2086 | 3009 return 1; |
3010 } | |
3011 | |
4617 | 3012 /* BBB */ |
3952 | 3013 /* |
4617 | 3014 * This is called after a remote AIM user has connected to us. We |
3015 * want to do some voodoo with the socket file descriptors, add a | |
3016 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3017 */ |
4656 | 3018 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3019 GaimConnection *gc = sess->aux_data; |
7283 | 3020 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3021 GaimXfer *xfer; |
5146 | 3022 struct aim_oft_info *oft_info; |
3630 | 3023 va_list ap; |
3024 aim_conn_t *conn, *listenerconn; | |
4656 | 3025 |
8660 | 3026 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3027 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3028 va_start(ap, fr); |
3029 conn = va_arg(ap, aim_conn_t *); | |
3030 listenerconn = va_arg(ap, aim_conn_t *); | |
3031 va_end(ap); | |
3032 | |
4617 | 3033 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3034 return 1; | |
3035 | |
5146 | 3036 if (!(oft_info = xfer->data)) |
4617 | 3037 return 1; |
3038 | |
3630 | 3039 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3040 gaim_input_remove(xfer->watcher); |
3630 | 3041 aim_conn_kill(sess, &listenerconn); |
3042 | |
5146 | 3043 oft_info->conn = conn; |
3044 xfer->fd = oft_info->conn->fd; | |
3045 | |
3046 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3047 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3048 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3049 |
3050 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3051 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3052 |
3053 return 0; | |
3054 } | |
3055 | |
3952 | 3056 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3057 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3058 * user in order to transfer a file. |
3952 | 3059 */ |
4617 | 3060 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
|
3061 GaimXfer *xfer; |
5146 | 3062 struct aim_oft_info *oft_info; |
4656 | 3063 |
8660 | 3064 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3065 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3066 if (!(xfer = data)) |
3067 return; | |
5146 | 3068 if (!(oft_info = xfer->data)) |
3630 | 3069 return; |
8446 | 3070 if (source < 0) { |
3071 gaim_xfer_cancel_remote(xfer); | |
4617 | 3072 return; |
8446 | 3073 } |
4617 | 3074 |
3075 xfer->fd = source; | |
5146 | 3076 oft_info->conn->fd = source; |
3077 | |
3078 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3079 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3080 |
3081 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3082 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3083 |
3084 return; | |
3630 | 3085 } |
3086 | |
3952 | 3087 /* |
4617 | 3088 * This is called when a buddy sends us some file info. This happens when they |
3089 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3090 * You should send them the exact same info except use the real cookie. We also |
4617 | 3091 * get like totally ready to like, receive the file, kay? |
3952 | 3092 */ |
4617 | 3093 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3094 GaimConnection *gc = sess->aux_data; |
7283 | 3095 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3096 GaimXfer *xfer; |
5146 | 3097 struct aim_oft_info *oft_info; |
4617 | 3098 va_list ap; |
3099 aim_conn_t *conn; | |
3100 fu8_t *cookie; | |
3101 struct aim_fileheader_t *fh; | |
4656 | 3102 |
8660 | 3103 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3104 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3105 va_start(ap, fr); |
3106 conn = va_arg(ap, aim_conn_t *); | |
3107 cookie = va_arg(ap, fu8_t *); | |
3108 fh = va_arg(ap, struct aim_fileheader_t *); | |
3109 va_end(ap); | |
3110 | |
3111 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3112 return 1; | |
3113 | |
5146 | 3114 if (!(oft_info = xfer->data)) |
4617 | 3115 return 1; |
3116 | |
3117 /* We want to stop listening with a normal thingy */ | |
3118 gaim_input_remove(xfer->watcher); | |
3119 xfer->watcher = 0; | |
3120 | |
5146 | 3121 /* They sent us some information about the file they're sending */ |
3122 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3123 | |
3124 /* Fill in the cookie */ | |
3125 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3126 | |
4617 | 3127 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3128 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3129 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3130 | |
3131 return 0; | |
3630 | 3132 } |
3133 | |
3952 | 3134 /* |
4657 | 3135 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3136 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3137 */ |
4617 | 3138 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3139 GaimConnection *gc = sess->aux_data; |
7283 | 3140 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3141 GaimXfer *xfer; |
4617 | 3142 va_list ap; |
3143 aim_conn_t *conn; | |
3144 fu8_t *cookie; | |
3145 struct aim_fileheader_t *fh; | |
4656 | 3146 |
8660 | 3147 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3148 va_start(ap, fr); |
3149 conn = va_arg(ap, aim_conn_t *); | |
3150 cookie = va_arg(ap, fu8_t *); | |
3151 fh = va_arg(ap, struct aim_fileheader_t *); | |
3152 va_end(ap); | |
3153 | |
3154 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3155 return 1; | |
3156 | |
4656 | 3157 /* We want to stop listening with a normal thingy */ |
3158 gaim_input_remove(xfer->watcher); | |
3159 xfer->watcher = 0; | |
3160 | |
4617 | 3161 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3162 | |
3163 return 0; | |
3630 | 3164 } |
4617 | 3165 |
3166 /* | |
3167 * We just sent a file to someone. They said they got it and everything, | |
3168 * so we can close our direct connection and what not. | |
3169 */ | |
3170 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3171 GaimConnection *gc = sess->aux_data; |
7283 | 3172 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3173 GaimXfer *xfer; |
4617 | 3174 va_list ap; |
3175 aim_conn_t *conn; | |
3176 fu8_t *cookie; | |
3177 struct aim_fileheader_t *fh; | |
4656 | 3178 |
8660 | 3179 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3180 va_start(ap, fr); |
3181 conn = va_arg(ap, aim_conn_t *); | |
3182 cookie = va_arg(ap, fu8_t *); | |
3183 fh = va_arg(ap, struct aim_fileheader_t *); | |
3184 va_end(ap); | |
3185 | |
3186 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3187 return 1; | |
3188 | |
4656 | 3189 xfer->fd = conn->fd; |
4617 | 3190 gaim_xfer_end(xfer); |
3191 | |
3192 return 0; | |
3193 } | |
3630 | 3194 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3195 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3196 GaimConnection *gc = sess->aux_data; |
7283 | 3197 OscarData *od = gc->proto_data; |
8708 | 3198 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3199 GaimConvImFlags flags = 0; |
4738 | 3200 struct buddyinfo *bi; |
5575 | 3201 const char *iconfile; |
9806 | 3202 GString *message; |
3203 gchar *tmp; | |
3204 aim_mpmsg_section_t *curpart; | |
3205 | |
3206 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3207 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3208 |
8708 | 3209 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3210 if (!bi) { |
3211 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3212 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3213 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3214 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3215 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3216 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3217 |
4738 | 3218 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3219 bi->typingnot = TRUE; | |
3220 else | |
3221 bi->typingnot = FALSE; | |
3222 | |
4380 | 3223 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3224 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3225 "%s has an icon\n", userinfo->sn); |
4738 | 3226 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3227 bi->ico_need = TRUE; | |
3228 bi->ico_len = args->iconlen; | |
3229 bi->ico_csum = args->iconsum; | |
3230 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3231 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3232 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3233 |
8708 | 3234 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3235 (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
|
3236 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3237 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3238 |
5575 | 3239 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3240 char *buf = g_malloc(st.st_size); |
5575 | 3241 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3242 if (file) { |
9532 | 3243 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3244 int len = fread(buf, 1, st.st_size, file); |
8660 | 3245 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3246 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3247 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3248 userinfo->sn, len, st.st_size); |
4617 | 3249 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3250 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3251 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3252 } else |
8660 | 3253 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3254 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3255 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3256 } else |
8660 | 3257 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3258 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3259 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3260 |
9806 | 3261 message = g_string_new(""); |
3262 curpart = args->mpmsg.parts; | |
3263 while (curpart != NULL) { | |
9908 | 3264 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3265 curpart->data, curpart->datalen); |
3266 if (tmp != NULL) { | |
3267 g_string_append(message, tmp); | |
3268 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3269 } |
9806 | 3270 |
3271 curpart = curpart->next; | |
3272 } | |
3273 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3274 |
8666 | 3275 /* |
8995 | 3276 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3277 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3278 * so any HTML we receive is intended to be displayed |
3279 * | |
3280 * Note: There *may* be some clients which send messages as HTML formatted - | |
3281 * they need to be special-cased somehow. | |
8666 | 3282 */ |
9975 | 3283 if (aim_sn_is_icq(gaim_account_get_username(account) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3284 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3285 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3286 g_free(tmp); |
3287 tmp = tmp2; | |
3288 } | |
3289 | |
6982 | 3290 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3291 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3292 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3293 return 1; |
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 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3296 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3297 GaimConnection *gc; |
9933 | 3298 GaimAccount *account; |
9070 | 3299 OscarData *od; |
9933 | 3300 const char *username = NULL; |
3301 char *message = NULL; | |
9070 | 3302 |
3303 g_return_val_if_fail(sess != NULL, 0); | |
3304 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3305 | |
3306 gc = sess->aux_data; | |
9933 | 3307 account = gaim_connection_get_account(gc); |
9070 | 3308 od = gc->proto_data; |
9933 | 3309 username = gaim_account_get_username(account); |
3310 | |
3311 if (args == NULL) | |
4121 | 3312 return 0; |
4194 | 3313 |
9933 | 3314 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3315 userinfo->sn, args->status); | |
3316 | |
3317 if (args->msg != NULL) | |
3318 { | |
3319 if (args->encoding != NULL) | |
3320 { | |
3321 char *encoding = NULL; | |
3322 encoding = oscar_encoding_extract(args->encoding); | |
3323 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3324 g_free(encoding); | |
3325 } else { | |
3326 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3327 message = g_strdup(args->msg); | |
3328 } | |
3329 } | |
2869 | 3330 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3331 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3332 char *name; |
5234 | 3333 GHashTable *components; |
3334 | |
9933 | 3335 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3336 g_free(message); | |
4121 | 3337 return 1; |
9933 | 3338 } |
5234 | 3339 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3340 g_free); | |
4121 | 3341 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3342 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3343 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
|
3344 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3345 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3346 userinfo->sn, |
9933 | 3347 message, |
5234 | 3348 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3349 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3350 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3351 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3352 /* BBB */ |
3353 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3354 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3355 GaimXfer *xfer; |
5146 | 3356 struct aim_oft_info *oft_info; |
3357 | |
3358 if (!args->cookie || !args->port || !args->verifiedip || | |
3359 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3360 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3361 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3362 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3363 "information.\n", userinfo->sn); |
5146 | 3364 if (args->proxyip) |
8660 | 3365 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3366 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3367 "does not support this yet.\n"); |
9933 | 3368 g_free(message); |
4617 | 3369 return 1; |
4656 | 3370 } |
4617 | 3371 |
3372 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3373 /* 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
|
3374 * directory -- remove the star and trailing slash so we don't save |
4617 | 3375 * directories that look like 'dirname\*' -- arl */ |
3376 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3377 if (tmp && (tmp[1] == '*')) { | |
3378 tmp[0] = '\0'; | |
3379 } | |
8660 | 3380 gaim_debug_warning("oscar", |
8446 | 3381 "We're receiving a whole directory! What fun! " |
3382 "Especially since we don't support that!\n"); | |
4617 | 3383 } |
3384 | |
3385 /* Build the file transfer handle */ | |
3386 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3387 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3388 xfer->remote_port = args->port; |
4617 | 3389 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3390 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3391 gaim_xfer_set_message(xfer, message); |
5146 | 3392 |
3393 /* Create the oscar-specific data */ | |
5163 | 3394 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3395 if (args->proxyip) |
5146 | 3396 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3397 if (args->verifiedip) |
5146 | 3398 oft_info->verifiedip = g_strdup(args->verifiedip); |
3399 xfer->data = oft_info; | |
4617 | 3400 |
3401 /* Setup our I/O op functions */ | |
8446 | 3402 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3403 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3404 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
|
3405 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3406 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3407 |
3408 /* Keep track of this transfer for later */ | |
3409 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3410 | |
3411 /* Now perform the request */ | |
3412 gaim_xfer_request(xfer); | |
3413 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3414 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3415 GaimXfer *xfer; |
8660 | 3416 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3417 "AAA - File transfer canceled by remote user\n"); |
4617 | 3418 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
|
3419 gaim_xfer_cancel_remote(xfer); |
4617 | 3420 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3421 /* | |
3422 * This gets sent by the receiver of a file | |
3423 * as they connect directly to us. If we don't | |
3424 * get this, then maybe a third party connected | |
3425 * to us, and we shouldn't send them anything. | |
3426 */ | |
3427 } else { | |
8660 | 3428 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3429 "unknown rendezvous status!\n"); |
3630 | 3430 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3431 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3432 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3433 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3434 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3435 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3436 args->info.icon.length); |
6871 | 3437 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3438 /* 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
|
3439 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3440 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
|
3441 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3442 |
4212 | 3443 if (!args->verifiedip) { |
8983 | 3444 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3445 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3446 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3447 g_free(message); |
4650 | 3448 return 1; |
4212 | 3449 } |
3450 | |
8660 | 3451 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3452 "%s received direct im request from %s (%s)\n", |
8983 | 3453 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3454 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3455 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3456 d->sn = g_strdup(userinfo->sn); |
8983 | 3457 /* Let's use the clientip here, because I think that's what AIM does. |
3458 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3459 * and then ask them to connect to us. */ | |
3460 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
|
3461 memcpy(d->cookie, args->cookie, 8); |
9070 | 3462 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3463 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3464 | |
8971 | 3465 oscar_direct_im_destroy(od, dim); |
8984 | 3466 d->donttryagain = TRUE; |
8971 | 3467 accept_direct_im_request(d); |
3468 } else { | |
8983 | 3469 if (dim && !dim->connected) |
8971 | 3470 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3471 "already connected to that buddy!"); | |
5575 | 3472 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
|
3473 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3474 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3475 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3476 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3477 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3478 "revealed, this may be considered a privacy " |
9972 | 3479 "risk."), |
3480 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3481 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3482 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3483 /* FIXME: we should actually send a packet on cancel */ | |
3484 } | |
8708 | 3485 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3486 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
|
3487 } else { |
8660 | 3488 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3489 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3490 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3491 |
9933 | 3492 g_free(message); |
3493 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3494 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3495 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3496 |
3453 | 3497 /* |
4230 | 3498 * Authorization Functions |
3499 * Most of these are callbacks from dialogs. They're used by both | |
3500 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3501 */ |
4269 | 3502 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3503 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3504 GaimConnection *gc = data->gc; |
4244 | 3505 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3506 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3507 OscarData *od = gc->proto_data; |
6695 | 3508 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3509 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3510 if (buddy && group) { |
8660 | 3511 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3512 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3513 buddy->name, group->name); |
4889 | 3514 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3515 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3516 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3517 } |
4230 | 3518 } |
4337 | 3519 } |
3520 | |
3521 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3522 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3523 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3524 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3525 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3526 data); |
4230 | 3527 } |
3528 | |
3529 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3530 GaimConnection *gc = data->gc; |
4244 | 3531 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3532 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3533 /* Remove from local list */ |
3534 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3535 gaim_blist_remove_buddy(b); | |
4244 | 3536 } |
3537 | |
5836 | 3538 oscar_free_name_data(data); |
4230 | 3539 } |
3540 | |
9030 | 3541 |
3542 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3543 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3544 GaimBuddy *buddy; |
4269 | 3545 gchar *dialog_msg, *nombre; |
3546 | |
4687 | 3547 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3548 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3549 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3550 else |
4830 | 3551 nombre = NULL; |
3552 | |
3553 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 | 3554 data->gc = gc; |
3555 data->name = g_strdup(name); | |
3556 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3557 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3558 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3559 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3560 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3561 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3562 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3563 |
3564 g_free(dialog_msg); | |
3565 g_free(nombre); | |
3566 } | |
3567 | |
9030 | 3568 |
3569 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3570 GaimBuddy *buddy; | |
3571 GaimConnection *gc; | |
3572 | |
3573 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3574 | |
3575 buddy = (GaimBuddy *) node; | |
3576 gc = gaim_account_get_connection(buddy->account); | |
3577 gaim_auth_sendrequest(gc, buddy->name); | |
3578 } | |
3579 | |
4230 | 3580 /* When other people ask you for authorization */ |
3581 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3582 GaimConnection *gc = data->gc; |
4244 | 3583 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3584 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3585 OscarData *od = gc->proto_data; |
4236 | 3586 #ifdef NOSSI |
6695 | 3587 GaimBuddy *buddy; |
4244 | 3588 gchar message; |
3589 message = 0; | |
4687 | 3590 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3591 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3592 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3593 #else |
4889 | 3594 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3595 #endif |
4244 | 3596 } |
3597 | |
5836 | 3598 oscar_free_name_data(data); |
3141 | 3599 } |
3600 | |
4230 | 3601 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3602 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3603 GaimConnection *gc = data->gc; |
4244 | 3604 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3605 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3606 OscarData *od = gc->proto_data; |
4230 | 3607 #ifdef NOSSI |
4617 | 3608 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3609 #else |
4889 | 3610 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3611 #endif |
4244 | 3612 } |
4337 | 3613 } |
3614 | |
3615 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3616 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3617 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3618 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3619 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3620 data); |
3141 | 3621 } |
3622 | |
7023 | 3623 /* When someone sends you buddies */ |
3624 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3625 GaimConnection *gc = data->gc; |
4244 | 3626 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3627 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3628 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3629 } |
3630 | |
5836 | 3631 oscar_free_name_data(data); |
3453 | 3632 } |
3633 | |
4075 | 3634 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 | 3635 GaimConnection *gc = sess->aux_data; |
9908 | 3636 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3637 gchar **msg1, **msg2; |
6051 | 3638 int i, numtoks; |
4076 | 3639 |
4121 | 3640 if (!args->type || !args->msg || !args->uin) |
3641 return 1; | |
4194 | 3642 |
8660 | 3643 gaim_debug_info("oscar", |
9908 | 3644 "Received a channel 4 message of type 0x%02hhx.\n", |
3645 args->type); | |
4076 | 3646 |
9919 | 3647 /* |
3648 * Split up the message at the delimeter character, then convert each | |
3649 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3650 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3651 * character in whatever encoding the message was sent in. Type 1 | |
3652 * messages are always made up of only one part, so we can easily account | |
3653 * for this suck-ass part of the protocol by splitting the string into at | |
3654 * most 1 baby string. | |
3655 */ | |
3656 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3657 for (numtoks=0; msg1[numtoks]; numtoks++); |
3658 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3659 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3660 gaim_str_strip_cr(msg1[i]); |
9908 | 3661 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3662 } |
3663 msg2[i] = NULL; | |
3664 | |
3952 | 3665 switch (args->type) { |
4173 | 3666 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3667 if (i >= 1) { |
5556 | 3668 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3669 gchar *tmp; |
3670 | |
3671 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3672 tmp = gaim_escape_html(msg2[0]); |
8493 | 3673 |
4076 | 3674 if (t) { /* This is an offline message */ |
9680 | 3675 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3676 #ifdef HAVE_TM_GMTOFF |
9724 | 3677 time_t now; |
3678 struct tm *tm; | |
3679 now = time(NULL); | |
3680 tm = localtime(&now); | |
3681 t += tm->tm_gmtoff; | |
9698 | 3682 #else |
3683 # ifdef HAVE_TIMEZONE | |
9680 | 3684 tzset(); |
3685 t -= timezone; | |
9698 | 3686 # endif |
3687 #endif | |
8514 | 3688 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3689 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3690 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3691 } |
3692 g_free(uin); | |
8493 | 3693 g_free(tmp); |
4075 | 3694 } |
3316 | 3695 } break; |
3696 | |
4173 | 3697 case 0x04: { /* Someone sent you a URL */ |
4076 | 3698 if (i >= 2) { |
7385 | 3699 if (msg2[1] != NULL) { |
3700 gchar *uin = g_strdup_printf("%u", args->uin); | |
3701 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3702 msg2[1], | |
3703 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3704 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3705 g_free(uin); | |
3706 g_free(message); | |
3707 } | |
3453 | 3708 } |
3709 } break; | |
3710 | |
4173 | 3711 case 0x06: { /* Someone requested authorization */ |
4076 | 3712 if (i >= 6) { |
4230 | 3713 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3714 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 | 3715 gaim_debug_info("oscar", |
5556 | 3716 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3717 args->uin); |
4076 | 3718 data->gc = gc; |
5556 | 3719 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3720 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3721 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3722 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3723 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3724 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3725 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3726 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3727 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3728 g_free(dialog_msg); |
3729 } | |
3141 | 3730 } break; |
3731 | |
4173 | 3732 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3733 if (i >= 1) { |
7023 | 3734 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
|
3735 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3736 dialog_msg); |
4076 | 3737 g_free(dialog_msg); |
3738 } | |
3141 | 3739 } break; |
3740 | |
4173 | 3741 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3742 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
|
3743 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3744 dialog_msg); |
3141 | 3745 g_free(dialog_msg); |
3746 } break; | |
3747 | |
4333 | 3748 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3749 if (i >= 5) { | |
3750 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
|
3751 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3752 g_free(dialog_msg); |
3753 } | |
3754 } break; | |
3755 | |
4173 | 3756 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3757 if (i >= 6) { |
4194 | 3758 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
|
3759 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3760 g_free(dialog_msg); |
3761 } | |
4075 | 3762 } break; |
3763 | |
4173 | 3764 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3765 if (i >= 6) { |
4308 | 3766 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
|
3767 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3768 g_free(dialog_msg); |
3769 } | |
4075 | 3770 } break; |
3771 | |
4173 | 3772 case 0x12: { |
3141 | 3773 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3774 /* Someone added you to their buddy list? */ |
3141 | 3775 } break; |
3776 | |
7023 | 3777 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3778 guint i, num; |
3453 | 3779 gchar **text; |
4173 | 3780 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3781 if (text) { |
3782 num = 0; | |
3783 for (i=0; i<strlen(text[0]); i++) | |
3784 num = num*10 + text[0][i]-48; | |
3785 for (i=0; i<num; i++) { | |
4230 | 3786 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3787 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 | 3788 data->gc = gc; |
4790 | 3789 data->name = g_strdup(text[i*2+1]); |
3790 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3791 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3792 gaim_request_action(gc, NULL, message, |
7023 | 3793 _("Do you want to add this buddy " |
3794 "to your buddy list?"), | |
9972 | 3795 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3796 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3797 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3798 g_free(message); |
3799 } | |
3800 g_strfreev(text); | |
3801 } | |
3802 } break; | |
3803 | |
7023 | 3804 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3805 /* This is boring and silly. */ |
3806 } break; | |
3807 | |
3141 | 3808 default: { |
8660 | 3809 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3810 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3811 "(type 0x%02hhx).\n", args->type); |
3141 | 3812 } break; |
3813 } | |
3814 | |
4076 | 3815 g_strfreev(msg1); |
3816 g_strfreev(msg2); | |
3817 | |
3141 | 3818 return 1; |
3819 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3820 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3821 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3822 fu16_t channel; |
3823 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3824 aim_userinfo_t *userinfo; |
2086 | 3825 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3826 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3827 va_start(ap, fr); |
4200 | 3828 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3829 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3830 |
3141 | 3831 switch (channel) { |
3832 case 1: { /* standard message */ | |
3833 struct aim_incomingim_ch1_args *args; | |
3834 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3835 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3836 } break; | |
3837 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3838 case 2: { /* rendezvous */ |
3141 | 3839 struct aim_incomingim_ch2_args *args; |
3840 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3841 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3842 } break; | |
3843 | |
3844 case 4: { /* ICQ */ | |
3845 struct aim_incomingim_ch4_args *args; | |
3846 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3847 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3848 } break; |
3849 | |
3850 default: { | |
8660 | 3851 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3852 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3853 "0x%04hx).", channel); |
3141 | 3854 } break; |
2086 | 3855 } |
3856 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3857 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3858 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3859 return ret; |
2086 | 3860 } |
3861 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3862 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3863 GaimConnection *gc = sess->aux_data; |
3864 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3865 char *buf; |
2086 | 3866 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3867 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3868 aim_userinfo_t *userinfo; |
2086 | 3869 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3870 va_start(ap, fr); |
4200 | 3871 chan = (fu16_t)va_arg(ap, unsigned int); |
3872 userinfo = va_arg(ap, aim_userinfo_t *); | |
3873 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3874 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3875 va_end(ap); |
3876 | |
3877 switch(reason) { | |
5420 | 3878 case 0: /* Invalid (0) */ |
3879 buf = g_strdup_printf( | |
3880 ngettext( | |
4276 | 3881 "You missed %hu message from %s because it was invalid.", |
3882 "You missed %hu messages from %s because they were invalid.", | |
3883 nummissed), | |
4282 | 3884 nummissed, |
3885 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3886 break; |
5420 | 3887 case 1: /* Message too large */ |
3888 buf = g_strdup_printf( | |
3889 ngettext( | |
4276 | 3890 "You missed %hu message from %s because it was too large.", |
3891 "You missed %hu messages from %s because they were too large.", | |
3892 nummissed), | |
4282 | 3893 nummissed, |
3894 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3895 break; |
5420 | 3896 case 2: /* Rate exceeded */ |
3897 buf = g_strdup_printf( | |
3898 ngettext( | |
4276 | 3899 "You missed %hu message from %s because the rate limit has been exceeded.", |
3900 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3901 nummissed), | |
4282 | 3902 nummissed, |
3903 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3904 break; |
5420 | 3905 case 3: /* Evil Sender */ |
3906 buf = g_strdup_printf( | |
3907 ngettext( | |
4276 | 3908 "You missed %hu message from %s because he/she was too evil.", |
3909 "You missed %hu messages from %s because he/she was too evil.", | |
3910 nummissed), | |
4282 | 3911 nummissed, |
3912 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3913 break; |
5420 | 3914 case 4: /* Evil Receiver */ |
3915 buf = g_strdup_printf( | |
3916 ngettext( | |
4276 | 3917 "You missed %hu message from %s because you are too evil.", |
3918 "You missed %hu messages from %s because you are too evil.", | |
3919 nummissed), | |
4282 | 3920 nummissed, |
3921 userinfo->sn); | |
2086 | 3922 break; |
3923 default: | |
5420 | 3924 buf = g_strdup_printf( |
3925 ngettext( | |
4276 | 3926 "You missed %hu message from %s for an unknown reason.", |
3927 "You missed %hu messages from %s for an unknown reason.", | |
3928 nummissed), | |
4282 | 3929 nummissed, |
3930 userinfo->sn); | |
2086 | 3931 break; |
3932 } | |
8733 | 3933 |
9627 | 3934 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3935 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3936 g_free(buf); |
2086 | 3937 |
3938 return 1; | |
3939 } | |
3940 | |
4194 | 3941 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3942 GaimConnection *gc = sess->aux_data; |
7283 | 3943 OscarData *od = gc->proto_data; |
4617 | 3944 |
3945 /* BBB */ | |
3630 | 3946 switch (reason) { |
4151 | 3947 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3948 GaimXfer *xfer; |
8971 | 3949 struct oscar_direct_im *dim; |
3950 | |
8660 | 3951 gaim_debug_info("oscar", |
9070 | 3952 "AAA - Other user declined some sort of direct " |
8971 | 3953 "connect attempt (automaticly?)\n"); |
4617 | 3954 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
|
3955 gaim_xfer_cancel_remote(xfer); |
8971 | 3956 else if ((dim = oscar_direct_im_find(od, who))) { |
3957 /* AAA should use find by cookie or something here */ | |
3958 oscar_direct_im_disconnect(od, dim); | |
3959 } | |
4151 | 3960 } break; |
3961 | |
3962 default: { | |
8660 | 3963 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3964 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3965 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3966 } |
3630 | 3967 |
3968 } | |
3969 | |
3970 return 0; | |
3971 } | |
3972 | |
4194 | 3973 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3974 GaimConnection *gc = sess->aux_data; |
4151 | 3975 |
3976 switch(reason) { | |
3977 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3978 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3979 | |
3980 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3981 |
3982 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3983 statusmsg = oscar_icqstatus(state); |
4151 | 3984 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3985 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3986 g_free(statusmsg); | |
4151 | 3987 g_strfreev(splitmsg); |
9244 | 3988 |
9797 | 3989 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 3990 |
3991 g_free(title); | |
3992 g_free(dialogmsg); | |
4151 | 3993 } break; |
3994 | |
3995 default: { | |
8660 | 3996 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3997 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3998 "Type 0x%04hx\n", who, reason); |
4151 | 3999 } break; |
4000 } /* end of switch */ | |
4001 | |
4002 return 0; | |
4003 } | |
4004 | |
3212 | 4005 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4006 va_list ap; | |
4007 fu16_t chan, reason; | |
4008 char *who; | |
4009 | |
4010 va_start(ap, fr); | |
4200 | 4011 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4012 who = va_arg(ap, char *); |
4200 | 4013 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4014 |
3952 | 4015 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4016 char *cookie = va_arg(ap, char *); |
4151 | 4017 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4018 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4019 fu32_t state = 0; |
4151 | 4020 char *msg = NULL; |
4021 if (reason == 0x0003) { | |
4200 | 4022 state = va_arg(ap, fu32_t); |
4151 | 4023 msg = va_arg(ap, char *); |
4024 } | |
4025 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4026 } | |
3952 | 4027 |
3212 | 4028 va_end(ap); |
4029 | |
4030 return 1; | |
4031 } | |
4032 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4033 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4034 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4035 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4036 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4037 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4038 va_start(ap, fr); |
4199 | 4039 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4040 va_end(ap); |
4041 | |
8660 | 4042 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4043 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4044 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4045 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4046 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4047 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4048 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4049 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4050 |
2086 | 4051 return 1; |
4052 } | |
4053 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4054 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4055 GaimConnection *gc = sess->aux_data; |
4617 | 4056 #if 0 |
7283 | 4057 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4058 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4059 #endif |
4617 | 4060 va_list ap; |
4061 fu16_t reason; | |
4062 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4063 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4064 va_start(ap, fr); |
4617 | 4065 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4066 data = va_arg(ap, char *); |
2086 | 4067 va_end(ap); |
4068 | |
8660 | 4069 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4070 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 4071 |
4072 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4073 #if 0 |
4617 | 4074 /* If this was a file transfer request, data is a cookie */ |
4075 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
|
4076 gaim_xfer_cancel_remote(xfer); |
3630 | 4077 return 1; |
4078 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4079 #endif |
3630 | 4080 |
4617 | 4081 /* Data is assumed to be the destination sn */ |
9826 | 4082 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4083 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4084 g_free(buf); | |
4085 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4086 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4087 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4088 } | |
4089 g_free(buf); | |
4090 | |
2086 | 4091 return 1; |
4092 } | |
4093 | |
3595 | 4094 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4095 GaimConnection *gc = sess->aux_data; |
3595 | 4096 va_list ap; |
4097 fu16_t type1, type2; | |
4098 char *sn; | |
4099 | |
4100 va_start(ap, fr); | |
4199 | 4101 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4102 sn = va_arg(ap, char *); |
4199 | 4103 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4104 va_end(ap); |
4105 | |
4106 switch (type2) { | |
4107 case 0x0000: { /* Text has been cleared */ | |
4108 serv_got_typing_stopped(gc, sn); | |
4109 } break; | |
4110 | |
4111 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4112 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4113 } break; |
4114 | |
4115 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4116 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4117 } break; |
4118 | |
4119 default: { | |
8660 | 4120 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 | 4121 } break; |
4122 } | |
4123 | |
4124 return 1; | |
4125 } | |
4126 | |
7141 | 4127 /* |
4128 * We get this error when there was an error in the locate family. This | |
7259 | 4129 * happens when you request info of someone who is offline. |
7141 | 4130 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4131 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4132 gchar *buf; |
2086 | 4133 va_list ap; |
5420 | 4134 fu16_t reason; |
2086 | 4135 char *destn; |
4136 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4137 va_start(ap, fr); |
4199 | 4138 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4139 destn = va_arg(ap, char *); |
4140 va_end(ap); | |
4141 | |
7781 | 4142 if (destn == NULL) |
7793 | 4143 return 1; |
9627 | 4144 |
9826 | 4145 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4146 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4147 g_free(buf); | |
9627 | 4148 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4149 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4150 } | |
4151 g_free(buf); | |
2086 | 4152 |
4153 return 1; | |
4154 } | |
4155 | |
7011 | 4156 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4157 GaimConnection *gc = sess->aux_data; |
8700 | 4158 GaimAccount *account = gaim_connection_get_account(gc); |
4159 GString *str; | |
9244 | 4160 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4161 va_list ap; |
7011 | 4162 aim_userinfo_t *userinfo; |
2086 | 4163 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4164 va_start(ap, fr); |
7011 | 4165 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4166 va_end(ap); |
4167 | |
8700 | 4168 str = g_string_new(""); |
4169 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4170 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4171 |
4172 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 4173 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 4174 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 4175 |
4176 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 4177 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 4178 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 4179 |
4180 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4181 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4182 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4183 g_free(tmp); |
4184 } | |
4185 | |
8701 | 4186 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4187 |
4188 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4189 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4190 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4191 g_free(tmp); | |
7011 | 4192 if (away_utf8 != NULL) { |
8700 | 4193 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4194 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4195 } |
7011 | 4196 } |
4197 | |
4198 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4199 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4200 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4201 g_free(tmp); | |
7011 | 4202 if (info_utf8 != NULL) { |
8700 | 4203 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4204 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4205 } |
7011 | 4206 } |
4207 | |
8701 | 4208 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4209 g_string_free(str, TRUE); |
9244 | 4210 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4211 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4212 g_free(title); |
8700 | 4213 g_free(tmp); |
4151 | 4214 |
2086 | 4215 return 1; |
4216 } | |
4217 | |
8341 | 4218 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4219 { | |
4220 aim_session_t *sess = data; | |
4221 GaimConnection *gc = sess->aux_data; | |
4222 OscarData *od = (OscarData *)gc->proto_data; | |
4223 | |
4224 aim_locate_dorequest(data); | |
4225 od->getinfotimer = 0; | |
4226 | |
4227 return FALSE; | |
4228 } | |
4229 | |
4230 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4231 { | |
4232 GaimConnection *gc = sess->aux_data; | |
4233 OscarData *od = (OscarData *)gc->proto_data; | |
4234 | |
4235 /* | |
4236 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4237 * us from hitting the rate limit due to request away messages and info | |
4238 * too quickly. | |
4239 */ | |
4240 if (od->getinfotimer == 0) | |
4241 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4242 | |
4243 return 1; | |
4244 } | |
4245 | |
4246 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4247 { | |
2086 | 4248 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4249 fu16_t id; |
2086 | 4250 va_list ap; |
4251 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4252 va_start(ap, fr); |
4199 | 4253 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4254 msg = va_arg(ap, char *); |
4255 va_end(ap); | |
4256 | |
8660 | 4257 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4258 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4259 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4260 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4261 _("Your AIM connection may be lost."), NULL); |
2086 | 4262 |
4263 return 1; | |
4264 } | |
4265 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4266 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4267 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4268 fu16_t type; |
5575 | 4269 GaimConnection *gc = sess->aux_data; |
7283 | 4270 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4271 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4272 va_start(ap, fr); |
4199 | 4273 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4274 |
4275 switch(type) { | |
4276 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4277 fu8_t maxrooms; |
2086 | 4278 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4279 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4280 |
4199 | 4281 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4282 exchangecount = va_arg(ap, int); |
4283 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4284 | |
8660 | 4285 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4286 "chat info: Chat Rights:\n"); |
8660 | 4287 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4288 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4289 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4290 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4291 for (i = 0; i < exchangecount; i++) |
8660 | 4292 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4293 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4294 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4295 while (od->create_rooms) { |
4296 struct create_room *cr = od->create_rooms->data; | |
8660 | 4297 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4298 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4299 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4300 g_free(cr->name); |
4617 | 4301 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4302 g_free(cr); |
2086 | 4303 } |
4304 } | |
4305 break; | |
4306 case 0x0008: { | |
4307 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4308 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4309 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4310 fu32_t createtime; |
2086 | 4311 |
4312 fqcn = va_arg(ap, char *); | |
4200 | 4313 instance = (fu16_t)va_arg(ap, unsigned int); |
4314 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4315 flags = (fu16_t)va_arg(ap, unsigned int); | |
4316 createtime = va_arg(ap, fu32_t); | |
4317 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4318 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4319 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4320 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4321 name = va_arg(ap, char *); | |
4322 ck = va_arg(ap, char *); | |
4194 | 4323 |
8660 | 4324 gaim_debug_misc("oscar", |
5556 | 4325 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4326 fqcn, |
4327 exchange, instance, flags, | |
4328 createtime, | |
4329 maxmsglen, maxoccupancy, createperms, unknown, | |
4330 name, ck); | |
4617 | 4331 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4332 } |
4333 break; | |
4334 default: | |
8660 | 4335 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4336 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4337 break; |
4338 } | |
4194 | 4339 |
4340 va_end(ap); | |
4341 | |
2086 | 4342 return 1; |
4343 } | |
4344 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4345 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4346 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4347 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4348 aim_userinfo_t *info; |
5575 | 4349 GaimConnection *g = sess->aux_data; |
2086 | 4350 |
4351 struct chat_connection *c = NULL; | |
4352 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4353 va_start(ap, fr); |
2086 | 4354 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4355 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4356 va_end(ap); |
4357 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4358 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4359 if (!c) |
4360 return 1; | |
4361 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4362 for (i = 0; i < count; i++) |
9846 | 4363 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4364 |
4365 return 1; | |
4366 } | |
4367 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4368 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4369 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4370 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4371 aim_userinfo_t *info; |
5575 | 4372 GaimConnection *g = sess->aux_data; |
2086 | 4373 |
4374 struct chat_connection *c = NULL; | |
4375 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4376 va_start(ap, fr); |
2086 | 4377 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4378 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4379 va_end(ap); |
4380 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4381 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4382 if (!c) |
4383 return 1; | |
4384 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4385 for (i = 0; i < count; i++) |
8733 | 4386 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4387 |
4388 return 1; | |
4389 } | |
4390 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4391 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
|
4392 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4393 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4394 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4395 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4396 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4397 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4398 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4399 fu32_t creationtime; |
5575 | 4400 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4401 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
|
4402 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4403 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4404 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4405 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4406 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4407 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4408 roomdesc = va_arg(ap, char *); |
4200 | 4409 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4410 creationtime = va_arg(ap, fu32_t); | |
4411 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4412 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4413 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4414 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4415 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4416 |
8660 | 4417 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4418 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4419 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4420 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4421 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4422 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4423 |
2086 | 4424 return 1; |
4425 } | |
4426 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4427 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4428 GaimConnection *gc = sess->aux_data; |
8225 | 4429 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4430 gchar *utf8; | |
2086 | 4431 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4432 aim_userinfo_t *info; |
8225 | 4433 int len; |
2086 | 4434 char *msg; |
8219 | 4435 char *charset; |
2086 | 4436 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4437 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4438 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4439 len = va_arg(ap, int); |
4194 | 4440 msg = va_arg(ap, char *); |
8219 | 4441 charset = va_arg(ap, char *); |
4194 | 4442 va_end(ap); |
2086 | 4443 |
8225 | 4444 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4445 if (utf8 == NULL) |
4446 /* The conversion failed! */ | |
8668 | 4447 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4448 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4449 g_free(utf8); | |
2086 | 4450 |
4451 return 1; | |
4452 } | |
4453 | |
3694 | 4454 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4455 va_list ap; | |
5575 | 4456 GaimConnection *gc = sess->aux_data; |
3694 | 4457 struct aim_emailinfo *emailinfo; |
3725 | 4458 int havenewmail; |
7297 | 4459 char *alertitle, *alerturl; |
3694 | 4460 |
4461 va_start(ap, fr); | |
4462 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4463 havenewmail = va_arg(ap, int); |
7301 | 4464 alertitle = va_arg(ap, char *); |
4465 alerturl = va_arg(ap, char *); | |
3694 | 4466 va_end(ap); |
4467 | |
9661 | 4468 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4469 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4470 emailinfo->domain ? "@" : "", | |
4471 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4472 if (emailinfo->unread && havenewmail) |
4473 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4474 g_free(to); |
3694 | 4475 } |
7297 | 4476 |
7301 | 4477 if (alertitle) |
8660 | 4478 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4479 |
4480 return 1; | |
4481 } | |
4482 | |
4804 | 4483 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4484 GaimConnection *gc = sess->aux_data; |
7283 | 4485 OscarData *od = gc->proto_data; |
4804 | 4486 char *sn; |
4487 | |
4488 sn = od->requesticon->data; | |
8660 | 4489 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4490 "removing %s from hash table\n", sn); |
4804 | 4491 od->requesticon = g_slist_remove(od->requesticon, sn); |
4492 free(sn); | |
4493 | |
4494 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4495 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4496 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4497 |
4498 return 1; | |
4499 } | |
4500 | |
4501 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4502 GaimConnection *gc = sess->aux_data; |
7283 | 4503 OscarData *od = gc->proto_data; |
4804 | 4504 GSList *cur; |
4505 va_list ap; | |
4506 char *sn; | |
4853 | 4507 fu8_t *iconcsum, *icon; |
4508 fu16_t iconcsumlen, iconlen; | |
4804 | 4509 |
4510 va_start(ap, fr); | |
4511 sn = va_arg(ap, char *); | |
4853 | 4512 iconcsum = va_arg(ap, fu8_t *); |
4513 iconcsumlen = va_arg(ap, int); | |
4804 | 4514 icon = va_arg(ap, fu8_t *); |
4515 iconlen = va_arg(ap, int); | |
4516 va_end(ap); | |
4517 | |
4853 | 4518 if (iconlen > 0) { |
4519 char *b16; | |
6695 | 4520 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4521 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4522 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4523 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4524 if (b16) { |
7693 | 4525 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4526 g_free(b16); |
5129 | 4527 } |
4853 | 4528 } |
4804 | 4529 |
4530 cur = od->requesticon; | |
4531 while (cur) { | |
4532 char *cursn = cur->data; | |
4533 if (!aim_sncmp(cursn, sn)) { | |
4534 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4535 free(cursn); | |
4536 cur = od->requesticon; | |
4537 } else | |
4538 cur = cur->next; | |
4539 } | |
4540 | |
4541 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4542 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4543 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4544 |
4545 return 1; | |
4546 } | |
4547 | |
4548 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4549 GaimConnection *gc = data; |
7283 | 4550 OscarData *od = gc->proto_data; |
7011 | 4551 aim_userinfo_t *userinfo; |
4804 | 4552 aim_conn_t *conn; |
4553 | |
4554 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4555 if (!conn) { |
4556 if (!od->iconconnecting) { | |
4557 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4558 od->iconconnecting = TRUE; | |
4559 } | |
4804 | 4560 return FALSE; |
4561 } | |
4562 | |
5842 | 4563 if (od->set_icon) { |
6039 | 4564 struct stat st; |
4565 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4566 if (iconfile == NULL) { | |
8363 | 4567 aim_ssi_delicon(od->sess); |
6039 | 4568 } else if (!stat(iconfile, &st)) { |
4569 char *buf = g_malloc(st.st_size); | |
4570 FILE *file = fopen(iconfile, "rb"); | |
4571 if (file) { | |
9532 | 4572 /* XXX - Use g_file_get_contents()? */ |
6039 | 4573 fread(buf, 1, st.st_size, file); |
4574 fclose(file); | |
8660 | 4575 gaim_debug_info("oscar", |
6039 | 4576 "Uploading icon to icon server\n"); |
6879 | 4577 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4578 } else |
8660 | 4579 gaim_debug_error("oscar", |
6039 | 4580 "Can't open buddy icon file!\n"); |
4581 g_free(buf); | |
4582 } else { | |
8660 | 4583 gaim_debug_error("oscar", |
6039 | 4584 "Can't stat buddy icon file!\n"); |
5842 | 4585 } |
4586 od->set_icon = FALSE; | |
4587 } | |
4588 | |
4589 if (!od->requesticon) { | |
8660 | 4590 gaim_debug_misc("oscar", |
5842 | 4591 "no more icons to request\n"); |
4592 return FALSE; | |
4593 } | |
4594 | |
7045 | 4595 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4596 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4597 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4598 return FALSE; |
4599 } else { | |
4600 char *sn = od->requesticon->data; | |
4601 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4602 free(sn); | |
4603 } | |
4604 | |
4605 return TRUE; | |
4606 } | |
4607 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4608 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4609 * 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
|
4610 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4611 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4612 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4613 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4614 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4615 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4616 va_start(ap, fr); |
4199 | 4617 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4618 sn = va_arg(ap, char *); |
4619 va_end(ap); | |
4620 | |
8660 | 4621 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4622 |
4623 return 1; | |
4624 } | |
4625 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4626 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
|
4627 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4628 "invalid", |
4194 | 4629 "change", |
4630 "warning", | |
4631 "limit", | |
4632 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4633 }; |
2086 | 4634 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4635 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4636 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4637 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4638 va_start(ap, fr); |
4200 | 4639 code = (fu16_t)va_arg(ap, unsigned int); |
4640 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4641 windowsize = va_arg(ap, fu32_t); | |
4642 clear = va_arg(ap, fu32_t); | |
4643 alert = va_arg(ap, fu32_t); | |
4644 limit = va_arg(ap, fu32_t); | |
4645 disconnect = va_arg(ap, fu32_t); | |
4646 currentavg = va_arg(ap, fu32_t); | |
4647 maxavg = va_arg(ap, fu32_t); | |
2086 | 4648 va_end(ap); |
4649 | |
8660 | 4650 gaim_debug_misc("oscar", |
5556 | 4651 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4652 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4653 (code < 5) ? codes[code] : codes[0], |
4654 rateclass, | |
4655 currentavg, maxavg, | |
4656 alert, clear, | |
4657 limit, disconnect, | |
4658 windowsize); | |
4659 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4660 /* XXX fix these values */ |
2086 | 4661 if (code == AIM_RATE_CODE_CHANGE) { |
4662 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4663 aim_conn_setlatency(fr->conn, 0); |
2086 | 4664 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4665 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4666 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4667 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4668 _("The last action you attempted could not be " |
4669 "performed because you are over the rate limit. " | |
4670 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4671 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4672 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4673 aim_conn_setlatency(fr->conn, 0); |
2086 | 4674 } |
4675 | |
4676 return 1; | |
4677 } | |
4678 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4679 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4680 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4681 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4682 aim_userinfo_t *userinfo; |
5575 | 4683 GaimConnection *gc = sess->aux_data; |
2086 | 4684 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4685 va_start(ap, fr); |
4199 | 4686 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4687 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4688 va_end(ap); |
4689 | |
7111 | 4690 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 4691 |
4692 return 1; | |
4693 } | |
4694 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4695 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
|
4696 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4697 aim_userinfo_t *info; |
5575 | 4698 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4699 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4700 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4701 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4702 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4703 |
5628 | 4704 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 4705 |
7872 | 4706 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 4707 gc->login_time_official = info->onlinesince; |
7872 | 4708 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
4709 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4710 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4711 return 1; |
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 |
4649 | 4714 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4715 GaimConnection *gc = sess->aux_data; |
7283 | 4716 OscarData *od = gc->proto_data; |
4649 | 4717 va_list ap; |
4718 fu16_t code; | |
4719 char *msg; | |
4720 | |
4721 va_start(ap, fr); | |
4722 code = (fu16_t)va_arg(ap, int); | |
4723 msg = va_arg(ap, char *); | |
4724 va_end(ap); | |
4725 | |
8660 | 4726 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4727 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4728 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4729 if (code == 0x0001) { |
6113 | 4730 gc->wants_to_die = TRUE; |
5579 | 4731 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4732 } else { |
5579 | 4733 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4734 } |
4666 | 4735 od->killme = TRUE; |
4649 | 4736 } |
4737 | |
4738 return 1; | |
4739 } | |
4740 | |
2675 | 4741 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4742 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4743 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4744 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4745 |
4746 #ifndef NOSSI | |
8660 | 4747 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4748 aim_ssi_reqrights(sess); |
6350 | 4749 aim_ssi_reqdata(sess); |
4230 | 4750 #endif |
4751 | |
7011 | 4752 aim_locate_reqrights(sess); |
7285 | 4753 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4754 aim_im_reqparams(sess); |
7334 | 4755 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4756 |
4757 #ifdef NOSSI | |
8660 | 4758 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4759 aim_bos_reqrights(sess, fr->conn); |
4230 | 4760 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4761 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4762 #endif | |
2086 | 4763 |
7283 | 4764 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4765 | |
2086 | 4766 return 1; |
4767 } | |
4768 | |
2675 | 4769 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4770 GaimConnection *gc = sess->aux_data; |
7283 | 4771 OscarData *od = gc->proto_data; |
2647 | 4772 |
6905 | 4773 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4774 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4775 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4776 | |
2672 | 4777 aim_clientready(sess, fr->conn); |
8660 | 4778 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4779 |
2647 | 4780 if (od->chpass) { |
8660 | 4781 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4782 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4783 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4784 od->oldp = NULL; |
2647 | 4785 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4786 od->newp = NULL; |
2647 | 4787 od->chpass = FALSE; |
4788 } | |
2979 | 4789 if (od->setnick) { |
8660 | 4790 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4791 aim_admin_setnick(sess, fr->conn, od->newsn); |
4792 g_free(od->newsn); | |
4793 od->newsn = NULL; | |
4794 od->setnick = FALSE; | |
4795 } | |
2647 | 4796 if (od->conf) { |
8660 | 4797 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4798 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4799 od->conf = FALSE; |
4800 } | |
4801 if (od->reqemail) { | |
8660 | 4802 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4803 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4804 od->reqemail = FALSE; |
4805 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4806 if (od->setemail) { |
8660 | 4807 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4808 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4809 g_free(od->email); |
5497 | 4810 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4811 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4812 } |
2647 | 4813 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4814 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4815 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4816 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4817 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
|
4818 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4819 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4820 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4821 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4822 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4823 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4824 |
4194 | 4825 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4826 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4827 "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
|
4828 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4829 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4830 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4831 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4832 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4833 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4834 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4835 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4836 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4837 |
4617 | 4838 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4839 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4840 return 1; |
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 |
2993 | 4843 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4844 { | |
5575 | 4845 GaimConnection *gc = sess->aux_data; |
7283 | 4846 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4847 va_list ap; |
4848 fu16_t maxsiglen; | |
2993 | 4849 |
4850 va_start(ap, fr); | |
4199 | 4851 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4852 va_end(ap); |
4853 | |
8660 | 4854 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4855 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4856 |
4617 | 4857 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4858 | |
4859 if (od->icq) | |
7334 | 4860 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4861 else |
7334 | 4862 aim_locate_setcaps(od->sess, caps_aim); |
4863 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4864 |
4865 return 1; | |
4866 } | |
4867 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4868 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
|
4869 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4870 fu16_t maxbuddies, maxwatchers; |
5575 | 4871 GaimConnection *gc = sess->aux_data; |
7283 | 4872 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4873 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4874 va_start(ap, fr); |
4199 | 4875 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4876 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4877 va_end(ap); |
4878 | |
8660 | 4879 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4880 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4881 |
4617 | 4882 od->rights.maxbuddies = (guint)maxbuddies; |
4883 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4884 |
2086 | 4885 return 1; |
4886 } | |
4887 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4888 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4889 GaimConnection *gc = sess->aux_data; |
7283 | 4890 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4891 va_list ap; |
4892 fu16_t maxpermits, maxdenies; | |
2086 | 4893 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4894 va_start(ap, fr); |
4199 | 4895 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4896 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4897 va_end(ap); |
4898 | |
8660 | 4899 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4900 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4901 |
4617 | 4902 od->rights.maxpermits = (guint)maxpermits; |
4903 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4904 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4905 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4906 serv_finish_login(gc); |
4907 | |
8660 | 4908 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4909 |
2672 | 4910 aim_clientready(sess, fr->conn); |
5948 | 4911 aim_srv_setavailmsg(sess, NULL); |
7474 | 4912 aim_srv_setidle(sess, 0); |
4617 | 4913 |
4664 | 4914 if (od->icq) { |
4915 aim_icq_reqofflinemsgs(sess); | |
4916 aim_icq_hideip(sess); | |
4917 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4918 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4919 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4920 if (sess->authinfo->email) |
4921 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4922 |
4923 return 1; | |
4924 } | |
4925 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4926 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
|
4927 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4928 struct aim_icq_offlinemsg *msg; |
4075 | 4929 struct aim_incomingim_ch4_args args; |
4930 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4931 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4932 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4933 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4934 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4935 |
8660 | 4936 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4937 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4938 args.uin = msg->sender; |
4939 args.type = msg->type; | |
4173 | 4940 args.flags = msg->flags; |
4076 | 4941 args.msglen = msg->msglen; |
4075 | 4942 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4943 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4944 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4945 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4946 return 1; |
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 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4949 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
|
4950 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4951 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4952 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4953 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4954 |
7388 | 4955 #if 0 |
4956 /* | |
7465 | 4957 * Update, 2003-11-09: |
4958 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4959 * | |
7388 | 4960 * It may not be my place to do this, but... |
4961 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4962 * stupid, and should not exist for % switches (%x in our case) that request | |
4963 * a year in the preferred representation for the current locale. For that | |
4964 * reason I've chosen to not use this workaround (n., see kluge). | |
4965 * | |
4966 * I have a date. I want to show it to the user in the "preferred" way. | |
4967 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4968 * what the locale wanted. | |
4969 * | |
4970 * If I have a necessity for a full representation of the year in the current | |
4971 * locale, then I'll use a switch that returns a full representation of the | |
4972 * year. | |
4973 * | |
4974 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4975 * (because you're anal, or whatever), then change the f***ing locale. | |
4976 * | |
4977 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4978 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4979 * |
4980 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4981 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4982 */ |
4983 | |
4984 /* | |
4985 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4986 * "last 2 digits" warning. |
4987 */ | |
4988 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4989 const struct tm *tm) | |
4990 { | |
4991 return strftime(s, max, fmt, tm); | |
4992 } | |
7388 | 4993 #endif |
7386 | 4994 |
4624 | 4995 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
|
4996 { |
5575 | 4997 GaimConnection *gc = sess->aux_data; |
8670 | 4998 OscarData *od = (OscarData *)gc->proto_data; |
4999 GaimBuddy *buddy; | |
8853 | 5000 struct buddyinfo *bi = NULL; |
4624 | 5001 gchar who[16]; |
8670 | 5002 GString *str; |
5003 gchar *primary, *utf8; | |
9634 | 5004 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5005 va_list ap; |
4151 | 5006 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5007 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5008 va_start(ap, fr); |
4151 | 5009 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5010 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5011 |
4664 | 5012 if (!info->uin) |
5013 return 0; | |
5014 | |
8670 | 5015 str = g_string_sized_new(100); |
5556 | 5016 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5017 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5018 if (buddy != NULL) | |
5019 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5020 | |
5021 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5022 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5023 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5024 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5025 (bi->ipaddr & 0xff000000) >> 24, | |
5026 (bi->ipaddr & 0x00ff0000) >> 16, | |
5027 (bi->ipaddr & 0x0000ff00) >> 8, | |
5028 (bi->ipaddr & 0x000000ff)); | |
8701 | 5029 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5030 g_free(tstr); |
5031 } | |
8701 | 5032 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5033 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5034 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5035 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5036 g_free(utf8); | |
4625 | 5037 } |
5038 if (info->numaddresses && info->email2) { | |
5039 int i; | |
5040 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5041 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5042 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5043 g_free(utf8); | |
4643 | 5044 } |
4625 | 5045 } |
4624 | 5046 } |
8701 | 5047 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
8902 | 5048 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
5049 info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5050 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5051 char date[30]; |
5052 struct tm tm; | |
5053 tm.tm_mday = (int)info->birthday; | |
5054 tm.tm_mon = (int)info->birthmonth-1; | |
5055 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5056 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5057 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5058 } |
4624 | 5059 if (info->age) { |
5060 char age[5]; | |
5061 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5062 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5063 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5064 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5065 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5066 g_free(utf8); | |
4819 | 5067 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5068 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5069 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5070 g_free(utf8); | |
5071 } | |
5072 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5073 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5074 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5075 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5076 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5077 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5078 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5079 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5080 } |
4641 | 5081 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5082 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5083 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5084 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5085 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5086 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5087 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5088 } |
4641 | 5089 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5090 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5091 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5092 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5093 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5094 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5095 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5096 g_free(utf8); | |
4624 | 5097 } |
8670 | 5098 g_string_append_printf(str, "\n<hr>\n"); |
5099 } | |
5100 | |
9634 | 5101 if (buddy != NULL) |
5102 alias = gaim_buddy_get_alias(buddy); | |
5103 else | |
5104 alias = who; | |
5105 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5106 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5107 g_free(primary); |
8670 | 5108 g_string_free(str, TRUE); |
4151 | 5109 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5110 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5111 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5112 |
4759 | 5113 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5114 { | |
5575 | 5115 GaimConnection *gc = sess->aux_data; |
4820 | 5116 gchar who[16], *utf8; |
6695 | 5117 GaimBuddy *b; |
4759 | 5118 va_list ap; |
5119 struct aim_icq_info *info; | |
5120 | |
5121 va_start(ap, fr); | |
5122 info = va_arg(ap, struct aim_icq_info *); | |
5123 va_end(ap); | |
5124 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5125 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5126 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5127 serv_got_alias(gc, who, utf8); |
4759 | 5128 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5129 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5130 } |
4820 | 5131 g_free(utf8); |
4759 | 5132 } |
5133 | |
5134 return 1; | |
5135 } | |
5136 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5137 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
|
5138 { |
7032 | 5139 GaimConnection *gc = sess->aux_data; |
5140 gchar *text; | |
5141 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5142 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5143 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5144 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5145 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5146 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5147 url = va_arg(ap, char *); |
4199 | 5148 wid = (fu16_t) va_arg(ap, int); |
5149 hei = (fu16_t) va_arg(ap, int); | |
5150 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5151 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5152 |
7032 | 5153 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5154 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5155 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5156 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5157 return 1; |
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 |
7032 | 5160 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5161 { | |
6873 | 5162 GaimConnection *gc = sess->aux_data; |
5163 gchar *secondary; | |
5164 GString *text; | |
5165 int i, num; | |
2086 | 5166 va_list ap; |
6873 | 5167 char *email, *SNs; |
2086 | 5168 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5169 va_start(ap, fr); |
6873 | 5170 email = va_arg(ap, char *); |
2086 | 5171 num = va_arg(ap, int); |
5172 SNs = va_arg(ap, char *); | |
5173 va_end(ap); | |
5174 | |
8152 | 5175 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5176 text = g_string_new(""); |
2086 | 5177 for (i = 0; i < num; i++) |
6873 | 5178 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5179 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5180 | |
5181 g_free(secondary); | |
5182 g_string_free(text, TRUE); | |
2086 | 5183 |
5184 return 1; | |
5185 } | |
5186 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5187 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5188 va_list ap; |
6873 | 5189 char *email; |
5420 | 5190 char *buf; |
2086 | 5191 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5192 va_start(ap, fr); |
6873 | 5193 email = va_arg(ap, char *); |
2086 | 5194 va_end(ap); |
5195 | |
6873 | 5196 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
|
5197 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5198 g_free(buf); |
2086 | 5199 |
5200 return 1; | |
5201 } | |
5202 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5203 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5204 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5205 fu16_t status; |
2086 | 5206 va_list ap; |
5207 char msg[256]; | |
5208 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5209 va_start(ap, fr); |
4199 | 5210 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5211 va_end(ap); |
5212 | |
8660 | 5213 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5214 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5215 status ? "unknown" : "email sent"); |
5216 if (!status) { | |
5302 | 5217 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5218 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5219 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5220 } |
5221 | |
5222 return 1; | |
5223 } | |
5224 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5225 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5226 GaimConnection *gc = sess->aux_data; |
2086 | 5227 va_list ap; |
3912 | 5228 fu16_t perms, err; |
5229 char *url, *sn, *email; | |
5230 int change; | |
2086 | 5231 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5232 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5233 change = va_arg(ap, int); |
4199 | 5234 perms = (fu16_t) va_arg(ap, unsigned int); |
5235 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5236 url = va_arg(ap, char *); |
5237 sn = va_arg(ap, char *); | |
5238 email = va_arg(ap, char *); | |
2086 | 5239 va_end(ap); |
5240 | |
8660 | 5241 gaim_debug_misc("oscar", |
9626 | 5242 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5243 change ? "change" : "request", perms, err, | |
5244 (url != NULL) ? url : "(null)", | |
5245 (sn != NULL) ? sn : "(null)", | |
5246 (email != NULL) ? email : "(null)"); | |
5247 | |
5248 if ((err > 0) && (url != NULL)) { | |
3912 | 5249 char *dialog_msg; |
5250 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5251 switch (err) { | |
5252 case 0x0001: { | |
5253 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5254 } break; | |
5255 case 0x0006: { | |
5256 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5257 } break; | |
5258 case 0x000b: { | |
5259 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5260 } break; | |
5261 case 0x001d: { | |
5262 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); | |
5263 } break; | |
5264 case 0x0021: { | |
5265 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); | |
5266 } break; | |
5267 case 0x0023: { | |
5268 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5269 } break; | |
5270 default: { | |
5271 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5272 } break; | |
5273 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5274 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5275 g_free(dialog_top); |
5276 g_free(dialog_msg); | |
5277 return 1; | |
5278 } | |
5279 | |
9626 | 5280 if (sn != NULL) { |
4585 | 5281 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
|
5282 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5283 g_free(dialog_msg); |
5284 } | |
5285 | |
9626 | 5286 if (email != NULL) { |
5575 | 5287 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5288 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5289 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5290 g_free(dialog_msg); |
2086 | 5291 } |
5292 | |
5293 return 1; | |
5294 } | |
5295 | |
5575 | 5296 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5297 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5298 aim_flap_nop(od->sess, od->conn); |
2086 | 5299 } |
5300 | |
6059 | 5301 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5302 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5303 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5304 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5305 if (typing == GAIM_TYPING) |
4870 | 5306 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5307 else if (typing == GAIM_TYPED) |
4870 | 5308 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5309 else | |
5310 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5311 else { |
5300 | 5312 /* Don't send if this turkey is in our deny list */ |
5313 GSList *list; | |
5314 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5315 if (!list) { | |
7261 | 5316 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5317 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5318 if (typing == GAIM_TYPING) |
5300 | 5319 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5320 else if (typing == GAIM_TYPED) |
5300 | 5321 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5322 else | |
5323 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5324 } | |
3595 | 5325 } |
5326 } | |
2993 | 5327 return 0; |
5328 } | |
9030 | 5329 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5330 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
|
5331 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5332 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5333 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5334 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
|
5335 int ret = 0; |
5575 | 5336 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5337 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5338 |
4838 | 5339 if (dim && dim->connected) { |
5340 /* If we're directly connected, send a direct IM */ | |
6982 | 5341 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5342 } else { |
4738 | 5343 struct buddyinfo *bi; |
3008 | 5344 struct aim_sendimext_args args; |
5345 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5346 gsize len; |
8962 | 5347 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5348 | |
5349 if (strstr(message, "<IMG ")) | |
5350 gaim_conversation_write(conv, "", | |
5351 _("Your IM Image was not sent. " | |
5352 "You must be Direct Connected to send IM Images."), | |
5353 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5354 |
7261 | 5355 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5356 if (!bi) { |
5357 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5358 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5359 } |
5360 | |
3008 | 5361 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5362 if (od->icq) { |
5363 args.features = features_icq; | |
5364 args.featureslen = sizeof(features_icq); | |
3008 | 5365 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5366 } else { |
5367 args.features = features_aim; | |
5368 args.featureslen = sizeof(features_aim); | |
4972 | 5369 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5370 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5371 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5372 } |
4269 | 5373 |
4738 | 5374 if (bi->ico_need) { |
8660 | 5375 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5376 "Sending buddy icon request with message\n"); |
3008 | 5377 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5378 bi->ico_need = FALSE; |
3008 | 5379 } |
4269 | 5380 |
5575 | 5381 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5382 FILE *file = fopen(iconfile, "rb"); |
3008 | 5383 if (file) { |
5384 char *buf = g_malloc(st.st_size); | |
9532 | 5385 /* XXX - Use g_file_get_contents()? */ |
3008 | 5386 fread(buf, 1, st.st_size, file); |
6039 | 5387 fclose(file); |
4269 | 5388 |
3008 | 5389 args.iconlen = st.st_size; |
4617 | 5390 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5391 args.iconstamp = st.st_mtime; |
5392 | |
7406 | 5393 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5394 bi->ico_informed = FALSE; |
7406 | 5395 bi->ico_sent = FALSE; |
5396 } | |
4738 | 5397 |
5398 if (!bi->ico_informed) { | |
8660 | 5399 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5400 "Claiming to have a buddy icon\n"); |
4738 | 5401 args.flags |= AIM_IMFLAGS_HASICON; |
5402 bi->ico_me_len = args.iconlen; | |
5403 bi->ico_me_csum = args.iconsum; | |
5404 bi->ico_me_time = args.iconstamp; | |
5405 bi->ico_informed = TRUE; | |
5406 } | |
5407 | |
3008 | 5408 g_free(buf); |
2086 | 5409 } |
5410 } | |
4269 | 5411 |
3008 | 5412 args.destsn = name; |
4269 | 5413 |
8985 | 5414 /* |
5415 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5416 * strip all HTML | |
5417 */ | |
9975 | 5418 if (aim_sn_is_icq(name) ) { |
8995 | 5419 /* being sent to an ICQ user */ |
9975 | 5420 if (!aim_sn_is_icq(gaim_account_get_username(gc->account))) { |
8995 | 5421 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5422 tmpmsg = gaim_str_add_cr(message); | |
5423 } else { | |
5424 /* from an ICQ user - do nothing */ | |
5425 tmpmsg = g_strdup(message); | |
5426 } | |
5427 } else { | |
5428 /* being sent to an AIM user */ | |
9975 | 5429 if (aim_sn_is_icq(gaim_account_get_username(gc->account))) { |
8995 | 5430 /* from an ICQ user */ |
5431 tmpmsg2 = gaim_strdup_withhtml(message); | |
5432 tmpmsg = gaim_escape_html(tmpmsg2); | |
5433 g_free(tmpmsg2); | |
5434 } else | |
5435 tmpmsg = gaim_strdup_withhtml(message); | |
5436 } | |
6310 | 5437 len = strlen(tmpmsg); |
5438 | |
9830 | 5439 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5440 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5441 args.charset, args.charsubset, args.msglen); | |
4617 | 5442 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5443 g_free((char *)args.msg); |
2086 | 5444 } |
4838 | 5445 |
6310 | 5446 g_free(tmpmsg); |
5447 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5448 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5449 return 1; |
6310 | 5450 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5451 return ret; |
2086 | 5452 } |
5453 | |
7011 | 5454 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5455 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5456 |
9975 | 5457 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5458 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5459 else |
7235 | 5460 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5461 } |
5462 | |
8950 | 5463 #if 0 |
7011 | 5464 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5465 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5466 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5467 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5468 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5469 maiden, NULL, NULL, city, state, NULL, 0, web); |
5470 } | |
8950 | 5471 #endif |
2086 | 5472 |
5575 | 5473 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5474 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5475 aim_srv_setidle(od->sess, time); |
2086 | 5476 } |
5477 | |
5954 | 5478 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5479 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5480 int charset = 0; |
6019 | 5481 char *text_html = NULL; |
5129 | 5482 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5483 gsize msglen = 0; |
2993 | 5484 |
4617 | 5485 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5486 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5487 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5488 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5489 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5490 "again when you are fully connected.")); |
4617 | 5491 |
7334 | 5492 if (!text) { |
5493 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5494 return; | |
5495 } | |
6019 | 5496 |
7334 | 5497 text_html = gaim_strdup_withhtml(text); |
9807 | 5498 charset = oscar_charset_check(text_html); |
9826 | 5499 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5500 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5501 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5502 g_free(msg); | |
9826 | 5503 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5504 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5505 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5506 g_free(msg); | |
5507 } else { | |
5508 msglen = strlen(text_html); | |
5509 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5510 } | |
5511 | |
5512 if (msglen > od->rights.maxsiglen) { | |
5513 gchar *errstr; | |
5514 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5515 "has been exceeded. Gaim has truncated it for you.", | |
5516 "The maximum profile length of %d bytes " | |
5517 "has been exceeded. Gaim has truncated it for you.", | |
5518 od->rights.maxsiglen), od->rights.maxsiglen); | |
5519 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5520 g_free(errstr); | |
5521 } | |
5522 | |
5523 g_free(text_html); | |
2993 | 5524 |
5525 return; | |
2086 | 5526 } |
5527 | |
9973 | 5528 static void oscar_set_status_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 5529 { |
9807 | 5530 int charset = 0; |
6019 | 5531 gchar *text_html = NULL; |
5129 | 5532 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5533 gsize msglen = 0; |
2993 | 5534 |
8257 | 5535 if (!strcmp(state, _("Visible"))) { |
5536 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5537 return; | |
5538 } else if (!strcmp(state, _("Invisible"))) { | |
5539 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5540 return; | |
5541 } /* else... */ | |
5542 | |
8476 | 5543 if (!strcmp(state, _("Back"))) { |
5544 /* If this is our only online account then globally set Gaim not-away */ | |
5545 GList *gcs = gaim_connections_get_all(); | |
5546 if (gcs->next == NULL) | |
9730 | 5547 ; /* XXX do_im_back(NULL, NULL); */ |
8476 | 5548 } |
5549 | |
8257 | 5550 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5551 | |
2993 | 5552 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5553 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5554 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5555 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5556 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5557 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5558 "fully connected.")); |
5129 | 5559 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5560 if (gc->away) { |
2993 | 5561 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5562 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5563 } |
2993 | 5564 |
5129 | 5565 if (!text) { |
7334 | 5566 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5567 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5568 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5569 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5570 text_html = gaim_strdup_withhtml(text); |
9807 | 5571 charset = oscar_charset_check(text_html); |
9826 | 5572 if (charset == AIM_CHARSET_UNICODE) { |
6019 | 5573 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5574 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5575 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5576 g_free(msg); |
5577 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
9826 | 5578 } else if (charset == AIM_CHARSET_CUSTOM) { |
6019 | 5579 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5580 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5581 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5582 g_free(msg); |
6019 | 5583 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5584 } else { |
6019 | 5585 msglen = strlen(text_html); |
7011 | 5586 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5587 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 5588 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 5589 } |
5590 | |
5591 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5592 gchar *errstr; |
5593 | |
6308 | 5594 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5595 "has been exceeded. Gaim has truncated it for you.", | |
5596 "The maximum away message length of %d bytes " | |
5597 "has been exceeded. Gaim has truncated it for you.", | |
5598 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5599 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5600 g_free(errstr); |
5601 } | |
6019 | 5602 |
5603 g_free(text_html); | |
8257 | 5604 |
2993 | 5605 return; |
5606 } | |
5607 | |
9973 | 5608 static void oscar_set_status_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 5609 { |
5575 | 5610 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5611 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5612 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5613 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5614 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5615 |
8265 | 5616 if (strcmp(state, _("Invisible"))) |
5575 | 5617 account->perm_deny = 4; |
8265 | 5618 else |
5575 | 5619 account->perm_deny = 3; |
8265 | 5620 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5621 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5622 |
5623 if (!strcmp(state, _("Online"))) | |
4901 | 5624 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 5625 else if (!strcmp(state, _("Away"))) { |
4901 | 5626 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5627 gc->away = g_strdup(""); |
4342 | 5628 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 5629 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
|
5630 gc->away = g_strdup(""); |
4342 | 5631 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 5632 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
|
5633 gc->away = g_strdup(""); |
4342 | 5634 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 5635 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
|
5636 gc->away = g_strdup(""); |
4342 | 5637 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 5638 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5639 gc->away = g_strdup(""); |
4342 | 5640 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 5641 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5642 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5643 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 5644 if (message) { |
4901 | 5645 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
|
5646 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5647 } else { |
4901 | 5648 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5649 } |
2086 | 5650 } |
2993 | 5651 |
5652 return; | |
5653 } | |
5654 | |
9973 | 5655 static void oscar_set_status(GaimConnection *gc, const char *state, const char *message) |
2993 | 5656 { |
7283 | 5657 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 5658 |
5659 if (od->icq) | |
9973 | 5660 oscar_set_status_icq(gc, od, state, message); |
2993 | 5661 else |
9973 | 5662 oscar_set_status_aim(gc, od, state, message); |
2993 | 5663 |
5664 return; | |
2086 | 5665 } |
5666 | |
9753 | 5667 static void oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { |
7283 | 5668 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5669 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5670 } |
5671 | |
9285 | 5672 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5673 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5674 |
5675 if (!aim_snvalid(buddy->name)) { | |
8092 | 5676 gchar *buf; |
9285 | 5677 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 | 5678 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5679 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5680 g_free(buf); |
8150 | 5681 |
5682 /* Remove from local list */ | |
9285 | 5683 gaim_blist_remove_buddy(buddy); |
8150 | 5684 |
8092 | 5685 return; |
5686 } | |
5687 | |
4230 | 5688 #ifdef NOSSI |
9285 | 5689 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5690 #else |
9285 | 5691 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5692 if (buddy && group) { | |
8660 | 5693 gaim_debug_info("oscar", |
9285 | 5694 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5695 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5696 } |
5697 } | |
5698 #endif | |
8150 | 5699 |
4759 | 5700 if (od->icq) |
9285 | 5701 aim_icq_getalias(od->sess, buddy->name); |
5702 } | |
5703 | |
5704 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5705 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5706 #ifdef NOSSI |
5707 char buf[MSG_LEN]; | |
5708 int n=0; | |
9285 | 5709 |
4230 | 5710 while (buddies) { |
9381 | 5711 GaimBuddy *buddy = buddies->data; |
4230 | 5712 if (n > MSG_LEN - 18) { |
7285 | 5713 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5714 n = 0; |
3092 | 5715 } |
9381 | 5716 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5717 buddies = buddies->next; |
5718 } | |
7285 | 5719 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5720 #else |
9285 | 5721 |
4230 | 5722 if (od->sess->ssi.received_data) { |
9285 | 5723 GList *curb = buddies; |
5724 GList *curg = groups; | |
5725 while ((curb != NULL) && (curg != NULL)) { | |
5726 GaimBuddy *buddy = curb->data; | |
5727 GaimGroup *group = curg->data; | |
5728 oscar_add_buddy(gc, buddy, group); | |
5729 curb = curb->next; | |
5730 curg = curg->next; | |
4230 | 5731 } |
5732 } | |
5733 #endif | |
5734 } | |
5735 | |
9285 | 5736 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5737 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5738 |
4230 | 5739 #ifdef NOSSI |
9285 | 5740 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5741 #else |
5742 if (od->sess->ssi.received_data) { | |
8660 | 5743 gaim_debug_info("oscar", |
9285 | 5744 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5745 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5746 } |
5747 #endif | |
5748 } | |
5749 | |
9285 | 5750 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5751 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5752 |
4230 | 5753 #ifdef NOSSI |
9285 | 5754 for (cur = buddies; cur != NULL; cur = cur->next) { |
5755 GaimBuddy *buddy = cur->data; | |
5756 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5757 } | |
4230 | 5758 #else |
5759 if (od->sess->ssi.received_data) { | |
9285 | 5760 GList *curb = buddies; |
5761 GList *curg = groups; | |
5762 while ((curb != NULL) && (curg != NULL)) { | |
5763 GaimBuddy *buddy = curb->data; | |
5764 GaimGroup *group = curg->data; | |
5765 oscar_remove_buddy(gc, buddy, group); | |
5766 curb = curb->next; | |
5767 curg = curg->next; | |
3092 | 5768 } |
4230 | 5769 } |
5770 #endif | |
5771 } | |
5772 | |
5773 #ifndef NOSSI | |
5575 | 5774 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5775 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5776 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5777 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5778 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5779 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5780 } |
5781 } | |
5782 | |
5575 | 5783 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5784 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5785 if (od->sess->ssi.received_data) { |
5786 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5787 if (gname) { | |
8660 | 5788 gaim_debug_info("oscar", |
9586 | 5789 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5790 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5791 } |
5792 } | |
5793 } | |
5794 | |
9285 | 5795 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5796 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5797 |
5798 if (od->sess->ssi.received_data) { | |
9285 | 5799 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5800 GList *cur, *groups = NULL; | |
5801 | |
5802 /* Make a list of what the groups each buddy is in */ | |
5803 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5804 GaimBlistNode *node = cur->data; | |
5805 groups = g_list_append(groups, node->parent); | |
5806 } | |
5807 | |
5808 oscar_remove_buddies(gc, moved_buddies, groups); | |
5809 oscar_add_buddies(gc, moved_buddies, groups); | |
5810 g_list_free(groups); | |
8660 | 5811 gaim_debug_info("oscar", |
9285 | 5812 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5813 } else { |
9285 | 5814 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5815 gaim_debug_info("oscar", |
9285 | 5816 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5817 } |
5818 } | |
5819 } | |
5820 | |
5968 | 5821 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5822 aim_session_t *sess = data; | |
6350 | 5823 aim_ssi_reqdata(sess); |
5968 | 5824 return FALSE; |
5825 } | |
5826 | |
4642 | 5827 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5828 GaimConnection *gc = sess->aux_data; |
7283 | 5829 OscarData *od = gc->proto_data; |
4642 | 5830 va_list ap; |
5831 fu16_t reason; | |
5832 | |
5833 va_start(ap, fr); | |
5834 reason = (fu16_t)va_arg(ap, unsigned int); | |
5835 va_end(ap); | |
5836 | |
8660 | 5837 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5838 |
5839 if (reason == 0x0005) { | |
5892 | 5840 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5841 _("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
|
5842 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5843 } |
5844 | |
5845 /* Activate SSI */ | |
5846 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5847 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5848 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5849 aim_ssi_enable(od->sess); |
5850 | |
5851 return 1; | |
5852 } | |
5853 | |
2991 | 5854 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5855 GaimConnection *gc = sess->aux_data; |
7283 | 5856 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5857 int numtypes, i; |
5858 fu16_t *maxitems; | |
2991 | 5859 va_list ap; |
5860 | |
5861 va_start(ap, fr); | |
4230 | 5862 numtypes = va_arg(ap, int); |
5863 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5864 va_end(ap); |
5865 | |
8660 | 5866 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5867 |
4230 | 5868 for (i=0; i<numtypes; i++) |
8660 | 5869 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5870 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5871 |
8660 | 5872 gaim_debug_misc(NULL, "\n"); |
4230 | 5873 |
5874 if (numtypes >= 0) | |
5875 od->rights.maxbuddies = maxitems[0]; | |
5876 if (numtypes >= 1) | |
5877 od->rights.maxgroups = maxitems[1]; | |
5878 if (numtypes >= 2) | |
5879 od->rights.maxpermits = maxitems[2]; | |
5880 if (numtypes >= 3) | |
5881 od->rights.maxdenies = maxitems[3]; | |
2991 | 5882 |
5883 return 1; | |
5884 } | |
5885 | |
5886 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5887 GaimConnection *gc = sess->aux_data; |
5888 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5889 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5890 GaimGroup *g; |
5891 GaimBuddy *b; | |
2995 | 5892 struct aim_ssi_item *curitem; |
2991 | 5893 int tmp; |
4230 | 5894 va_list ap; |
8219 | 5895 fu16_t fmtver, numitems; |
5896 struct aim_ssi_item *items; | |
5897 fu32_t timestamp; | |
4230 | 5898 |
5899 va_start(ap, fr); | |
5900 fmtver = (fu16_t)va_arg(ap, int); | |
5901 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5902 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5903 timestamp = va_arg(ap, fu32_t); |
8219 | 5904 va_end(ap); |
2991 | 5905 |
8660 | 5906 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5907 "ssi: syncing local list and server list\n"); |
2991 | 5908 |
8219 | 5909 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5910 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 | 5911 return 1; |
5912 } | |
5913 | |
2991 | 5914 /* Clean the buddy list */ |
4889 | 5915 aim_ssi_cleanlist(sess); |
2991 | 5916 |
8150 | 5917 { /* If not in server list then prune from local list */ |
5918 GaimBlistNode *gnode, *cnode, *bnode; | |
5919 GaimBuddyList *blist; | |
9539 | 5920 GSList *cur, *next; |
8150 | 5921 |
5922 /* Buddies */ | |
5923 cur = NULL; | |
5924 if ((blist = gaim_get_blist()) != NULL) { | |
5925 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5926 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5927 continue; | |
5928 g = (GaimGroup *)gnode; | |
5929 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5930 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5931 continue; | |
5932 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5933 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5934 continue; | |
5935 b = (GaimBuddy *)bnode; | |
5936 if (b->account == gc->account) { | |
5937 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5938 /* If the buddy is an ICQ user then load his nickname */ | |
5939 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5940 char *alias; |
8150 | 5941 if (servernick) |
5942 serv_got_alias(gc, b->name, servernick); | |
5943 | |
5944 /* Store local alias on server */ | |
8214 | 5945 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5946 if (!alias && b->alias && strlen(b->alias)) |
5947 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5948 free(alias); | |
5949 } else { | |
8660 | 5950 gaim_debug_info("oscar", |
8150 | 5951 "ssi: removing buddy %s from local list\n", b->name); |
5952 /* We can't actually remove now because it will screw up our looping */ | |
5953 cur = g_slist_prepend(cur, b); | |
5954 } | |
5955 } | |
5956 } | |
5957 } | |
5958 } | |
5959 } | |
8175 | 5960 |
8150 | 5961 while (cur != NULL) { |
5962 b = cur->data; | |
5963 cur = g_slist_remove(cur, b); | |
5964 gaim_blist_remove_buddy(b); | |
5965 } | |
5966 | |
5967 /* Permit list */ | |
5968 if (gc->account->permit) { | |
9539 | 5969 next = gc->account->permit; |
5970 while (next != NULL) { | |
5971 cur = next; | |
5972 next = next->next; | |
8150 | 5973 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5974 gaim_debug_info("oscar", |
8150 | 5975 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5976 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5977 } | |
9539 | 5978 } |
8150 | 5979 } |
5980 | |
5981 /* Deny list */ | |
5982 if (gc->account->deny) { | |
9539 | 5983 next = gc->account->deny; |
5984 while (next != NULL) { | |
5985 cur = next; | |
5986 next = next->next; | |
8150 | 5987 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 5988 gaim_debug_info("oscar", |
8150 | 5989 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5990 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5991 } | |
9539 | 5992 } |
8150 | 5993 } |
5994 /* Presence settings (idle time visibility) */ | |
5995 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5996 if (!(tmp & 0x400)) | |
5997 aim_ssi_setpresence(sess, tmp | 0x400); | |
5998 } /* end pruning buddies from local list */ | |
5999 | |
2991 | 6000 /* Add from server list to local list */ |
4230 | 6001 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6002 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6003 switch (curitem->type) { |
4230 | 6004 case 0x0000: { /* Buddy */ |
4251 | 6005 if (curitem->name) { |
4292 | 6006 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6007 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6008 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6009 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6010 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6011 /* Should gname be freed here? -- elb */ |
4754 | 6012 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6013 free(alias); |
8150 | 6014 if (b) { |
4292 | 6015 /* Get server stored alias */ |
4705 | 6016 if (alias_utf8) { |
8150 | 6017 g_free(b->alias); |
6018 b->alias = g_strdup(alias_utf8); | |
4705 | 6019 } |
4282 | 6020 } else { |
8150 | 6021 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6022 |
4754 | 6023 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6024 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6025 gaim_blist_add_group(g, NULL); |
6026 } | |
5146 | 6027 |
8660 | 6028 gaim_debug_info("oscar", |
9285 | 6029 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6030 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6031 } |
8341 | 6032 if (!aim_sncmp(curitem->name, account->username)) { |
6033 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6034 gaim_check_comment(od, comment); | |
6035 free(comment); | |
6036 } | |
7162 | 6037 g_free(gname_utf8); |
6038 g_free(alias_utf8); | |
2991 | 6039 } |
4230 | 6040 } break; |
6041 | |
6042 case 0x0001: { /* Group */ | |
4282 | 6043 /* Shouldn't add empty groups */ |
4230 | 6044 } break; |
6045 | |
6046 case 0x0002: { /* Permit buddy */ | |
2991 | 6047 if (curitem->name) { |
4230 | 6048 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6049 GSList *list; |
5575 | 6050 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6051 if (!list) { |
8660 | 6052 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6053 "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
|
6054 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6055 } |
6056 } | |
4230 | 6057 } break; |
6058 | |
6059 case 0x0003: { /* Deny buddy */ | |
2991 | 6060 if (curitem->name) { |
6061 GSList *list; | |
5575 | 6062 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6063 if (!list) { |
8660 | 6064 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6065 "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
|
6066 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6067 } |
6068 } | |
4230 | 6069 } break; |
6070 | |
6071 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6072 if (curitem->data) { |
6073 fu8_t permdeny; | |
5575 | 6074 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6075 gaim_debug_info("oscar", |
5575 | 6076 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6077 account->perm_deny = permdeny; | |
6078 if (od->icq && account->perm_deny == 0x03) { | |
9973 | 6079 serv_set_status(gc, "Invisible", ""); |
4342 | 6080 } |
2991 | 6081 } |
6082 } | |
4230 | 6083 } break; |
6084 | |
6085 case 0x0005: { /* Presence setting */ | |
3109 | 6086 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6087 } break; |
2991 | 6088 } /* End of switch on curitem->type */ |
6089 } /* End of for loop */ | |
4230 | 6090 |
4901 | 6091 /* Set our ICQ status */ |
8257 | 6092 if (!gc->away) { |
4901 | 6093 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6094 } | |
6095 | |
4342 | 6096 /* Activate SSI */ |
6097 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6098 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6099 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6100 "ssi: activating server-stored buddy list\n"); |
4642 | 6101 aim_ssi_enable(sess); |
4342 | 6102 |
2991 | 6103 return 1; |
2086 | 6104 } |
4230 | 6105 |
6106 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6107 GaimConnection *gc = sess->aux_data; |
4230 | 6108 va_list ap; |
6109 struct aim_ssi_tmp *retval; | |
6110 | |
6111 va_start(ap, fr); | |
6112 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6113 va_end(ap); | |
6114 | |
6115 while (retval) { | |
8660 | 6116 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6117 "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 | 6118 |
6119 if (retval->ack != 0xffff) | |
6120 switch (retval->ack) { | |
6121 case 0x0000: { /* added successfully */ | |
6122 } break; | |
6123 | |
4829 | 6124 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6125 gchar *buf; | |
6126 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 | 6127 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6128 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6129 g_free(buf); |
6130 } | |
6131 | |
7023 | 6132 case 0x000e: { /* buddy requires authorization */ |
4828 | 6133 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6134 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6135 } break; |
6136 | |
6137 default: { /* La la la */ | |
5197 | 6138 gchar *buf; |
8660 | 6139 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6140 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 | 6141 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6142 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6143 g_free(buf); |
4230 | 6144 } break; |
6145 } | |
6146 | |
6147 retval = retval->next; | |
6148 } | |
6149 | |
6150 return 1; | |
6151 } | |
6152 | |
8227 | 6153 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6154 GaimConnection *gc = sess->aux_data; | |
6155 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6156 GaimBuddy *b; | |
6157 GaimGroup *g; | |
6158 va_list ap; | |
6159 fu16_t type; | |
6160 const char *name; | |
6161 | |
6162 va_start(ap, fr); | |
6163 type = (fu16_t)va_arg(ap, int); | |
6164 name = va_arg(ap, char *); | |
6165 va_end(ap); | |
6166 | |
6167 if ((type != 0x0000) || (name == NULL)) | |
6168 return 1; | |
6169 | |
6170 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6171 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6172 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6173 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6174 b = gaim_find_buddy(gc->account, name); | |
6175 free(alias); | |
6176 | |
6177 if (b) { | |
6178 /* Get server stored alias */ | |
6179 if (alias_utf8) { | |
6180 g_free(b->alias); | |
6181 b->alias = g_strdup(alias_utf8); | |
6182 } | |
6183 } else { | |
6184 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6185 | |
6186 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6187 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6188 gaim_blist_add_group(g, NULL); | |
6189 } | |
6190 | |
8660 | 6191 gaim_debug_info("oscar", |
9285 | 6192 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6193 gaim_blist_add_buddy(b, NULL, g, NULL); |
6194 } | |
6195 g_free(gname_utf8); | |
6196 g_free(alias_utf8); | |
6197 | |
6198 return 1; | |
6199 } | |
6200 | |
4230 | 6201 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6202 GaimConnection *gc = sess->aux_data; |
4230 | 6203 va_list ap; |
6204 char *sn, *msg; | |
4236 | 6205 gchar *dialog_msg, *nombre; |
4230 | 6206 struct name_data *data; |
6695 | 6207 GaimBuddy *buddy; |
4230 | 6208 |
6209 va_start(ap, fr); | |
6210 sn = va_arg(ap, char *); | |
6211 msg = va_arg(ap, char *); | |
6212 va_end(ap); | |
6213 | |
8660 | 6214 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6215 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6216 |
4687 | 6217 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6218 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6219 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6220 else |
6221 nombre = g_strdup(sn); | |
6222 | |
6223 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 | 6224 data = g_new(struct name_data, 1); |
6225 data->gc = gc; | |
6226 data->name = g_strdup(sn); | |
6227 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6228 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6229 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6230 0, data, |
7023 | 6231 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6232 G_CALLBACK(oscar_free_name_data)); |
4236 | 6233 |
4230 | 6234 g_free(dialog_msg); |
4236 | 6235 g_free(nombre); |
4230 | 6236 |
6237 return 1; | |
6238 } | |
6239 | |
6240 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6241 GaimConnection *gc = sess->aux_data; |
4230 | 6242 va_list ap; |
6243 char *sn, *msg; | |
4236 | 6244 gchar *dialog_msg, *nombre; |
4230 | 6245 struct name_data *data; |
6695 | 6246 GaimBuddy *buddy; |
4230 | 6247 |
6248 va_start(ap, fr); | |
6249 sn = va_arg(ap, char *); | |
6250 msg = va_arg(ap, char *); | |
6251 va_end(ap); | |
6252 | |
8660 | 6253 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6254 "ssi: received authorization request from %s\n", sn); |
4230 | 6255 |
4687 | 6256 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6257 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6258 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6259 else |
6260 nombre = g_strdup(sn); | |
6261 | |
4337 | 6262 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 | 6263 data = g_new(struct name_data, 1); |
6264 data->gc = gc; | |
6265 data->name = g_strdup(sn); | |
6266 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6267 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6268 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6269 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6270 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6271 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6272 |
4230 | 6273 g_free(dialog_msg); |
4236 | 6274 g_free(nombre); |
4230 | 6275 |
6276 return 1; | |
6277 } | |
6278 | |
6279 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6280 GaimConnection *gc = sess->aux_data; |
4230 | 6281 va_list ap; |
6282 char *sn, *msg; | |
4236 | 6283 gchar *dialog_msg, *nombre; |
4230 | 6284 fu8_t reply; |
6695 | 6285 GaimBuddy *buddy; |
4230 | 6286 |
6287 va_start(ap, fr); | |
6288 sn = va_arg(ap, char *); | |
6289 reply = (fu8_t)va_arg(ap, int); | |
6290 msg = va_arg(ap, char *); | |
6291 va_end(ap); | |
6292 | |
8660 | 6293 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6294 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6295 |
4687 | 6296 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6297 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6298 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6299 else |
6300 nombre = g_strdup(sn); | |
6301 | |
4230 | 6302 if (reply) { |
6303 /* Granted */ | |
7023 | 6304 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
|
6305 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6306 } else { |
6307 /* Denied */ | |
7023 | 6308 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
|
6309 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6310 } |
6311 g_free(dialog_msg); | |
4236 | 6312 g_free(nombre); |
4230 | 6313 |
6314 return 1; | |
6315 } | |
6316 | |
6317 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6318 GaimConnection *gc = sess->aux_data; |
4230 | 6319 va_list ap; |
6320 char *sn; | |
6695 | 6321 GaimBuddy *buddy; |
4230 | 6322 |
6323 va_start(ap, fr); | |
6324 sn = va_arg(ap, char *); | |
6325 va_end(ap); | |
6326 | |
4687 | 6327 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6328 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6329 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6330 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6331 |
6332 return 1; | |
6333 } | |
4269 | 6334 #endif |
2086 | 6335 |
5575 | 6336 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6337 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6338 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6339 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6340 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6341 pce->label = _("_Room:"); |
5234 | 6342 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6343 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6344 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6345 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6346 pce->label = _("_Exchange:"); |
5234 | 6347 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6348 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6349 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6350 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6351 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6352 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6353 return m; |
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 |
9754 | 6356 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6357 { | |
6358 GHashTable *defaults; | |
6359 | |
6360 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6361 | |
6362 if (chat_name != NULL) | |
6363 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6364 | |
6365 return defaults; | |
6366 } | |
6367 | |
9917 | 6368 static char *oscar_get_chat_name(GHashTable *data) { |
6369 return g_strdup(g_hash_table_lookup(data, "room")); | |
6370 } | |
6371 | |
8308 | 6372 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6373 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6374 aim_conn_t *cur; |
5234 | 6375 char *name, *exchange; |
6376 | |
6377 name = g_hash_table_lookup(data, "room"); | |
6378 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6379 |
8660 | 6380 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6381 "Attempting to join chat room %s.\n", name); |
8308 | 6382 |
6383 if ((name == NULL) || (*name == '\0')) { | |
6384 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6385 return; | |
6386 } | |
6387 | |
4617 | 6388 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6389 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6390 "chatnav exists, creating room\n"); |
5234 | 6391 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6392 } else { |
6393 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6394 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6395 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6396 "chatnav does not exist, opening chatnav\n"); |
5234 | 6397 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6398 cr->name = g_strdup(name); |
4617 | 6399 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6400 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6401 } |
6402 } | |
6403 | |
8308 | 6404 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6405 OscarData *od = (OscarData *)gc->proto_data; | |
6406 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6407 |
6408 if (!ccon) | |
6409 return; | |
6410 | |
8225 | 6411 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6412 ccon->exchange, ccon->name, 0x0); |
6413 } | |
6414 | |
8308 | 6415 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6416 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6417 GSList *bcs = gc->buddy_chats; | |
5679 | 6418 GaimConversation *b = NULL; |
2086 | 6419 struct chat_connection *c = NULL; |
6420 int count = 0; | |
6421 | |
6422 while (bcs) { | |
6423 count++; | |
5679 | 6424 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6425 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6426 break; |
6427 bcs = bcs->next; | |
6428 b = NULL; | |
6429 } | |
6430 | |
6431 if (!b) | |
6432 return; | |
6433 | |
8660 | 6434 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6435 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6436 |
8308 | 6437 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6438 if (c != NULL) { |
4617 | 6439 if (od) |
6440 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6441 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6442 gaim_input_remove(c->inpa); |
8308 | 6443 if (gc && od->sess) |
4617 | 6444 aim_conn_kill(od->sess, &c->conn); |
2086 | 6445 g_free(c->name); |
6446 g_free(c->show); | |
6447 g_free(c); | |
6448 } | |
6449 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6450 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6451 } |
6452 | |
8219 | 6453 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6454 OscarData *od = (OscarData *)gc->proto_data; | |
6455 GaimConversation *conv = NULL; | |
2086 | 6456 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6457 char *buf, *buf2; |
9830 | 6458 fu16_t charset, charsubset; |
9807 | 6459 char *charsetstr = NULL; |
8907 | 6460 gsize len; |
8219 | 6461 |
6462 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6463 return -EINVAL; |
2086 | 6464 |
8219 | 6465 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6466 return -EINVAL; |
2086 | 6467 |
8219 | 6468 buf = gaim_strdup_withhtml(message); |
6469 len = strlen(buf); | |
6470 | |
8962 | 6471 if (strstr(buf, "<IMG ")) |
6472 gaim_conversation_write(conv, "", | |
6473 _("Your IM Image was not sent. " | |
6474 "You cannot send IM Images in AIM chats."), | |
6475 GAIM_MESSAGE_ERROR, time(NULL)); | |
6476 | |
9830 | 6477 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6478 if ((len > c->maxlen) || (len > c->maxvis)) { |
6479 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6480 return -E2BIG; |
8359 | 6481 } |
6482 | |
9831 | 6483 if (charset == AIM_CHARSET_ASCII) |
6484 charsetstr = "us-ascii"; | |
6485 else if (charset == AIM_CHARSET_UNICODE) | |
6486 charsetstr = "unicode-2-0"; | |
6487 else if (charset == AIM_CHARSET_CUSTOM) | |
6488 charsetstr = "iso-8859-1"; | |
9807 | 6489 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6490 g_free(buf2); |
8359 | 6491 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6492 return 0; |
2086 | 6493 } |
6494 | |
6695 | 6495 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6496 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6497 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6498 return "icq"; |
6499 else | |
6500 return "aim"; | |
6501 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6502 |
9975 | 6503 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6504 return "icq"; |
6505 return "aim"; | |
6506 } | |
6507 | |
9972 | 6508 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6509 { |
7334 | 6510 GaimAccount *account = NULL; |
6511 GaimConnection *gc = NULL; | |
6512 OscarData *od = NULL; | |
4687 | 6513 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6514 int i = 0; | |
7334 | 6515 aim_userinfo_t *userinfo = NULL; |
6516 | |
6517 if (b != NULL) | |
6518 account = b->account; | |
6519 if (account != NULL) | |
6520 gc = account->gc; | |
6521 if (gc != NULL) | |
6522 od = gc->proto_data; | |
7945 | 6523 if (od != NULL) |
6524 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6525 |
5131 | 6526 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6527 char *gname; | |
7334 | 6528 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6529 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6530 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6531 emblems[i++] = "notauthorized"; | |
6532 } else { | |
6533 emblems[i++] = "offline"; | |
6534 } | |
6535 } | |
4916 | 6536 |
9975 | 6537 if (b->name && (b->uc & 0xffff0000) && aim_sn_is_icq(b->name)) { |
4960 | 6538 int uc = b->uc >> 16; |
4766 | 6539 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6540 emblems[i++] = "invisible"; |
4766 | 6541 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6542 emblems[i++] = "freeforchat"; |
4766 | 6543 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6544 emblems[i++] = "dnd"; |
4766 | 6545 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6546 emblems[i++] = "na"; |
4766 | 6547 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6548 emblems[i++] = "occupied"; |
4766 | 6549 else if (uc & AIM_ICQ_STATE_AWAY) |
6550 emblems[i++] = "away"; | |
6551 } else { | |
6552 if (b->uc & UC_UNAVAILABLE) | |
6553 emblems[i++] = "away"; | |
6554 } | |
4687 | 6555 if (b->uc & UC_WIRELESS) |
6556 emblems[i++] = "wireless"; | |
6557 if (b->uc & UC_AOL) | |
6558 emblems[i++] = "aol"; | |
6559 if (b->uc & UC_ADMIN) | |
6560 emblems[i++] = "admin"; | |
6561 if (b->uc & UC_AB && i < 4) | |
6562 emblems[i++] = "activebuddy"; | |
4766 | 6563 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6564 emblems[i++] = "unconfirmed"; */ | |
7334 | 6565 |
7945 | 6566 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6567 emblems[i++] = "hiptop"; | |
6568 | |
6569 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6570 emblems[i++] = "secure"; |
6571 | |
4687 | 6572 *se = emblems[0]; |
6573 *sw = emblems[1]; | |
6574 *nw = emblems[2]; | |
6575 *ne = emblems[3]; | |
6576 } | |
6577 | |
6695 | 6578 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6579 GaimConnection *gc = b->account->gc; |
7283 | 6580 OscarData *od = gc->proto_data; |
7045 | 6581 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6582 GString *str = g_string_new(""); |
5131 | 6583 |
6584 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6585 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6586 |
6587 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6588 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6589 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6590 g_free(charset); |
7011 | 6591 if (away_utf8 != NULL) { |
7091 | 6592 gchar *tmp1, *tmp2; |
9627 | 6593 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6594 g_free(away_utf8); |
8571 | 6595 tmp1 = gaim_escape_html(tmp2); |
7091 | 6596 g_free(tmp2); |
8700 | 6597 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6598 g_free(tmp1); |
8701 | 6599 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6600 g_free(tmp2); |
5836 | 6601 } |
5131 | 6602 } |
8701 | 6603 } |
6604 | |
6605 return g_string_free(str, FALSE); | |
5131 | 6606 } |
6607 | |
6695 | 6608 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 6609 GaimConnection *gc = b->account->gc; |
7283 | 6610 OscarData *od = gc->proto_data; |
5167 | 6611 gchar *ret = NULL; |
6612 | |
6613 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6614 if (aim_sn_is_icq(b->name)) |
8701 | 6615 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6616 else |
6617 ret = g_strdup(_("Away")); | |
5836 | 6618 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6619 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 6620 if (bi->availmsg) |
6621 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 6622 } else { |
5167 | 6623 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6624 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6625 ret = g_strdup(_("Not Authorized")); | |
6626 else | |
6627 ret = g_strdup(_("Offline")); | |
6628 } | |
6629 | |
6630 return ret; | |
6631 } | |
6632 | |
5842 | 6633 |
5844 | 6634 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6635 GaimConnection *gc = sess->aux_data; |
7283 | 6636 OscarData *od = gc->proto_data; |
5892 | 6637 va_list ap; |
5842 | 6638 fu16_t type; |
5892 | 6639 fu8_t flags = 0, length = 0; |
6640 char *md5 = NULL; | |
6641 | |
7334 | 6642 |
5842 | 6643 va_start(ap, fr); |
6644 type = va_arg(ap, int); | |
5892 | 6645 |
6646 switch(type) { | |
6647 case 0x0000: | |
6648 case 0x0001: { | |
6649 flags = va_arg(ap, int); | |
6650 length = va_arg(ap, int); | |
6651 md5 = va_arg(ap, char *); | |
6652 | |
6653 if (flags == 0x41) { | |
6654 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6655 od->iconconnecting = TRUE; | |
6656 od->set_icon = TRUE; | |
6657 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6658 } else { | |
6039 | 6659 struct stat st; |
6660 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6661 if (iconfile == NULL) { | |
8363 | 6662 aim_ssi_delicon(od->sess); |
6039 | 6663 } else if (!stat(iconfile, &st)) { |
6664 char *buf = g_malloc(st.st_size); | |
6665 FILE *file = fopen(iconfile, "rb"); | |
6666 if (file) { | |
9532 | 6667 /* XXX - Use g_file_get_contents()? */ |
6039 | 6668 fread(buf, 1, st.st_size, file); |
6669 fclose(file); | |
8660 | 6670 gaim_debug_info("oscar", |
6039 | 6671 "Uploading icon to icon server\n"); |
6879 | 6672 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6673 } else |
8660 | 6674 gaim_debug_error("oscar", |
6039 | 6675 "Can't open buddy icon file!\n"); |
6676 g_free(buf); | |
6677 } else { | |
8660 | 6678 gaim_debug_error("oscar", |
6039 | 6679 "Can't stat buddy icon file!\n"); |
5892 | 6680 } |
6681 } | |
8363 | 6682 } else if (flags == 0x81) { |
6683 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6684 if (iconfile == NULL) | |
6685 aim_ssi_delicon(od->sess); | |
6686 else | |
6687 aim_ssi_seticon(od->sess, md5, length); | |
6688 } | |
5892 | 6689 } break; |
6690 | |
6691 case 0x0002: { /* We just set an "available" message? */ | |
6692 } break; | |
6693 } | |
6694 | |
5842 | 6695 va_end(ap); |
5844 | 6696 |
6697 return 0; | |
5842 | 6698 } |
5892 | 6699 |
5575 | 6700 static void oscar_set_permit_deny(GaimConnection *gc) { |
6701 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6702 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6703 #ifdef NOSSI |
8143 | 6704 GSList *list; |
4230 | 6705 char buf[MAXMSGLEN]; |
6706 int at; | |
6707 | |
5575 | 6708 switch(account->perm_deny) { |
8175 | 6709 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6710 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6711 break; |
8175 | 6712 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6713 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6714 break; |
8175 | 6715 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6716 list = account->permit; |
4230 | 6717 at = 0; |
6718 while (list) { | |
6719 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6720 list = list->next; | |
6721 } | |
6722 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6723 break; | |
8175 | 6724 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6725 list = account->deny; |
4230 | 6726 at = 0; |
6727 while (list) { | |
6728 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6729 list = list->next; | |
6730 } | |
6731 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6732 break; | |
6733 default: | |
6734 break; | |
2086 | 6735 } |
4230 | 6736 #else |
8175 | 6737 if (od->sess->ssi.received_data) { |
6738 switch (account->perm_deny) { | |
6739 case GAIM_PRIVACY_ALLOW_ALL: | |
6740 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6741 break; | |
6742 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6743 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6744 break; | |
6745 case GAIM_PRIVACY_ALLOW_USERS: | |
6746 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6747 break; | |
6748 case GAIM_PRIVACY_DENY_ALL: | |
6749 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6750 break; | |
6751 case GAIM_PRIVACY_DENY_USERS: | |
6752 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6753 break; | |
6754 default: | |
6755 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6756 break; | |
6757 } | |
6758 } | |
4230 | 6759 #endif |
2086 | 6760 } |
6761 | |
5575 | 6762 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6763 #ifdef NOSSI |
8143 | 6764 if (gc->account->perm_deny == 3) |
4269 | 6765 oscar_set_permit_deny(gc); |
6766 #else | |
7283 | 6767 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6768 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6769 if (od->sess->ssi.received_data) |
4889 | 6770 aim_ssi_addpermit(od->sess, who); |
4230 | 6771 #endif |
2086 | 6772 } |
6773 | |
5575 | 6774 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6775 #ifdef NOSSI |
8143 | 6776 if (gc->account->perm_deny == 4) |
4269 | 6777 oscar_set_permit_deny(gc); |
6778 #else | |
7283 | 6779 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6780 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6781 if (od->sess->ssi.received_data) |
4889 | 6782 aim_ssi_adddeny(od->sess, who); |
4230 | 6783 #endif |
2086 | 6784 } |
6785 | |
5575 | 6786 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6787 #ifdef NOSSI |
8143 | 6788 if (gc->account->perm_deny == 3) |
4269 | 6789 oscar_set_permit_deny(gc); |
6790 #else | |
7283 | 6791 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6792 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6793 if (od->sess->ssi.received_data) |
4889 | 6794 aim_ssi_delpermit(od->sess, who); |
4230 | 6795 #endif |
2086 | 6796 } |
6797 | |
5575 | 6798 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6799 #ifdef NOSSI |
8143 | 6800 if (gc->account->perm_deny == 4) |
4269 | 6801 oscar_set_permit_deny(gc); |
6802 #else | |
7283 | 6803 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6804 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6805 if (od->sess->ssi.received_data) |
4889 | 6806 aim_ssi_deldeny(od->sess, who); |
4230 | 6807 #endif |
2086 | 6808 } |
6809 | |
9975 | 6810 static GList * |
6811 oscar_status_types(GaimAccount *account) | |
2086 | 6812 { |
9975 | 6813 GList *status_types = NULL; |
6814 GaimStatusType *type; | |
6815 gboolean is_icq; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6816 |
9973 | 6817 g_return_val_if_fail(account != NULL, NULL); |
6818 | |
9975 | 6819 is_icq = aim_sn_is_icq(gaim_account_get_username(account)); |
6820 | |
6821 | |
6822 | |
6823 return status_types; | |
6824 | |
6825 #if 0 /* STATUS - old stuff that should be removed */ | |
8257 | 6826 if (od->icq) { |
6827 m = g_list_append(m, _("Online")); | |
6828 m = g_list_append(m, _("Away")); | |
6829 m = g_list_append(m, _("Do Not Disturb")); | |
6830 m = g_list_append(m, _("Not Available")); | |
6831 m = g_list_append(m, _("Occupied")); | |
6832 m = g_list_append(m, _("Free For Chat")); | |
6833 m = g_list_append(m, _("Invisible")); | |
6834 } else { | |
6835 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6836 m = g_list_append(m, _("Back")); |
8257 | 6837 m = g_list_append(m, _("Visible")); |
6838 m = g_list_append(m, _("Invisible")); | |
6839 } | |
4333 | 6840 |
6841 return m; | |
9975 | 6842 #endif |
4333 | 6843 } |
6844 | |
7172 | 6845 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6846 GaimConnection *gc = data->gc; |
6847 OscarData *od = gc->proto_data; | |
7172 | 6848 GaimBuddy *b; |
6849 GaimGroup *g; | |
6850 | |
6851 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6852 oscar_free_name_data(data); | |
6853 return; | |
6854 } | |
6855 | |
6856 if (!(g = gaim_find_buddys_group(b))) { | |
6857 oscar_free_name_data(data); | |
6858 return; | |
6859 } | |
6860 | |
6861 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6862 |
6863 if (!aim_sncmp(data->name, gc->account->username)) | |
6864 gaim_check_comment(od, text); | |
6865 | |
7172 | 6866 oscar_free_name_data(data); |
6867 } | |
6868 | |
9030 | 6869 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6870 | |
6871 GaimBuddy *buddy; | |
6872 GaimConnection *gc; | |
6873 OscarData *od; | |
6874 struct name_data *data; | |
7172 | 6875 GaimGroup *g; |
6876 char *comment; | |
6877 gchar *comment_utf8; | |
9631 | 6878 gchar *title; |
7172 | 6879 |
9030 | 6880 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6881 | |
6882 buddy = (GaimBuddy *) node; | |
6883 gc = gaim_account_get_connection(buddy->account); | |
6884 od = gc->proto_data; | |
6885 | |
6886 data = g_new(struct name_data, 1); | |
6887 | |
6888 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6889 return; |
9030 | 6890 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6891 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6892 | |
6893 data->gc = gc; | |
9030 | 6894 data->name = g_strdup(buddy->name); |
7172 | 6895 data->nick = NULL; |
6896 | |
9631 | 6897 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6898 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6899 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6900 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6901 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6902 data); | |
9631 | 6903 g_free(title); |
7172 | 6904 |
6905 free(comment); | |
6906 g_free(comment_utf8); | |
6907 } | |
6908 | |
9030 | 6909 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6910 | |
6911 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6912 OscarData *od = gc->proto_data; |
9030 | 6913 |
4333 | 6914 GList *m = NULL; |
9030 | 6915 GaimBlistNodeAction *act; |
6916 | |
6917 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6918 oscar_buddycb_edit_comment, NULL); | |
6919 m = g_list_append(m, act); | |
7172 | 6920 |
4333 | 6921 if (od->icq) { |
4624 | 6922 #if 0 |
9030 | 6923 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6924 oscar_get_icqstatusmsg, NULL); | |
6925 m = g_list_append(m, act); | |
4624 | 6926 #endif |
4333 | 6927 } else { |
7011 | 6928 aim_userinfo_t *userinfo; |
9030 | 6929 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6930 | |
6931 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
6932 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
6933 | |
7011 | 6934 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 6935 act = gaim_blist_node_action_new(_("Direct IM"), |
6936 oscar_ask_direct_im, NULL); | |
6937 m = g_list_append(m, act); | |
5917 | 6938 } |
9466 | 6939 #if 0 |
7011 | 6940 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6941 act = gaim_blist_node_action_new(_("Get File"), |
6942 oscar_ask_getfile, NULL); | |
6943 m = g_list_append(m, act); | |
5917 | 6944 } |
4826 | 6945 #endif |
4333 | 6946 } |
5131 | 6947 } |
5197 | 6948 |
5131 | 6949 if (od->sess->ssi.received_data) { |
9030 | 6950 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6951 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
6952 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
6953 gaim_auth_sendrequest_menu, NULL); | |
6954 m = g_list_append(m, act); | |
4333 | 6955 } |
4916 | 6956 } |
6957 | |
4333 | 6958 return m; |
6959 } | |
6960 | |
9030 | 6961 |
6962 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6963 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6964 return oscar_buddy_menu((GaimBuddy *) node); | |
6965 } else { | |
6966 return NULL; | |
6967 } | |
6968 } | |
6969 | |
6970 | |
5575 | 6971 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6972 OscarData *od = gc->proto_data; |
5575 | 6973 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6974 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6975 od->setnick = TRUE; | |
6976 od->newsn = g_strdup(nick); | |
6977 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6978 } else { | |
6979 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6980 } | |
6981 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6982 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6983 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6984 } |
6985 } | |
6986 | |
9015 | 6987 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 6988 { |
9015 | 6989 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 6990 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 6991 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6992 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6993 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6994 gc); |
4333 | 6995 } |
6996 | |
9015 | 6997 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 6998 { |
9015 | 6999 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7000 OscarData *od = gc->proto_data; |
4333 | 7001 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7002 | |
7003 if (conn) { | |
7004 aim_admin_reqconfirm(od->sess, conn); | |
7005 } else { | |
7006 od->conf = TRUE; | |
7007 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7008 } | |
7009 } | |
7010 | |
9015 | 7011 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7012 { |
9015 | 7013 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7014 OscarData *od = gc->proto_data; |
4333 | 7015 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7016 | |
7017 if (conn) { | |
7018 aim_admin_getinfo(od->sess, conn, 0x11); | |
7019 } else { | |
7020 od->reqemail = TRUE; | |
7021 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7022 } | |
7023 } | |
7024 | |
5575 | 7025 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7026 { |
7283 | 7027 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7028 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
|
7029 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7030 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7031 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7032 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7033 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7034 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7035 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7036 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7037 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7038 |
9015 | 7039 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7040 { |
9015 | 7041 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7042 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7043 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7044 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7045 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7046 gc); |
4333 | 7047 } |
7048 | |
9015 | 7049 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7050 { |
9015 | 7051 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7052 OscarData *od = gc->proto_data; |
4333 | 7053 gchar *nombre, *text, *tmp; |
6695 | 7054 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7055 int num=0; |
7056 | |
6873 | 7057 text = g_strdup(""); |
4333 | 7058 |
4785 | 7059 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7060 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7061 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7062 continue; | |
6695 | 7063 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7064 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7065 continue; |
6695 | 7066 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7067 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7068 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7069 continue; | |
7070 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7071 if (gaim_buddy_get_alias_only(buddy)) |
7072 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7073 else |
7074 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7075 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7076 g_free(text); |
7077 text = tmp; | |
7078 g_free(nombre); | |
7079 num++; | |
7080 } | |
4333 | 7081 } |
2979 | 7082 } |
4333 | 7083 } |
7084 | |
7085 if (!num) { | |
7086 g_free(text); | |
6873 | 7087 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7088 } | |
7089 | |
7090 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7091 "the following buddies"), _("You can re-request " | |
7092 "authorization from these buddies by " | |
7093 "right-clicking on them and selecting " | |
7094 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7095 g_free(text); |
2979 | 7096 } |
7097 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7098 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7099 { |
8950 | 7100 OscarData *od = (OscarData *)gc->proto_data; |
7101 | |
7102 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7103 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7104 |
9015 | 7105 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7106 { |
9015 | 7107 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7108 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7109 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7110 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7111 "searching for."), |
8697 | 7112 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7113 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7114 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7115 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7116 |
5917 | 7117 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 7118 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 7119 |
7334 | 7120 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 7121 aim_srv_setavailmsg(od->sess, text); |
7122 } | |
7123 | |
9879 | 7124 static void oscar_show_setavailmsg(GaimPluginAction *action) |
5917 | 7125 { |
9879 | 7126 GaimConnection *gc = (GaimConnection *) action->context; |
7313 | 7127 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
7128 _("I'm doing work and hoping for a distraction--IM me!"), | |
8697 | 7129 TRUE, FALSE, NULL, |
5917 | 7130 _("OK"), G_CALLBACK(oscar_setavailmsg), |
7131 _("Cancel"), NULL, | |
7132 gc); | |
7133 } | |
7134 | |
9015 | 7135 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7136 { |
9015 | 7137 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7138 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7139 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7140 |
9015 | 7141 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7142 { |
9015 | 7143 GaimConnection *gc = (GaimConnection *) action->context; |
9809 | 7144 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7145 } |
7146 | |
9015 | 7147 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7148 { |
9015 | 7149 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7150 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7151 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7152 |
9015 | 7153 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7154 { |
9015 | 7155 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7156 OscarData *od = gc->proto_data; |
5575 | 7157 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
|
7158 gaim_notify_uri(gc, substituted); |
5517 | 7159 g_free(substituted); |
4333 | 7160 } |
7161 | |
9015 | 7162 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7163 { |
9015 | 7164 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7165 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7166 } | |
7167 | |
5842 | 7168 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7169 { | |
7283 | 7170 OscarData *od = gc->proto_data; |
5844 | 7171 aim_session_t *sess = od->sess; |
5842 | 7172 FILE *file; |
7173 struct stat st; | |
5844 | 7174 |
6039 | 7175 if (iconfile == NULL) { |
8363 | 7176 aim_ssi_delicon(od->sess); |
6039 | 7177 } else if (!stat(iconfile, &st)) { |
5842 | 7178 char *buf = g_malloc(st.st_size); |
7179 file = fopen(iconfile, "rb"); | |
7180 if (file) { | |
6052 | 7181 md5_state_t *state; |
6039 | 7182 char md5[16]; |
9532 | 7183 /* XXX - Use g_file_get_contents()? */ |
5842 | 7184 int len = fread(buf, 1, st.st_size, file); |
6039 | 7185 fclose(file); |
6052 | 7186 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7187 md5_init(state); |
7188 md5_append(state, buf, len); | |
7189 md5_finish(state, md5); | |
7190 g_free(state); | |
7191 aim_ssi_seticon(sess, md5, 16); | |
7192 } else | |
8660 | 7193 gaim_debug_error("oscar", |
5842 | 7194 "Can't open buddy icon file!\n"); |
7195 g_free(buf); | |
7196 } else | |
8660 | 7197 gaim_debug_error("oscar", |
5842 | 7198 "Can't stat buddy icon file!\n"); |
7199 } | |
7200 | |
7201 | |
9015 | 7202 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7203 { |
9015 | 7204 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7205 OscarData *od = gc->proto_data; |
4333 | 7206 GList *m = NULL; |
9015 | 7207 GaimPluginAction *act; |
7208 | |
7209 act = gaim_plugin_action_new(_("Set User Info..."), | |
7210 oscar_show_set_info); | |
7211 m = g_list_append(m, act); | |
4333 | 7212 |
8576 | 7213 if (od->icq) { |
9015 | 7214 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7215 oscar_show_set_info_icqurl); | |
7216 m = g_list_append(m, act); | |
8576 | 7217 } |
7218 | |
9879 | 7219 if (!od->icq) { |
7220 act = gaim_plugin_action_new(_("Set Available Message..."), | |
7221 oscar_show_setavailmsg); | |
7222 m = g_list_append(m, act); | |
7223 } | |
5917 | 7224 |
9015 | 7225 act = gaim_plugin_action_new(_("Change Password..."), |
7226 oscar_change_pass); | |
7227 m = g_list_append(m, act); | |
4617 | 7228 |
7229 if (od->sess->authinfo->chpassurl) { | |
9015 | 7230 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7231 oscar_show_chpassurl); | |
7232 m = g_list_append(m, act); | |
7233 | |
7234 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7235 oscar_show_imforwardingurl); | |
7236 m = g_list_append(m, act); | |
7026 | 7237 } |
7238 | |
5238 | 7239 if (!od->icq) { |
4617 | 7240 /* AIM actions */ |
7241 m = g_list_append(m, NULL); | |
4333 | 7242 |
9015 | 7243 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7244 oscar_show_format_screenname); | |
7245 m = g_list_append(m, act); | |
7246 | |
7247 act = gaim_plugin_action_new(_("Confirm Account"), | |
7248 oscar_confirm_account); | |
7249 m = g_list_append(m, act); | |
7250 | |
7251 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7252 oscar_show_email); | |
7253 m = g_list_append(m, act); | |
7254 | |
7255 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7256 oscar_show_change_email); | |
7257 m = g_list_append(m, act); | |
2086 | 7258 } |
4333 | 7259 |
7260 m = g_list_append(m, NULL); | |
7261 | |
9015 | 7262 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7263 oscar_show_awaitingauth); | |
7264 m = g_list_append(m, act); | |
4333 | 7265 |
2086 | 7266 m = g_list_append(m, NULL); |
4333 | 7267 |
9015 | 7268 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7269 oscar_show_find_email); | |
7270 m = g_list_append(m, act); | |
4333 | 7271 |
8591 | 7272 #if 0 |
9015 | 7273 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7274 show_find_info); | |
7275 m = g_list_append(m, act); | |
8591 | 7276 #endif |
2086 | 7277 |
7278 return m; | |
7279 } | |
7280 | |
5575 | 7281 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7282 { |
7283 | 7283 OscarData *od = gc->proto_data; |
4617 | 7284 |
7285 if (od->icq) { | |
7286 aim_icq_changepasswd(od->sess, new); | |
2086 | 7287 } else { |
4617 | 7288 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7289 if (conn) { | |
7290 aim_admin_changepasswd(od->sess, conn, new, old); | |
7291 } else { | |
7292 od->chpass = TRUE; | |
7293 od->oldp = g_strdup(old); | |
7294 od->newp = g_strdup(new); | |
7295 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7296 } | |
2086 | 7297 } |
7298 } | |
7299 | |
6059 | 7300 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7301 { |
7283 | 7302 OscarData *od = gc->proto_data; |
8971 | 7303 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
|
7304 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7305 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7306 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7307 |
8971 | 7308 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7309 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7310 |
9935 | 7311 static void |
7312 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7313 { | |
7314 GaimConnection *gc = data; | |
7315 OscarData *od = gc->proto_data; | |
7316 aim_session_t *sess = od->sess; | |
7317 fu32_t presence; | |
7318 | |
7319 presence = aim_ssi_getpresence(sess->ssi.local); | |
7320 | |
7321 if (value) { | |
9971 | 7322 // presence |= 0x00400000; |
7323 presence &= ~0x00020000; | |
9935 | 7324 aim_ssi_setpresence(sess, presence); |
7325 } else { | |
9971 | 7326 // presence &= ~0x00400000; |
7327 presence |= 0x00020000; | |
9935 | 7328 aim_ssi_setpresence(sess, presence); |
7329 } | |
7330 } | |
7331 | |
7332 static GaimPluginPrefFrame * | |
9936 | 7333 get_plugin_pref_frame(GaimPlugin *plugin) |
7334 { | |
9935 | 7335 GaimPluginPrefFrame *frame; |
7336 GaimPluginPref *ppref; | |
7337 | |
7338 frame = gaim_plugin_pref_frame_new(); | |
7339 | |
7340 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7341 gaim_plugin_pref_frame_add(frame, ppref); | |
7342 | |
7343 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7344 gaim_plugin_pref_frame_add(frame, ppref); | |
7345 | |
7346 return frame; | |
7347 } | |
7348 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7349 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7350 { |
9308 | 7351 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7352 NULL, /* user_splits */ |
7353 NULL, /* protocol_options */ | |
7354 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7355 oscar_list_icon, /* list_icon */ | |
7356 oscar_list_emblems, /* list_emblems */ | |
7357 oscar_status_text, /* status_text */ | |
7358 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7359 oscar_status_types, /* status_types */ |
9475 | 7360 oscar_blist_node_menu, /* blist_node_menu */ |
7361 oscar_chat_info, /* chat_info */ | |
9754 | 7362 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7363 oscar_login, /* login */ |
7364 oscar_close, /* close */ | |
7365 oscar_send_im, /* send_im */ | |
7366 oscar_set_info, /* set_info */ | |
7367 oscar_send_typing, /* send_typing */ | |
7368 oscar_get_info, /* get_info */ | |
9973 | 7369 oscar_set_status, /* set_status */ |
9475 | 7370 oscar_set_idle, /* set_idle */ |
7371 oscar_change_passwd, /* change_passwd */ | |
7372 oscar_add_buddy, /* add_buddy */ | |
7373 oscar_add_buddies, /* add_buddies */ | |
7374 oscar_remove_buddy, /* remove_buddy */ | |
7375 oscar_remove_buddies, /* remove_buddies */ | |
7376 oscar_add_permit, /* add_permit */ | |
7377 oscar_add_deny, /* add_deny */ | |
7378 oscar_rem_permit, /* rem_permit */ | |
7379 oscar_rem_deny, /* rem_deny */ | |
7380 oscar_set_permit_deny, /* set_permit_deny */ | |
7381 oscar_warn, /* warn */ | |
7382 oscar_join_chat, /* join_chat */ | |
7383 NULL, /* reject_chat */ | |
9973 | 7384 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7385 oscar_chat_invite, /* chat_invite */ |
7386 oscar_chat_leave, /* chat_leave */ | |
7387 NULL, /* chat_whisper */ | |
7388 oscar_send_chat, /* chat_send */ | |
7389 oscar_keepalive, /* keepalive */ | |
7390 NULL, /* register_user */ | |
7391 NULL, /* get_cb_info */ | |
7392 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7393 #ifndef NOSSI |
9475 | 7394 oscar_alias_buddy, /* alias_buddy */ |
7395 oscar_move_buddy, /* group_buddy */ | |
7396 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7397 #else |
9475 | 7398 NULL, /* alias_buddy */ |
7399 NULL, /* group_buddy */ | |
7400 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7401 #endif |
9475 | 7402 NULL, /* buddy_free */ |
7403 oscar_convo_closed, /* convo_closed */ | |
7404 NULL, /* normalize */ | |
7405 oscar_set_icon, /* set_buddy_icon */ | |
7406 NULL, /* remove_group */ | |
7407 NULL, /* get_cb_real_name */ | |
7408 NULL, /* set_chat_topic */ | |
7409 NULL, /* find_blist_chat */ | |
7410 NULL, /* roomlist_get_list */ | |
7411 NULL, /* roomlist_cancel */ | |
7412 NULL, /* roomlist_expand_category */ | |
7413 oscar_can_receive_file, /* can_receive_file */ | |
7414 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7415 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7416 |
9935 | 7417 static GaimPluginUiInfo prefs_info = { |
7418 get_plugin_pref_frame | |
7419 }; | |
7420 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7421 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7422 { |
9943 | 7423 GAIM_PLUGIN_MAGIC, |
7424 GAIM_MAJOR_VERSION, | |
7425 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7426 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7427 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7428 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7429 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7430 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7431 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7432 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7433 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7434 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7435 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7436 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7437 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7438 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7439 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7440 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7441 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7442 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7443 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7444 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7445 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7446 NULL, /**< ui_info */ |
8993 | 7447 &prpl_info, /**< extra_info */ |
9935 | 7448 &prefs_info, /**< prefs_info */ |
9015 | 7449 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7450 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7451 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7452 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7453 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7454 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7455 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7456 |
9830 | 7457 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7458 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7459 | |
7460 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7461 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7462 | |
7463 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7464 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
|
7465 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7466 my_protocol = plugin; |
9935 | 7467 |
7468 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7469 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7470 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7471 } |
7472 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7473 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |