Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 11172:1f0844561c7e
[gaim-migrate @ 13274]
Change assumed capabilities for offline ICQ users to fix encoding
troubles. Thanks to Ilya Konstantinov, SF Bug #1179452.
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Sat, 30 Jul 2005 01:29:26 +0000 |
parents | ccb38cf22483 |
children | 1ce573a2e125 |
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 | |
11155 | 7 * Some code copyright (C) 2001-2005, Mark Doliner <thekingant@users.sourceforge.net> |
11049 | 8 * Some code copyright (C) 2005, Jonathan Clark <ardentlygnarly@users.sourceforge.net> |
6302 | 9 * |
10 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 11 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 12 * |
13 * This program is free software; you can redistribute it and/or modify | |
14 * it under the terms of the GNU General Public License as published by | |
15 * the Free Software Foundation; either version 2 of the License, or | |
16 * (at your option) any later version. | |
17 * | |
18 * This program is distributed in the hope that it will be useful, | |
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10485 | 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2086 | 21 * GNU General Public License for more details. |
22 * | |
23 * You should have received a copy of the GNU General Public License | |
24 * along with this program; if not, write to the Free Software | |
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
26 * | |
27 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
30 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
31 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
32 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
33 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
34 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
36 #include "ft.h" |
6982 | 37 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
38 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
40 #include "privacy.h" |
2086 | 41 #include "prpl.h" |
4889 | 42 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 #include "util.h" |
9943 | 45 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
46 |
2086 | 47 #include "aim.h" |
5842 | 48 #include "md5.h" |
2086 | 49 |
9976 | 50 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
51 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
52 #define OSCAR_STATUS_ID_ONLINE "online" | |
9991 | 53 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 54 #define OSCAR_STATUS_ID_AWAY "away" |
55 #define OSCAR_STATUS_ID_DND "dnd" | |
56 #define OSCAR_STATUS_ID_NA "na" | |
57 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
58 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
59 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 60 |
2086 | 61 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
62 | |
7283 | 63 #define OSCAR_CONNECT_STEPS 6 |
9830 | 64 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
10570 | 65 #define OSCAR_DEFAULT_AUTHORIZATION TRUE |
66 #define OSCAR_DEFAULT_HIDE_IP TRUE | |
67 #define OSCAR_DEFAULT_WEB_AWARE FALSE | |
7283 | 68 |
11084 | 69 /* Seconds each file transfer ip address will be given to make a connection */ |
70 #define FT_IP_TIMEOUT 15 | |
71 | |
10329 | 72 #define FAIM_DEBUG_LEVEL 0 |
73 | |
7376 | 74 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
75 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 76 |
4665 | 77 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
78 static fu8_t features_icq[] = {0x01, 0x06}; | |
11172 | 79 static fu8_t features_icq_offline[] = {0x01}; |
8341 | 80 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 81 |
7283 | 82 typedef struct _OscarData OscarData; |
83 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
84 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
85 aim_conn_t *conn; |
2086 | 86 |
87 guint cnpa; | |
88 guint paspa; | |
3694 | 89 guint emlpa; |
4804 | 90 guint icopa; |
2086 | 91 |
4823 | 92 gboolean iconconnecting; |
5842 | 93 gboolean set_icon; |
4823 | 94 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
95 GSList *create_rooms; |
2086 | 96 |
97 gboolean conf; | |
98 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
99 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
100 char *email; |
2979 | 101 gboolean setnick; |
102 char *newsn; | |
2086 | 103 gboolean chpass; |
104 char *oldp; | |
105 char *newp; | |
9971 | 106 |
2086 | 107 GSList *oscar_chats; |
108 GSList *direct_ims; | |
3630 | 109 GSList *file_transfers; |
4738 | 110 GHashTable *buddyinfo; |
4804 | 111 GSList *requesticon; |
2086 | 112 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
113 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
114 gboolean icq; |
4804 | 115 guint icontimer; |
5968 | 116 guint getblisttimer; |
8341 | 117 guint getinfotimer; |
10567 | 118 gint timeoffset; |
2993 | 119 |
120 struct { | |
4230 | 121 guint maxwatchers; /* max users who can watch you */ |
2993 | 122 guint maxbuddies; /* max users you can watch */ |
4230 | 123 guint maxgroups; /* max groups in server list */ |
2993 | 124 guint maxpermits; /* max users on permit list */ |
125 guint maxdenies; /* max users on deny list */ | |
126 guint maxsiglen; /* max size (bytes) of profile */ | |
127 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
128 } rights; | |
2086 | 129 }; |
130 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
133 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
134 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
135 |
2086 | 136 struct chat_connection { |
137 char *name; | |
138 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
139 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
140 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
141 aim_conn_t *conn; |
2086 | 142 int inpa; |
143 int id; | |
5575 | 144 GaimConnection *gc; /* i hate this. */ |
8733 | 145 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
146 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
147 int maxvis; |
2086 | 148 }; |
149 | |
8971 | 150 struct oscar_direct_im { |
5575 | 151 GaimConnection *gc; |
2086 | 152 char name[80]; |
153 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
154 aim_conn_t *conn; |
3008 | 155 gboolean connected; |
8978 | 156 gboolean gpc_pend; |
157 gboolean killme; | |
8984 | 158 gboolean donttryagain; |
2086 | 159 }; |
160 | |
161 struct ask_direct { | |
5575 | 162 GaimConnection *gc; |
2086 | 163 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
164 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
165 fu8_t cookie[8]; |
8984 | 166 gboolean donttryagain; |
2086 | 167 }; |
168 | |
7011 | 169 /* |
170 * Various PRPL-specific buddy info that we want to keep track of | |
171 * Some other info is maintained by locate.c, and I'd like to move | |
172 * the rest of this to libfaim, mostly im.c | |
173 */ | |
4738 | 174 struct buddyinfo { |
175 gboolean typingnot; | |
6292 | 176 gchar *availmsg; |
6857 | 177 fu32_t ipaddr; |
5836 | 178 |
179 unsigned long ico_me_len; | |
180 unsigned long ico_me_csum; | |
181 time_t ico_me_time; | |
182 gboolean ico_informed; | |
4738 | 183 |
184 unsigned long ico_len; | |
185 unsigned long ico_csum; | |
186 time_t ico_time; | |
187 gboolean ico_need; | |
7406 | 188 gboolean ico_sent; |
2086 | 189 }; |
190 | |
4230 | 191 struct name_data { |
5575 | 192 GaimConnection *gc; |
4230 | 193 gchar *name; |
3453 | 194 gchar *nick; |
3141 | 195 }; |
196 | |
5129 | 197 static char *msgerrreason[] = { |
198 N_("Invalid error"), | |
199 N_("Invalid SNAC"), | |
200 N_("Rate to host"), | |
201 N_("Rate to client"), | |
202 N_("Not logged in"), | |
203 N_("Service unavailable"), | |
204 N_("Service not defined"), | |
205 N_("Obsolete SNAC"), | |
206 N_("Not supported by host"), | |
207 N_("Not supported by client"), | |
208 N_("Refused by client"), | |
209 N_("Reply too big"), | |
210 N_("Responses lost"), | |
211 N_("Request denied"), | |
212 N_("Busted SNAC payload"), | |
213 N_("Insufficient rights"), | |
214 N_("In local permit/deny"), | |
215 N_("Too evil (sender)"), | |
216 N_("Too evil (receiver)"), | |
217 N_("User temporarily unavailable"), | |
218 N_("No match"), | |
219 N_("List overflow"), | |
220 N_("Request ambiguous"), | |
221 N_("Queue full"), | |
222 N_("Not while on AOL") | |
223 }; | |
224 static int msgerrreasonlen = 25; | |
225 | |
226 /* All the libfaim->gaim callback functions */ | |
227 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 229 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 230 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
231 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
237 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 238 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 239 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 240 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
241 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
|
242 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
|
243 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
|
244 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
|
245 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 246 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
247 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 249 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 250 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
251 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
259 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
260 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
261 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
262 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
280 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 281 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 282 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
283 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
284 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
286 | |
287 /* for DirectIM/image transfer */ | |
288 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
289 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
290 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 291 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 292 |
293 /* for file transfer */ | |
294 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
295 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
296 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
297 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
298 | |
299 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 300 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
11159 | 301 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie); |
5954 | 302 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 303 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
11084 | 304 static void oscar_xfer_init_recv(GaimXfer *xfer); |
9935 | 305 |
5836 | 306 static void oscar_free_name_data(struct name_data *data) { |
4230 | 307 g_free(data->name); |
308 g_free(data->nick); | |
309 g_free(data); | |
310 } | |
311 | |
5836 | 312 static void oscar_free_buddyinfo(void *data) { |
313 struct buddyinfo *bi = data; | |
6292 | 314 g_free(bi->availmsg); |
5836 | 315 g_free(bi); |
316 } | |
317 | |
9807 | 318 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 319 { |
320 int i = 0; | |
9826 | 321 int charset = AIM_CHARSET_ASCII; |
5129 | 322 |
11081 | 323 /* Determine how we can send this message. Per the warnings elsewhere |
324 * in this file, these little checks determine the simplest encoding | |
5129 | 325 * we can use for a given message send using it. */ |
326 while (utf8[i]) { | |
327 if ((unsigned char)utf8[i] > 0x7f) { | |
328 /* not ASCII! */ | |
9826 | 329 charset = AIM_CHARSET_CUSTOM; |
5129 | 330 break; |
331 } | |
332 i++; | |
333 } | |
334 while (utf8[i]) { | |
335 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
336 * followed by 0xc0-0xc3 in the second */ | |
337 if ((unsigned char)utf8[i] < 0x80) { | |
338 i++; | |
339 continue; | |
340 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
341 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
342 i += 2; | |
343 continue; | |
344 } | |
9826 | 345 charset = AIM_CHARSET_UNICODE; |
5129 | 346 break; |
347 } | |
348 | |
9807 | 349 return charset; |
5129 | 350 } |
351 | |
8225 | 352 /* |
353 * Take a string of the form charset="bleh" where bleh is | |
11081 | 354 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and |
8225 | 355 * return a newly allocated string containing bleh. |
356 */ | |
357 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 358 { |
8225 | 359 gchar *ret = NULL; |
360 char *begin, *end; | |
361 | |
9933 | 362 g_return_val_if_fail(encoding != NULL, NULL); |
363 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
364 /* Make sure encoding begins with charset= */ |
10540 | 365 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
366 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
367 { | |
8225 | 368 return NULL; |
10540 | 369 } |
8225 | 370 |
371 begin = strchr(encoding, '"'); | |
372 end = strrchr(encoding, '"'); | |
373 | |
374 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
375 return NULL; | |
376 | |
377 ret = g_strndup(begin+1, (end-1) - begin); | |
378 | |
379 return ret; | |
380 } | |
381 | |
9830 | 382 static gchar * |
383 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 384 { |
385 gchar *utf8 = NULL; | |
9595 | 386 |
387 if ((encoding == NULL) || encoding[0] == '\0') { | |
388 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 389 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 390 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 391 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 392 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 393 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 394 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 395 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 396 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 397 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 398 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
399 } | |
400 | |
401 /* | |
402 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
403 * we have been unable to convert the text to utf-8 from the encoding | |
404 * that was specified. So we check if the text is valid utf-8 then | |
405 * just copy it. | |
406 */ | |
407 if (utf8 == NULL) { | |
9638 | 408 if (textlen != 0 && *text != '\0' |
409 && !g_utf8_validate(text, textlen, NULL)) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
410 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 411 else |
9481 | 412 utf8 = g_strndup(text, textlen); |
5129 | 413 } |
414 | |
415 return utf8; | |
416 } | |
417 | |
9830 | 418 static gchar * |
11159 | 419 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback) |
9830 | 420 { |
421 gchar *ret = NULL; | |
422 GError *err = NULL; | |
423 | |
9908 | 424 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
425 return NULL; | |
426 | |
427 if (strcasecmp("UTF-8", charsetstr)) { | |
428 if (fallback) | |
429 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
430 else | |
431 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
432 if (err != NULL) { | |
433 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
434 charsetstr, err->message); | |
435 g_error_free(err); | |
436 } | |
437 } else { | |
438 if (g_utf8_validate(data, datalen, NULL)) | |
439 ret = g_strndup(data, datalen); | |
440 else | |
441 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
442 } | |
443 | |
444 return ret; | |
445 } | |
446 | |
447 /* | |
11081 | 448 * This attemps to decode an incoming IM into a UTF8 string. |
449 * | |
9908 | 450 * We try decoding using two different character sets. The charset |
451 * specified in the IM determines the order in which we attempt to | |
452 * decode. We do this because there are lots of broken ICQ clients | |
453 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
454 * able to deal with that crap, then people complain like banshees. | |
455 * charsetstr1 is always set to what the correct encoding should be. | |
456 */ | |
457 static gchar * | |
11159 | 458 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, const gchar *data, gsize datalen) |
9908 | 459 { |
460 gchar *ret = NULL; | |
461 const gchar *charsetstr1, *charsetstr2; | |
462 | |
463 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 464 |
465 if ((datalen == 0) || (data == NULL)) | |
466 return NULL; | |
467 | |
9908 | 468 if (charset == AIM_CHARSET_UNICODE) { |
469 charsetstr1 = "UCS-2BE"; | |
470 charsetstr2 = "UTF-8"; | |
471 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 472 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 473 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 474 else |
9908 | 475 charsetstr1 = "ISO-8859-1"; |
476 charsetstr2 = "UTF-8"; | |
477 } else if (charset == AIM_CHARSET_ASCII) { | |
478 /* Should just be "ASCII" */ | |
9914 | 479 charsetstr1 = "ASCII"; |
9908 | 480 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
481 } else if (charset == 0x000d) { | |
9830 | 482 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 483 charsetstr1 = "ISO-8859-1"; |
484 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
485 } else { | |
9830 | 486 /* Unknown, hope for valid UTF-8... */ |
9908 | 487 charsetstr1 = "UTF-8"; |
488 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
489 } | |
490 | |
491 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
492 if (ret == NULL) | |
493 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
494 if (ret == NULL) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
495 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9830 | 496 |
497 return ret; | |
498 } | |
499 | |
11081 | 500 /* |
501 * Figure out what encoding to use when sending a given outgoing message. | |
502 */ | |
9830 | 503 static void |
504 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 505 gchar **msg, int *msglen_int, |
9830 | 506 fu16_t *charset, fu16_t *charsubset) |
507 { | |
508 OscarData *od = gc->proto_data; | |
509 GaimAccount *account = gaim_connection_get_account(gc); | |
510 GError *err = NULL; | |
511 aim_userinfo_t *userinfo = NULL; | |
512 const gchar *charsetstr; | |
10039 | 513 gsize msglen; |
9830 | 514 |
515 /* Attempt to send as ASCII */ | |
10098 | 516 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 517 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 518 *charset = AIM_CHARSET_ASCII; |
9830 | 519 *charsubset = 0x0000; |
10039 | 520 *msglen_int = msglen; |
9830 | 521 return; |
522 } | |
523 | |
524 /* | |
10565 | 525 * If we're sending to an ICQ user, and they are in our |
526 * buddy list, and they are advertising the Unicode | |
527 * capability, and they are online, then attempt to send | |
528 * as UCS-2BE. | |
9830 | 529 */ |
9975 | 530 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 531 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
532 | |
10565 | 533 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
534 { | |
535 GaimBuddy *b; | |
536 b = gaim_find_buddy(account, destsn); | |
537 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
538 { | |
539 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
540 if (*msg != NULL) | |
541 { | |
542 *charset = AIM_CHARSET_UNICODE; | |
543 *charsubset = 0x0000; | |
544 *msglen_int = msglen; | |
545 return; | |
546 } | |
9830 | 547 } |
548 } | |
549 | |
550 /* | |
551 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
552 * ICQ then attempt to send as the user specified character encoding. | |
553 */ | |
554 charsetstr = "ISO-8859-1"; | |
9975 | 555 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 556 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
557 | |
10097 | 558 /* |
559 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
560 * can be converted to "charsetstr" | |
561 */ | |
10039 | 562 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 563 if (*msg != NULL) { |
564 *charset = AIM_CHARSET_CUSTOM; | |
565 *charsubset = 0x0000; | |
10039 | 566 *msglen_int = msglen; |
9830 | 567 return; |
568 } | |
569 | |
570 /* | |
571 * Nothing else worked, so send as UCS-2BE. | |
572 */ | |
10039 | 573 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 574 if (*msg != NULL) { |
575 *charset = AIM_CHARSET_UNICODE; | |
576 *charsubset = 0x0000; | |
10039 | 577 *msglen_int = msglen; |
9830 | 578 return; |
579 } | |
580 | |
9908 | 581 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 582 g_error_free(err); |
583 | |
584 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
585 *msg = g_strdup(from); | |
10039 | 586 *msglen_int = strlen(*msg); |
9830 | 587 *charset = AIM_CHARSET_ASCII; |
588 *charsubset = 0x0000; | |
589 return; | |
590 } | |
591 | |
9407 | 592 gchar *oscar_caps_to_string(guint caps) |
8701 | 593 { |
9407 | 594 GString *str; |
595 gchar *tmp; | |
8701 | 596 guint bit = 1; |
597 | |
9407 | 598 str = g_string_new(""); |
599 | |
8701 | 600 if (!caps) { |
601 return NULL; | |
602 } else while (bit <= AIM_CAPS_LAST) { | |
603 if (bit & caps) { | |
604 switch (bit) { | |
605 case AIM_CAPS_BUDDYICON: | |
606 tmp = _("Buddy Icon"); | |
607 break; | |
608 case AIM_CAPS_TALK: | |
609 tmp = _("Voice"); | |
610 break; | |
611 case AIM_CAPS_DIRECTIM: | |
612 tmp = _("AIM Direct IM"); | |
613 break; | |
614 case AIM_CAPS_CHAT: | |
615 tmp = _("Chat"); | |
616 break; | |
617 case AIM_CAPS_GETFILE: | |
618 tmp = _("Get File"); | |
619 break; | |
620 case AIM_CAPS_SENDFILE: | |
621 tmp = _("Send File"); | |
622 break; | |
623 case AIM_CAPS_GAMES: | |
624 case AIM_CAPS_GAMES2: | |
625 tmp = _("Games"); | |
626 break; | |
627 case AIM_CAPS_ADDINS: | |
628 tmp = _("Add-Ins"); | |
629 break; | |
630 case AIM_CAPS_SENDBUDDYLIST: | |
631 tmp = _("Send Buddy List"); | |
632 break; | |
633 case AIM_CAPS_ICQ_DIRECT: | |
634 tmp = _("ICQ Direct Connect"); | |
635 break; | |
636 case AIM_CAPS_APINFO: | |
637 tmp = _("AP User"); | |
638 break; | |
639 case AIM_CAPS_ICQRTF: | |
640 tmp = _("ICQ RTF"); | |
641 break; | |
642 case AIM_CAPS_EMPTY: | |
643 tmp = _("Nihilist"); | |
644 break; | |
645 case AIM_CAPS_ICQSERVERRELAY: | |
646 tmp = _("ICQ Server Relay"); | |
647 break; | |
648 case AIM_CAPS_ICQUTF8OLD: | |
649 tmp = _("Old ICQ UTF8"); | |
650 break; | |
651 case AIM_CAPS_TRILLIANCRYPT: | |
652 tmp = _("Trillian Encryption"); | |
653 break; | |
654 case AIM_CAPS_ICQUTF8: | |
655 tmp = _("ICQ UTF8"); | |
656 break; | |
657 case AIM_CAPS_HIPTOP: | |
658 tmp = _("Hiptop"); | |
659 break; | |
660 case AIM_CAPS_SECUREIM: | |
661 tmp = _("Security Enabled"); | |
662 break; | |
663 case AIM_CAPS_VIDEO: | |
664 tmp = _("Video Chat"); | |
665 break; | |
666 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
667 case AIM_CAPS_ICHATAV: | |
668 tmp = _("iChat AV"); | |
669 break; | |
670 case AIM_CAPS_LIVEVIDEO: | |
671 tmp = _("Live Video"); | |
672 break; | |
673 case AIM_CAPS_CAMERA: | |
674 tmp = _("Camera"); | |
675 break; | |
676 default: | |
677 tmp = NULL; | |
678 break; | |
679 } | |
680 if (tmp) | |
9532 | 681 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 682 } |
683 bit <<= 1; | |
684 } | |
9407 | 685 |
686 return g_string_free(str, FALSE); | |
8701 | 687 } |
688 | |
689 static char *oscar_icqstatus(int state) { | |
690 /* Make a cute little string that shows the status of the dude or dudet */ | |
691 if (state & AIM_ICQ_STATE_CHAT) | |
692 return g_strdup_printf(_("Free For Chat")); | |
693 else if (state & AIM_ICQ_STATE_DND) | |
694 return g_strdup_printf(_("Do Not Disturb")); | |
695 else if (state & AIM_ICQ_STATE_OUT) | |
696 return g_strdup_printf(_("Not Available")); | |
697 else if (state & AIM_ICQ_STATE_BUSY) | |
698 return g_strdup_printf(_("Occupied")); | |
699 else if (state & AIM_ICQ_STATE_AWAY) | |
700 return g_strdup_printf(_("Away")); | |
701 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
702 return g_strdup_printf(_("Web Aware")); | |
703 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
704 return g_strdup_printf(_("Invisible")); | |
705 else | |
706 return g_strdup_printf(_("Online")); | |
707 } | |
708 | |
9973 | 709 static void |
710 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 711 { |
712 gchar *utf8; | |
713 | |
714 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 715 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 716 g_free(utf8); |
717 } | |
718 } | |
719 | |
9973 | 720 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 721 { |
10042 | 722 OscarData *od; |
723 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
724 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
725 GaimStatus *status = NULL; |
8701 | 726 GaimGroup *g = NULL; |
727 struct buddyinfo *bi = NULL; | |
728 char *tmp; | |
729 | |
10042 | 730 od = gc->proto_data; |
731 account = gaim_connection_get_account(gc); | |
732 | |
733 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 734 return; |
735 | |
736 if (userinfo == NULL) | |
737 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
738 | |
739 if (b == NULL) | |
10042 | 740 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 741 |
742 if (b != NULL) | |
10498 | 743 { |
8701 | 744 g = gaim_find_buddys_group(b); |
10498 | 745 presence = gaim_buddy_get_presence(b); |
746 status = gaim_presence_get_active_status(presence); | |
747 } | |
8701 | 748 |
749 if (userinfo != NULL) | |
750 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
751 | |
8733 | 752 if (b != NULL) { |
10498 | 753 if (gaim_presence_is_online(presence)) { |
9975 | 754 if (aim_sn_is_icq(b->name)) { |
8733 | 755 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
756 oscar_string_append(str, newline, _("Status"), tmp); | |
757 g_free(tmp); | |
758 } | |
759 } else { | |
9625 | 760 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 761 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
762 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
763 else | |
764 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 765 } |
8733 | 766 } |
8701 | 767 |
768 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 769 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 770 (bi->ipaddr & 0xff000000) >> 24, |
771 (bi->ipaddr & 0x00ff0000) >> 16, | |
772 (bi->ipaddr & 0x0000ff00) >> 8, | |
773 (bi->ipaddr & 0x000000ff)); | |
774 oscar_string_append(str, newline, _("IP Address"), tmp); | |
775 g_free(tmp); | |
776 } | |
777 | |
778 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
779 tmp = oscar_caps_to_string(userinfo->capabilities); | |
780 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 781 g_free(tmp); |
8701 | 782 } |
783 | |
784 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
785 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
786 if (tmp != NULL) { | |
9625 | 787 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 788 g_free(tmp); |
9625 | 789 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
790 g_free(tmp2); | |
8701 | 791 } |
792 } | |
793 | |
10498 | 794 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_status_is_available(status)) { |
8701 | 795 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
796 oscar_string_append(str, newline, _("Available"), tmp); | |
797 g_free(tmp); | |
798 } | |
799 } | |
800 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
801 static char *extract_name(const char *name) { |
4121 | 802 char *tmp, *x; |
2086 | 803 int i, j; |
4120 | 804 |
805 if (!name) | |
4121 | 806 return NULL; |
10042 | 807 |
4120 | 808 x = strchr(name, '-'); |
4121 | 809 |
2086 | 810 if (!x) return NULL; |
811 x = strchr(++x, '-'); | |
812 if (!x) return NULL; | |
813 tmp = g_strdup(++x); | |
814 | |
815 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
816 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
817 if (x[i] != '%') { |
2086 | 818 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
819 continue; |
2086 | 820 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
821 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
822 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
823 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 824 } |
825 | |
826 tmp[j] = 0; | |
827 return tmp; | |
828 } | |
829 | |
10458 | 830 static struct chat_connection * |
831 find_oscar_chat(GaimConnection *gc, int id) | |
832 { | |
833 OscarData *od = (OscarData *)gc->proto_data; | |
834 GSList *cur; | |
835 struct chat_connection *cc; | |
836 | |
837 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
838 { | |
839 cc = (struct chat_connection *)cur->data; | |
840 if (cc->id == id) | |
841 return cc; | |
842 } | |
843 | |
844 return NULL; | |
845 } | |
846 | |
847 static struct chat_connection * | |
848 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
849 { | |
850 OscarData *od = (OscarData *)gc->proto_data; | |
851 GSList *cur; | |
852 struct chat_connection *cc; | |
853 | |
854 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
855 { | |
856 cc = (struct chat_connection *)cur->data; | |
857 if (cc->conn == conn) | |
858 return cc; | |
859 } | |
860 | |
861 return NULL; | |
862 } | |
863 | |
864 static struct chat_connection * | |
865 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
866 { | |
867 OscarData *od = (OscarData *)gc->proto_data; | |
868 GSList *cur; | |
869 struct chat_connection *cc; | |
870 | |
871 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
872 { | |
873 cc = (struct chat_connection *)cur->data; | |
874 if (cc->conv == conv) | |
875 return cc; | |
876 } | |
877 | |
878 return NULL; | |
879 } | |
880 | |
881 static void | |
882 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
883 { | |
884 OscarData *od = (OscarData *)gc->proto_data; | |
885 | |
886 /* Notify the conversation window that we've left the chat */ | |
887 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
888 | |
889 /* Destroy the chat_connection */ | |
890 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
891 if (cc->inpa > 0) | |
892 gaim_input_remove(cc->inpa); | |
893 aim_conn_kill(od->sess, &cc->conn); | |
894 g_free(cc->name); | |
895 g_free(cc->show); | |
896 g_free(cc); | |
8219 | 897 } |
898 | |
8971 | 899 /***************************************************************************** |
900 * Begin scary direct im stuff | |
901 *****************************************************************************/ | |
902 | |
903 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
904 GSList *d = od->direct_ims; | |
905 struct oscar_direct_im *m = NULL; | |
906 | |
907 while (d) { | |
908 m = (struct oscar_direct_im *)d->data; | |
909 if (!aim_sncmp(who, m->name)) | |
910 return m; | |
911 d = d->next; | |
912 } | |
913 | |
914 return NULL; | |
915 } | |
916 | |
917 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
918 { | |
919 gaim_debug_info("oscar", | |
920 "destroying Direct IM for %s.\n", dim->name); | |
921 | |
922 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 923 if (dim->gpc_pend) { |
924 dim->killme = TRUE; | |
925 return; | |
926 } | |
8971 | 927 if (dim->watcher) |
928 gaim_input_remove(dim->watcher); | |
929 if (dim->conn) { | |
10271 | 930 aim_conn_close(dim->conn); |
8971 | 931 aim_conn_kill(od->sess, &dim->conn); |
932 } | |
933 g_free(dim); | |
934 } | |
935 | |
936 /* the only difference between this and destroy is this writes a conv message */ | |
937 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
938 { | |
939 GaimConversation *conv; | |
940 char buf[256]; | |
941 | |
942 gaim_debug_info("oscar", | |
943 "%s disconnected Direct IM.\n", dim->name); | |
944 | |
945 if (dim->connected) | |
946 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 947 else |
8971 | 948 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
949 | |
10246 | 950 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
951 gaim_connection_get_account(dim->gc)); | |
8971 | 952 if (conv) { |
953 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 954 gaim_conversation_update_progress(conv, 0); |
8971 | 955 } else { |
956 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
957 } | |
958 | |
959 oscar_direct_im_destroy(od, dim); | |
960 | |
961 return; | |
962 } | |
963 | |
964 /* oops i made two of these. this one just calls the other one. */ | |
965 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
966 { | |
967 GaimConnection *gc = sess->aux_data; | |
968 OscarData *od = (OscarData *)gc->proto_data; | |
969 struct oscar_direct_im *dim; | |
970 char *sn; | |
971 | |
972 sn = g_strdup(aim_odc_getsn(conn)); | |
973 dim = oscar_direct_im_find(od, sn); | |
974 oscar_direct_im_disconnect(od, dim); | |
975 g_free(sn); | |
976 } | |
977 | |
978 static void destroy_direct_im_request(struct ask_direct *d) { | |
979 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
980 | |
981 g_free(d->sn); | |
982 g_free(d); | |
983 } | |
984 | |
985 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
986 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
987 struct oscar_direct_im *dim = data; | |
988 GaimConnection *gc = dim->gc; | |
989 OscarData *od = gc->proto_data; | |
990 GaimConversation *conv; | |
991 char buf[256]; | |
992 struct sockaddr name; | |
993 socklen_t name_len = 1; | |
994 | |
995 g_return_if_fail(gc != NULL); | |
996 | |
8978 | 997 dim->gpc_pend = FALSE; |
998 if (dim->killme) { | |
999 oscar_direct_im_destroy(od, dim); | |
1000 return; | |
1001 } | |
1002 | |
8971 | 1003 if (!g_list_find(gaim_connections_get_all(), gc)) { |
1004 oscar_direct_im_destroy(od, dim); | |
1005 return; | |
1006 } | |
1007 | |
1008 if (source < 0) { | |
8984 | 1009 if (dim->donttryagain) { |
1010 oscar_direct_im_disconnect(od, dim); | |
1011 return; | |
1012 } else { | |
11159 | 1013 guchar cookie[8]; |
8984 | 1014 char *who = g_strdup(dim->name); |
11159 | 1015 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1016 |
1017 memcpy(cookie, tmp, 8); | |
1018 oscar_direct_im_destroy(od, dim); | |
1019 oscar_direct_im_initiate(gc, who, cookie); | |
1020 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1021 g_free(who); | |
1022 return; | |
1023 } | |
8971 | 1024 } |
1025 | |
1026 dim->conn->fd = source; | |
1027 aim_conn_completeconnect(od->sess, dim->conn); | |
1028 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
1029 | |
1030 /* This is the best way to see if we're connected or not */ | |
8983 | 1031 /* Is this really needed? */ |
8971 | 1032 if (getpeername(source, &name, &name_len) == 0) { |
1033 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1034 dim->connected = TRUE; | |
1035 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1036 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1037 } else { | |
8984 | 1038 if (dim->donttryagain) { |
1039 oscar_direct_im_disconnect(od, dim); | |
1040 return; | |
1041 } else { | |
11159 | 1042 guchar cookie[8]; |
8984 | 1043 char *who = g_strdup(dim->name); |
11159 | 1044 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1045 |
1046 memcpy(cookie, tmp, 8); | |
1047 oscar_direct_im_destroy(od, dim); | |
1048 oscar_direct_im_initiate(gc, who, cookie); | |
1049 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1050 g_free(who); | |
1051 return; | |
1052 } | |
8983 | 1053 } |
1054 | |
1055 | |
8971 | 1056 } |
1057 | |
1058 static void accept_direct_im_request(struct ask_direct *d) { | |
1059 GaimConnection *gc = d->gc; | |
1060 OscarData *od; | |
1061 struct oscar_direct_im *dim; | |
1062 char *host; int port = 5190; | |
1063 int i, rc; | |
8982 | 1064 char *tmp; |
1065 GaimConversation *conv; | |
8971 | 1066 |
1067 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1068 destroy_direct_im_request(d); | |
1069 return; | |
1070 } | |
1071 | |
1072 od = (OscarData *)gc->proto_data; | |
1073 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1074 | |
1075 dim = oscar_direct_im_find(od, d->sn); | |
1076 if (dim && dim->connected) { | |
1077 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1078 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1079 return; | |
1080 } | |
1081 dim = g_new0(struct oscar_direct_im, 1); | |
1082 dim->gc = d->gc; | |
8984 | 1083 dim->donttryagain = d->donttryagain; |
8971 | 1084 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1085 | |
1086 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1087 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1088 if (!dim->conn) { | |
1089 oscar_direct_im_disconnect(od, dim); | |
1090 destroy_direct_im_request(d); | |
1091 return; | |
1092 } | |
1093 | |
1094 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1095 gaim_odc_incoming, 0); | |
1096 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1097 gaim_odc_typing, 0); | |
1098 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1099 gaim_odc_update_ui, 0); | |
1100 | |
1101 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1102 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1103 if (d->ip[i] == ':') { | |
1104 port = atoi(&(d->ip[i+1])); | |
1105 break; | |
1106 } | |
1107 } | |
1108 host = g_strndup(d->ip, i); | |
1109 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1110 dim->gpc_pend = TRUE; |
8971 | 1111 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1112 |
1113 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1114 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1115 port); | |
1116 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1117 g_free(tmp); | |
8983 | 1118 |
8971 | 1119 g_free(host); |
1120 if (rc < 0) { | |
8978 | 1121 dim->gpc_pend = FALSE; |
8971 | 1122 oscar_direct_im_disconnect(od, dim); |
1123 destroy_direct_im_request(d); | |
1124 return; | |
1125 } | |
1126 | |
1127 destroy_direct_im_request(d); | |
1128 | |
1129 return; | |
1130 } | |
1131 | |
1132 /* | |
1133 * We have just established a socket with the other dude, so set up some handlers. | |
1134 */ | |
1135 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1136 GaimConnection *gc = sess->aux_data; |
7283 | 1137 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1138 GaimConversation *conv; |
8971 | 1139 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1140 char buf[256]; |
8971 | 1141 char *sn; |
1142 va_list ap; | |
1143 aim_conn_t *newconn, *listenerconn; | |
1144 | |
1145 va_start(ap, fr); | |
1146 newconn = va_arg(ap, aim_conn_t *); | |
1147 listenerconn = va_arg(ap, aim_conn_t *); | |
1148 va_end(ap); | |
1149 | |
10271 | 1150 aim_conn_close(listenerconn); |
8971 | 1151 aim_conn_kill(sess, &listenerconn); |
1152 | |
1153 sn = g_strdup(aim_odc_getsn(newconn)); | |
1154 | |
1155 gaim_debug_info("oscar", | |
1156 "DirectIM: initiate success to %s\n", sn); | |
1157 dim = oscar_direct_im_find(od, sn); | |
1158 | |
1159 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1160 gaim_input_remove(dim->watcher); | |
1161 dim->conn = newconn; | |
1162 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1163 dim->connected = TRUE; | |
1164 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1165 g_free(sn); | |
1166 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1167 | |
1168 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1169 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1170 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1171 | |
1172 return 1; | |
1173 } | |
1174 | |
1175 /* | |
1176 * This is called when each chunk of an image is received. It can be used to | |
1177 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1178 * nasty, you sicko. | |
1179 */ | |
1180 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1181 va_list ap; | |
1182 char *sn; | |
1183 double percent; | |
1184 GaimConnection *gc = sess->aux_data; | |
1185 OscarData *od = (OscarData *)gc->proto_data; | |
1186 GaimConversation *c; | |
1187 struct oscar_direct_im *dim; | |
1188 | |
1189 va_start(ap, fr); | |
1190 sn = va_arg(ap, char *); | |
1191 percent = va_arg(ap, double); | |
1192 va_end(ap); | |
1193 | |
1194 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1195 return 1; | |
1196 if (dim->watcher) { | |
1197 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1198 /* The callback will callback? I don't get how that would happen here. */ | |
1199 dim->watcher = 0; | |
1200 } | |
1201 | |
10246 | 1202 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1203 gaim_connection_get_account(gc)); | |
8971 | 1204 if (c != NULL) |
1205 gaim_conversation_update_progress(c, percent); | |
1206 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1207 oscar_callback, dim->conn); | |
1208 | |
1209 return 1; | |
1210 } | |
1211 | |
1212 /* | |
1213 * This is called after a direct IM has been received in its entirety. This | |
1214 * function is passed a long chunk of data which contains the IM with any | |
1215 * data chunks (images) appended to it. | |
1216 * | |
1217 * This function rips out all the data chunks and creates an imgstore for | |
1218 * each one. In order to do this, it first goes through the IM and takes | |
1219 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1220 * with one compatible with the imgstore Gaim core code. For each one, we | |
1221 * then read in chunks of data from the end of the message and actually | |
1222 * create the img store using the given data. | |
1223 * | |
1224 * For somewhat easy reference, here's a sample message | |
1225 * (without the whitespace and asterisks): | |
1226 * | |
1227 * <HTML><BODY BGCOLOR="#ffffff"> | |
1228 * <FONT LANG="0"> | |
1229 * This is a really stupid picture:<BR> | |
1230 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1231 * Yeah it is<BR> | |
1232 * Here is another one:<BR> | |
1233 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1234 * </FONT> | |
1235 * </BODY></HTML> | |
1236 * <BINARY> | |
1237 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1238 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1239 * </BINARY> | |
1240 */ | |
1241 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1242 GaimConnection *gc = sess->aux_data; | |
1243 GaimConvImFlags imflags = 0; | |
1244 gchar *utf8; | |
1245 GString *newmsg = g_string_new(""); | |
1246 GSList *images = NULL; | |
1247 va_list ap; | |
1248 const char *sn, *msg, *msgend, *binary; | |
1249 size_t len; | |
1250 int encoding, isawaymsg; | |
1251 | |
1252 va_start(ap, fr); | |
1253 sn = va_arg(ap, const char *); | |
1254 msg = va_arg(ap, const char *); | |
1255 len = va_arg(ap, size_t); | |
1256 encoding = va_arg(ap, int); | |
1257 isawaymsg = va_arg(ap, int); | |
1258 va_end(ap); | |
1259 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1260 |
8660 | 1261 gaim_debug_info("oscar", |
8971 | 1262 "Got DirectIM message from %s\n", sn); |
1263 | |
1264 if (isawaymsg) | |
1265 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1266 | |
1267 /* message has a binary trailer */ | |
1268 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1269 GData *attribs; | |
1270 const char *tmp, *start, *end, *last = NULL; | |
1271 | |
1272 tmp = msg; | |
1273 | |
1274 /* for each valid image tag... */ | |
1275 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1276 const char *id, *src, *datasize; | |
10504 | 1277 const char *data = NULL; |
1278 char *tag = NULL; | |
8971 | 1279 size_t size; |
1280 int imgid = 0; | |
1281 | |
1282 /* update the location of the last img tag */ | |
1283 last = end; | |
1284 | |
1285 /* grab attributes */ | |
1286 id = g_datalist_get_data(&attribs, "id"); | |
1287 src = g_datalist_get_data(&attribs, "src"); | |
1288 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1289 | |
1290 /* if we have id & datasize, build the data tag */ | |
1291 if (id && datasize) | |
1292 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1293 | |
1294 /* if we have a tag, find the start of the data */ | |
1295 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1296 data += strlen(tag); | |
1297 | |
10504 | 1298 g_free(tag); |
1299 | |
8971 | 1300 /* check the data is here and store it */ |
1301 if (data + (size = atoi(datasize)) <= msgend) | |
1302 imgid = gaim_imgstore_add(data, size, src); | |
1303 | |
1304 /* | |
1305 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1306 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1307 */ | |
1308 /* if we have a stored image... */ | |
1309 if (imgid) { | |
1310 /* append the message up to the tag */ | |
1311 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1312 if (utf8 != NULL) { | |
1313 newmsg = g_string_append(newmsg, utf8); | |
1314 g_free(utf8); | |
1315 } | |
1316 | |
1317 /* write the new image tag */ | |
1318 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1319 | |
1320 /* and record the image number */ | |
1321 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1322 } else { | |
1323 /* otherwise, copy up to the end of the tag */ | |
1324 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1325 if (utf8 != NULL) { | |
1326 newmsg = g_string_append(newmsg, utf8); | |
1327 g_free(utf8); | |
1328 } | |
1329 } | |
1330 | |
1331 /* clear the attribute list */ | |
1332 g_datalist_clear(&attribs); | |
1333 | |
1334 /* continue from the end of the tag */ | |
1335 tmp = end + 1; | |
1336 } | |
1337 | |
1338 /* append any remaining message data (without the > :-) */ | |
1339 if (last++ && (last < binary)) | |
1340 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1341 | |
1342 /* set the flag if we caught any images */ | |
1343 if (images) | |
1344 imflags |= GAIM_CONV_IM_IMAGES; | |
1345 } else { | |
1346 g_string_append_len(newmsg, msg, len); | |
1347 } | |
1348 | |
10318 | 1349 /* Convert to UTF8 */ |
1350 /* (This hasn't been tested very much) */ | |
1351 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1352 if (utf8 != NULL) { | |
1353 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1354 g_free(utf8); | |
1355 } | |
1356 | |
1357 /* free the message */ | |
8971 | 1358 g_string_free(newmsg, TRUE); |
1359 | |
1360 /* unref any images we allocated */ | |
1361 if (images) { | |
1362 GSList *tmp; | |
1363 int id; | |
1364 | |
1365 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1366 id = GPOINTER_TO_INT(tmp->data); | |
1367 gaim_imgstore_unref(id); | |
1368 } | |
1369 | |
1370 g_slist_free(images); | |
1371 } | |
1372 | |
1373 return 1; | |
1374 } | |
1375 | |
1376 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1377 va_list ap; | |
1378 char *sn; | |
1379 int typing; | |
1380 GaimConnection *gc = sess->aux_data; | |
1381 | |
1382 va_start(ap, fr); | |
1383 sn = va_arg(ap, char *); | |
1384 typing = va_arg(ap, int); | |
1385 va_end(ap); | |
1386 | |
1387 if (typing == 0x0002) { | |
1388 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1389 gaim_debug_info("oscar", | |
1390 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1391 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1392 } else if (typing == 0x0001) | |
1393 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1394 else | |
1395 serv_got_typing_stopped(gc, sn); | |
1396 return 1; | |
1397 } | |
1398 | |
1399 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1400 char *buf; | |
1401 size_t len; | |
1402 int ret; | |
1403 GString *msg = g_string_new("<HTML><BODY>"); | |
1404 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1405 GData *attribs; | |
1406 const char *start, *end, *last; | |
1407 int oscar_id = 0; | |
1408 | |
1409 last = message; | |
1410 | |
1411 /* for each valid IMG tag... */ | |
1412 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1413 GaimStoredImage *image = NULL; | |
1414 const char *id; | |
1415 | |
1416 if (start - last) { | |
1417 g_string_append_len(msg, last, start - last); | |
1418 } | |
1419 | |
1420 id = g_datalist_get_data(&attribs, "id"); | |
1421 | |
1422 /* ... if it refers to a valid gaim image ... */ | |
1423 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1424 /* ... append the message from start to the tag ... */ | |
9126 | 1425 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1426 const char *filename = gaim_imgstore_get_filename(image); |
1427 gpointer imgdata = gaim_imgstore_get_data(image); | |
1428 | |
1429 oscar_id++; | |
1430 | |
1431 /* ... insert a new img tag with the oscar id ... */ | |
1432 if (filename) | |
1433 g_string_append_printf(msg, | |
9126 | 1434 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1435 filename, oscar_id, size); |
1436 else | |
1437 g_string_append_printf(msg, | |
9126 | 1438 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1439 oscar_id, size); |
1440 | |
1441 /* ... and append the data to the binary section ... */ | |
9126 | 1442 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1443 oscar_id, size); |
1444 data = g_string_append_len(data, imgdata, size); | |
1445 data = g_string_append(data, "</DATA>"); | |
1446 } | |
1447 /* If the tag is invalid, skip it, thus no else here */ | |
1448 | |
1449 g_datalist_clear(&attribs); | |
1450 | |
1451 /* continue from the end of the tag */ | |
1452 last = end + 1; | |
1453 } | |
1454 | |
1455 /* append any remaining message data (without the > :-) */ | |
1456 if (last && *last) | |
1457 msg = g_string_append(msg, last); | |
1458 | |
1459 /* if we inserted any images in the binary section, append it */ | |
1460 if (oscar_id) { | |
1461 msg = g_string_append_len(msg, data->str, data->len); | |
1462 msg = g_string_append(msg, "</BINARY>"); | |
1463 } | |
1464 | |
1465 len = msg->len; | |
1466 buf = msg->str; | |
1467 g_string_free(msg, FALSE); | |
1468 g_string_free(data, TRUE); | |
1469 | |
1470 | |
1471 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1472 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1473 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1474 else | |
1475 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1476 | |
1477 g_free(buf); | |
1478 | |
1479 return ret; | |
1480 } | |
1481 | |
1482 struct ask_do_dir_im { | |
1483 char *who; | |
1484 GaimConnection *gc; | |
1485 }; | |
1486 | |
1487 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1488 g_free(data->who); | |
1489 g_free(data); | |
1490 } | |
1491 | |
8983 | 1492 /* this function is used to initiate a direct im session with someone. |
1493 * we start listening on a port and send a request. they either connect | |
1494 * or send some kind of reply. If they can't connect, they ask us to | |
1495 * connect to them, and so we do that. | |
1496 * | |
1497 * this function will also get called if the other side initiate's a direct | |
1498 * im and we try to connect and fail. in that case cookie will not be null. | |
1499 * | |
1500 * note that cookie is an 8 byte string that isn't NULL terminated | |
1501 */ | |
11159 | 1502 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie) { |
8971 | 1503 OscarData *od; |
1504 struct oscar_direct_im *dim; | |
1505 int listenfd; | |
8982 | 1506 const char *ip; |
8971 | 1507 |
1508 od = (OscarData *)gc->proto_data; | |
1509 | |
8983 | 1510 dim = oscar_direct_im_find(od, who); |
8971 | 1511 if (dim) { |
1512 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1513 oscar_direct_im_disconnect(od, dim); | |
1514 gaim_debug_info("oscar", | |
1515 "Gave up on old direct IM, trying again\n"); | |
1516 } else { | |
1517 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1518 return; |
8971 | 1519 } |
1520 } | |
1521 dim = g_new0(struct oscar_direct_im, 1); | |
1522 dim->gc = gc; | |
8983 | 1523 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1524 |
1525 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1526 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1527 if (listenfd >= 0) |
1528 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1529 if (dim->conn != NULL) { |
8982 | 1530 char *tmp; |
1531 GaimConversation *conv; | |
1532 | |
8971 | 1533 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1534 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1535 oscar_callback, dim->conn); | |
1536 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1537 gaim_odc_initiate, 0); | |
8982 | 1538 |
8983 | 1539 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1540 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1541 gaim_network_get_port_from_fd(listenfd)); |
1542 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1543 g_free(tmp); | |
8971 | 1544 } else { |
1545 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1546 oscar_direct_im_destroy(od, dim); | |
1547 } | |
8983 | 1548 } |
1549 | |
1550 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1551 GaimConnection *gc = data->gc; | |
1552 | |
1553 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1554 g_free(data->who); | |
1555 g_free(data); | |
1556 return; | |
1557 } | |
1558 | |
1559 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1560 g_free(data->who); |
1561 g_free(data); | |
1562 } | |
1563 | |
1564 /* this is the right click menu cb thingy */ | |
9030 | 1565 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1566 | |
1567 GaimBuddy *buddy; | |
1568 GaimConnection *gc; | |
8971 | 1569 gchar *buf; |
9030 | 1570 struct ask_do_dir_im *data; |
1571 | |
1572 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1573 | |
1574 buddy = (GaimBuddy *) node; | |
1575 gc = gaim_account_get_connection(buddy->account); | |
1576 | |
1577 data = g_new0(struct ask_do_dir_im, 1); | |
1578 data->who = g_strdup(buddy->name); | |
8971 | 1579 data->gc = gc; |
9030 | 1580 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1581 buddy->name); | |
8971 | 1582 |
1583 gaim_request_action(gc, NULL, buf, | |
9030 | 1584 _("Because this reveals your IP address, it " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1585 "may be considered a privacy risk. Do you " |
9030 | 1586 "wish to continue?"), |
1587 0, data, 2, | |
1588 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1589 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1590 g_free(buf); |
1591 } | |
1592 | |
1593 /***************************************************************************** | |
1594 * End scary direct im stuff | |
1595 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1596 |
4617 | 1597 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1598 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1599 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1600 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1601 OscarData *od; |
2086 | 1602 |
1603 if (!gc) { | |
8660 | 1604 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1605 "oscar callback for closed connection (1).\n"); |
2086 | 1606 return; |
1607 } | |
10458 | 1608 |
7283 | 1609 od = (OscarData *)gc->proto_data; |
2086 | 1610 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1611 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1612 /* oh boy. this is probably bad. i guess the only thing we |
1613 * can really do is return? */ | |
8660 | 1614 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1615 "oscar callback for closed connection (2).\n"); |
8660 | 1616 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1617 return; |
1618 } | |
1619 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1620 if (condition & GAIM_INPUT_READ) { |
4617 | 1621 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1622 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1623 "got information on rendezvous listener\n"); |
4617 | 1624 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1625 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1626 "connection error (rendezvous listener)\n"); |
4617 | 1627 aim_conn_kill(od->sess, &conn); |
8446 | 1628 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1629 } |
1630 } else { | |
4617 | 1631 if (aim_get_command(od->sess, conn) >= 0) { |
1632 aim_rxdispatch(od->sess); | |
6029 | 1633 if (od->killme) { |
8660 | 1634 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1635 return; |
1636 } | |
2086 | 1637 } else { |
1638 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
10444 | 1639 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1640 { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1641 gaim_debug_error("oscar", "Major connection error. i.e. " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1642 "invalid data was received on the oscar TCP stream\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1643 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1644 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1645 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1646 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1647 char *buf; |
10458 | 1648 |
1649 gaim_debug_info("oscar", "Lost connection " | |
1650 "to chat room %s\n", cc->name); | |
1651 | |
1652 buf = g_strdup_printf(_("You have lost your connection " | |
1653 "to chat room %s."), cc->name); | |
1654 if (conv != NULL) | |
9627 | 1655 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1656 else | |
1657 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1658 g_free(buf); |
10458 | 1659 |
1660 oscar_chat_kill(gc, cc); | |
1661 | |
2086 | 1662 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1663 if (od->cnpa > 0) |
1664 gaim_input_remove(od->cnpa); | |
1665 od->cnpa = 0; | |
8660 | 1666 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1667 "removing chatnav input watcher\n"); |
4617 | 1668 while (od->create_rooms) { |
1669 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1670 g_free(cr->name); |
4617 | 1671 od->create_rooms = |
1672 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1673 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1674 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1675 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1676 NULL); |
2086 | 1677 } |
4617 | 1678 aim_conn_kill(od->sess, &conn); |
2086 | 1679 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1680 if (od->paspa > 0) |
1681 gaim_input_remove(od->paspa); | |
1682 od->paspa = 0; | |
8660 | 1683 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1684 "removing authconn input watcher\n"); |
4617 | 1685 aim_conn_kill(od->sess, &conn); |
3694 | 1686 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1687 if (od->emlpa > 0) |
1688 gaim_input_remove(od->emlpa); | |
1689 od->emlpa = 0; | |
8660 | 1690 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1691 "removing email input watcher\n"); |
4617 | 1692 aim_conn_kill(od->sess, &conn); |
4804 | 1693 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1694 if (od->icopa > 0) | |
1695 gaim_input_remove(od->icopa); | |
1696 od->icopa = 0; | |
8660 | 1697 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1698 "removing icon input watcher\n"); |
4804 | 1699 aim_conn_kill(od->sess, &conn); |
2086 | 1700 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1701 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1702 gaim_odc_disconnect(od->sess, conn); |
1703 aim_conn_kill(od->sess, &conn); | |
2086 | 1704 } else { |
8660 | 1705 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1706 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1707 conn->type); |
4617 | 1708 aim_conn_kill(od->sess, &conn); |
2086 | 1709 } |
1710 } | |
1711 } | |
1712 } | |
1713 } | |
1714 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1715 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1716 GaimConnection *gc = sess->aux_data; |
7285 | 1717 gchar *s = g_strdup_vprintf(format, va); |
1718 gchar *buf; | |
1719 | |
1720 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1721 gaim_debug_info("oscar", buf); |
7285 | 1722 if (buf[strlen(buf)-1] != '\n') |
8660 | 1723 gaim_debug_info(NULL, "\n"); |
7285 | 1724 g_free(buf); |
2086 | 1725 g_free(s); |
1726 } | |
1727 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1728 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1729 { |
5575 | 1730 GaimConnection *gc = data; |
7283 | 1731 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1732 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1733 aim_conn_t *conn; |
2086 | 1734 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1735 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1736 close(source); |
1737 return; | |
1738 } | |
1739 | |
4617 | 1740 od = gc->proto_data; |
1741 sess = od->sess; | |
2086 | 1742 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1743 conn->fd = source; |
2086 | 1744 |
1745 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1746 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1747 return; |
1748 } | |
1749 | |
1750 aim_conn_completeconnect(sess, conn); | |
4617 | 1751 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1752 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1753 | |
8660 | 1754 gaim_debug_info("oscar", |
7282 | 1755 "Screen name sent, waiting for response\n"); |
7283 | 1756 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1757 ck[1] = 0x65; |
2086 | 1758 } |
1759 | |
10444 | 1760 static void |
1761 oscar_login(GaimAccount *account, GaimStatus *status) | |
1762 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1763 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1764 aim_conn_t *conn; |
5575 | 1765 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1766 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
10400 | 1767 GaimStatusType *status_type; |
1768 GaimStatusPrimitive primitive; | |
1769 | |
1770 status_type = gaim_status_get_type(status); | |
1771 primitive = gaim_status_type_get_primitive(status_type); | |
2086 | 1772 |
8660 | 1773 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
10444 | 1774 |
10400 | 1775 if (primitive == GAIM_STATUS_OFFLINE) |
1776 return; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1777 |
8437 | 1778 if (!aim_snvalid(gaim_account_get_username(account))) { |
1779 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1780 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 | 1781 gaim_connection_error(gc, buf); |
1782 g_free(buf); | |
1783 } | |
1784 | |
9975 | 1785 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1786 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1787 } else { |
6622 | 1788 gc->flags |= GAIM_CONNECTION_HTML; |
1789 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1790 } |
5836 | 1791 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1792 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1793 sess = g_new0(aim_session_t, 1); |
10329 | 1794 aim_session_init(sess, TRUE, FAIM_DEBUG_LEVEL); |
2086 | 1795 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1796 /* |
11162 | 1797 * We need an immediate queue because we don't use a while-loop |
7282 | 1798 * to see if things need to be sent. |
1799 */ | |
2086 | 1800 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1801 od->sess = sess; |
2086 | 1802 sess->aux_data = gc; |
1803 | |
9935 | 1804 /* Connect to core Gaim signals */ |
10087 | 1805 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1806 |
11162 | 1807 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
2086 | 1808 if (conn == NULL) { |
10444 | 1809 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1810 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1811 return; |
1812 } | |
1813 | |
4649 | 1814 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1815 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1816 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1817 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1818 |
1819 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1820 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1821 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1822 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1823 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1824 return; |
1825 } | |
7282 | 1826 |
7283 | 1827 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1828 ck[0] = 0x5a; |
5575 | 1829 } |
1830 | |
1831 static void oscar_close(GaimConnection *gc) { | |
7283 | 1832 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1833 |
1834 while (od->oscar_chats) { | |
1835 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1836 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1837 gaim_input_remove(n->inpa); |
2086 | 1838 g_free(n->name); |
1839 g_free(n->show); | |
4617 | 1840 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1841 g_free(n); |
1842 } | |
4617 | 1843 while (od->direct_ims) { |
8971 | 1844 struct oscar_direct_im *n = od->direct_ims->data; |
1845 oscar_direct_im_destroy(od, n); | |
2086 | 1846 } |
4617 | 1847 /* BBB */ |
1848 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1849 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1850 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1851 gaim_xfer_cancel_local(xfer); |
3630 | 1852 } |
4804 | 1853 while (od->requesticon) { |
1854 char *sn = od->requesticon->data; | |
1855 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1856 free(sn); | |
1857 } | |
4738 | 1858 g_hash_table_destroy(od->buddyinfo); |
4617 | 1859 while (od->create_rooms) { |
1860 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1861 g_free(cr->name); |
4617 | 1862 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1863 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1864 } |
4617 | 1865 if (od->email) |
1866 g_free(od->email); | |
1867 if (od->newp) | |
1868 g_free(od->newp); | |
1869 if (od->oldp) | |
1870 g_free(od->oldp); | |
2086 | 1871 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1872 gaim_input_remove(gc->inpa); |
4617 | 1873 if (od->cnpa > 0) |
1874 gaim_input_remove(od->cnpa); | |
1875 if (od->paspa > 0) | |
1876 gaim_input_remove(od->paspa); | |
1877 if (od->emlpa > 0) | |
1878 gaim_input_remove(od->emlpa); | |
4804 | 1879 if (od->icopa > 0) |
1880 gaim_input_remove(od->icopa); | |
6907 | 1881 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1882 gaim_timeout_remove(od->icontimer); |
8341 | 1883 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1884 gaim_timeout_remove(od->getblisttimer); |
8341 | 1885 if (od->getinfotimer > 0) |
1886 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1887 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1888 |
4617 | 1889 aim_session_kill(od->sess); |
1890 g_free(od->sess); | |
1891 od->sess = NULL; | |
2086 | 1892 g_free(gc->proto_data); |
1893 gc->proto_data = NULL; | |
8660 | 1894 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1895 } |
1896 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1897 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1898 GaimConnection *gc = data; |
7283 | 1899 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1900 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1901 aim_conn_t *bosconn; |
2086 | 1902 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1903 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1904 close(source); |
1905 return; | |
1906 } | |
1907 | |
4617 | 1908 od = gc->proto_data; |
1909 sess = od->sess; | |
1910 bosconn = od->conn; | |
4366 | 1911 bosconn->fd = source; |
2086 | 1912 |
1913 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1914 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1915 return; |
1916 } | |
1917 | |
1918 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1919 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1920 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1921 gaim_connection_update_progress(gc, |
7283 | 1922 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1923 ck[4] = 0x61; |
2086 | 1924 } |
1925 | |
4617 | 1926 /* BBB */ |
4656 | 1927 /* |
1928 * This little area in oscar.c is the nexus of file transfer code, | |
1929 * so I wrote a little explanation of what happens. I am such a | |
1930 * ninja. | |
1931 * | |
1932 * The series of events for a file send is: | |
1933 * -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
|
1934 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1935 * listening socket, then asks the remote user to connect to us (and |
1936 * gives them the file name, port, IP, etc.) | |
1937 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1938 * in oscar_sendfile_estblsh) | |
1939 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1940 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1941 * connection. | |
1942 * -We get drunk because file transfer kicks ass. | |
1943 * | |
1944 * The series of events for a file receive is: | |
1945 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1946 * -Gaim user selects file to name and location to save file to and | |
1947 * oscar_xfer_init is called | |
1948 * -It connects to the remote user using the IP they gave us earlier | |
1949 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1950 * them an AIM_CB_OFT_ACK. | |
1951 * -They begin to send us lots of raw data. | |
1952 * -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
|
1953 * the connection. |
4656 | 1954 */ |
1955 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1956 | |
8446 | 1957 /* |
1958 * Miscellaneous xfer functions | |
1959 */ | |
1960 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1961 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1962 GaimXfer *xfer; |
5146 | 1963 struct aim_oft_info *oft_info; |
4656 | 1964 |
1965 while (fts) { | |
1966 xfer = fts->data; | |
5146 | 1967 oft_info = xfer->data; |
1968 | |
8446 | 1969 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1970 return xfer; |
1971 | |
1972 fts = g_slist_next(fts); | |
1973 } | |
1974 | |
1975 return NULL; | |
1976 } | |
1977 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1978 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1979 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1980 GaimXfer *xfer; |
5146 | 1981 struct aim_oft_info *oft_info; |
4656 | 1982 |
1983 while (fts) { | |
1984 xfer = fts->data; | |
5146 | 1985 oft_info = xfer->data; |
1986 | |
1987 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1988 return xfer; |
1989 | |
1990 fts = g_slist_next(fts); | |
1991 } | |
1992 | |
1993 return NULL; | |
1994 } | |
1995 | |
8446 | 1996 static void oscar_xfer_end(GaimXfer *xfer) |
1997 { | |
1998 struct aim_oft_info *oft_info = xfer->data; | |
1999 GaimConnection *gc = oft_info->sess->aux_data; | |
2000 OscarData *od = gc->proto_data; | |
2001 | |
8660 | 2002 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 2003 |
2004 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
2005 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
2006 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
2007 } | |
2008 | |
2009 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2010 aim_oft_destroyinfo(oft_info); | |
2011 xfer->data = NULL; | |
2012 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2013 } | |
2014 | |
2015 /* | |
2016 * xfer functions used when receiving files | |
2017 */ | |
2018 | |
11084 | 2019 /* |
2020 * This is a gaim timeout callback for when the clientip looks to be useless (after verifiedip has been tried) | |
2021 * It gives up on the file transfer completely if it doesn't approve of the file transfer status | |
2022 */ | |
2023 static gboolean oscar_clientip_timeout(gpointer data) { | |
2024 GaimXfer *xfer; | |
2025 struct aim_oft_info *oft_info; | |
2026 char *msg = NULL; | |
11162 | 2027 |
11084 | 2028 gaim_debug_info("oscar","AAA - in oscar_clientip_timeout\n"); |
2029 xfer = (GaimXfer*) data; | |
2030 if(xfer->data) { | |
2031 oft_info = (struct aim_oft_info*) xfer->data; | |
11162 | 2032 |
11084 | 2033 /* Check to see if the clientip has produced any results */ |
2034 if(oft_info->conn && oft_info->conn->status != AIM_CONN_STATUS_INPROGRESS) { | |
2035 msg = g_strdup_printf(_("Transfer of file %s timed out."),gaim_xfer_get_filename(xfer)); | |
2036 gaim_xfer_conversation_write(xfer, msg, TRUE); | |
2037 g_free(msg); | |
2038 gaim_xfer_unref(xfer); | |
2039 gaim_xfer_cancel_local(xfer); | |
2040 } | |
2041 } | |
2042 return FALSE; | |
2043 } | |
2044 | |
2045 /* | |
2046 * This is a gaim timeout callback for when the verifiedip looks to be useless | |
2047 * It tries the file transfer again using the clientip | |
2048 * | |
2049 * BBB | |
2050 */ | |
2051 static gboolean oscar_verifiedip_timeout(gpointer data) { | |
2052 GaimXfer *xfer; | |
2053 struct aim_oft_info *oft_info; | |
2054 | |
2055 gaim_debug_info("oscar","AAA - in oscar_verifiedip_timeout\n"); | |
2056 xfer = (GaimXfer*) data; | |
2057 if(xfer->data) { | |
2058 oft_info = (struct aim_oft_info*) xfer->data; | |
2059 | |
2060 /* Check to see if the verifiedip has produced any results */ | |
2061 if(oft_info->conn && oft_info->conn->status != AIM_CONN_STATUS_INPROGRESS) { | |
2062 /* gaim_xfer_conversation_write(xfer, | |
2063 "Attempting file transfer via secondary IP address...", FALSE); */ | |
2064 | |
2065 /* The verifiedip connection has worn out its welcome. Goodbye. */ | |
2066 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2067 | |
2068 /* Try the file transfer again with the clientip */ | |
2069 g_free(xfer->remote_ip); | |
2070 xfer->remote_ip = g_strdup(oft_info->clientip); | |
2071 gaim_debug_info("oscar","attempting connection using clientip\n"); | |
2072 oscar_xfer_init_recv(xfer); | |
2073 } | |
2074 } | |
2075 return FALSE; | |
2076 } | |
11162 | 2077 |
8446 | 2078 static void oscar_xfer_init_recv(GaimXfer *xfer) |
2079 { | |
2080 struct aim_oft_info *oft_info = xfer->data; | |
2081 GaimConnection *gc = oft_info->sess->aux_data; | |
2082 OscarData *od = gc->proto_data; | |
2083 | |
8660 | 2084 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
11162 | 2085 |
11084 | 2086 /* Start a timer for this ip address |
2087 * If the verifiedip fails, try the clientip | |
2088 * If clientip fails, declare the whole file transfer dead | |
2089 * This xfer reference will be released in oscar_clientip_timeout */ | |
2090 if(xfer->data) { | |
2091 gaim_xfer_ref(xfer); | |
2092 /* If clientip & verifiedip are the same, we must prevent an infinite loop */ | |
2093 if(g_ascii_strcasecmp(xfer->remote_ip, oft_info->verifiedip) == 0 | |
2094 && g_ascii_strcasecmp(oft_info->clientip, oft_info->verifiedip) != 0 ) { | |
2095 gaim_timeout_add(FT_IP_TIMEOUT * 1000, oscar_verifiedip_timeout, xfer); | |
2096 } else { | |
2097 gaim_timeout_add(FT_IP_TIMEOUT * 1000, oscar_clientip_timeout, xfer); | |
2098 } | |
2099 } | |
8446 | 2100 |
11162 | 2101 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS); |
8446 | 2102 if (oft_info->conn) { |
2103 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2104 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
2105 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
2106 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
2107 if (xfer->fd == -1) { | |
10654 | 2108 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2109 _("Unable to establish file descriptor.")); |
2110 gaim_xfer_cancel_local(xfer); | |
2111 } | |
2112 } else { | |
10654 | 2113 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2114 _("Unable to create new connection.")); |
2115 gaim_xfer_cancel_local(xfer); | |
2116 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2117 } | |
2118 | |
2119 } | |
2120 | |
2121 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
2122 { | |
10405 | 2123 struct aim_oft_info *oft_info; |
2124 GaimConnection *gc; | |
2125 OscarData *od; | |
2126 | |
2127 g_return_if_fail(xfer != NULL); | |
2128 g_return_if_fail(xfer->data != NULL); | |
2129 | |
2130 oft_info = xfer->data; | |
2131 gc = oft_info->sess->aux_data; | |
2132 od = gc->proto_data; | |
8446 | 2133 |
8660 | 2134 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2135 |
9771 | 2136 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2137 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2138 |
2139 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2140 aim_oft_destroyinfo(oft_info); | |
2141 xfer->data = NULL; | |
2142 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2143 } | |
2144 | |
11159 | 2145 static void oscar_xfer_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2146 { |
2147 struct aim_oft_info *oft_info = xfer->data; | |
2148 | |
2149 /* Update our rolling checksum. Like Walmart, yo. */ | |
2150 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2151 } | |
2152 | |
2153 /* | |
2154 * xfer functions used when sending files | |
2155 */ | |
2156 | |
2157 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2158 { | |
2159 struct aim_oft_info *oft_info = xfer->data; | |
2160 GaimConnection *gc = oft_info->sess->aux_data; | |
2161 OscarData *od = gc->proto_data; | |
2162 int listenfd; | |
2163 | |
8660 | 2164 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2165 |
2166 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2167 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2168 oft_info->fh.name[63] = '\0'; | |
2169 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2170 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2171 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2172 | |
2173 /* Create a listening socket and an associated libfaim conn */ | |
2174 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2175 gaim_xfer_cancel_local(xfer); | |
2176 return; | |
2177 } | |
2178 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2179 oft_info->port = xfer->local_port; | |
2180 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2181 gaim_xfer_cancel_local(xfer); | |
2182 return; | |
2183 } | |
8660 | 2184 gaim_debug_misc("oscar", |
8446 | 2185 "port is %hu, ip is %s\n", |
2186 xfer->local_port, oft_info->clientip); | |
2187 if (oft_info->conn) { | |
2188 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2189 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2190 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2191 } else { | |
10654 | 2192 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2193 _("Unable to establish listener socket.")); |
2194 gaim_xfer_cancel_local(xfer); | |
2195 } | |
2196 } | |
2197 | |
2198 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2199 { | |
2200 struct aim_oft_info *oft_info = xfer->data; | |
2201 GaimConnection *gc = oft_info->sess->aux_data; | |
2202 OscarData *od = gc->proto_data; | |
2203 | |
8660 | 2204 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2205 |
9771 | 2206 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2207 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2208 |
2209 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2210 aim_oft_destroyinfo(oft_info); | |
2211 xfer->data = NULL; | |
2212 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2213 } | |
2214 | |
11159 | 2215 static void oscar_xfer_ack_send(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2216 { |
2217 struct aim_oft_info *oft_info = xfer->data; | |
2218 | |
2219 /* I'm not sure I like how we do this. --marv | |
2220 * I do. AIM file transfers aren't really meant to be thought | |
2221 * of as a transferring just a single file. The rendezvous | |
2222 * establishes a connection between two computers, and then | |
2223 * those computers can use the same connection for transferring | |
2224 * multiple files. So we don't want the Gaim core up and closing | |
2225 * the socket all willy-nilly. We want to do that in the oscar | |
2226 * prpl, whenever one side or the other says they're finished | |
2227 * using the connection. There might be a better way to intercept | |
2228 * the socket from the core, however... --KingAnt | |
2229 */ | |
2230 | |
2231 /* | |
2232 * If we're done sending, intercept the socket from the core ft code | |
2233 * and wait for the other guy to send the "done" OFT packet. | |
2234 */ | |
2235 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2236 gaim_input_remove(xfer->watcher); | |
2237 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2238 xfer->fd = 0; | |
2239 gaim_xfer_set_completed(xfer, TRUE); | |
2240 } | |
2241 } | |
2242 | |
9466 | 2243 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2244 gboolean can_receive = FALSE; | |
2245 OscarData *od = gc->proto_data; | |
2246 | |
11049 | 2247 if (od != NULL) { |
9466 | 2248 aim_userinfo_t *userinfo; |
2249 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2250 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2251 can_receive = TRUE; | |
2252 } | |
2253 | |
2254 return can_receive; | |
2255 } | |
2256 | |
2257 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2258 |
2259 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2260 GaimXfer *xfer; |
5146 | 2261 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2262 const char *ip; |
3752 | 2263 |
9030 | 2264 od = (OscarData *)gc->proto_data; |
2265 | |
4617 | 2266 /* You want to send a file to someone else, you're so generous */ |
2267 | |
2268 /* Build the file transfer handle */ | |
9466 | 2269 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2270 |
5146 | 2271 /* Create the oscar-specific data */ |
8838 | 2272 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2273 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2274 xfer->data = oft_info; |
2275 | |
4617 | 2276 /* Setup our I/O op functions */ |
8446 | 2277 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2278 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2279 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2280 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2281 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2282 |
2283 /* Keep track of this transfer for later */ | |
2284 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2285 | |
2286 /* Now perform the request */ | |
9466 | 2287 if (file) |
2288 gaim_xfer_request_accepted(xfer, file); | |
2289 else | |
2290 gaim_xfer_request(xfer); | |
3630 | 2291 } |
2292 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2293 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2294 GaimConnection *gc = sess->aux_data; |
7283 | 2295 OscarData *od = gc->proto_data; |
6029 | 2296 GaimAccount *account = gc->account; |
2297 aim_conn_t *bosconn; | |
2298 char *host; int port; | |
2299 int i, rc; | |
2086 | 2300 va_list ap; |
2704 | 2301 struct aim_authresp_info *info; |
6029 | 2302 |
5575 | 2303 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2304 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2305 va_start(ap, fr); |
2704 | 2306 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2307 va_end(ap); |
2308 | |
8660 | 2309 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2310 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2311 |
4293 | 2312 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2313 char buf[256]; |
2704 | 2314 switch (info->errorcode) { |
2086 | 2315 case 0x05: |
2316 /* Incorrect nick/password */ | |
6498 | 2317 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2318 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2319 break; |
2320 case 0x11: | |
2321 /* Suspended account */ | |
6498 | 2322 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2323 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2324 break; |
3498 | 2325 case 0x14: |
2326 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2327 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2328 break; |
2086 | 2329 case 0x18: |
2330 /* connecting too frequently */ | |
6498 | 2331 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2332 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 | 2333 break; |
2334 case 0x1c: | |
2335 /* client too old */ | |
6498 | 2336 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2337 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
|
2338 gaim_connection_error(gc, buf); |
2086 | 2339 break; |
2340 default: | |
6623 | 2341 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2342 break; |
2343 } | |
8660 | 2344 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2345 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2346 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2347 "Error URL: %s\n", info->errorurl); |
2086 | 2348 od->killme = TRUE; |
2349 return 1; | |
2350 } | |
2351 | |
2352 | |
9992 | 2353 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2354 |
2704 | 2355 if (info->email) { |
8660 | 2356 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2357 } else { |
8660 | 2358 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2359 } |
10042 | 2360 |
8660 | 2361 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2362 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2363 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2364 aim_conn_kill(sess, &fr->conn); |
2086 | 2365 |
11162 | 2366 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS); |
2086 | 2367 if (bosconn == NULL) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2368 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2369 od->killme = TRUE; |
2370 return 0; | |
2371 } | |
2372 | |
4649 | 2373 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2374 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2375 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2376 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2377 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2378 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2379 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2380 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2381 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2382 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2383 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2384 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2385 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2386 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2387 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2388 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2389 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2390 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2391 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2392 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2393 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2394 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2395 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
|
2396 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2397 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2398 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2399 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2400 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2401 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2402 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
|
2403 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
|
2404 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
|
2405 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2406 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2407 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4642 | 2408 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2409 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2410 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2411 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2412 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2413 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2414 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2415 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2416 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2417 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2418 |
7283 | 2419 od->conn = bosconn; |
2704 | 2420 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2421 if (info->bosip[i] == ':') { | |
2422 port = atoi(&(info->bosip[i+1])); | |
2086 | 2423 break; |
2424 } | |
2425 } | |
2704 | 2426 host = g_strndup(info->bosip, i); |
2086 | 2427 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2428 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2429 g_free(host); |
4366 | 2430 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2431 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2432 od->killme = TRUE; |
2433 return 0; | |
2434 } | |
4293 | 2435 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2436 gaim_input_remove(gc->inpa); |
2704 | 2437 |
7283 | 2438 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2439 ck[3] = 0x64; |
7282 | 2440 |
2086 | 2441 return 1; |
2442 } | |
2443 | |
10464 | 2444 static void |
2445 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2446 { | |
2447 GaimConnection *gc = user_data; | |
2448 OscarData *od = gc->proto_data; | |
2449 aim_session_t *sess = od->sess; | |
2450 | |
2451 aim_auth_securid_send(sess, msg); | |
2452 } | |
2453 | |
2454 static void | |
2455 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2456 { | |
2457 GaimConnection *gc = user_data; | |
2458 OscarData *od = gc->proto_data; | |
2459 | |
2460 /* Disconnect */ | |
2461 gc->wants_to_die = TRUE; | |
2462 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2463 od->killme = TRUE; | |
2464 } | |
2465 | |
2466 static int | |
2467 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2468 { | |
2469 GaimConnection *gc = sess->aux_data; | |
2470 GaimAccount *account = gaim_connection_get_account(gc); | |
2471 gchar *primary; | |
2472 | |
2473 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2474 | |
2475 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2476 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2477 _("Enter the 6 digit number from the digital display."), | |
2478 FALSE, FALSE, NULL, | |
2479 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2480 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2481 gc); | |
2482 g_free(primary); | |
2483 | |
2484 return 1; | |
2485 } | |
2486 | |
7285 | 2487 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2488 struct pieceofcrap { |
5575 | 2489 GaimConnection *gc; |
2086 | 2490 unsigned long offset; |
2491 unsigned long len; | |
2492 char *modname; | |
2493 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2494 aim_conn_t *conn; |
2086 | 2495 unsigned int inpa; |
2496 }; | |
2497 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2498 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2499 { |
2500 struct pieceofcrap *pos = data; | |
7283 | 2501 OscarData *od = pos->gc->proto_data; |
2086 | 2502 char in = '\0'; |
2503 int x = 0; | |
2504 unsigned char m[17]; | |
2505 | |
2506 while (read(pos->fd, &in, 1) == 1) { | |
2507 if (in == '\n') | |
2508 x++; | |
2509 else if (in != '\r') | |
2510 x = 0; | |
2511 if (x == 2) | |
2512 break; | |
2513 in = '\0'; | |
2514 } | |
2515 if (in != '\n') { | |
4056 | 2516 char buf[256]; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2517 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
|
2518 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2519 gaim_notify_warning(pos->gc, NULL, |
7422 | 2520 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2521 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2522 gaim_input_remove(pos->inpa); |
2086 | 2523 close(pos->fd); |
2524 g_free(pos); | |
2525 return; | |
2526 } | |
2527 read(pos->fd, m, 16); | |
2528 m[16] = '\0'; | |
8660 | 2529 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2530 for (x = 0; x < 16; x++) |
8660 | 2531 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2532 | |
2533 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2534 gaim_input_remove(pos->inpa); |
2086 | 2535 close(pos->fd); |
2536 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2537 g_free(pos); | |
2538 } | |
2539 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2540 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2541 struct pieceofcrap *pos = data; |
5420 | 2542 gchar *buf; |
2086 | 2543 |
4366 | 2544 pos->fd = source; |
2545 | |
2086 | 2546 if (source < 0) { |
5420 | 2547 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
|
2548 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2549 gaim_notify_warning(pos->gc, NULL, |
7422 | 2550 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2551 buf); |
5420 | 2552 g_free(buf); |
2086 | 2553 if (pos->modname) |
2554 g_free(pos->modname); | |
2555 g_free(pos); | |
2556 return; | |
2557 } | |
2558 | |
5420 | 2559 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2560 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2561 write(pos->fd, buf, strlen(buf)); | |
5420 | 2562 g_free(buf); |
2086 | 2563 if (pos->modname) |
2564 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2565 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2566 return; |
2567 } | |
2568 | |
2569 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2570 #define AIM_MAX_FILE_SIZE 98304 | |
2571 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2572 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2573 va_list ap; |
2574 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2575 fu32_t offset, len; |
2086 | 2576 char *modname; |
2577 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2578 va_start(ap, fr); |
4200 | 2579 offset = va_arg(ap, fu32_t); |
2580 len = va_arg(ap, fu32_t); | |
2086 | 2581 modname = va_arg(ap, char *); |
2582 va_end(ap); | |
2583 | |
8660 | 2584 gaim_debug_misc("oscar", |
5556 | 2585 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2586 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2587 |
2086 | 2588 if (len == 0) { |
8660 | 2589 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2590 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2591 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2592 return 1; | |
2593 } | |
9625 | 2594 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2595 #if 0 | |
2086 | 2596 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2597 char *buf; | |
2598 int i = 8; | |
2599 if (modname) | |
2600 i += strlen(modname); | |
2601 buf = g_malloc(i); | |
2602 i = 0; | |
2603 if (modname) { | |
2604 memcpy(buf, modname, strlen(modname)); | |
2605 i += strlen(modname); | |
2606 } | |
2607 buf[i++] = offset & 0xff; | |
2608 buf[i++] = (offset >> 8) & 0xff; | |
2609 buf[i++] = (offset >> 16) & 0xff; | |
2610 buf[i++] = (offset >> 24) & 0xff; | |
2611 buf[i++] = len & 0xff; | |
2612 buf[i++] = (len >> 8) & 0xff; | |
2613 buf[i++] = (len >> 16) & 0xff; | |
2614 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2615 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2616 "hashing request\n"); |
2086 | 2617 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2618 g_free(buf); | |
2619 return 1; | |
2620 } | |
9625 | 2621 #endif |
2086 | 2622 |
2623 pos = g_new0(struct pieceofcrap, 1); | |
2624 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2625 pos->conn = fr->conn; |
2086 | 2626 |
2627 pos->offset = offset; | |
2628 pos->len = len; | |
2629 pos->modname = modname ? g_strdup(modname) : NULL; | |
2630 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2631 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2632 char buf[256]; |
2086 | 2633 if (pos->modname) |
2634 g_free(pos->modname); | |
2635 g_free(pos); | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2636 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2637 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2638 gaim_notify_warning(pos->gc, NULL, |
7422 | 2639 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2640 buf); |
2086 | 2641 } |
2642 | |
2643 return 1; | |
2644 } | |
2645 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2646 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2647 GaimConnection *gc = sess->aux_data; |
7283 | 2648 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2649 GaimAccount *account = gaim_connection_get_account(gc); |
7282 | 2650 #if 0 |
2651 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2652 #endif | |
7011 | 2653 va_list ap; |
2654 char *key; | |
2086 | 2655 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2656 va_start(ap, fr); |
2086 | 2657 key = va_arg(ap, char *); |
2658 va_end(ap); | |
2659 | |
4617 | 2660 if (od->icq) { |
3458 | 2661 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
10740 | 2662 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2663 gaim_connection_get_password(gc), &info, key); | |
3458 | 2664 } else { |
2665 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
10740 | 2666 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2667 gaim_connection_get_password(gc), &info, key); | |
3458 | 2668 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2669 |
7283 | 2670 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2671 ck[2] = 0x6c; |
7282 | 2672 |
2086 | 2673 return 1; |
2674 } | |
2675 | |
2675 | 2676 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2677 GaimConnection *gc = sess->aux_data; |
2647 | 2678 struct chat_connection *chatcon; |
2679 static int id = 1; | |
2680 | |
6905 | 2681 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
|
2682 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
|
2683 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
|
2684 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
|
2685 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2686 |
2672 | 2687 aim_clientready(sess, fr->conn); |
2675 | 2688 |
2647 | 2689 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2690 chatcon->id = id; | |
8733 | 2691 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2692 |
2693 return 1; | |
2694 } | |
2695 | |
2675 | 2696 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2697 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2698 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2699 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2700 |
2701 aim_clientready(sess, fr->conn); | |
2702 | |
2703 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2704 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2705 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2706 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2707 |
3694 | 2708 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2709 | |
2710 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2711 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2712 | |
7282 | 2713 aim_email_sendcookies(sess); |
2714 aim_email_activate(sess); | |
3694 | 2715 aim_clientready(sess, fr->conn); |
2716 | |
2717 return 1; | |
2718 } | |
2719 | |
4804 | 2720 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2721 GaimConnection *gc = sess->aux_data; |
7283 | 2722 OscarData *od = gc->proto_data; |
4804 | 2723 |
2724 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2725 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2726 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2727 | |
2728 aim_clientready(sess, fr->conn); | |
2729 | |
4823 | 2730 od->iconconnecting = FALSE; |
2731 | |
4804 | 2732 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2733 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2734 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2735 |
2736 return 1; | |
2737 } | |
2738 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2739 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2740 GaimConnection *gc = data; |
7283 | 2741 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2742 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2743 aim_conn_t *tstconn; |
2086 | 2744 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2745 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2746 close(source); |
2747 return; | |
2748 } | |
2749 | |
4617 | 2750 od = gc->proto_data; |
2751 sess = od->sess; | |
2086 | 2752 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2753 tstconn->fd = source; |
2086 | 2754 |
2755 if (source < 0) { | |
2756 aim_conn_kill(sess, &tstconn); | |
8660 | 2757 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2758 "unable to connect to chatnav server\n"); |
2086 | 2759 return; |
2760 } | |
2761 | |
2762 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2763 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2764 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2765 } |
2766 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2767 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2768 { |
5575 | 2769 GaimConnection *gc = data; |
7283 | 2770 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2771 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2772 aim_conn_t *tstconn; |
2086 | 2773 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2774 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2775 close(source); |
2776 return; | |
2777 } | |
2778 | |
4617 | 2779 od = gc->proto_data; |
2780 sess = od->sess; | |
2086 | 2781 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2782 tstconn->fd = source; |
2086 | 2783 |
2784 if (source < 0) { | |
2785 aim_conn_kill(sess, &tstconn); | |
8660 | 2786 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2787 "unable to connect to authorizer\n"); |
2086 | 2788 return; |
2789 } | |
2790 | |
2791 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2792 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2793 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2794 } |
2795 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2796 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2797 { |
2798 struct chat_connection *ccon = data; | |
5575 | 2799 GaimConnection *gc = ccon->gc; |
7283 | 2800 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2801 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2802 aim_conn_t *tstconn; |
2086 | 2803 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2804 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2805 close(source); |
2806 g_free(ccon->show); | |
2807 g_free(ccon->name); | |
2808 g_free(ccon); | |
2809 return; | |
2810 } | |
2811 | |
4617 | 2812 od = gc->proto_data; |
2813 sess = od->sess; | |
2086 | 2814 tstconn = ccon->conn; |
4366 | 2815 tstconn->fd = source; |
2086 | 2816 |
2817 if (source < 0) { | |
2818 aim_conn_kill(sess, &tstconn); | |
2819 g_free(ccon->show); | |
2820 g_free(ccon->name); | |
2821 g_free(ccon); | |
2822 return; | |
2823 } | |
2824 | |
2825 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2826 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2827 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2828 } |
2829 | |
3694 | 2830 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2831 GaimConnection *gc = data; |
7283 | 2832 OscarData *od; |
3694 | 2833 aim_session_t *sess; |
2834 aim_conn_t *tstconn; | |
2835 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2836 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2837 close(source); |
2838 return; | |
2839 } | |
2840 | |
4617 | 2841 od = gc->proto_data; |
2842 sess = od->sess; | |
3694 | 2843 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2844 tstconn->fd = source; |
3694 | 2845 |
2846 if (source < 0) { | |
2847 aim_conn_kill(sess, &tstconn); | |
8660 | 2848 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2849 "unable to connect to email server\n"); |
3694 | 2850 return; |
2851 } | |
2852 | |
2853 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2854 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2855 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2856 "email: connected\n"); |
3694 | 2857 } |
2858 | |
4804 | 2859 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2860 GaimConnection *gc = data; |
7283 | 2861 OscarData *od; |
4804 | 2862 aim_session_t *sess; |
2863 aim_conn_t *tstconn; | |
2864 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2865 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2866 close(source); |
2867 return; | |
2868 } | |
2869 | |
2870 od = gc->proto_data; | |
2871 sess = od->sess; | |
2872 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2873 tstconn->fd = source; | |
2874 | |
2875 if (source < 0) { | |
2876 aim_conn_kill(sess, &tstconn); | |
8660 | 2877 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2878 "unable to connect to icon server\n"); |
4804 | 2879 return; |
2880 } | |
2881 | |
2882 aim_conn_completeconnect(sess, tstconn); | |
2883 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2884 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2885 } |
2886 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2887 /* 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
|
2888 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2889 GaimConnection *gc = sess->aux_data; |
2890 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2891 aim_conn_t *tstconn; |
4452 | 2892 int i; |
2086 | 2893 char *host; |
2894 int port; | |
4821 | 2895 va_list ap; |
2896 struct aim_redirect_data *redir; | |
2086 | 2897 |
5575 | 2898 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2899 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2900 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2901 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2902 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2903 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2904 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2905 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2906 port = atoi(&(redir->ip[i+1])); |
2086 | 2907 break; |
2908 } | |
2909 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2910 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2911 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2912 switch(redir->group) { |
2086 | 2913 case 0x7: /* Authorizer */ |
8660 | 2914 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2915 "Reconnecting with authorizor...\n"); |
11162 | 2916 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
2086 | 2917 if (tstconn == NULL) { |
8660 | 2918 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2919 "unable to reconnect with authorizer\n"); |
2086 | 2920 g_free(host); |
2921 return 1; | |
2922 } | |
4649 | 2923 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2924 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2925 |
2926 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2927 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2928 aim_conn_kill(sess, &tstconn); |
8660 | 2929 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2930 "unable to reconnect with authorizer\n"); |
2086 | 2931 g_free(host); |
2932 return 1; | |
2933 } | |
4293 | 2934 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2935 break; |
2936 | |
2086 | 2937 case 0xd: /* ChatNav */ |
11162 | 2938 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV); |
2086 | 2939 if (tstconn == NULL) { |
8660 | 2940 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2941 "unable to connect to chatnav server\n"); |
2086 | 2942 g_free(host); |
2943 return 1; | |
2944 } | |
4649 | 2945 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2946 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2947 |
2948 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2949 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2950 aim_conn_kill(sess, &tstconn); |
8660 | 2951 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2952 "unable to connect to chatnav server\n"); |
2086 | 2953 g_free(host); |
2954 return 1; | |
2955 } | |
4293 | 2956 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2957 break; |
2958 | |
2959 case 0xe: { /* Chat */ | |
2086 | 2960 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2961 |
11162 | 2962 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT); |
2086 | 2963 if (tstconn == NULL) { |
8660 | 2964 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2965 "unable to connect to chat server\n"); |
2086 | 2966 g_free(host); |
2967 return 1; | |
2968 } | |
2969 | |
4649 | 2970 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2971 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2972 | |
2086 | 2973 ccon = g_new0(struct chat_connection, 1); |
2974 ccon->conn = tstconn; | |
2975 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2976 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2977 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2978 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2979 ccon->show = extract_name(redir->chat.room); |
4634 | 2980 |
2086 | 2981 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2982 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2983 aim_conn_kill(sess, &tstconn); |
8660 | 2984 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2985 "unable to connect to chat server\n"); |
2086 | 2986 g_free(host); |
2987 g_free(ccon->show); | |
2988 g_free(ccon->name); | |
2989 g_free(ccon); | |
2990 return 1; | |
2991 } | |
4293 | 2992 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2993 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2994 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2995 ccon->name, ccon->exchange); |
4194 | 2996 } break; |
3694 | 2997 |
4804 | 2998 case 0x0010: { /* icon */ |
11162 | 2999 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON))) { |
8660 | 3000 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3001 "unable to connect to icon server\n"); |
4804 | 3002 g_free(host); |
3003 return 1; | |
3004 } | |
3005 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
3006 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
3007 | |
3008 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3009 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 3010 aim_conn_kill(sess, &tstconn); |
8660 | 3011 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3012 "unable to connect to icon server\n"); |
4804 | 3013 g_free(host); |
3014 return 1; | |
3015 } | |
3016 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
3017 } break; | |
3018 | |
3694 | 3019 case 0x0018: { /* email */ |
11162 | 3020 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL))) { |
8660 | 3021 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3022 "unable to connect to email server\n"); |
3694 | 3023 g_free(host); |
3024 return 1; | |
3025 } | |
4649 | 3026 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 3027 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
3028 | |
3029 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3030 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 3031 aim_conn_kill(sess, &tstconn); |
8660 | 3032 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3033 "unable to connect to email server\n"); |
3694 | 3034 g_free(host); |
3035 return 1; | |
3036 } | |
4293 | 3037 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 3038 } break; |
3039 | |
2086 | 3040 default: /* huh? */ |
8660 | 3041 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3042 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3043 redir->group); |
2086 | 3044 break; |
3045 } | |
3046 | |
3047 g_free(host); | |
3048 return 1; | |
3049 } | |
3050 | |
10042 | 3051 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
3052 { | |
3053 GaimConnection *gc; | |
3054 GaimAccount *account; | |
3055 OscarData *od; | |
4738 | 3056 struct buddyinfo *bi; |
2993 | 3057 time_t time_idle = 0, signon = 0; |
3058 int type = 0; | |
3059 int caps = 0; | |
2086 | 3060 va_list ap; |
4738 | 3061 aim_userinfo_t *info; |
10042 | 3062 gboolean buddy_is_away = FALSE; |
3063 | |
3064 gc = sess->aux_data; | |
3065 account = gaim_connection_get_account(gc); | |
3066 od = gc->proto_data; | |
4194 | 3067 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3068 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3069 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3070 va_end(ap); |
3071 | |
10130 | 3072 g_return_val_if_fail(info != NULL, 1); |
3073 g_return_val_if_fail(info->sn != NULL, 1); | |
3074 | |
2993 | 3075 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
3076 caps = info->capabilities; | |
3267 | 3077 |
4766 | 3078 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
3079 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 3080 buddy_is_away = TRUE; |
3081 } | |
3082 | |
2993 | 3083 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 3084 type = (info->icqinfo.status << 16); |
3013 | 3085 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3086 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3087 buddy_is_away = TRUE; |
3013 | 3088 } |
2993 | 3089 } |
3090 | |
7141 | 3091 if (caps & AIM_CAPS_ICQ_DIRECT) |
3092 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 3093 |
10860 | 3094 /* info->idletime is the number of minutes that this user has been idle */ |
3095 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
3096 time_idle = time(NULL) - info->idletime * 60; | |
2993 | 3097 |
5836 | 3098 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3099 signon = info->onlinesince; | |
3100 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3101 signon = time(NULL) - info->sessionlen; |
2086 | 3102 |
10567 | 3103 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3104 gaim_connection_set_display_name(gc, info->sn); |
10567 | 3105 od->timeoffset = signon - gc->login_time; |
3106 } | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
3107 |
9982 | 3108 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3109 if (!bi) { |
3110 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3111 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3112 } |
4739 | 3113 bi->typingnot = FALSE; |
3114 bi->ico_informed = FALSE; | |
6857 | 3115 bi->ipaddr = info->icqinfo.ipaddr; |
3116 | |
10563 | 3117 /* |
3118 * Handle the available message. If info->avail is NULL then the user | |
3119 * may or may not have an available message, so don't do anything. If | |
3120 * info->avail is set to the empty string, then the user's client DOES | |
3121 * support available messages and the user DOES NOT have one set. | |
3122 * Otherwise info->avail contains the available message. | |
3123 */ | |
7011 | 3124 if (info->avail != NULL) |
10563 | 3125 { |
3126 free(bi->availmsg); | |
3127 if (info->avail[0] != '\0') | |
3128 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); | |
3129 else | |
3130 bi->availmsg = NULL; | |
3131 } | |
4732 | 3132 |
4804 | 3133 /* Server stored icon stuff */ |
4853 | 3134 if (info->iconcsumlen) { |
7125 | 3135 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3136 char *b16 = NULL, *filepath = NULL; |
7093 | 3137 GaimBuddy *b = NULL; |
4853 | 3138 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3139 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3140 b = gaim_find_buddy(account, info->sn); |
7093 | 3141 /* |
3142 * If for some reason the checksum is valid, but cached file is not.. | |
3143 * we want to know. | |
3144 */ | |
7693 | 3145 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3146 if (filename != NULL) { |
3147 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3148 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3149 "icon_checksum"); | |
9801 | 3150 else { |
3151 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3152 filename, NULL); | |
3153 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3154 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3155 "icon_checksum"); | |
3156 g_free(filepath); | |
3157 } | |
7093 | 3158 } else |
3159 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3160 |
4853 | 3161 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3162 GSList *cur = od->requesticon; | |
3163 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3164 cur = cur->next; | |
3165 if (!cur) { | |
9982 | 3166 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3167 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3168 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3169 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3170 } |
3171 } | |
6053 | 3172 g_free(b16); |
4853 | 3173 } |
3174 | |
10042 | 3175 /* XXX - Represent other ICQ statuses */ |
3176 if (buddy_is_away == TRUE) | |
3177 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
3178 else | |
3179 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
10567 | 3180 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
9982 | 3181 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); |
3182 | |
3183 if (time_idle > 0) | |
3184 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 3185 else |
3186 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 3187 |
3188 return 1; | |
3189 } | |
3190 | |
8341 | 3191 static void gaim_check_comment(OscarData *od, const char *str) { |
11159 | 3192 if ((str == NULL) || strcmp(str, (const char *)ck)) |
8341 | 3193 aim_locate_setcaps(od->sess, caps_aim); |
3194 else | |
3195 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3196 } | |
3197 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3198 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3199 GaimConnection *gc = sess->aux_data; |
7283 | 3200 OscarData *od = gc->proto_data; |
9982 | 3201 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3202 va_list ap; |
4739 | 3203 aim_userinfo_t *info; |
2086 | 3204 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3205 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3206 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3207 va_end(ap); |
3208 | |
9982 | 3209 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3210 |
7261 | 3211 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3212 |
2086 | 3213 return 1; |
3214 } | |
3215 | |
4617 | 3216 /* BBB */ |
3952 | 3217 /* |
4617 | 3218 * This is called after a remote AIM user has connected to us. We |
3219 * want to do some voodoo with the socket file descriptors, add a | |
3220 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3221 */ |
4656 | 3222 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3223 GaimConnection *gc = sess->aux_data; |
7283 | 3224 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3225 GaimXfer *xfer; |
5146 | 3226 struct aim_oft_info *oft_info; |
3630 | 3227 va_list ap; |
3228 aim_conn_t *conn, *listenerconn; | |
4656 | 3229 |
8660 | 3230 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3231 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3232 va_start(ap, fr); |
3233 conn = va_arg(ap, aim_conn_t *); | |
3234 listenerconn = va_arg(ap, aim_conn_t *); | |
3235 va_end(ap); | |
3236 | |
4617 | 3237 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3238 return 1; | |
3239 | |
5146 | 3240 if (!(oft_info = xfer->data)) |
4617 | 3241 return 1; |
3242 | |
3630 | 3243 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3244 gaim_input_remove(xfer->watcher); |
3630 | 3245 aim_conn_kill(sess, &listenerconn); |
3246 | |
5146 | 3247 oft_info->conn = conn; |
3248 xfer->fd = oft_info->conn->fd; | |
3249 | |
3250 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3251 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3252 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3253 |
3254 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3255 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3256 |
3257 return 0; | |
3258 } | |
3259 | |
3952 | 3260 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3261 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3262 * user in order to transfer a file. |
3952 | 3263 */ |
4617 | 3264 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
|
3265 GaimXfer *xfer; |
5146 | 3266 struct aim_oft_info *oft_info; |
4656 | 3267 |
8660 | 3268 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3269 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3270 if (!(xfer = data)) |
3271 return; | |
5146 | 3272 if (!(oft_info = xfer->data)) |
3630 | 3273 return; |
8446 | 3274 if (source < 0) { |
3275 gaim_xfer_cancel_remote(xfer); | |
4617 | 3276 return; |
8446 | 3277 } |
4617 | 3278 |
3279 xfer->fd = source; | |
5146 | 3280 oft_info->conn->fd = source; |
3281 | |
3282 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3283 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3284 |
3285 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3286 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3287 |
3288 return; | |
3630 | 3289 } |
3290 | |
3952 | 3291 /* |
4617 | 3292 * This is called when a buddy sends us some file info. This happens when they |
3293 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3294 * You should send them the exact same info except use the real cookie. We also |
4617 | 3295 * get like totally ready to like, receive the file, kay? |
3952 | 3296 */ |
4617 | 3297 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3298 GaimConnection *gc = sess->aux_data; |
7283 | 3299 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3300 GaimXfer *xfer; |
5146 | 3301 struct aim_oft_info *oft_info; |
4617 | 3302 va_list ap; |
3303 aim_conn_t *conn; | |
3304 fu8_t *cookie; | |
3305 struct aim_fileheader_t *fh; | |
4656 | 3306 |
8660 | 3307 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3308 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3309 va_start(ap, fr); |
3310 conn = va_arg(ap, aim_conn_t *); | |
3311 cookie = va_arg(ap, fu8_t *); | |
3312 fh = va_arg(ap, struct aim_fileheader_t *); | |
3313 va_end(ap); | |
3314 | |
3315 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3316 return 1; | |
3317 | |
5146 | 3318 if (!(oft_info = xfer->data)) |
4617 | 3319 return 1; |
3320 | |
3321 /* We want to stop listening with a normal thingy */ | |
3322 gaim_input_remove(xfer->watcher); | |
3323 xfer->watcher = 0; | |
3324 | |
5146 | 3325 /* They sent us some information about the file they're sending */ |
3326 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3327 | |
3328 /* Fill in the cookie */ | |
3329 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3330 | |
4617 | 3331 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3332 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3333 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3334 | |
3335 return 0; | |
3630 | 3336 } |
3337 | |
3952 | 3338 /* |
4657 | 3339 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3340 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3341 */ |
4617 | 3342 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3343 GaimConnection *gc = sess->aux_data; |
7283 | 3344 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3345 GaimXfer *xfer; |
4617 | 3346 va_list ap; |
3347 aim_conn_t *conn; | |
3348 fu8_t *cookie; | |
3349 struct aim_fileheader_t *fh; | |
4656 | 3350 |
8660 | 3351 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3352 va_start(ap, fr); |
3353 conn = va_arg(ap, aim_conn_t *); | |
3354 cookie = va_arg(ap, fu8_t *); | |
3355 fh = va_arg(ap, struct aim_fileheader_t *); | |
3356 va_end(ap); | |
3357 | |
3358 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3359 return 1; | |
3360 | |
4656 | 3361 /* We want to stop listening with a normal thingy */ |
3362 gaim_input_remove(xfer->watcher); | |
3363 xfer->watcher = 0; | |
3364 | |
4617 | 3365 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3366 | |
3367 return 0; | |
3630 | 3368 } |
4617 | 3369 |
3370 /* | |
3371 * We just sent a file to someone. They said they got it and everything, | |
3372 * so we can close our direct connection and what not. | |
3373 */ | |
3374 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3375 GaimConnection *gc = sess->aux_data; |
7283 | 3376 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3377 GaimXfer *xfer; |
4617 | 3378 va_list ap; |
3379 aim_conn_t *conn; | |
3380 fu8_t *cookie; | |
3381 struct aim_fileheader_t *fh; | |
4656 | 3382 |
8660 | 3383 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3384 va_start(ap, fr); |
3385 conn = va_arg(ap, aim_conn_t *); | |
3386 cookie = va_arg(ap, fu8_t *); | |
3387 fh = va_arg(ap, struct aim_fileheader_t *); | |
3388 va_end(ap); | |
3389 | |
3390 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3391 return 1; | |
3392 | |
4656 | 3393 xfer->fd = conn->fd; |
4617 | 3394 gaim_xfer_end(xfer); |
3395 | |
3396 return 0; | |
3397 } | |
3630 | 3398 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3399 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3400 GaimConnection *gc = sess->aux_data; |
7283 | 3401 OscarData *od = gc->proto_data; |
8708 | 3402 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3403 GaimConvImFlags flags = 0; |
4738 | 3404 struct buddyinfo *bi; |
5575 | 3405 const char *iconfile; |
9806 | 3406 GString *message; |
3407 gchar *tmp; | |
3408 aim_mpmsg_section_t *curpart; | |
3409 | |
10472 | 3410 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3411 userinfo->sn, args->mpmsg.numparts); |
4738 | 3412 |
10595 | 3413 if (args->mpmsg.numparts == 0) |
3414 return 1; | |
3415 | |
8708 | 3416 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3417 if (!bi) { |
3418 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3419 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3420 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3421 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3422 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3423 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3424 |
4738 | 3425 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3426 bi->typingnot = TRUE; | |
3427 else | |
3428 bi->typingnot = FALSE; | |
3429 | |
4380 | 3430 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3431 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3432 "%s has an icon\n", userinfo->sn); |
4738 | 3433 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3434 bi->ico_need = TRUE; | |
3435 bi->ico_len = args->iconlen; | |
3436 bi->ico_csum = args->iconsum; | |
3437 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3438 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3439 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3440 |
10458 | 3441 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3442 (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
|
3443 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3444 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3445 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3446 if (!g_stat(iconfile, &st)) { |
11159 | 3447 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3448 file = g_fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3449 if (file) { |
9532 | 3450 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3451 int len = fread(buf, 1, st.st_size, file); |
8660 | 3452 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3453 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3454 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3455 userinfo->sn, len, st.st_size); |
4617 | 3456 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3457 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3458 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3459 } else |
8660 | 3460 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3461 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3462 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3463 } else |
8660 | 3464 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3465 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3466 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3467 |
9806 | 3468 message = g_string_new(""); |
3469 curpart = args->mpmsg.parts; | |
3470 while (curpart != NULL) { | |
11159 | 3471 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, |
3472 curpart->charsubset, curpart->data, curpart->datalen); | |
9806 | 3473 if (tmp != NULL) { |
3474 g_string_append(message, tmp); | |
3475 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3476 } |
9806 | 3477 |
3478 curpart = curpart->next; | |
3479 } | |
3480 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3481 |
8666 | 3482 /* |
10781 | 3483 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
9016 | 3484 * because HTML is not sent over ICQ as a means to format a message. |
10781 | 3485 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
3486 * replaced with <br> | |
8995 | 3487 * |
3488 * Note: There *may* be some clients which send messages as HTML formatted - | |
3489 * they need to be special-cased somehow. | |
8666 | 3490 */ |
9982 | 3491 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3492 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
3493 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
8493 | 3494 g_free(tmp); |
3495 tmp = tmp2; | |
10783 | 3496 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
10781 | 3497 g_free(tmp); |
3498 tmp = tmp2; | |
8493 | 3499 } |
3500 | |
6982 | 3501 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3502 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3503 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3504 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3505 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3506 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3507 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3508 GaimConnection *gc; |
9933 | 3509 GaimAccount *account; |
9070 | 3510 OscarData *od; |
9933 | 3511 const char *username = NULL; |
3512 char *message = NULL; | |
9070 | 3513 |
3514 g_return_val_if_fail(sess != NULL, 0); | |
3515 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3516 | |
3517 gc = sess->aux_data; | |
9933 | 3518 account = gaim_connection_get_account(gc); |
9070 | 3519 od = gc->proto_data; |
9933 | 3520 username = gaim_account_get_username(account); |
3521 | |
3522 if (args == NULL) | |
4121 | 3523 return 0; |
4194 | 3524 |
9933 | 3525 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3526 userinfo->sn, args->status); | |
3527 | |
3528 if (args->msg != NULL) | |
3529 { | |
3530 if (args->encoding != NULL) | |
3531 { | |
3532 char *encoding = NULL; | |
3533 encoding = oscar_encoding_extract(args->encoding); | |
3534 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3535 g_free(encoding); | |
3536 } else { | |
3537 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3538 message = g_strdup(args->msg); | |
3539 } | |
3540 } | |
2869 | 3541 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3542 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3543 char *name; |
5234 | 3544 GHashTable *components; |
3545 | |
9933 | 3546 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3547 g_free(message); | |
4121 | 3548 return 1; |
9933 | 3549 } |
5234 | 3550 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3551 g_free); | |
4121 | 3552 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3553 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3554 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
|
3555 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3556 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3557 userinfo->sn, |
9933 | 3558 message, |
5234 | 3559 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3560 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3561 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3562 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3563 /* BBB */ |
3564 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3565 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3566 GaimXfer *xfer; |
5146 | 3567 struct aim_oft_info *oft_info; |
3568 | |
3569 if (!args->cookie || !args->port || !args->verifiedip || | |
3570 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3571 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3572 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3573 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3574 "information.\n", userinfo->sn); |
5146 | 3575 if (args->proxyip) |
8660 | 3576 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3577 "IP for a proxy server was given. Gaim " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3578 "does not support this yet.\n"); |
9933 | 3579 g_free(message); |
4617 | 3580 return 1; |
4656 | 3581 } |
4617 | 3582 |
3583 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3584 /* 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
|
3585 * directory -- remove the star and trailing slash so we don't save |
4617 | 3586 * directories that look like 'dirname\*' -- arl */ |
3587 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3588 if (tmp && (tmp[1] == '*')) { | |
3589 tmp[0] = '\0'; | |
3590 } | |
8660 | 3591 gaim_debug_warning("oscar", |
8446 | 3592 "We're receiving a whole directory! What fun! " |
3593 "Especially since we don't support that!\n"); | |
4617 | 3594 } |
3595 | |
3596 /* Build the file transfer handle */ | |
3597 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3598 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3599 xfer->remote_port = args->port; |
4617 | 3600 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3601 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
11084 | 3602 |
3603 /* Ignore <ICQ_COOL_FT> XML that is sent along with ICQ sendfile requests */ | |
3604 if(g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13)) { | |
3605 gaim_debug_info("oscar","Ignoring ICQ file transfer message: %s\n", message); | |
3606 g_free(message); | |
3607 message = NULL; | |
3608 } | |
9933 | 3609 gaim_xfer_set_message(xfer, message); |
5146 | 3610 |
3611 /* Create the oscar-specific data */ | |
5163 | 3612 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3613 if (args->proxyip) |
5146 | 3614 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3615 if (args->verifiedip) |
5146 | 3616 oft_info->verifiedip = g_strdup(args->verifiedip); |
3617 xfer->data = oft_info; | |
4617 | 3618 |
3619 /* Setup our I/O op functions */ | |
8446 | 3620 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3621 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3622 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
|
3623 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3624 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3625 |
3626 /* Keep track of this transfer for later */ | |
3627 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3628 | |
3629 /* Now perform the request */ | |
3630 gaim_xfer_request(xfer); | |
3631 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3632 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3633 GaimXfer *xfer; |
8660 | 3634 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3635 "AAA - File transfer canceled by remote user\n"); |
4617 | 3636 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
|
3637 gaim_xfer_cancel_remote(xfer); |
4617 | 3638 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3639 /* | |
3640 * This gets sent by the receiver of a file | |
3641 * as they connect directly to us. If we don't | |
3642 * get this, then maybe a third party connected | |
3643 * to us, and we shouldn't send them anything. | |
3644 */ | |
3645 } else { | |
8660 | 3646 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3647 "unknown rendezvous status!\n"); |
3630 | 3648 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3649 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3650 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3651 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3652 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3653 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3654 args->info.icon.length); |
6871 | 3655 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3656 /* 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
|
3657 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3658 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
|
3659 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3660 |
4212 | 3661 if (!args->verifiedip) { |
8983 | 3662 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3663 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3664 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3665 g_free(message); |
4650 | 3666 return 1; |
4212 | 3667 } |
3668 | |
8660 | 3669 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3670 "%s received direct im request from %s (%s)\n", |
10594 | 3671 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3672 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3673 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3674 d->sn = g_strdup(userinfo->sn); |
8983 | 3675 /* Let's use the clientip here, because I think that's what AIM does. |
3676 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3677 * and then ask them to connect to us. */ | |
10594 | 3678 /* |
3679 * I disagree, let's use the verifiedip. I think AIM tries the | |
3680 * verified IP first, then tries the client IP if that fails. In | |
3681 * any case, there's a better chance the verified IP will be correct. | |
3682 * The client IP is what the other person _thinks_ their IP address | |
3683 * is. The verified IP is the address that the AIM server sees the | |
3684 * other person using. | |
3685 */ | |
3686 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->verifiedip, args->port?args->port:5190); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3687 memcpy(d->cookie, args->cookie, 8); |
9070 | 3688 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3689 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3690 | |
8971 | 3691 oscar_direct_im_destroy(od, dim); |
8984 | 3692 d->donttryagain = TRUE; |
8971 | 3693 accept_direct_im_request(d); |
3694 } else { | |
8983 | 3695 if (dim && !dim->connected) |
8971 | 3696 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3697 "already connected to that buddy!"); | |
5575 | 3698 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
|
3699 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3700 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3701 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3702 "the two computers and is necessary for IM " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3703 "Images. Because your IP address will be " |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3704 "revealed, this may be considered a privacy " |
9972 | 3705 "risk."), |
3706 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3707 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3708 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3709 /* FIXME: we should actually send a packet on cancel */ | |
3710 } | |
8708 | 3711 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3712 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
|
3713 } else { |
8660 | 3714 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3715 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3716 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3717 |
9933 | 3718 g_free(message); |
3719 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3720 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3721 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3722 |
3453 | 3723 /* |
4230 | 3724 * Authorization Functions |
3725 * Most of these are callbacks from dialogs. They're used by both | |
3726 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3727 */ |
4269 | 3728 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3729 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3730 GaimConnection *gc = data->gc; |
4244 | 3731 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3732 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3733 OscarData *od = gc->proto_data; |
6695 | 3734 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3735 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3736 if (buddy && group) { |
8660 | 3737 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3738 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3739 buddy->name, group->name); |
4889 | 3740 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3741 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3742 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3743 } |
4230 | 3744 } |
4337 | 3745 } |
3746 | |
3747 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3748 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3749 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3750 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3751 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3752 data); |
4230 | 3753 } |
3754 | |
3755 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3756 GaimConnection *gc = data->gc; |
4244 | 3757 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3758 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3759 /* Remove from local list */ |
3760 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3761 gaim_blist_remove_buddy(b); | |
4244 | 3762 } |
3763 | |
5836 | 3764 oscar_free_name_data(data); |
4230 | 3765 } |
3766 | |
9030 | 3767 |
3768 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3769 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3770 GaimBuddy *buddy; |
4269 | 3771 gchar *dialog_msg, *nombre; |
3772 | |
4687 | 3773 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3774 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3775 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3776 else |
4830 | 3777 nombre = NULL; |
3778 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3779 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 | 3780 data->gc = gc; |
3781 data->name = g_strdup(name); | |
3782 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3783 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3784 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3785 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3786 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3787 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3788 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3789 |
3790 g_free(dialog_msg); | |
3791 g_free(nombre); | |
3792 } | |
3793 | |
9030 | 3794 |
3795 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3796 GaimBuddy *buddy; | |
3797 GaimConnection *gc; | |
3798 | |
3799 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3800 | |
3801 buddy = (GaimBuddy *) node; | |
3802 gc = gaim_account_get_connection(buddy->account); | |
3803 gaim_auth_sendrequest(gc, buddy->name); | |
3804 } | |
3805 | |
4230 | 3806 /* When other people ask you for authorization */ |
3807 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3808 GaimConnection *gc = data->gc; |
4244 | 3809 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3810 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3811 OscarData *od = gc->proto_data; |
4889 | 3812 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4244 | 3813 } |
3814 | |
5836 | 3815 oscar_free_name_data(data); |
3141 | 3816 } |
3817 | |
4230 | 3818 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3819 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3820 GaimConnection *gc = data->gc; |
4244 | 3821 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3822 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3823 OscarData *od = gc->proto_data; |
4889 | 3824 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4244 | 3825 } |
4337 | 3826 } |
3827 | |
3828 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3829 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3830 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3831 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3832 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3833 data); |
3141 | 3834 } |
3835 | |
7023 | 3836 /* When someone sends you buddies */ |
3837 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3838 GaimConnection *gc = data->gc; |
4244 | 3839 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3840 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3841 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3842 } |
3843 | |
5836 | 3844 oscar_free_name_data(data); |
3453 | 3845 } |
3846 | |
4075 | 3847 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 | 3848 GaimConnection *gc = sess->aux_data; |
9908 | 3849 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3850 gchar **msg1, **msg2; |
6051 | 3851 int i, numtoks; |
4076 | 3852 |
4121 | 3853 if (!args->type || !args->msg || !args->uin) |
3854 return 1; | |
4194 | 3855 |
8660 | 3856 gaim_debug_info("oscar", |
9908 | 3857 "Received a channel 4 message of type 0x%02hhx.\n", |
3858 args->type); | |
4076 | 3859 |
9919 | 3860 /* |
3861 * Split up the message at the delimeter character, then convert each | |
3862 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3863 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3864 * character in whatever encoding the message was sent in. Type 1 | |
3865 * messages are always made up of only one part, so we can easily account | |
3866 * for this suck-ass part of the protocol by splitting the string into at | |
3867 * most 1 baby string. | |
3868 */ | |
3869 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3870 for (numtoks=0; msg1[numtoks]; numtoks++); |
3871 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3872 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3873 gaim_str_strip_cr(msg1[i]); |
9908 | 3874 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3875 } |
3876 msg2[i] = NULL; | |
3877 | |
3952 | 3878 switch (args->type) { |
4173 | 3879 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3880 if (i >= 1) { |
5556 | 3881 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3882 gchar *tmp; |
3883 | |
3884 /* If the message came from an ICQ user then escape any HTML */ | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
3885 tmp = g_markup_escape_text(msg2[0], -1); |
8493 | 3886 |
4076 | 3887 if (t) { /* This is an offline message */ |
9680 | 3888 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3889 #ifdef HAVE_TM_GMTOFF |
9724 | 3890 time_t now; |
3891 struct tm *tm; | |
3892 now = time(NULL); | |
3893 tm = localtime(&now); | |
3894 t += tm->tm_gmtoff; | |
9698 | 3895 #else |
3896 # ifdef HAVE_TIMEZONE | |
9680 | 3897 tzset(); |
3898 t -= timezone; | |
9698 | 3899 # endif |
3900 #endif | |
8514 | 3901 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3902 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3903 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3904 } |
3905 g_free(uin); | |
8493 | 3906 g_free(tmp); |
4075 | 3907 } |
3316 | 3908 } break; |
3909 | |
4173 | 3910 case 0x04: { /* Someone sent you a URL */ |
4076 | 3911 if (i >= 2) { |
7385 | 3912 if (msg2[1] != NULL) { |
3913 gchar *uin = g_strdup_printf("%u", args->uin); | |
3914 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3915 msg2[1], | |
3916 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3917 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3918 g_free(uin); | |
3919 g_free(message); | |
3920 } | |
3453 | 3921 } |
3922 } break; | |
3923 | |
4173 | 3924 case 0x06: { /* Someone requested authorization */ |
4076 | 3925 if (i >= 6) { |
4230 | 3926 struct name_data *data = g_new(struct name_data, 1); |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3927 gchar *sn = g_strdup_printf("%u", args->uin); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3928 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3929 gchar *dialog_msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3930 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3931 if (msg2[5] != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3932 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5])); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3933 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3934 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3935 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3936 dialog_msg = g_strdup_printf( |
10949 | 3937 _("The user %u wants to add %s to their buddy list for the following reason:\n%s"), |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3938 args->uin, gaim_account_get_username(gc->account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3939 g_free(reason); |
8660 | 3940 gaim_debug_info("oscar", |
5556 | 3941 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3942 args->uin); |
4076 | 3943 data->gc = gc; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3944 data->name = sn; |
4230 | 3945 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3946 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3947 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3948 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3949 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3950 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3951 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3952 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3953 g_free(dialog_msg); |
3954 } | |
3141 | 3955 } break; |
3956 | |
4173 | 3957 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3958 if (i >= 1) { |
7023 | 3959 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
|
3960 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3961 dialog_msg); |
4076 | 3962 g_free(dialog_msg); |
3963 } | |
3141 | 3964 } break; |
3965 | |
4173 | 3966 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3967 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
|
3968 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3969 dialog_msg); |
3141 | 3970 g_free(dialog_msg); |
3971 } break; | |
3972 | |
4333 | 3973 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3974 if (i >= 5) { | |
3975 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
|
3976 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3977 g_free(dialog_msg); |
3978 } | |
3979 } break; | |
3980 | |
4173 | 3981 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3982 if (i >= 6) { |
4194 | 3983 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
|
3984 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3985 g_free(dialog_msg); |
3986 } | |
4075 | 3987 } break; |
3988 | |
4173 | 3989 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3990 if (i >= 6) { |
4308 | 3991 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
|
3992 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3993 g_free(dialog_msg); |
3994 } | |
4075 | 3995 } break; |
3996 | |
4173 | 3997 case 0x12: { |
3141 | 3998 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3999 /* Someone added you to their buddy list? */ |
3141 | 4000 } break; |
4001 | |
7023 | 4002 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 4003 guint i, num; |
3453 | 4004 gchar **text; |
4173 | 4005 text = g_strsplit(args->msg, "\376", 0); |
3453 | 4006 if (text) { |
4007 num = 0; | |
4008 for (i=0; i<strlen(text[0]); i++) | |
4009 num = num*10 + text[0][i]-48; | |
4010 for (i=0; i<num; i++) { | |
4230 | 4011 struct name_data *data = g_new(struct name_data, 1); |
7023 | 4012 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 | 4013 data->gc = gc; |
4790 | 4014 data->name = g_strdup(text[i*2+1]); |
4015 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4016 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4017 gaim_request_action(gc, NULL, message, |
7023 | 4018 _("Do you want to add this buddy " |
4019 "to your buddy list?"), | |
9972 | 4020 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 4021 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 4022 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 4023 g_free(message); |
4024 } | |
4025 g_strfreev(text); | |
4026 } | |
4027 } break; | |
4028 | |
7023 | 4029 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 4030 /* This is boring and silly. */ |
4031 } break; | |
4032 | |
3141 | 4033 default: { |
8660 | 4034 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4035 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4036 "(type 0x%02hhx).\n", args->type); |
3141 | 4037 } break; |
4038 } | |
4039 | |
4076 | 4040 g_strfreev(msg1); |
4041 g_strfreev(msg2); | |
4042 | |
3141 | 4043 return 1; |
4044 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4045 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4046 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 4047 fu16_t channel; |
4048 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4049 aim_userinfo_t *userinfo; |
2086 | 4050 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4051 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4052 va_start(ap, fr); |
4200 | 4053 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4054 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4055 |
3141 | 4056 switch (channel) { |
4057 case 1: { /* standard message */ | |
4058 struct aim_incomingim_ch1_args *args; | |
4059 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
4060 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
4061 } break; | |
4062 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
4063 case 2: { /* rendezvous */ |
3141 | 4064 struct aim_incomingim_ch2_args *args; |
4065 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
4066 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
4067 } break; | |
4068 | |
4069 case 4: { /* ICQ */ | |
4070 struct aim_incomingim_ch4_args *args; | |
4071 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 4072 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 4073 } break; |
4074 | |
4075 default: { | |
8660 | 4076 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4077 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4078 "0x%04hx).", channel); |
3141 | 4079 } break; |
2086 | 4080 } |
4081 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4082 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4083 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4084 return ret; |
2086 | 4085 } |
4086 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4087 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 4088 GaimConnection *gc = sess->aux_data; |
4089 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 4090 char *buf; |
2086 | 4091 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4092 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4093 aim_userinfo_t *userinfo; |
2086 | 4094 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4095 va_start(ap, fr); |
4200 | 4096 chan = (fu16_t)va_arg(ap, unsigned int); |
4097 userinfo = va_arg(ap, aim_userinfo_t *); | |
4098 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
4099 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 4100 va_end(ap); |
4101 | |
4102 switch(reason) { | |
5420 | 4103 case 0: /* Invalid (0) */ |
4104 buf = g_strdup_printf( | |
4105 ngettext( | |
4276 | 4106 "You missed %hu message from %s because it was invalid.", |
4107 "You missed %hu messages from %s because they were invalid.", | |
4108 nummissed), | |
4282 | 4109 nummissed, |
4110 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4111 break; |
5420 | 4112 case 1: /* Message too large */ |
4113 buf = g_strdup_printf( | |
4114 ngettext( | |
4276 | 4115 "You missed %hu message from %s because it was too large.", |
4116 "You missed %hu messages from %s because they were too large.", | |
4117 nummissed), | |
4282 | 4118 nummissed, |
4119 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4120 break; |
5420 | 4121 case 2: /* Rate exceeded */ |
4122 buf = g_strdup_printf( | |
4123 ngettext( | |
4276 | 4124 "You missed %hu message from %s because the rate limit has been exceeded.", |
4125 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
4126 nummissed), | |
4282 | 4127 nummissed, |
4128 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4129 break; |
5420 | 4130 case 3: /* Evil Sender */ |
4131 buf = g_strdup_printf( | |
4132 ngettext( | |
4276 | 4133 "You missed %hu message from %s because he/she was too evil.", |
4134 "You missed %hu messages from %s because he/she was too evil.", | |
4135 nummissed), | |
4282 | 4136 nummissed, |
4137 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4138 break; |
5420 | 4139 case 4: /* Evil Receiver */ |
4140 buf = g_strdup_printf( | |
4141 ngettext( | |
4276 | 4142 "You missed %hu message from %s because you are too evil.", |
4143 "You missed %hu messages from %s because you are too evil.", | |
4144 nummissed), | |
4282 | 4145 nummissed, |
4146 userinfo->sn); | |
2086 | 4147 break; |
4148 default: | |
5420 | 4149 buf = g_strdup_printf( |
4150 ngettext( | |
4276 | 4151 "You missed %hu message from %s for an unknown reason.", |
4152 "You missed %hu messages from %s for an unknown reason.", | |
4153 nummissed), | |
4282 | 4154 nummissed, |
4155 userinfo->sn); | |
2086 | 4156 break; |
4157 } | |
8733 | 4158 |
9627 | 4159 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4160 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4161 g_free(buf); |
2086 | 4162 |
4163 return 1; | |
4164 } | |
4165 | |
11159 | 4166 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const guchar *cookie) { |
5575 | 4167 GaimConnection *gc = sess->aux_data; |
7283 | 4168 OscarData *od = gc->proto_data; |
4617 | 4169 |
4170 /* BBB */ | |
3630 | 4171 switch (reason) { |
4151 | 4172 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4173 GaimXfer *xfer; |
8971 | 4174 struct oscar_direct_im *dim; |
4175 | |
8660 | 4176 gaim_debug_info("oscar", |
9070 | 4177 "AAA - Other user declined some sort of direct " |
8971 | 4178 "connect attempt (automaticly?)\n"); |
4617 | 4179 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
|
4180 gaim_xfer_cancel_remote(xfer); |
8971 | 4181 else if ((dim = oscar_direct_im_find(od, who))) { |
4182 /* AAA should use find by cookie or something here */ | |
4183 oscar_direct_im_disconnect(od, dim); | |
4184 } | |
4151 | 4185 } break; |
4186 | |
4187 default: { | |
8660 | 4188 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4189 "Received an unknown rendezvous client auto-response " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4190 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4191 } |
3630 | 4192 |
4193 } | |
4194 | |
4195 return 0; | |
4196 } | |
4197 | |
4194 | 4198 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4199 GaimConnection *gc = sess->aux_data; |
4151 | 4200 |
4201 switch(reason) { | |
4202 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4203 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4204 | |
4205 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4206 |
4207 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4208 statusmsg = oscar_icqstatus(state); |
4151 | 4209 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4210 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4211 g_free(statusmsg); | |
4151 | 4212 g_strfreev(splitmsg); |
9244 | 4213 |
9797 | 4214 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4215 |
4216 g_free(title); | |
4217 g_free(dialogmsg); | |
4151 | 4218 } break; |
4219 | |
4220 default: { | |
8660 | 4221 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4222 "Received an unknown client auto-response from %s. " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4223 "Type 0x%04hx\n", who, reason); |
4151 | 4224 } break; |
4225 } /* end of switch */ | |
4226 | |
4227 return 0; | |
4228 } | |
4229 | |
3212 | 4230 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4231 va_list ap; | |
4232 fu16_t chan, reason; | |
4233 char *who; | |
4234 | |
4235 va_start(ap, fr); | |
4200 | 4236 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4237 who = va_arg(ap, char *); |
4200 | 4238 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4239 |
3952 | 4240 if (chan == 0x0002) { /* File transfer declined */ |
11159 | 4241 guchar *cookie = va_arg(ap, guchar *); |
4151 | 4242 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4243 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4244 fu32_t state = 0; |
4151 | 4245 char *msg = NULL; |
4246 if (reason == 0x0003) { | |
4200 | 4247 state = va_arg(ap, fu32_t); |
4151 | 4248 msg = va_arg(ap, char *); |
4249 } | |
4250 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4251 } | |
3952 | 4252 |
3212 | 4253 va_end(ap); |
4254 | |
4255 return 1; | |
4256 } | |
4257 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4258 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4259 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4260 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4261 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4262 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4263 va_start(ap, fr); |
4199 | 4264 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4265 va_end(ap); |
4266 | |
8660 | 4267 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4268 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4269 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4270 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4271 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4272 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4273 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4274 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4275 |
2086 | 4276 return 1; |
4277 } | |
4278 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4279 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4280 GaimConnection *gc = sess->aux_data; |
4617 | 4281 #if 0 |
7283 | 4282 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4283 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4284 #endif |
4617 | 4285 va_list ap; |
4286 fu16_t reason; | |
4287 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4288 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4289 va_start(ap, fr); |
4617 | 4290 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4291 data = va_arg(ap, char *); |
2086 | 4292 va_end(ap); |
4293 | |
8660 | 4294 gaim_debug_error("oscar", |
10130 | 4295 "Message error with data %s and reason %hu\n", |
4296 (data != NULL ? data : ""), reason); | |
4617 | 4297 |
4298 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4299 #if 0 |
4617 | 4300 /* If this was a file transfer request, data is a cookie */ |
4301 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
|
4302 gaim_xfer_cancel_remote(xfer); |
3630 | 4303 return 1; |
4304 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4305 #endif |
3630 | 4306 |
4617 | 4307 /* Data is assumed to be the destination sn */ |
9826 | 4308 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4309 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4310 g_free(buf); | |
4311 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4312 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4313 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4314 } | |
4315 g_free(buf); | |
4316 | |
2086 | 4317 return 1; |
4318 } | |
4319 | |
3595 | 4320 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4321 GaimConnection *gc = sess->aux_data; |
3595 | 4322 va_list ap; |
4323 fu16_t type1, type2; | |
4324 char *sn; | |
4325 | |
4326 va_start(ap, fr); | |
4199 | 4327 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4328 sn = va_arg(ap, char *); |
4199 | 4329 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4330 va_end(ap); |
4331 | |
4332 switch (type2) { | |
4333 case 0x0000: { /* Text has been cleared */ | |
4334 serv_got_typing_stopped(gc, sn); | |
4335 } break; | |
4336 | |
4337 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4338 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4339 } break; |
4340 | |
4341 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4342 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4343 } break; |
4344 | |
4345 default: { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4346 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 | 4347 } break; |
4348 } | |
4349 | |
4350 return 1; | |
4351 } | |
4352 | |
7141 | 4353 /* |
4354 * We get this error when there was an error in the locate family. This | |
7259 | 4355 * happens when you request info of someone who is offline. |
7141 | 4356 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4357 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4358 gchar *buf; |
2086 | 4359 va_list ap; |
5420 | 4360 fu16_t reason; |
2086 | 4361 char *destn; |
4362 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4363 va_start(ap, fr); |
4199 | 4364 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4365 destn = va_arg(ap, char *); |
4366 va_end(ap); | |
4367 | |
7781 | 4368 if (destn == NULL) |
7793 | 4369 return 1; |
10560 | 4370 |
9826 | 4371 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4372 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4373 g_free(buf); | |
9627 | 4374 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4375 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4376 } | |
4377 g_free(buf); | |
2086 | 4378 |
4379 return 1; | |
4380 } | |
4381 | |
7011 | 4382 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4383 GaimConnection *gc = sess->aux_data; |
8700 | 4384 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 4385 OscarData *od = gc->proto_data; |
8700 | 4386 GString *str; |
9244 | 4387 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4388 va_list ap; |
7011 | 4389 aim_userinfo_t *userinfo; |
2086 | 4390 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4391 va_start(ap, fr); |
7011 | 4392 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4393 va_end(ap); |
4394 | |
8700 | 4395 str = g_string_new(""); |
4396 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4397 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4398 |
10116 | 4399 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 4400 time_t t = userinfo->onlinesince - od->timeoffset; |
10116 | 4401 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); |
4402 } | |
4403 | |
4404 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 4405 time_t t = userinfo->membersince - od->timeoffset; |
10116 | 4406 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); |
4407 } | |
7011 | 4408 |
4409 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4410 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4411 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4412 g_free(tmp); |
4413 } | |
4414 | |
8701 | 4415 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4416 |
4417 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4418 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4419 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4420 g_free(tmp); | |
7011 | 4421 if (away_utf8 != NULL) { |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4422 g_string_append_printf(str, "\n<hr>%s<br>", away_utf8); |
7011 | 4423 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4424 } |
7011 | 4425 } |
4426 | |
4427 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4428 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4429 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4430 g_free(tmp); | |
7011 | 4431 if (info_utf8 != NULL) { |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4432 g_string_append_printf(str, "\n<hr>%s<br>", info_utf8); |
7011 | 4433 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4434 } |
7011 | 4435 } |
4436 | |
8701 | 4437 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4438 g_string_free(str, TRUE); |
9244 | 4439 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4440 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4441 g_free(title); |
8700 | 4442 g_free(tmp); |
4151 | 4443 |
2086 | 4444 return 1; |
4445 } | |
4446 | |
8341 | 4447 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4448 { | |
4449 aim_session_t *sess = data; | |
4450 GaimConnection *gc = sess->aux_data; | |
4451 OscarData *od = (OscarData *)gc->proto_data; | |
4452 | |
4453 aim_locate_dorequest(data); | |
4454 od->getinfotimer = 0; | |
4455 | |
4456 return FALSE; | |
4457 } | |
4458 | |
4459 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4460 { | |
4461 GaimConnection *gc = sess->aux_data; | |
4462 OscarData *od = (OscarData *)gc->proto_data; | |
4463 | |
4464 /* | |
4465 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4466 * us from hitting the rate limit due to request away messages and info | |
4467 * too quickly. | |
4468 */ | |
4469 if (od->getinfotimer == 0) | |
10198 | 4470 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4471 |
4472 return 1; | |
4473 } | |
4474 | |
4475 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4476 { | |
2086 | 4477 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4478 fu16_t id; |
2086 | 4479 va_list ap; |
4480 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4481 va_start(ap, fr); |
4199 | 4482 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4483 msg = va_arg(ap, char *); |
4484 va_end(ap); | |
4485 | |
8660 | 4486 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4487 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4488 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4489 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4490 _("Your AIM connection may be lost."), NULL); |
2086 | 4491 |
4492 return 1; | |
4493 } | |
4494 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4495 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4496 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4497 fu16_t type; |
5575 | 4498 GaimConnection *gc = sess->aux_data; |
7283 | 4499 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4500 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4501 va_start(ap, fr); |
4199 | 4502 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4503 |
4504 switch(type) { | |
4505 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4506 fu8_t maxrooms; |
2086 | 4507 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4508 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4509 |
4199 | 4510 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4511 exchangecount = va_arg(ap, int); |
4512 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4513 | |
8660 | 4514 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4515 "chat info: Chat Rights:\n"); |
8660 | 4516 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4517 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4518 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4519 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4520 for (i = 0; i < exchangecount; i++) |
8660 | 4521 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4522 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4523 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4524 while (od->create_rooms) { |
4525 struct create_room *cr = od->create_rooms->data; | |
8660 | 4526 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4527 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4528 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4529 g_free(cr->name); |
4617 | 4530 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4531 g_free(cr); |
2086 | 4532 } |
4533 } | |
4534 break; | |
4535 case 0x0008: { | |
4536 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4537 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4538 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4539 fu32_t createtime; |
2086 | 4540 |
4541 fqcn = va_arg(ap, char *); | |
4200 | 4542 instance = (fu16_t)va_arg(ap, unsigned int); |
4543 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4544 flags = (fu16_t)va_arg(ap, unsigned int); | |
4545 createtime = va_arg(ap, fu32_t); | |
4546 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4547 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4548 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4549 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4550 name = va_arg(ap, char *); | |
4551 ck = va_arg(ap, char *); | |
4194 | 4552 |
8660 | 4553 gaim_debug_misc("oscar", |
5556 | 4554 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4555 fqcn, |
4556 exchange, instance, flags, | |
4557 createtime, | |
4558 maxmsglen, maxoccupancy, createperms, unknown, | |
4559 name, ck); | |
4617 | 4560 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4561 } |
4562 break; | |
4563 default: | |
8660 | 4564 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4565 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4566 break; |
4567 } | |
4194 | 4568 |
4569 va_end(ap); | |
4570 | |
2086 | 4571 return 1; |
4572 } | |
4573 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4574 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4575 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4576 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4577 aim_userinfo_t *info; |
5575 | 4578 GaimConnection *g = sess->aux_data; |
2086 | 4579 |
4580 struct chat_connection *c = NULL; | |
4581 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4582 va_start(ap, fr); |
2086 | 4583 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4584 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4585 va_end(ap); |
4586 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4587 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4588 if (!c) |
4589 return 1; | |
4590 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4591 for (i = 0; i < count; i++) |
9846 | 4592 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4593 |
4594 return 1; | |
4595 } | |
4596 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4597 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4598 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4599 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4600 aim_userinfo_t *info; |
5575 | 4601 GaimConnection *g = sess->aux_data; |
2086 | 4602 |
4603 struct chat_connection *c = NULL; | |
4604 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4605 va_start(ap, fr); |
2086 | 4606 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4607 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4608 va_end(ap); |
4609 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4610 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4611 if (!c) |
4612 return 1; | |
4613 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4614 for (i = 0; i < count; i++) |
8733 | 4615 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4616 |
4617 return 1; | |
4618 } | |
4619 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4620 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
|
4621 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4622 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4623 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4624 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4625 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4626 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4627 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4628 fu32_t creationtime; |
5575 | 4629 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4630 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
|
4631 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4632 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4633 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4634 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4635 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4636 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4637 roomdesc = va_arg(ap, char *); |
4200 | 4638 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4639 creationtime = va_arg(ap, fu32_t); | |
4640 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4641 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4642 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4643 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4644 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4645 |
8660 | 4646 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4647 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4648 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4649 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4650 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4651 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4652 |
2086 | 4653 return 1; |
4654 } | |
4655 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4656 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4657 GaimConnection *gc = sess->aux_data; |
8225 | 4658 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4659 gchar *utf8; | |
2086 | 4660 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4661 aim_userinfo_t *info; |
8225 | 4662 int len; |
2086 | 4663 char *msg; |
8219 | 4664 char *charset; |
2086 | 4665 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4666 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4667 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4668 len = va_arg(ap, int); |
4194 | 4669 msg = va_arg(ap, char *); |
8219 | 4670 charset = va_arg(ap, char *); |
4194 | 4671 va_end(ap); |
2086 | 4672 |
8225 | 4673 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4674 if (utf8 == NULL) |
4675 /* The conversion failed! */ | |
8668 | 4676 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4677 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4678 g_free(utf8); | |
2086 | 4679 |
4680 return 1; | |
4681 } | |
4682 | |
3694 | 4683 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4684 va_list ap; | |
5575 | 4685 GaimConnection *gc = sess->aux_data; |
3694 | 4686 struct aim_emailinfo *emailinfo; |
3725 | 4687 int havenewmail; |
7297 | 4688 char *alertitle, *alerturl; |
3694 | 4689 |
4690 va_start(ap, fr); | |
4691 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4692 havenewmail = va_arg(ap, int); |
7301 | 4693 alertitle = va_arg(ap, char *); |
4694 alerturl = va_arg(ap, char *); | |
3694 | 4695 va_end(ap); |
4696 | |
9661 | 4697 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4698 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4699 emailinfo->domain ? "@" : "", | |
4700 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4701 if (emailinfo->unread && havenewmail) |
4702 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4703 g_free(to); |
3694 | 4704 } |
10157 | 4705 |
7301 | 4706 if (alertitle) |
8660 | 4707 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4708 |
4709 return 1; | |
4710 } | |
4711 | |
4804 | 4712 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4713 GaimConnection *gc = sess->aux_data; |
7283 | 4714 OscarData *od = gc->proto_data; |
4804 | 4715 char *sn; |
4716 | |
4717 sn = od->requesticon->data; | |
8660 | 4718 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4719 "removing %s from hash table\n", sn); |
4804 | 4720 od->requesticon = g_slist_remove(od->requesticon, sn); |
4721 free(sn); | |
4722 | |
4723 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4724 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4725 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4726 |
4727 return 1; | |
4728 } | |
4729 | |
4730 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4731 GaimConnection *gc = sess->aux_data; |
7283 | 4732 OscarData *od = gc->proto_data; |
4804 | 4733 GSList *cur; |
4734 va_list ap; | |
4735 char *sn; | |
11024 | 4736 fu8_t iconcsumtype, *iconcsum, *icon; |
4853 | 4737 fu16_t iconcsumlen, iconlen; |
4804 | 4738 |
4739 va_start(ap, fr); | |
4740 sn = va_arg(ap, char *); | |
11024 | 4741 iconcsumtype = va_arg(ap, int); |
4853 | 4742 iconcsum = va_arg(ap, fu8_t *); |
4743 iconcsumlen = va_arg(ap, int); | |
4804 | 4744 icon = va_arg(ap, fu8_t *); |
4745 iconlen = va_arg(ap, int); | |
4746 va_end(ap); | |
4747 | |
11024 | 4748 /* |
4749 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
4750 * no icon is set. Ignore these. | |
4751 */ | |
4752 if ((iconlen > 0) && (iconlen != 90)) { | |
4853 | 4753 char *b16; |
6695 | 4754 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4755 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4756 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4757 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4758 if (b16) { |
7693 | 4759 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4760 g_free(b16); |
5129 | 4761 } |
4853 | 4762 } |
4804 | 4763 |
4764 cur = od->requesticon; | |
4765 while (cur) { | |
4766 char *cursn = cur->data; | |
4767 if (!aim_sncmp(cursn, sn)) { | |
4768 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4769 free(cursn); | |
4770 cur = od->requesticon; | |
4771 } else | |
4772 cur = cur->next; | |
4773 } | |
4774 | |
4775 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4776 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4777 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4778 |
4779 return 1; | |
4780 } | |
4781 | |
4782 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4783 GaimConnection *gc = data; |
7283 | 4784 OscarData *od = gc->proto_data; |
7011 | 4785 aim_userinfo_t *userinfo; |
4804 | 4786 aim_conn_t *conn; |
4787 | |
4788 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4789 if (!conn) { |
4790 if (!od->iconconnecting) { | |
4791 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4792 od->iconconnecting = TRUE; | |
4793 } | |
4804 | 4794 return FALSE; |
4795 } | |
4796 | |
5842 | 4797 if (od->set_icon) { |
6039 | 4798 struct stat st; |
4799 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4800 if (iconfile == NULL) { | |
8363 | 4801 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4802 } else if (!g_stat(iconfile, &st)) { |
11159 | 4803 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4804 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 4805 if (file) { |
9532 | 4806 /* XXX - Use g_file_get_contents()? */ |
6039 | 4807 fread(buf, 1, st.st_size, file); |
4808 fclose(file); | |
8660 | 4809 gaim_debug_info("oscar", |
6039 | 4810 "Uploading icon to icon server\n"); |
6879 | 4811 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4812 } else |
8660 | 4813 gaim_debug_error("oscar", |
6039 | 4814 "Can't open buddy icon file!\n"); |
4815 g_free(buf); | |
4816 } else { | |
8660 | 4817 gaim_debug_error("oscar", |
6039 | 4818 "Can't stat buddy icon file!\n"); |
5842 | 4819 } |
4820 od->set_icon = FALSE; | |
4821 } | |
4822 | |
4823 if (!od->requesticon) { | |
8660 | 4824 gaim_debug_misc("oscar", |
5842 | 4825 "no more icons to request\n"); |
4826 return FALSE; | |
4827 } | |
4828 | |
7045 | 4829 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4830 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
11024 | 4831 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
4804 | 4832 return FALSE; |
4833 } else { | |
4834 char *sn = od->requesticon->data; | |
4835 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4836 free(sn); | |
4837 } | |
4838 | |
4839 return TRUE; | |
4840 } | |
4841 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4842 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4843 * 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
|
4844 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4845 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4846 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4847 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4848 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4849 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4850 va_start(ap, fr); |
4199 | 4851 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4852 sn = va_arg(ap, char *); |
4853 va_end(ap); | |
4854 | |
8660 | 4855 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4856 |
4857 return 1; | |
4858 } | |
4859 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4860 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
|
4861 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4862 "invalid", |
4194 | 4863 "change", |
4864 "warning", | |
4865 "limit", | |
4866 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4867 }; |
2086 | 4868 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4869 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4870 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4871 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4872 va_start(ap, fr); |
4200 | 4873 code = (fu16_t)va_arg(ap, unsigned int); |
4874 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4875 windowsize = va_arg(ap, fu32_t); | |
4876 clear = va_arg(ap, fu32_t); | |
4877 alert = va_arg(ap, fu32_t); | |
4878 limit = va_arg(ap, fu32_t); | |
4879 disconnect = va_arg(ap, fu32_t); | |
4880 currentavg = va_arg(ap, fu32_t); | |
4881 maxavg = va_arg(ap, fu32_t); | |
2086 | 4882 va_end(ap); |
4883 | |
8660 | 4884 gaim_debug_misc("oscar", |
5556 | 4885 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4886 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4887 (code < 5) ? codes[code] : codes[0], |
4888 rateclass, | |
4889 currentavg, maxavg, | |
4890 alert, clear, | |
4891 limit, disconnect, | |
4892 windowsize); | |
4893 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4894 /* XXX fix these values */ |
2086 | 4895 if (code == AIM_RATE_CODE_CHANGE) { |
4896 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4897 aim_conn_setlatency(fr->conn, 0); |
2086 | 4898 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4899 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4900 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4901 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4902 _("The last action you attempted could not be " |
4903 "performed because you are over the rate limit. " | |
4904 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4905 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4906 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4907 aim_conn_setlatency(fr->conn, 0); |
2086 | 4908 } |
4909 | |
4910 return 1; | |
4911 } | |
4912 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4913 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4914 GaimConnection *gc = sess->aux_data; |
4915 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4916 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4917 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4918 aim_userinfo_t *userinfo; |
2086 | 4919 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4920 va_start(ap, fr); |
4199 | 4921 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4922 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4923 va_end(ap); |
4924 | |
9982 | 4925 /* XXX - What's with the + 0.5? */ |
4926 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4927 |
4928 return 1; | |
4929 } | |
4930 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4931 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4932 GaimConnection *gc = sess->aux_data; |
4933 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4934 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4935 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4936 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4937 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4938 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4939 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4940 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4941 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4942 |
9982 | 4943 warning_level = info->warnlevel/10.0 + 0.5; |
4944 | |
10152 | 4945 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4946 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4947 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4948 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4949 |
4649 | 4950 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4951 GaimConnection *gc = sess->aux_data; |
7283 | 4952 OscarData *od = gc->proto_data; |
4649 | 4953 va_list ap; |
4954 fu16_t code; | |
4955 char *msg; | |
4956 | |
4957 va_start(ap, fr); | |
4958 code = (fu16_t)va_arg(ap, int); | |
4959 msg = va_arg(ap, char *); | |
4960 va_end(ap); | |
4961 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4962 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
10458 | 4963 code, (msg != NULL ? msg : "")); |
4964 | |
4965 g_return_val_if_fail(fr != NULL, 1); | |
4966 g_return_val_if_fail(fr->conn != NULL, 1); | |
4967 | |
4968 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 4969 if (code == 0x0001) { |
6113 | 4970 gc->wants_to_die = TRUE; |
10715 | 4971 gaim_connection_error(gc, _("You have signed on from another location.")); |
4651 | 4972 } else { |
5579 | 4973 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4974 } |
4666 | 4975 od->killme = TRUE; |
10458 | 4976 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
4977 struct chat_connection *cc; | |
4978 GaimConversation *conv; | |
4979 | |
4980 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
4981 conv = gaim_find_chat(gc, cc->id); | |
4982 | |
4983 if (conv != NULL) | |
4984 { | |
4985 gchar *buf; | |
4986 buf = g_strdup_printf(_("You have been disconnected from chat " | |
4987 "room %s."), cc->name); | |
4988 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
4989 g_free(buf); | |
4990 } | |
4991 oscar_chat_kill(gc, cc); | |
4649 | 4992 } |
4993 | |
4994 return 1; | |
4995 } | |
4996 | |
2675 | 4997 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4998 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4999 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5000 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 5001 |
8660 | 5002 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 5003 aim_ssi_reqrights(sess); |
6350 | 5004 aim_ssi_reqdata(sess); |
4230 | 5005 |
7011 | 5006 aim_locate_reqrights(sess); |
7285 | 5007 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 5008 aim_im_reqparams(sess); |
7334 | 5009 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 5010 |
7283 | 5011 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
5012 | |
2086 | 5013 return 1; |
5014 } | |
5015 | |
2675 | 5016 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5017 GaimConnection *gc = sess->aux_data; |
7283 | 5018 OscarData *od = gc->proto_data; |
2647 | 5019 |
6905 | 5020 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
5021 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
5022 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
5023 | |
2672 | 5024 aim_clientready(sess, fr->conn); |
8660 | 5025 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5026 |
2647 | 5027 if (od->chpass) { |
8660 | 5028 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5029 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 5030 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5031 od->oldp = NULL; |
2647 | 5032 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5033 od->newp = NULL; |
2647 | 5034 od->chpass = FALSE; |
5035 } | |
2979 | 5036 if (od->setnick) { |
8660 | 5037 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 5038 aim_admin_setnick(sess, fr->conn, od->newsn); |
5039 g_free(od->newsn); | |
5040 od->newsn = NULL; | |
5041 od->setnick = FALSE; | |
5042 } | |
2647 | 5043 if (od->conf) { |
8660 | 5044 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5045 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 5046 od->conf = FALSE; |
5047 } | |
5048 if (od->reqemail) { | |
8660 | 5049 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5050 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 5051 od->reqemail = FALSE; |
5052 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5053 if (od->setemail) { |
8660 | 5054 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5055 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5056 g_free(od->email); |
5497 | 5057 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5058 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5059 } |
2647 | 5060 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5061 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5062 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5063 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5064 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
|
5065 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5066 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5067 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5068 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5069 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5070 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5071 |
4194 | 5072 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 5073 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 5074 "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
|
5075 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5076 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5077 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
5078 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5079 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5080 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 5081 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5082 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5083 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5084 |
4617 | 5085 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5086 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5087 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5088 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5089 |
2993 | 5090 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
5091 { | |
5575 | 5092 GaimConnection *gc = sess->aux_data; |
7283 | 5093 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 5094 va_list ap; |
5095 fu16_t maxsiglen; | |
2993 | 5096 |
5097 va_start(ap, fr); | |
4199 | 5098 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 5099 va_end(ap); |
5100 | |
8660 | 5101 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5102 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 5103 |
4617 | 5104 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
5105 | |
5106 if (od->icq) | |
7334 | 5107 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 5108 else |
7334 | 5109 aim_locate_setcaps(od->sess, caps_aim); |
5110 oscar_set_info(gc, gc->account->user_info); | |
2993 | 5111 |
5112 return 1; | |
5113 } | |
5114 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5115 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
|
5116 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5117 fu16_t maxbuddies, maxwatchers; |
5575 | 5118 GaimConnection *gc = sess->aux_data; |
7283 | 5119 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5120 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5121 va_start(ap, fr); |
4199 | 5122 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5123 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5124 va_end(ap); |
5125 | |
8660 | 5126 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5127 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5128 |
4617 | 5129 od->rights.maxbuddies = (guint)maxbuddies; |
5130 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5131 |
2086 | 5132 return 1; |
5133 } | |
5134 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5135 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5136 GaimConnection *gc = sess->aux_data; |
7283 | 5137 OscarData *od = (OscarData *)gc->proto_data; |
10570 | 5138 GaimAccount *account = gaim_connection_get_account(gc); |
7334 | 5139 va_list ap; |
5140 fu16_t maxpermits, maxdenies; | |
2086 | 5141 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5142 va_start(ap, fr); |
4199 | 5143 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5144 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5145 va_end(ap); |
5146 | |
8660 | 5147 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5148 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5149 |
4617 | 5150 od->rights.maxpermits = (guint)maxpermits; |
5151 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5152 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5153 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5154 |
8660 | 5155 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5156 |
2672 | 5157 aim_clientready(sess, fr->conn); |
5948 | 5158 aim_srv_setavailmsg(sess, NULL); |
7474 | 5159 aim_srv_setidle(sess, 0); |
4617 | 5160 |
4664 | 5161 if (od->icq) { |
5162 aim_icq_reqofflinemsgs(sess); | |
10570 | 5163 aim_icq_setsecurity(sess, |
5164 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
5165 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE), | |
5166 gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP)); | |
4664 | 5167 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5168 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5169 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5170 if (sess->authinfo->email) |
5171 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5172 |
5173 return 1; | |
5174 } | |
5175 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5176 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
|
5177 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5178 struct aim_icq_offlinemsg *msg; |
4075 | 5179 struct aim_incomingim_ch4_args args; |
5180 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5181 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5182 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5183 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5184 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5185 |
8660 | 5186 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5187 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5188 args.uin = msg->sender; |
5189 args.type = msg->type; | |
4173 | 5190 args.flags = msg->flags; |
4076 | 5191 args.msglen = msg->msglen; |
4075 | 5192 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5193 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5194 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5195 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5196 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5197 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5198 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5199 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
|
5200 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5201 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5202 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5203 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5204 |
7388 | 5205 #if 0 |
5206 /* | |
7465 | 5207 * Update, 2003-11-09: |
5208 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5209 * | |
7388 | 5210 * It may not be my place to do this, but... |
5211 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5212 * stupid, and should not exist for % switches (%x in our case) that request | |
5213 * a year in the preferred representation for the current locale. For that | |
5214 * reason I've chosen to not use this workaround (n., see kluge). | |
5215 * | |
5216 * I have a date. I want to show it to the user in the "preferred" way. | |
5217 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5218 * what the locale wanted. | |
5219 * | |
5220 * If I have a necessity for a full representation of the year in the current | |
5221 * locale, then I'll use a switch that returns a full representation of the | |
5222 * year. | |
5223 * | |
5224 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5225 * (because you're anal, or whatever), then change the f***ing locale. | |
5226 * | |
5227 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5228 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5229 * |
5230 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5231 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5232 */ |
5233 | |
5234 /* | |
5235 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5236 * "last 2 digits" warning. |
5237 */ | |
10157 | 5238 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5239 const struct tm *tm) |
5240 { | |
5241 return strftime(s, max, fmt, tm); | |
5242 } | |
10636 | 5243 |
5244 /* | |
5245 * Before even realizing this was here, I went and did the same thing in util.c. | |
5246 * | |
5247 * Use gaim_strftime() | |
5248 */ | |
5249 | |
7388 | 5250 #endif |
7386 | 5251 |
4624 | 5252 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
|
5253 { |
5575 | 5254 GaimConnection *gc = sess->aux_data; |
8670 | 5255 OscarData *od = (OscarData *)gc->proto_data; |
5256 GaimBuddy *buddy; | |
8853 | 5257 struct buddyinfo *bi = NULL; |
4624 | 5258 gchar who[16]; |
8670 | 5259 GString *str; |
5260 gchar *primary, *utf8; | |
9634 | 5261 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5262 va_list ap; |
4151 | 5263 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5264 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5265 va_start(ap, fr); |
4151 | 5266 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5267 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5268 |
4664 | 5269 if (!info->uin) |
5270 return 0; | |
5271 | |
8670 | 5272 str = g_string_sized_new(100); |
5556 | 5273 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5274 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5275 if (buddy != NULL) | |
5276 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5277 | |
5278 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5279 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5280 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5281 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5282 (bi->ipaddr & 0xff000000) >> 24, | |
5283 (bi->ipaddr & 0x00ff0000) >> 16, | |
5284 (bi->ipaddr & 0x0000ff00) >> 8, | |
5285 (bi->ipaddr & 0x000000ff)); | |
8701 | 5286 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5287 g_free(tstr); |
5288 } | |
8701 | 5289 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5290 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5291 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5292 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5293 g_free(utf8); | |
4625 | 5294 } |
5295 if (info->numaddresses && info->email2) { | |
5296 int i; | |
5297 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5298 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
10683 | 5299 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 5300 g_free(utf8); |
4643 | 5301 } |
4625 | 5302 } |
4624 | 5303 } |
8701 | 5304 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5305 if (info->gender != 0) |
5306 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5307 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5308 char date[30]; |
5309 struct tm tm; | |
5310 tm.tm_mday = (int)info->birthday; | |
5311 tm.tm_mon = (int)info->birthmonth-1; | |
5312 tm.tm_year = (int)info->birthyear-1900; | |
10636 | 5313 gaim_strftime(date, sizeof(date), "%x", &tm); |
8701 | 5314 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5315 } |
4624 | 5316 if (info->age) { |
5317 char age[5]; | |
5318 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5319 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5320 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5321 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5322 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5323 g_free(utf8); | |
4819 | 5324 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5325 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5326 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5327 g_free(utf8); | |
5328 } | |
10683 | 5329 g_string_append_printf(str, "<hr>"); |
4641 | 5330 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5331 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5332 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5333 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5334 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5335 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
10683 | 5336 g_string_append_printf(str, "\n<hr>"); |
4151 | 5337 } |
4641 | 5338 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5339 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5340 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5341 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5342 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5343 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
10683 | 5344 g_string_append_printf(str, "\n<hr>"); |
4624 | 5345 } |
4641 | 5346 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5347 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5348 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5349 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5350 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5351 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5352 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5353 g_free(utf8); | |
4624 | 5354 } |
10683 | 5355 g_string_append_printf(str, "\n<hr>"); |
8670 | 5356 } |
5357 | |
9634 | 5358 if (buddy != NULL) |
5359 alias = gaim_buddy_get_alias(buddy); | |
5360 else | |
5361 alias = who; | |
5362 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5363 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5364 g_free(primary); |
8670 | 5365 g_string_free(str, TRUE); |
4151 | 5366 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5367 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5368 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5369 |
4759 | 5370 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5371 { | |
5575 | 5372 GaimConnection *gc = sess->aux_data; |
4820 | 5373 gchar who[16], *utf8; |
6695 | 5374 GaimBuddy *b; |
4759 | 5375 va_list ap; |
5376 struct aim_icq_info *info; | |
5377 | |
5378 va_start(ap, fr); | |
5379 info = va_arg(ap, struct aim_icq_info *); | |
5380 va_end(ap); | |
5381 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5382 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5383 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5384 serv_got_alias(gc, who, utf8); |
4759 | 5385 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5386 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5387 } |
4820 | 5388 g_free(utf8); |
4759 | 5389 } |
5390 | |
5391 return 1; | |
5392 } | |
5393 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5394 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
|
5395 { |
7032 | 5396 GaimConnection *gc = sess->aux_data; |
5397 gchar *text; | |
5398 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5399 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5400 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5401 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5402 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5403 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5404 url = va_arg(ap, char *); |
4199 | 5405 wid = (fu16_t) va_arg(ap, int); |
5406 hei = (fu16_t) va_arg(ap, int); | |
5407 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5408 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5409 |
7032 | 5410 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5411 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5412 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5413 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5414 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5415 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5416 |
7032 | 5417 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5418 { | |
6873 | 5419 GaimConnection *gc = sess->aux_data; |
5420 gchar *secondary; | |
10439 | 5421 gchar **screennames; |
6873 | 5422 int i, num; |
2086 | 5423 va_list ap; |
6873 | 5424 char *email, *SNs; |
2086 | 5425 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5426 va_start(ap, fr); |
6873 | 5427 email = va_arg(ap, char *); |
2086 | 5428 num = va_arg(ap, int); |
5429 SNs = va_arg(ap, char *); | |
5430 va_end(ap); | |
5431 | |
10439 | 5432 /* TODO: Need to use ngettext() here */ |
8152 | 5433 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5434 |
5435 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5436 for (i = 0; i < num; i++) |
10439 | 5437 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5438 screennames[num] = NULL; | |
5439 | |
5440 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5441 (const char **)screennames, NULL, NULL); | |
6873 | 5442 |
5443 g_free(secondary); | |
10439 | 5444 g_strfreev(screennames); |
2086 | 5445 |
5446 return 1; | |
5447 } | |
5448 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5449 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5450 va_list ap; |
6873 | 5451 char *email; |
5420 | 5452 char *buf; |
2086 | 5453 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5454 va_start(ap, fr); |
6873 | 5455 email = va_arg(ap, char *); |
2086 | 5456 va_end(ap); |
5457 | |
6873 | 5458 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
|
5459 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5460 g_free(buf); |
2086 | 5461 |
5462 return 1; | |
5463 } | |
5464 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5465 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5466 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5467 fu16_t status; |
2086 | 5468 va_list ap; |
5469 char msg[256]; | |
5470 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5471 va_start(ap, fr); |
4199 | 5472 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5473 va_end(ap); |
5474 | |
8660 | 5475 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5476 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5477 status ? "unknown" : "email sent"); |
5478 if (!status) { | |
5302 | 5479 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5480 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5481 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5482 } |
5483 | |
5484 return 1; | |
5485 } | |
5486 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5487 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5488 GaimConnection *gc = sess->aux_data; |
2086 | 5489 va_list ap; |
3912 | 5490 fu16_t perms, err; |
5491 char *url, *sn, *email; | |
5492 int change; | |
2086 | 5493 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5494 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5495 change = va_arg(ap, int); |
4199 | 5496 perms = (fu16_t) va_arg(ap, unsigned int); |
5497 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5498 url = va_arg(ap, char *); |
5499 sn = va_arg(ap, char *); | |
5500 email = va_arg(ap, char *); | |
2086 | 5501 va_end(ap); |
5502 | |
8660 | 5503 gaim_debug_misc("oscar", |
9626 | 5504 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5505 change ? "change" : "request", perms, err, | |
5506 (url != NULL) ? url : "(null)", | |
5507 (sn != NULL) ? sn : "(null)", | |
5508 (email != NULL) ? email : "(null)"); | |
5509 | |
5510 if ((err > 0) && (url != NULL)) { | |
3912 | 5511 char *dialog_msg; |
5512 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5513 switch (err) { | |
5514 case 0x0001: { | |
5515 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5516 } break; | |
5517 case 0x0006: { | |
5518 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5519 } break; | |
5520 case 0x000b: { | |
5521 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5522 } break; | |
5523 case 0x001d: { | |
5524 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); | |
5525 } break; | |
5526 case 0x0021: { | |
5527 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); | |
5528 } break; | |
5529 case 0x0023: { | |
5530 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5531 } break; | |
5532 default: { | |
5533 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5534 } break; | |
5535 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5536 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5537 g_free(dialog_top); |
5538 g_free(dialog_msg); | |
5539 return 1; | |
5540 } | |
5541 | |
9626 | 5542 if (sn != NULL) { |
4585 | 5543 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
|
5544 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5545 g_free(dialog_msg); |
5546 } | |
5547 | |
9626 | 5548 if (email != NULL) { |
5575 | 5549 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5550 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5551 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5552 g_free(dialog_msg); |
2086 | 5553 } |
5554 | |
5555 return 1; | |
5556 } | |
5557 | |
5575 | 5558 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5559 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5560 aim_flap_nop(od->sess, od->conn); |
2086 | 5561 } |
5562 | |
6059 | 5563 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5564 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5565 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5566 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5567 if (typing == GAIM_TYPING) |
4870 | 5568 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5569 else if (typing == GAIM_TYPED) |
4870 | 5570 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5571 else | |
5572 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5573 else { |
5300 | 5574 /* Don't send if this turkey is in our deny list */ |
5575 GSList *list; | |
5576 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5577 if (!list) { | |
7261 | 5578 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5579 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5580 if (typing == GAIM_TYPING) |
5300 | 5581 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5582 else if (typing == GAIM_TYPED) |
5300 | 5583 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5584 else | |
5585 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5586 } | |
3595 | 5587 } |
5588 } | |
2993 | 5589 return 0; |
5590 } | |
9030 | 5591 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5592 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
|
5593 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5594 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5595 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5596 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5597 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
|
5598 int ret = 0; |
10246 | 5599 const char *iconfile = gaim_account_get_buddy_icon(account); |
10781 | 5600 char *tmpmsg = NULL; |
3458 | 5601 |
4838 | 5602 if (dim && dim->connected) { |
5603 /* If we're directly connected, send a direct IM */ | |
6982 | 5604 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5605 } else { |
4738 | 5606 struct buddyinfo *bi; |
3008 | 5607 struct aim_sendimext_args args; |
5608 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5609 gsize len; |
10246 | 5610 GaimConversation *conv; |
5611 | |
5612 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5613 |
5614 if (strstr(message, "<IMG ")) | |
5615 gaim_conversation_write(conv, "", | |
5616 _("Your IM Image was not sent. " | |
5617 "You must be Direct Connected to send IM Images."), | |
5618 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5619 |
10246 | 5620 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5621 if (!bi) { |
5622 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5623 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5624 } |
5625 | |
3008 | 5626 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5627 if (od->icq) { |
11172 | 5628 /* We have to present different "features" (whose meaning |
5629 is unclear and are merely a result of protocol inspection) | |
5630 to offline ICQ buddies. Otherwise, the official | |
5631 ICQ client doesn't treat those messages as being "ANSI- | |
5632 encoded" (and instead, assumes them to be UTF-8). | |
5633 For more details, see SF issue 1179452. | |
5634 */ | |
5635 GaimBuddy *buddy = gaim_find_buddy(gc->account, name); | |
5636 if (buddy && buddy->present != 0) { | |
5637 args.features = features_icq; | |
5638 args.featureslen = sizeof(features_icq); | |
5639 } else { | |
5640 args.features = features_icq_offline; | |
5641 args.featureslen = sizeof(features_icq_offline); | |
5642 } | |
3008 | 5643 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5644 } else { |
5645 args.features = features_aim; | |
5646 args.featureslen = sizeof(features_aim); | |
4972 | 5647 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5648 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5649 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5650 } |
4269 | 5651 |
4738 | 5652 if (bi->ico_need) { |
8660 | 5653 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5654 "Sending buddy icon request with message\n"); |
3008 | 5655 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5656 bi->ico_need = FALSE; |
3008 | 5657 } |
4269 | 5658 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5659 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5660 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 5661 if (file) { |
11159 | 5662 guchar *buf = g_malloc(st.st_size); |
9532 | 5663 /* XXX - Use g_file_get_contents()? */ |
3008 | 5664 fread(buf, 1, st.st_size, file); |
6039 | 5665 fclose(file); |
4269 | 5666 |
3008 | 5667 args.iconlen = st.st_size; |
4617 | 5668 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5669 args.iconstamp = st.st_mtime; |
5670 | |
7406 | 5671 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5672 bi->ico_informed = FALSE; |
7406 | 5673 bi->ico_sent = FALSE; |
5674 } | |
4738 | 5675 |
5676 if (!bi->ico_informed) { | |
8660 | 5677 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5678 "Claiming to have a buddy icon\n"); |
4738 | 5679 args.flags |= AIM_IMFLAGS_HASICON; |
5680 bi->ico_me_len = args.iconlen; | |
5681 bi->ico_me_csum = args.iconsum; | |
5682 bi->ico_me_time = args.iconstamp; | |
5683 bi->ico_informed = TRUE; | |
5684 } | |
5685 | |
3008 | 5686 g_free(buf); |
2086 | 5687 } |
5688 } | |
4269 | 5689 |
3008 | 5690 args.destsn = name; |
4269 | 5691 |
8985 | 5692 /* |
10781 | 5693 * If we're IMing an ICQ user from an ICQ account, then strip HTML |
5694 * and use \r\n as the newline character. | |
8985 | 5695 */ |
10781 | 5696 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
5697 if (aim_sn_is_icq(name)) | |
5698 /* From ICQ to ICQ */ | |
8995 | 5699 tmpmsg = g_strdup(message); |
10781 | 5700 else |
5701 /* From ICQ to AIM */ | |
5702 tmpmsg = g_markup_escape_text(message, -1); | |
8995 | 5703 } else { |
10785 | 5704 /* From AIM to AIM and AIM to ICQ */ |
5705 tmpmsg = g_strdup(message); | |
8995 | 5706 } |
6310 | 5707 len = strlen(tmpmsg); |
5708 | |
9830 | 5709 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5710 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5711 args.charset, args.charsubset, args.msglen); | |
4617 | 5712 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5713 g_free((char *)args.msg); |
2086 | 5714 } |
4838 | 5715 |
6310 | 5716 g_free(tmpmsg); |
5717 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5718 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5719 return 1; |
6310 | 5720 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5721 return ret; |
2086 | 5722 } |
5723 | |
7011 | 5724 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5725 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5726 |
9975 | 5727 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5728 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5729 else |
7235 | 5730 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5731 } |
5732 | |
8950 | 5733 #if 0 |
7011 | 5734 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5735 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5736 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5737 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5738 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5739 maiden, NULL, NULL, city, state, NULL, 0, web); |
5740 } | |
8950 | 5741 #endif |
2086 | 5742 |
5575 | 5743 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5744 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5745 aim_srv_setidle(od->sess, time); |
2086 | 5746 } |
5747 | |
5954 | 5748 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5749 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5750 int charset = 0; |
6019 | 5751 char *text_html = NULL; |
5129 | 5752 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5753 gsize msglen = 0; |
2993 | 5754 |
4617 | 5755 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5756 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5757 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5758 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5759 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5760 "again when you are fully connected.")); |
4617 | 5761 |
7334 | 5762 if (!text) { |
5763 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5764 return; | |
5765 } | |
10097 | 5766 |
7334 | 5767 text_html = gaim_strdup_withhtml(text); |
9807 | 5768 charset = oscar_charset_check(text_html); |
9826 | 5769 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5770 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5771 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5772 g_free(msg); | |
9826 | 5773 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5774 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5775 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5776 g_free(msg); | |
5777 } else { | |
5778 msglen = strlen(text_html); | |
5779 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5780 } | |
5781 | |
5782 if (msglen > od->rights.maxsiglen) { | |
5783 gchar *errstr; | |
5784 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5785 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5786 "The maximum profile length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5787 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5788 od->rights.maxsiglen), od->rights.maxsiglen); |
5789 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5790 g_free(errstr); | |
5791 } | |
5792 | |
5793 g_free(text_html); | |
2086 | 5794 } |
5795 | |
9991 | 5796 static void |
5797 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5798 { |
9991 | 5799 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5800 OscarData *od = NULL; |
9992 | 5801 GaimStatusType *status_type; |
9991 | 5802 GaimStatusPrimitive primitive; |
5803 GaimPresence *presence; | |
5804 const gchar *status_id; | |
9807 | 5805 int charset = 0; |
10196 | 5806 const gchar *text_html = NULL; |
5129 | 5807 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5808 gsize msglen = 0; |
2993 | 5809 |
9992 | 5810 status_type = gaim_status_get_type(status); |
5811 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5812 status_id = gaim_status_get_id(status); |
5813 presence = gaim_account_get_presence(account); | |
5814 | |
10400 | 5815 if (gc) |
5816 od = (OscarData *)gc->proto_data; | |
10401 | 5817 |
5818 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { | |
9991 | 5819 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5820 _("You have probably requested to set your " |
5821 "away message before the login procedure " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5822 "completed. You remain in a \"present\" " |
10400 | 5823 "state; try setting it again when you are " |
5824 "fully connected.")); | |
10401 | 5825 return; |
5826 } | |
5129 | 5827 |
9992 | 5828 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5829 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5830 | |
7334 | 5831 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5832 |
5833 text_html = gaim_status_get_attr_string(status, "message"); | |
5834 if (text_html != NULL) { | |
5835 aim_srv_setavailmsg(od->sess, text_html); | |
5836 } | |
10196 | 5837 |
5838 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5839 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5840 | |
10196 | 5841 text_html = gaim_status_get_attr_string(status, "message"); |
5842 | |
5843 if (text_html == NULL) { | |
5844 text_html = _("Away"); | |
5845 } | |
5846 | |
5847 charset = oscar_charset_check(text_html); | |
5848 if (charset == AIM_CHARSET_UNICODE) { | |
5849 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5850 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5851 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5852 g_free(msg); | |
5853 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5854 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5855 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5856 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5857 g_free(msg); | |
5858 } else { | |
5859 msglen = strlen(text_html); | |
5860 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5861 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5862 } | |
5863 | |
5864 if (msglen > od->rights.maxawaymsglen) { | |
5865 gchar *errstr; | |
5866 | |
5867 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5868 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5869 "The maximum away message length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5870 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5871 od->rights.maxawaymsglen), od->rights.maxawaymsglen); |
5872 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5873 g_free(errstr); | |
5874 } | |
5875 | |
10197 | 5876 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5877 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5878 | |
5129 | 5879 } else { |
10196 | 5880 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5881 | |
5882 } | |
2993 | 5883 } |
5884 | |
9991 | 5885 static void |
5886 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5887 { |
9991 | 5888 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 5889 OscarData *od = NULL; |
9991 | 5890 const gchar *status_id = gaim_status_get_id(status); |
5891 | |
10646 | 5892 if (gc) |
5893 od = (OscarData *)gc->proto_data; | |
5894 if (!od) | |
5895 return; | |
5896 | |
9991 | 5897 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) |
5575 | 5898 account->perm_deny = 4; |
8265 | 5899 else |
5575 | 5900 account->perm_deny = 3; |
9991 | 5901 |
8265 | 5902 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5903 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5904 |
9991 | 5905 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5906 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5907 |
5908 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5909 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5910 |
5911 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5912 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5913 |
5914 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5915 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5916 |
5917 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5918 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5919 |
5920 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5921 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5922 |
5923 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5924 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5925 |
5926 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5927 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5928 } |
5929 | |
9991 | 5930 static void |
5931 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5932 { |
10747 | 5933 gboolean connected = gaim_account_is_connected(account); |
10400 | 5934 GaimStatusType *type = gaim_status_get_type(status); |
5935 int primitive = gaim_status_type_get_primitive(type); | |
5936 | |
10747 | 5937 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
5938 | |
10498 | 5939 if (!gaim_status_is_active(status)) |
10485 | 5940 return; |
5941 | |
10753 | 5942 if (primitive != GAIM_STATUS_OFFLINE && !connected) { |
10738 | 5943 gaim_account_connect(account); |
10747 | 5944 } else if (primitive == GAIM_STATUS_OFFLINE && connected) { |
10400 | 5945 gaim_account_disconnect(account); |
5946 } else { | |
10747 | 5947 if (!connected) |
5948 return; | |
10400 | 5949 |
5950 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
5951 oscar_set_status_icq(account, status); | |
5952 else | |
10560 | 5953 /* QQQ - Should probably also set this for ICQ */ |
10400 | 5954 oscar_set_status_aim(account, status); |
5955 } | |
2086 | 5956 } |
5957 | |
9991 | 5958 static void |
5959 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5960 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5961 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5962 } |
5963 | |
10747 | 5964 static void |
5965 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5966 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5967 |
5968 if (!aim_snvalid(buddy->name)) { | |
8092 | 5969 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5970 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 | 5971 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5972 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5973 g_free(buf); |
8150 | 5974 |
5975 /* Remove from local list */ | |
9285 | 5976 gaim_blist_remove_buddy(buddy); |
8150 | 5977 |
8092 | 5978 return; |
5979 } | |
5980 | |
9285 | 5981 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5982 if (buddy && group) { | |
8660 | 5983 gaim_debug_info("oscar", |
9285 | 5984 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5985 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5986 } |
5987 } | |
8150 | 5988 |
10157 | 5989 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5990 if (od->icq) |
9285 | 5991 aim_icq_getalias(od->sess, buddy->name); |
5992 } | |
5993 | |
5994 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5995 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5996 |
4230 | 5997 if (od->sess->ssi.received_data) { |
8660 | 5998 gaim_debug_info("oscar", |
9285 | 5999 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
6000 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 6001 } |
10866 | 6002 } |
6003 | |
5575 | 6004 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 6005 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 6006 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 6007 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6008 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 6009 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 6010 } |
6011 } | |
6012 | |
5575 | 6013 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 6014 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 6015 if (od->sess->ssi.received_data) { |
6016 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
6017 if (gname) { | |
8660 | 6018 gaim_debug_info("oscar", |
9586 | 6019 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 6020 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 6021 } |
6022 } | |
6023 } | |
6024 | |
11005 | 6025 /* |
6026 * FYI, the OSCAR SSI code removes empty groups automatically. | |
6027 */ | |
9285 | 6028 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 6029 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6030 |
6031 if (od->sess->ssi.received_data) { | |
9285 | 6032 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
6033 GList *cur, *groups = NULL; | |
6034 | |
6035 /* Make a list of what the groups each buddy is in */ | |
6036 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
6037 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6038 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6039 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6040 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6041 node->parent->parent); |
9285 | 6042 } |
6043 | |
10866 | 6044 serv_remove_buddies(gc, moved_buddies, groups); |
6045 serv_add_buddies(gc, moved_buddies); | |
9285 | 6046 g_list_free(groups); |
8660 | 6047 gaim_debug_info("oscar", |
9285 | 6048 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 6049 } else { |
9285 | 6050 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 6051 gaim_debug_info("oscar", |
9285 | 6052 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 6053 } |
6054 } | |
6055 } | |
6056 | |
5968 | 6057 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
6058 aim_session_t *sess = data; | |
6350 | 6059 aim_ssi_reqdata(sess); |
5968 | 6060 return FALSE; |
6061 } | |
6062 | |
4642 | 6063 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6064 GaimConnection *gc = sess->aux_data; |
7283 | 6065 OscarData *od = gc->proto_data; |
4642 | 6066 va_list ap; |
6067 fu16_t reason; | |
6068 | |
6069 va_start(ap, fr); | |
6070 reason = (fu16_t)va_arg(ap, unsigned int); | |
6071 va_end(ap); | |
6072 | |
8660 | 6073 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 6074 |
6075 if (reason == 0x0005) { | |
5892 | 6076 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6077 _("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
|
6078 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 6079 } |
6080 | |
6081 /* Activate SSI */ | |
6082 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6083 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6084 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 6085 aim_ssi_enable(od->sess); |
6086 | |
6087 return 1; | |
6088 } | |
6089 | |
2991 | 6090 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6091 GaimConnection *gc = sess->aux_data; |
7283 | 6092 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 6093 int i; |
6094 va_list ap; | |
6095 int numtypes; | |
4230 | 6096 fu16_t *maxitems; |
2991 | 6097 |
6098 va_start(ap, fr); | |
4230 | 6099 numtypes = va_arg(ap, int); |
6100 maxitems = va_arg(ap, fu16_t *); | |
2991 | 6101 va_end(ap); |
6102 | |
8660 | 6103 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6104 |
4230 | 6105 for (i=0; i<numtypes; i++) |
8660 | 6106 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6107 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6108 |
8660 | 6109 gaim_debug_misc(NULL, "\n"); |
4230 | 6110 |
6111 if (numtypes >= 0) | |
6112 od->rights.maxbuddies = maxitems[0]; | |
6113 if (numtypes >= 1) | |
6114 od->rights.maxgroups = maxitems[1]; | |
6115 if (numtypes >= 2) | |
6116 od->rights.maxpermits = maxitems[2]; | |
6117 if (numtypes >= 3) | |
6118 od->rights.maxdenies = maxitems[3]; | |
2991 | 6119 |
6120 return 1; | |
6121 } | |
6122 | |
6123 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6124 GaimConnection *gc = sess->aux_data; |
6125 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6126 GaimStatus *status; |
7283 | 6127 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6128 GaimGroup *g; |
6129 GaimBuddy *b; | |
2995 | 6130 struct aim_ssi_item *curitem; |
2991 | 6131 int tmp; |
4230 | 6132 va_list ap; |
8219 | 6133 fu16_t fmtver, numitems; |
6134 struct aim_ssi_item *items; | |
6135 fu32_t timestamp; | |
4230 | 6136 |
6137 va_start(ap, fr); | |
6138 fmtver = (fu16_t)va_arg(ap, int); | |
6139 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6140 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6141 timestamp = va_arg(ap, fu32_t); |
8219 | 6142 va_end(ap); |
2991 | 6143 |
8660 | 6144 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6145 "ssi: syncing local list and server list\n"); |
2991 | 6146 |
8219 | 6147 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6148 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 | 6149 return 1; |
6150 } | |
6151 | |
2991 | 6152 /* Clean the buddy list */ |
4889 | 6153 aim_ssi_cleanlist(sess); |
2991 | 6154 |
8150 | 6155 { /* If not in server list then prune from local list */ |
6156 GaimBlistNode *gnode, *cnode, *bnode; | |
6157 GaimBuddyList *blist; | |
9539 | 6158 GSList *cur, *next; |
8150 | 6159 |
6160 /* Buddies */ | |
6161 cur = NULL; | |
6162 if ((blist = gaim_get_blist()) != NULL) { | |
6163 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6164 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6165 continue; | |
6166 g = (GaimGroup *)gnode; | |
6167 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6168 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6169 continue; | |
6170 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6171 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6172 continue; | |
6173 b = (GaimBuddy *)bnode; | |
6174 if (b->account == gc->account) { | |
6175 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6176 /* If the buddy is an ICQ user then load his nickname */ | |
6177 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6178 char *alias; |
8150 | 6179 if (servernick) |
6180 serv_got_alias(gc, b->name, servernick); | |
6181 | |
6182 /* Store local alias on server */ | |
8214 | 6183 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6184 if (!alias && b->alias && strlen(b->alias)) |
6185 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6186 free(alias); | |
6187 } else { | |
8660 | 6188 gaim_debug_info("oscar", |
8150 | 6189 "ssi: removing buddy %s from local list\n", b->name); |
6190 /* We can't actually remove now because it will screw up our looping */ | |
6191 cur = g_slist_prepend(cur, b); | |
6192 } | |
6193 } | |
6194 } | |
6195 } | |
6196 } | |
6197 } | |
8175 | 6198 |
8150 | 6199 while (cur != NULL) { |
6200 b = cur->data; | |
6201 cur = g_slist_remove(cur, b); | |
6202 gaim_blist_remove_buddy(b); | |
6203 } | |
6204 | |
6205 /* Permit list */ | |
6206 if (gc->account->permit) { | |
9539 | 6207 next = gc->account->permit; |
6208 while (next != NULL) { | |
6209 cur = next; | |
6210 next = next->next; | |
8150 | 6211 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6212 gaim_debug_info("oscar", |
8150 | 6213 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6214 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6215 } | |
9539 | 6216 } |
8150 | 6217 } |
6218 | |
6219 /* Deny list */ | |
6220 if (gc->account->deny) { | |
9539 | 6221 next = gc->account->deny; |
6222 while (next != NULL) { | |
6223 cur = next; | |
6224 next = next->next; | |
8150 | 6225 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6226 gaim_debug_info("oscar", |
8150 | 6227 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6228 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6229 } | |
9539 | 6230 } |
8150 | 6231 } |
6232 /* Presence settings (idle time visibility) */ | |
6233 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6234 if (!(tmp & 0x400)) | |
6235 aim_ssi_setpresence(sess, tmp | 0x400); | |
6236 } /* end pruning buddies from local list */ | |
6237 | |
2991 | 6238 /* Add from server list to local list */ |
4230 | 6239 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6240 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6241 switch (curitem->type) { |
4230 | 6242 case 0x0000: { /* Buddy */ |
4251 | 6243 if (curitem->name) { |
4292 | 6244 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6245 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6246 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6247 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6248 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6249 /* Should gname be freed here? -- elb */ |
4754 | 6250 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6251 free(alias); |
8150 | 6252 if (b) { |
4292 | 6253 /* Get server stored alias */ |
4705 | 6254 if (alias_utf8) { |
8150 | 6255 g_free(b->alias); |
6256 b->alias = g_strdup(alias_utf8); | |
4705 | 6257 } |
4282 | 6258 } else { |
8150 | 6259 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6260 |
4754 | 6261 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6262 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6263 gaim_blist_add_group(g, NULL); |
6264 } | |
5146 | 6265 |
8660 | 6266 gaim_debug_info("oscar", |
9285 | 6267 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6268 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6269 } |
8341 | 6270 if (!aim_sncmp(curitem->name, account->username)) { |
6271 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6272 gaim_check_comment(od, comment); | |
6273 free(comment); | |
6274 } | |
7162 | 6275 g_free(gname_utf8); |
6276 g_free(alias_utf8); | |
2991 | 6277 } |
4230 | 6278 } break; |
6279 | |
6280 case 0x0001: { /* Group */ | |
4282 | 6281 /* Shouldn't add empty groups */ |
4230 | 6282 } break; |
6283 | |
6284 case 0x0002: { /* Permit buddy */ | |
2991 | 6285 if (curitem->name) { |
4230 | 6286 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6287 GSList *list; |
5575 | 6288 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6289 if (!list) { |
8660 | 6290 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6291 "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
|
6292 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6293 } |
6294 } | |
4230 | 6295 } break; |
6296 | |
6297 case 0x0003: { /* Deny buddy */ | |
2991 | 6298 if (curitem->name) { |
6299 GSList *list; | |
5575 | 6300 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6301 if (!list) { |
8660 | 6302 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6303 "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
|
6304 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6305 } |
6306 } | |
4230 | 6307 } break; |
6308 | |
6309 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6310 if (curitem->data) { |
6311 fu8_t permdeny; | |
5575 | 6312 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6313 gaim_debug_info("oscar", |
5575 | 6314 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6315 account->perm_deny = permdeny; | |
6316 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6317 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6318 } |
2991 | 6319 } |
6320 } | |
4230 | 6321 } break; |
6322 | |
6323 case 0x0005: { /* Presence setting */ | |
3109 | 6324 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6325 } break; |
2991 | 6326 } /* End of switch on curitem->type */ |
6327 } /* End of for loop */ | |
4230 | 6328 |
9991 | 6329 /* |
6330 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6331 * this. We probably want the SSI status setting to override the local | |
6332 * setting. | |
6333 */ | |
9982 | 6334 status = gaim_presence_get_active_status(account->presence); |
6335 if (gaim_status_is_available(status)) | |
4901 | 6336 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6337 | |
4342 | 6338 /* Activate SSI */ |
6339 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6340 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6341 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6342 "ssi: activating server-stored buddy list\n"); |
4642 | 6343 aim_ssi_enable(sess); |
4342 | 6344 |
2991 | 6345 return 1; |
2086 | 6346 } |
4230 | 6347 |
6348 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6349 GaimConnection *gc = sess->aux_data; |
4230 | 6350 va_list ap; |
6351 struct aim_ssi_tmp *retval; | |
6352 | |
6353 va_start(ap, fr); | |
6354 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6355 va_end(ap); | |
6356 | |
6357 while (retval) { | |
8660 | 6358 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6359 "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 | 6360 |
6361 if (retval->ack != 0xffff) | |
6362 switch (retval->ack) { | |
6363 case 0x0000: { /* added successfully */ | |
6364 } break; | |
6365 | |
4829 | 6366 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6367 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6368 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 | 6369 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6370 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6371 g_free(buf); |
6372 } | |
6373 | |
7023 | 6374 case 0x000e: { /* buddy requires authorization */ |
4828 | 6375 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6376 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6377 } break; |
6378 | |
6379 default: { /* La la la */ | |
5197 | 6380 gchar *buf; |
8660 | 6381 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6382 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 | 6383 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6384 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6385 g_free(buf); |
4230 | 6386 } break; |
6387 } | |
6388 | |
6389 retval = retval->next; | |
6390 } | |
6391 | |
6392 return 1; | |
6393 } | |
6394 | |
8227 | 6395 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6396 GaimConnection *gc = sess->aux_data; | |
6397 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6398 GaimBuddy *b; | |
6399 GaimGroup *g; | |
6400 va_list ap; | |
6401 fu16_t type; | |
6402 const char *name; | |
6403 | |
6404 va_start(ap, fr); | |
6405 type = (fu16_t)va_arg(ap, int); | |
6406 name = va_arg(ap, char *); | |
6407 va_end(ap); | |
6408 | |
6409 if ((type != 0x0000) || (name == NULL)) | |
6410 return 1; | |
6411 | |
6412 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6413 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6414 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6415 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6416 b = gaim_find_buddy(gc->account, name); | |
6417 free(alias); | |
6418 | |
6419 if (b) { | |
6420 /* Get server stored alias */ | |
6421 if (alias_utf8) { | |
6422 g_free(b->alias); | |
6423 b->alias = g_strdup(alias_utf8); | |
6424 } | |
6425 } else { | |
6426 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6427 | |
6428 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6429 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6430 gaim_blist_add_group(g, NULL); | |
6431 } | |
6432 | |
8660 | 6433 gaim_debug_info("oscar", |
9285 | 6434 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6435 gaim_blist_add_buddy(b, NULL, g, NULL); |
6436 } | |
6437 g_free(gname_utf8); | |
6438 g_free(alias_utf8); | |
6439 | |
6440 return 1; | |
6441 } | |
6442 | |
4230 | 6443 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6444 GaimConnection *gc = sess->aux_data; |
4230 | 6445 va_list ap; |
6446 char *sn, *msg; | |
4236 | 6447 gchar *dialog_msg, *nombre; |
4230 | 6448 struct name_data *data; |
6695 | 6449 GaimBuddy *buddy; |
4230 | 6450 |
6451 va_start(ap, fr); | |
6452 sn = va_arg(ap, char *); | |
6453 msg = va_arg(ap, char *); | |
6454 va_end(ap); | |
6455 | |
8660 | 6456 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6457 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6458 |
4687 | 6459 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6460 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6461 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6462 else |
6463 nombre = g_strdup(sn); | |
6464 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6465 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 | 6466 data = g_new(struct name_data, 1); |
6467 data->gc = gc; | |
6468 data->name = g_strdup(sn); | |
6469 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6470 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6471 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6472 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6473 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6474 G_CALLBACK(oscar_free_name_data)); |
4236 | 6475 |
4230 | 6476 g_free(dialog_msg); |
4236 | 6477 g_free(nombre); |
4230 | 6478 |
6479 return 1; | |
6480 } | |
6481 | |
6482 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6483 GaimConnection *gc = sess->aux_data; |
4230 | 6484 va_list ap; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6485 char *sn; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6486 char *msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6487 GaimAccount *account = gaim_connection_get_account(gc); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6488 gchar *nombre; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6489 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6490 gchar *dialog_msg; |
4230 | 6491 struct name_data *data; |
6695 | 6492 GaimBuddy *buddy; |
4230 | 6493 |
6494 va_start(ap, fr); | |
6495 sn = va_arg(ap, char *); | |
6496 msg = va_arg(ap, char *); | |
6497 va_end(ap); | |
6498 | |
8660 | 6499 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6500 "ssi: received authorization request from %s\n", sn); |
4230 | 6501 |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6502 buddy = gaim_find_buddy(account, sn); |
9620 | 6503 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6504 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6505 else |
6506 nombre = g_strdup(sn); | |
6507 | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6508 if (msg != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6509 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg, strlen(msg)); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6510 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6511 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6512 |
10949 | 6513 dialog_msg = g_strdup_printf( |
6514 _("The user %s wants to add %s to their buddy list for the following reason:\n%s"), | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6515 nombre, gaim_account_get_username(account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6516 g_free(reason); |
10949 | 6517 |
4230 | 6518 data = g_new(struct name_data, 1); |
6519 data->gc = gc; | |
6520 data->name = g_strdup(sn); | |
6521 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6522 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6523 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6524 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6525 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6526 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6527 |
4230 | 6528 g_free(dialog_msg); |
4236 | 6529 g_free(nombre); |
4230 | 6530 |
6531 return 1; | |
6532 } | |
6533 | |
6534 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6535 GaimConnection *gc = sess->aux_data; |
4230 | 6536 va_list ap; |
6537 char *sn, *msg; | |
4236 | 6538 gchar *dialog_msg, *nombre; |
4230 | 6539 fu8_t reply; |
6695 | 6540 GaimBuddy *buddy; |
4230 | 6541 |
6542 va_start(ap, fr); | |
6543 sn = va_arg(ap, char *); | |
6544 reply = (fu8_t)va_arg(ap, int); | |
6545 msg = va_arg(ap, char *); | |
6546 va_end(ap); | |
6547 | |
8660 | 6548 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6549 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6550 |
4687 | 6551 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6552 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6553 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6554 else |
6555 nombre = g_strdup(sn); | |
6556 | |
4230 | 6557 if (reply) { |
6558 /* Granted */ | |
7023 | 6559 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
|
6560 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6561 } else { |
6562 /* Denied */ | |
7023 | 6563 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
|
6564 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6565 } |
6566 g_free(dialog_msg); | |
4236 | 6567 g_free(nombre); |
4230 | 6568 |
6569 return 1; | |
6570 } | |
6571 | |
6572 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6573 GaimConnection *gc = sess->aux_data; |
4230 | 6574 va_list ap; |
6575 char *sn; | |
6695 | 6576 GaimBuddy *buddy; |
4230 | 6577 |
6578 va_start(ap, fr); | |
6579 sn = va_arg(ap, char *); | |
6580 va_end(ap); | |
6581 | |
4687 | 6582 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6583 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6584 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6585 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6586 |
6587 return 1; | |
6588 } | |
2086 | 6589 |
5575 | 6590 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6591 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6592 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6593 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6594 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6595 pce->label = _("_Room:"); |
5234 | 6596 pce->identifier = "room"; |
10475 | 6597 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6598 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6599 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6600 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6601 pce->label = _("_Exchange:"); |
5234 | 6602 pce->identifier = "exchange"; |
10475 | 6603 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6604 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6605 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6606 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6607 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6608 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6609 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6610 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6611 |
9754 | 6612 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6613 { | |
6614 GHashTable *defaults; | |
6615 | |
6616 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6617 | |
6618 if (chat_name != NULL) | |
6619 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6620 | |
6621 return defaults; | |
6622 } | |
6623 | |
9917 | 6624 static char *oscar_get_chat_name(GHashTable *data) { |
6625 return g_strdup(g_hash_table_lookup(data, "room")); | |
6626 } | |
6627 | |
8308 | 6628 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6629 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6630 aim_conn_t *cur; |
5234 | 6631 char *name, *exchange; |
6632 | |
6633 name = g_hash_table_lookup(data, "room"); | |
6634 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6635 |
8660 | 6636 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6637 "Attempting to join chat room %s.\n", name); |
8308 | 6638 |
6639 if ((name == NULL) || (*name == '\0')) { | |
6640 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6641 return; | |
6642 } | |
6643 | |
4617 | 6644 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6645 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6646 "chatnav exists, creating room\n"); |
5234 | 6647 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6648 } else { |
6649 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6650 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6651 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6652 "chatnav does not exist, opening chatnav\n"); |
5234 | 6653 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6654 cr->name = g_strdup(name); |
4617 | 6655 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6656 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6657 } |
6658 } | |
6659 | |
8308 | 6660 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6661 OscarData *od = (OscarData *)gc->proto_data; | |
6662 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6663 |
6664 if (ccon == NULL) | |
2086 | 6665 return; |
10404 | 6666 |
8225 | 6667 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6668 ccon->exchange, ccon->name, 0x0); |
6669 } | |
6670 | |
10458 | 6671 static void |
6672 oscar_chat_leave(GaimConnection *gc, int id) | |
6673 { | |
6674 GaimConversation *conv; | |
6675 struct chat_connection *cc; | |
6676 | |
6677 conv = gaim_find_chat(gc, id); | |
6678 | |
6679 g_return_if_fail(conv != NULL); | |
6680 | |
6681 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6682 | |
6683 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6684 oscar_chat_kill(gc, cc); | |
2086 | 6685 } |
6686 | |
8219 | 6687 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6688 OscarData *od = (OscarData *)gc->proto_data; | |
6689 GaimConversation *conv = NULL; | |
2086 | 6690 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6691 char *buf, *buf2; |
9830 | 6692 fu16_t charset, charsubset; |
9807 | 6693 char *charsetstr = NULL; |
10111 | 6694 int len; |
8219 | 6695 |
6696 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6697 return -EINVAL; |
2086 | 6698 |
8219 | 6699 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6700 return -EINVAL; |
2086 | 6701 |
8219 | 6702 buf = gaim_strdup_withhtml(message); |
6703 len = strlen(buf); | |
6704 | |
8962 | 6705 if (strstr(buf, "<IMG ")) |
6706 gaim_conversation_write(conv, "", | |
6707 _("Your IM Image was not sent. " | |
6708 "You cannot send IM Images in AIM chats."), | |
6709 GAIM_MESSAGE_ERROR, time(NULL)); | |
6710 | |
9830 | 6711 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6712 if ((len > c->maxlen) || (len > c->maxvis)) { |
6713 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6714 return -E2BIG; |
8359 | 6715 } |
6716 | |
9831 | 6717 if (charset == AIM_CHARSET_ASCII) |
6718 charsetstr = "us-ascii"; | |
6719 else if (charset == AIM_CHARSET_UNICODE) | |
6720 charsetstr = "unicode-2-0"; | |
6721 else if (charset == AIM_CHARSET_CUSTOM) | |
6722 charsetstr = "iso-8859-1"; | |
9807 | 6723 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6724 g_free(buf2); |
8359 | 6725 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6726 return 0; |
2086 | 6727 } |
6728 | |
10042 | 6729 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6730 { | |
4766 | 6731 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6732 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6733 return "icq"; |
6734 else | |
6735 return "aim"; | |
6736 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6737 |
9975 | 6738 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6739 return "icq"; |
6740 return "aim"; | |
6741 } | |
6742 | |
9972 | 6743 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6744 { |
7334 | 6745 GaimConnection *gc = NULL; |
6746 OscarData *od = NULL; | |
10042 | 6747 GaimAccount *account = NULL; |
6748 GaimPresence *presence; | |
6749 GaimStatus *status; | |
6750 const char *status_id; | |
4687 | 6751 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6752 int i = 0; | |
7334 | 6753 aim_userinfo_t *userinfo = NULL; |
6754 | |
6755 if (b != NULL) | |
6756 account = b->account; | |
6757 if (account != NULL) | |
6758 gc = account->gc; | |
6759 if (gc != NULL) | |
6760 od = gc->proto_data; | |
7945 | 6761 if (od != NULL) |
6762 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6763 |
10042 | 6764 presence = gaim_buddy_get_presence(b); |
6765 status = gaim_presence_get_active_status(presence); | |
6766 status_id = gaim_status_get_id(status); | |
6767 | |
6768 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6769 char *gname; |
7334 | 6770 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6771 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6772 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6773 emblems[i++] = "notauthorized"; | |
6774 } else { | |
6775 emblems[i++] = "offline"; | |
6776 } | |
6777 } | |
4916 | 6778 |
10042 | 6779 if (b->name && aim_sn_is_icq(b->name)) { |
6780 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6781 emblems[i++] = "invisible"; | |
6782 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6783 emblems[i++] = "freeforchat"; |
10042 | 6784 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6785 emblems[i++] = "dnd"; |
10042 | 6786 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6787 emblems[i++] = "na"; |
10042 | 6788 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6789 emblems[i++] = "occupied"; |
10042 | 6790 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6791 emblems[i++] = "away"; |
10042 | 6792 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6793 emblems[i++] = "away"; | |
6794 } | |
6795 | |
6796 if (userinfo != NULL ) { | |
6797 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6798 emblems[i++] = "unconfirmed"; */ | |
6799 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6800 emblems[i++] = "admin"; | |
6801 if (userinfo->flags & AIM_FLAG_AOL) | |
6802 emblems[i++] = "aol"; | |
6803 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6804 emblems[i++] = "wireless"; | |
6805 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6806 emblems[i++] = "activebuddy"; | |
6807 | |
6808 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6809 emblems[i++] = "hiptop"; |
6810 | |
10042 | 6811 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6812 emblems[i++] = "secure"; |
10042 | 6813 } |
7334 | 6814 |
4687 | 6815 *se = emblems[0]; |
6816 *sw = emblems[1]; | |
6817 *nw = emblems[2]; | |
6818 *ne = emblems[3]; | |
6819 } | |
6820 | |
6695 | 6821 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6822 GaimConnection *gc = b->account->gc; |
7283 | 6823 OscarData *od = gc->proto_data; |
7045 | 6824 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6825 GString *str = g_string_new(""); |
5131 | 6826 |
6827 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6828 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6829 |
6830 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6831 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6832 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6833 g_free(charset); |
7011 | 6834 if (away_utf8 != NULL) { |
7091 | 6835 gchar *tmp1, *tmp2; |
9627 | 6836 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6837 g_free(away_utf8); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
6838 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 6839 g_free(tmp2); |
8700 | 6840 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6841 g_free(tmp1); |
8701 | 6842 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6843 g_free(tmp2); |
5836 | 6844 } |
5131 | 6845 } |
8701 | 6846 } |
6847 | |
6848 return g_string_free(str, FALSE); | |
5131 | 6849 } |
6850 | |
10042 | 6851 static char *oscar_status_text(GaimBuddy *b) |
6852 { | |
6853 GaimConnection *gc; | |
6854 OscarData *od; | |
6855 GaimStatus *status; | |
5167 | 6856 gchar *ret = NULL; |
6857 | |
10042 | 6858 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6859 od = gc->proto_data; | |
6860 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6861 | |
6862 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6863 if (aim_sn_is_icq(b->name)) |
8701 | 6864 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6865 else |
6866 ret = g_strdup(_("Away")); | |
5836 | 6867 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6868 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6869 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6870 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6871 } else { |
5167 | 6872 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6873 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6874 ret = g_strdup(_("Not Authorized")); | |
6875 else | |
6876 ret = g_strdup(_("Offline")); | |
6877 } | |
6878 | |
6879 return ret; | |
6880 } | |
6881 | |
5842 | 6882 |
5844 | 6883 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6884 GaimConnection *gc = sess->aux_data; |
7283 | 6885 OscarData *od = gc->proto_data; |
5892 | 6886 va_list ap; |
5842 | 6887 fu16_t type; |
5892 | 6888 fu8_t flags = 0, length = 0; |
11159 | 6889 guchar *md5 = NULL; |
5892 | 6890 |
7334 | 6891 |
5842 | 6892 va_start(ap, fr); |
6893 type = va_arg(ap, int); | |
5892 | 6894 |
6895 switch(type) { | |
6896 case 0x0000: | |
6897 case 0x0001: { | |
6898 flags = va_arg(ap, int); | |
6899 length = va_arg(ap, int); | |
11159 | 6900 md5 = va_arg(ap, guchar *); |
5892 | 6901 |
6902 if (flags == 0x41) { | |
6903 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6904 od->iconconnecting = TRUE; | |
6905 od->set_icon = TRUE; | |
6906 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6907 } else { | |
6039 | 6908 struct stat st; |
6909 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6910 if (iconfile == NULL) { | |
8363 | 6911 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6912 } else if (!g_stat(iconfile, &st)) { |
11159 | 6913 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6914 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 6915 if (file) { |
9532 | 6916 /* XXX - Use g_file_get_contents()? */ |
6039 | 6917 fread(buf, 1, st.st_size, file); |
6918 fclose(file); | |
8660 | 6919 gaim_debug_info("oscar", |
10042 | 6920 "Uploading icon to icon server\n"); |
6879 | 6921 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6922 } else |
8660 | 6923 gaim_debug_error("oscar", |
10042 | 6924 "Can't open buddy icon file!\n"); |
6039 | 6925 g_free(buf); |
6926 } else { | |
8660 | 6927 gaim_debug_error("oscar", |
10042 | 6928 "Can't stat buddy icon file!\n"); |
5892 | 6929 } |
6930 } | |
8363 | 6931 } else if (flags == 0x81) { |
6932 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6933 if (iconfile == NULL) | |
6934 aim_ssi_delicon(od->sess); | |
6935 else | |
6936 aim_ssi_seticon(od->sess, md5, length); | |
6937 } | |
5892 | 6938 } break; |
6939 | |
6940 case 0x0002: { /* We just set an "available" message? */ | |
6941 } break; | |
6942 } | |
6943 | |
5842 | 6944 va_end(ap); |
5844 | 6945 |
6946 return 0; | |
5842 | 6947 } |
5892 | 6948 |
5575 | 6949 static void oscar_set_permit_deny(GaimConnection *gc) { |
6950 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6951 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 6952 |
8175 | 6953 if (od->sess->ssi.received_data) { |
6954 switch (account->perm_deny) { | |
6955 case GAIM_PRIVACY_ALLOW_ALL: | |
6956 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6957 break; | |
6958 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6959 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6960 break; | |
6961 case GAIM_PRIVACY_ALLOW_USERS: | |
6962 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6963 break; | |
6964 case GAIM_PRIVACY_DENY_ALL: | |
6965 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6966 break; | |
6967 case GAIM_PRIVACY_DENY_USERS: | |
6968 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6969 break; | |
6970 default: | |
6971 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6972 break; | |
6973 } | |
6974 } | |
2086 | 6975 } |
6976 | |
5575 | 6977 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 6978 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6979 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6980 if (od->sess->ssi.received_data) |
4889 | 6981 aim_ssi_addpermit(od->sess, who); |
2086 | 6982 } |
6983 | |
5575 | 6984 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 6985 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6986 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6987 if (od->sess->ssi.received_data) |
4889 | 6988 aim_ssi_adddeny(od->sess, who); |
2086 | 6989 } |
6990 | |
5575 | 6991 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 6992 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6993 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6994 if (od->sess->ssi.received_data) |
4889 | 6995 aim_ssi_delpermit(od->sess, who); |
2086 | 6996 } |
6997 | |
5575 | 6998 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 6999 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7000 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 7001 if (od->sess->ssi.received_data) |
4889 | 7002 aim_ssi_deldeny(od->sess, who); |
2086 | 7003 } |
7004 | |
9975 | 7005 static GList * |
7006 oscar_status_types(GaimAccount *account) | |
2086 | 7007 { |
9975 | 7008 GList *status_types = NULL; |
7009 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
7010 |
9973 | 7011 g_return_val_if_fail(account != NULL, NULL); |
7012 | |
10042 | 7013 /* Oscar-common status types */ |
9991 | 7014 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
7015 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 7016 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 7017 status_types = g_list_append(status_types, type); |
7018 | |
9991 | 7019 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
7020 OSCAR_STATUS_ID_ONLINE, | |
10400 | 7021 _("Online"), FALSE, TRUE, FALSE); |
9976 | 7022 status_types = g_list_append(status_types, type); |
7023 | |
10198 | 7024 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
7025 OSCAR_STATUS_ID_AVAILABLE, | |
7026 _("Available"), TRUE, TRUE, FALSE, | |
7027 "message", _("Message"), | |
7028 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 7029 status_types = g_list_append(status_types, type); |
7030 | |
10195 | 7031 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
7032 OSCAR_STATUS_ID_AWAY, | |
7033 _("Away"), TRUE, TRUE, FALSE, | |
7034 "message", _("Message"), | |
7035 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 7036 status_types = g_list_append(status_types, type); |
7037 | |
7038 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
7039 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 7040 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 7041 status_types = g_list_append(status_types, type); |
7042 | |
7043 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
7044 return status_types; | |
7045 | |
7046 /* ICQ-specific status types */ | |
7047 | |
9991 | 7048 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
7049 OSCAR_STATUS_ID_FREE4CHAT, | |
7050 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 7051 status_types = g_list_append(status_types, type); |
7052 | |
9991 | 7053 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
7054 OSCAR_STATUS_ID_OCCUPIED, | |
7055 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 7056 status_types = g_list_append(status_types, type); |
7057 | |
9991 | 7058 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7059 OSCAR_STATUS_ID_DND, | |
7060 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 7061 status_types = g_list_append(status_types, type); |
7062 | |
9991 | 7063 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7064 OSCAR_STATUS_ID_NA, | |
7065 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 7066 status_types = g_list_append(status_types, type); |
9975 | 7067 |
7068 return status_types; | |
4333 | 7069 } |
7070 | |
7172 | 7071 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 7072 GaimConnection *gc = data->gc; |
7073 OscarData *od = gc->proto_data; | |
7172 | 7074 GaimBuddy *b; |
7075 GaimGroup *g; | |
7076 | |
7077 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
7078 oscar_free_name_data(data); | |
7079 return; | |
7080 } | |
7081 | |
7082 if (!(g = gaim_find_buddys_group(b))) { | |
7083 oscar_free_name_data(data); | |
7084 return; | |
7085 } | |
7086 | |
7087 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 7088 |
7089 if (!aim_sncmp(data->name, gc->account->username)) | |
7090 gaim_check_comment(od, text); | |
7091 | |
7172 | 7092 oscar_free_name_data(data); |
7093 } | |
7094 | |
9030 | 7095 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
7096 | |
7097 GaimBuddy *buddy; | |
7098 GaimConnection *gc; | |
7099 OscarData *od; | |
7100 struct name_data *data; | |
7172 | 7101 GaimGroup *g; |
7102 char *comment; | |
7103 gchar *comment_utf8; | |
9631 | 7104 gchar *title; |
7172 | 7105 |
9030 | 7106 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
7107 | |
7108 buddy = (GaimBuddy *) node; | |
7109 gc = gaim_account_get_connection(buddy->account); | |
7110 od = gc->proto_data; | |
7111 | |
7112 data = g_new(struct name_data, 1); | |
7113 | |
7114 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 7115 return; |
9030 | 7116 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 7117 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
7118 | |
7119 data->gc = gc; | |
9030 | 7120 data->name = g_strdup(buddy->name); |
7172 | 7121 data->nick = NULL; |
7122 | |
9631 | 7123 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7124 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7125 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7126 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7127 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7128 data); | |
9631 | 7129 g_free(title); |
7172 | 7130 |
7131 free(comment); | |
7132 g_free(comment_utf8); | |
7133 } | |
7134 | |
9030 | 7135 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7136 | |
7137 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7138 OscarData *od = gc->proto_data; |
9030 | 7139 |
4333 | 7140 GList *m = NULL; |
9030 | 7141 GaimBlistNodeAction *act; |
7142 | |
7143 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7144 oscar_buddycb_edit_comment, NULL, NULL); |
9030 | 7145 m = g_list_append(m, act); |
7172 | 7146 |
4333 | 7147 if (od->icq) { |
4624 | 7148 #if 0 |
9030 | 7149 act = gaim_blist_node_action_new(_("Get Status Msg"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7150 oscar_get_icqstatusmsg, NULL, NULL); |
9030 | 7151 m = g_list_append(m, act); |
4624 | 7152 #endif |
4333 | 7153 } else { |
7011 | 7154 aim_userinfo_t *userinfo; |
9030 | 7155 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7156 | |
7157 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7158 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7159 | |
7011 | 7160 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7161 act = gaim_blist_node_action_new(_("Direct IM"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7162 oscar_ask_direct_im, NULL, NULL); |
9030 | 7163 m = g_list_append(m, act); |
5917 | 7164 } |
9466 | 7165 #if 0 |
7011 | 7166 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7167 act = gaim_blist_node_action_new(_("Get File"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7168 oscar_ask_getfile, NULL, NULL); |
9030 | 7169 m = g_list_append(m, act); |
5917 | 7170 } |
4826 | 7171 #endif |
4333 | 7172 } |
5131 | 7173 } |
5197 | 7174 |
5131 | 7175 if (od->sess->ssi.received_data) { |
9030 | 7176 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7177 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7178 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7179 gaim_auth_sendrequest_menu, NULL, NULL); |
9030 | 7180 m = g_list_append(m, act); |
4333 | 7181 } |
4916 | 7182 } |
10157 | 7183 |
4333 | 7184 return m; |
7185 } | |
7186 | |
9030 | 7187 |
7188 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7189 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7190 return oscar_buddy_menu((GaimBuddy *) node); | |
7191 } else { | |
7192 return NULL; | |
7193 } | |
7194 } | |
7195 | |
10570 | 7196 static void |
7197 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
7198 { | |
7199 OscarData *od = gc->proto_data; | |
7200 GaimAccount *account = gaim_connection_get_account(gc); | |
7201 GaimRequestField *f; | |
7202 gboolean auth, hide_ip, web_aware; | |
7203 | |
7204 f = gaim_request_fields_get_field(fields, "authorization"); | |
7205 auth = gaim_request_field_bool_get_value(f); | |
7206 | |
7207 f = gaim_request_fields_get_field(fields, "hide_ip"); | |
7208 hide_ip = gaim_request_field_bool_get_value(f); | |
7209 | |
7210 f = gaim_request_fields_get_field(fields, "web_aware"); | |
7211 web_aware = gaim_request_field_bool_get_value(f); | |
7212 | |
7213 gaim_account_set_bool(account, "authorization", auth); | |
7214 gaim_account_set_bool(account, "hide_ip", hide_ip); | |
7215 gaim_account_set_bool(account, "web_aware", web_aware); | |
7216 | |
7217 aim_icq_setsecurity(od->sess, auth, web_aware, hide_ip); | |
7218 } | |
7219 | |
7220 static void | |
7221 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
7222 { | |
7223 GaimConnection *gc = (GaimConnection *) action->context; | |
7224 GaimAccount *account = gaim_connection_get_account(gc); | |
7225 GaimRequestFields *fields; | |
7226 GaimRequestFieldGroup *g; | |
7227 GaimRequestField *f; | |
7228 gboolean auth, hide_ip, web_aware; | |
7229 | |
7230 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7231 hide_ip = gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7232 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7233 | |
7234 fields = gaim_request_fields_new(); | |
7235 | |
7236 g = gaim_request_field_group_new(NULL); | |
7237 | |
7238 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
7239 gaim_request_field_group_add_field(g, f); | |
7240 | |
7241 f = gaim_request_field_bool_new("hide_ip", _("Hide IP address"), hide_ip); | |
7242 gaim_request_field_group_add_field(g, f); | |
7243 | |
7244 f = gaim_request_field_bool_new("web_aware", _("Web aware"), web_aware); | |
7245 gaim_request_field_group_add_field(g, f); | |
7246 | |
7247 gaim_request_fields_add_group(fields, g); | |
7248 | |
7249 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
7250 NULL, fields, | |
7251 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
7252 _("Cancel"), NULL, gc); | |
7253 } | |
9030 | 7254 |
5575 | 7255 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7256 OscarData *od = gc->proto_data; |
5575 | 7257 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7258 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7259 od->setnick = TRUE; | |
7260 od->newsn = g_strdup(nick); | |
7261 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7262 } else { | |
7263 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7264 } | |
7265 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7266 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7267 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7268 } |
7269 } | |
7270 | |
9015 | 7271 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7272 { |
9015 | 7273 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7274 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7275 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7276 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7277 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7278 gc); |
4333 | 7279 } |
7280 | |
9015 | 7281 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7282 { |
9015 | 7283 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7284 OscarData *od = gc->proto_data; |
4333 | 7285 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7286 | |
7287 if (conn) { | |
7288 aim_admin_reqconfirm(od->sess, conn); | |
7289 } else { | |
7290 od->conf = TRUE; | |
7291 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7292 } | |
7293 } | |
7294 | |
9015 | 7295 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7296 { |
9015 | 7297 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7298 OscarData *od = gc->proto_data; |
4333 | 7299 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7300 | |
7301 if (conn) { | |
7302 aim_admin_getinfo(od->sess, conn, 0x11); | |
7303 } else { | |
7304 od->reqemail = TRUE; | |
7305 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7306 } | |
7307 } | |
7308 | |
5575 | 7309 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7310 { |
7283 | 7311 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7312 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
|
7313 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7314 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7315 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7316 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7317 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7318 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7319 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7320 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7321 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7322 |
9015 | 7323 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7324 { |
9015 | 7325 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7326 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7327 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7328 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7329 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7330 gc); |
4333 | 7331 } |
7332 | |
9015 | 7333 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7334 { |
9015 | 7335 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7336 OscarData *od = gc->proto_data; |
4333 | 7337 gchar *nombre, *text, *tmp; |
6695 | 7338 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7339 int num=0; |
7340 | |
6873 | 7341 text = g_strdup(""); |
4333 | 7342 |
4785 | 7343 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7344 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7345 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7346 continue; | |
6695 | 7347 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7348 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7349 continue; |
6695 | 7350 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7351 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7352 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7353 continue; | |
7354 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7355 if (gaim_buddy_get_alias_only(buddy)) |
7356 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7357 else |
7358 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7359 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7360 g_free(text); |
7361 text = tmp; | |
7362 g_free(nombre); | |
7363 num++; | |
7364 } | |
4333 | 7365 } |
2979 | 7366 } |
4333 | 7367 } |
7368 | |
7369 if (!num) { | |
7370 g_free(text); | |
6873 | 7371 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7372 } | |
7373 | |
7374 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7375 "the following buddies"), _("You can re-request " | |
7376 "authorization from these buddies by " | |
7377 "right-clicking on them and selecting " | |
7378 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7379 g_free(text); |
2979 | 7380 } |
7381 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7382 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7383 { |
8950 | 7384 OscarData *od = (OscarData *)gc->proto_data; |
7385 | |
7386 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7387 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7388 |
9015 | 7389 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7390 { |
9015 | 7391 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7392 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7393 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7394 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7395 "searching for."), |
8697 | 7396 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7397 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7398 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7399 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7400 |
9015 | 7401 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7402 { |
9015 | 7403 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7404 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7405 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7406 |
9015 | 7407 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7408 { |
9015 | 7409 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7410 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7411 } |
7412 | |
9015 | 7413 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7414 { |
9015 | 7415 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7416 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7417 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7418 |
9015 | 7419 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7420 { |
9015 | 7421 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7422 OscarData *od = gc->proto_data; |
5575 | 7423 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
|
7424 gaim_notify_uri(gc, substituted); |
5517 | 7425 g_free(substituted); |
4333 | 7426 } |
7427 | |
9015 | 7428 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7429 { |
9015 | 7430 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7431 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7432 } |
7433 | |
5842 | 7434 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7435 { | |
7283 | 7436 OscarData *od = gc->proto_data; |
5844 | 7437 aim_session_t *sess = od->sess; |
5842 | 7438 FILE *file; |
7439 struct stat st; | |
5844 | 7440 |
6039 | 7441 if (iconfile == NULL) { |
8363 | 7442 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7443 } else if (!g_stat(iconfile, &st)) { |
11159 | 7444 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7445 file = g_fopen(iconfile, "rb"); |
5842 | 7446 if (file) { |
6052 | 7447 md5_state_t *state; |
11159 | 7448 guchar md5[16]; |
9532 | 7449 /* XXX - Use g_file_get_contents()? */ |
5842 | 7450 int len = fread(buf, 1, st.st_size, file); |
6039 | 7451 fclose(file); |
6052 | 7452 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7453 md5_init(state); |
7454 md5_append(state, buf, len); | |
7455 md5_finish(state, md5); | |
7456 g_free(state); | |
7457 aim_ssi_seticon(sess, md5, 16); | |
7458 } else | |
8660 | 7459 gaim_debug_error("oscar", |
5842 | 7460 "Can't open buddy icon file!\n"); |
7461 g_free(buf); | |
7462 } else | |
8660 | 7463 gaim_debug_error("oscar", |
5842 | 7464 "Can't stat buddy icon file!\n"); |
7465 } | |
7466 | |
7467 | |
9015 | 7468 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7469 { |
9015 | 7470 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7471 OscarData *od = gc->proto_data; |
4333 | 7472 GList *m = NULL; |
9015 | 7473 GaimPluginAction *act; |
7474 | |
7475 act = gaim_plugin_action_new(_("Set User Info..."), | |
7476 oscar_show_set_info); | |
7477 m = g_list_append(m, act); | |
4333 | 7478 |
10570 | 7479 if (od->icq) |
7480 { | |
9015 | 7481 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7482 oscar_show_set_info_icqurl); | |
7483 m = g_list_append(m, act); | |
8576 | 7484 } |
7485 | |
9015 | 7486 act = gaim_plugin_action_new(_("Change Password..."), |
7487 oscar_change_pass); | |
7488 m = g_list_append(m, act); | |
4617 | 7489 |
10570 | 7490 if (od->sess->authinfo->chpassurl != NULL) |
7491 { | |
9015 | 7492 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7493 oscar_show_chpassurl); | |
7494 m = g_list_append(m, act); | |
7495 | |
7496 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7497 oscar_show_imforwardingurl); | |
7498 m = g_list_append(m, act); | |
7026 | 7499 } |
7500 | |
10570 | 7501 m = g_list_append(m, NULL); |
7502 | |
7503 if (od->icq) | |
7504 { | |
7505 /* ICQ actions */ | |
7506 act = gaim_plugin_action_new(_("Show privacy options..."), | |
7507 oscar_show_icq_privacy_opts); | |
7508 m = g_list_append(m, act); | |
7509 } | |
7510 else | |
7511 { | |
4617 | 7512 /* AIM actions */ |
9015 | 7513 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7514 oscar_show_format_screenname); | |
7515 m = g_list_append(m, act); | |
7516 | |
7517 act = gaim_plugin_action_new(_("Confirm Account"), | |
7518 oscar_confirm_account); | |
7519 m = g_list_append(m, act); | |
7520 | |
7521 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7522 oscar_show_email); | |
7523 m = g_list_append(m, act); | |
7524 | |
7525 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7526 oscar_show_change_email); | |
7527 m = g_list_append(m, act); | |
2086 | 7528 } |
4333 | 7529 |
7530 m = g_list_append(m, NULL); | |
7531 | |
9015 | 7532 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7533 oscar_show_awaitingauth); | |
7534 m = g_list_append(m, act); | |
4333 | 7535 |
2086 | 7536 m = g_list_append(m, NULL); |
4333 | 7537 |
9015 | 7538 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7539 oscar_show_find_email); | |
7540 m = g_list_append(m, act); | |
4333 | 7541 |
8591 | 7542 #if 0 |
9015 | 7543 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7544 show_find_info); | |
7545 m = g_list_append(m, act); | |
8591 | 7546 #endif |
2086 | 7547 |
7548 return m; | |
7549 } | |
7550 | |
5575 | 7551 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7552 { |
7283 | 7553 OscarData *od = gc->proto_data; |
4617 | 7554 |
7555 if (od->icq) { | |
7556 aim_icq_changepasswd(od->sess, new); | |
2086 | 7557 } else { |
4617 | 7558 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7559 if (conn) { | |
7560 aim_admin_changepasswd(od->sess, conn, new, old); | |
7561 } else { | |
7562 od->chpass = TRUE; | |
7563 od->oldp = g_strdup(old); | |
7564 od->newp = g_strdup(new); | |
7565 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7566 } | |
2086 | 7567 } |
7568 } | |
7569 | |
6059 | 7570 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7571 { |
7283 | 7572 OscarData *od = gc->proto_data; |
8971 | 7573 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
|
7574 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7575 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7576 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7577 |
8971 | 7578 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7579 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7580 |
9935 | 7581 static void |
7582 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7583 { | |
7584 GaimConnection *gc = data; | |
7585 OscarData *od = gc->proto_data; | |
7586 aim_session_t *sess = od->sess; | |
7587 fu32_t presence; | |
7588 | |
7589 presence = aim_ssi_getpresence(sess->ssi.local); | |
7590 | |
7591 if (value) { | |
9992 | 7592 /* Based on the packet capture I thought it was the first one */ |
7593 /* Stu thinks it's the second one. */ | |
7594 /* presence |= 0x00400000; */ | |
9971 | 7595 presence &= ~0x00020000; |
9935 | 7596 aim_ssi_setpresence(sess, presence); |
7597 } else { | |
9992 | 7598 /* presence &= ~0x00400000; */ |
9971 | 7599 presence |= 0x00020000; |
9935 | 7600 aim_ssi_setpresence(sess, presence); |
7601 } | |
7602 } | |
7603 | |
10653 | 7604 #if USE_PRPL_PREFERENCES |
9935 | 7605 static GaimPluginPrefFrame * |
9936 | 7606 get_plugin_pref_frame(GaimPlugin *plugin) |
7607 { | |
9935 | 7608 GaimPluginPrefFrame *frame; |
7609 GaimPluginPref *ppref; | |
7610 | |
7611 frame = gaim_plugin_pref_frame_new(); | |
7612 | |
7613 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7614 gaim_plugin_pref_frame_add(frame, ppref); | |
7615 | |
7616 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7617 gaim_plugin_pref_frame_add(frame, ppref); | |
7618 | |
7619 return frame; | |
7620 } | |
10653 | 7621 #endif |
9935 | 7622 |
11153 | 7623 static const char * |
7624 oscar_normalize(const GaimAccount *account, const char *str) | |
7625 { | |
7626 static char buf[BUF_LEN]; | |
7627 char *tmp1, *tmp2; | |
7628 int i, j; | |
7629 | |
7630 g_return_val_if_fail(str != NULL, NULL); | |
7631 | |
7632 strncpy(buf, str, BUF_LEN); | |
7633 for (i=0, j=0; buf[j]; i++, j++) | |
7634 { | |
7635 while (buf[j] == ' ') | |
7636 j++; | |
7637 buf[i] = buf[j]; | |
7638 } | |
7639 buf[i] = '\0'; | |
7640 | |
7641 tmp1 = g_utf8_strdown(buf, -1); | |
7642 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
7643 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
7644 g_free(tmp2); | |
7645 g_free(tmp1); | |
7646 | |
7647 return buf; | |
7648 } | |
7649 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7650 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7651 { |
9308 | 7652 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7653 NULL, /* user_splits */ |
7654 NULL, /* protocol_options */ | |
10674 | 7655 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
7656 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 7657 oscar_list_icon, /* list_icon */ |
7658 oscar_list_emblems, /* list_emblems */ | |
7659 oscar_status_text, /* status_text */ | |
7660 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7661 oscar_status_types, /* status_types */ |
9475 | 7662 oscar_blist_node_menu, /* blist_node_menu */ |
7663 oscar_chat_info, /* chat_info */ | |
9754 | 7664 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7665 oscar_login, /* login */ |
7666 oscar_close, /* close */ | |
7667 oscar_send_im, /* send_im */ | |
7668 oscar_set_info, /* set_info */ | |
7669 oscar_send_typing, /* send_typing */ | |
7670 oscar_get_info, /* get_info */ | |
9973 | 7671 oscar_set_status, /* set_status */ |
9475 | 7672 oscar_set_idle, /* set_idle */ |
7673 oscar_change_passwd, /* change_passwd */ | |
7674 oscar_add_buddy, /* add_buddy */ | |
10866 | 7675 NULL, /* add_buddies */ |
9475 | 7676 oscar_remove_buddy, /* remove_buddy */ |
10866 | 7677 NULL, /* remove_buddies */ |
9475 | 7678 oscar_add_permit, /* add_permit */ |
7679 oscar_add_deny, /* add_deny */ | |
7680 oscar_rem_permit, /* rem_permit */ | |
7681 oscar_rem_deny, /* rem_deny */ | |
7682 oscar_set_permit_deny, /* set_permit_deny */ | |
7683 oscar_warn, /* warn */ | |
7684 oscar_join_chat, /* join_chat */ | |
7685 NULL, /* reject_chat */ | |
9973 | 7686 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7687 oscar_chat_invite, /* chat_invite */ |
7688 oscar_chat_leave, /* chat_leave */ | |
7689 NULL, /* chat_whisper */ | |
7690 oscar_send_chat, /* chat_send */ | |
7691 oscar_keepalive, /* keepalive */ | |
7692 NULL, /* register_user */ | |
7693 NULL, /* get_cb_info */ | |
7694 NULL, /* get_cb_away */ | |
7695 oscar_alias_buddy, /* alias_buddy */ | |
7696 oscar_move_buddy, /* group_buddy */ | |
7697 oscar_rename_group, /* rename_group */ | |
7698 NULL, /* buddy_free */ | |
7699 oscar_convo_closed, /* convo_closed */ | |
11153 | 7700 oscar_normalize, /* normalize */ |
9475 | 7701 oscar_set_icon, /* set_buddy_icon */ |
7702 NULL, /* remove_group */ | |
7703 NULL, /* get_cb_real_name */ | |
7704 NULL, /* set_chat_topic */ | |
7705 NULL, /* find_blist_chat */ | |
7706 NULL, /* roomlist_get_list */ | |
7707 NULL, /* roomlist_cancel */ | |
7708 NULL, /* roomlist_expand_category */ | |
7709 oscar_can_receive_file, /* can_receive_file */ | |
7710 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7711 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7712 |
10653 | 7713 #if USE_PRPL_PREFERENCES |
9935 | 7714 static GaimPluginUiInfo prefs_info = { |
7715 get_plugin_pref_frame | |
7716 }; | |
10653 | 7717 #endif |
9935 | 7718 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7719 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7720 { |
9943 | 7721 GAIM_PLUGIN_MAGIC, |
7722 GAIM_MAJOR_VERSION, | |
7723 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7724 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7725 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7726 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7727 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7728 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7729 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7730 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7731 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7732 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7733 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7734 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7735 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7736 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7737 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7738 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7739 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7740 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7741 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7742 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7743 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7744 NULL, /**< ui_info */ |
8993 | 7745 &prpl_info, /**< extra_info */ |
10653 | 7746 #if USE_PRPL_PREFERENCES |
10487 | 7747 NULL, /**< prefs_info */ |
10653 | 7748 #else |
7749 NULL, /**< prefs_info */ | |
7750 #endif | |
9015 | 7751 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7752 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7753 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7754 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7755 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7756 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7757 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7758 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7759 gaim_debug_register_category("oscar"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7760 |
9830 | 7761 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7762 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7763 | |
7764 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7765 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7766 | |
7767 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7768 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
11084 | 7769 |
9935 | 7770 gaim_prefs_add_none("/plugins/prpl/oscar"); |
7771 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7772 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7773 } |
7774 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7775 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |