Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 10246:a66cf83552dc
[gaim-migrate @ 11386]
I changed gaim_find_conversation and gaim_find_conversation_with_account
The first parameter is now one of GAIM_CONV_IM, GAIM_CONV_CHAT or
GAIM_CONV_ANY. Unfortunately, this changes a bajillion files.
Please look over this and make sure I use the correct type everywhere.
Especially in Novell and MSN, and somewhat in SILC.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 23 Nov 2004 06:14:15 +0000 |
parents | 95ca0db2d01d |
children | 9cafe038c95e |
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 | |
10042 | 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2086 | 20 * GNU General Public License for more details. |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 * | |
26 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
31 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
32 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
33 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "ft.h" |
6982 | 36 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
37 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
38 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "privacy.h" |
2086 | 40 #include "prpl.h" |
4889 | 41 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
42 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "util.h" |
9943 | 44 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 |
2086 | 46 #include "aim.h" |
5842 | 47 #include "md5.h" |
2086 | 48 |
9976 | 49 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
50 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
51 #define OSCAR_STATUS_ID_ONLINE "online" | |
9991 | 52 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 53 #define OSCAR_STATUS_ID_AWAY "away" |
54 #define OSCAR_STATUS_ID_DND "dnd" | |
55 #define OSCAR_STATUS_ID_NA "na" | |
56 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
57 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
58 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 59 |
2086 | 60 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
61 | |
7283 | 62 #define OSCAR_CONNECT_STEPS 6 |
9830 | 63 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 64 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
65 static GaimPlugin *my_protocol = NULL; |
4249 | 66 |
7376 | 67 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
68 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 69 |
4665 | 70 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
71 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 72 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 73 |
7283 | 74 typedef struct _OscarData OscarData; |
75 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
76 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
77 aim_conn_t *conn; |
2086 | 78 |
79 guint cnpa; | |
80 guint paspa; | |
3694 | 81 guint emlpa; |
4804 | 82 guint icopa; |
2086 | 83 |
4823 | 84 gboolean iconconnecting; |
5842 | 85 gboolean set_icon; |
4823 | 86 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
87 GSList *create_rooms; |
2086 | 88 |
89 gboolean conf; | |
90 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
91 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
92 char *email; |
2979 | 93 gboolean setnick; |
94 char *newsn; | |
2086 | 95 gboolean chpass; |
96 char *oldp; | |
97 char *newp; | |
9971 | 98 |
2086 | 99 GSList *oscar_chats; |
100 GSList *direct_ims; | |
3630 | 101 GSList *file_transfers; |
4738 | 102 GHashTable *buddyinfo; |
4804 | 103 GSList *requesticon; |
2086 | 104 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
105 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
106 gboolean icq; |
4804 | 107 guint icontimer; |
5968 | 108 guint getblisttimer; |
8341 | 109 guint getinfotimer; |
2993 | 110 |
111 struct { | |
4230 | 112 guint maxwatchers; /* max users who can watch you */ |
2993 | 113 guint maxbuddies; /* max users you can watch */ |
4230 | 114 guint maxgroups; /* max groups in server list */ |
2993 | 115 guint maxpermits; /* max users on permit list */ |
116 guint maxdenies; /* max users on deny list */ | |
117 guint maxsiglen; /* max size (bytes) of profile */ | |
118 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
119 } rights; | |
2086 | 120 }; |
121 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
122 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
123 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
124 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
125 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
126 |
2086 | 127 struct chat_connection { |
128 char *name; | |
129 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
130 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
131 fu16_t instance; |
2086 | 132 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
|
133 aim_conn_t *conn; |
2086 | 134 int inpa; |
135 int id; | |
5575 | 136 GaimConnection *gc; /* i hate this. */ |
8733 | 137 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
138 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
139 int maxvis; |
2086 | 140 }; |
141 | |
8971 | 142 struct oscar_direct_im { |
5575 | 143 GaimConnection *gc; |
2086 | 144 char name[80]; |
145 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
146 aim_conn_t *conn; |
3008 | 147 gboolean connected; |
8978 | 148 gboolean gpc_pend; |
149 gboolean killme; | |
8984 | 150 gboolean donttryagain; |
2086 | 151 }; |
152 | |
153 struct ask_direct { | |
5575 | 154 GaimConnection *gc; |
2086 | 155 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
156 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
157 fu8_t cookie[8]; |
8984 | 158 gboolean donttryagain; |
2086 | 159 }; |
160 | |
7011 | 161 /* |
162 * Various PRPL-specific buddy info that we want to keep track of | |
163 * Some other info is maintained by locate.c, and I'd like to move | |
164 * the rest of this to libfaim, mostly im.c | |
165 */ | |
4738 | 166 struct buddyinfo { |
167 gboolean typingnot; | |
6292 | 168 gchar *availmsg; |
6857 | 169 fu32_t ipaddr; |
5836 | 170 |
171 unsigned long ico_me_len; | |
172 unsigned long ico_me_csum; | |
173 time_t ico_me_time; | |
174 gboolean ico_informed; | |
4738 | 175 |
176 unsigned long ico_len; | |
177 unsigned long ico_csum; | |
178 time_t ico_time; | |
179 gboolean ico_need; | |
7406 | 180 gboolean ico_sent; |
2086 | 181 }; |
182 | |
4230 | 183 struct name_data { |
5575 | 184 GaimConnection *gc; |
4230 | 185 gchar *name; |
3453 | 186 gchar *nick; |
3141 | 187 }; |
188 | |
5129 | 189 static char *msgerrreason[] = { |
190 N_("Invalid error"), | |
191 N_("Invalid SNAC"), | |
192 N_("Rate to host"), | |
193 N_("Rate to client"), | |
194 N_("Not logged in"), | |
195 N_("Service unavailable"), | |
196 N_("Service not defined"), | |
197 N_("Obsolete SNAC"), | |
198 N_("Not supported by host"), | |
199 N_("Not supported by client"), | |
200 N_("Refused by client"), | |
201 N_("Reply too big"), | |
202 N_("Responses lost"), | |
203 N_("Request denied"), | |
204 N_("Busted SNAC payload"), | |
205 N_("Insufficient rights"), | |
206 N_("In local permit/deny"), | |
207 N_("Too evil (sender)"), | |
208 N_("Too evil (receiver)"), | |
209 N_("User temporarily unavailable"), | |
210 N_("No match"), | |
211 N_("List overflow"), | |
212 N_("Request ambiguous"), | |
213 N_("Queue full"), | |
214 N_("Not while on AOL") | |
215 }; | |
216 static int msgerrreasonlen = 25; | |
217 | |
218 /* All the libfaim->gaim callback functions */ | |
219 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
220 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
221 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
224 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
225 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
226 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 229 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 230 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 231 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
232 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
|
233 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
|
234 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
|
235 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
|
236 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 237 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
238 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 240 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 241 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
242 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
243 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
244 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
245 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
248 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
249 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
250 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
251 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
252 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
253 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
268 #ifndef NOSSI | |
269 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 273 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 274 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
275 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
278 #endif | |
279 | |
280 /* for DirectIM/image transfer */ | |
281 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
282 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
283 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 284 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 285 |
286 /* for file transfer */ | |
287 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
288 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
289 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
290 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
291 | |
292 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 293 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 294 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 295 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 296 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
297 | |
5836 | 298 static void oscar_free_name_data(struct name_data *data) { |
4230 | 299 g_free(data->name); |
300 g_free(data->nick); | |
301 g_free(data); | |
302 } | |
303 | |
5836 | 304 static void oscar_free_buddyinfo(void *data) { |
305 struct buddyinfo *bi = data; | |
6292 | 306 g_free(bi->availmsg); |
5836 | 307 g_free(bi); |
308 } | |
309 | |
9807 | 310 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 311 { |
312 int i = 0; | |
9826 | 313 int charset = AIM_CHARSET_ASCII; |
5129 | 314 |
315 /* Determine how we can send this message. Per the warnings elsewhere | |
316 * in this file, these little checks determine the simplest encoding | |
317 * we can use for a given message send using it. */ | |
318 while (utf8[i]) { | |
319 if ((unsigned char)utf8[i] > 0x7f) { | |
320 /* not ASCII! */ | |
9826 | 321 charset = AIM_CHARSET_CUSTOM; |
5129 | 322 break; |
323 } | |
324 i++; | |
325 } | |
326 while (utf8[i]) { | |
327 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
328 * followed by 0xc0-0xc3 in the second */ | |
329 if ((unsigned char)utf8[i] < 0x80) { | |
330 i++; | |
331 continue; | |
332 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
333 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
334 i += 2; | |
335 continue; | |
336 } | |
9826 | 337 charset = AIM_CHARSET_UNICODE; |
5129 | 338 break; |
339 } | |
340 | |
9807 | 341 return charset; |
5129 | 342 } |
343 | |
8225 | 344 /* |
345 * Take a string of the form charset="bleh" where bleh is | |
346 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
347 * return a newly allocated string containing bleh. | |
348 */ | |
349 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 350 { |
8225 | 351 gchar *ret = NULL; |
352 char *begin, *end; | |
353 | |
9933 | 354 g_return_val_if_fail(encoding != NULL, NULL); |
355 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
356 /* Make sure encoding begins with charset= */ |
8225 | 357 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
358 return NULL; | |
359 | |
360 begin = strchr(encoding, '"'); | |
361 end = strrchr(encoding, '"'); | |
362 | |
363 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
364 return NULL; | |
365 | |
366 ret = g_strndup(begin+1, (end-1) - begin); | |
367 | |
368 return ret; | |
369 } | |
370 | |
9830 | 371 static gchar * |
372 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 373 { |
374 gchar *utf8 = NULL; | |
9595 | 375 |
376 if ((encoding == NULL) || encoding[0] == '\0') { | |
377 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
378 | |
9639 | 379 } else if (!strcmp(encoding, "iso-8859-1") |
380 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 381 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
382 | |
383 } else if (!strcmp(encoding, "unicode-2-0")) { | |
384 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
385 | |
386 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
387 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
10096 | 388 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 389 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
390 } | |
391 | |
392 /* | |
393 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
394 * we have been unable to convert the text to utf-8 from the encoding | |
395 * that was specified. So we check if the text is valid utf-8 then | |
396 * just copy it. | |
397 */ | |
398 if (utf8 == NULL) { | |
9638 | 399 if (textlen != 0 && *text != '\0' |
400 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 401 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 402 else |
9481 | 403 utf8 = g_strndup(text, textlen); |
5129 | 404 } |
405 | |
406 return utf8; | |
407 } | |
408 | |
9830 | 409 static gchar * |
9908 | 410 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 411 { |
412 gchar *ret = NULL; | |
413 GError *err = NULL; | |
414 | |
9908 | 415 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
416 return NULL; | |
417 | |
418 if (strcasecmp("UTF-8", charsetstr)) { | |
419 if (fallback) | |
420 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
421 else | |
422 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
423 if (err != NULL) { | |
424 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
425 charsetstr, err->message); | |
426 g_error_free(err); | |
427 } | |
428 } else { | |
429 if (g_utf8_validate(data, datalen, NULL)) | |
430 ret = g_strndup(data, datalen); | |
431 else | |
432 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
433 } | |
434 | |
435 return ret; | |
436 } | |
437 | |
438 /* | |
439 * We try decoding using two different character sets. The charset | |
440 * specified in the IM determines the order in which we attempt to | |
441 * decode. We do this because there are lots of broken ICQ clients | |
442 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
443 * able to deal with that crap, then people complain like banshees. | |
444 * charsetstr1 is always set to what the correct encoding should be. | |
445 */ | |
446 static gchar * | |
447 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
448 { | |
449 gchar *ret = NULL; | |
450 const gchar *charsetstr1, *charsetstr2; | |
451 | |
452 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 453 |
454 if ((datalen == 0) || (data == NULL)) | |
455 return NULL; | |
456 | |
9908 | 457 if (charset == AIM_CHARSET_UNICODE) { |
458 charsetstr1 = "UCS-2BE"; | |
459 charsetstr2 = "UTF-8"; | |
460 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 461 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 462 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 463 else |
9908 | 464 charsetstr1 = "ISO-8859-1"; |
465 charsetstr2 = "UTF-8"; | |
466 } else if (charset == AIM_CHARSET_ASCII) { | |
467 /* Should just be "ASCII" */ | |
9914 | 468 charsetstr1 = "ASCII"; |
9908 | 469 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
470 } else if (charset == 0x000d) { | |
9830 | 471 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 472 charsetstr1 = "ISO-8859-1"; |
473 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
474 } else { | |
9830 | 475 /* Unknown, hope for valid UTF-8... */ |
9908 | 476 charsetstr1 = "UTF-8"; |
477 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
478 } | |
479 | |
480 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
481 if (ret == NULL) | |
482 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
483 if (ret == NULL) | |
484 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 485 |
486 return ret; | |
487 } | |
488 | |
489 static void | |
490 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 491 gchar **msg, int *msglen_int, |
9830 | 492 fu16_t *charset, fu16_t *charsubset) |
493 { | |
494 OscarData *od = gc->proto_data; | |
495 GaimAccount *account = gaim_connection_get_account(gc); | |
496 GError *err = NULL; | |
497 aim_userinfo_t *userinfo = NULL; | |
498 const gchar *charsetstr; | |
10039 | 499 gsize msglen; |
9830 | 500 |
501 /* Attempt to send as ASCII */ | |
10098 | 502 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 503 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 504 *charset = AIM_CHARSET_ASCII; |
9830 | 505 *charsubset = 0x0000; |
10039 | 506 *msglen_int = msglen; |
9830 | 507 return; |
508 } | |
509 | |
510 /* | |
9908 | 511 * If we're sending to an ICQ user, and they are advertising the |
512 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 513 */ |
9975 | 514 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 515 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
516 | |
517 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
10039 | 518 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
9830 | 519 if (*msg != NULL) { |
520 *charset = AIM_CHARSET_UNICODE; | |
521 *charsubset = 0x0000; | |
10039 | 522 *msglen_int = msglen; |
9830 | 523 return; |
524 } | |
525 } | |
526 | |
527 /* | |
528 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
529 * ICQ then attempt to send as the user specified character encoding. | |
530 */ | |
531 charsetstr = "ISO-8859-1"; | |
9975 | 532 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 533 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
534 | |
10097 | 535 /* |
536 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
537 * can be converted to "charsetstr" | |
538 */ | |
10039 | 539 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 540 if (*msg != NULL) { |
541 *charset = AIM_CHARSET_CUSTOM; | |
542 *charsubset = 0x0000; | |
10039 | 543 *msglen_int = msglen; |
9830 | 544 return; |
545 } | |
546 | |
547 /* | |
548 * Nothing else worked, so send as UCS-2BE. | |
549 */ | |
10039 | 550 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 551 if (*msg != NULL) { |
552 *charset = AIM_CHARSET_UNICODE; | |
553 *charsubset = 0x0000; | |
10039 | 554 *msglen_int = msglen; |
9830 | 555 return; |
556 } | |
557 | |
9908 | 558 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 559 g_error_free(err); |
560 | |
561 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
562 *msg = g_strdup(from); | |
10039 | 563 *msglen_int = strlen(*msg); |
9830 | 564 *charset = AIM_CHARSET_ASCII; |
565 *charsubset = 0x0000; | |
566 return; | |
567 } | |
568 | |
9407 | 569 gchar *oscar_caps_to_string(guint caps) |
8701 | 570 { |
9407 | 571 GString *str; |
572 gchar *tmp; | |
8701 | 573 guint bit = 1; |
574 | |
9407 | 575 str = g_string_new(""); |
576 | |
8701 | 577 if (!caps) { |
578 return NULL; | |
579 } else while (bit <= AIM_CAPS_LAST) { | |
580 if (bit & caps) { | |
581 switch (bit) { | |
582 case AIM_CAPS_BUDDYICON: | |
583 tmp = _("Buddy Icon"); | |
584 break; | |
585 case AIM_CAPS_TALK: | |
586 tmp = _("Voice"); | |
587 break; | |
588 case AIM_CAPS_DIRECTIM: | |
589 tmp = _("AIM Direct IM"); | |
590 break; | |
591 case AIM_CAPS_CHAT: | |
592 tmp = _("Chat"); | |
593 break; | |
594 case AIM_CAPS_GETFILE: | |
595 tmp = _("Get File"); | |
596 break; | |
597 case AIM_CAPS_SENDFILE: | |
598 tmp = _("Send File"); | |
599 break; | |
600 case AIM_CAPS_GAMES: | |
601 case AIM_CAPS_GAMES2: | |
602 tmp = _("Games"); | |
603 break; | |
604 case AIM_CAPS_ADDINS: | |
605 tmp = _("Add-Ins"); | |
606 break; | |
607 case AIM_CAPS_SENDBUDDYLIST: | |
608 tmp = _("Send Buddy List"); | |
609 break; | |
610 case AIM_CAPS_ICQ_DIRECT: | |
611 tmp = _("ICQ Direct Connect"); | |
612 break; | |
613 case AIM_CAPS_APINFO: | |
614 tmp = _("AP User"); | |
615 break; | |
616 case AIM_CAPS_ICQRTF: | |
617 tmp = _("ICQ RTF"); | |
618 break; | |
619 case AIM_CAPS_EMPTY: | |
620 tmp = _("Nihilist"); | |
621 break; | |
622 case AIM_CAPS_ICQSERVERRELAY: | |
623 tmp = _("ICQ Server Relay"); | |
624 break; | |
625 case AIM_CAPS_ICQUTF8OLD: | |
626 tmp = _("Old ICQ UTF8"); | |
627 break; | |
628 case AIM_CAPS_TRILLIANCRYPT: | |
629 tmp = _("Trillian Encryption"); | |
630 break; | |
631 case AIM_CAPS_ICQUTF8: | |
632 tmp = _("ICQ UTF8"); | |
633 break; | |
634 case AIM_CAPS_HIPTOP: | |
635 tmp = _("Hiptop"); | |
636 break; | |
637 case AIM_CAPS_SECUREIM: | |
638 tmp = _("Security Enabled"); | |
639 break; | |
640 case AIM_CAPS_VIDEO: | |
641 tmp = _("Video Chat"); | |
642 break; | |
643 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
644 case AIM_CAPS_ICHATAV: | |
645 tmp = _("iChat AV"); | |
646 break; | |
647 case AIM_CAPS_LIVEVIDEO: | |
648 tmp = _("Live Video"); | |
649 break; | |
650 case AIM_CAPS_CAMERA: | |
651 tmp = _("Camera"); | |
652 break; | |
653 default: | |
654 tmp = NULL; | |
655 break; | |
656 } | |
657 if (tmp) | |
9532 | 658 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 659 } |
660 bit <<= 1; | |
661 } | |
9407 | 662 |
663 return g_string_free(str, FALSE); | |
8701 | 664 } |
665 | |
666 static char *oscar_icqstatus(int state) { | |
667 /* Make a cute little string that shows the status of the dude or dudet */ | |
668 if (state & AIM_ICQ_STATE_CHAT) | |
669 return g_strdup_printf(_("Free For Chat")); | |
670 else if (state & AIM_ICQ_STATE_DND) | |
671 return g_strdup_printf(_("Do Not Disturb")); | |
672 else if (state & AIM_ICQ_STATE_OUT) | |
673 return g_strdup_printf(_("Not Available")); | |
674 else if (state & AIM_ICQ_STATE_BUSY) | |
675 return g_strdup_printf(_("Occupied")); | |
676 else if (state & AIM_ICQ_STATE_AWAY) | |
677 return g_strdup_printf(_("Away")); | |
678 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
679 return g_strdup_printf(_("Web Aware")); | |
680 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
681 return g_strdup_printf(_("Invisible")); | |
682 else | |
683 return g_strdup_printf(_("Online")); | |
684 } | |
685 | |
9973 | 686 static void |
687 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 688 { |
689 gchar *utf8; | |
690 | |
691 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 692 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 693 g_free(utf8); |
694 } | |
695 } | |
696 | |
9973 | 697 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 698 { |
10042 | 699 OscarData *od; |
700 GaimAccount *account; | |
701 GaimPresence *presence; | |
702 GaimPresence *buddy_presence; | |
8701 | 703 GaimGroup *g = NULL; |
704 struct buddyinfo *bi = NULL; | |
705 char *tmp; | |
706 | |
10042 | 707 od = gc->proto_data; |
708 account = gaim_connection_get_account(gc); | |
709 presence = gaim_account_get_presence(account); | |
710 buddy_presence = gaim_buddy_get_presence(b); | |
711 | |
712 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 713 return; |
714 | |
715 if (userinfo == NULL) | |
716 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
717 | |
718 if (b == NULL) | |
10042 | 719 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 720 |
721 if (b != NULL) | |
722 g = gaim_find_buddys_group(b); | |
723 | |
724 if (userinfo != NULL) | |
725 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
726 | |
8733 | 727 if (b != NULL) { |
10042 | 728 if (gaim_presence_is_online(buddy_presence)) { |
9975 | 729 if (aim_sn_is_icq(b->name)) { |
8733 | 730 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
731 oscar_string_append(str, newline, _("Status"), tmp); | |
732 g_free(tmp); | |
733 } | |
734 } else { | |
9625 | 735 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 736 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
737 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
738 else | |
739 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 740 } |
8733 | 741 } |
8701 | 742 |
743 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 744 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 745 (bi->ipaddr & 0xff000000) >> 24, |
746 (bi->ipaddr & 0x00ff0000) >> 16, | |
747 (bi->ipaddr & 0x0000ff00) >> 8, | |
748 (bi->ipaddr & 0x000000ff)); | |
749 oscar_string_append(str, newline, _("IP Address"), tmp); | |
750 g_free(tmp); | |
751 } | |
752 | |
753 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
754 tmp = oscar_caps_to_string(userinfo->capabilities); | |
755 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 756 g_free(tmp); |
8701 | 757 } |
758 | |
759 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
760 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
761 if (tmp != NULL) { | |
9625 | 762 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 763 g_free(tmp); |
9625 | 764 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
765 g_free(tmp2); | |
8701 | 766 } |
767 } | |
768 | |
10042 | 769 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_presence_is_available(presence)) { |
8701 | 770 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
771 oscar_string_append(str, newline, _("Available"), tmp); | |
772 g_free(tmp); | |
773 } | |
774 } | |
775 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
776 static char *extract_name(const char *name) { |
4121 | 777 char *tmp, *x; |
2086 | 778 int i, j; |
4120 | 779 |
780 if (!name) | |
4121 | 781 return NULL; |
10042 | 782 |
4120 | 783 x = strchr(name, '-'); |
4121 | 784 |
2086 | 785 if (!x) return NULL; |
786 x = strchr(++x, '-'); | |
787 if (!x) return NULL; | |
788 tmp = g_strdup(++x); | |
789 | |
790 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
791 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
792 if (x[i] != '%') { |
2086 | 793 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
794 continue; |
2086 | 795 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
796 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
797 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
798 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 799 } |
800 | |
801 tmp[j] = 0; | |
802 return tmp; | |
803 } | |
804 | |
5575 | 805 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 806 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 807 struct chat_connection *c = NULL; |
808 | |
809 while (g) { | |
810 c = (struct chat_connection *)g->data; | |
811 if (c->id == id) | |
812 break; | |
813 g = g->next; | |
814 c = NULL; | |
815 } | |
816 | |
817 return c; | |
818 } | |
819 | |
5575 | 820 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
|
821 aim_conn_t *conn) { |
7283 | 822 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 823 struct chat_connection *c = NULL; |
824 | |
825 while (g) { | |
826 c = (struct chat_connection *)g->data; | |
827 if (c->conn == conn) | |
828 break; | |
829 g = g->next; | |
830 c = NULL; | |
831 } | |
832 | |
833 return c; | |
834 } | |
835 | |
8219 | 836 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
837 GaimConversation *conv) { | |
838 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
839 struct chat_connection *c = NULL; | |
840 | |
841 while (g) { | |
842 c = (struct chat_connection *)g->data; | |
8733 | 843 if (c->conv == conv) |
8219 | 844 break; |
845 g = g->next; | |
846 c = NULL; | |
847 } | |
848 | |
849 return c; | |
850 } | |
851 | |
8971 | 852 /***************************************************************************** |
853 * Begin scary direct im stuff | |
854 *****************************************************************************/ | |
855 | |
856 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
857 GSList *d = od->direct_ims; | |
858 struct oscar_direct_im *m = NULL; | |
859 | |
860 while (d) { | |
861 m = (struct oscar_direct_im *)d->data; | |
862 if (!aim_sncmp(who, m->name)) | |
863 return m; | |
864 d = d->next; | |
865 } | |
866 | |
867 return NULL; | |
868 } | |
869 | |
870 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
871 { | |
872 gaim_debug_info("oscar", | |
873 "destroying Direct IM for %s.\n", dim->name); | |
874 | |
875 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 876 if (dim->gpc_pend) { |
877 dim->killme = TRUE; | |
878 return; | |
879 } | |
8971 | 880 if (dim->watcher) |
881 gaim_input_remove(dim->watcher); | |
882 if (dim->conn) { | |
883 aim_conn_close(dim->conn); | |
884 aim_conn_kill(od->sess, &dim->conn); | |
885 } | |
886 g_free(dim); | |
887 } | |
888 | |
889 /* the only difference between this and destroy is this writes a conv message */ | |
890 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
891 { | |
892 GaimConversation *conv; | |
893 char buf[256]; | |
894 | |
895 gaim_debug_info("oscar", | |
896 "%s disconnected Direct IM.\n", dim->name); | |
897 | |
898 if (dim->connected) | |
899 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 900 else |
8971 | 901 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
902 | |
10246 | 903 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
904 gaim_connection_get_account(dim->gc)); | |
8971 | 905 if (conv) { |
906 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 907 gaim_conversation_update_progress(conv, 0); |
8971 | 908 } else { |
909 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
910 } | |
911 | |
912 oscar_direct_im_destroy(od, dim); | |
913 | |
914 return; | |
915 } | |
916 | |
917 /* oops i made two of these. this one just calls the other one. */ | |
918 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
919 { | |
920 GaimConnection *gc = sess->aux_data; | |
921 OscarData *od = (OscarData *)gc->proto_data; | |
922 struct oscar_direct_im *dim; | |
923 char *sn; | |
924 | |
925 sn = g_strdup(aim_odc_getsn(conn)); | |
926 dim = oscar_direct_im_find(od, sn); | |
927 oscar_direct_im_disconnect(od, dim); | |
928 g_free(sn); | |
929 } | |
930 | |
931 static void destroy_direct_im_request(struct ask_direct *d) { | |
932 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
933 | |
934 g_free(d->sn); | |
935 g_free(d); | |
936 } | |
937 | |
938 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
939 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
940 struct oscar_direct_im *dim = data; | |
941 GaimConnection *gc = dim->gc; | |
942 OscarData *od = gc->proto_data; | |
943 GaimConversation *conv; | |
944 char buf[256]; | |
945 struct sockaddr name; | |
946 socklen_t name_len = 1; | |
947 | |
948 g_return_if_fail(gc != NULL); | |
949 | |
8978 | 950 dim->gpc_pend = FALSE; |
951 if (dim->killme) { | |
952 oscar_direct_im_destroy(od, dim); | |
953 return; | |
954 } | |
955 | |
8971 | 956 if (!g_list_find(gaim_connections_get_all(), gc)) { |
957 oscar_direct_im_destroy(od, dim); | |
958 return; | |
959 } | |
960 | |
961 if (source < 0) { | |
8984 | 962 if (dim->donttryagain) { |
963 oscar_direct_im_disconnect(od, dim); | |
964 return; | |
965 } else { | |
966 fu8_t cookie[8]; | |
967 char *who = g_strdup(dim->name); | |
968 const char *tmp = aim_odc_getcookie(dim->conn); | |
969 | |
970 memcpy(cookie, tmp, 8); | |
971 oscar_direct_im_destroy(od, dim); | |
972 oscar_direct_im_initiate(gc, who, cookie); | |
973 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
974 g_free(who); | |
975 return; | |
976 } | |
8971 | 977 } |
978 | |
979 dim->conn->fd = source; | |
980 aim_conn_completeconnect(od->sess, dim->conn); | |
981 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
982 | |
983 /* This is the best way to see if we're connected or not */ | |
8983 | 984 /* Is this really needed? */ |
8971 | 985 if (getpeername(source, &name, &name_len) == 0) { |
986 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
987 dim->connected = TRUE; | |
988 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 989 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
990 } else { | |
8984 | 991 if (dim->donttryagain) { |
992 oscar_direct_im_disconnect(od, dim); | |
993 return; | |
994 } else { | |
995 fu8_t cookie[8]; | |
996 char *who = g_strdup(dim->name); | |
997 const char *tmp = aim_odc_getcookie(dim->conn); | |
998 | |
999 memcpy(cookie, tmp, 8); | |
1000 oscar_direct_im_destroy(od, dim); | |
1001 oscar_direct_im_initiate(gc, who, cookie); | |
1002 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1003 g_free(who); | |
1004 return; | |
1005 } | |
8983 | 1006 } |
1007 | |
1008 | |
8971 | 1009 } |
1010 | |
1011 static void accept_direct_im_request(struct ask_direct *d) { | |
1012 GaimConnection *gc = d->gc; | |
1013 OscarData *od; | |
1014 struct oscar_direct_im *dim; | |
1015 char *host; int port = 5190; | |
1016 int i, rc; | |
8982 | 1017 char *tmp; |
1018 GaimConversation *conv; | |
8971 | 1019 |
1020 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1021 destroy_direct_im_request(d); | |
1022 return; | |
1023 } | |
1024 | |
1025 od = (OscarData *)gc->proto_data; | |
1026 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1027 | |
1028 dim = oscar_direct_im_find(od, d->sn); | |
1029 if (dim && dim->connected) { | |
1030 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1031 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1032 return; | |
1033 } | |
1034 dim = g_new0(struct oscar_direct_im, 1); | |
1035 dim->gc = d->gc; | |
8984 | 1036 dim->donttryagain = d->donttryagain; |
8971 | 1037 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1038 | |
1039 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1040 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1041 if (!dim->conn) { | |
1042 oscar_direct_im_disconnect(od, dim); | |
1043 destroy_direct_im_request(d); | |
1044 return; | |
1045 } | |
1046 | |
1047 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1048 gaim_odc_incoming, 0); | |
1049 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1050 gaim_odc_typing, 0); | |
1051 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1052 gaim_odc_update_ui, 0); | |
1053 | |
1054 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1055 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1056 if (d->ip[i] == ':') { | |
1057 port = atoi(&(d->ip[i+1])); | |
1058 break; | |
1059 } | |
1060 } | |
1061 host = g_strndup(d->ip, i); | |
1062 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1063 dim->gpc_pend = TRUE; |
8971 | 1064 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1065 |
1066 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1067 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1068 port); | |
1069 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1070 g_free(tmp); | |
8983 | 1071 |
8971 | 1072 g_free(host); |
1073 if (rc < 0) { | |
8978 | 1074 dim->gpc_pend = FALSE; |
8971 | 1075 oscar_direct_im_disconnect(od, dim); |
1076 destroy_direct_im_request(d); | |
1077 return; | |
1078 } | |
1079 | |
1080 destroy_direct_im_request(d); | |
1081 | |
1082 return; | |
1083 } | |
1084 | |
1085 /* | |
1086 * We have just established a socket with the other dude, so set up some handlers. | |
1087 */ | |
1088 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1089 GaimConnection *gc = sess->aux_data; |
7283 | 1090 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1091 GaimConversation *conv; |
8971 | 1092 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1093 char buf[256]; |
8971 | 1094 char *sn; |
1095 va_list ap; | |
1096 aim_conn_t *newconn, *listenerconn; | |
1097 | |
1098 va_start(ap, fr); | |
1099 newconn = va_arg(ap, aim_conn_t *); | |
1100 listenerconn = va_arg(ap, aim_conn_t *); | |
1101 va_end(ap); | |
1102 | |
1103 aim_conn_close(listenerconn); | |
1104 aim_conn_kill(sess, &listenerconn); | |
1105 | |
1106 sn = g_strdup(aim_odc_getsn(newconn)); | |
1107 | |
1108 gaim_debug_info("oscar", | |
1109 "DirectIM: initiate success to %s\n", sn); | |
1110 dim = oscar_direct_im_find(od, sn); | |
1111 | |
1112 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1113 gaim_input_remove(dim->watcher); | |
1114 dim->conn = newconn; | |
1115 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1116 dim->connected = TRUE; | |
1117 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1118 g_free(sn); | |
1119 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1120 | |
1121 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1122 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1123 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1124 | |
1125 return 1; | |
1126 } | |
1127 | |
1128 /* | |
1129 * This is called when each chunk of an image is received. It can be used to | |
1130 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1131 * nasty, you sicko. | |
1132 */ | |
1133 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1134 va_list ap; | |
1135 char *sn; | |
1136 double percent; | |
1137 GaimConnection *gc = sess->aux_data; | |
1138 OscarData *od = (OscarData *)gc->proto_data; | |
1139 GaimConversation *c; | |
1140 struct oscar_direct_im *dim; | |
1141 | |
1142 va_start(ap, fr); | |
1143 sn = va_arg(ap, char *); | |
1144 percent = va_arg(ap, double); | |
1145 va_end(ap); | |
1146 | |
1147 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1148 return 1; | |
1149 if (dim->watcher) { | |
1150 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1151 /* The callback will callback? I don't get how that would happen here. */ | |
1152 dim->watcher = 0; | |
1153 } | |
1154 | |
10246 | 1155 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1156 gaim_connection_get_account(gc)); | |
8971 | 1157 if (c != NULL) |
1158 gaim_conversation_update_progress(c, percent); | |
1159 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1160 oscar_callback, dim->conn); | |
1161 | |
1162 return 1; | |
1163 } | |
1164 | |
1165 /* | |
1166 * This is called after a direct IM has been received in its entirety. This | |
1167 * function is passed a long chunk of data which contains the IM with any | |
1168 * data chunks (images) appended to it. | |
1169 * | |
1170 * This function rips out all the data chunks and creates an imgstore for | |
1171 * each one. In order to do this, it first goes through the IM and takes | |
1172 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1173 * with one compatible with the imgstore Gaim core code. For each one, we | |
1174 * then read in chunks of data from the end of the message and actually | |
1175 * create the img store using the given data. | |
1176 * | |
1177 * For somewhat easy reference, here's a sample message | |
1178 * (without the whitespace and asterisks): | |
1179 * | |
1180 * <HTML><BODY BGCOLOR="#ffffff"> | |
1181 * <FONT LANG="0"> | |
1182 * This is a really stupid picture:<BR> | |
1183 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1184 * Yeah it is<BR> | |
1185 * Here is another one:<BR> | |
1186 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1187 * </FONT> | |
1188 * </BODY></HTML> | |
1189 * <BINARY> | |
1190 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1191 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1192 * </BINARY> | |
1193 */ | |
1194 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1195 GaimConnection *gc = sess->aux_data; | |
1196 GaimConvImFlags imflags = 0; | |
1197 gchar *utf8; | |
1198 GString *newmsg = g_string_new(""); | |
1199 GSList *images = NULL; | |
1200 va_list ap; | |
1201 const char *sn, *msg, *msgend, *binary; | |
1202 size_t len; | |
1203 int encoding, isawaymsg; | |
1204 | |
1205 va_start(ap, fr); | |
1206 sn = va_arg(ap, const char *); | |
1207 msg = va_arg(ap, const char *); | |
1208 len = va_arg(ap, size_t); | |
1209 encoding = va_arg(ap, int); | |
1210 isawaymsg = va_arg(ap, int); | |
1211 va_end(ap); | |
1212 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1213 |
8660 | 1214 gaim_debug_info("oscar", |
8971 | 1215 "Got DirectIM message from %s\n", sn); |
1216 | |
1217 if (isawaymsg) | |
1218 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1219 | |
1220 /* message has a binary trailer */ | |
1221 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1222 GData *attribs; | |
1223 const char *tmp, *start, *end, *last = NULL; | |
1224 | |
1225 tmp = msg; | |
1226 | |
1227 /* for each valid image tag... */ | |
1228 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1229 const char *id, *src, *datasize; | |
1230 const char *tag = NULL, *data = NULL; | |
1231 size_t size; | |
1232 int imgid = 0; | |
1233 | |
1234 /* update the location of the last img tag */ | |
1235 last = end; | |
1236 | |
1237 /* grab attributes */ | |
1238 id = g_datalist_get_data(&attribs, "id"); | |
1239 src = g_datalist_get_data(&attribs, "src"); | |
1240 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1241 | |
1242 /* if we have id & datasize, build the data tag */ | |
1243 if (id && datasize) | |
1244 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1245 | |
1246 /* if we have a tag, find the start of the data */ | |
1247 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1248 data += strlen(tag); | |
1249 | |
1250 /* check the data is here and store it */ | |
1251 if (data + (size = atoi(datasize)) <= msgend) | |
1252 imgid = gaim_imgstore_add(data, size, src); | |
1253 | |
1254 /* | |
1255 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1256 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1257 */ | |
1258 /* if we have a stored image... */ | |
1259 if (imgid) { | |
1260 /* append the message up to the tag */ | |
1261 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1262 if (utf8 != NULL) { | |
1263 newmsg = g_string_append(newmsg, utf8); | |
1264 g_free(utf8); | |
1265 } | |
1266 | |
1267 /* write the new image tag */ | |
1268 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1269 | |
1270 /* and record the image number */ | |
1271 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1272 } else { | |
1273 /* otherwise, copy up to the end of the tag */ | |
1274 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1275 if (utf8 != NULL) { | |
1276 newmsg = g_string_append(newmsg, utf8); | |
1277 g_free(utf8); | |
1278 } | |
1279 } | |
1280 | |
1281 /* clear the attribute list */ | |
1282 g_datalist_clear(&attribs); | |
1283 | |
1284 /* continue from the end of the tag */ | |
1285 tmp = end + 1; | |
1286 } | |
1287 | |
1288 /* append any remaining message data (without the > :-) */ | |
1289 if (last++ && (last < binary)) | |
1290 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1291 | |
1292 /* set the flag if we caught any images */ | |
1293 if (images) | |
1294 imflags |= GAIM_CONV_IM_IMAGES; | |
1295 } else { | |
1296 g_string_append_len(newmsg, msg, len); | |
1297 } | |
1298 | |
1299 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1300 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1301 | |
1302 /* free up the message */ | |
1303 g_string_free(newmsg, TRUE); | |
1304 | |
1305 /* unref any images we allocated */ | |
1306 if (images) { | |
1307 GSList *tmp; | |
1308 int id; | |
1309 | |
1310 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1311 id = GPOINTER_TO_INT(tmp->data); | |
1312 gaim_imgstore_unref(id); | |
1313 } | |
1314 | |
1315 g_slist_free(images); | |
1316 } | |
1317 | |
1318 return 1; | |
1319 } | |
1320 | |
1321 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1322 va_list ap; | |
1323 char *sn; | |
1324 int typing; | |
1325 GaimConnection *gc = sess->aux_data; | |
1326 | |
1327 va_start(ap, fr); | |
1328 sn = va_arg(ap, char *); | |
1329 typing = va_arg(ap, int); | |
1330 va_end(ap); | |
1331 | |
1332 if (typing == 0x0002) { | |
1333 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1334 gaim_debug_info("oscar", | |
1335 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1336 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1337 } else if (typing == 0x0001) | |
1338 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1339 else | |
1340 serv_got_typing_stopped(gc, sn); | |
1341 return 1; | |
1342 } | |
1343 | |
1344 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1345 char *buf; | |
1346 size_t len; | |
1347 int ret; | |
1348 GString *msg = g_string_new("<HTML><BODY>"); | |
1349 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1350 GData *attribs; | |
1351 const char *start, *end, *last; | |
1352 int oscar_id = 0; | |
1353 | |
1354 last = message; | |
1355 | |
1356 /* for each valid IMG tag... */ | |
1357 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1358 GaimStoredImage *image = NULL; | |
1359 const char *id; | |
1360 | |
1361 if (start - last) { | |
1362 g_string_append_len(msg, last, start - last); | |
1363 } | |
1364 | |
1365 id = g_datalist_get_data(&attribs, "id"); | |
1366 | |
1367 /* ... if it refers to a valid gaim image ... */ | |
1368 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1369 /* ... append the message from start to the tag ... */ | |
9126 | 1370 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1371 const char *filename = gaim_imgstore_get_filename(image); |
1372 gpointer imgdata = gaim_imgstore_get_data(image); | |
1373 | |
1374 oscar_id++; | |
1375 | |
1376 /* ... insert a new img tag with the oscar id ... */ | |
1377 if (filename) | |
1378 g_string_append_printf(msg, | |
9126 | 1379 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1380 filename, oscar_id, size); |
1381 else | |
1382 g_string_append_printf(msg, | |
9126 | 1383 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1384 oscar_id, size); |
1385 | |
1386 /* ... and append the data to the binary section ... */ | |
9126 | 1387 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1388 oscar_id, size); |
1389 data = g_string_append_len(data, imgdata, size); | |
1390 data = g_string_append(data, "</DATA>"); | |
1391 } | |
1392 /* If the tag is invalid, skip it, thus no else here */ | |
1393 | |
1394 g_datalist_clear(&attribs); | |
1395 | |
1396 /* continue from the end of the tag */ | |
1397 last = end + 1; | |
1398 } | |
1399 | |
1400 /* append any remaining message data (without the > :-) */ | |
1401 if (last && *last) | |
1402 msg = g_string_append(msg, last); | |
1403 | |
1404 /* if we inserted any images in the binary section, append it */ | |
1405 if (oscar_id) { | |
1406 msg = g_string_append_len(msg, data->str, data->len); | |
1407 msg = g_string_append(msg, "</BINARY>"); | |
1408 } | |
1409 | |
1410 len = msg->len; | |
1411 buf = msg->str; | |
1412 g_string_free(msg, FALSE); | |
1413 g_string_free(data, TRUE); | |
1414 | |
1415 | |
1416 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1417 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1418 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1419 else | |
1420 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1421 | |
1422 g_free(buf); | |
1423 | |
1424 return ret; | |
1425 } | |
1426 | |
1427 struct ask_do_dir_im { | |
1428 char *who; | |
1429 GaimConnection *gc; | |
1430 }; | |
1431 | |
1432 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1433 g_free(data->who); | |
1434 g_free(data); | |
1435 } | |
1436 | |
8983 | 1437 /* this function is used to initiate a direct im session with someone. |
1438 * we start listening on a port and send a request. they either connect | |
1439 * or send some kind of reply. If they can't connect, they ask us to | |
1440 * connect to them, and so we do that. | |
1441 * | |
1442 * this function will also get called if the other side initiate's a direct | |
1443 * im and we try to connect and fail. in that case cookie will not be null. | |
1444 * | |
1445 * note that cookie is an 8 byte string that isn't NULL terminated | |
1446 */ | |
1447 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1448 OscarData *od; |
1449 struct oscar_direct_im *dim; | |
1450 int listenfd; | |
8982 | 1451 const char *ip; |
8971 | 1452 |
1453 od = (OscarData *)gc->proto_data; | |
1454 | |
8983 | 1455 dim = oscar_direct_im_find(od, who); |
8971 | 1456 if (dim) { |
1457 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1458 oscar_direct_im_disconnect(od, dim); | |
1459 gaim_debug_info("oscar", | |
1460 "Gave up on old direct IM, trying again\n"); | |
1461 } else { | |
1462 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1463 return; |
8971 | 1464 } |
1465 } | |
1466 dim = g_new0(struct oscar_direct_im, 1); | |
1467 dim->gc = gc; | |
8983 | 1468 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1469 |
1470 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1471 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1472 if (listenfd >= 0) |
1473 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1474 if (dim->conn != NULL) { |
8982 | 1475 char *tmp; |
1476 GaimConversation *conv; | |
1477 | |
8971 | 1478 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1479 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1480 oscar_callback, dim->conn); | |
1481 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1482 gaim_odc_initiate, 0); | |
8982 | 1483 |
8983 | 1484 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1485 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1486 gaim_network_get_port_from_fd(listenfd)); |
1487 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1488 g_free(tmp); | |
8971 | 1489 } else { |
1490 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1491 oscar_direct_im_destroy(od, dim); | |
1492 } | |
8983 | 1493 } |
1494 | |
1495 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1496 GaimConnection *gc = data->gc; | |
1497 | |
1498 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1499 g_free(data->who); | |
1500 g_free(data); | |
1501 return; | |
1502 } | |
1503 | |
1504 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1505 g_free(data->who); |
1506 g_free(data); | |
1507 } | |
1508 | |
1509 /* this is the right click menu cb thingy */ | |
9030 | 1510 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1511 | |
1512 GaimBuddy *buddy; | |
1513 GaimConnection *gc; | |
8971 | 1514 gchar *buf; |
9030 | 1515 struct ask_do_dir_im *data; |
1516 | |
1517 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1518 | |
1519 buddy = (GaimBuddy *) node; | |
1520 gc = gaim_account_get_connection(buddy->account); | |
1521 | |
1522 data = g_new0(struct ask_do_dir_im, 1); | |
1523 data->who = g_strdup(buddy->name); | |
8971 | 1524 data->gc = gc; |
9030 | 1525 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1526 buddy->name); | |
8971 | 1527 |
1528 gaim_request_action(gc, NULL, buf, | |
9030 | 1529 _("Because this reveals your IP address, it " |
1530 "may be considered a privacy risk. Do you " | |
1531 "wish to continue?"), | |
1532 0, data, 2, | |
1533 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1534 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1535 g_free(buf); |
1536 } | |
1537 | |
1538 /***************************************************************************** | |
1539 * End scary direct im stuff | |
1540 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1541 |
4617 | 1542 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1543 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1544 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1545 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1546 OscarData *od; |
2086 | 1547 |
1548 if (!gc) { | |
8660 | 1549 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1550 "oscar callback for closed connection (1).\n"); |
2086 | 1551 return; |
1552 } | |
1553 | |
7283 | 1554 od = (OscarData *)gc->proto_data; |
2086 | 1555 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1556 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1557 /* oh boy. this is probably bad. i guess the only thing we |
1558 * can really do is return? */ | |
8660 | 1559 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1560 "oscar callback for closed connection (2).\n"); |
8660 | 1561 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1562 return; |
1563 } | |
1564 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1565 if (condition & GAIM_INPUT_READ) { |
4617 | 1566 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1567 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1568 "got information on rendezvous listener\n"); |
4617 | 1569 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1570 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1571 "connection error (rendezvous listener)\n"); |
4617 | 1572 aim_conn_kill(od->sess, &conn); |
8446 | 1573 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1574 } |
1575 } else { | |
4617 | 1576 if (aim_get_command(od->sess, conn) >= 0) { |
1577 aim_rxdispatch(od->sess); | |
6029 | 1578 if (od->killme) { |
8660 | 1579 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1580 return; |
1581 } | |
2086 | 1582 } else { |
1583 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1584 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1585 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1586 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1587 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1588 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1589 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1590 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1591 char *buf; |
8660 | 1592 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1593 "disconnected from chat room %s\n", c->name); |
2086 | 1594 c->conn = NULL; |
1595 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1596 gaim_input_remove(c->inpa); |
2086 | 1597 c->inpa = 0; |
1598 c->fd = -1; | |
4617 | 1599 aim_conn_kill(od->sess, &conn); |
5420 | 1600 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1601 if (conv) |
1602 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1603 else | |
1604 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1605 g_free(buf); |
2086 | 1606 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1607 if (od->cnpa > 0) |
1608 gaim_input_remove(od->cnpa); | |
1609 od->cnpa = 0; | |
8660 | 1610 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1611 "removing chatnav input watcher\n"); |
4617 | 1612 while (od->create_rooms) { |
1613 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1614 g_free(cr->name); |
4617 | 1615 od->create_rooms = |
1616 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1617 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1618 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1619 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1620 NULL); |
2086 | 1621 } |
4617 | 1622 aim_conn_kill(od->sess, &conn); |
2086 | 1623 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1624 if (od->paspa > 0) |
1625 gaim_input_remove(od->paspa); | |
1626 od->paspa = 0; | |
8660 | 1627 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1628 "removing authconn input watcher\n"); |
4617 | 1629 aim_conn_kill(od->sess, &conn); |
3694 | 1630 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1631 if (od->emlpa > 0) |
1632 gaim_input_remove(od->emlpa); | |
1633 od->emlpa = 0; | |
8660 | 1634 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1635 "removing email input watcher\n"); |
4617 | 1636 aim_conn_kill(od->sess, &conn); |
4804 | 1637 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1638 if (od->icopa > 0) | |
1639 gaim_input_remove(od->icopa); | |
1640 od->icopa = 0; | |
8660 | 1641 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1642 "removing icon input watcher\n"); |
4804 | 1643 aim_conn_kill(od->sess, &conn); |
2086 | 1644 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1645 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1646 gaim_odc_disconnect(od->sess, conn); |
1647 aim_conn_kill(od->sess, &conn); | |
2086 | 1648 } else { |
8660 | 1649 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1650 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1651 conn->type); |
4617 | 1652 aim_conn_kill(od->sess, &conn); |
2086 | 1653 } |
1654 } | |
1655 } | |
1656 } | |
1657 } | |
1658 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1659 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1660 GaimConnection *gc = sess->aux_data; |
7285 | 1661 gchar *s = g_strdup_vprintf(format, va); |
1662 gchar *buf; | |
1663 | |
1664 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1665 gaim_debug_info("oscar", buf); |
7285 | 1666 if (buf[strlen(buf)-1] != '\n') |
8660 | 1667 gaim_debug_info(NULL, "\n"); |
7285 | 1668 g_free(buf); |
2086 | 1669 g_free(s); |
1670 } | |
1671 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1672 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1673 { |
5575 | 1674 GaimConnection *gc = data; |
7283 | 1675 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1676 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1677 aim_conn_t *conn; |
2086 | 1678 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1679 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1680 close(source); |
1681 return; | |
1682 } | |
1683 | |
4617 | 1684 od = gc->proto_data; |
1685 sess = od->sess; | |
2086 | 1686 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1687 conn->fd = source; |
2086 | 1688 |
1689 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1690 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1691 return; |
1692 } | |
1693 | |
1694 aim_conn_completeconnect(sess, conn); | |
4617 | 1695 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1696 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1697 | |
8660 | 1698 gaim_debug_info("oscar", |
7282 | 1699 "Screen name sent, waiting for response\n"); |
7283 | 1700 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1701 ck[1] = 0x65; |
2086 | 1702 } |
1703 | |
5575 | 1704 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1705 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1706 aim_conn_t *conn; |
5575 | 1707 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1708 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1709 |
8660 | 1710 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1711 |
8437 | 1712 if (!aim_snvalid(gaim_account_get_username(account))) { |
1713 gchar *buf; | |
8590 | 1714 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 | 1715 gaim_connection_error(gc, buf); |
1716 g_free(buf); | |
1717 } | |
1718 | |
9975 | 1719 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1720 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1721 } else { |
6622 | 1722 gc->flags |= GAIM_CONNECTION_HTML; |
1723 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1724 } |
5836 | 1725 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1726 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1727 sess = g_new0(aim_session_t, 1); |
7285 | 1728 aim_session_init(sess, TRUE, 0); |
2086 | 1729 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1730 /* |
1731 * We need an immediate queue because we don't use a while-loop | |
1732 * to see if things need to be sent. | |
1733 */ | |
2086 | 1734 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1735 od->sess = sess; |
2086 | 1736 sess->aux_data = gc; |
1737 | |
9935 | 1738 /* Connect to core Gaim signals */ |
10087 | 1739 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1740 |
2086 | 1741 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1742 if (conn == NULL) { | |
8660 | 1743 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1744 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1745 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1746 return; |
1747 } | |
1748 | |
4649 | 1749 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1750 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1751 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1752 | |
1753 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1754 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1755 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1756 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1757 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1758 return; |
1759 } | |
7282 | 1760 |
7283 | 1761 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1762 ck[0] = 0x5a; |
5575 | 1763 } |
1764 | |
1765 static void oscar_close(GaimConnection *gc) { | |
7283 | 1766 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1767 |
1768 while (od->oscar_chats) { | |
1769 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1770 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1771 gaim_input_remove(n->inpa); |
2086 | 1772 g_free(n->name); |
1773 g_free(n->show); | |
4617 | 1774 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1775 g_free(n); |
1776 } | |
4617 | 1777 while (od->direct_ims) { |
8971 | 1778 struct oscar_direct_im *n = od->direct_ims->data; |
1779 oscar_direct_im_destroy(od, n); | |
2086 | 1780 } |
4617 | 1781 /* BBB */ |
1782 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1783 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1784 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1785 gaim_xfer_cancel_local(xfer); |
3630 | 1786 } |
4804 | 1787 while (od->requesticon) { |
1788 char *sn = od->requesticon->data; | |
1789 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1790 free(sn); | |
1791 } | |
4738 | 1792 g_hash_table_destroy(od->buddyinfo); |
4617 | 1793 while (od->create_rooms) { |
1794 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1795 g_free(cr->name); |
4617 | 1796 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1797 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1798 } |
4617 | 1799 if (od->email) |
1800 g_free(od->email); | |
1801 if (od->newp) | |
1802 g_free(od->newp); | |
1803 if (od->oldp) | |
1804 g_free(od->oldp); | |
2086 | 1805 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1806 gaim_input_remove(gc->inpa); |
4617 | 1807 if (od->cnpa > 0) |
1808 gaim_input_remove(od->cnpa); | |
1809 if (od->paspa > 0) | |
1810 gaim_input_remove(od->paspa); | |
1811 if (od->emlpa > 0) | |
1812 gaim_input_remove(od->emlpa); | |
4804 | 1813 if (od->icopa > 0) |
1814 gaim_input_remove(od->icopa); | |
6907 | 1815 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1816 gaim_timeout_remove(od->icontimer); |
8341 | 1817 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1818 gaim_timeout_remove(od->getblisttimer); |
8341 | 1819 if (od->getinfotimer > 0) |
1820 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1821 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1822 |
4617 | 1823 aim_session_kill(od->sess); |
1824 g_free(od->sess); | |
1825 od->sess = NULL; | |
2086 | 1826 g_free(gc->proto_data); |
1827 gc->proto_data = NULL; | |
8660 | 1828 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1829 } |
1830 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1831 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1832 GaimConnection *gc = data; |
7283 | 1833 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1834 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1835 aim_conn_t *bosconn; |
2086 | 1836 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1837 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1838 close(source); |
1839 return; | |
1840 } | |
1841 | |
4617 | 1842 od = gc->proto_data; |
1843 sess = od->sess; | |
1844 bosconn = od->conn; | |
4366 | 1845 bosconn->fd = source; |
2086 | 1846 |
1847 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1848 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1849 return; |
1850 } | |
1851 | |
1852 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1853 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1854 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1855 gaim_connection_update_progress(gc, |
7283 | 1856 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1857 ck[4] = 0x61; |
2086 | 1858 } |
1859 | |
4617 | 1860 /* BBB */ |
4656 | 1861 /* |
1862 * This little area in oscar.c is the nexus of file transfer code, | |
1863 * so I wrote a little explanation of what happens. I am such a | |
1864 * ninja. | |
1865 * | |
1866 * The series of events for a file send is: | |
1867 * -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
|
1868 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1869 * listening socket, then asks the remote user to connect to us (and |
1870 * gives them the file name, port, IP, etc.) | |
1871 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1872 * in oscar_sendfile_estblsh) | |
1873 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1874 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1875 * connection. | |
1876 * -We get drunk because file transfer kicks ass. | |
1877 * | |
1878 * The series of events for a file receive is: | |
1879 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1880 * -Gaim user selects file to name and location to save file to and | |
1881 * oscar_xfer_init is called | |
1882 * -It connects to the remote user using the IP they gave us earlier | |
1883 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1884 * them an AIM_CB_OFT_ACK. | |
1885 * -They begin to send us lots of raw data. | |
1886 * -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
|
1887 * the connection. |
4656 | 1888 */ |
1889 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1890 | |
8446 | 1891 /* |
1892 * Miscellaneous xfer functions | |
1893 */ | |
1894 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1895 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1896 GaimXfer *xfer; |
5146 | 1897 struct aim_oft_info *oft_info; |
4656 | 1898 |
1899 while (fts) { | |
1900 xfer = fts->data; | |
5146 | 1901 oft_info = xfer->data; |
1902 | |
8446 | 1903 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1904 return xfer; |
1905 | |
1906 fts = g_slist_next(fts); | |
1907 } | |
1908 | |
1909 return NULL; | |
1910 } | |
1911 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1912 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1913 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1914 GaimXfer *xfer; |
5146 | 1915 struct aim_oft_info *oft_info; |
4656 | 1916 |
1917 while (fts) { | |
1918 xfer = fts->data; | |
5146 | 1919 oft_info = xfer->data; |
1920 | |
1921 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1922 return xfer; |
1923 | |
1924 fts = g_slist_next(fts); | |
1925 } | |
1926 | |
1927 return NULL; | |
1928 } | |
1929 | |
8446 | 1930 static void oscar_xfer_end(GaimXfer *xfer) |
1931 { | |
1932 struct aim_oft_info *oft_info = xfer->data; | |
1933 GaimConnection *gc = oft_info->sess->aux_data; | |
1934 OscarData *od = gc->proto_data; | |
1935 | |
8660 | 1936 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1937 |
1938 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1939 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1940 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1941 } | |
1942 | |
1943 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1944 aim_oft_destroyinfo(oft_info); | |
1945 xfer->data = NULL; | |
1946 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1947 } | |
1948 | |
1949 /* | |
1950 * xfer functions used when receiving files | |
1951 */ | |
1952 | |
1953 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1954 { | |
1955 struct aim_oft_info *oft_info = xfer->data; | |
1956 GaimConnection *gc = oft_info->sess->aux_data; | |
1957 OscarData *od = gc->proto_data; | |
1958 | |
8660 | 1959 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1960 |
1961 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1962 if (oft_info->conn) { | |
1963 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1964 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1965 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1966 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1967 if (xfer->fd == -1) { | |
1968 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1969 _("Unable to establish file descriptor.")); | |
1970 gaim_xfer_cancel_local(xfer); | |
1971 } | |
1972 } else { | |
1973 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1974 _("Unable to create new connection.")); | |
1975 gaim_xfer_cancel_local(xfer); | |
1976 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1977 } | |
1978 | |
1979 } | |
1980 | |
1981 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1982 { | |
1983 struct aim_oft_info *oft_info = xfer->data; | |
1984 GaimConnection *gc = oft_info->sess->aux_data; | |
1985 OscarData *od = gc->proto_data; | |
1986 | |
8660 | 1987 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1988 |
9771 | 1989 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1990 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1991 |
1992 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1993 aim_oft_destroyinfo(oft_info); | |
1994 xfer->data = NULL; | |
1995 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1996 } | |
1997 | |
1998 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1999 { | |
2000 struct aim_oft_info *oft_info = xfer->data; | |
2001 | |
2002 /* Update our rolling checksum. Like Walmart, yo. */ | |
2003 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2004 } | |
2005 | |
2006 /* | |
2007 * xfer functions used when sending files | |
2008 */ | |
2009 | |
2010 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2011 { | |
2012 struct aim_oft_info *oft_info = xfer->data; | |
2013 GaimConnection *gc = oft_info->sess->aux_data; | |
2014 OscarData *od = gc->proto_data; | |
2015 int listenfd; | |
2016 | |
8660 | 2017 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2018 |
2019 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2020 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2021 oft_info->fh.name[63] = '\0'; | |
2022 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2023 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2024 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2025 | |
2026 /* Create a listening socket and an associated libfaim conn */ | |
2027 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2028 gaim_xfer_cancel_local(xfer); | |
2029 return; | |
2030 } | |
2031 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2032 oft_info->port = xfer->local_port; | |
2033 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2034 gaim_xfer_cancel_local(xfer); | |
2035 return; | |
2036 } | |
8660 | 2037 gaim_debug_misc("oscar", |
8446 | 2038 "port is %hu, ip is %s\n", |
2039 xfer->local_port, oft_info->clientip); | |
2040 if (oft_info->conn) { | |
2041 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2042 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2043 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2044 } else { | |
2045 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2046 _("Unable to establish listener socket.")); | |
2047 gaim_xfer_cancel_local(xfer); | |
2048 } | |
2049 } | |
2050 | |
2051 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2052 { | |
2053 struct aim_oft_info *oft_info = xfer->data; | |
2054 GaimConnection *gc = oft_info->sess->aux_data; | |
2055 OscarData *od = gc->proto_data; | |
2056 | |
8660 | 2057 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2058 |
9771 | 2059 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2060 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2061 |
2062 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2063 aim_oft_destroyinfo(oft_info); | |
2064 xfer->data = NULL; | |
2065 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2066 } | |
2067 | |
2068 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2069 { | |
2070 struct aim_oft_info *oft_info = xfer->data; | |
2071 | |
2072 /* I'm not sure I like how we do this. --marv | |
2073 * I do. AIM file transfers aren't really meant to be thought | |
2074 * of as a transferring just a single file. The rendezvous | |
2075 * establishes a connection between two computers, and then | |
2076 * those computers can use the same connection for transferring | |
2077 * multiple files. So we don't want the Gaim core up and closing | |
2078 * the socket all willy-nilly. We want to do that in the oscar | |
2079 * prpl, whenever one side or the other says they're finished | |
2080 * using the connection. There might be a better way to intercept | |
2081 * the socket from the core, however... --KingAnt | |
2082 */ | |
2083 | |
2084 /* | |
2085 * If we're done sending, intercept the socket from the core ft code | |
2086 * and wait for the other guy to send the "done" OFT packet. | |
2087 */ | |
2088 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2089 gaim_input_remove(xfer->watcher); | |
2090 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2091 xfer->fd = 0; | |
2092 gaim_xfer_set_completed(xfer, TRUE); | |
2093 } | |
2094 } | |
2095 | |
9466 | 2096 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2097 gboolean can_receive = FALSE; | |
2098 OscarData *od = gc->proto_data; | |
2099 | |
2100 if (!od->icq) { | |
2101 aim_userinfo_t *userinfo; | |
2102 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2103 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2104 can_receive = TRUE; | |
2105 } | |
2106 | |
2107 return can_receive; | |
2108 } | |
2109 | |
2110 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2111 |
2112 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2113 GaimXfer *xfer; |
5146 | 2114 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2115 const char *ip; |
3752 | 2116 |
9030 | 2117 od = (OscarData *)gc->proto_data; |
2118 | |
4617 | 2119 /* You want to send a file to someone else, you're so generous */ |
2120 | |
2121 /* Build the file transfer handle */ | |
9466 | 2122 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2123 |
5146 | 2124 /* Create the oscar-specific data */ |
8838 | 2125 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2126 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2127 xfer->data = oft_info; |
2128 | |
4617 | 2129 /* Setup our I/O op functions */ |
8446 | 2130 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2131 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2132 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2133 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2134 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2135 |
2136 /* Keep track of this transfer for later */ | |
2137 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2138 | |
2139 /* Now perform the request */ | |
9466 | 2140 if (file) |
2141 gaim_xfer_request_accepted(xfer, file); | |
2142 else | |
2143 gaim_xfer_request(xfer); | |
3630 | 2144 } |
2145 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2146 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2147 GaimConnection *gc = sess->aux_data; |
7283 | 2148 OscarData *od = gc->proto_data; |
6029 | 2149 GaimAccount *account = gc->account; |
2150 aim_conn_t *bosconn; | |
2151 char *host; int port; | |
2152 int i, rc; | |
2086 | 2153 va_list ap; |
2704 | 2154 struct aim_authresp_info *info; |
6029 | 2155 |
5575 | 2156 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2157 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2158 va_start(ap, fr); |
2704 | 2159 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2160 va_end(ap); |
2161 | |
8660 | 2162 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2163 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2164 |
4293 | 2165 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2166 char buf[256]; |
2704 | 2167 switch (info->errorcode) { |
2086 | 2168 case 0x05: |
2169 /* Incorrect nick/password */ | |
6498 | 2170 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2171 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2172 break; |
2173 case 0x11: | |
2174 /* Suspended account */ | |
6498 | 2175 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2176 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2177 break; |
3498 | 2178 case 0x14: |
2179 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2180 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2181 break; |
2086 | 2182 case 0x18: |
2183 /* connecting too frequently */ | |
6498 | 2184 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2185 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 | 2186 break; |
2187 case 0x1c: | |
2188 /* client too old */ | |
6498 | 2189 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2190 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
|
2191 gaim_connection_error(gc, buf); |
2086 | 2192 break; |
2193 default: | |
6623 | 2194 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2195 break; |
2196 } | |
8660 | 2197 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2198 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2199 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2200 "Error URL: %s\n", info->errorurl); |
2086 | 2201 od->killme = TRUE; |
2202 return 1; | |
2203 } | |
2204 | |
2205 | |
9992 | 2206 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2207 |
2704 | 2208 if (info->email) { |
8660 | 2209 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2210 } else { |
8660 | 2211 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2212 } |
10042 | 2213 |
8660 | 2214 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2215 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2216 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2217 aim_conn_kill(sess, &fr->conn); |
2086 | 2218 |
2219 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2220 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2221 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2222 od->killme = TRUE; |
2223 return 0; | |
2224 } | |
2225 | |
4649 | 2226 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2227 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2228 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2229 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2230 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2231 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2232 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2234 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2235 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2237 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2239 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2240 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2241 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2242 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2243 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2244 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2245 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2246 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2247 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2248 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
|
2249 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2250 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2251 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2252 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2253 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2254 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2255 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
|
2256 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
|
2257 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
|
2258 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2259 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2260 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2261 #ifndef NOSSI |
4642 | 2262 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2263 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2264 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2265 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2266 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2267 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2268 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2269 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2270 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2271 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2272 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2273 |
7283 | 2274 od->conn = bosconn; |
2704 | 2275 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2276 if (info->bosip[i] == ':') { | |
2277 port = atoi(&(info->bosip[i+1])); | |
2086 | 2278 break; |
2279 } | |
2280 } | |
2704 | 2281 host = g_strndup(info->bosip, i); |
2086 | 2282 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2283 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2284 g_free(host); |
4366 | 2285 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2286 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2287 od->killme = TRUE; |
2288 return 0; | |
2289 } | |
4293 | 2290 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2291 gaim_input_remove(gc->inpa); |
2704 | 2292 |
7283 | 2293 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2294 ck[3] = 0x64; |
7282 | 2295 |
2086 | 2296 return 1; |
2297 } | |
2298 | |
7285 | 2299 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2300 struct pieceofcrap { |
5575 | 2301 GaimConnection *gc; |
2086 | 2302 unsigned long offset; |
2303 unsigned long len; | |
2304 char *modname; | |
2305 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2306 aim_conn_t *conn; |
2086 | 2307 unsigned int inpa; |
2308 }; | |
2309 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2310 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2311 { |
2312 struct pieceofcrap *pos = data; | |
7283 | 2313 OscarData *od = pos->gc->proto_data; |
2086 | 2314 char in = '\0'; |
2315 int x = 0; | |
2316 unsigned char m[17]; | |
2317 | |
2318 while (read(pos->fd, &in, 1) == 1) { | |
2319 if (in == '\n') | |
2320 x++; | |
2321 else if (in != '\r') | |
2322 x = 0; | |
2323 if (x == 2) | |
2324 break; | |
2325 in = '\0'; | |
2326 } | |
2327 if (in != '\n') { | |
4056 | 2328 char buf[256]; |
2329 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
|
2330 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2331 gaim_notify_warning(pos->gc, NULL, |
7422 | 2332 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2333 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2334 gaim_input_remove(pos->inpa); |
2086 | 2335 close(pos->fd); |
2336 g_free(pos); | |
2337 return; | |
2338 } | |
2339 read(pos->fd, m, 16); | |
2340 m[16] = '\0'; | |
8660 | 2341 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2342 for (x = 0; x < 16; x++) |
8660 | 2343 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2344 | |
2345 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2346 gaim_input_remove(pos->inpa); |
2086 | 2347 close(pos->fd); |
2348 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2349 g_free(pos); | |
2350 } | |
2351 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2352 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2353 struct pieceofcrap *pos = data; |
5420 | 2354 gchar *buf; |
2086 | 2355 |
4366 | 2356 pos->fd = source; |
2357 | |
2086 | 2358 if (source < 0) { |
5420 | 2359 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
|
2360 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2361 gaim_notify_warning(pos->gc, NULL, |
7422 | 2362 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2363 buf); |
5420 | 2364 g_free(buf); |
2086 | 2365 if (pos->modname) |
2366 g_free(pos->modname); | |
2367 g_free(pos); | |
2368 return; | |
2369 } | |
2370 | |
5420 | 2371 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2372 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2373 write(pos->fd, buf, strlen(buf)); | |
5420 | 2374 g_free(buf); |
2086 | 2375 if (pos->modname) |
2376 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2377 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2378 return; |
2379 } | |
2380 | |
2381 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2382 #define AIM_MAX_FILE_SIZE 98304 | |
2383 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2384 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2385 va_list ap; |
2386 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2387 fu32_t offset, len; |
2086 | 2388 char *modname; |
2389 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2390 va_start(ap, fr); |
4200 | 2391 offset = va_arg(ap, fu32_t); |
2392 len = va_arg(ap, fu32_t); | |
2086 | 2393 modname = va_arg(ap, char *); |
2394 va_end(ap); | |
2395 | |
8660 | 2396 gaim_debug_misc("oscar", |
5556 | 2397 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2398 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2399 |
2086 | 2400 if (len == 0) { |
8660 | 2401 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2402 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2403 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2404 return 1; | |
2405 } | |
9625 | 2406 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2407 #if 0 | |
2086 | 2408 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2409 char *buf; | |
2410 int i = 8; | |
2411 if (modname) | |
2412 i += strlen(modname); | |
2413 buf = g_malloc(i); | |
2414 i = 0; | |
2415 if (modname) { | |
2416 memcpy(buf, modname, strlen(modname)); | |
2417 i += strlen(modname); | |
2418 } | |
2419 buf[i++] = offset & 0xff; | |
2420 buf[i++] = (offset >> 8) & 0xff; | |
2421 buf[i++] = (offset >> 16) & 0xff; | |
2422 buf[i++] = (offset >> 24) & 0xff; | |
2423 buf[i++] = len & 0xff; | |
2424 buf[i++] = (len >> 8) & 0xff; | |
2425 buf[i++] = (len >> 16) & 0xff; | |
2426 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2427 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2428 "hashing request\n"); |
2086 | 2429 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2430 g_free(buf); | |
2431 return 1; | |
2432 } | |
9625 | 2433 #endif |
2086 | 2434 |
2435 pos = g_new0(struct pieceofcrap, 1); | |
2436 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2437 pos->conn = fr->conn; |
2086 | 2438 |
2439 pos->offset = offset; | |
2440 pos->len = len; | |
2441 pos->modname = modname ? g_strdup(modname) : NULL; | |
2442 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2443 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2444 char buf[256]; |
2086 | 2445 if (pos->modname) |
2446 g_free(pos->modname); | |
2447 g_free(pos); | |
4056 | 2448 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
|
2449 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2450 gaim_notify_warning(pos->gc, NULL, |
7422 | 2451 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2452 buf); |
2086 | 2453 } |
2454 | |
2455 return 1; | |
2456 } | |
2457 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2458 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2459 GaimConnection *gc = sess->aux_data; |
7283 | 2460 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2461 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2462 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2463 #if 0 |
2464 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2465 #endif | |
7011 | 2466 va_list ap; |
2467 char *key; | |
2086 | 2468 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2469 va_start(ap, fr); |
2086 | 2470 key = va_arg(ap, char *); |
2471 va_end(ap); | |
2472 | |
4617 | 2473 if (od->icq) { |
3458 | 2474 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2475 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2476 gaim_account_get_password(account), &info, key); |
3458 | 2477 } else { |
2478 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2479 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2480 gaim_account_get_password(account), &info, key); |
3458 | 2481 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2482 |
7283 | 2483 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2484 ck[2] = 0x6c; |
7282 | 2485 |
2086 | 2486 return 1; |
2487 } | |
2488 | |
2675 | 2489 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2490 GaimConnection *gc = sess->aux_data; |
2647 | 2491 struct chat_connection *chatcon; |
2492 static int id = 1; | |
2493 | |
6905 | 2494 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
|
2495 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
|
2496 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
|
2497 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
|
2498 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2499 |
2672 | 2500 aim_clientready(sess, fr->conn); |
2675 | 2501 |
2647 | 2502 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2503 chatcon->id = id; | |
8733 | 2504 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2505 |
2506 return 1; | |
2507 } | |
2508 | |
2675 | 2509 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2510 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2511 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2512 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2513 |
2514 aim_clientready(sess, fr->conn); | |
2515 | |
2516 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2517 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2518 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2519 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2520 |
3694 | 2521 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2522 | |
2523 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2524 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2525 | |
7282 | 2526 aim_email_sendcookies(sess); |
2527 aim_email_activate(sess); | |
3694 | 2528 aim_clientready(sess, fr->conn); |
2529 | |
2530 return 1; | |
2531 } | |
2532 | |
4804 | 2533 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2534 GaimConnection *gc = sess->aux_data; |
7283 | 2535 OscarData *od = gc->proto_data; |
4804 | 2536 |
2537 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2538 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2539 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2540 | |
2541 aim_clientready(sess, fr->conn); | |
2542 | |
4823 | 2543 od->iconconnecting = FALSE; |
2544 | |
4804 | 2545 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2546 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2547 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2548 |
2549 return 1; | |
2550 } | |
2551 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2552 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2553 GaimConnection *gc = data; |
7283 | 2554 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2555 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2556 aim_conn_t *tstconn; |
2086 | 2557 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2558 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2559 close(source); |
2560 return; | |
2561 } | |
2562 | |
4617 | 2563 od = gc->proto_data; |
2564 sess = od->sess; | |
2086 | 2565 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2566 tstconn->fd = source; |
2086 | 2567 |
2568 if (source < 0) { | |
2569 aim_conn_kill(sess, &tstconn); | |
8660 | 2570 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2571 "unable to connect to chatnav server\n"); |
2086 | 2572 return; |
2573 } | |
2574 | |
2575 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2576 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2577 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2578 } |
2579 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2580 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2581 { |
5575 | 2582 GaimConnection *gc = data; |
7283 | 2583 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2584 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2585 aim_conn_t *tstconn; |
2086 | 2586 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2587 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2588 close(source); |
2589 return; | |
2590 } | |
2591 | |
4617 | 2592 od = gc->proto_data; |
2593 sess = od->sess; | |
2086 | 2594 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2595 tstconn->fd = source; |
2086 | 2596 |
2597 if (source < 0) { | |
2598 aim_conn_kill(sess, &tstconn); | |
8660 | 2599 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2600 "unable to connect to authorizer\n"); |
2086 | 2601 return; |
2602 } | |
2603 | |
2604 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2605 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2606 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2607 } |
2608 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2609 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2610 { |
2611 struct chat_connection *ccon = data; | |
5575 | 2612 GaimConnection *gc = ccon->gc; |
7283 | 2613 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2614 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2615 aim_conn_t *tstconn; |
2086 | 2616 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2617 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2618 close(source); |
2619 g_free(ccon->show); | |
2620 g_free(ccon->name); | |
2621 g_free(ccon); | |
2622 return; | |
2623 } | |
2624 | |
4617 | 2625 od = gc->proto_data; |
2626 sess = od->sess; | |
2086 | 2627 tstconn = ccon->conn; |
4366 | 2628 tstconn->fd = source; |
2086 | 2629 |
2630 if (source < 0) { | |
2631 aim_conn_kill(sess, &tstconn); | |
2632 g_free(ccon->show); | |
2633 g_free(ccon->name); | |
2634 g_free(ccon); | |
2635 return; | |
2636 } | |
2637 | |
2638 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2639 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2640 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2641 } |
2642 | |
3694 | 2643 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2644 GaimConnection *gc = data; |
7283 | 2645 OscarData *od; |
3694 | 2646 aim_session_t *sess; |
2647 aim_conn_t *tstconn; | |
2648 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2649 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2650 close(source); |
2651 return; | |
2652 } | |
2653 | |
4617 | 2654 od = gc->proto_data; |
2655 sess = od->sess; | |
3694 | 2656 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2657 tstconn->fd = source; |
3694 | 2658 |
2659 if (source < 0) { | |
2660 aim_conn_kill(sess, &tstconn); | |
8660 | 2661 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2662 "unable to connect to email server\n"); |
3694 | 2663 return; |
2664 } | |
2665 | |
2666 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2667 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2668 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2669 "email: connected\n"); |
3694 | 2670 } |
2671 | |
4804 | 2672 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2673 GaimConnection *gc = data; |
7283 | 2674 OscarData *od; |
4804 | 2675 aim_session_t *sess; |
2676 aim_conn_t *tstconn; | |
2677 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2678 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2679 close(source); |
2680 return; | |
2681 } | |
2682 | |
2683 od = gc->proto_data; | |
2684 sess = od->sess; | |
2685 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2686 tstconn->fd = source; | |
2687 | |
2688 if (source < 0) { | |
2689 aim_conn_kill(sess, &tstconn); | |
8660 | 2690 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2691 "unable to connect to icon server\n"); |
4804 | 2692 return; |
2693 } | |
2694 | |
2695 aim_conn_completeconnect(sess, tstconn); | |
2696 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2697 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2698 } |
2699 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2700 /* 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
|
2701 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2702 GaimConnection *gc = sess->aux_data; |
2703 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2704 aim_conn_t *tstconn; |
4452 | 2705 int i; |
2086 | 2706 char *host; |
2707 int port; | |
4821 | 2708 va_list ap; |
2709 struct aim_redirect_data *redir; | |
2086 | 2710 |
5575 | 2711 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2712 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2713 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2714 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2715 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2716 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2717 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2718 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2719 port = atoi(&(redir->ip[i+1])); |
2086 | 2720 break; |
2721 } | |
2722 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2723 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2724 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2725 switch(redir->group) { |
2086 | 2726 case 0x7: /* Authorizer */ |
8660 | 2727 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2728 "Reconnecting with authorizor...\n"); |
2086 | 2729 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2730 if (tstconn == NULL) { | |
8660 | 2731 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2732 "unable to reconnect with authorizer\n"); |
2086 | 2733 g_free(host); |
2734 return 1; | |
2735 } | |
4649 | 2736 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2737 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2738 |
2739 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2740 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2741 aim_conn_kill(sess, &tstconn); |
8660 | 2742 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2743 "unable to reconnect with authorizer\n"); |
2086 | 2744 g_free(host); |
2745 return 1; | |
2746 } | |
4293 | 2747 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2748 break; |
2749 | |
2086 | 2750 case 0xd: /* ChatNav */ |
2751 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2752 if (tstconn == NULL) { | |
8660 | 2753 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2754 "unable to connect to chatnav server\n"); |
2086 | 2755 g_free(host); |
2756 return 1; | |
2757 } | |
4649 | 2758 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2759 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2760 |
2761 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2762 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2763 aim_conn_kill(sess, &tstconn); |
8660 | 2764 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2765 "unable to connect to chatnav server\n"); |
2086 | 2766 g_free(host); |
2767 return 1; | |
2768 } | |
4293 | 2769 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2770 break; |
2771 | |
2772 case 0xe: { /* Chat */ | |
2086 | 2773 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2774 |
2086 | 2775 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2776 if (tstconn == NULL) { | |
8660 | 2777 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2778 "unable to connect to chat server\n"); |
2086 | 2779 g_free(host); |
2780 return 1; | |
2781 } | |
2782 | |
4649 | 2783 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2784 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2785 | |
2086 | 2786 ccon = g_new0(struct chat_connection, 1); |
2787 ccon->conn = tstconn; | |
2788 ccon->gc = gc; | |
2789 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2790 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2791 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2792 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2793 ccon->show = extract_name(redir->chat.room); |
4634 | 2794 |
2086 | 2795 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2796 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2797 aim_conn_kill(sess, &tstconn); |
8660 | 2798 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2799 "unable to connect to chat server\n"); |
2086 | 2800 g_free(host); |
2801 g_free(ccon->show); | |
2802 g_free(ccon->name); | |
2803 g_free(ccon); | |
2804 return 1; | |
2805 } | |
4293 | 2806 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2807 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2808 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2809 ccon->name, ccon->exchange); |
4194 | 2810 } break; |
3694 | 2811 |
4804 | 2812 case 0x0010: { /* icon */ |
2813 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2814 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2815 "unable to connect to icon server\n"); |
4804 | 2816 g_free(host); |
2817 return 1; | |
2818 } | |
2819 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2820 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2821 | |
2822 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2823 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2824 aim_conn_kill(sess, &tstconn); |
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 icon server\n"); |
4804 | 2827 g_free(host); |
2828 return 1; | |
2829 } | |
2830 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2831 } break; | |
2832 | |
3694 | 2833 case 0x0018: { /* email */ |
2834 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2835 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2836 "unable to connect to email server\n"); |
3694 | 2837 g_free(host); |
2838 return 1; | |
2839 } | |
4649 | 2840 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2841 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2842 | |
2843 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2844 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2845 aim_conn_kill(sess, &tstconn); |
8660 | 2846 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2847 "unable to connect to email server\n"); |
3694 | 2848 g_free(host); |
2849 return 1; | |
2850 } | |
4293 | 2851 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2852 } break; |
2853 | |
2086 | 2854 default: /* huh? */ |
8660 | 2855 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2856 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2857 redir->group); |
2086 | 2858 break; |
2859 } | |
2860 | |
2861 g_free(host); | |
2862 return 1; | |
2863 } | |
2864 | |
10042 | 2865 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
2866 { | |
2867 GaimConnection *gc; | |
2868 GaimAccount *account; | |
2869 OscarData *od; | |
4738 | 2870 struct buddyinfo *bi; |
2993 | 2871 time_t time_idle = 0, signon = 0; |
2872 int type = 0; | |
2873 int caps = 0; | |
2086 | 2874 va_list ap; |
4738 | 2875 aim_userinfo_t *info; |
10042 | 2876 gboolean buddy_is_away = FALSE; |
2877 | |
2878 gc = sess->aux_data; | |
2879 account = gaim_connection_get_account(gc); | |
2880 od = gc->proto_data; | |
4194 | 2881 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2882 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2883 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2884 va_end(ap); |
2885 | |
10130 | 2886 g_return_val_if_fail(info != NULL, 1); |
2887 g_return_val_if_fail(info->sn != NULL, 1); | |
2888 | |
2993 | 2889 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2890 caps = info->capabilities; | |
3267 | 2891 |
4766 | 2892 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2893 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 2894 buddy_is_away = TRUE; |
2895 } | |
2896 | |
2993 | 2897 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2898 type = (info->icqinfo.status << 16); |
3013 | 2899 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2900 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 2901 buddy_is_away = TRUE; |
3013 | 2902 } |
2993 | 2903 } |
2904 | |
7141 | 2905 if (caps & AIM_CAPS_ICQ_DIRECT) |
2906 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2907 |
2908 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2909 time(&time_idle); |
2910 time_idle -= info->idletime*60; | |
9295 | 2911 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2912 } |
2913 | |
5836 | 2914 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2915 signon = info->onlinesince; | |
2916 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2917 signon = time(NULL) - info->sessionlen; |
2086 | 2918 |
9982 | 2919 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) |
5575 | 2920 gaim_connection_set_display_name(gc, info->sn); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2921 |
9982 | 2922 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 2923 if (!bi) { |
2924 bi = g_new0(struct buddyinfo, 1); | |
9982 | 2925 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 2926 } |
4739 | 2927 bi->typingnot = FALSE; |
2928 bi->ico_informed = FALSE; | |
6857 | 2929 bi->ipaddr = info->icqinfo.ipaddr; |
2930 | |
2931 /* Available message stuff */ | |
6292 | 2932 free(bi->availmsg); |
7011 | 2933 if (info->avail != NULL) |
8225 | 2934 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2935 else |
6292 | 2936 bi->availmsg = NULL; |
4732 | 2937 |
4804 | 2938 /* Server stored icon stuff */ |
4853 | 2939 if (info->iconcsumlen) { |
7125 | 2940 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2941 char *b16 = NULL, *filepath = NULL; |
7093 | 2942 GaimBuddy *b = NULL; |
4853 | 2943 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2944 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 2945 b = gaim_find_buddy(account, info->sn); |
7093 | 2946 /* |
2947 * If for some reason the checksum is valid, but cached file is not.. | |
2948 * we want to know. | |
2949 */ | |
7693 | 2950 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2951 if (filename != NULL) { |
2952 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2953 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2954 "icon_checksum"); | |
9801 | 2955 else { |
2956 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2957 filename, NULL); | |
2958 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2959 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2960 "icon_checksum"); | |
2961 g_free(filepath); | |
2962 } | |
7093 | 2963 } else |
2964 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2965 |
4853 | 2966 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2967 GSList *cur = od->requesticon; | |
2968 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2969 cur = cur->next; | |
2970 if (!cur) { | |
9982 | 2971 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 2972 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2973 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2974 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2975 } |
2976 } | |
6053 | 2977 g_free(b16); |
4853 | 2978 } |
2979 | |
10042 | 2980 /* XXX - Represent other ICQ statuses */ |
2981 if (buddy_is_away == TRUE) | |
2982 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
2983 else | |
2984 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
9982 | 2985 gaim_prpl_got_user_login_time(account, info->sn, signon); |
2986 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); | |
2987 | |
2988 if (time_idle > 0) | |
2989 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 2990 else |
2991 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 2992 |
2993 return 1; | |
2994 } | |
2995 | |
8341 | 2996 static void gaim_check_comment(OscarData *od, const char *str) { |
2997 if ((str == NULL) || strcmp(str, ck)) | |
2998 aim_locate_setcaps(od->sess, caps_aim); | |
2999 else | |
3000 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3001 } | |
3002 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3003 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3004 GaimConnection *gc = sess->aux_data; |
7283 | 3005 OscarData *od = gc->proto_data; |
9982 | 3006 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3007 va_list ap; |
4739 | 3008 aim_userinfo_t *info; |
2086 | 3009 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3010 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3011 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3012 va_end(ap); |
3013 | |
9982 | 3014 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3015 |
7261 | 3016 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3017 |
2086 | 3018 return 1; |
3019 } | |
3020 | |
4617 | 3021 /* BBB */ |
3952 | 3022 /* |
4617 | 3023 * This is called after a remote AIM user has connected to us. We |
3024 * want to do some voodoo with the socket file descriptors, add a | |
3025 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3026 */ |
4656 | 3027 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3028 GaimConnection *gc = sess->aux_data; |
7283 | 3029 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3030 GaimXfer *xfer; |
5146 | 3031 struct aim_oft_info *oft_info; |
3630 | 3032 va_list ap; |
3033 aim_conn_t *conn, *listenerconn; | |
4656 | 3034 |
8660 | 3035 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3036 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3037 va_start(ap, fr); |
3038 conn = va_arg(ap, aim_conn_t *); | |
3039 listenerconn = va_arg(ap, aim_conn_t *); | |
3040 va_end(ap); | |
3041 | |
4617 | 3042 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3043 return 1; | |
3044 | |
5146 | 3045 if (!(oft_info = xfer->data)) |
4617 | 3046 return 1; |
3047 | |
3630 | 3048 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3049 gaim_input_remove(xfer->watcher); |
3630 | 3050 aim_conn_kill(sess, &listenerconn); |
3051 | |
5146 | 3052 oft_info->conn = conn; |
3053 xfer->fd = oft_info->conn->fd; | |
3054 | |
3055 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3056 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3057 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3058 |
3059 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3060 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3061 |
3062 return 0; | |
3063 } | |
3064 | |
3952 | 3065 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3066 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3067 * user in order to transfer a file. |
3952 | 3068 */ |
4617 | 3069 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
|
3070 GaimXfer *xfer; |
5146 | 3071 struct aim_oft_info *oft_info; |
4656 | 3072 |
8660 | 3073 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3074 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3075 if (!(xfer = data)) |
3076 return; | |
5146 | 3077 if (!(oft_info = xfer->data)) |
3630 | 3078 return; |
8446 | 3079 if (source < 0) { |
3080 gaim_xfer_cancel_remote(xfer); | |
4617 | 3081 return; |
8446 | 3082 } |
4617 | 3083 |
3084 xfer->fd = source; | |
5146 | 3085 oft_info->conn->fd = source; |
3086 | |
3087 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3088 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3089 |
3090 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3091 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3092 |
3093 return; | |
3630 | 3094 } |
3095 | |
3952 | 3096 /* |
4617 | 3097 * This is called when a buddy sends us some file info. This happens when they |
3098 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3099 * You should send them the exact same info except use the real cookie. We also |
4617 | 3100 * get like totally ready to like, receive the file, kay? |
3952 | 3101 */ |
4617 | 3102 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3103 GaimConnection *gc = sess->aux_data; |
7283 | 3104 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3105 GaimXfer *xfer; |
5146 | 3106 struct aim_oft_info *oft_info; |
4617 | 3107 va_list ap; |
3108 aim_conn_t *conn; | |
3109 fu8_t *cookie; | |
3110 struct aim_fileheader_t *fh; | |
4656 | 3111 |
8660 | 3112 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3113 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3114 va_start(ap, fr); |
3115 conn = va_arg(ap, aim_conn_t *); | |
3116 cookie = va_arg(ap, fu8_t *); | |
3117 fh = va_arg(ap, struct aim_fileheader_t *); | |
3118 va_end(ap); | |
3119 | |
3120 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3121 return 1; | |
3122 | |
5146 | 3123 if (!(oft_info = xfer->data)) |
4617 | 3124 return 1; |
3125 | |
3126 /* We want to stop listening with a normal thingy */ | |
3127 gaim_input_remove(xfer->watcher); | |
3128 xfer->watcher = 0; | |
3129 | |
5146 | 3130 /* They sent us some information about the file they're sending */ |
3131 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3132 | |
3133 /* Fill in the cookie */ | |
3134 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3135 | |
4617 | 3136 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3137 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3138 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3139 | |
3140 return 0; | |
3630 | 3141 } |
3142 | |
3952 | 3143 /* |
4657 | 3144 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3145 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3146 */ |
4617 | 3147 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3148 GaimConnection *gc = sess->aux_data; |
7283 | 3149 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3150 GaimXfer *xfer; |
4617 | 3151 va_list ap; |
3152 aim_conn_t *conn; | |
3153 fu8_t *cookie; | |
3154 struct aim_fileheader_t *fh; | |
4656 | 3155 |
8660 | 3156 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3157 va_start(ap, fr); |
3158 conn = va_arg(ap, aim_conn_t *); | |
3159 cookie = va_arg(ap, fu8_t *); | |
3160 fh = va_arg(ap, struct aim_fileheader_t *); | |
3161 va_end(ap); | |
3162 | |
3163 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3164 return 1; | |
3165 | |
4656 | 3166 /* We want to stop listening with a normal thingy */ |
3167 gaim_input_remove(xfer->watcher); | |
3168 xfer->watcher = 0; | |
3169 | |
4617 | 3170 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3171 | |
3172 return 0; | |
3630 | 3173 } |
4617 | 3174 |
3175 /* | |
3176 * We just sent a file to someone. They said they got it and everything, | |
3177 * so we can close our direct connection and what not. | |
3178 */ | |
3179 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3180 GaimConnection *gc = sess->aux_data; |
7283 | 3181 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3182 GaimXfer *xfer; |
4617 | 3183 va_list ap; |
3184 aim_conn_t *conn; | |
3185 fu8_t *cookie; | |
3186 struct aim_fileheader_t *fh; | |
4656 | 3187 |
8660 | 3188 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3189 va_start(ap, fr); |
3190 conn = va_arg(ap, aim_conn_t *); | |
3191 cookie = va_arg(ap, fu8_t *); | |
3192 fh = va_arg(ap, struct aim_fileheader_t *); | |
3193 va_end(ap); | |
3194 | |
3195 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3196 return 1; | |
3197 | |
4656 | 3198 xfer->fd = conn->fd; |
4617 | 3199 gaim_xfer_end(xfer); |
3200 | |
3201 return 0; | |
3202 } | |
3630 | 3203 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3204 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3205 GaimConnection *gc = sess->aux_data; |
7283 | 3206 OscarData *od = gc->proto_data; |
8708 | 3207 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3208 GaimConvImFlags flags = 0; |
4738 | 3209 struct buddyinfo *bi; |
5575 | 3210 const char *iconfile; |
9806 | 3211 GString *message; |
3212 gchar *tmp; | |
3213 aim_mpmsg_section_t *curpart; | |
3214 | |
3215 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3216 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3217 |
8708 | 3218 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3219 if (!bi) { |
3220 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3221 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3222 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3223 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3224 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3225 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3226 |
4738 | 3227 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3228 bi->typingnot = TRUE; | |
3229 else | |
3230 bi->typingnot = FALSE; | |
3231 | |
4380 | 3232 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3233 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3234 "%s has an icon\n", userinfo->sn); |
4738 | 3235 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3236 bi->ico_need = TRUE; | |
3237 bi->ico_len = args->iconlen; | |
3238 bi->ico_csum = args->iconsum; | |
3239 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3240 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3241 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3242 |
8708 | 3243 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3244 (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
|
3245 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3246 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3247 |
5575 | 3248 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3249 char *buf = g_malloc(st.st_size); |
5575 | 3250 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3251 if (file) { |
9532 | 3252 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3253 int len = fread(buf, 1, st.st_size, file); |
8660 | 3254 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3255 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3256 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3257 userinfo->sn, len, st.st_size); |
4617 | 3258 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3259 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3260 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3261 } else |
8660 | 3262 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3263 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3264 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3265 } else |
8660 | 3266 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3267 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3268 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3269 |
9806 | 3270 message = g_string_new(""); |
3271 curpart = args->mpmsg.parts; | |
3272 while (curpart != NULL) { | |
9908 | 3273 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3274 curpart->data, curpart->datalen); |
3275 if (tmp != NULL) { | |
3276 g_string_append(message, tmp); | |
3277 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3278 } |
9806 | 3279 |
3280 curpart = curpart->next; | |
3281 } | |
3282 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3283 |
8666 | 3284 /* |
8995 | 3285 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3286 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3287 * so any HTML we receive is intended to be displayed |
3288 * | |
3289 * Note: There *may* be some clients which send messages as HTML formatted - | |
3290 * they need to be special-cased somehow. | |
8666 | 3291 */ |
9982 | 3292 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3293 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3294 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3295 g_free(tmp); |
3296 tmp = tmp2; | |
3297 } | |
3298 | |
6982 | 3299 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3300 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3301 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3302 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3303 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3304 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3305 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3306 GaimConnection *gc; |
9933 | 3307 GaimAccount *account; |
9070 | 3308 OscarData *od; |
9933 | 3309 const char *username = NULL; |
3310 char *message = NULL; | |
9070 | 3311 |
3312 g_return_val_if_fail(sess != NULL, 0); | |
3313 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3314 | |
3315 gc = sess->aux_data; | |
9933 | 3316 account = gaim_connection_get_account(gc); |
9070 | 3317 od = gc->proto_data; |
9933 | 3318 username = gaim_account_get_username(account); |
3319 | |
3320 if (args == NULL) | |
4121 | 3321 return 0; |
4194 | 3322 |
9933 | 3323 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3324 userinfo->sn, args->status); | |
3325 | |
3326 if (args->msg != NULL) | |
3327 { | |
3328 if (args->encoding != NULL) | |
3329 { | |
3330 char *encoding = NULL; | |
3331 encoding = oscar_encoding_extract(args->encoding); | |
3332 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3333 g_free(encoding); | |
3334 } else { | |
3335 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3336 message = g_strdup(args->msg); | |
3337 } | |
3338 } | |
2869 | 3339 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3340 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3341 char *name; |
5234 | 3342 GHashTable *components; |
3343 | |
9933 | 3344 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3345 g_free(message); | |
4121 | 3346 return 1; |
9933 | 3347 } |
5234 | 3348 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3349 g_free); | |
4121 | 3350 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3351 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3352 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
|
3353 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3354 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3355 userinfo->sn, |
9933 | 3356 message, |
5234 | 3357 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3358 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3359 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3360 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3361 /* BBB */ |
3362 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3363 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3364 GaimXfer *xfer; |
5146 | 3365 struct aim_oft_info *oft_info; |
3366 | |
3367 if (!args->cookie || !args->port || !args->verifiedip || | |
3368 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3369 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3370 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3371 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3372 "information.\n", userinfo->sn); |
5146 | 3373 if (args->proxyip) |
8660 | 3374 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3375 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3376 "does not support this yet.\n"); |
9933 | 3377 g_free(message); |
4617 | 3378 return 1; |
4656 | 3379 } |
4617 | 3380 |
3381 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3382 /* 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
|
3383 * directory -- remove the star and trailing slash so we don't save |
4617 | 3384 * directories that look like 'dirname\*' -- arl */ |
3385 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3386 if (tmp && (tmp[1] == '*')) { | |
3387 tmp[0] = '\0'; | |
3388 } | |
8660 | 3389 gaim_debug_warning("oscar", |
8446 | 3390 "We're receiving a whole directory! What fun! " |
3391 "Especially since we don't support that!\n"); | |
4617 | 3392 } |
3393 | |
3394 /* Build the file transfer handle */ | |
3395 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3396 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3397 xfer->remote_port = args->port; |
4617 | 3398 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3399 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3400 gaim_xfer_set_message(xfer, message); |
5146 | 3401 |
3402 /* Create the oscar-specific data */ | |
5163 | 3403 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3404 if (args->proxyip) |
5146 | 3405 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3406 if (args->verifiedip) |
5146 | 3407 oft_info->verifiedip = g_strdup(args->verifiedip); |
3408 xfer->data = oft_info; | |
4617 | 3409 |
3410 /* Setup our I/O op functions */ | |
8446 | 3411 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3412 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3413 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
|
3414 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3415 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3416 |
3417 /* Keep track of this transfer for later */ | |
3418 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3419 | |
3420 /* Now perform the request */ | |
3421 gaim_xfer_request(xfer); | |
3422 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3423 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3424 GaimXfer *xfer; |
8660 | 3425 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3426 "AAA - File transfer canceled by remote user\n"); |
4617 | 3427 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
|
3428 gaim_xfer_cancel_remote(xfer); |
4617 | 3429 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3430 /* | |
3431 * This gets sent by the receiver of a file | |
3432 * as they connect directly to us. If we don't | |
3433 * get this, then maybe a third party connected | |
3434 * to us, and we shouldn't send them anything. | |
3435 */ | |
3436 } else { | |
8660 | 3437 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3438 "unknown rendezvous status!\n"); |
3630 | 3439 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3440 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3441 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3442 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3443 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3444 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3445 args->info.icon.length); |
6871 | 3446 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3447 /* 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
|
3448 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3449 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
|
3450 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3451 |
4212 | 3452 if (!args->verifiedip) { |
8983 | 3453 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3454 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3455 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3456 g_free(message); |
4650 | 3457 return 1; |
4212 | 3458 } |
3459 | |
8660 | 3460 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3461 "%s received direct im request from %s (%s)\n", |
8983 | 3462 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3463 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3464 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3465 d->sn = g_strdup(userinfo->sn); |
8983 | 3466 /* Let's use the clientip here, because I think that's what AIM does. |
3467 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3468 * and then ask them to connect to us. */ | |
3469 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
|
3470 memcpy(d->cookie, args->cookie, 8); |
9070 | 3471 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3472 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3473 | |
8971 | 3474 oscar_direct_im_destroy(od, dim); |
8984 | 3475 d->donttryagain = TRUE; |
8971 | 3476 accept_direct_im_request(d); |
3477 } else { | |
8983 | 3478 if (dim && !dim->connected) |
8971 | 3479 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3480 "already connected to that buddy!"); | |
5575 | 3481 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
|
3482 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3483 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3484 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3485 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3486 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3487 "revealed, this may be considered a privacy " |
9972 | 3488 "risk."), |
3489 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3490 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3491 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3492 /* FIXME: we should actually send a packet on cancel */ | |
3493 } | |
8708 | 3494 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3495 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
|
3496 } else { |
8660 | 3497 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3498 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3499 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3500 |
9933 | 3501 g_free(message); |
3502 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3503 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3504 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3505 |
3453 | 3506 /* |
4230 | 3507 * Authorization Functions |
3508 * Most of these are callbacks from dialogs. They're used by both | |
3509 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3510 */ |
4269 | 3511 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3512 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3513 GaimConnection *gc = data->gc; |
4244 | 3514 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3515 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3516 OscarData *od = gc->proto_data; |
6695 | 3517 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3518 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3519 if (buddy && group) { |
8660 | 3520 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3521 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3522 buddy->name, group->name); |
4889 | 3523 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3524 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3525 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3526 } |
4230 | 3527 } |
4337 | 3528 } |
3529 | |
3530 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3531 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3532 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3533 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3534 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3535 data); |
4230 | 3536 } |
3537 | |
3538 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3539 GaimConnection *gc = data->gc; |
4244 | 3540 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3541 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3542 /* Remove from local list */ |
3543 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3544 gaim_blist_remove_buddy(b); | |
4244 | 3545 } |
3546 | |
5836 | 3547 oscar_free_name_data(data); |
4230 | 3548 } |
3549 | |
9030 | 3550 |
3551 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3552 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3553 GaimBuddy *buddy; |
4269 | 3554 gchar *dialog_msg, *nombre; |
3555 | |
4687 | 3556 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3557 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3558 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3559 else |
4830 | 3560 nombre = NULL; |
3561 | |
3562 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 | 3563 data->gc = gc; |
3564 data->name = g_strdup(name); | |
3565 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3566 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3567 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3568 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3569 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3570 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3571 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3572 |
3573 g_free(dialog_msg); | |
3574 g_free(nombre); | |
3575 } | |
3576 | |
9030 | 3577 |
3578 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3579 GaimBuddy *buddy; | |
3580 GaimConnection *gc; | |
3581 | |
3582 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3583 | |
3584 buddy = (GaimBuddy *) node; | |
3585 gc = gaim_account_get_connection(buddy->account); | |
3586 gaim_auth_sendrequest(gc, buddy->name); | |
3587 } | |
3588 | |
4230 | 3589 /* When other people ask you for authorization */ |
3590 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3591 GaimConnection *gc = data->gc; |
4244 | 3592 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3593 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3594 OscarData *od = gc->proto_data; |
4236 | 3595 #ifdef NOSSI |
6695 | 3596 GaimBuddy *buddy; |
4244 | 3597 gchar message; |
3598 message = 0; | |
4687 | 3599 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3600 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3601 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3602 #else |
4889 | 3603 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3604 #endif |
4244 | 3605 } |
3606 | |
5836 | 3607 oscar_free_name_data(data); |
3141 | 3608 } |
3609 | |
4230 | 3610 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3611 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3612 GaimConnection *gc = data->gc; |
4244 | 3613 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3614 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3615 OscarData *od = gc->proto_data; |
4230 | 3616 #ifdef NOSSI |
4617 | 3617 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3618 #else |
4889 | 3619 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3620 #endif |
4244 | 3621 } |
4337 | 3622 } |
3623 | |
3624 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3625 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3626 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3627 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3628 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3629 data); |
3141 | 3630 } |
3631 | |
7023 | 3632 /* When someone sends you buddies */ |
3633 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3634 GaimConnection *gc = data->gc; |
4244 | 3635 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3636 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3637 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3638 } |
3639 | |
5836 | 3640 oscar_free_name_data(data); |
3453 | 3641 } |
3642 | |
4075 | 3643 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 | 3644 GaimConnection *gc = sess->aux_data; |
9908 | 3645 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3646 gchar **msg1, **msg2; |
6051 | 3647 int i, numtoks; |
4076 | 3648 |
4121 | 3649 if (!args->type || !args->msg || !args->uin) |
3650 return 1; | |
4194 | 3651 |
8660 | 3652 gaim_debug_info("oscar", |
9908 | 3653 "Received a channel 4 message of type 0x%02hhx.\n", |
3654 args->type); | |
4076 | 3655 |
9919 | 3656 /* |
3657 * Split up the message at the delimeter character, then convert each | |
3658 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3659 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3660 * character in whatever encoding the message was sent in. Type 1 | |
3661 * messages are always made up of only one part, so we can easily account | |
3662 * for this suck-ass part of the protocol by splitting the string into at | |
3663 * most 1 baby string. | |
3664 */ | |
3665 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3666 for (numtoks=0; msg1[numtoks]; numtoks++); |
3667 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3668 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3669 gaim_str_strip_cr(msg1[i]); |
9908 | 3670 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3671 } |
3672 msg2[i] = NULL; | |
3673 | |
3952 | 3674 switch (args->type) { |
4173 | 3675 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3676 if (i >= 1) { |
5556 | 3677 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3678 gchar *tmp; |
3679 | |
3680 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3681 tmp = gaim_escape_html(msg2[0]); |
8493 | 3682 |
4076 | 3683 if (t) { /* This is an offline message */ |
9680 | 3684 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3685 #ifdef HAVE_TM_GMTOFF |
9724 | 3686 time_t now; |
3687 struct tm *tm; | |
3688 now = time(NULL); | |
3689 tm = localtime(&now); | |
3690 t += tm->tm_gmtoff; | |
9698 | 3691 #else |
3692 # ifdef HAVE_TIMEZONE | |
9680 | 3693 tzset(); |
3694 t -= timezone; | |
9698 | 3695 # endif |
3696 #endif | |
8514 | 3697 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3698 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3699 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3700 } |
3701 g_free(uin); | |
8493 | 3702 g_free(tmp); |
4075 | 3703 } |
3316 | 3704 } break; |
3705 | |
4173 | 3706 case 0x04: { /* Someone sent you a URL */ |
4076 | 3707 if (i >= 2) { |
7385 | 3708 if (msg2[1] != NULL) { |
3709 gchar *uin = g_strdup_printf("%u", args->uin); | |
3710 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3711 msg2[1], | |
3712 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3713 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3714 g_free(uin); | |
3715 g_free(message); | |
3716 } | |
3453 | 3717 } |
3718 } break; | |
3719 | |
4173 | 3720 case 0x06: { /* Someone requested authorization */ |
4076 | 3721 if (i >= 6) { |
4230 | 3722 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3723 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 | 3724 gaim_debug_info("oscar", |
5556 | 3725 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3726 args->uin); |
4076 | 3727 data->gc = gc; |
5556 | 3728 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3729 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3730 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3731 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3732 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3733 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3734 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3735 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3736 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3737 g_free(dialog_msg); |
3738 } | |
3141 | 3739 } break; |
3740 | |
4173 | 3741 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3742 if (i >= 1) { |
7023 | 3743 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
|
3744 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3745 dialog_msg); |
4076 | 3746 g_free(dialog_msg); |
3747 } | |
3141 | 3748 } break; |
3749 | |
4173 | 3750 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3751 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
|
3752 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3753 dialog_msg); |
3141 | 3754 g_free(dialog_msg); |
3755 } break; | |
3756 | |
4333 | 3757 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3758 if (i >= 5) { | |
3759 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
|
3760 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3761 g_free(dialog_msg); |
3762 } | |
3763 } break; | |
3764 | |
4173 | 3765 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3766 if (i >= 6) { |
4194 | 3767 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
|
3768 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3769 g_free(dialog_msg); |
3770 } | |
4075 | 3771 } break; |
3772 | |
4173 | 3773 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3774 if (i >= 6) { |
4308 | 3775 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
|
3776 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3777 g_free(dialog_msg); |
3778 } | |
4075 | 3779 } break; |
3780 | |
4173 | 3781 case 0x12: { |
3141 | 3782 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3783 /* Someone added you to their buddy list? */ |
3141 | 3784 } break; |
3785 | |
7023 | 3786 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3787 guint i, num; |
3453 | 3788 gchar **text; |
4173 | 3789 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3790 if (text) { |
3791 num = 0; | |
3792 for (i=0; i<strlen(text[0]); i++) | |
3793 num = num*10 + text[0][i]-48; | |
3794 for (i=0; i<num; i++) { | |
4230 | 3795 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3796 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 | 3797 data->gc = gc; |
4790 | 3798 data->name = g_strdup(text[i*2+1]); |
3799 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3800 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3801 gaim_request_action(gc, NULL, message, |
7023 | 3802 _("Do you want to add this buddy " |
3803 "to your buddy list?"), | |
9972 | 3804 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3805 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3806 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3807 g_free(message); |
3808 } | |
3809 g_strfreev(text); | |
3810 } | |
3811 } break; | |
3812 | |
7023 | 3813 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3814 /* This is boring and silly. */ |
3815 } break; | |
3816 | |
3141 | 3817 default: { |
8660 | 3818 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3819 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3820 "(type 0x%02hhx).\n", args->type); |
3141 | 3821 } break; |
3822 } | |
3823 | |
4076 | 3824 g_strfreev(msg1); |
3825 g_strfreev(msg2); | |
3826 | |
3141 | 3827 return 1; |
3828 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3829 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3830 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3831 fu16_t channel; |
3832 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3833 aim_userinfo_t *userinfo; |
2086 | 3834 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3835 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3836 va_start(ap, fr); |
4200 | 3837 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3838 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3839 |
3141 | 3840 switch (channel) { |
3841 case 1: { /* standard message */ | |
3842 struct aim_incomingim_ch1_args *args; | |
3843 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3844 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3845 } break; | |
3846 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3847 case 2: { /* rendezvous */ |
3141 | 3848 struct aim_incomingim_ch2_args *args; |
3849 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3850 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3851 } break; | |
3852 | |
3853 case 4: { /* ICQ */ | |
3854 struct aim_incomingim_ch4_args *args; | |
3855 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3856 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3857 } break; |
3858 | |
3859 default: { | |
8660 | 3860 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3861 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3862 "0x%04hx).", channel); |
3141 | 3863 } break; |
2086 | 3864 } |
3865 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3866 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3867 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3868 return ret; |
2086 | 3869 } |
3870 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3871 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3872 GaimConnection *gc = sess->aux_data; |
3873 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3874 char *buf; |
2086 | 3875 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3876 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3877 aim_userinfo_t *userinfo; |
2086 | 3878 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3879 va_start(ap, fr); |
4200 | 3880 chan = (fu16_t)va_arg(ap, unsigned int); |
3881 userinfo = va_arg(ap, aim_userinfo_t *); | |
3882 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3883 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3884 va_end(ap); |
3885 | |
3886 switch(reason) { | |
5420 | 3887 case 0: /* Invalid (0) */ |
3888 buf = g_strdup_printf( | |
3889 ngettext( | |
4276 | 3890 "You missed %hu message from %s because it was invalid.", |
3891 "You missed %hu messages from %s because they were invalid.", | |
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 1: /* Message too large */ |
3897 buf = g_strdup_printf( | |
3898 ngettext( | |
4276 | 3899 "You missed %hu message from %s because it was too large.", |
3900 "You missed %hu messages from %s because they were too large.", | |
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 2: /* Rate exceeded */ |
3906 buf = g_strdup_printf( | |
3907 ngettext( | |
4276 | 3908 "You missed %hu message from %s because the rate limit has been exceeded.", |
3909 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
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 3: /* Evil Sender */ |
3915 buf = g_strdup_printf( | |
3916 ngettext( | |
4276 | 3917 "You missed %hu message from %s because he/she was too evil.", |
3918 "You missed %hu messages from %s because he/she was too evil.", | |
3919 nummissed), | |
4282 | 3920 nummissed, |
3921 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3922 break; |
5420 | 3923 case 4: /* Evil Receiver */ |
3924 buf = g_strdup_printf( | |
3925 ngettext( | |
4276 | 3926 "You missed %hu message from %s because you are too evil.", |
3927 "You missed %hu messages from %s because you are too evil.", | |
3928 nummissed), | |
4282 | 3929 nummissed, |
3930 userinfo->sn); | |
2086 | 3931 break; |
3932 default: | |
5420 | 3933 buf = g_strdup_printf( |
3934 ngettext( | |
4276 | 3935 "You missed %hu message from %s for an unknown reason.", |
3936 "You missed %hu messages from %s for an unknown reason.", | |
3937 nummissed), | |
4282 | 3938 nummissed, |
3939 userinfo->sn); | |
2086 | 3940 break; |
3941 } | |
8733 | 3942 |
9627 | 3943 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3944 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3945 g_free(buf); |
2086 | 3946 |
3947 return 1; | |
3948 } | |
3949 | |
4194 | 3950 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3951 GaimConnection *gc = sess->aux_data; |
7283 | 3952 OscarData *od = gc->proto_data; |
4617 | 3953 |
3954 /* BBB */ | |
3630 | 3955 switch (reason) { |
4151 | 3956 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3957 GaimXfer *xfer; |
8971 | 3958 struct oscar_direct_im *dim; |
3959 | |
8660 | 3960 gaim_debug_info("oscar", |
9070 | 3961 "AAA - Other user declined some sort of direct " |
8971 | 3962 "connect attempt (automaticly?)\n"); |
4617 | 3963 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
|
3964 gaim_xfer_cancel_remote(xfer); |
8971 | 3965 else if ((dim = oscar_direct_im_find(od, who))) { |
3966 /* AAA should use find by cookie or something here */ | |
3967 oscar_direct_im_disconnect(od, dim); | |
3968 } | |
4151 | 3969 } break; |
3970 | |
3971 default: { | |
8660 | 3972 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3973 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3974 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3975 } |
3630 | 3976 |
3977 } | |
3978 | |
3979 return 0; | |
3980 } | |
3981 | |
4194 | 3982 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3983 GaimConnection *gc = sess->aux_data; |
4151 | 3984 |
3985 switch(reason) { | |
3986 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3987 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3988 | |
3989 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3990 |
3991 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3992 statusmsg = oscar_icqstatus(state); |
4151 | 3993 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3994 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3995 g_free(statusmsg); | |
4151 | 3996 g_strfreev(splitmsg); |
9244 | 3997 |
9797 | 3998 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 3999 |
4000 g_free(title); | |
4001 g_free(dialogmsg); | |
4151 | 4002 } break; |
4003 | |
4004 default: { | |
8660 | 4005 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4006 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4007 "Type 0x%04hx\n", who, reason); |
4151 | 4008 } break; |
4009 } /* end of switch */ | |
4010 | |
4011 return 0; | |
4012 } | |
4013 | |
3212 | 4014 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4015 va_list ap; | |
4016 fu16_t chan, reason; | |
4017 char *who; | |
4018 | |
4019 va_start(ap, fr); | |
4200 | 4020 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4021 who = va_arg(ap, char *); |
4200 | 4022 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4023 |
3952 | 4024 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4025 char *cookie = va_arg(ap, char *); |
4151 | 4026 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4027 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4028 fu32_t state = 0; |
4151 | 4029 char *msg = NULL; |
4030 if (reason == 0x0003) { | |
4200 | 4031 state = va_arg(ap, fu32_t); |
4151 | 4032 msg = va_arg(ap, char *); |
4033 } | |
4034 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4035 } | |
3952 | 4036 |
3212 | 4037 va_end(ap); |
4038 | |
4039 return 1; | |
4040 } | |
4041 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4042 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4043 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4044 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4045 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4046 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4047 va_start(ap, fr); |
4199 | 4048 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4049 va_end(ap); |
4050 | |
8660 | 4051 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4052 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4053 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4054 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4055 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4056 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4057 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4058 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4059 |
2086 | 4060 return 1; |
4061 } | |
4062 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4063 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4064 GaimConnection *gc = sess->aux_data; |
4617 | 4065 #if 0 |
7283 | 4066 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4067 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4068 #endif |
4617 | 4069 va_list ap; |
4070 fu16_t reason; | |
4071 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4072 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4073 va_start(ap, fr); |
4617 | 4074 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4075 data = va_arg(ap, char *); |
2086 | 4076 va_end(ap); |
4077 | |
8660 | 4078 gaim_debug_error("oscar", |
10130 | 4079 "Message error with data %s and reason %hu\n", |
4080 (data != NULL ? data : ""), reason); | |
4617 | 4081 |
4082 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4083 #if 0 |
4617 | 4084 /* If this was a file transfer request, data is a cookie */ |
4085 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
|
4086 gaim_xfer_cancel_remote(xfer); |
3630 | 4087 return 1; |
4088 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4089 #endif |
3630 | 4090 |
4617 | 4091 /* Data is assumed to be the destination sn */ |
9826 | 4092 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4093 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4094 g_free(buf); | |
4095 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4096 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4097 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4098 } | |
4099 g_free(buf); | |
4100 | |
2086 | 4101 return 1; |
4102 } | |
4103 | |
3595 | 4104 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4105 GaimConnection *gc = sess->aux_data; |
3595 | 4106 va_list ap; |
4107 fu16_t type1, type2; | |
4108 char *sn; | |
4109 | |
4110 va_start(ap, fr); | |
4199 | 4111 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4112 sn = va_arg(ap, char *); |
4199 | 4113 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4114 va_end(ap); |
4115 | |
4116 switch (type2) { | |
4117 case 0x0000: { /* Text has been cleared */ | |
4118 serv_got_typing_stopped(gc, sn); | |
4119 } break; | |
4120 | |
4121 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4122 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4123 } break; |
4124 | |
4125 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4126 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4127 } break; |
4128 | |
4129 default: { | |
8660 | 4130 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 | 4131 } break; |
4132 } | |
4133 | |
4134 return 1; | |
4135 } | |
4136 | |
7141 | 4137 /* |
4138 * We get this error when there was an error in the locate family. This | |
7259 | 4139 * happens when you request info of someone who is offline. |
7141 | 4140 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4141 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4142 gchar *buf; |
2086 | 4143 va_list ap; |
5420 | 4144 fu16_t reason; |
2086 | 4145 char *destn; |
4146 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4147 va_start(ap, fr); |
4199 | 4148 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4149 destn = va_arg(ap, char *); |
4150 va_end(ap); | |
4151 | |
7781 | 4152 if (destn == NULL) |
7793 | 4153 return 1; |
9627 | 4154 |
9826 | 4155 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4156 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4157 g_free(buf); | |
9627 | 4158 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4159 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4160 } | |
4161 g_free(buf); | |
2086 | 4162 |
4163 return 1; | |
4164 } | |
4165 | |
7011 | 4166 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4167 GaimConnection *gc = sess->aux_data; |
8700 | 4168 GaimAccount *account = gaim_connection_get_account(gc); |
4169 GString *str; | |
9244 | 4170 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4171 va_list ap; |
7011 | 4172 aim_userinfo_t *userinfo; |
2086 | 4173 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4174 va_start(ap, fr); |
7011 | 4175 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4176 va_end(ap); |
4177 | |
8700 | 4178 str = g_string_new(""); |
4179 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4180 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4181 |
10116 | 4182 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
4183 time_t t = userinfo->onlinesince; | |
4184 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); | |
4185 } | |
4186 | |
4187 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
4188 time_t t = userinfo->membersince; | |
4189 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); | |
4190 } | |
7011 | 4191 |
4192 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4193 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4194 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4195 g_free(tmp); |
4196 } | |
4197 | |
8701 | 4198 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4199 |
4200 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4201 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4202 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4203 g_free(tmp); | |
7011 | 4204 if (away_utf8 != NULL) { |
8700 | 4205 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4206 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4207 } |
7011 | 4208 } |
4209 | |
4210 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4211 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4212 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4213 g_free(tmp); | |
7011 | 4214 if (info_utf8 != NULL) { |
8700 | 4215 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4216 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4217 } |
7011 | 4218 } |
4219 | |
8701 | 4220 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4221 g_string_free(str, TRUE); |
9244 | 4222 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4223 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4224 g_free(title); |
8700 | 4225 g_free(tmp); |
4151 | 4226 |
2086 | 4227 return 1; |
4228 } | |
4229 | |
8341 | 4230 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4231 { | |
4232 aim_session_t *sess = data; | |
4233 GaimConnection *gc = sess->aux_data; | |
4234 OscarData *od = (OscarData *)gc->proto_data; | |
4235 | |
4236 aim_locate_dorequest(data); | |
4237 od->getinfotimer = 0; | |
4238 | |
4239 return FALSE; | |
4240 } | |
4241 | |
4242 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4243 { | |
4244 GaimConnection *gc = sess->aux_data; | |
4245 OscarData *od = (OscarData *)gc->proto_data; | |
4246 | |
4247 /* | |
4248 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4249 * us from hitting the rate limit due to request away messages and info | |
4250 * too quickly. | |
4251 */ | |
4252 if (od->getinfotimer == 0) | |
10198 | 4253 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4254 |
4255 return 1; | |
4256 } | |
4257 | |
4258 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4259 { | |
2086 | 4260 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4261 fu16_t id; |
2086 | 4262 va_list ap; |
4263 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4264 va_start(ap, fr); |
4199 | 4265 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4266 msg = va_arg(ap, char *); |
4267 va_end(ap); | |
4268 | |
8660 | 4269 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4270 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4271 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4272 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4273 _("Your AIM connection may be lost."), NULL); |
2086 | 4274 |
4275 return 1; | |
4276 } | |
4277 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4278 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4279 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4280 fu16_t type; |
5575 | 4281 GaimConnection *gc = sess->aux_data; |
7283 | 4282 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4283 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4284 va_start(ap, fr); |
4199 | 4285 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4286 |
4287 switch(type) { | |
4288 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4289 fu8_t maxrooms; |
2086 | 4290 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4291 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4292 |
4199 | 4293 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4294 exchangecount = va_arg(ap, int); |
4295 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4296 | |
8660 | 4297 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4298 "chat info: Chat Rights:\n"); |
8660 | 4299 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4300 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4301 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4302 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4303 for (i = 0; i < exchangecount; i++) |
8660 | 4304 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4305 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4306 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4307 while (od->create_rooms) { |
4308 struct create_room *cr = od->create_rooms->data; | |
8660 | 4309 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4310 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4311 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4312 g_free(cr->name); |
4617 | 4313 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4314 g_free(cr); |
2086 | 4315 } |
4316 } | |
4317 break; | |
4318 case 0x0008: { | |
4319 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4320 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4321 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4322 fu32_t createtime; |
2086 | 4323 |
4324 fqcn = va_arg(ap, char *); | |
4200 | 4325 instance = (fu16_t)va_arg(ap, unsigned int); |
4326 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4327 flags = (fu16_t)va_arg(ap, unsigned int); | |
4328 createtime = va_arg(ap, fu32_t); | |
4329 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4330 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4331 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4332 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4333 name = va_arg(ap, char *); | |
4334 ck = va_arg(ap, char *); | |
4194 | 4335 |
8660 | 4336 gaim_debug_misc("oscar", |
5556 | 4337 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4338 fqcn, |
4339 exchange, instance, flags, | |
4340 createtime, | |
4341 maxmsglen, maxoccupancy, createperms, unknown, | |
4342 name, ck); | |
4617 | 4343 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4344 } |
4345 break; | |
4346 default: | |
8660 | 4347 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4348 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4349 break; |
4350 } | |
4194 | 4351 |
4352 va_end(ap); | |
4353 | |
2086 | 4354 return 1; |
4355 } | |
4356 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4357 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4358 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4359 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4360 aim_userinfo_t *info; |
5575 | 4361 GaimConnection *g = sess->aux_data; |
2086 | 4362 |
4363 struct chat_connection *c = NULL; | |
4364 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4365 va_start(ap, fr); |
2086 | 4366 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4367 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4368 va_end(ap); |
4369 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4370 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4371 if (!c) |
4372 return 1; | |
4373 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4374 for (i = 0; i < count; i++) |
9846 | 4375 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4376 |
4377 return 1; | |
4378 } | |
4379 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4380 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4381 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4382 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4383 aim_userinfo_t *info; |
5575 | 4384 GaimConnection *g = sess->aux_data; |
2086 | 4385 |
4386 struct chat_connection *c = NULL; | |
4387 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4388 va_start(ap, fr); |
2086 | 4389 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4390 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4391 va_end(ap); |
4392 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4393 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4394 if (!c) |
4395 return 1; | |
4396 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4397 for (i = 0; i < count; i++) |
8733 | 4398 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4399 |
4400 return 1; | |
4401 } | |
4402 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4403 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
|
4404 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4405 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4406 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4407 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4408 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4409 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4410 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4411 fu32_t creationtime; |
5575 | 4412 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4413 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
|
4414 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4415 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4416 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4417 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4418 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4419 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4420 roomdesc = va_arg(ap, char *); |
4200 | 4421 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4422 creationtime = va_arg(ap, fu32_t); | |
4423 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4424 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4425 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4426 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4427 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4428 |
8660 | 4429 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4430 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4431 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4432 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4433 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4434 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4435 |
2086 | 4436 return 1; |
4437 } | |
4438 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4439 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4440 GaimConnection *gc = sess->aux_data; |
8225 | 4441 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4442 gchar *utf8; | |
2086 | 4443 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4444 aim_userinfo_t *info; |
8225 | 4445 int len; |
2086 | 4446 char *msg; |
8219 | 4447 char *charset; |
2086 | 4448 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4449 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4450 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4451 len = va_arg(ap, int); |
4194 | 4452 msg = va_arg(ap, char *); |
8219 | 4453 charset = va_arg(ap, char *); |
4194 | 4454 va_end(ap); |
2086 | 4455 |
8225 | 4456 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4457 if (utf8 == NULL) |
4458 /* The conversion failed! */ | |
8668 | 4459 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4460 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4461 g_free(utf8); | |
2086 | 4462 |
4463 return 1; | |
4464 } | |
4465 | |
3694 | 4466 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4467 va_list ap; | |
5575 | 4468 GaimConnection *gc = sess->aux_data; |
3694 | 4469 struct aim_emailinfo *emailinfo; |
3725 | 4470 int havenewmail; |
7297 | 4471 char *alertitle, *alerturl; |
3694 | 4472 |
4473 va_start(ap, fr); | |
4474 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4475 havenewmail = va_arg(ap, int); |
7301 | 4476 alertitle = va_arg(ap, char *); |
4477 alerturl = va_arg(ap, char *); | |
3694 | 4478 va_end(ap); |
4479 | |
9661 | 4480 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4481 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4482 emailinfo->domain ? "@" : "", | |
4483 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4484 if (emailinfo->unread && havenewmail) |
4485 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4486 g_free(to); |
3694 | 4487 } |
10157 | 4488 |
7301 | 4489 if (alertitle) |
8660 | 4490 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4491 |
4492 return 1; | |
4493 } | |
4494 | |
4804 | 4495 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4496 GaimConnection *gc = sess->aux_data; |
7283 | 4497 OscarData *od = gc->proto_data; |
4804 | 4498 char *sn; |
4499 | |
4500 sn = od->requesticon->data; | |
8660 | 4501 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4502 "removing %s from hash table\n", sn); |
4804 | 4503 od->requesticon = g_slist_remove(od->requesticon, sn); |
4504 free(sn); | |
4505 | |
4506 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4507 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4508 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4509 |
4510 return 1; | |
4511 } | |
4512 | |
4513 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4514 GaimConnection *gc = sess->aux_data; |
7283 | 4515 OscarData *od = gc->proto_data; |
4804 | 4516 GSList *cur; |
4517 va_list ap; | |
4518 char *sn; | |
4853 | 4519 fu8_t *iconcsum, *icon; |
4520 fu16_t iconcsumlen, iconlen; | |
4804 | 4521 |
4522 va_start(ap, fr); | |
4523 sn = va_arg(ap, char *); | |
4853 | 4524 iconcsum = va_arg(ap, fu8_t *); |
4525 iconcsumlen = va_arg(ap, int); | |
4804 | 4526 icon = va_arg(ap, fu8_t *); |
4527 iconlen = va_arg(ap, int); | |
4528 va_end(ap); | |
4529 | |
4853 | 4530 if (iconlen > 0) { |
4531 char *b16; | |
6695 | 4532 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4533 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4534 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4535 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4536 if (b16) { |
7693 | 4537 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4538 g_free(b16); |
5129 | 4539 } |
4853 | 4540 } |
4804 | 4541 |
4542 cur = od->requesticon; | |
4543 while (cur) { | |
4544 char *cursn = cur->data; | |
4545 if (!aim_sncmp(cursn, sn)) { | |
4546 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4547 free(cursn); | |
4548 cur = od->requesticon; | |
4549 } else | |
4550 cur = cur->next; | |
4551 } | |
4552 | |
4553 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4554 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4555 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4556 |
4557 return 1; | |
4558 } | |
4559 | |
4560 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4561 GaimConnection *gc = data; |
7283 | 4562 OscarData *od = gc->proto_data; |
7011 | 4563 aim_userinfo_t *userinfo; |
4804 | 4564 aim_conn_t *conn; |
4565 | |
4566 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4567 if (!conn) { |
4568 if (!od->iconconnecting) { | |
4569 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4570 od->iconconnecting = TRUE; | |
4571 } | |
4804 | 4572 return FALSE; |
4573 } | |
4574 | |
5842 | 4575 if (od->set_icon) { |
6039 | 4576 struct stat st; |
4577 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4578 if (iconfile == NULL) { | |
8363 | 4579 aim_ssi_delicon(od->sess); |
6039 | 4580 } else if (!stat(iconfile, &st)) { |
4581 char *buf = g_malloc(st.st_size); | |
4582 FILE *file = fopen(iconfile, "rb"); | |
4583 if (file) { | |
9532 | 4584 /* XXX - Use g_file_get_contents()? */ |
6039 | 4585 fread(buf, 1, st.st_size, file); |
4586 fclose(file); | |
8660 | 4587 gaim_debug_info("oscar", |
6039 | 4588 "Uploading icon to icon server\n"); |
6879 | 4589 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4590 } else |
8660 | 4591 gaim_debug_error("oscar", |
6039 | 4592 "Can't open buddy icon file!\n"); |
4593 g_free(buf); | |
4594 } else { | |
8660 | 4595 gaim_debug_error("oscar", |
6039 | 4596 "Can't stat buddy icon file!\n"); |
5842 | 4597 } |
4598 od->set_icon = FALSE; | |
4599 } | |
4600 | |
4601 if (!od->requesticon) { | |
8660 | 4602 gaim_debug_misc("oscar", |
5842 | 4603 "no more icons to request\n"); |
4604 return FALSE; | |
4605 } | |
4606 | |
7045 | 4607 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4608 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4609 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4610 return FALSE; |
4611 } else { | |
4612 char *sn = od->requesticon->data; | |
4613 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4614 free(sn); | |
4615 } | |
4616 | |
4617 return TRUE; | |
4618 } | |
4619 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4620 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4621 * 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
|
4622 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4623 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4624 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4625 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4626 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4627 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4628 va_start(ap, fr); |
4199 | 4629 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4630 sn = va_arg(ap, char *); |
4631 va_end(ap); | |
4632 | |
8660 | 4633 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4634 |
4635 return 1; | |
4636 } | |
4637 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4638 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
|
4639 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4640 "invalid", |
4194 | 4641 "change", |
4642 "warning", | |
4643 "limit", | |
4644 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4645 }; |
2086 | 4646 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4647 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4648 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4649 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4650 va_start(ap, fr); |
4200 | 4651 code = (fu16_t)va_arg(ap, unsigned int); |
4652 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4653 windowsize = va_arg(ap, fu32_t); | |
4654 clear = va_arg(ap, fu32_t); | |
4655 alert = va_arg(ap, fu32_t); | |
4656 limit = va_arg(ap, fu32_t); | |
4657 disconnect = va_arg(ap, fu32_t); | |
4658 currentavg = va_arg(ap, fu32_t); | |
4659 maxavg = va_arg(ap, fu32_t); | |
2086 | 4660 va_end(ap); |
4661 | |
8660 | 4662 gaim_debug_misc("oscar", |
5556 | 4663 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4664 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4665 (code < 5) ? codes[code] : codes[0], |
4666 rateclass, | |
4667 currentavg, maxavg, | |
4668 alert, clear, | |
4669 limit, disconnect, | |
4670 windowsize); | |
4671 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4672 /* XXX fix these values */ |
2086 | 4673 if (code == AIM_RATE_CODE_CHANGE) { |
4674 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4675 aim_conn_setlatency(fr->conn, 0); |
2086 | 4676 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4677 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4678 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4679 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4680 _("The last action you attempted could not be " |
4681 "performed because you are over the rate limit. " | |
4682 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4683 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4684 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4685 aim_conn_setlatency(fr->conn, 0); |
2086 | 4686 } |
4687 | |
4688 return 1; | |
4689 } | |
4690 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4691 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4692 GaimConnection *gc = sess->aux_data; |
4693 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4694 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4695 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4696 aim_userinfo_t *userinfo; |
2086 | 4697 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4698 va_start(ap, fr); |
4199 | 4699 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4700 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4701 va_end(ap); |
4702 | |
9982 | 4703 /* XXX - What's with the + 0.5? */ |
4704 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4705 |
4706 return 1; | |
4707 } | |
4708 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4709 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4710 GaimConnection *gc = sess->aux_data; |
4711 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4712 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4713 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4714 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4715 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4716 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4717 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4718 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4719 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4720 |
9982 | 4721 warning_level = info->warnlevel/10.0 + 0.5; |
4722 | |
10152 | 4723 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4724 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4725 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4726 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4727 |
4649 | 4728 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4729 GaimConnection *gc = sess->aux_data; |
7283 | 4730 OscarData *od = gc->proto_data; |
4649 | 4731 va_list ap; |
4732 fu16_t code; | |
4733 char *msg; | |
4734 | |
4735 va_start(ap, fr); | |
4736 code = (fu16_t)va_arg(ap, int); | |
4737 msg = va_arg(ap, char *); | |
4738 va_end(ap); | |
4739 | |
8660 | 4740 gaim_debug_info("oscar", |
10130 | 4741 "Disconnected. Code is 0x%04x and msg is %s\n", code, |
4742 (msg != NULL ? msg : "")); | |
4743 | |
4649 | 4744 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4745 if (code == 0x0001) { |
6113 | 4746 gc->wants_to_die = TRUE; |
5579 | 4747 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4748 } else { |
5579 | 4749 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4750 } |
4666 | 4751 od->killme = TRUE; |
4649 | 4752 } |
4753 | |
4754 return 1; | |
4755 } | |
4756 | |
2675 | 4757 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4758 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4759 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4760 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4761 |
4762 #ifndef NOSSI | |
8660 | 4763 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4764 aim_ssi_reqrights(sess); |
6350 | 4765 aim_ssi_reqdata(sess); |
4230 | 4766 #endif |
4767 | |
7011 | 4768 aim_locate_reqrights(sess); |
7285 | 4769 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4770 aim_im_reqparams(sess); |
7334 | 4771 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4772 |
4773 #ifdef NOSSI | |
8660 | 4774 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4775 aim_bos_reqrights(sess, fr->conn); |
4230 | 4776 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4777 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4778 #endif | |
2086 | 4779 |
7283 | 4780 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4781 | |
2086 | 4782 return 1; |
4783 } | |
4784 | |
2675 | 4785 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4786 GaimConnection *gc = sess->aux_data; |
7283 | 4787 OscarData *od = gc->proto_data; |
2647 | 4788 |
6905 | 4789 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4790 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4791 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4792 | |
2672 | 4793 aim_clientready(sess, fr->conn); |
8660 | 4794 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4795 |
2647 | 4796 if (od->chpass) { |
8660 | 4797 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4798 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4799 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4800 od->oldp = NULL; |
2647 | 4801 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4802 od->newp = NULL; |
2647 | 4803 od->chpass = FALSE; |
4804 } | |
2979 | 4805 if (od->setnick) { |
8660 | 4806 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4807 aim_admin_setnick(sess, fr->conn, od->newsn); |
4808 g_free(od->newsn); | |
4809 od->newsn = NULL; | |
4810 od->setnick = FALSE; | |
4811 } | |
2647 | 4812 if (od->conf) { |
8660 | 4813 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4814 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4815 od->conf = FALSE; |
4816 } | |
4817 if (od->reqemail) { | |
8660 | 4818 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4819 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4820 od->reqemail = FALSE; |
4821 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4822 if (od->setemail) { |
8660 | 4823 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4824 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4825 g_free(od->email); |
5497 | 4826 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4827 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4828 } |
2647 | 4829 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4830 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4831 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4832 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4833 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
|
4834 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4835 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4836 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4837 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4838 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4839 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4840 |
4194 | 4841 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4842 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4843 "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
|
4844 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4845 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4846 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4847 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4848 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4849 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4850 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4851 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4852 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4853 |
4617 | 4854 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4855 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4856 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4857 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4858 |
2993 | 4859 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4860 { | |
5575 | 4861 GaimConnection *gc = sess->aux_data; |
7283 | 4862 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4863 va_list ap; |
4864 fu16_t maxsiglen; | |
2993 | 4865 |
4866 va_start(ap, fr); | |
4199 | 4867 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4868 va_end(ap); |
4869 | |
8660 | 4870 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4871 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4872 |
4617 | 4873 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4874 | |
4875 if (od->icq) | |
7334 | 4876 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4877 else |
7334 | 4878 aim_locate_setcaps(od->sess, caps_aim); |
4879 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4880 |
4881 return 1; | |
4882 } | |
4883 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4884 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
|
4885 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4886 fu16_t maxbuddies, maxwatchers; |
5575 | 4887 GaimConnection *gc = sess->aux_data; |
7283 | 4888 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4889 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4890 va_start(ap, fr); |
4199 | 4891 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4892 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4893 va_end(ap); |
4894 | |
8660 | 4895 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4896 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4897 |
4617 | 4898 od->rights.maxbuddies = (guint)maxbuddies; |
4899 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4900 |
2086 | 4901 return 1; |
4902 } | |
4903 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4904 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4905 GaimConnection *gc = sess->aux_data; |
7283 | 4906 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4907 va_list ap; |
4908 fu16_t maxpermits, maxdenies; | |
2086 | 4909 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4910 va_start(ap, fr); |
4199 | 4911 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4912 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4913 va_end(ap); |
4914 | |
8660 | 4915 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4916 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4917 |
4617 | 4918 od->rights.maxpermits = (guint)maxpermits; |
4919 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4920 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4921 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4922 serv_finish_login(gc); |
4923 | |
8660 | 4924 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4925 |
2672 | 4926 aim_clientready(sess, fr->conn); |
5948 | 4927 aim_srv_setavailmsg(sess, NULL); |
7474 | 4928 aim_srv_setidle(sess, 0); |
4617 | 4929 |
4664 | 4930 if (od->icq) { |
4931 aim_icq_reqofflinemsgs(sess); | |
4932 aim_icq_hideip(sess); | |
4933 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4934 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4935 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4936 if (sess->authinfo->email) |
4937 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4938 |
4939 return 1; | |
4940 } | |
4941 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4942 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
|
4943 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4944 struct aim_icq_offlinemsg *msg; |
4075 | 4945 struct aim_incomingim_ch4_args args; |
4946 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4947 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4948 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4949 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4950 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4951 |
8660 | 4952 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4953 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4954 args.uin = msg->sender; |
4955 args.type = msg->type; | |
4173 | 4956 args.flags = msg->flags; |
4076 | 4957 args.msglen = msg->msglen; |
4075 | 4958 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4959 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4960 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4961 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4962 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4963 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4964 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4965 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
|
4966 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4967 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4968 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4969 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4970 |
7388 | 4971 #if 0 |
4972 /* | |
7465 | 4973 * Update, 2003-11-09: |
4974 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4975 * | |
7388 | 4976 * It may not be my place to do this, but... |
4977 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4978 * stupid, and should not exist for % switches (%x in our case) that request | |
4979 * a year in the preferred representation for the current locale. For that | |
4980 * reason I've chosen to not use this workaround (n., see kluge). | |
4981 * | |
4982 * I have a date. I want to show it to the user in the "preferred" way. | |
4983 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4984 * what the locale wanted. | |
4985 * | |
4986 * If I have a necessity for a full representation of the year in the current | |
4987 * locale, then I'll use a switch that returns a full representation of the | |
4988 * year. | |
4989 * | |
4990 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4991 * (because you're anal, or whatever), then change the f***ing locale. | |
4992 * | |
4993 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4994 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4995 * |
4996 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4997 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4998 */ |
4999 | |
5000 /* | |
5001 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5002 * "last 2 digits" warning. |
5003 */ | |
10157 | 5004 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5005 const struct tm *tm) |
5006 { | |
5007 return strftime(s, max, fmt, tm); | |
5008 } | |
7388 | 5009 #endif |
7386 | 5010 |
4624 | 5011 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
|
5012 { |
5575 | 5013 GaimConnection *gc = sess->aux_data; |
8670 | 5014 OscarData *od = (OscarData *)gc->proto_data; |
5015 GaimBuddy *buddy; | |
8853 | 5016 struct buddyinfo *bi = NULL; |
4624 | 5017 gchar who[16]; |
8670 | 5018 GString *str; |
5019 gchar *primary, *utf8; | |
9634 | 5020 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5021 va_list ap; |
4151 | 5022 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5023 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5024 va_start(ap, fr); |
4151 | 5025 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5026 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5027 |
4664 | 5028 if (!info->uin) |
5029 return 0; | |
5030 | |
8670 | 5031 str = g_string_sized_new(100); |
5556 | 5032 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5033 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5034 if (buddy != NULL) | |
5035 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5036 | |
5037 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5038 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5039 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5040 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5041 (bi->ipaddr & 0xff000000) >> 24, | |
5042 (bi->ipaddr & 0x00ff0000) >> 16, | |
5043 (bi->ipaddr & 0x0000ff00) >> 8, | |
5044 (bi->ipaddr & 0x000000ff)); | |
8701 | 5045 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5046 g_free(tstr); |
5047 } | |
8701 | 5048 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5049 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5050 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5051 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5052 g_free(utf8); | |
4625 | 5053 } |
5054 if (info->numaddresses && info->email2) { | |
5055 int i; | |
5056 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5057 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5058 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5059 g_free(utf8); | |
4643 | 5060 } |
4625 | 5061 } |
4624 | 5062 } |
8701 | 5063 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5064 if (info->gender != 0) |
5065 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5066 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5067 char date[30]; |
5068 struct tm tm; | |
5069 tm.tm_mday = (int)info->birthday; | |
5070 tm.tm_mon = (int)info->birthmonth-1; | |
5071 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5072 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5073 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5074 } |
4624 | 5075 if (info->age) { |
5076 char age[5]; | |
5077 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5078 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5079 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5080 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5081 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5082 g_free(utf8); | |
4819 | 5083 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5084 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5085 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5086 g_free(utf8); | |
5087 } | |
5088 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5089 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5090 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5091 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5092 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5093 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5094 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5095 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5096 } |
4641 | 5097 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5098 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5099 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5100 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5101 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5102 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5103 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5104 } |
4641 | 5105 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5106 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5107 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5108 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5109 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5110 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5111 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5112 g_free(utf8); | |
4624 | 5113 } |
8670 | 5114 g_string_append_printf(str, "\n<hr>\n"); |
5115 } | |
5116 | |
9634 | 5117 if (buddy != NULL) |
5118 alias = gaim_buddy_get_alias(buddy); | |
5119 else | |
5120 alias = who; | |
5121 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5122 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5123 g_free(primary); |
8670 | 5124 g_string_free(str, TRUE); |
4151 | 5125 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5126 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5127 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5128 |
4759 | 5129 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5130 { | |
5575 | 5131 GaimConnection *gc = sess->aux_data; |
4820 | 5132 gchar who[16], *utf8; |
6695 | 5133 GaimBuddy *b; |
4759 | 5134 va_list ap; |
5135 struct aim_icq_info *info; | |
5136 | |
5137 va_start(ap, fr); | |
5138 info = va_arg(ap, struct aim_icq_info *); | |
5139 va_end(ap); | |
5140 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5141 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5142 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5143 serv_got_alias(gc, who, utf8); |
4759 | 5144 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5145 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5146 } |
4820 | 5147 g_free(utf8); |
4759 | 5148 } |
5149 | |
5150 return 1; | |
5151 } | |
5152 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5153 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
|
5154 { |
7032 | 5155 GaimConnection *gc = sess->aux_data; |
5156 gchar *text; | |
5157 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5158 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5159 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5160 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5161 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5162 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5163 url = va_arg(ap, char *); |
4199 | 5164 wid = (fu16_t) va_arg(ap, int); |
5165 hei = (fu16_t) va_arg(ap, int); | |
5166 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5167 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5168 |
7032 | 5169 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5170 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5171 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5172 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5173 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5174 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5175 |
7032 | 5176 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5177 { | |
6873 | 5178 GaimConnection *gc = sess->aux_data; |
5179 gchar *secondary; | |
5180 GString *text; | |
5181 int i, num; | |
2086 | 5182 va_list ap; |
6873 | 5183 char *email, *SNs; |
2086 | 5184 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5185 va_start(ap, fr); |
6873 | 5186 email = va_arg(ap, char *); |
2086 | 5187 num = va_arg(ap, int); |
5188 SNs = va_arg(ap, char *); | |
5189 va_end(ap); | |
5190 | |
8152 | 5191 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5192 text = g_string_new(""); |
2086 | 5193 for (i = 0; i < num; i++) |
6873 | 5194 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5195 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5196 | |
5197 g_free(secondary); | |
5198 g_string_free(text, TRUE); | |
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_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5204 va_list ap; |
6873 | 5205 char *email; |
5420 | 5206 char *buf; |
2086 | 5207 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5208 va_start(ap, fr); |
6873 | 5209 email = va_arg(ap, char *); |
2086 | 5210 va_end(ap); |
5211 | |
6873 | 5212 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
|
5213 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5214 g_free(buf); |
2086 | 5215 |
5216 return 1; | |
5217 } | |
5218 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5219 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5220 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5221 fu16_t status; |
2086 | 5222 va_list ap; |
5223 char msg[256]; | |
5224 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5225 va_start(ap, fr); |
4199 | 5226 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5227 va_end(ap); |
5228 | |
8660 | 5229 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5230 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5231 status ? "unknown" : "email sent"); |
5232 if (!status) { | |
5302 | 5233 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5234 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5235 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5236 } |
5237 | |
5238 return 1; | |
5239 } | |
5240 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5241 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5242 GaimConnection *gc = sess->aux_data; |
2086 | 5243 va_list ap; |
3912 | 5244 fu16_t perms, err; |
5245 char *url, *sn, *email; | |
5246 int change; | |
2086 | 5247 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5248 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5249 change = va_arg(ap, int); |
4199 | 5250 perms = (fu16_t) va_arg(ap, unsigned int); |
5251 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5252 url = va_arg(ap, char *); |
5253 sn = va_arg(ap, char *); | |
5254 email = va_arg(ap, char *); | |
2086 | 5255 va_end(ap); |
5256 | |
8660 | 5257 gaim_debug_misc("oscar", |
9626 | 5258 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5259 change ? "change" : "request", perms, err, | |
5260 (url != NULL) ? url : "(null)", | |
5261 (sn != NULL) ? sn : "(null)", | |
5262 (email != NULL) ? email : "(null)"); | |
5263 | |
5264 if ((err > 0) && (url != NULL)) { | |
3912 | 5265 char *dialog_msg; |
5266 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5267 switch (err) { | |
5268 case 0x0001: { | |
5269 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5270 } break; | |
5271 case 0x0006: { | |
5272 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5273 } break; | |
5274 case 0x000b: { | |
5275 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5276 } break; | |
5277 case 0x001d: { | |
5278 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); | |
5279 } break; | |
5280 case 0x0021: { | |
5281 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); | |
5282 } break; | |
5283 case 0x0023: { | |
5284 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5285 } break; | |
5286 default: { | |
5287 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5288 } break; | |
5289 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5290 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5291 g_free(dialog_top); |
5292 g_free(dialog_msg); | |
5293 return 1; | |
5294 } | |
5295 | |
9626 | 5296 if (sn != NULL) { |
4585 | 5297 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
|
5298 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5299 g_free(dialog_msg); |
5300 } | |
5301 | |
9626 | 5302 if (email != NULL) { |
5575 | 5303 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5304 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5305 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5306 g_free(dialog_msg); |
2086 | 5307 } |
5308 | |
5309 return 1; | |
5310 } | |
5311 | |
5575 | 5312 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5313 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5314 aim_flap_nop(od->sess, od->conn); |
2086 | 5315 } |
5316 | |
6059 | 5317 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5318 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5319 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5320 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5321 if (typing == GAIM_TYPING) |
4870 | 5322 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5323 else if (typing == GAIM_TYPED) |
4870 | 5324 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5325 else | |
5326 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5327 else { |
5300 | 5328 /* Don't send if this turkey is in our deny list */ |
5329 GSList *list; | |
5330 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5331 if (!list) { | |
7261 | 5332 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5333 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5334 if (typing == GAIM_TYPING) |
5300 | 5335 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5336 else if (typing == GAIM_TYPED) |
5300 | 5337 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5338 else | |
5339 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5340 } | |
3595 | 5341 } |
5342 } | |
2993 | 5343 return 0; |
5344 } | |
9030 | 5345 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5346 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
|
5347 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5348 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5349 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5350 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5351 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
|
5352 int ret = 0; |
10246 | 5353 const char *iconfile = gaim_account_get_buddy_icon(account); |
8800 | 5354 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5355 |
4838 | 5356 if (dim && dim->connected) { |
5357 /* If we're directly connected, send a direct IM */ | |
6982 | 5358 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5359 } else { |
4738 | 5360 struct buddyinfo *bi; |
3008 | 5361 struct aim_sendimext_args args; |
5362 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5363 gsize len; |
10246 | 5364 GaimConversation *conv; |
5365 | |
5366 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5367 |
5368 if (strstr(message, "<IMG ")) | |
5369 gaim_conversation_write(conv, "", | |
5370 _("Your IM Image was not sent. " | |
5371 "You must be Direct Connected to send IM Images."), | |
5372 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5373 |
10246 | 5374 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5375 if (!bi) { |
5376 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5377 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5378 } |
5379 | |
3008 | 5380 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5381 if (od->icq) { |
5382 args.features = features_icq; | |
5383 args.featureslen = sizeof(features_icq); | |
3008 | 5384 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5385 } else { |
5386 args.features = features_aim; | |
5387 args.featureslen = sizeof(features_aim); | |
4972 | 5388 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5389 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5390 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5391 } |
4269 | 5392 |
4738 | 5393 if (bi->ico_need) { |
8660 | 5394 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5395 "Sending buddy icon request with message\n"); |
3008 | 5396 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5397 bi->ico_need = FALSE; |
3008 | 5398 } |
4269 | 5399 |
5575 | 5400 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5401 FILE *file = fopen(iconfile, "rb"); |
3008 | 5402 if (file) { |
5403 char *buf = g_malloc(st.st_size); | |
9532 | 5404 /* XXX - Use g_file_get_contents()? */ |
3008 | 5405 fread(buf, 1, st.st_size, file); |
6039 | 5406 fclose(file); |
4269 | 5407 |
3008 | 5408 args.iconlen = st.st_size; |
4617 | 5409 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5410 args.iconstamp = st.st_mtime; |
5411 | |
7406 | 5412 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5413 bi->ico_informed = FALSE; |
7406 | 5414 bi->ico_sent = FALSE; |
5415 } | |
4738 | 5416 |
5417 if (!bi->ico_informed) { | |
8660 | 5418 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5419 "Claiming to have a buddy icon\n"); |
4738 | 5420 args.flags |= AIM_IMFLAGS_HASICON; |
5421 bi->ico_me_len = args.iconlen; | |
5422 bi->ico_me_csum = args.iconsum; | |
5423 bi->ico_me_time = args.iconstamp; | |
5424 bi->ico_informed = TRUE; | |
5425 } | |
5426 | |
3008 | 5427 g_free(buf); |
2086 | 5428 } |
5429 } | |
4269 | 5430 |
3008 | 5431 args.destsn = name; |
4269 | 5432 |
8985 | 5433 /* |
5434 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5435 * strip all HTML | |
5436 */ | |
9975 | 5437 if (aim_sn_is_icq(name) ) { |
8995 | 5438 /* being sent to an ICQ user */ |
10246 | 5439 if (!aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5440 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5441 tmpmsg = gaim_str_add_cr(message); | |
5442 } else { | |
5443 /* from an ICQ user - do nothing */ | |
5444 tmpmsg = g_strdup(message); | |
5445 } | |
5446 } else { | |
5447 /* being sent to an AIM user */ | |
10246 | 5448 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5449 /* from an ICQ user */ |
5450 tmpmsg2 = gaim_strdup_withhtml(message); | |
5451 tmpmsg = gaim_escape_html(tmpmsg2); | |
5452 g_free(tmpmsg2); | |
5453 } else | |
5454 tmpmsg = gaim_strdup_withhtml(message); | |
5455 } | |
6310 | 5456 len = strlen(tmpmsg); |
5457 | |
9830 | 5458 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5459 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5460 args.charset, args.charsubset, args.msglen); | |
4617 | 5461 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5462 g_free((char *)args.msg); |
2086 | 5463 } |
4838 | 5464 |
6310 | 5465 g_free(tmpmsg); |
5466 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5467 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5468 return 1; |
6310 | 5469 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5470 return ret; |
2086 | 5471 } |
5472 | |
7011 | 5473 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5474 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5475 |
9975 | 5476 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5477 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5478 else |
7235 | 5479 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5480 } |
5481 | |
8950 | 5482 #if 0 |
7011 | 5483 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5484 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5485 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5486 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5487 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5488 maiden, NULL, NULL, city, state, NULL, 0, web); |
5489 } | |
8950 | 5490 #endif |
2086 | 5491 |
5575 | 5492 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5493 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5494 aim_srv_setidle(od->sess, time); |
2086 | 5495 } |
5496 | |
5954 | 5497 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5498 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5499 int charset = 0; |
6019 | 5500 char *text_html = NULL; |
5129 | 5501 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5502 gsize msglen = 0; |
2993 | 5503 |
4617 | 5504 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5505 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5506 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5507 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5508 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5509 "again when you are fully connected.")); |
4617 | 5510 |
7334 | 5511 if (!text) { |
5512 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5513 return; | |
5514 } | |
10097 | 5515 |
7334 | 5516 text_html = gaim_strdup_withhtml(text); |
9807 | 5517 charset = oscar_charset_check(text_html); |
9826 | 5518 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5519 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5520 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5521 g_free(msg); | |
9826 | 5522 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5523 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5524 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5525 g_free(msg); | |
5526 } else { | |
5527 msglen = strlen(text_html); | |
5528 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5529 } | |
5530 | |
5531 if (msglen > od->rights.maxsiglen) { | |
5532 gchar *errstr; | |
5533 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5534 "has been exceeded. Gaim has truncated it for you.", | |
5535 "The maximum profile length of %d bytes " | |
5536 "has been exceeded. Gaim has truncated it for you.", | |
5537 od->rights.maxsiglen), od->rights.maxsiglen); | |
5538 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5539 g_free(errstr); | |
5540 } | |
5541 | |
5542 g_free(text_html); | |
2993 | 5543 |
5544 return; | |
2086 | 5545 } |
5546 | |
9991 | 5547 static void |
5548 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5549 { |
9991 | 5550 GaimConnection *gc = gaim_account_get_connection(account); |
5551 OscarData *od = (OscarData *)gc->proto_data; | |
9992 | 5552 GaimStatusType *status_type; |
9991 | 5553 GaimStatusPrimitive primitive; |
5554 GaimPresence *presence; | |
5555 const gchar *status_id; | |
9807 | 5556 int charset = 0; |
10196 | 5557 const gchar *text_html = NULL; |
5129 | 5558 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5559 gsize msglen = 0; |
2993 | 5560 |
9992 | 5561 status_type = gaim_status_get_type(status); |
5562 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5563 status_id = gaim_status_get_id(status); |
5564 presence = gaim_account_get_presence(account); | |
5565 | |
10196 | 5566 gaim_debug_info("oscar", "Setting status to %s\n", status_id); |
5567 | |
2993 | 5568 if (od->rights.maxawaymsglen == 0) |
9991 | 5569 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5570 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5571 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5572 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5573 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5574 "fully connected.")); |
5129 | 5575 |
9992 | 5576 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5577 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5578 | |
7334 | 5579 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5580 |
5581 text_html = gaim_status_get_attr_string(status, "message"); | |
5582 if (text_html != NULL) { | |
5583 aim_srv_setavailmsg(od->sess, text_html); | |
5584 } | |
10196 | 5585 |
5586 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5587 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5588 | |
10196 | 5589 text_html = gaim_status_get_attr_string(status, "message"); |
5590 | |
5591 if (text_html == NULL) { | |
5592 text_html = _("Away"); | |
5593 } | |
5594 | |
5595 charset = oscar_charset_check(text_html); | |
5596 if (charset == AIM_CHARSET_UNICODE) { | |
5597 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5598 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5599 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5600 g_free(msg); | |
5601 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5602 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5603 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5604 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5605 g_free(msg); | |
5606 } else { | |
5607 msglen = strlen(text_html); | |
5608 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5609 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5610 } | |
5611 | |
5612 if (msglen > od->rights.maxawaymsglen) { | |
5613 gchar *errstr; | |
5614 | |
5615 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
5616 "has been exceeded. Gaim has truncated it for you.", | |
5617 "The maximum away message length of %d bytes " | |
5618 "has been exceeded. Gaim has truncated it for you.", | |
5619 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5620 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5621 g_free(errstr); | |
5622 } | |
5623 | |
10197 | 5624 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5625 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5626 | |
5129 | 5627 } else { |
10196 | 5628 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5629 | |
5630 } | |
2993 | 5631 } |
5632 | |
9991 | 5633 static void |
5634 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5635 { |
9991 | 5636 GaimConnection *gc = gaim_account_get_connection(account); |
5637 OscarData *od = (OscarData *)gc->proto_data; | |
5638 const gchar *status_id = gaim_status_get_id(status); | |
5639 | |
5640 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) | |
5575 | 5641 account->perm_deny = 4; |
8265 | 5642 else |
5575 | 5643 account->perm_deny = 3; |
9991 | 5644 |
8265 | 5645 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5646 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5647 |
9991 | 5648 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5649 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5650 |
5651 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5652 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5653 |
5654 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5655 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5656 |
5657 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5658 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5659 |
5660 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5661 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5662 |
5663 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5664 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5665 |
5666 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5667 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5668 |
5669 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5670 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5671 |
5672 return; | |
5673 } | |
5674 | |
9991 | 5675 static void |
5676 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5677 { |
9991 | 5678 GaimConnection *gc = gaim_account_get_connection(account); |
5679 OscarData *od = (OscarData *)gc->proto_data; | |
2993 | 5680 |
5681 if (od->icq) | |
9988 | 5682 oscar_set_status_icq(account, status); |
2993 | 5683 else |
9988 | 5684 oscar_set_status_aim(account, status); |
2993 | 5685 |
5686 return; | |
2086 | 5687 } |
5688 | |
9991 | 5689 static void |
5690 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5691 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5692 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5693 } |
5694 | |
9285 | 5695 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5696 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5697 |
5698 if (!aim_snvalid(buddy->name)) { | |
8092 | 5699 gchar *buf; |
9285 | 5700 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 | 5701 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5702 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5703 g_free(buf); |
8150 | 5704 |
5705 /* Remove from local list */ | |
9285 | 5706 gaim_blist_remove_buddy(buddy); |
8150 | 5707 |
8092 | 5708 return; |
5709 } | |
5710 | |
4230 | 5711 #ifdef NOSSI |
9285 | 5712 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5713 #else |
9285 | 5714 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5715 if (buddy && group) { | |
8660 | 5716 gaim_debug_info("oscar", |
9285 | 5717 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5718 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5719 } |
5720 } | |
5721 #endif | |
8150 | 5722 |
10157 | 5723 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5724 if (od->icq) |
9285 | 5725 aim_icq_getalias(od->sess, buddy->name); |
5726 } | |
5727 | |
5728 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5729 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5730 #ifdef NOSSI |
5731 char buf[MSG_LEN]; | |
5732 int n=0; | |
9285 | 5733 |
4230 | 5734 while (buddies) { |
9381 | 5735 GaimBuddy *buddy = buddies->data; |
4230 | 5736 if (n > MSG_LEN - 18) { |
7285 | 5737 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5738 n = 0; |
3092 | 5739 } |
9381 | 5740 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5741 buddies = buddies->next; |
5742 } | |
7285 | 5743 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5744 #else |
9285 | 5745 |
4230 | 5746 if (od->sess->ssi.received_data) { |
9285 | 5747 GList *curb = buddies; |
5748 GList *curg = groups; | |
5749 while ((curb != NULL) && (curg != NULL)) { | |
5750 GaimBuddy *buddy = curb->data; | |
5751 GaimGroup *group = curg->data; | |
5752 oscar_add_buddy(gc, buddy, group); | |
5753 curb = curb->next; | |
5754 curg = curg->next; | |
4230 | 5755 } |
5756 } | |
5757 #endif | |
5758 } | |
5759 | |
9285 | 5760 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5761 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5762 |
4230 | 5763 #ifdef NOSSI |
9285 | 5764 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5765 #else |
5766 if (od->sess->ssi.received_data) { | |
8660 | 5767 gaim_debug_info("oscar", |
9285 | 5768 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5769 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5770 } |
5771 #endif | |
5772 } | |
5773 | |
9285 | 5774 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5775 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5776 |
4230 | 5777 #ifdef NOSSI |
9285 | 5778 for (cur = buddies; cur != NULL; cur = cur->next) { |
5779 GaimBuddy *buddy = cur->data; | |
5780 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5781 } | |
4230 | 5782 #else |
5783 if (od->sess->ssi.received_data) { | |
9285 | 5784 GList *curb = buddies; |
5785 GList *curg = groups; | |
5786 while ((curb != NULL) && (curg != NULL)) { | |
5787 GaimBuddy *buddy = curb->data; | |
5788 GaimGroup *group = curg->data; | |
5789 oscar_remove_buddy(gc, buddy, group); | |
5790 curb = curb->next; | |
5791 curg = curg->next; | |
3092 | 5792 } |
4230 | 5793 } |
5794 #endif | |
5795 } | |
5796 | |
5797 #ifndef NOSSI | |
5575 | 5798 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5799 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5800 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5801 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5802 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5803 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5804 } |
5805 } | |
5806 | |
5575 | 5807 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5808 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5809 if (od->sess->ssi.received_data) { |
5810 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5811 if (gname) { | |
8660 | 5812 gaim_debug_info("oscar", |
9586 | 5813 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5814 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5815 } |
5816 } | |
5817 } | |
5818 | |
9285 | 5819 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5820 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5821 |
5822 if (od->sess->ssi.received_data) { | |
9285 | 5823 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5824 GList *cur, *groups = NULL; | |
5825 | |
5826 /* Make a list of what the groups each buddy is in */ | |
5827 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5828 GaimBlistNode *node = cur->data; | |
5829 groups = g_list_append(groups, node->parent); | |
5830 } | |
5831 | |
5832 oscar_remove_buddies(gc, moved_buddies, groups); | |
5833 oscar_add_buddies(gc, moved_buddies, groups); | |
5834 g_list_free(groups); | |
8660 | 5835 gaim_debug_info("oscar", |
9285 | 5836 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5837 } else { |
9285 | 5838 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5839 gaim_debug_info("oscar", |
9285 | 5840 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5841 } |
5842 } | |
5843 } | |
5844 | |
5968 | 5845 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5846 aim_session_t *sess = data; | |
6350 | 5847 aim_ssi_reqdata(sess); |
5968 | 5848 return FALSE; |
5849 } | |
5850 | |
4642 | 5851 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5852 GaimConnection *gc = sess->aux_data; |
7283 | 5853 OscarData *od = gc->proto_data; |
4642 | 5854 va_list ap; |
5855 fu16_t reason; | |
5856 | |
5857 va_start(ap, fr); | |
5858 reason = (fu16_t)va_arg(ap, unsigned int); | |
5859 va_end(ap); | |
5860 | |
8660 | 5861 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5862 |
5863 if (reason == 0x0005) { | |
5892 | 5864 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5865 _("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
|
5866 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5867 } |
5868 | |
5869 /* Activate SSI */ | |
5870 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5871 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5872 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5873 aim_ssi_enable(od->sess); |
5874 | |
5875 return 1; | |
5876 } | |
5877 | |
2991 | 5878 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5879 GaimConnection *gc = sess->aux_data; |
7283 | 5880 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 5881 int i; |
5882 va_list ap; | |
5883 int numtypes; | |
4230 | 5884 fu16_t *maxitems; |
2991 | 5885 |
5886 va_start(ap, fr); | |
4230 | 5887 numtypes = va_arg(ap, int); |
5888 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5889 va_end(ap); |
5890 | |
8660 | 5891 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5892 |
4230 | 5893 for (i=0; i<numtypes; i++) |
8660 | 5894 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5895 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5896 |
8660 | 5897 gaim_debug_misc(NULL, "\n"); |
4230 | 5898 |
5899 if (numtypes >= 0) | |
5900 od->rights.maxbuddies = maxitems[0]; | |
5901 if (numtypes >= 1) | |
5902 od->rights.maxgroups = maxitems[1]; | |
5903 if (numtypes >= 2) | |
5904 od->rights.maxpermits = maxitems[2]; | |
5905 if (numtypes >= 3) | |
5906 od->rights.maxdenies = maxitems[3]; | |
2991 | 5907 |
5908 return 1; | |
5909 } | |
5910 | |
5911 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5912 GaimConnection *gc = sess->aux_data; |
5913 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 5914 GaimStatus *status; |
7283 | 5915 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5916 GaimGroup *g; |
5917 GaimBuddy *b; | |
2995 | 5918 struct aim_ssi_item *curitem; |
2991 | 5919 int tmp; |
4230 | 5920 va_list ap; |
8219 | 5921 fu16_t fmtver, numitems; |
5922 struct aim_ssi_item *items; | |
5923 fu32_t timestamp; | |
4230 | 5924 |
5925 va_start(ap, fr); | |
5926 fmtver = (fu16_t)va_arg(ap, int); | |
5927 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5928 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5929 timestamp = va_arg(ap, fu32_t); |
8219 | 5930 va_end(ap); |
2991 | 5931 |
8660 | 5932 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5933 "ssi: syncing local list and server list\n"); |
2991 | 5934 |
8219 | 5935 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5936 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 | 5937 return 1; |
5938 } | |
5939 | |
2991 | 5940 /* Clean the buddy list */ |
4889 | 5941 aim_ssi_cleanlist(sess); |
2991 | 5942 |
8150 | 5943 { /* If not in server list then prune from local list */ |
5944 GaimBlistNode *gnode, *cnode, *bnode; | |
5945 GaimBuddyList *blist; | |
9539 | 5946 GSList *cur, *next; |
8150 | 5947 |
5948 /* Buddies */ | |
5949 cur = NULL; | |
5950 if ((blist = gaim_get_blist()) != NULL) { | |
5951 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5952 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5953 continue; | |
5954 g = (GaimGroup *)gnode; | |
5955 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5956 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5957 continue; | |
5958 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5959 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5960 continue; | |
5961 b = (GaimBuddy *)bnode; | |
5962 if (b->account == gc->account) { | |
5963 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5964 /* If the buddy is an ICQ user then load his nickname */ | |
5965 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5966 char *alias; |
8150 | 5967 if (servernick) |
5968 serv_got_alias(gc, b->name, servernick); | |
5969 | |
5970 /* Store local alias on server */ | |
8214 | 5971 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5972 if (!alias && b->alias && strlen(b->alias)) |
5973 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5974 free(alias); | |
5975 } else { | |
8660 | 5976 gaim_debug_info("oscar", |
8150 | 5977 "ssi: removing buddy %s from local list\n", b->name); |
5978 /* We can't actually remove now because it will screw up our looping */ | |
5979 cur = g_slist_prepend(cur, b); | |
5980 } | |
5981 } | |
5982 } | |
5983 } | |
5984 } | |
5985 } | |
8175 | 5986 |
8150 | 5987 while (cur != NULL) { |
5988 b = cur->data; | |
5989 cur = g_slist_remove(cur, b); | |
5990 gaim_blist_remove_buddy(b); | |
5991 } | |
5992 | |
5993 /* Permit list */ | |
5994 if (gc->account->permit) { | |
9539 | 5995 next = gc->account->permit; |
5996 while (next != NULL) { | |
5997 cur = next; | |
5998 next = next->next; | |
8150 | 5999 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6000 gaim_debug_info("oscar", |
8150 | 6001 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6002 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6003 } | |
9539 | 6004 } |
8150 | 6005 } |
6006 | |
6007 /* Deny list */ | |
6008 if (gc->account->deny) { | |
9539 | 6009 next = gc->account->deny; |
6010 while (next != NULL) { | |
6011 cur = next; | |
6012 next = next->next; | |
8150 | 6013 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6014 gaim_debug_info("oscar", |
8150 | 6015 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6016 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6017 } | |
9539 | 6018 } |
8150 | 6019 } |
6020 /* Presence settings (idle time visibility) */ | |
6021 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6022 if (!(tmp & 0x400)) | |
6023 aim_ssi_setpresence(sess, tmp | 0x400); | |
6024 } /* end pruning buddies from local list */ | |
6025 | |
2991 | 6026 /* Add from server list to local list */ |
4230 | 6027 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6028 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6029 switch (curitem->type) { |
4230 | 6030 case 0x0000: { /* Buddy */ |
4251 | 6031 if (curitem->name) { |
4292 | 6032 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6033 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6034 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6035 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6036 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6037 /* Should gname be freed here? -- elb */ |
4754 | 6038 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6039 free(alias); |
8150 | 6040 if (b) { |
4292 | 6041 /* Get server stored alias */ |
4705 | 6042 if (alias_utf8) { |
8150 | 6043 g_free(b->alias); |
6044 b->alias = g_strdup(alias_utf8); | |
4705 | 6045 } |
4282 | 6046 } else { |
8150 | 6047 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6048 |
4754 | 6049 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6050 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6051 gaim_blist_add_group(g, NULL); |
6052 } | |
5146 | 6053 |
8660 | 6054 gaim_debug_info("oscar", |
9285 | 6055 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6056 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6057 } |
8341 | 6058 if (!aim_sncmp(curitem->name, account->username)) { |
6059 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6060 gaim_check_comment(od, comment); | |
6061 free(comment); | |
6062 } | |
7162 | 6063 g_free(gname_utf8); |
6064 g_free(alias_utf8); | |
2991 | 6065 } |
4230 | 6066 } break; |
6067 | |
6068 case 0x0001: { /* Group */ | |
4282 | 6069 /* Shouldn't add empty groups */ |
4230 | 6070 } break; |
6071 | |
6072 case 0x0002: { /* Permit buddy */ | |
2991 | 6073 if (curitem->name) { |
4230 | 6074 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6075 GSList *list; |
5575 | 6076 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6077 if (!list) { |
8660 | 6078 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6079 "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
|
6080 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6081 } |
6082 } | |
4230 | 6083 } break; |
6084 | |
6085 case 0x0003: { /* Deny buddy */ | |
2991 | 6086 if (curitem->name) { |
6087 GSList *list; | |
5575 | 6088 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6089 if (!list) { |
8660 | 6090 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6091 "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
|
6092 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6093 } |
6094 } | |
4230 | 6095 } break; |
6096 | |
6097 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6098 if (curitem->data) { |
6099 fu8_t permdeny; | |
5575 | 6100 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6101 gaim_debug_info("oscar", |
5575 | 6102 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6103 account->perm_deny = permdeny; | |
6104 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6105 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6106 } |
2991 | 6107 } |
6108 } | |
4230 | 6109 } break; |
6110 | |
6111 case 0x0005: { /* Presence setting */ | |
3109 | 6112 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6113 } break; |
2991 | 6114 } /* End of switch on curitem->type */ |
6115 } /* End of for loop */ | |
4230 | 6116 |
9991 | 6117 /* |
6118 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6119 * this. We probably want the SSI status setting to override the local | |
6120 * setting. | |
6121 */ | |
9982 | 6122 status = gaim_presence_get_active_status(account->presence); |
6123 if (gaim_status_is_available(status)) | |
4901 | 6124 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6125 | |
4342 | 6126 /* Activate SSI */ |
6127 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6128 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6129 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6130 "ssi: activating server-stored buddy list\n"); |
4642 | 6131 aim_ssi_enable(sess); |
4342 | 6132 |
2991 | 6133 return 1; |
2086 | 6134 } |
4230 | 6135 |
6136 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6137 GaimConnection *gc = sess->aux_data; |
4230 | 6138 va_list ap; |
6139 struct aim_ssi_tmp *retval; | |
6140 | |
6141 va_start(ap, fr); | |
6142 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6143 va_end(ap); | |
6144 | |
6145 while (retval) { | |
8660 | 6146 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6147 "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 | 6148 |
6149 if (retval->ack != 0xffff) | |
6150 switch (retval->ack) { | |
6151 case 0x0000: { /* added successfully */ | |
6152 } break; | |
6153 | |
4829 | 6154 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6155 gchar *buf; | |
6156 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 | 6157 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6158 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6159 g_free(buf); |
6160 } | |
6161 | |
7023 | 6162 case 0x000e: { /* buddy requires authorization */ |
4828 | 6163 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6164 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6165 } break; |
6166 | |
6167 default: { /* La la la */ | |
5197 | 6168 gchar *buf; |
8660 | 6169 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6170 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 | 6171 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6172 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6173 g_free(buf); |
4230 | 6174 } break; |
6175 } | |
6176 | |
6177 retval = retval->next; | |
6178 } | |
6179 | |
6180 return 1; | |
6181 } | |
6182 | |
8227 | 6183 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6184 GaimConnection *gc = sess->aux_data; | |
6185 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6186 GaimBuddy *b; | |
6187 GaimGroup *g; | |
6188 va_list ap; | |
6189 fu16_t type; | |
6190 const char *name; | |
6191 | |
6192 va_start(ap, fr); | |
6193 type = (fu16_t)va_arg(ap, int); | |
6194 name = va_arg(ap, char *); | |
6195 va_end(ap); | |
6196 | |
6197 if ((type != 0x0000) || (name == NULL)) | |
6198 return 1; | |
6199 | |
6200 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6201 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6202 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6203 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6204 b = gaim_find_buddy(gc->account, name); | |
6205 free(alias); | |
6206 | |
6207 if (b) { | |
6208 /* Get server stored alias */ | |
6209 if (alias_utf8) { | |
6210 g_free(b->alias); | |
6211 b->alias = g_strdup(alias_utf8); | |
6212 } | |
6213 } else { | |
6214 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6215 | |
6216 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6217 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6218 gaim_blist_add_group(g, NULL); | |
6219 } | |
6220 | |
8660 | 6221 gaim_debug_info("oscar", |
9285 | 6222 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6223 gaim_blist_add_buddy(b, NULL, g, NULL); |
6224 } | |
6225 g_free(gname_utf8); | |
6226 g_free(alias_utf8); | |
6227 | |
6228 return 1; | |
6229 } | |
6230 | |
4230 | 6231 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6232 GaimConnection *gc = sess->aux_data; |
4230 | 6233 va_list ap; |
6234 char *sn, *msg; | |
4236 | 6235 gchar *dialog_msg, *nombre; |
4230 | 6236 struct name_data *data; |
6695 | 6237 GaimBuddy *buddy; |
4230 | 6238 |
6239 va_start(ap, fr); | |
6240 sn = va_arg(ap, char *); | |
6241 msg = va_arg(ap, char *); | |
6242 va_end(ap); | |
6243 | |
8660 | 6244 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6245 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6246 |
4687 | 6247 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6248 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6249 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6250 else |
6251 nombre = g_strdup(sn); | |
6252 | |
6253 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 | 6254 data = g_new(struct name_data, 1); |
6255 data->gc = gc; | |
6256 data->name = g_strdup(sn); | |
6257 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6258 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6259 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6260 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6261 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6262 G_CALLBACK(oscar_free_name_data)); |
4236 | 6263 |
4230 | 6264 g_free(dialog_msg); |
4236 | 6265 g_free(nombre); |
4230 | 6266 |
6267 return 1; | |
6268 } | |
6269 | |
6270 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6271 GaimConnection *gc = sess->aux_data; |
4230 | 6272 va_list ap; |
6273 char *sn, *msg; | |
4236 | 6274 gchar *dialog_msg, *nombre; |
4230 | 6275 struct name_data *data; |
6695 | 6276 GaimBuddy *buddy; |
4230 | 6277 |
6278 va_start(ap, fr); | |
6279 sn = va_arg(ap, char *); | |
6280 msg = va_arg(ap, char *); | |
6281 va_end(ap); | |
6282 | |
8660 | 6283 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6284 "ssi: received authorization request from %s\n", sn); |
4230 | 6285 |
4687 | 6286 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6287 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6288 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6289 else |
6290 nombre = g_strdup(sn); | |
6291 | |
4337 | 6292 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 | 6293 data = g_new(struct name_data, 1); |
6294 data->gc = gc; | |
6295 data->name = g_strdup(sn); | |
6296 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6297 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6298 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6299 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6300 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6301 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6302 |
4230 | 6303 g_free(dialog_msg); |
4236 | 6304 g_free(nombre); |
4230 | 6305 |
6306 return 1; | |
6307 } | |
6308 | |
6309 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6310 GaimConnection *gc = sess->aux_data; |
4230 | 6311 va_list ap; |
6312 char *sn, *msg; | |
4236 | 6313 gchar *dialog_msg, *nombre; |
4230 | 6314 fu8_t reply; |
6695 | 6315 GaimBuddy *buddy; |
4230 | 6316 |
6317 va_start(ap, fr); | |
6318 sn = va_arg(ap, char *); | |
6319 reply = (fu8_t)va_arg(ap, int); | |
6320 msg = va_arg(ap, char *); | |
6321 va_end(ap); | |
6322 | |
8660 | 6323 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6324 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6325 |
4687 | 6326 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6327 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6328 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6329 else |
6330 nombre = g_strdup(sn); | |
6331 | |
4230 | 6332 if (reply) { |
6333 /* Granted */ | |
7023 | 6334 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
|
6335 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6336 } else { |
6337 /* Denied */ | |
7023 | 6338 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
|
6339 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6340 } |
6341 g_free(dialog_msg); | |
4236 | 6342 g_free(nombre); |
4230 | 6343 |
6344 return 1; | |
6345 } | |
6346 | |
6347 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6348 GaimConnection *gc = sess->aux_data; |
4230 | 6349 va_list ap; |
6350 char *sn; | |
6695 | 6351 GaimBuddy *buddy; |
4230 | 6352 |
6353 va_start(ap, fr); | |
6354 sn = va_arg(ap, char *); | |
6355 va_end(ap); | |
6356 | |
4687 | 6357 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6358 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6359 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6360 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6361 |
6362 return 1; | |
6363 } | |
4269 | 6364 #endif |
2086 | 6365 |
5575 | 6366 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6367 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6368 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6369 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6370 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6371 pce->label = _("_Room:"); |
5234 | 6372 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6373 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6374 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6375 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6376 pce->label = _("_Exchange:"); |
5234 | 6377 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6378 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6379 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6380 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6381 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6382 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6383 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6384 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6385 |
9754 | 6386 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6387 { | |
6388 GHashTable *defaults; | |
6389 | |
6390 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6391 | |
6392 if (chat_name != NULL) | |
6393 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6394 | |
6395 return defaults; | |
6396 } | |
6397 | |
9917 | 6398 static char *oscar_get_chat_name(GHashTable *data) { |
6399 return g_strdup(g_hash_table_lookup(data, "room")); | |
6400 } | |
6401 | |
8308 | 6402 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6403 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6404 aim_conn_t *cur; |
5234 | 6405 char *name, *exchange; |
6406 | |
6407 name = g_hash_table_lookup(data, "room"); | |
6408 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6409 |
8660 | 6410 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6411 "Attempting to join chat room %s.\n", name); |
8308 | 6412 |
6413 if ((name == NULL) || (*name == '\0')) { | |
6414 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6415 return; | |
6416 } | |
6417 | |
4617 | 6418 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6419 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6420 "chatnav exists, creating room\n"); |
5234 | 6421 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6422 } else { |
6423 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6424 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6425 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6426 "chatnav does not exist, opening chatnav\n"); |
5234 | 6427 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6428 cr->name = g_strdup(name); |
4617 | 6429 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6430 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6431 } |
6432 } | |
6433 | |
8308 | 6434 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6435 OscarData *od = (OscarData *)gc->proto_data; | |
6436 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6437 |
6438 if (!ccon) | |
6439 return; | |
6440 | |
8225 | 6441 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6442 ccon->exchange, ccon->name, 0x0); |
6443 } | |
6444 | |
8308 | 6445 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6446 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6447 GSList *bcs = gc->buddy_chats; | |
5679 | 6448 GaimConversation *b = NULL; |
2086 | 6449 struct chat_connection *c = NULL; |
6450 int count = 0; | |
6451 | |
6452 while (bcs) { | |
6453 count++; | |
5679 | 6454 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6455 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6456 break; |
6457 bcs = bcs->next; | |
6458 b = NULL; | |
6459 } | |
6460 | |
6461 if (!b) | |
6462 return; | |
6463 | |
8660 | 6464 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6465 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6466 |
8308 | 6467 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6468 if (c != NULL) { |
4617 | 6469 if (od) |
6470 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6471 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6472 gaim_input_remove(c->inpa); |
8308 | 6473 if (gc && od->sess) |
4617 | 6474 aim_conn_kill(od->sess, &c->conn); |
2086 | 6475 g_free(c->name); |
6476 g_free(c->show); | |
6477 g_free(c); | |
6478 } | |
6479 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6480 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6481 } |
6482 | |
8219 | 6483 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6484 OscarData *od = (OscarData *)gc->proto_data; | |
6485 GaimConversation *conv = NULL; | |
2086 | 6486 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6487 char *buf, *buf2; |
9830 | 6488 fu16_t charset, charsubset; |
9807 | 6489 char *charsetstr = NULL; |
10111 | 6490 int len; |
8219 | 6491 |
6492 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6493 return -EINVAL; |
2086 | 6494 |
8219 | 6495 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6496 return -EINVAL; |
2086 | 6497 |
8219 | 6498 buf = gaim_strdup_withhtml(message); |
6499 len = strlen(buf); | |
6500 | |
8962 | 6501 if (strstr(buf, "<IMG ")) |
6502 gaim_conversation_write(conv, "", | |
6503 _("Your IM Image was not sent. " | |
6504 "You cannot send IM Images in AIM chats."), | |
6505 GAIM_MESSAGE_ERROR, time(NULL)); | |
6506 | |
9830 | 6507 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6508 if ((len > c->maxlen) || (len > c->maxvis)) { |
6509 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6510 return -E2BIG; |
8359 | 6511 } |
6512 | |
9831 | 6513 if (charset == AIM_CHARSET_ASCII) |
6514 charsetstr = "us-ascii"; | |
6515 else if (charset == AIM_CHARSET_UNICODE) | |
6516 charsetstr = "unicode-2-0"; | |
6517 else if (charset == AIM_CHARSET_CUSTOM) | |
6518 charsetstr = "iso-8859-1"; | |
9807 | 6519 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6520 g_free(buf2); |
8359 | 6521 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6522 return 0; |
2086 | 6523 } |
6524 | |
10042 | 6525 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6526 { | |
4766 | 6527 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6528 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6529 return "icq"; |
6530 else | |
6531 return "aim"; | |
6532 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6533 |
9975 | 6534 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6535 return "icq"; |
6536 return "aim"; | |
6537 } | |
6538 | |
9972 | 6539 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6540 { |
7334 | 6541 GaimConnection *gc = NULL; |
6542 OscarData *od = NULL; | |
10042 | 6543 GaimAccount *account = NULL; |
6544 GaimPresence *presence; | |
6545 GaimStatus *status; | |
6546 const char *status_id; | |
4687 | 6547 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6548 int i = 0; | |
7334 | 6549 aim_userinfo_t *userinfo = NULL; |
6550 | |
6551 if (b != NULL) | |
6552 account = b->account; | |
6553 if (account != NULL) | |
6554 gc = account->gc; | |
6555 if (gc != NULL) | |
6556 od = gc->proto_data; | |
7945 | 6557 if (od != NULL) |
6558 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6559 |
10042 | 6560 presence = gaim_buddy_get_presence(b); |
6561 status = gaim_presence_get_active_status(presence); | |
6562 status_id = gaim_status_get_id(status); | |
6563 | |
6564 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6565 char *gname; |
7334 | 6566 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6567 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6568 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6569 emblems[i++] = "notauthorized"; | |
6570 } else { | |
6571 emblems[i++] = "offline"; | |
6572 } | |
6573 } | |
4916 | 6574 |
10042 | 6575 if (b->name && aim_sn_is_icq(b->name)) { |
6576 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6577 emblems[i++] = "invisible"; | |
6578 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6579 emblems[i++] = "freeforchat"; |
10042 | 6580 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6581 emblems[i++] = "dnd"; |
10042 | 6582 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6583 emblems[i++] = "na"; |
10042 | 6584 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6585 emblems[i++] = "occupied"; |
10042 | 6586 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6587 emblems[i++] = "away"; |
10042 | 6588 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6589 emblems[i++] = "away"; | |
6590 } | |
6591 | |
6592 if (userinfo != NULL ) { | |
6593 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6594 emblems[i++] = "unconfirmed"; */ | |
6595 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6596 emblems[i++] = "admin"; | |
6597 if (userinfo->flags & AIM_FLAG_AOL) | |
6598 emblems[i++] = "aol"; | |
6599 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6600 emblems[i++] = "wireless"; | |
6601 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6602 emblems[i++] = "activebuddy"; | |
6603 | |
6604 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6605 emblems[i++] = "hiptop"; |
6606 | |
10042 | 6607 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6608 emblems[i++] = "secure"; |
10042 | 6609 } |
7334 | 6610 |
4687 | 6611 *se = emblems[0]; |
6612 *sw = emblems[1]; | |
6613 *nw = emblems[2]; | |
6614 *ne = emblems[3]; | |
6615 } | |
6616 | |
6695 | 6617 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6618 GaimConnection *gc = b->account->gc; |
7283 | 6619 OscarData *od = gc->proto_data; |
7045 | 6620 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6621 GString *str = g_string_new(""); |
5131 | 6622 |
6623 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6624 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6625 |
6626 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6627 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6628 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6629 g_free(charset); |
7011 | 6630 if (away_utf8 != NULL) { |
7091 | 6631 gchar *tmp1, *tmp2; |
9627 | 6632 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6633 g_free(away_utf8); |
8571 | 6634 tmp1 = gaim_escape_html(tmp2); |
7091 | 6635 g_free(tmp2); |
8700 | 6636 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6637 g_free(tmp1); |
8701 | 6638 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6639 g_free(tmp2); |
5836 | 6640 } |
5131 | 6641 } |
8701 | 6642 } |
6643 | |
6644 return g_string_free(str, FALSE); | |
5131 | 6645 } |
6646 | |
10042 | 6647 static char *oscar_status_text(GaimBuddy *b) |
6648 { | |
6649 GaimConnection *gc; | |
6650 OscarData *od; | |
6651 GaimStatus *status; | |
5167 | 6652 gchar *ret = NULL; |
6653 | |
10042 | 6654 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6655 od = gc->proto_data; | |
6656 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6657 | |
6658 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6659 if (aim_sn_is_icq(b->name)) |
8701 | 6660 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6661 else |
6662 ret = g_strdup(_("Away")); | |
5836 | 6663 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6664 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6665 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6666 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6667 } else { |
5167 | 6668 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6669 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6670 ret = g_strdup(_("Not Authorized")); | |
6671 else | |
6672 ret = g_strdup(_("Offline")); | |
6673 } | |
6674 | |
6675 return ret; | |
6676 } | |
6677 | |
5842 | 6678 |
5844 | 6679 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6680 GaimConnection *gc = sess->aux_data; |
7283 | 6681 OscarData *od = gc->proto_data; |
5892 | 6682 va_list ap; |
5842 | 6683 fu16_t type; |
5892 | 6684 fu8_t flags = 0, length = 0; |
6685 char *md5 = NULL; | |
6686 | |
7334 | 6687 |
5842 | 6688 va_start(ap, fr); |
6689 type = va_arg(ap, int); | |
5892 | 6690 |
6691 switch(type) { | |
6692 case 0x0000: | |
6693 case 0x0001: { | |
6694 flags = va_arg(ap, int); | |
6695 length = va_arg(ap, int); | |
6696 md5 = va_arg(ap, char *); | |
6697 | |
6698 if (flags == 0x41) { | |
6699 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6700 od->iconconnecting = TRUE; | |
6701 od->set_icon = TRUE; | |
6702 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6703 } else { | |
6039 | 6704 struct stat st; |
6705 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6706 if (iconfile == NULL) { | |
8363 | 6707 aim_ssi_delicon(od->sess); |
6039 | 6708 } else if (!stat(iconfile, &st)) { |
6709 char *buf = g_malloc(st.st_size); | |
6710 FILE *file = fopen(iconfile, "rb"); | |
6711 if (file) { | |
9532 | 6712 /* XXX - Use g_file_get_contents()? */ |
6039 | 6713 fread(buf, 1, st.st_size, file); |
6714 fclose(file); | |
8660 | 6715 gaim_debug_info("oscar", |
10042 | 6716 "Uploading icon to icon server\n"); |
6879 | 6717 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6718 } else |
8660 | 6719 gaim_debug_error("oscar", |
10042 | 6720 "Can't open buddy icon file!\n"); |
6039 | 6721 g_free(buf); |
6722 } else { | |
8660 | 6723 gaim_debug_error("oscar", |
10042 | 6724 "Can't stat buddy icon file!\n"); |
5892 | 6725 } |
6726 } | |
8363 | 6727 } else if (flags == 0x81) { |
6728 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6729 if (iconfile == NULL) | |
6730 aim_ssi_delicon(od->sess); | |
6731 else | |
6732 aim_ssi_seticon(od->sess, md5, length); | |
6733 } | |
5892 | 6734 } break; |
6735 | |
6736 case 0x0002: { /* We just set an "available" message? */ | |
6737 } break; | |
6738 } | |
6739 | |
5842 | 6740 va_end(ap); |
5844 | 6741 |
6742 return 0; | |
5842 | 6743 } |
5892 | 6744 |
5575 | 6745 static void oscar_set_permit_deny(GaimConnection *gc) { |
6746 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6747 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6748 #ifdef NOSSI |
8143 | 6749 GSList *list; |
4230 | 6750 char buf[MAXMSGLEN]; |
6751 int at; | |
6752 | |
5575 | 6753 switch(account->perm_deny) { |
8175 | 6754 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6755 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6756 break; |
8175 | 6757 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6758 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6759 break; |
8175 | 6760 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6761 list = account->permit; |
4230 | 6762 at = 0; |
6763 while (list) { | |
6764 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6765 list = list->next; | |
6766 } | |
6767 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6768 break; | |
8175 | 6769 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6770 list = account->deny; |
4230 | 6771 at = 0; |
6772 while (list) { | |
6773 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6774 list = list->next; | |
6775 } | |
6776 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6777 break; | |
6778 default: | |
6779 break; | |
2086 | 6780 } |
4230 | 6781 #else |
8175 | 6782 if (od->sess->ssi.received_data) { |
6783 switch (account->perm_deny) { | |
6784 case GAIM_PRIVACY_ALLOW_ALL: | |
6785 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6786 break; | |
6787 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6788 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6789 break; | |
6790 case GAIM_PRIVACY_ALLOW_USERS: | |
6791 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6792 break; | |
6793 case GAIM_PRIVACY_DENY_ALL: | |
6794 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6795 break; | |
6796 case GAIM_PRIVACY_DENY_USERS: | |
6797 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6798 break; | |
6799 default: | |
6800 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6801 break; | |
6802 } | |
6803 } | |
4230 | 6804 #endif |
2086 | 6805 } |
6806 | |
5575 | 6807 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6808 #ifdef NOSSI |
8143 | 6809 if (gc->account->perm_deny == 3) |
4269 | 6810 oscar_set_permit_deny(gc); |
6811 #else | |
7283 | 6812 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6813 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6814 if (od->sess->ssi.received_data) |
4889 | 6815 aim_ssi_addpermit(od->sess, who); |
4230 | 6816 #endif |
2086 | 6817 } |
6818 | |
5575 | 6819 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6820 #ifdef NOSSI |
8143 | 6821 if (gc->account->perm_deny == 4) |
4269 | 6822 oscar_set_permit_deny(gc); |
6823 #else | |
7283 | 6824 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6825 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6826 if (od->sess->ssi.received_data) |
4889 | 6827 aim_ssi_adddeny(od->sess, who); |
4230 | 6828 #endif |
2086 | 6829 } |
6830 | |
5575 | 6831 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6832 #ifdef NOSSI |
8143 | 6833 if (gc->account->perm_deny == 3) |
4269 | 6834 oscar_set_permit_deny(gc); |
6835 #else | |
7283 | 6836 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6837 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6838 if (od->sess->ssi.received_data) |
4889 | 6839 aim_ssi_delpermit(od->sess, who); |
4230 | 6840 #endif |
2086 | 6841 } |
6842 | |
5575 | 6843 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6844 #ifdef NOSSI |
8143 | 6845 if (gc->account->perm_deny == 4) |
4269 | 6846 oscar_set_permit_deny(gc); |
6847 #else | |
7283 | 6848 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6849 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6850 if (od->sess->ssi.received_data) |
4889 | 6851 aim_ssi_deldeny(od->sess, who); |
4230 | 6852 #endif |
2086 | 6853 } |
6854 | |
9975 | 6855 static GList * |
6856 oscar_status_types(GaimAccount *account) | |
2086 | 6857 { |
9975 | 6858 GList *status_types = NULL; |
6859 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6860 |
9973 | 6861 g_return_val_if_fail(account != NULL, NULL); |
6862 | |
10042 | 6863 /* Oscar-common status types */ |
9991 | 6864 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
6865 OSCAR_STATUS_ID_OFFLINE, | |
6866 _("Offline"), FALSE, FALSE, FALSE); | |
9976 | 6867 status_types = g_list_append(status_types, type); |
6868 | |
9991 | 6869 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
6870 OSCAR_STATUS_ID_ONLINE, | |
6871 _("Online"), FALSE, FALSE, FALSE); | |
9976 | 6872 status_types = g_list_append(status_types, type); |
6873 | |
10198 | 6874 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
6875 OSCAR_STATUS_ID_AVAILABLE, | |
6876 _("Available"), TRUE, TRUE, FALSE, | |
6877 "message", _("Message"), | |
6878 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 6879 status_types = g_list_append(status_types, type); |
6880 | |
10195 | 6881 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
6882 OSCAR_STATUS_ID_AWAY, | |
6883 _("Away"), TRUE, TRUE, FALSE, | |
6884 "message", _("Message"), | |
6885 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 6886 status_types = g_list_append(status_types, type); |
6887 | |
6888 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
6889 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 6890 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 6891 status_types = g_list_append(status_types, type); |
6892 | |
6893 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
6894 return status_types; | |
6895 | |
6896 /* ICQ-specific status types */ | |
6897 | |
9991 | 6898 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6899 OSCAR_STATUS_ID_FREE4CHAT, | |
6900 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 6901 status_types = g_list_append(status_types, type); |
6902 | |
9991 | 6903 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
6904 OSCAR_STATUS_ID_OCCUPIED, | |
6905 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 6906 status_types = g_list_append(status_types, type); |
6907 | |
9991 | 6908 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6909 OSCAR_STATUS_ID_DND, | |
6910 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 6911 status_types = g_list_append(status_types, type); |
6912 | |
9991 | 6913 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6914 OSCAR_STATUS_ID_NA, | |
6915 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 6916 status_types = g_list_append(status_types, type); |
9975 | 6917 |
6918 return status_types; | |
4333 | 6919 } |
6920 | |
7172 | 6921 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6922 GaimConnection *gc = data->gc; |
6923 OscarData *od = gc->proto_data; | |
7172 | 6924 GaimBuddy *b; |
6925 GaimGroup *g; | |
6926 | |
6927 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6928 oscar_free_name_data(data); | |
6929 return; | |
6930 } | |
6931 | |
6932 if (!(g = gaim_find_buddys_group(b))) { | |
6933 oscar_free_name_data(data); | |
6934 return; | |
6935 } | |
6936 | |
6937 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6938 |
6939 if (!aim_sncmp(data->name, gc->account->username)) | |
6940 gaim_check_comment(od, text); | |
6941 | |
7172 | 6942 oscar_free_name_data(data); |
6943 } | |
6944 | |
9030 | 6945 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6946 | |
6947 GaimBuddy *buddy; | |
6948 GaimConnection *gc; | |
6949 OscarData *od; | |
6950 struct name_data *data; | |
7172 | 6951 GaimGroup *g; |
6952 char *comment; | |
6953 gchar *comment_utf8; | |
9631 | 6954 gchar *title; |
7172 | 6955 |
9030 | 6956 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6957 | |
6958 buddy = (GaimBuddy *) node; | |
6959 gc = gaim_account_get_connection(buddy->account); | |
6960 od = gc->proto_data; | |
6961 | |
6962 data = g_new(struct name_data, 1); | |
6963 | |
6964 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6965 return; |
9030 | 6966 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6967 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6968 | |
6969 data->gc = gc; | |
9030 | 6970 data->name = g_strdup(buddy->name); |
7172 | 6971 data->nick = NULL; |
6972 | |
9631 | 6973 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6974 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6975 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6976 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6977 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6978 data); | |
9631 | 6979 g_free(title); |
7172 | 6980 |
6981 free(comment); | |
6982 g_free(comment_utf8); | |
6983 } | |
6984 | |
9030 | 6985 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6986 | |
6987 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6988 OscarData *od = gc->proto_data; |
9030 | 6989 |
4333 | 6990 GList *m = NULL; |
9030 | 6991 GaimBlistNodeAction *act; |
6992 | |
6993 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6994 oscar_buddycb_edit_comment, NULL); | |
6995 m = g_list_append(m, act); | |
7172 | 6996 |
4333 | 6997 if (od->icq) { |
4624 | 6998 #if 0 |
9030 | 6999 act = gaim_blist_node_action_new(_("Get Status Msg"), |
7000 oscar_get_icqstatusmsg, NULL); | |
7001 m = g_list_append(m, act); | |
4624 | 7002 #endif |
4333 | 7003 } else { |
7011 | 7004 aim_userinfo_t *userinfo; |
9030 | 7005 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7006 | |
7007 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7008 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7009 | |
7011 | 7010 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7011 act = gaim_blist_node_action_new(_("Direct IM"), |
7012 oscar_ask_direct_im, NULL); | |
7013 m = g_list_append(m, act); | |
5917 | 7014 } |
9466 | 7015 #if 0 |
7011 | 7016 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7017 act = gaim_blist_node_action_new(_("Get File"), |
7018 oscar_ask_getfile, NULL); | |
7019 m = g_list_append(m, act); | |
5917 | 7020 } |
4826 | 7021 #endif |
4333 | 7022 } |
5131 | 7023 } |
5197 | 7024 |
5131 | 7025 if (od->sess->ssi.received_data) { |
9030 | 7026 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7027 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7028 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
7029 gaim_auth_sendrequest_menu, NULL); | |
7030 m = g_list_append(m, act); | |
4333 | 7031 } |
4916 | 7032 } |
10157 | 7033 |
4333 | 7034 return m; |
7035 } | |
7036 | |
9030 | 7037 |
7038 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7039 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7040 return oscar_buddy_menu((GaimBuddy *) node); | |
7041 } else { | |
7042 return NULL; | |
7043 } | |
7044 } | |
7045 | |
7046 | |
5575 | 7047 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7048 OscarData *od = gc->proto_data; |
5575 | 7049 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7050 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7051 od->setnick = TRUE; | |
7052 od->newsn = g_strdup(nick); | |
7053 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7054 } else { | |
7055 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7056 } | |
7057 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7058 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7059 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7060 } |
7061 } | |
7062 | |
9015 | 7063 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7064 { |
9015 | 7065 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7066 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7067 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7068 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7069 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7070 gc); |
4333 | 7071 } |
7072 | |
9015 | 7073 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7074 { |
9015 | 7075 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7076 OscarData *od = gc->proto_data; |
4333 | 7077 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7078 | |
7079 if (conn) { | |
7080 aim_admin_reqconfirm(od->sess, conn); | |
7081 } else { | |
7082 od->conf = TRUE; | |
7083 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7084 } | |
7085 } | |
7086 | |
9015 | 7087 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7088 { |
9015 | 7089 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7090 OscarData *od = gc->proto_data; |
4333 | 7091 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7092 | |
7093 if (conn) { | |
7094 aim_admin_getinfo(od->sess, conn, 0x11); | |
7095 } else { | |
7096 od->reqemail = TRUE; | |
7097 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7098 } | |
7099 } | |
7100 | |
5575 | 7101 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7102 { |
7283 | 7103 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7104 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
|
7105 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7106 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7107 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7108 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7109 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7110 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7111 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7112 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7113 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7114 |
9015 | 7115 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7116 { |
9015 | 7117 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7118 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7119 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7120 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7121 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7122 gc); |
4333 | 7123 } |
7124 | |
9015 | 7125 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7126 { |
9015 | 7127 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7128 OscarData *od = gc->proto_data; |
4333 | 7129 gchar *nombre, *text, *tmp; |
6695 | 7130 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7131 int num=0; |
7132 | |
6873 | 7133 text = g_strdup(""); |
4333 | 7134 |
4785 | 7135 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7136 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7137 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7138 continue; | |
6695 | 7139 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7140 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7141 continue; |
6695 | 7142 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7143 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7144 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7145 continue; | |
7146 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7147 if (gaim_buddy_get_alias_only(buddy)) |
7148 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7149 else |
7150 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7151 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7152 g_free(text); |
7153 text = tmp; | |
7154 g_free(nombre); | |
7155 num++; | |
7156 } | |
4333 | 7157 } |
2979 | 7158 } |
4333 | 7159 } |
7160 | |
7161 if (!num) { | |
7162 g_free(text); | |
6873 | 7163 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7164 } | |
7165 | |
7166 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7167 "the following buddies"), _("You can re-request " | |
7168 "authorization from these buddies by " | |
7169 "right-clicking on them and selecting " | |
7170 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7171 g_free(text); |
2979 | 7172 } |
7173 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7174 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7175 { |
8950 | 7176 OscarData *od = (OscarData *)gc->proto_data; |
7177 | |
7178 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7179 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7180 |
9015 | 7181 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7182 { |
9015 | 7183 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7184 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7185 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7186 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7187 "searching for."), |
8697 | 7188 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7189 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7190 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7191 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7192 |
9015 | 7193 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7194 { |
9015 | 7195 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7196 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7197 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7198 |
9015 | 7199 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7200 { |
9015 | 7201 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7202 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7203 } |
7204 | |
9015 | 7205 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7206 { |
9015 | 7207 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7208 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7209 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7210 |
9015 | 7211 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7212 { |
9015 | 7213 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7214 OscarData *od = gc->proto_data; |
5575 | 7215 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7216 gaim_notify_uri(gc, substituted); |
5517 | 7217 g_free(substituted); |
4333 | 7218 } |
7219 | |
9015 | 7220 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7221 { |
9015 | 7222 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7223 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7224 } |
7225 | |
5842 | 7226 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7227 { | |
7283 | 7228 OscarData *od = gc->proto_data; |
5844 | 7229 aim_session_t *sess = od->sess; |
5842 | 7230 FILE *file; |
7231 struct stat st; | |
5844 | 7232 |
6039 | 7233 if (iconfile == NULL) { |
8363 | 7234 aim_ssi_delicon(od->sess); |
6039 | 7235 } else if (!stat(iconfile, &st)) { |
5842 | 7236 char *buf = g_malloc(st.st_size); |
7237 file = fopen(iconfile, "rb"); | |
7238 if (file) { | |
6052 | 7239 md5_state_t *state; |
6039 | 7240 char md5[16]; |
9532 | 7241 /* XXX - Use g_file_get_contents()? */ |
5842 | 7242 int len = fread(buf, 1, st.st_size, file); |
6039 | 7243 fclose(file); |
6052 | 7244 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7245 md5_init(state); |
7246 md5_append(state, buf, len); | |
7247 md5_finish(state, md5); | |
7248 g_free(state); | |
7249 aim_ssi_seticon(sess, md5, 16); | |
7250 } else | |
8660 | 7251 gaim_debug_error("oscar", |
5842 | 7252 "Can't open buddy icon file!\n"); |
7253 g_free(buf); | |
7254 } else | |
8660 | 7255 gaim_debug_error("oscar", |
5842 | 7256 "Can't stat buddy icon file!\n"); |
7257 } | |
7258 | |
7259 | |
9015 | 7260 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7261 { |
9015 | 7262 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7263 OscarData *od = gc->proto_data; |
4333 | 7264 GList *m = NULL; |
9015 | 7265 GaimPluginAction *act; |
7266 | |
7267 act = gaim_plugin_action_new(_("Set User Info..."), | |
7268 oscar_show_set_info); | |
7269 m = g_list_append(m, act); | |
4333 | 7270 |
8576 | 7271 if (od->icq) { |
9015 | 7272 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7273 oscar_show_set_info_icqurl); | |
7274 m = g_list_append(m, act); | |
8576 | 7275 } |
7276 | |
9015 | 7277 act = gaim_plugin_action_new(_("Change Password..."), |
7278 oscar_change_pass); | |
7279 m = g_list_append(m, act); | |
4617 | 7280 |
7281 if (od->sess->authinfo->chpassurl) { | |
9015 | 7282 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7283 oscar_show_chpassurl); | |
7284 m = g_list_append(m, act); | |
7285 | |
7286 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7287 oscar_show_imforwardingurl); | |
7288 m = g_list_append(m, act); | |
7026 | 7289 } |
7290 | |
5238 | 7291 if (!od->icq) { |
4617 | 7292 /* AIM actions */ |
7293 m = g_list_append(m, NULL); | |
4333 | 7294 |
9015 | 7295 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7296 oscar_show_format_screenname); | |
7297 m = g_list_append(m, act); | |
7298 | |
7299 act = gaim_plugin_action_new(_("Confirm Account"), | |
7300 oscar_confirm_account); | |
7301 m = g_list_append(m, act); | |
7302 | |
7303 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7304 oscar_show_email); | |
7305 m = g_list_append(m, act); | |
7306 | |
7307 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7308 oscar_show_change_email); | |
7309 m = g_list_append(m, act); | |
2086 | 7310 } |
4333 | 7311 |
7312 m = g_list_append(m, NULL); | |
7313 | |
9015 | 7314 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7315 oscar_show_awaitingauth); | |
7316 m = g_list_append(m, act); | |
4333 | 7317 |
2086 | 7318 m = g_list_append(m, NULL); |
4333 | 7319 |
9015 | 7320 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7321 oscar_show_find_email); | |
7322 m = g_list_append(m, act); | |
4333 | 7323 |
8591 | 7324 #if 0 |
9015 | 7325 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7326 show_find_info); | |
7327 m = g_list_append(m, act); | |
8591 | 7328 #endif |
2086 | 7329 |
7330 return m; | |
7331 } | |
7332 | |
5575 | 7333 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7334 { |
7283 | 7335 OscarData *od = gc->proto_data; |
4617 | 7336 |
7337 if (od->icq) { | |
7338 aim_icq_changepasswd(od->sess, new); | |
2086 | 7339 } else { |
4617 | 7340 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7341 if (conn) { | |
7342 aim_admin_changepasswd(od->sess, conn, new, old); | |
7343 } else { | |
7344 od->chpass = TRUE; | |
7345 od->oldp = g_strdup(old); | |
7346 od->newp = g_strdup(new); | |
7347 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7348 } | |
2086 | 7349 } |
7350 } | |
7351 | |
6059 | 7352 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7353 { |
7283 | 7354 OscarData *od = gc->proto_data; |
8971 | 7355 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
|
7356 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7357 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7358 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7359 |
8971 | 7360 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7361 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7362 |
9935 | 7363 static void |
7364 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7365 { | |
7366 GaimConnection *gc = data; | |
7367 OscarData *od = gc->proto_data; | |
7368 aim_session_t *sess = od->sess; | |
7369 fu32_t presence; | |
7370 | |
7371 presence = aim_ssi_getpresence(sess->ssi.local); | |
7372 | |
7373 if (value) { | |
9992 | 7374 /* Based on the packet capture I thought it was the first one */ |
7375 /* Stu thinks it's the second one. */ | |
7376 /* presence |= 0x00400000; */ | |
9971 | 7377 presence &= ~0x00020000; |
9935 | 7378 aim_ssi_setpresence(sess, presence); |
7379 } else { | |
9992 | 7380 /* presence &= ~0x00400000; */ |
9971 | 7381 presence |= 0x00020000; |
9935 | 7382 aim_ssi_setpresence(sess, presence); |
7383 } | |
7384 } | |
7385 | |
7386 static GaimPluginPrefFrame * | |
9936 | 7387 get_plugin_pref_frame(GaimPlugin *plugin) |
7388 { | |
9935 | 7389 GaimPluginPrefFrame *frame; |
7390 GaimPluginPref *ppref; | |
7391 | |
7392 frame = gaim_plugin_pref_frame_new(); | |
7393 | |
7394 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7395 gaim_plugin_pref_frame_add(frame, ppref); | |
7396 | |
7397 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7398 gaim_plugin_pref_frame_add(frame, ppref); | |
7399 | |
7400 return frame; | |
7401 } | |
7402 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7403 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7404 { |
9308 | 7405 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7406 NULL, /* user_splits */ |
7407 NULL, /* protocol_options */ | |
7408 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7409 oscar_list_icon, /* list_icon */ | |
7410 oscar_list_emblems, /* list_emblems */ | |
7411 oscar_status_text, /* status_text */ | |
7412 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7413 oscar_status_types, /* status_types */ |
9475 | 7414 oscar_blist_node_menu, /* blist_node_menu */ |
7415 oscar_chat_info, /* chat_info */ | |
9754 | 7416 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7417 oscar_login, /* login */ |
7418 oscar_close, /* close */ | |
7419 oscar_send_im, /* send_im */ | |
7420 oscar_set_info, /* set_info */ | |
7421 oscar_send_typing, /* send_typing */ | |
7422 oscar_get_info, /* get_info */ | |
9973 | 7423 oscar_set_status, /* set_status */ |
9475 | 7424 oscar_set_idle, /* set_idle */ |
7425 oscar_change_passwd, /* change_passwd */ | |
7426 oscar_add_buddy, /* add_buddy */ | |
7427 oscar_add_buddies, /* add_buddies */ | |
7428 oscar_remove_buddy, /* remove_buddy */ | |
7429 oscar_remove_buddies, /* remove_buddies */ | |
7430 oscar_add_permit, /* add_permit */ | |
7431 oscar_add_deny, /* add_deny */ | |
7432 oscar_rem_permit, /* rem_permit */ | |
7433 oscar_rem_deny, /* rem_deny */ | |
7434 oscar_set_permit_deny, /* set_permit_deny */ | |
7435 oscar_warn, /* warn */ | |
7436 oscar_join_chat, /* join_chat */ | |
7437 NULL, /* reject_chat */ | |
9973 | 7438 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7439 oscar_chat_invite, /* chat_invite */ |
7440 oscar_chat_leave, /* chat_leave */ | |
7441 NULL, /* chat_whisper */ | |
7442 oscar_send_chat, /* chat_send */ | |
7443 oscar_keepalive, /* keepalive */ | |
7444 NULL, /* register_user */ | |
7445 NULL, /* get_cb_info */ | |
7446 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7447 #ifndef NOSSI |
9475 | 7448 oscar_alias_buddy, /* alias_buddy */ |
7449 oscar_move_buddy, /* group_buddy */ | |
7450 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7451 #else |
9475 | 7452 NULL, /* alias_buddy */ |
7453 NULL, /* group_buddy */ | |
7454 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7455 #endif |
9475 | 7456 NULL, /* buddy_free */ |
7457 oscar_convo_closed, /* convo_closed */ | |
7458 NULL, /* normalize */ | |
7459 oscar_set_icon, /* set_buddy_icon */ | |
7460 NULL, /* remove_group */ | |
7461 NULL, /* get_cb_real_name */ | |
7462 NULL, /* set_chat_topic */ | |
7463 NULL, /* find_blist_chat */ | |
7464 NULL, /* roomlist_get_list */ | |
7465 NULL, /* roomlist_cancel */ | |
7466 NULL, /* roomlist_expand_category */ | |
7467 oscar_can_receive_file, /* can_receive_file */ | |
7468 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7469 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7470 |
9935 | 7471 static GaimPluginUiInfo prefs_info = { |
7472 get_plugin_pref_frame | |
7473 }; | |
7474 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7475 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7476 { |
9943 | 7477 GAIM_PLUGIN_MAGIC, |
7478 GAIM_MAJOR_VERSION, | |
7479 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7480 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7481 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7482 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7483 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7484 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7485 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7486 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7487 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7488 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7489 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7490 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7491 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7492 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7493 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7494 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7495 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7496 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7497 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7498 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7499 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7500 NULL, /**< ui_info */ |
8993 | 7501 &prpl_info, /**< extra_info */ |
9935 | 7502 &prefs_info, /**< prefs_info */ |
9015 | 7503 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7504 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7505 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7506 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7507 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7508 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7509 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7510 |
9830 | 7511 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7512 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7513 | |
7514 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7515 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7516 | |
7517 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7518 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
|
7519 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7520 my_protocol = plugin; |
9935 | 7521 |
7522 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7523 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7524 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7525 } |
7526 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7527 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |