Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 11253:7d31d61e6438
[gaim-migrate @ 13422]
Get rid of faimdprintf and use gaim_debug functions instead
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 13 Aug 2005 06:43:45 +0000 |
parents | ad9a61894d9b |
children | bb0d7b719af2 |
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 | |
7376 | 72 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
73 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 74 |
4665 | 75 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
76 static fu8_t features_icq[] = {0x01, 0x06}; | |
11172 | 77 static fu8_t features_icq_offline[] = {0x01}; |
8341 | 78 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 79 |
7283 | 80 typedef struct _OscarData OscarData; |
81 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
82 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
83 aim_conn_t *conn; |
2086 | 84 |
85 guint cnpa; | |
86 guint paspa; | |
3694 | 87 guint emlpa; |
4804 | 88 guint icopa; |
2086 | 89 |
4823 | 90 gboolean iconconnecting; |
5842 | 91 gboolean set_icon; |
4823 | 92 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
93 GSList *create_rooms; |
2086 | 94 |
95 gboolean conf; | |
96 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
97 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
98 char *email; |
2979 | 99 gboolean setnick; |
100 char *newsn; | |
2086 | 101 gboolean chpass; |
102 char *oldp; | |
103 char *newp; | |
9971 | 104 |
2086 | 105 GSList *oscar_chats; |
106 GSList *direct_ims; | |
3630 | 107 GSList *file_transfers; |
4738 | 108 GHashTable *buddyinfo; |
4804 | 109 GSList *requesticon; |
2086 | 110 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
111 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
112 gboolean icq; |
4804 | 113 guint icontimer; |
5968 | 114 guint getblisttimer; |
8341 | 115 guint getinfotimer; |
10567 | 116 gint timeoffset; |
2993 | 117 |
118 struct { | |
4230 | 119 guint maxwatchers; /* max users who can watch you */ |
2993 | 120 guint maxbuddies; /* max users you can watch */ |
4230 | 121 guint maxgroups; /* max groups in server list */ |
2993 | 122 guint maxpermits; /* max users on permit list */ |
123 guint maxdenies; /* max users on deny list */ | |
124 guint maxsiglen; /* max size (bytes) of profile */ | |
125 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
126 } rights; | |
2086 | 127 }; |
128 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
129 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
130 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
133 |
2086 | 134 struct chat_connection { |
135 char *name; | |
136 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
137 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
138 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
139 aim_conn_t *conn; |
2086 | 140 int inpa; |
141 int id; | |
5575 | 142 GaimConnection *gc; /* i hate this. */ |
8733 | 143 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
144 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
145 int maxvis; |
2086 | 146 }; |
147 | |
8971 | 148 struct oscar_direct_im { |
5575 | 149 GaimConnection *gc; |
2086 | 150 char name[80]; |
151 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
152 aim_conn_t *conn; |
3008 | 153 gboolean connected; |
8978 | 154 gboolean gpc_pend; |
155 gboolean killme; | |
8984 | 156 gboolean donttryagain; |
2086 | 157 }; |
158 | |
159 struct ask_direct { | |
5575 | 160 GaimConnection *gc; |
2086 | 161 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
162 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
163 fu8_t cookie[8]; |
8984 | 164 gboolean donttryagain; |
2086 | 165 }; |
166 | |
7011 | 167 /* |
168 * Various PRPL-specific buddy info that we want to keep track of | |
169 * Some other info is maintained by locate.c, and I'd like to move | |
170 * the rest of this to libfaim, mostly im.c | |
171 */ | |
4738 | 172 struct buddyinfo { |
173 gboolean typingnot; | |
6292 | 174 gchar *availmsg; |
6857 | 175 fu32_t ipaddr; |
5836 | 176 |
177 unsigned long ico_me_len; | |
178 unsigned long ico_me_csum; | |
179 time_t ico_me_time; | |
180 gboolean ico_informed; | |
4738 | 181 |
182 unsigned long ico_len; | |
183 unsigned long ico_csum; | |
184 time_t ico_time; | |
185 gboolean ico_need; | |
7406 | 186 gboolean ico_sent; |
2086 | 187 }; |
188 | |
4230 | 189 struct name_data { |
5575 | 190 GaimConnection *gc; |
4230 | 191 gchar *name; |
3453 | 192 gchar *nick; |
3141 | 193 }; |
194 | |
5129 | 195 static char *msgerrreason[] = { |
196 N_("Invalid error"), | |
197 N_("Invalid SNAC"), | |
198 N_("Rate to host"), | |
199 N_("Rate to client"), | |
200 N_("Not logged in"), | |
201 N_("Service unavailable"), | |
202 N_("Service not defined"), | |
203 N_("Obsolete SNAC"), | |
204 N_("Not supported by host"), | |
205 N_("Not supported by client"), | |
206 N_("Refused by client"), | |
207 N_("Reply too big"), | |
208 N_("Responses lost"), | |
209 N_("Request denied"), | |
210 N_("Busted SNAC payload"), | |
211 N_("Insufficient rights"), | |
212 N_("In local permit/deny"), | |
213 N_("Too evil (sender)"), | |
214 N_("Too evil (receiver)"), | |
215 N_("User temporarily unavailable"), | |
216 N_("No match"), | |
217 N_("List overflow"), | |
218 N_("Request ambiguous"), | |
219 N_("Queue full"), | |
220 N_("Not while on AOL") | |
221 }; | |
222 static int msgerrreasonlen = 25; | |
223 | |
224 /* All the libfaim->gaim callback functions */ | |
225 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
226 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 227 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 228 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
229 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 236 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 237 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 238 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
239 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
240 static int gaim_conv_chat_join (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
241 static int gaim_conv_chat_leave (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
242 static int gaim_conv_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
243 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 244 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
245 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 247 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 248 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
249 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
255 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
256 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
259 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
260 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 279 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 280 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
281 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
282 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
283 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
284 | |
285 /* for DirectIM/image transfer */ | |
286 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
287 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
288 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 289 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 290 |
291 /* for file transfer */ | |
292 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
293 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
294 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
295 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
296 | |
297 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 298 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
11159 | 299 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie); |
5954 | 300 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 301 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
11084 | 302 static void oscar_xfer_init_recv(GaimXfer *xfer); |
9935 | 303 |
5836 | 304 static void oscar_free_name_data(struct name_data *data) { |
4230 | 305 g_free(data->name); |
306 g_free(data->nick); | |
307 g_free(data); | |
308 } | |
309 | |
5836 | 310 static void oscar_free_buddyinfo(void *data) { |
311 struct buddyinfo *bi = data; | |
6292 | 312 g_free(bi->availmsg); |
5836 | 313 g_free(bi); |
314 } | |
315 | |
9807 | 316 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 317 { |
318 int i = 0; | |
9826 | 319 int charset = AIM_CHARSET_ASCII; |
5129 | 320 |
11081 | 321 /* Determine how we can send this message. Per the warnings elsewhere |
322 * in this file, these little checks determine the simplest encoding | |
5129 | 323 * we can use for a given message send using it. */ |
324 while (utf8[i]) { | |
325 if ((unsigned char)utf8[i] > 0x7f) { | |
326 /* not ASCII! */ | |
9826 | 327 charset = AIM_CHARSET_CUSTOM; |
5129 | 328 break; |
329 } | |
330 i++; | |
331 } | |
332 while (utf8[i]) { | |
333 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
334 * followed by 0xc0-0xc3 in the second */ | |
335 if ((unsigned char)utf8[i] < 0x80) { | |
336 i++; | |
337 continue; | |
338 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
339 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
340 i += 2; | |
341 continue; | |
342 } | |
9826 | 343 charset = AIM_CHARSET_UNICODE; |
5129 | 344 break; |
345 } | |
346 | |
9807 | 347 return charset; |
5129 | 348 } |
349 | |
8225 | 350 /* |
351 * Take a string of the form charset="bleh" where bleh is | |
11081 | 352 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and |
8225 | 353 * return a newly allocated string containing bleh. |
354 */ | |
355 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 356 { |
8225 | 357 gchar *ret = NULL; |
358 char *begin, *end; | |
359 | |
9933 | 360 g_return_val_if_fail(encoding != NULL, NULL); |
361 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
362 /* Make sure encoding begins with charset= */ |
10540 | 363 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
364 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
365 { | |
8225 | 366 return NULL; |
10540 | 367 } |
8225 | 368 |
369 begin = strchr(encoding, '"'); | |
370 end = strrchr(encoding, '"'); | |
371 | |
372 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
373 return NULL; | |
374 | |
375 ret = g_strndup(begin+1, (end-1) - begin); | |
376 | |
377 return ret; | |
378 } | |
379 | |
9830 | 380 static gchar * |
381 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 382 { |
383 gchar *utf8 = NULL; | |
9595 | 384 |
385 if ((encoding == NULL) || encoding[0] == '\0') { | |
386 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 387 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 388 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 389 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 390 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 391 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 392 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 393 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 394 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 395 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 396 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
397 } | |
398 | |
399 /* | |
400 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
401 * we have been unable to convert the text to utf-8 from the encoding | |
402 * that was specified. So we check if the text is valid utf-8 then | |
403 * just copy it. | |
404 */ | |
405 if (utf8 == NULL) { | |
9638 | 406 if (textlen != 0 && *text != '\0' |
407 && !g_utf8_validate(text, textlen, NULL)) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
408 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 409 else |
9481 | 410 utf8 = g_strndup(text, textlen); |
5129 | 411 } |
412 | |
413 return utf8; | |
414 } | |
415 | |
9830 | 416 static gchar * |
11159 | 417 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback) |
9830 | 418 { |
419 gchar *ret = NULL; | |
420 GError *err = NULL; | |
421 | |
9908 | 422 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
423 return NULL; | |
424 | |
425 if (strcasecmp("UTF-8", charsetstr)) { | |
426 if (fallback) | |
427 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
428 else | |
429 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
430 if (err != NULL) { | |
431 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
432 charsetstr, err->message); | |
433 g_error_free(err); | |
434 } | |
435 } else { | |
436 if (g_utf8_validate(data, datalen, NULL)) | |
437 ret = g_strndup(data, datalen); | |
438 else | |
439 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
440 } | |
441 | |
442 return ret; | |
443 } | |
444 | |
445 /* | |
11081 | 446 * This attemps to decode an incoming IM into a UTF8 string. |
447 * | |
9908 | 448 * We try decoding using two different character sets. The charset |
449 * specified in the IM determines the order in which we attempt to | |
450 * decode. We do this because there are lots of broken ICQ clients | |
451 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
452 * able to deal with that crap, then people complain like banshees. | |
453 * charsetstr1 is always set to what the correct encoding should be. | |
454 */ | |
455 static gchar * | |
11159 | 456 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, const gchar *data, gsize datalen) |
9908 | 457 { |
458 gchar *ret = NULL; | |
459 const gchar *charsetstr1, *charsetstr2; | |
460 | |
461 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 462 |
463 if ((datalen == 0) || (data == NULL)) | |
464 return NULL; | |
465 | |
9908 | 466 if (charset == AIM_CHARSET_UNICODE) { |
467 charsetstr1 = "UCS-2BE"; | |
468 charsetstr2 = "UTF-8"; | |
469 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 470 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 471 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 472 else |
9908 | 473 charsetstr1 = "ISO-8859-1"; |
474 charsetstr2 = "UTF-8"; | |
475 } else if (charset == AIM_CHARSET_ASCII) { | |
476 /* Should just be "ASCII" */ | |
9914 | 477 charsetstr1 = "ASCII"; |
9908 | 478 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
479 } else if (charset == 0x000d) { | |
9830 | 480 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 481 charsetstr1 = "ISO-8859-1"; |
482 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
483 } else { | |
9830 | 484 /* Unknown, hope for valid UTF-8... */ |
9908 | 485 charsetstr1 = "UTF-8"; |
486 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
487 } | |
488 | |
489 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
490 if (ret == NULL) | |
491 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
492 if (ret == NULL) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
493 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9830 | 494 |
495 return ret; | |
496 } | |
497 | |
11081 | 498 /* |
499 * Figure out what encoding to use when sending a given outgoing message. | |
500 */ | |
9830 | 501 static void |
502 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 503 gchar **msg, int *msglen_int, |
9830 | 504 fu16_t *charset, fu16_t *charsubset) |
505 { | |
506 OscarData *od = gc->proto_data; | |
507 GaimAccount *account = gaim_connection_get_account(gc); | |
508 GError *err = NULL; | |
509 aim_userinfo_t *userinfo = NULL; | |
510 const gchar *charsetstr; | |
10039 | 511 gsize msglen; |
9830 | 512 |
513 /* Attempt to send as ASCII */ | |
10098 | 514 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 515 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 516 *charset = AIM_CHARSET_ASCII; |
9830 | 517 *charsubset = 0x0000; |
10039 | 518 *msglen_int = msglen; |
9830 | 519 return; |
520 } | |
521 | |
522 /* | |
10565 | 523 * If we're sending to an ICQ user, and they are in our |
524 * buddy list, and they are advertising the Unicode | |
525 * capability, and they are online, then attempt to send | |
526 * as UCS-2BE. | |
9830 | 527 */ |
9975 | 528 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 529 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
530 | |
10565 | 531 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
532 { | |
533 GaimBuddy *b; | |
534 b = gaim_find_buddy(account, destsn); | |
535 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
536 { | |
537 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
538 if (*msg != NULL) | |
539 { | |
540 *charset = AIM_CHARSET_UNICODE; | |
541 *charsubset = 0x0000; | |
542 *msglen_int = msglen; | |
543 return; | |
544 } | |
9830 | 545 } |
546 } | |
547 | |
548 /* | |
549 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
550 * ICQ then attempt to send as the user specified character encoding. | |
551 */ | |
552 charsetstr = "ISO-8859-1"; | |
9975 | 553 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 554 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
555 | |
10097 | 556 /* |
557 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
558 * can be converted to "charsetstr" | |
559 */ | |
10039 | 560 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 561 if (*msg != NULL) { |
562 *charset = AIM_CHARSET_CUSTOM; | |
563 *charsubset = 0x0000; | |
10039 | 564 *msglen_int = msglen; |
9830 | 565 return; |
566 } | |
567 | |
568 /* | |
569 * Nothing else worked, so send as UCS-2BE. | |
570 */ | |
10039 | 571 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 572 if (*msg != NULL) { |
573 *charset = AIM_CHARSET_UNICODE; | |
574 *charsubset = 0x0000; | |
10039 | 575 *msglen_int = msglen; |
9830 | 576 return; |
577 } | |
578 | |
9908 | 579 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 580 g_error_free(err); |
581 | |
582 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
583 *msg = g_strdup(from); | |
10039 | 584 *msglen_int = strlen(*msg); |
9830 | 585 *charset = AIM_CHARSET_ASCII; |
586 *charsubset = 0x0000; | |
587 return; | |
588 } | |
589 | |
9407 | 590 gchar *oscar_caps_to_string(guint caps) |
8701 | 591 { |
9407 | 592 GString *str; |
593 gchar *tmp; | |
8701 | 594 guint bit = 1; |
595 | |
9407 | 596 str = g_string_new(""); |
597 | |
8701 | 598 if (!caps) { |
599 return NULL; | |
600 } else while (bit <= AIM_CAPS_LAST) { | |
601 if (bit & caps) { | |
602 switch (bit) { | |
603 case AIM_CAPS_BUDDYICON: | |
604 tmp = _("Buddy Icon"); | |
605 break; | |
606 case AIM_CAPS_TALK: | |
607 tmp = _("Voice"); | |
608 break; | |
609 case AIM_CAPS_DIRECTIM: | |
610 tmp = _("AIM Direct IM"); | |
611 break; | |
612 case AIM_CAPS_CHAT: | |
613 tmp = _("Chat"); | |
614 break; | |
615 case AIM_CAPS_GETFILE: | |
616 tmp = _("Get File"); | |
617 break; | |
618 case AIM_CAPS_SENDFILE: | |
619 tmp = _("Send File"); | |
620 break; | |
621 case AIM_CAPS_GAMES: | |
622 case AIM_CAPS_GAMES2: | |
623 tmp = _("Games"); | |
624 break; | |
625 case AIM_CAPS_ADDINS: | |
626 tmp = _("Add-Ins"); | |
627 break; | |
628 case AIM_CAPS_SENDBUDDYLIST: | |
629 tmp = _("Send Buddy List"); | |
630 break; | |
631 case AIM_CAPS_ICQ_DIRECT: | |
632 tmp = _("ICQ Direct Connect"); | |
633 break; | |
634 case AIM_CAPS_APINFO: | |
635 tmp = _("AP User"); | |
636 break; | |
637 case AIM_CAPS_ICQRTF: | |
638 tmp = _("ICQ RTF"); | |
639 break; | |
640 case AIM_CAPS_EMPTY: | |
641 tmp = _("Nihilist"); | |
642 break; | |
643 case AIM_CAPS_ICQSERVERRELAY: | |
644 tmp = _("ICQ Server Relay"); | |
645 break; | |
646 case AIM_CAPS_ICQUTF8OLD: | |
647 tmp = _("Old ICQ UTF8"); | |
648 break; | |
649 case AIM_CAPS_TRILLIANCRYPT: | |
650 tmp = _("Trillian Encryption"); | |
651 break; | |
652 case AIM_CAPS_ICQUTF8: | |
653 tmp = _("ICQ UTF8"); | |
654 break; | |
655 case AIM_CAPS_HIPTOP: | |
656 tmp = _("Hiptop"); | |
657 break; | |
658 case AIM_CAPS_SECUREIM: | |
659 tmp = _("Security Enabled"); | |
660 break; | |
661 case AIM_CAPS_VIDEO: | |
662 tmp = _("Video Chat"); | |
663 break; | |
664 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
665 case AIM_CAPS_ICHATAV: | |
666 tmp = _("iChat AV"); | |
667 break; | |
668 case AIM_CAPS_LIVEVIDEO: | |
669 tmp = _("Live Video"); | |
670 break; | |
671 case AIM_CAPS_CAMERA: | |
672 tmp = _("Camera"); | |
673 break; | |
674 default: | |
675 tmp = NULL; | |
676 break; | |
677 } | |
678 if (tmp) | |
9532 | 679 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 680 } |
681 bit <<= 1; | |
682 } | |
9407 | 683 |
684 return g_string_free(str, FALSE); | |
8701 | 685 } |
686 | |
687 static char *oscar_icqstatus(int state) { | |
688 /* Make a cute little string that shows the status of the dude or dudet */ | |
689 if (state & AIM_ICQ_STATE_CHAT) | |
690 return g_strdup_printf(_("Free For Chat")); | |
691 else if (state & AIM_ICQ_STATE_DND) | |
692 return g_strdup_printf(_("Do Not Disturb")); | |
693 else if (state & AIM_ICQ_STATE_OUT) | |
694 return g_strdup_printf(_("Not Available")); | |
695 else if (state & AIM_ICQ_STATE_BUSY) | |
696 return g_strdup_printf(_("Occupied")); | |
697 else if (state & AIM_ICQ_STATE_AWAY) | |
698 return g_strdup_printf(_("Away")); | |
699 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
700 return g_strdup_printf(_("Web Aware")); | |
701 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
702 return g_strdup_printf(_("Invisible")); | |
703 else | |
704 return g_strdup_printf(_("Online")); | |
705 } | |
706 | |
9973 | 707 static void |
708 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 709 { |
710 gchar *utf8; | |
711 | |
712 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 713 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 714 g_free(utf8); |
715 } | |
716 } | |
717 | |
9973 | 718 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 719 { |
10042 | 720 OscarData *od; |
721 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
722 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
723 GaimStatus *status = NULL; |
8701 | 724 GaimGroup *g = NULL; |
725 struct buddyinfo *bi = NULL; | |
726 char *tmp; | |
727 | |
10042 | 728 od = gc->proto_data; |
729 account = gaim_connection_get_account(gc); | |
730 | |
731 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 732 return; |
733 | |
734 if (userinfo == NULL) | |
735 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
736 | |
737 if (b == NULL) | |
10042 | 738 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 739 |
740 if (b != NULL) | |
10498 | 741 { |
8701 | 742 g = gaim_find_buddys_group(b); |
10498 | 743 presence = gaim_buddy_get_presence(b); |
744 status = gaim_presence_get_active_status(presence); | |
745 } | |
8701 | 746 |
747 if (userinfo != NULL) | |
748 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
749 | |
8733 | 750 if (b != NULL) { |
10498 | 751 if (gaim_presence_is_online(presence)) { |
9975 | 752 if (aim_sn_is_icq(b->name)) { |
8733 | 753 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
754 oscar_string_append(str, newline, _("Status"), tmp); | |
755 g_free(tmp); | |
756 } | |
757 } else { | |
9625 | 758 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 759 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
760 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
761 else | |
762 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 763 } |
8733 | 764 } |
8701 | 765 |
766 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 767 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 768 (bi->ipaddr & 0xff000000) >> 24, |
769 (bi->ipaddr & 0x00ff0000) >> 16, | |
770 (bi->ipaddr & 0x0000ff00) >> 8, | |
771 (bi->ipaddr & 0x000000ff)); | |
772 oscar_string_append(str, newline, _("IP Address"), tmp); | |
773 g_free(tmp); | |
774 } | |
775 | |
776 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
777 tmp = oscar_caps_to_string(userinfo->capabilities); | |
778 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 779 g_free(tmp); |
8701 | 780 } |
781 | |
782 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
783 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
784 if (tmp != NULL) { | |
9625 | 785 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 786 g_free(tmp); |
9625 | 787 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
788 g_free(tmp2); | |
8701 | 789 } |
790 } | |
791 | |
10498 | 792 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_status_is_available(status)) { |
8701 | 793 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
794 oscar_string_append(str, newline, _("Available"), tmp); | |
795 g_free(tmp); | |
796 } | |
797 } | |
798 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
799 static char *extract_name(const char *name) { |
4121 | 800 char *tmp, *x; |
2086 | 801 int i, j; |
4120 | 802 |
803 if (!name) | |
4121 | 804 return NULL; |
10042 | 805 |
4120 | 806 x = strchr(name, '-'); |
4121 | 807 |
2086 | 808 if (!x) return NULL; |
809 x = strchr(++x, '-'); | |
810 if (!x) return NULL; | |
811 tmp = g_strdup(++x); | |
812 | |
813 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
814 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
815 if (x[i] != '%') { |
2086 | 816 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
817 continue; |
2086 | 818 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
819 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
820 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
821 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 822 } |
823 | |
824 tmp[j] = 0; | |
825 return tmp; | |
826 } | |
827 | |
10458 | 828 static struct chat_connection * |
829 find_oscar_chat(GaimConnection *gc, int id) | |
830 { | |
831 OscarData *od = (OscarData *)gc->proto_data; | |
832 GSList *cur; | |
833 struct chat_connection *cc; | |
834 | |
835 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
836 { | |
837 cc = (struct chat_connection *)cur->data; | |
838 if (cc->id == id) | |
839 return cc; | |
840 } | |
841 | |
842 return NULL; | |
843 } | |
844 | |
845 static struct chat_connection * | |
846 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
847 { | |
848 OscarData *od = (OscarData *)gc->proto_data; | |
849 GSList *cur; | |
850 struct chat_connection *cc; | |
851 | |
852 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
853 { | |
854 cc = (struct chat_connection *)cur->data; | |
855 if (cc->conn == conn) | |
856 return cc; | |
857 } | |
858 | |
859 return NULL; | |
860 } | |
861 | |
862 static struct chat_connection * | |
863 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
864 { | |
865 OscarData *od = (OscarData *)gc->proto_data; | |
866 GSList *cur; | |
867 struct chat_connection *cc; | |
868 | |
869 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
870 { | |
871 cc = (struct chat_connection *)cur->data; | |
872 if (cc->conv == conv) | |
873 return cc; | |
874 } | |
875 | |
876 return NULL; | |
877 } | |
878 | |
879 static void | |
880 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
881 { | |
882 OscarData *od = (OscarData *)gc->proto_data; | |
883 | |
884 /* Notify the conversation window that we've left the chat */ | |
885 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
886 | |
887 /* Destroy the chat_connection */ | |
888 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
889 if (cc->inpa > 0) | |
890 gaim_input_remove(cc->inpa); | |
891 aim_conn_kill(od->sess, &cc->conn); | |
892 g_free(cc->name); | |
893 g_free(cc->show); | |
894 g_free(cc); | |
8219 | 895 } |
896 | |
8971 | 897 /***************************************************************************** |
898 * Begin scary direct im stuff | |
899 *****************************************************************************/ | |
900 | |
901 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
902 GSList *d = od->direct_ims; | |
903 struct oscar_direct_im *m = NULL; | |
904 | |
905 while (d) { | |
906 m = (struct oscar_direct_im *)d->data; | |
907 if (!aim_sncmp(who, m->name)) | |
908 return m; | |
909 d = d->next; | |
910 } | |
911 | |
912 return NULL; | |
913 } | |
914 | |
915 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
916 { | |
917 gaim_debug_info("oscar", | |
918 "destroying Direct IM for %s.\n", dim->name); | |
919 | |
920 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 921 if (dim->gpc_pend) { |
922 dim->killme = TRUE; | |
923 return; | |
924 } | |
8971 | 925 if (dim->watcher) |
926 gaim_input_remove(dim->watcher); | |
927 if (dim->conn) { | |
10271 | 928 aim_conn_close(dim->conn); |
8971 | 929 aim_conn_kill(od->sess, &dim->conn); |
930 } | |
931 g_free(dim); | |
932 } | |
933 | |
934 /* the only difference between this and destroy is this writes a conv message */ | |
935 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
936 { | |
937 GaimConversation *conv; | |
938 char buf[256]; | |
939 | |
940 gaim_debug_info("oscar", | |
941 "%s disconnected Direct IM.\n", dim->name); | |
942 | |
943 if (dim->connected) | |
944 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 945 else |
8971 | 946 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
947 | |
10246 | 948 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
949 gaim_connection_get_account(dim->gc)); | |
8971 | 950 if (conv) { |
951 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 952 gaim_conversation_update_progress(conv, 0); |
8971 | 953 } else { |
954 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
955 } | |
956 | |
957 oscar_direct_im_destroy(od, dim); | |
958 | |
959 return; | |
960 } | |
961 | |
962 /* oops i made two of these. this one just calls the other one. */ | |
963 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
964 { | |
965 GaimConnection *gc = sess->aux_data; | |
966 OscarData *od = (OscarData *)gc->proto_data; | |
967 struct oscar_direct_im *dim; | |
968 char *sn; | |
969 | |
970 sn = g_strdup(aim_odc_getsn(conn)); | |
971 dim = oscar_direct_im_find(od, sn); | |
972 oscar_direct_im_disconnect(od, dim); | |
973 g_free(sn); | |
974 } | |
975 | |
976 static void destroy_direct_im_request(struct ask_direct *d) { | |
977 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
978 | |
979 g_free(d->sn); | |
980 g_free(d); | |
981 } | |
982 | |
983 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
984 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
985 struct oscar_direct_im *dim = data; | |
986 GaimConnection *gc = dim->gc; | |
987 OscarData *od = gc->proto_data; | |
988 GaimConversation *conv; | |
989 char buf[256]; | |
990 struct sockaddr name; | |
991 socklen_t name_len = 1; | |
992 | |
993 g_return_if_fail(gc != NULL); | |
994 | |
8978 | 995 dim->gpc_pend = FALSE; |
996 if (dim->killme) { | |
997 oscar_direct_im_destroy(od, dim); | |
998 return; | |
999 } | |
1000 | |
8971 | 1001 if (!g_list_find(gaim_connections_get_all(), gc)) { |
1002 oscar_direct_im_destroy(od, dim); | |
1003 return; | |
1004 } | |
1005 | |
1006 if (source < 0) { | |
8984 | 1007 if (dim->donttryagain) { |
1008 oscar_direct_im_disconnect(od, dim); | |
1009 return; | |
1010 } else { | |
11159 | 1011 guchar cookie[8]; |
8984 | 1012 char *who = g_strdup(dim->name); |
11159 | 1013 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1014 |
1015 memcpy(cookie, tmp, 8); | |
1016 oscar_direct_im_destroy(od, dim); | |
1017 oscar_direct_im_initiate(gc, who, cookie); | |
1018 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1019 g_free(who); | |
1020 return; | |
1021 } | |
8971 | 1022 } |
1023 | |
1024 dim->conn->fd = source; | |
1025 aim_conn_completeconnect(od->sess, dim->conn); | |
1026 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
1027 | |
1028 /* This is the best way to see if we're connected or not */ | |
8983 | 1029 /* Is this really needed? */ |
8971 | 1030 if (getpeername(source, &name, &name_len) == 0) { |
1031 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1032 dim->connected = TRUE; | |
1033 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1034 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1035 } else { | |
8984 | 1036 if (dim->donttryagain) { |
1037 oscar_direct_im_disconnect(od, dim); | |
1038 return; | |
1039 } else { | |
11159 | 1040 guchar cookie[8]; |
8984 | 1041 char *who = g_strdup(dim->name); |
11159 | 1042 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1043 |
1044 memcpy(cookie, tmp, 8); | |
1045 oscar_direct_im_destroy(od, dim); | |
1046 oscar_direct_im_initiate(gc, who, cookie); | |
1047 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1048 g_free(who); | |
1049 return; | |
1050 } | |
8983 | 1051 } |
1052 | |
1053 | |
8971 | 1054 } |
1055 | |
1056 static void accept_direct_im_request(struct ask_direct *d) { | |
1057 GaimConnection *gc = d->gc; | |
1058 OscarData *od; | |
1059 struct oscar_direct_im *dim; | |
1060 char *host; int port = 5190; | |
1061 int i, rc; | |
8982 | 1062 char *tmp; |
1063 GaimConversation *conv; | |
8971 | 1064 |
1065 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1066 destroy_direct_im_request(d); | |
1067 return; | |
1068 } | |
1069 | |
1070 od = (OscarData *)gc->proto_data; | |
1071 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1072 | |
1073 dim = oscar_direct_im_find(od, d->sn); | |
1074 if (dim && dim->connected) { | |
1075 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1076 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1077 return; | |
1078 } | |
1079 dim = g_new0(struct oscar_direct_im, 1); | |
1080 dim->gc = d->gc; | |
8984 | 1081 dim->donttryagain = d->donttryagain; |
8971 | 1082 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1083 | |
1084 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1085 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1086 if (!dim->conn) { | |
1087 oscar_direct_im_disconnect(od, dim); | |
1088 destroy_direct_im_request(d); | |
1089 return; | |
1090 } | |
1091 | |
1092 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1093 gaim_odc_incoming, 0); | |
1094 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1095 gaim_odc_typing, 0); | |
1096 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1097 gaim_odc_update_ui, 0); | |
1098 | |
1099 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1100 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1101 if (d->ip[i] == ':') { | |
1102 port = atoi(&(d->ip[i+1])); | |
1103 break; | |
1104 } | |
1105 } | |
1106 host = g_strndup(d->ip, i); | |
1107 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1108 dim->gpc_pend = TRUE; |
8971 | 1109 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1110 |
1111 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1112 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1113 port); | |
1114 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1115 g_free(tmp); | |
8983 | 1116 |
8971 | 1117 g_free(host); |
1118 if (rc < 0) { | |
8978 | 1119 dim->gpc_pend = FALSE; |
8971 | 1120 oscar_direct_im_disconnect(od, dim); |
1121 destroy_direct_im_request(d); | |
1122 return; | |
1123 } | |
1124 | |
1125 destroy_direct_im_request(d); | |
1126 | |
1127 return; | |
1128 } | |
1129 | |
1130 /* | |
1131 * We have just established a socket with the other dude, so set up some handlers. | |
1132 */ | |
1133 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1134 GaimConnection *gc = sess->aux_data; |
7283 | 1135 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1136 GaimConversation *conv; |
8971 | 1137 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1138 char buf[256]; |
8971 | 1139 char *sn; |
1140 va_list ap; | |
1141 aim_conn_t *newconn, *listenerconn; | |
1142 | |
1143 va_start(ap, fr); | |
1144 newconn = va_arg(ap, aim_conn_t *); | |
1145 listenerconn = va_arg(ap, aim_conn_t *); | |
1146 va_end(ap); | |
1147 | |
10271 | 1148 aim_conn_close(listenerconn); |
8971 | 1149 aim_conn_kill(sess, &listenerconn); |
1150 | |
1151 sn = g_strdup(aim_odc_getsn(newconn)); | |
1152 | |
1153 gaim_debug_info("oscar", | |
1154 "DirectIM: initiate success to %s\n", sn); | |
1155 dim = oscar_direct_im_find(od, sn); | |
1156 | |
1157 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1158 gaim_input_remove(dim->watcher); | |
1159 dim->conn = newconn; | |
1160 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1161 dim->connected = TRUE; | |
1162 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1163 g_free(sn); | |
1164 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1165 | |
1166 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1167 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1168 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1169 | |
1170 return 1; | |
1171 } | |
1172 | |
1173 /* | |
1174 * This is called when each chunk of an image is received. It can be used to | |
1175 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1176 * nasty, you sicko. | |
1177 */ | |
1178 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1179 va_list ap; | |
1180 char *sn; | |
1181 double percent; | |
1182 GaimConnection *gc = sess->aux_data; | |
1183 OscarData *od = (OscarData *)gc->proto_data; | |
1184 GaimConversation *c; | |
1185 struct oscar_direct_im *dim; | |
1186 | |
1187 va_start(ap, fr); | |
1188 sn = va_arg(ap, char *); | |
1189 percent = va_arg(ap, double); | |
1190 va_end(ap); | |
1191 | |
1192 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1193 return 1; | |
1194 if (dim->watcher) { | |
1195 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1196 /* The callback will callback? I don't get how that would happen here. */ | |
1197 dim->watcher = 0; | |
1198 } | |
1199 | |
10246 | 1200 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1201 gaim_connection_get_account(gc)); | |
8971 | 1202 if (c != NULL) |
1203 gaim_conversation_update_progress(c, percent); | |
1204 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1205 oscar_callback, dim->conn); | |
1206 | |
1207 return 1; | |
1208 } | |
1209 | |
1210 /* | |
1211 * This is called after a direct IM has been received in its entirety. This | |
1212 * function is passed a long chunk of data which contains the IM with any | |
1213 * data chunks (images) appended to it. | |
1214 * | |
1215 * This function rips out all the data chunks and creates an imgstore for | |
1216 * each one. In order to do this, it first goes through the IM and takes | |
1217 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1218 * with one compatible with the imgstore Gaim core code. For each one, we | |
1219 * then read in chunks of data from the end of the message and actually | |
1220 * create the img store using the given data. | |
1221 * | |
1222 * For somewhat easy reference, here's a sample message | |
1223 * (without the whitespace and asterisks): | |
1224 * | |
1225 * <HTML><BODY BGCOLOR="#ffffff"> | |
1226 * <FONT LANG="0"> | |
1227 * This is a really stupid picture:<BR> | |
1228 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1229 * Yeah it is<BR> | |
1230 * Here is another one:<BR> | |
1231 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1232 * </FONT> | |
1233 * </BODY></HTML> | |
1234 * <BINARY> | |
1235 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1236 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1237 * </BINARY> | |
1238 */ | |
1239 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1240 GaimConnection *gc = sess->aux_data; | |
1241 GaimConvImFlags imflags = 0; | |
1242 gchar *utf8; | |
1243 GString *newmsg = g_string_new(""); | |
1244 GSList *images = NULL; | |
1245 va_list ap; | |
1246 const char *sn, *msg, *msgend, *binary; | |
1247 size_t len; | |
1248 int encoding, isawaymsg; | |
1249 | |
1250 va_start(ap, fr); | |
1251 sn = va_arg(ap, const char *); | |
1252 msg = va_arg(ap, const char *); | |
1253 len = va_arg(ap, size_t); | |
1254 encoding = va_arg(ap, int); | |
1255 isawaymsg = va_arg(ap, int); | |
1256 va_end(ap); | |
1257 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1258 |
8660 | 1259 gaim_debug_info("oscar", |
8971 | 1260 "Got DirectIM message from %s\n", sn); |
1261 | |
1262 if (isawaymsg) | |
1263 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1264 | |
1265 /* message has a binary trailer */ | |
1266 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1267 GData *attribs; | |
1268 const char *tmp, *start, *end, *last = NULL; | |
1269 | |
1270 tmp = msg; | |
1271 | |
1272 /* for each valid image tag... */ | |
1273 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1274 const char *id, *src, *datasize; | |
10504 | 1275 const char *data = NULL; |
1276 char *tag = NULL; | |
8971 | 1277 size_t size; |
1278 int imgid = 0; | |
1279 | |
1280 /* update the location of the last img tag */ | |
1281 last = end; | |
1282 | |
1283 /* grab attributes */ | |
1284 id = g_datalist_get_data(&attribs, "id"); | |
1285 src = g_datalist_get_data(&attribs, "src"); | |
1286 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1287 | |
1288 /* if we have id & datasize, build the data tag */ | |
1289 if (id && datasize) | |
1290 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1291 | |
1292 /* if we have a tag, find the start of the data */ | |
1293 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1294 data += strlen(tag); | |
1295 | |
10504 | 1296 g_free(tag); |
1297 | |
8971 | 1298 /* check the data is here and store it */ |
1299 if (data + (size = atoi(datasize)) <= msgend) | |
1300 imgid = gaim_imgstore_add(data, size, src); | |
1301 | |
1302 /* | |
1303 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1304 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1305 */ | |
1306 /* if we have a stored image... */ | |
1307 if (imgid) { | |
1308 /* append the message up to the tag */ | |
1309 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1310 if (utf8 != NULL) { | |
1311 newmsg = g_string_append(newmsg, utf8); | |
1312 g_free(utf8); | |
1313 } | |
1314 | |
1315 /* write the new image tag */ | |
1316 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1317 | |
1318 /* and record the image number */ | |
1319 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1320 } else { | |
1321 /* otherwise, copy up to the end of the tag */ | |
1322 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1323 if (utf8 != NULL) { | |
1324 newmsg = g_string_append(newmsg, utf8); | |
1325 g_free(utf8); | |
1326 } | |
1327 } | |
1328 | |
1329 /* clear the attribute list */ | |
1330 g_datalist_clear(&attribs); | |
1331 | |
1332 /* continue from the end of the tag */ | |
1333 tmp = end + 1; | |
1334 } | |
1335 | |
1336 /* append any remaining message data (without the > :-) */ | |
1337 if (last++ && (last < binary)) | |
1338 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1339 | |
1340 /* set the flag if we caught any images */ | |
1341 if (images) | |
1342 imflags |= GAIM_CONV_IM_IMAGES; | |
1343 } else { | |
1344 g_string_append_len(newmsg, msg, len); | |
1345 } | |
1346 | |
10318 | 1347 /* Convert to UTF8 */ |
1348 /* (This hasn't been tested very much) */ | |
1349 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1350 if (utf8 != NULL) { | |
1351 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1352 g_free(utf8); | |
1353 } | |
1354 | |
1355 /* free the message */ | |
8971 | 1356 g_string_free(newmsg, TRUE); |
1357 | |
1358 /* unref any images we allocated */ | |
1359 if (images) { | |
1360 GSList *tmp; | |
1361 int id; | |
1362 | |
1363 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1364 id = GPOINTER_TO_INT(tmp->data); | |
1365 gaim_imgstore_unref(id); | |
1366 } | |
1367 | |
1368 g_slist_free(images); | |
1369 } | |
1370 | |
1371 return 1; | |
1372 } | |
1373 | |
1374 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1375 va_list ap; | |
1376 char *sn; | |
1377 int typing; | |
1378 GaimConnection *gc = sess->aux_data; | |
1379 | |
1380 va_start(ap, fr); | |
1381 sn = va_arg(ap, char *); | |
1382 typing = va_arg(ap, int); | |
1383 va_end(ap); | |
1384 | |
1385 if (typing == 0x0002) { | |
1386 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1387 gaim_debug_info("oscar", | |
1388 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1389 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1390 } else if (typing == 0x0001) | |
1391 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1392 else | |
1393 serv_got_typing_stopped(gc, sn); | |
1394 return 1; | |
1395 } | |
1396 | |
1397 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1398 char *buf; | |
1399 size_t len; | |
1400 int ret; | |
1401 GString *msg = g_string_new("<HTML><BODY>"); | |
1402 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1403 GData *attribs; | |
1404 const char *start, *end, *last; | |
1405 int oscar_id = 0; | |
1406 | |
1407 last = message; | |
1408 | |
1409 /* for each valid IMG tag... */ | |
1410 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1411 GaimStoredImage *image = NULL; | |
1412 const char *id; | |
1413 | |
1414 if (start - last) { | |
1415 g_string_append_len(msg, last, start - last); | |
1416 } | |
1417 | |
1418 id = g_datalist_get_data(&attribs, "id"); | |
1419 | |
1420 /* ... if it refers to a valid gaim image ... */ | |
1421 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1422 /* ... append the message from start to the tag ... */ | |
9126 | 1423 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1424 const char *filename = gaim_imgstore_get_filename(image); |
1425 gpointer imgdata = gaim_imgstore_get_data(image); | |
1426 | |
1427 oscar_id++; | |
1428 | |
1429 /* ... insert a new img tag with the oscar id ... */ | |
1430 if (filename) | |
1431 g_string_append_printf(msg, | |
9126 | 1432 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1433 filename, oscar_id, size); |
1434 else | |
1435 g_string_append_printf(msg, | |
9126 | 1436 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1437 oscar_id, size); |
1438 | |
1439 /* ... and append the data to the binary section ... */ | |
9126 | 1440 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1441 oscar_id, size); |
1442 data = g_string_append_len(data, imgdata, size); | |
1443 data = g_string_append(data, "</DATA>"); | |
1444 } | |
1445 /* If the tag is invalid, skip it, thus no else here */ | |
1446 | |
1447 g_datalist_clear(&attribs); | |
1448 | |
1449 /* continue from the end of the tag */ | |
1450 last = end + 1; | |
1451 } | |
1452 | |
1453 /* append any remaining message data (without the > :-) */ | |
1454 if (last && *last) | |
1455 msg = g_string_append(msg, last); | |
1456 | |
1457 /* if we inserted any images in the binary section, append it */ | |
1458 if (oscar_id) { | |
1459 msg = g_string_append_len(msg, data->str, data->len); | |
1460 msg = g_string_append(msg, "</BINARY>"); | |
1461 } | |
1462 | |
1463 len = msg->len; | |
1464 buf = msg->str; | |
1465 g_string_free(msg, FALSE); | |
1466 g_string_free(data, TRUE); | |
1467 | |
1468 | |
1469 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1470 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1471 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1472 else | |
1473 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1474 | |
1475 g_free(buf); | |
1476 | |
1477 return ret; | |
1478 } | |
1479 | |
1480 struct ask_do_dir_im { | |
1481 char *who; | |
1482 GaimConnection *gc; | |
1483 }; | |
1484 | |
1485 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1486 g_free(data->who); | |
1487 g_free(data); | |
1488 } | |
1489 | |
8983 | 1490 /* this function is used to initiate a direct im session with someone. |
1491 * we start listening on a port and send a request. they either connect | |
1492 * or send some kind of reply. If they can't connect, they ask us to | |
1493 * connect to them, and so we do that. | |
1494 * | |
1495 * this function will also get called if the other side initiate's a direct | |
1496 * im and we try to connect and fail. in that case cookie will not be null. | |
1497 * | |
1498 * note that cookie is an 8 byte string that isn't NULL terminated | |
1499 */ | |
11159 | 1500 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie) { |
8971 | 1501 OscarData *od; |
1502 struct oscar_direct_im *dim; | |
1503 int listenfd; | |
8982 | 1504 const char *ip; |
8971 | 1505 |
1506 od = (OscarData *)gc->proto_data; | |
1507 | |
8983 | 1508 dim = oscar_direct_im_find(od, who); |
8971 | 1509 if (dim) { |
1510 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1511 oscar_direct_im_disconnect(od, dim); | |
1512 gaim_debug_info("oscar", | |
1513 "Gave up on old direct IM, trying again\n"); | |
1514 } else { | |
1515 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1516 return; |
8971 | 1517 } |
1518 } | |
1519 dim = g_new0(struct oscar_direct_im, 1); | |
1520 dim->gc = gc; | |
8983 | 1521 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1522 |
1523 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1524 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1525 if (listenfd >= 0) |
1526 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1527 if (dim->conn != NULL) { |
8982 | 1528 char *tmp; |
1529 GaimConversation *conv; | |
1530 | |
8971 | 1531 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1532 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1533 oscar_callback, dim->conn); | |
1534 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1535 gaim_odc_initiate, 0); | |
8982 | 1536 |
8983 | 1537 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1538 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1539 gaim_network_get_port_from_fd(listenfd)); |
1540 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1541 g_free(tmp); | |
8971 | 1542 } else { |
1543 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1544 oscar_direct_im_destroy(od, dim); | |
1545 } | |
8983 | 1546 } |
1547 | |
1548 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1549 GaimConnection *gc = data->gc; | |
1550 | |
1551 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1552 g_free(data->who); | |
1553 g_free(data); | |
1554 return; | |
1555 } | |
1556 | |
1557 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1558 g_free(data->who); |
1559 g_free(data); | |
1560 } | |
1561 | |
1562 /* this is the right click menu cb thingy */ | |
9030 | 1563 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1564 | |
1565 GaimBuddy *buddy; | |
1566 GaimConnection *gc; | |
8971 | 1567 gchar *buf; |
9030 | 1568 struct ask_do_dir_im *data; |
1569 | |
1570 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1571 | |
1572 buddy = (GaimBuddy *) node; | |
1573 gc = gaim_account_get_connection(buddy->account); | |
1574 | |
1575 data = g_new0(struct ask_do_dir_im, 1); | |
1576 data->who = g_strdup(buddy->name); | |
8971 | 1577 data->gc = gc; |
9030 | 1578 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1579 buddy->name); | |
8971 | 1580 |
1581 gaim_request_action(gc, NULL, buf, | |
9030 | 1582 _("Because this reveals your IP address, it " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1583 "may be considered a privacy risk. Do you " |
9030 | 1584 "wish to continue?"), |
1585 0, data, 2, | |
1586 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1587 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1588 g_free(buf); |
1589 } | |
1590 | |
1591 /***************************************************************************** | |
1592 * End scary direct im stuff | |
1593 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1594 |
4617 | 1595 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1596 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1597 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1598 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1599 OscarData *od; |
11214 | 1600 |
2086 | 1601 if (!gc) { |
8660 | 1602 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1603 "oscar callback for closed connection (1).\n"); |
2086 | 1604 return; |
1605 } | |
10458 | 1606 |
7283 | 1607 od = (OscarData *)gc->proto_data; |
2086 | 1608 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1609 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1610 /* oh boy. this is probably bad. i guess the only thing we |
1611 * can really do is return? */ | |
8660 | 1612 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1613 "oscar callback for closed connection (2).\n"); |
8660 | 1614 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1615 return; |
1616 } | |
1617 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1618 if (condition & GAIM_INPUT_READ) { |
4617 | 1619 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1620 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1621 "got information on rendezvous listener\n"); |
4617 | 1622 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1623 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1624 "connection error (rendezvous listener)\n"); |
4617 | 1625 aim_conn_kill(od->sess, &conn); |
8446 | 1626 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1627 } |
1628 } else { | |
4617 | 1629 if (aim_get_command(od->sess, conn) >= 0) { |
1630 aim_rxdispatch(od->sess); | |
6029 | 1631 if (od->killme) { |
8660 | 1632 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1633 return; |
1634 } | |
2086 | 1635 } else { |
1636 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
10444 | 1637 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1638 { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1639 gaim_debug_error("oscar", "Major connection error. i.e. " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1640 "invalid data was received on the oscar TCP stream\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1641 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1642 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1643 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1644 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1645 char *buf; |
10458 | 1646 |
1647 gaim_debug_info("oscar", "Lost connection " | |
1648 "to chat room %s\n", cc->name); | |
1649 | |
1650 buf = g_strdup_printf(_("You have lost your connection " | |
1651 "to chat room %s."), cc->name); | |
1652 if (conv != NULL) | |
9627 | 1653 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1654 else | |
1655 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1656 g_free(buf); |
10458 | 1657 |
1658 oscar_chat_kill(gc, cc); | |
1659 | |
2086 | 1660 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1661 if (od->cnpa > 0) |
1662 gaim_input_remove(od->cnpa); | |
1663 od->cnpa = 0; | |
8660 | 1664 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1665 "removing chatnav input watcher\n"); |
4617 | 1666 while (od->create_rooms) { |
1667 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1668 g_free(cr->name); |
4617 | 1669 od->create_rooms = |
1670 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1671 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1672 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1673 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1674 NULL); |
2086 | 1675 } |
4617 | 1676 aim_conn_kill(od->sess, &conn); |
2086 | 1677 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1678 if (od->paspa > 0) |
1679 gaim_input_remove(od->paspa); | |
1680 od->paspa = 0; | |
8660 | 1681 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1682 "removing authconn input watcher\n"); |
4617 | 1683 aim_conn_kill(od->sess, &conn); |
3694 | 1684 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1685 if (od->emlpa > 0) |
1686 gaim_input_remove(od->emlpa); | |
1687 od->emlpa = 0; | |
8660 | 1688 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1689 "removing email input watcher\n"); |
4617 | 1690 aim_conn_kill(od->sess, &conn); |
4804 | 1691 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1692 if (od->icopa > 0) | |
1693 gaim_input_remove(od->icopa); | |
1694 od->icopa = 0; | |
8660 | 1695 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1696 "removing icon input watcher\n"); |
4804 | 1697 aim_conn_kill(od->sess, &conn); |
2086 | 1698 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1699 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1700 gaim_odc_disconnect(od->sess, conn); |
11214 | 1701 gaim_debug_info("oscar","killing rendezvous connection\n"); |
4617 | 1702 aim_conn_kill(od->sess, &conn); |
2086 | 1703 } else { |
8660 | 1704 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1705 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1706 conn->type); |
4617 | 1707 aim_conn_kill(od->sess, &conn); |
2086 | 1708 } |
1709 } | |
1710 } | |
1711 } | |
1712 } | |
1713 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1714 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1715 { |
5575 | 1716 GaimConnection *gc = data; |
7283 | 1717 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1718 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1719 aim_conn_t *conn; |
2086 | 1720 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1721 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1722 close(source); |
1723 return; | |
1724 } | |
1725 | |
4617 | 1726 od = gc->proto_data; |
1727 sess = od->sess; | |
2086 | 1728 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1729 conn->fd = source; |
2086 | 1730 |
1731 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1732 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1733 return; |
1734 } | |
1735 | |
1736 aim_conn_completeconnect(sess, conn); | |
4617 | 1737 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1738 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1739 | |
8660 | 1740 gaim_debug_info("oscar", |
7282 | 1741 "Screen name sent, waiting for response\n"); |
7283 | 1742 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1743 ck[1] = 0x65; |
2086 | 1744 } |
1745 | |
10444 | 1746 static void |
1747 oscar_login(GaimAccount *account, GaimStatus *status) | |
1748 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1749 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1750 aim_conn_t *conn; |
5575 | 1751 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1752 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
10400 | 1753 GaimStatusType *status_type; |
1754 GaimStatusPrimitive primitive; | |
1755 | |
1756 status_type = gaim_status_get_type(status); | |
1757 primitive = gaim_status_type_get_primitive(status_type); | |
2086 | 1758 |
8660 | 1759 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
10444 | 1760 |
10400 | 1761 if (primitive == GAIM_STATUS_OFFLINE) |
1762 return; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1763 |
8437 | 1764 if (!aim_snvalid(gaim_account_get_username(account))) { |
1765 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1766 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 | 1767 gaim_connection_error(gc, buf); |
1768 g_free(buf); | |
1769 } | |
1770 | |
9975 | 1771 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1772 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1773 } else { |
6622 | 1774 gc->flags |= GAIM_CONNECTION_HTML; |
1775 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1776 } |
5836 | 1777 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1778 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1779 sess = g_new0(aim_session_t, 1); |
11253 | 1780 aim_session_init(sess, TRUE); |
7282 | 1781 /* |
11162 | 1782 * We need an immediate queue because we don't use a while-loop |
7282 | 1783 * to see if things need to be sent. |
1784 */ | |
2086 | 1785 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1786 od->sess = sess; |
2086 | 1787 sess->aux_data = gc; |
1788 | |
9935 | 1789 /* Connect to core Gaim signals */ |
10087 | 1790 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1791 |
11162 | 1792 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
2086 | 1793 if (conn == NULL) { |
10444 | 1794 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1795 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1796 return; |
1797 } | |
1798 | |
4649 | 1799 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1800 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1801 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1802 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1803 |
1804 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1805 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1806 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1807 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1808 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1809 return; |
1810 } | |
7282 | 1811 |
7283 | 1812 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1813 ck[0] = 0x5a; |
5575 | 1814 } |
1815 | |
1816 static void oscar_close(GaimConnection *gc) { | |
7283 | 1817 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1818 |
1819 while (od->oscar_chats) { | |
1820 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1821 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1822 gaim_input_remove(n->inpa); |
2086 | 1823 g_free(n->name); |
1824 g_free(n->show); | |
4617 | 1825 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1826 g_free(n); |
1827 } | |
4617 | 1828 while (od->direct_ims) { |
8971 | 1829 struct oscar_direct_im *n = od->direct_ims->data; |
1830 oscar_direct_im_destroy(od, n); | |
2086 | 1831 } |
4617 | 1832 /* BBB */ |
1833 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1834 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1835 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1836 gaim_xfer_cancel_local(xfer); |
3630 | 1837 } |
4804 | 1838 while (od->requesticon) { |
1839 char *sn = od->requesticon->data; | |
1840 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1841 free(sn); | |
1842 } | |
4738 | 1843 g_hash_table_destroy(od->buddyinfo); |
4617 | 1844 while (od->create_rooms) { |
1845 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1846 g_free(cr->name); |
4617 | 1847 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1848 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1849 } |
4617 | 1850 if (od->email) |
1851 g_free(od->email); | |
1852 if (od->newp) | |
1853 g_free(od->newp); | |
1854 if (od->oldp) | |
1855 g_free(od->oldp); | |
2086 | 1856 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1857 gaim_input_remove(gc->inpa); |
4617 | 1858 if (od->cnpa > 0) |
1859 gaim_input_remove(od->cnpa); | |
1860 if (od->paspa > 0) | |
1861 gaim_input_remove(od->paspa); | |
1862 if (od->emlpa > 0) | |
1863 gaim_input_remove(od->emlpa); | |
4804 | 1864 if (od->icopa > 0) |
1865 gaim_input_remove(od->icopa); | |
6907 | 1866 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1867 gaim_timeout_remove(od->icontimer); |
8341 | 1868 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1869 gaim_timeout_remove(od->getblisttimer); |
8341 | 1870 if (od->getinfotimer > 0) |
1871 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1872 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1873 |
4617 | 1874 aim_session_kill(od->sess); |
1875 g_free(od->sess); | |
1876 od->sess = NULL; | |
2086 | 1877 g_free(gc->proto_data); |
1878 gc->proto_data = NULL; | |
8660 | 1879 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1880 } |
1881 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1882 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1883 GaimConnection *gc = data; |
7283 | 1884 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1885 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1886 aim_conn_t *bosconn; |
2086 | 1887 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1888 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1889 close(source); |
1890 return; | |
1891 } | |
1892 | |
4617 | 1893 od = gc->proto_data; |
1894 sess = od->sess; | |
1895 bosconn = od->conn; | |
4366 | 1896 bosconn->fd = source; |
2086 | 1897 |
1898 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1899 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1900 return; |
1901 } | |
1902 | |
1903 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1904 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1905 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1906 gaim_connection_update_progress(gc, |
7283 | 1907 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1908 ck[4] = 0x61; |
2086 | 1909 } |
1910 | |
4617 | 1911 /* BBB */ |
4656 | 1912 /* |
1913 * This little area in oscar.c is the nexus of file transfer code, | |
1914 * so I wrote a little explanation of what happens. I am such a | |
1915 * ninja. | |
1916 * | |
1917 * The series of events for a file send is: | |
1918 * -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
|
1919 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1920 * listening socket, then asks the remote user to connect to us (and |
1921 * gives them the file name, port, IP, etc.) | |
1922 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1923 * in oscar_sendfile_estblsh) | |
1924 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1925 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1926 * connection. | |
1927 * -We get drunk because file transfer kicks ass. | |
1928 * | |
1929 * The series of events for a file receive is: | |
1930 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1931 * -Gaim user selects file to name and location to save file to and | |
1932 * oscar_xfer_init is called | |
1933 * -It connects to the remote user using the IP they gave us earlier | |
1934 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1935 * them an AIM_CB_OFT_ACK. | |
1936 * -They begin to send us lots of raw data. | |
1937 * -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
|
1938 * the connection. |
4656 | 1939 */ |
1940 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1941 | |
8446 | 1942 /* |
1943 * Miscellaneous xfer functions | |
1944 */ | |
1945 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1946 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1947 GaimXfer *xfer; |
5146 | 1948 struct aim_oft_info *oft_info; |
4656 | 1949 |
1950 while (fts) { | |
1951 xfer = fts->data; | |
5146 | 1952 oft_info = xfer->data; |
1953 | |
8446 | 1954 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1955 return xfer; |
1956 | |
1957 fts = g_slist_next(fts); | |
1958 } | |
1959 | |
1960 return NULL; | |
1961 } | |
1962 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1963 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1964 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1965 GaimXfer *xfer; |
5146 | 1966 struct aim_oft_info *oft_info; |
4656 | 1967 |
1968 while (fts) { | |
1969 xfer = fts->data; | |
5146 | 1970 oft_info = xfer->data; |
1971 | |
1972 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1973 return xfer; |
1974 | |
1975 fts = g_slist_next(fts); | |
1976 } | |
1977 | |
1978 return NULL; | |
1979 } | |
1980 | |
8446 | 1981 static void oscar_xfer_end(GaimXfer *xfer) |
1982 { | |
1983 struct aim_oft_info *oft_info = xfer->data; | |
1984 GaimConnection *gc = oft_info->sess->aux_data; | |
1985 OscarData *od = gc->proto_data; | |
1986 | |
8660 | 1987 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1988 |
1989 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1990 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1991 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1992 } | |
1993 | |
1994 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1995 aim_oft_destroyinfo(oft_info); | |
1996 xfer->data = NULL; | |
1997 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1998 } | |
1999 | |
2000 /* | |
2001 * xfer functions used when receiving files | |
2002 */ | |
2003 | |
11084 | 2004 /* |
2005 * This is a gaim timeout callback for when the clientip looks to be useless (after verifiedip has been tried) | |
2006 * It gives up on the file transfer completely if it doesn't approve of the file transfer status | |
2007 */ | |
2008 static gboolean oscar_clientip_timeout(gpointer data) { | |
2009 GaimXfer *xfer; | |
2010 struct aim_oft_info *oft_info; | |
2011 char *msg = NULL; | |
11214 | 2012 |
11084 | 2013 gaim_debug_info("oscar","AAA - in oscar_clientip_timeout\n"); |
2014 xfer = (GaimXfer*) data; | |
2015 if(xfer->data) { | |
2016 oft_info = (struct aim_oft_info*) xfer->data; | |
11214 | 2017 |
11084 | 2018 /* Check to see if the clientip has produced any results */ |
11214 | 2019 if(!oft_info->success) { |
11084 | 2020 msg = g_strdup_printf(_("Transfer of file %s timed out."),gaim_xfer_get_filename(xfer)); |
2021 gaim_xfer_conversation_write(xfer, msg, TRUE); | |
2022 g_free(msg); | |
2023 gaim_xfer_unref(xfer); | |
2024 gaim_xfer_cancel_local(xfer); | |
11214 | 2025 } else { |
2026 gaim_debug_info("oscar","connection successful; no action taken\n"); | |
11084 | 2027 } |
2028 } | |
2029 return FALSE; | |
2030 } | |
2031 | |
2032 /* | |
2033 * This is a gaim timeout callback for when the verifiedip looks to be useless | |
2034 * It tries the file transfer again using the clientip | |
2035 * | |
2036 * BBB | |
2037 */ | |
2038 static gboolean oscar_verifiedip_timeout(gpointer data) { | |
2039 GaimXfer *xfer; | |
2040 struct aim_oft_info *oft_info; | |
2041 | |
2042 gaim_debug_info("oscar","AAA - in oscar_verifiedip_timeout\n"); | |
2043 xfer = (GaimXfer*) data; | |
2044 if(xfer->data) { | |
2045 oft_info = (struct aim_oft_info*) xfer->data; | |
2046 | |
2047 /* Check to see if the verifiedip has produced any results */ | |
11214 | 2048 if(!oft_info->success) { |
11084 | 2049 /* gaim_xfer_conversation_write(xfer, |
2050 "Attempting file transfer via secondary IP address...", FALSE); */ | |
2051 | |
2052 /* The verifiedip connection has worn out its welcome. Goodbye. */ | |
11214 | 2053 close(oft_info->conn->fd); |
11084 | 2054 aim_conn_kill(oft_info->sess, &oft_info->conn); |
2055 | |
2056 /* Try the file transfer again with the clientip */ | |
2057 g_free(xfer->remote_ip); | |
2058 xfer->remote_ip = g_strdup(oft_info->clientip); | |
11214 | 2059 gaim_debug_info("oscar","attempting connection using clientip: %s\n", xfer->remote_ip); |
11084 | 2060 oscar_xfer_init_recv(xfer); |
11214 | 2061 } else { |
2062 gaim_debug_info("oscar","connection successful; no action taken\n"); | |
11084 | 2063 } |
2064 } | |
2065 return FALSE; | |
2066 } | |
11162 | 2067 |
8446 | 2068 static void oscar_xfer_init_recv(GaimXfer *xfer) |
2069 { | |
2070 struct aim_oft_info *oft_info = xfer->data; | |
2071 GaimConnection *gc = oft_info->sess->aux_data; | |
2072 OscarData *od = gc->proto_data; | |
2073 | |
8660 | 2074 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
11214 | 2075 |
11084 | 2076 /* Start a timer for this ip address |
2077 * If the verifiedip fails, try the clientip | |
2078 * If clientip fails, declare the whole file transfer dead | |
2079 * This xfer reference will be released in oscar_clientip_timeout */ | |
2080 if(xfer->data) { | |
2081 gaim_xfer_ref(xfer); | |
2082 /* If clientip & verifiedip are the same, we must prevent an infinite loop */ | |
2083 if(g_ascii_strcasecmp(xfer->remote_ip, oft_info->verifiedip) == 0 | |
2084 && g_ascii_strcasecmp(oft_info->clientip, oft_info->verifiedip) != 0 ) { | |
2085 gaim_timeout_add(FT_IP_TIMEOUT * 1000, oscar_verifiedip_timeout, xfer); | |
2086 } else { | |
2087 gaim_timeout_add(FT_IP_TIMEOUT * 1000, oscar_clientip_timeout, xfer); | |
2088 } | |
2089 } | |
8446 | 2090 |
11162 | 2091 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS); |
8446 | 2092 if (oft_info->conn) { |
2093 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2094 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
2095 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
11214 | 2096 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); |
8446 | 2097 if (xfer->fd == -1) { |
10654 | 2098 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2099 _("Unable to establish file descriptor.")); |
2100 gaim_xfer_cancel_local(xfer); | |
2101 } | |
2102 } else { | |
10654 | 2103 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2104 _("Unable to create new connection.")); |
2105 gaim_xfer_cancel_local(xfer); | |
2106 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2107 } | |
2108 | |
2109 } | |
2110 | |
2111 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
2112 { | |
10405 | 2113 struct aim_oft_info *oft_info; |
2114 GaimConnection *gc; | |
2115 OscarData *od; | |
2116 | |
2117 g_return_if_fail(xfer != NULL); | |
2118 g_return_if_fail(xfer->data != NULL); | |
2119 | |
2120 oft_info = xfer->data; | |
2121 gc = oft_info->sess->aux_data; | |
2122 od = gc->proto_data; | |
8446 | 2123 |
8660 | 2124 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2125 |
9771 | 2126 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2127 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2128 |
2129 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2130 aim_oft_destroyinfo(oft_info); | |
2131 xfer->data = NULL; | |
2132 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2133 } | |
2134 | |
11159 | 2135 static void oscar_xfer_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2136 { |
2137 struct aim_oft_info *oft_info = xfer->data; | |
2138 | |
2139 /* Update our rolling checksum. Like Walmart, yo. */ | |
2140 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2141 } | |
2142 | |
2143 /* | |
2144 * xfer functions used when sending files | |
2145 */ | |
2146 | |
2147 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2148 { | |
2149 struct aim_oft_info *oft_info = xfer->data; | |
2150 GaimConnection *gc = oft_info->sess->aux_data; | |
2151 OscarData *od = gc->proto_data; | |
2152 int listenfd; | |
2153 | |
8660 | 2154 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2155 |
2156 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2157 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2158 oft_info->fh.name[63] = '\0'; | |
2159 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2160 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2161 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2162 | |
2163 /* Create a listening socket and an associated libfaim conn */ | |
2164 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2165 gaim_xfer_cancel_local(xfer); | |
2166 return; | |
2167 } | |
2168 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2169 oft_info->port = xfer->local_port; | |
2170 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2171 gaim_xfer_cancel_local(xfer); | |
2172 return; | |
2173 } | |
8660 | 2174 gaim_debug_misc("oscar", |
8446 | 2175 "port is %hu, ip is %s\n", |
2176 xfer->local_port, oft_info->clientip); | |
2177 if (oft_info->conn) { | |
2178 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2179 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2180 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2181 } else { | |
10654 | 2182 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2183 _("Unable to establish listener socket.")); |
2184 gaim_xfer_cancel_local(xfer); | |
2185 } | |
2186 } | |
2187 | |
2188 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2189 { | |
2190 struct aim_oft_info *oft_info = xfer->data; | |
2191 GaimConnection *gc = oft_info->sess->aux_data; | |
2192 OscarData *od = gc->proto_data; | |
2193 | |
8660 | 2194 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2195 |
9771 | 2196 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2197 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2198 |
2199 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2200 aim_oft_destroyinfo(oft_info); | |
2201 xfer->data = NULL; | |
2202 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2203 } | |
2204 | |
11159 | 2205 static void oscar_xfer_ack_send(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2206 { |
2207 struct aim_oft_info *oft_info = xfer->data; | |
2208 | |
2209 /* I'm not sure I like how we do this. --marv | |
2210 * I do. AIM file transfers aren't really meant to be thought | |
2211 * of as a transferring just a single file. The rendezvous | |
2212 * establishes a connection between two computers, and then | |
2213 * those computers can use the same connection for transferring | |
2214 * multiple files. So we don't want the Gaim core up and closing | |
2215 * the socket all willy-nilly. We want to do that in the oscar | |
2216 * prpl, whenever one side or the other says they're finished | |
2217 * using the connection. There might be a better way to intercept | |
2218 * the socket from the core, however... --KingAnt | |
2219 */ | |
2220 | |
2221 /* | |
2222 * If we're done sending, intercept the socket from the core ft code | |
2223 * and wait for the other guy to send the "done" OFT packet. | |
2224 */ | |
2225 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2226 gaim_input_remove(xfer->watcher); | |
2227 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2228 xfer->fd = 0; | |
2229 gaim_xfer_set_completed(xfer, TRUE); | |
2230 } | |
2231 } | |
2232 | |
9466 | 2233 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2234 gboolean can_receive = FALSE; | |
2235 OscarData *od = gc->proto_data; | |
2236 | |
11049 | 2237 if (od != NULL) { |
9466 | 2238 aim_userinfo_t *userinfo; |
2239 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2240 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2241 can_receive = TRUE; | |
2242 } | |
2243 | |
2244 return can_receive; | |
2245 } | |
2246 | |
2247 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2248 |
2249 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2250 GaimXfer *xfer; |
5146 | 2251 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2252 const char *ip; |
3752 | 2253 |
9030 | 2254 od = (OscarData *)gc->proto_data; |
2255 | |
4617 | 2256 /* You want to send a file to someone else, you're so generous */ |
2257 | |
2258 /* Build the file transfer handle */ | |
9466 | 2259 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2260 |
5146 | 2261 /* Create the oscar-specific data */ |
8838 | 2262 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2263 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2264 xfer->data = oft_info; |
2265 | |
4617 | 2266 /* Setup our I/O op functions */ |
8446 | 2267 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2268 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2269 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2270 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2271 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2272 |
2273 /* Keep track of this transfer for later */ | |
2274 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2275 | |
2276 /* Now perform the request */ | |
9466 | 2277 if (file) |
2278 gaim_xfer_request_accepted(xfer, file); | |
2279 else | |
2280 gaim_xfer_request(xfer); | |
3630 | 2281 } |
2282 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2283 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2284 GaimConnection *gc = sess->aux_data; |
7283 | 2285 OscarData *od = gc->proto_data; |
6029 | 2286 GaimAccount *account = gc->account; |
2287 aim_conn_t *bosconn; | |
2288 char *host; int port; | |
2289 int i, rc; | |
2086 | 2290 va_list ap; |
2704 | 2291 struct aim_authresp_info *info; |
6029 | 2292 |
5575 | 2293 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2294 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2295 va_start(ap, fr); |
2704 | 2296 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2297 va_end(ap); |
2298 | |
8660 | 2299 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2300 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2301 |
4293 | 2302 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2303 char buf[256]; |
2704 | 2304 switch (info->errorcode) { |
2086 | 2305 case 0x05: |
2306 /* Incorrect nick/password */ | |
6498 | 2307 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2308 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2309 break; |
2310 case 0x11: | |
2311 /* Suspended account */ | |
6498 | 2312 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2313 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2314 break; |
3498 | 2315 case 0x14: |
2316 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2317 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2318 break; |
2086 | 2319 case 0x18: |
2320 /* connecting too frequently */ | |
6498 | 2321 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2322 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 | 2323 break; |
2324 case 0x1c: | |
2325 /* client too old */ | |
6498 | 2326 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2327 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
|
2328 gaim_connection_error(gc, buf); |
2086 | 2329 break; |
2330 default: | |
6623 | 2331 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2332 break; |
2333 } | |
8660 | 2334 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2335 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2336 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2337 "Error URL: %s\n", info->errorurl); |
2086 | 2338 od->killme = TRUE; |
2339 return 1; | |
2340 } | |
2341 | |
2342 | |
9992 | 2343 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2344 |
2704 | 2345 if (info->email) { |
8660 | 2346 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2347 } else { |
8660 | 2348 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2349 } |
10042 | 2350 |
8660 | 2351 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2352 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2353 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2354 aim_conn_kill(sess, &fr->conn); |
2086 | 2355 |
11162 | 2356 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS); |
2086 | 2357 if (bosconn == NULL) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2358 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2359 od->killme = TRUE; |
2360 return 0; | |
2361 } | |
2362 | |
4649 | 2363 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2364 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2365 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2366 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2367 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2368 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2369 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2370 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2371 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2372 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2373 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2374 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2375 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2376 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2377 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2378 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2379 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2380 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2381 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2382 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2383 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2384 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2385 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
|
2386 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2387 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2388 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2389 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2390 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2391 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2392 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
|
2393 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
|
2394 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
|
2395 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2396 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2397 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4642 | 2398 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2399 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2400 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2401 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2402 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2403 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2404 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2405 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2406 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2407 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
|
2408 |
7283 | 2409 od->conn = bosconn; |
2704 | 2410 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2411 if (info->bosip[i] == ':') { | |
2412 port = atoi(&(info->bosip[i+1])); | |
2086 | 2413 break; |
2414 } | |
2415 } | |
2704 | 2416 host = g_strndup(info->bosip, i); |
2086 | 2417 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2418 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2419 g_free(host); |
4366 | 2420 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2421 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2422 od->killme = TRUE; |
2423 return 0; | |
2424 } | |
4293 | 2425 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2426 gaim_input_remove(gc->inpa); |
2704 | 2427 |
7283 | 2428 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2429 ck[3] = 0x64; |
7282 | 2430 |
2086 | 2431 return 1; |
2432 } | |
2433 | |
10464 | 2434 static void |
2435 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2436 { | |
2437 GaimConnection *gc = user_data; | |
2438 OscarData *od = gc->proto_data; | |
2439 aim_session_t *sess = od->sess; | |
2440 | |
2441 aim_auth_securid_send(sess, msg); | |
2442 } | |
2443 | |
2444 static void | |
2445 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2446 { | |
2447 GaimConnection *gc = user_data; | |
2448 OscarData *od = gc->proto_data; | |
2449 | |
2450 /* Disconnect */ | |
2451 gc->wants_to_die = TRUE; | |
2452 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2453 od->killme = TRUE; | |
2454 } | |
2455 | |
2456 static int | |
2457 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2458 { | |
2459 GaimConnection *gc = sess->aux_data; | |
2460 GaimAccount *account = gaim_connection_get_account(gc); | |
2461 gchar *primary; | |
2462 | |
2463 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2464 | |
2465 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2466 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2467 _("Enter the 6 digit number from the digital display."), | |
2468 FALSE, FALSE, NULL, | |
2469 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2470 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2471 gc); | |
2472 g_free(primary); | |
2473 | |
2474 return 1; | |
2475 } | |
2476 | |
7285 | 2477 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2478 struct pieceofcrap { |
5575 | 2479 GaimConnection *gc; |
2086 | 2480 unsigned long offset; |
2481 unsigned long len; | |
2482 char *modname; | |
2483 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2484 aim_conn_t *conn; |
2086 | 2485 unsigned int inpa; |
2486 }; | |
2487 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2488 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2489 { |
2490 struct pieceofcrap *pos = data; | |
7283 | 2491 OscarData *od = pos->gc->proto_data; |
2086 | 2492 char in = '\0'; |
2493 int x = 0; | |
2494 unsigned char m[17]; | |
2495 | |
2496 while (read(pos->fd, &in, 1) == 1) { | |
2497 if (in == '\n') | |
2498 x++; | |
2499 else if (in != '\r') | |
2500 x = 0; | |
2501 if (x == 2) | |
2502 break; | |
2503 in = '\0'; | |
2504 } | |
2505 if (in != '\n') { | |
4056 | 2506 char buf[256]; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2507 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
|
2508 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2509 gaim_notify_warning(pos->gc, NULL, |
7422 | 2510 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2511 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2512 gaim_input_remove(pos->inpa); |
2086 | 2513 close(pos->fd); |
2514 g_free(pos); | |
2515 return; | |
2516 } | |
2517 read(pos->fd, m, 16); | |
2518 m[16] = '\0'; | |
8660 | 2519 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2520 for (x = 0; x < 16; x++) |
8660 | 2521 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2522 | |
2523 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2524 gaim_input_remove(pos->inpa); |
2086 | 2525 close(pos->fd); |
2526 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2527 g_free(pos); | |
2528 } | |
2529 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2530 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2531 struct pieceofcrap *pos = data; |
5420 | 2532 gchar *buf; |
2086 | 2533 |
4366 | 2534 pos->fd = source; |
2535 | |
2086 | 2536 if (source < 0) { |
5420 | 2537 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
|
2538 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2539 gaim_notify_warning(pos->gc, NULL, |
7422 | 2540 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2541 buf); |
5420 | 2542 g_free(buf); |
2086 | 2543 if (pos->modname) |
2544 g_free(pos->modname); | |
2545 g_free(pos); | |
2546 return; | |
2547 } | |
2548 | |
5420 | 2549 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2550 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2551 write(pos->fd, buf, strlen(buf)); | |
5420 | 2552 g_free(buf); |
2086 | 2553 if (pos->modname) |
2554 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2555 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2556 return; |
2557 } | |
2558 | |
2559 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2560 #define AIM_MAX_FILE_SIZE 98304 | |
2561 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2562 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2563 va_list ap; |
2564 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2565 fu32_t offset, len; |
2086 | 2566 char *modname; |
2567 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2568 va_start(ap, fr); |
4200 | 2569 offset = va_arg(ap, fu32_t); |
2570 len = va_arg(ap, fu32_t); | |
2086 | 2571 modname = va_arg(ap, char *); |
2572 va_end(ap); | |
2573 | |
8660 | 2574 gaim_debug_misc("oscar", |
5556 | 2575 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2576 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2577 |
2086 | 2578 if (len == 0) { |
8660 | 2579 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2580 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2581 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2582 return 1; | |
2583 } | |
9625 | 2584 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2585 #if 0 | |
2086 | 2586 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2587 char *buf; | |
2588 int i = 8; | |
2589 if (modname) | |
2590 i += strlen(modname); | |
2591 buf = g_malloc(i); | |
2592 i = 0; | |
2593 if (modname) { | |
2594 memcpy(buf, modname, strlen(modname)); | |
2595 i += strlen(modname); | |
2596 } | |
2597 buf[i++] = offset & 0xff; | |
2598 buf[i++] = (offset >> 8) & 0xff; | |
2599 buf[i++] = (offset >> 16) & 0xff; | |
2600 buf[i++] = (offset >> 24) & 0xff; | |
2601 buf[i++] = len & 0xff; | |
2602 buf[i++] = (len >> 8) & 0xff; | |
2603 buf[i++] = (len >> 16) & 0xff; | |
2604 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2605 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2606 "hashing request\n"); |
2086 | 2607 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2608 g_free(buf); | |
2609 return 1; | |
2610 } | |
9625 | 2611 #endif |
2086 | 2612 |
2613 pos = g_new0(struct pieceofcrap, 1); | |
2614 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2615 pos->conn = fr->conn; |
2086 | 2616 |
2617 pos->offset = offset; | |
2618 pos->len = len; | |
2619 pos->modname = modname ? g_strdup(modname) : NULL; | |
2620 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2621 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2622 char buf[256]; |
2086 | 2623 if (pos->modname) |
2624 g_free(pos->modname); | |
2625 g_free(pos); | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2626 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
|
2627 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2628 gaim_notify_warning(pos->gc, NULL, |
7422 | 2629 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2630 buf); |
2086 | 2631 } |
2632 | |
2633 return 1; | |
2634 } | |
2635 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2636 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2637 GaimConnection *gc = sess->aux_data; |
7283 | 2638 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2639 GaimAccount *account = gaim_connection_get_account(gc); |
7282 | 2640 #if 0 |
2641 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2642 #endif | |
7011 | 2643 va_list ap; |
2644 char *key; | |
2086 | 2645 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2646 va_start(ap, fr); |
2086 | 2647 key = va_arg(ap, char *); |
2648 va_end(ap); | |
2649 | |
4617 | 2650 if (od->icq) { |
3458 | 2651 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
10740 | 2652 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2653 gaim_connection_get_password(gc), &info, key); | |
3458 | 2654 } else { |
2655 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
10740 | 2656 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2657 gaim_connection_get_password(gc), &info, key); | |
3458 | 2658 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2659 |
7283 | 2660 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2661 ck[2] = 0x6c; |
7282 | 2662 |
2086 | 2663 return 1; |
2664 } | |
2665 | |
2675 | 2666 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2667 GaimConnection *gc = sess->aux_data; |
2647 | 2668 struct chat_connection *chatcon; |
2669 static int id = 1; | |
2670 | |
6905 | 2671 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
|
2672 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
|
2673 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
|
2674 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
|
2675 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2676 |
2672 | 2677 aim_clientready(sess, fr->conn); |
2675 | 2678 |
2647 | 2679 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2680 chatcon->id = id; | |
8733 | 2681 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2682 |
2683 return 1; | |
2684 } | |
2685 | |
2675 | 2686 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2687 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2688 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2689 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2690 |
2691 aim_clientready(sess, fr->conn); | |
2692 | |
2693 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2694 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2695 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2696 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2697 |
3694 | 2698 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2699 | |
2700 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2701 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2702 | |
7282 | 2703 aim_email_sendcookies(sess); |
2704 aim_email_activate(sess); | |
3694 | 2705 aim_clientready(sess, fr->conn); |
2706 | |
2707 return 1; | |
2708 } | |
2709 | |
4804 | 2710 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2711 GaimConnection *gc = sess->aux_data; |
7283 | 2712 OscarData *od = gc->proto_data; |
4804 | 2713 |
2714 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2715 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2716 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2717 | |
2718 aim_clientready(sess, fr->conn); | |
2719 | |
4823 | 2720 od->iconconnecting = FALSE; |
2721 | |
4804 | 2722 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2723 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2724 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2725 |
2726 return 1; | |
2727 } | |
2728 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2729 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2730 GaimConnection *gc = data; |
7283 | 2731 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2732 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2733 aim_conn_t *tstconn; |
2086 | 2734 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2735 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2736 close(source); |
2737 return; | |
2738 } | |
2739 | |
4617 | 2740 od = gc->proto_data; |
2741 sess = od->sess; | |
2086 | 2742 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2743 tstconn->fd = source; |
2086 | 2744 |
2745 if (source < 0) { | |
2746 aim_conn_kill(sess, &tstconn); | |
8660 | 2747 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2748 "unable to connect to chatnav server\n"); |
2086 | 2749 return; |
2750 } | |
2751 | |
2752 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2753 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2754 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2755 } |
2756 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2757 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2758 { |
5575 | 2759 GaimConnection *gc = data; |
7283 | 2760 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2761 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2762 aim_conn_t *tstconn; |
2086 | 2763 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2764 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2765 close(source); |
2766 return; | |
2767 } | |
2768 | |
4617 | 2769 od = gc->proto_data; |
2770 sess = od->sess; | |
2086 | 2771 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2772 tstconn->fd = source; |
2086 | 2773 |
2774 if (source < 0) { | |
2775 aim_conn_kill(sess, &tstconn); | |
8660 | 2776 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2777 "unable to connect to authorizer\n"); |
2086 | 2778 return; |
2779 } | |
2780 | |
2781 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2782 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2783 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2784 } |
2785 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2786 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2787 { |
2788 struct chat_connection *ccon = data; | |
5575 | 2789 GaimConnection *gc = ccon->gc; |
7283 | 2790 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2791 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2792 aim_conn_t *tstconn; |
2086 | 2793 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2794 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2795 close(source); |
2796 g_free(ccon->show); | |
2797 g_free(ccon->name); | |
2798 g_free(ccon); | |
2799 return; | |
2800 } | |
2801 | |
4617 | 2802 od = gc->proto_data; |
2803 sess = od->sess; | |
2086 | 2804 tstconn = ccon->conn; |
4366 | 2805 tstconn->fd = source; |
2086 | 2806 |
2807 if (source < 0) { | |
2808 aim_conn_kill(sess, &tstconn); | |
2809 g_free(ccon->show); | |
2810 g_free(ccon->name); | |
2811 g_free(ccon); | |
2812 return; | |
2813 } | |
2814 | |
2815 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2816 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2817 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2818 } |
2819 | |
3694 | 2820 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2821 GaimConnection *gc = data; |
7283 | 2822 OscarData *od; |
3694 | 2823 aim_session_t *sess; |
2824 aim_conn_t *tstconn; | |
2825 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2826 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2827 close(source); |
2828 return; | |
2829 } | |
2830 | |
4617 | 2831 od = gc->proto_data; |
2832 sess = od->sess; | |
3694 | 2833 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2834 tstconn->fd = source; |
3694 | 2835 |
2836 if (source < 0) { | |
2837 aim_conn_kill(sess, &tstconn); | |
8660 | 2838 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2839 "unable to connect to email server\n"); |
3694 | 2840 return; |
2841 } | |
2842 | |
2843 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2844 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2845 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2846 "email: connected\n"); |
3694 | 2847 } |
2848 | |
4804 | 2849 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2850 GaimConnection *gc = data; |
7283 | 2851 OscarData *od; |
4804 | 2852 aim_session_t *sess; |
2853 aim_conn_t *tstconn; | |
2854 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2855 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2856 close(source); |
2857 return; | |
2858 } | |
2859 | |
2860 od = gc->proto_data; | |
2861 sess = od->sess; | |
2862 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2863 tstconn->fd = source; | |
2864 | |
2865 if (source < 0) { | |
2866 aim_conn_kill(sess, &tstconn); | |
8660 | 2867 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2868 "unable to connect to icon server\n"); |
4804 | 2869 return; |
2870 } | |
2871 | |
2872 aim_conn_completeconnect(sess, tstconn); | |
2873 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2874 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2875 } |
2876 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2877 /* 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
|
2878 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2879 GaimConnection *gc = sess->aux_data; |
2880 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2881 aim_conn_t *tstconn; |
4452 | 2882 int i; |
2086 | 2883 char *host; |
2884 int port; | |
4821 | 2885 va_list ap; |
2886 struct aim_redirect_data *redir; | |
2086 | 2887 |
5575 | 2888 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2889 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2890 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2891 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2892 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2893 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2894 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2895 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2896 port = atoi(&(redir->ip[i+1])); |
2086 | 2897 break; |
2898 } | |
2899 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2900 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2901 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2902 switch(redir->group) { |
2086 | 2903 case 0x7: /* Authorizer */ |
8660 | 2904 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2905 "Reconnecting with authorizor...\n"); |
11162 | 2906 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
2086 | 2907 if (tstconn == NULL) { |
8660 | 2908 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2909 "unable to reconnect with authorizer\n"); |
2086 | 2910 g_free(host); |
2911 return 1; | |
2912 } | |
4649 | 2913 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2914 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2915 |
2916 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2917 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2918 aim_conn_kill(sess, &tstconn); |
8660 | 2919 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2920 "unable to reconnect with authorizer\n"); |
2086 | 2921 g_free(host); |
2922 return 1; | |
2923 } | |
4293 | 2924 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2925 break; |
2926 | |
2086 | 2927 case 0xd: /* ChatNav */ |
11162 | 2928 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV); |
2086 | 2929 if (tstconn == NULL) { |
8660 | 2930 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2931 "unable to connect to chatnav server\n"); |
2086 | 2932 g_free(host); |
2933 return 1; | |
2934 } | |
4649 | 2935 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2936 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2937 |
2938 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2939 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2940 aim_conn_kill(sess, &tstconn); |
8660 | 2941 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2942 "unable to connect to chatnav server\n"); |
2086 | 2943 g_free(host); |
2944 return 1; | |
2945 } | |
4293 | 2946 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2947 break; |
2948 | |
2949 case 0xe: { /* Chat */ | |
2086 | 2950 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2951 |
11162 | 2952 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT); |
2086 | 2953 if (tstconn == NULL) { |
8660 | 2954 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2955 "unable to connect to chat server\n"); |
2086 | 2956 g_free(host); |
2957 return 1; | |
2958 } | |
2959 | |
4649 | 2960 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2961 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2962 | |
2086 | 2963 ccon = g_new0(struct chat_connection, 1); |
2964 ccon->conn = tstconn; | |
2965 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2966 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2967 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2968 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2969 ccon->show = extract_name(redir->chat.room); |
4634 | 2970 |
2086 | 2971 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2972 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2973 aim_conn_kill(sess, &tstconn); |
8660 | 2974 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2975 "unable to connect to chat server\n"); |
2086 | 2976 g_free(host); |
2977 g_free(ccon->show); | |
2978 g_free(ccon->name); | |
2979 g_free(ccon); | |
2980 return 1; | |
2981 } | |
4293 | 2982 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2983 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2984 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2985 ccon->name, ccon->exchange); |
4194 | 2986 } break; |
3694 | 2987 |
4804 | 2988 case 0x0010: { /* icon */ |
11162 | 2989 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON))) { |
8660 | 2990 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2991 "unable to connect to icon server\n"); |
4804 | 2992 g_free(host); |
2993 return 1; | |
2994 } | |
2995 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2996 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2997 | |
2998 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2999 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 3000 aim_conn_kill(sess, &tstconn); |
8660 | 3001 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3002 "unable to connect to icon server\n"); |
4804 | 3003 g_free(host); |
3004 return 1; | |
3005 } | |
3006 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
3007 } break; | |
3008 | |
3694 | 3009 case 0x0018: { /* email */ |
11162 | 3010 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL))) { |
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 email server\n"); |
3694 | 3013 g_free(host); |
3014 return 1; | |
3015 } | |
4649 | 3016 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 3017 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
3018 | |
3019 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3020 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 3021 aim_conn_kill(sess, &tstconn); |
8660 | 3022 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3023 "unable to connect to email server\n"); |
3694 | 3024 g_free(host); |
3025 return 1; | |
3026 } | |
4293 | 3027 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 3028 } break; |
3029 | |
2086 | 3030 default: /* huh? */ |
8660 | 3031 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3032 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3033 redir->group); |
2086 | 3034 break; |
3035 } | |
3036 | |
3037 g_free(host); | |
3038 return 1; | |
3039 } | |
3040 | |
10042 | 3041 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
3042 { | |
3043 GaimConnection *gc; | |
3044 GaimAccount *account; | |
3045 OscarData *od; | |
4738 | 3046 struct buddyinfo *bi; |
2993 | 3047 time_t time_idle = 0, signon = 0; |
3048 int type = 0; | |
3049 int caps = 0; | |
2086 | 3050 va_list ap; |
4738 | 3051 aim_userinfo_t *info; |
10042 | 3052 gboolean buddy_is_away = FALSE; |
3053 | |
3054 gc = sess->aux_data; | |
3055 account = gaim_connection_get_account(gc); | |
3056 od = gc->proto_data; | |
4194 | 3057 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3058 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3059 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3060 va_end(ap); |
3061 | |
10130 | 3062 g_return_val_if_fail(info != NULL, 1); |
3063 g_return_val_if_fail(info->sn != NULL, 1); | |
3064 | |
2993 | 3065 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
3066 caps = info->capabilities; | |
3267 | 3067 |
4766 | 3068 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
3069 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 3070 buddy_is_away = TRUE; |
3071 } | |
3072 | |
2993 | 3073 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 3074 type = (info->icqinfo.status << 16); |
3013 | 3075 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3076 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3077 buddy_is_away = TRUE; |
3013 | 3078 } |
2993 | 3079 } |
3080 | |
7141 | 3081 if (caps & AIM_CAPS_ICQ_DIRECT) |
3082 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 3083 |
10860 | 3084 /* info->idletime is the number of minutes that this user has been idle */ |
3085 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
3086 time_idle = time(NULL) - info->idletime * 60; | |
2993 | 3087 |
5836 | 3088 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3089 signon = info->onlinesince; | |
3090 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3091 signon = time(NULL) - info->sessionlen; |
2086 | 3092 |
10567 | 3093 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3094 gaim_connection_set_display_name(gc, info->sn); |
10567 | 3095 od->timeoffset = signon - gc->login_time; |
3096 } | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
3097 |
9982 | 3098 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3099 if (!bi) { |
3100 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3101 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3102 } |
4739 | 3103 bi->typingnot = FALSE; |
3104 bi->ico_informed = FALSE; | |
6857 | 3105 bi->ipaddr = info->icqinfo.ipaddr; |
3106 | |
10563 | 3107 /* |
3108 * Handle the available message. If info->avail is NULL then the user | |
3109 * may or may not have an available message, so don't do anything. If | |
3110 * info->avail is set to the empty string, then the user's client DOES | |
3111 * support available messages and the user DOES NOT have one set. | |
3112 * Otherwise info->avail contains the available message. | |
3113 */ | |
7011 | 3114 if (info->avail != NULL) |
10563 | 3115 { |
3116 free(bi->availmsg); | |
3117 if (info->avail[0] != '\0') | |
3118 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); | |
3119 else | |
3120 bi->availmsg = NULL; | |
3121 } | |
4732 | 3122 |
4804 | 3123 /* Server stored icon stuff */ |
4853 | 3124 if (info->iconcsumlen) { |
7125 | 3125 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3126 char *b16 = NULL, *filepath = NULL; |
7093 | 3127 GaimBuddy *b = NULL; |
4853 | 3128 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3129 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3130 b = gaim_find_buddy(account, info->sn); |
7093 | 3131 /* |
3132 * If for some reason the checksum is valid, but cached file is not.. | |
3133 * we want to know. | |
3134 */ | |
7693 | 3135 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3136 if (filename != NULL) { |
3137 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3138 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3139 "icon_checksum"); | |
9801 | 3140 else { |
3141 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3142 filename, NULL); | |
3143 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3144 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3145 "icon_checksum"); | |
3146 g_free(filepath); | |
3147 } | |
7093 | 3148 } else |
3149 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3150 |
4853 | 3151 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3152 GSList *cur = od->requesticon; | |
3153 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3154 cur = cur->next; | |
3155 if (!cur) { | |
9982 | 3156 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3157 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3158 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3159 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3160 } |
3161 } | |
6053 | 3162 g_free(b16); |
4853 | 3163 } |
3164 | |
10042 | 3165 /* XXX - Represent other ICQ statuses */ |
3166 if (buddy_is_away == TRUE) | |
3167 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
3168 else | |
3169 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
10567 | 3170 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
9982 | 3171 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); |
3172 | |
3173 if (time_idle > 0) | |
3174 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 3175 else |
3176 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 3177 |
3178 return 1; | |
3179 } | |
3180 | |
8341 | 3181 static void gaim_check_comment(OscarData *od, const char *str) { |
11159 | 3182 if ((str == NULL) || strcmp(str, (const char *)ck)) |
8341 | 3183 aim_locate_setcaps(od->sess, caps_aim); |
3184 else | |
3185 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3186 } | |
3187 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3188 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3189 GaimConnection *gc = sess->aux_data; |
7283 | 3190 OscarData *od = gc->proto_data; |
9982 | 3191 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3192 va_list ap; |
4739 | 3193 aim_userinfo_t *info; |
2086 | 3194 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3195 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3196 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3197 va_end(ap); |
3198 | |
9982 | 3199 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3200 |
7261 | 3201 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3202 |
2086 | 3203 return 1; |
3204 } | |
3205 | |
4617 | 3206 /* BBB */ |
3952 | 3207 /* |
4617 | 3208 * This is called after a remote AIM user has connected to us. We |
3209 * want to do some voodoo with the socket file descriptors, add a | |
3210 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3211 */ |
4656 | 3212 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3213 GaimConnection *gc = sess->aux_data; |
7283 | 3214 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3215 GaimXfer *xfer; |
5146 | 3216 struct aim_oft_info *oft_info; |
3630 | 3217 va_list ap; |
3218 aim_conn_t *conn, *listenerconn; | |
4656 | 3219 |
8660 | 3220 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3221 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3222 va_start(ap, fr); |
3223 conn = va_arg(ap, aim_conn_t *); | |
3224 listenerconn = va_arg(ap, aim_conn_t *); | |
3225 va_end(ap); | |
3226 | |
4617 | 3227 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3228 return 1; | |
3229 | |
5146 | 3230 if (!(oft_info = xfer->data)) |
4617 | 3231 return 1; |
3232 | |
3630 | 3233 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3234 gaim_input_remove(xfer->watcher); |
3630 | 3235 aim_conn_kill(sess, &listenerconn); |
3236 | |
5146 | 3237 oft_info->conn = conn; |
3238 xfer->fd = oft_info->conn->fd; | |
3239 | |
3240 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3241 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3242 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3243 |
3244 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3245 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3246 |
3247 return 0; | |
3248 } | |
3249 | |
3952 | 3250 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3251 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3252 * user in order to transfer a file. |
3952 | 3253 */ |
4617 | 3254 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
|
3255 GaimXfer *xfer; |
5146 | 3256 struct aim_oft_info *oft_info; |
4656 | 3257 |
8660 | 3258 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3259 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3260 if (!(xfer = data)) |
3261 return; | |
5146 | 3262 if (!(oft_info = xfer->data)) |
3630 | 3263 return; |
8446 | 3264 if (source < 0) { |
11214 | 3265 /* This will also be called 3 minutes after the verifiedip times out. |
3266 * However, we might have made a successful connection with the clientip | |
3267 * so we need to make sure the verifiedip's failures aren't taken out | |
3268 * on the poor little clientip, which might actually have been a success. */ | |
3269 if(oft_info->success) { | |
3270 gaim_debug_info("oscar","fd of %d for verifiedip, but clientip succeeded; ignoring\n", | |
3271 source); | |
3272 return; | |
3273 } else { | |
3274 gaim_debug_info("oscar","received fd of %d; aborting transfer\n", source); | |
3275 gaim_xfer_cancel_remote(xfer); | |
3276 return; | |
3277 } | |
3278 } | |
3279 | |
3280 gaim_debug_info("oscar","marking connection as success; fd is %d\n", source); | |
3281 oft_info->success = TRUE; /* Mark this connection as successful before it times out */ | |
4617 | 3282 |
3283 xfer->fd = source; | |
5146 | 3284 oft_info->conn->fd = source; |
3285 | |
3286 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3287 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3288 |
3289 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3290 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3291 |
3292 return; | |
3630 | 3293 } |
3294 | |
3952 | 3295 /* |
4617 | 3296 * This is called when a buddy sends us some file info. This happens when they |
3297 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3298 * You should send them the exact same info except use the real cookie. We also |
4617 | 3299 * get like totally ready to like, receive the file, kay? |
3952 | 3300 */ |
4617 | 3301 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3302 GaimConnection *gc = sess->aux_data; |
7283 | 3303 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3304 GaimXfer *xfer; |
5146 | 3305 struct aim_oft_info *oft_info; |
4617 | 3306 va_list ap; |
3307 aim_conn_t *conn; | |
3308 fu8_t *cookie; | |
3309 struct aim_fileheader_t *fh; | |
4656 | 3310 |
8660 | 3311 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3312 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3313 va_start(ap, fr); |
3314 conn = va_arg(ap, aim_conn_t *); | |
3315 cookie = va_arg(ap, fu8_t *); | |
3316 fh = va_arg(ap, struct aim_fileheader_t *); | |
3317 va_end(ap); | |
3318 | |
3319 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3320 return 1; | |
3321 | |
5146 | 3322 if (!(oft_info = xfer->data)) |
4617 | 3323 return 1; |
3324 | |
3325 /* We want to stop listening with a normal thingy */ | |
3326 gaim_input_remove(xfer->watcher); | |
3327 xfer->watcher = 0; | |
3328 | |
5146 | 3329 /* They sent us some information about the file they're sending */ |
3330 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3331 | |
3332 /* Fill in the cookie */ | |
3333 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3334 | |
4617 | 3335 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3336 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3337 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3338 | |
3339 return 0; | |
3630 | 3340 } |
3341 | |
3952 | 3342 /* |
4657 | 3343 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3344 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3345 */ |
4617 | 3346 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3347 GaimConnection *gc = sess->aux_data; |
7283 | 3348 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3349 GaimXfer *xfer; |
4617 | 3350 va_list ap; |
3351 aim_conn_t *conn; | |
3352 fu8_t *cookie; | |
3353 struct aim_fileheader_t *fh; | |
4656 | 3354 |
8660 | 3355 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3356 va_start(ap, fr); |
3357 conn = va_arg(ap, aim_conn_t *); | |
3358 cookie = va_arg(ap, fu8_t *); | |
3359 fh = va_arg(ap, struct aim_fileheader_t *); | |
3360 va_end(ap); | |
3361 | |
3362 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3363 return 1; | |
3364 | |
4656 | 3365 /* We want to stop listening with a normal thingy */ |
3366 gaim_input_remove(xfer->watcher); | |
3367 xfer->watcher = 0; | |
3368 | |
4617 | 3369 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3370 | |
3371 return 0; | |
3630 | 3372 } |
4617 | 3373 |
3374 /* | |
3375 * We just sent a file to someone. They said they got it and everything, | |
3376 * so we can close our direct connection and what not. | |
3377 */ | |
3378 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3379 GaimConnection *gc = sess->aux_data; |
7283 | 3380 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3381 GaimXfer *xfer; |
4617 | 3382 va_list ap; |
3383 aim_conn_t *conn; | |
3384 fu8_t *cookie; | |
3385 struct aim_fileheader_t *fh; | |
4656 | 3386 |
8660 | 3387 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3388 va_start(ap, fr); |
3389 conn = va_arg(ap, aim_conn_t *); | |
3390 cookie = va_arg(ap, fu8_t *); | |
3391 fh = va_arg(ap, struct aim_fileheader_t *); | |
3392 va_end(ap); | |
3393 | |
3394 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3395 return 1; | |
3396 | |
4656 | 3397 xfer->fd = conn->fd; |
4617 | 3398 gaim_xfer_end(xfer); |
3399 | |
3400 return 0; | |
3401 } | |
3630 | 3402 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3403 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3404 GaimConnection *gc = sess->aux_data; |
7283 | 3405 OscarData *od = gc->proto_data; |
8708 | 3406 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3407 GaimConvImFlags flags = 0; |
4738 | 3408 struct buddyinfo *bi; |
5575 | 3409 const char *iconfile; |
9806 | 3410 GString *message; |
3411 gchar *tmp; | |
3412 aim_mpmsg_section_t *curpart; | |
3413 | |
10472 | 3414 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3415 userinfo->sn, args->mpmsg.numparts); |
4738 | 3416 |
10595 | 3417 if (args->mpmsg.numparts == 0) |
3418 return 1; | |
3419 | |
8708 | 3420 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3421 if (!bi) { |
3422 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3423 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3424 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3425 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3426 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3427 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3428 |
4738 | 3429 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3430 bi->typingnot = TRUE; | |
3431 else | |
3432 bi->typingnot = FALSE; | |
3433 | |
4380 | 3434 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3435 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3436 "%s has an icon\n", userinfo->sn); |
4738 | 3437 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3438 bi->ico_need = TRUE; | |
3439 bi->ico_len = args->iconlen; | |
3440 bi->ico_csum = args->iconsum; | |
3441 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3442 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3443 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3444 |
10458 | 3445 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3446 (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
|
3447 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3448 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3449 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3450 if (!g_stat(iconfile, &st)) { |
11159 | 3451 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3452 file = g_fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3453 if (file) { |
9532 | 3454 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3455 int len = fread(buf, 1, st.st_size, file); |
8660 | 3456 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3457 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3458 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3459 userinfo->sn, len, st.st_size); |
4617 | 3460 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3461 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3462 fclose(file); |
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 open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3466 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3467 } else |
8660 | 3468 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3469 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3470 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3471 |
9806 | 3472 message = g_string_new(""); |
3473 curpart = args->mpmsg.parts; | |
3474 while (curpart != NULL) { | |
11159 | 3475 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, |
3476 curpart->charsubset, curpart->data, curpart->datalen); | |
9806 | 3477 if (tmp != NULL) { |
3478 g_string_append(message, tmp); | |
3479 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3480 } |
9806 | 3481 |
3482 curpart = curpart->next; | |
3483 } | |
3484 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3485 |
8666 | 3486 /* |
10781 | 3487 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
9016 | 3488 * because HTML is not sent over ICQ as a means to format a message. |
10781 | 3489 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
3490 * replaced with <br> | |
8995 | 3491 * |
3492 * Note: There *may* be some clients which send messages as HTML formatted - | |
3493 * they need to be special-cased somehow. | |
8666 | 3494 */ |
9982 | 3495 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3496 /* 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
|
3497 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
8493 | 3498 g_free(tmp); |
3499 tmp = tmp2; | |
10783 | 3500 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
10781 | 3501 g_free(tmp); |
3502 tmp = tmp2; | |
8493 | 3503 } |
3504 | |
6982 | 3505 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3506 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3507 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3508 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3509 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3510 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3511 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3512 GaimConnection *gc; |
9933 | 3513 GaimAccount *account; |
9070 | 3514 OscarData *od; |
9933 | 3515 const char *username = NULL; |
3516 char *message = NULL; | |
9070 | 3517 |
3518 g_return_val_if_fail(sess != NULL, 0); | |
3519 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3520 | |
3521 gc = sess->aux_data; | |
9933 | 3522 account = gaim_connection_get_account(gc); |
9070 | 3523 od = gc->proto_data; |
9933 | 3524 username = gaim_account_get_username(account); |
3525 | |
3526 if (args == NULL) | |
4121 | 3527 return 0; |
4194 | 3528 |
9933 | 3529 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3530 userinfo->sn, args->status); | |
3531 | |
3532 if (args->msg != NULL) | |
3533 { | |
3534 if (args->encoding != NULL) | |
3535 { | |
3536 char *encoding = NULL; | |
3537 encoding = oscar_encoding_extract(args->encoding); | |
3538 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3539 g_free(encoding); | |
3540 } else { | |
3541 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3542 message = g_strdup(args->msg); | |
3543 } | |
3544 } | |
2869 | 3545 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3546 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3547 char *name; |
5234 | 3548 GHashTable *components; |
3549 | |
9933 | 3550 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3551 g_free(message); | |
4121 | 3552 return 1; |
9933 | 3553 } |
5234 | 3554 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3555 g_free); | |
4121 | 3556 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3557 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3558 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
|
3559 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3560 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3561 userinfo->sn, |
9933 | 3562 message, |
5234 | 3563 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3564 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3565 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3566 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3567 /* BBB */ |
3568 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3569 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3570 GaimXfer *xfer; |
5146 | 3571 struct aim_oft_info *oft_info; |
3572 | |
3573 if (!args->cookie || !args->port || !args->verifiedip || | |
3574 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3575 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3576 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3577 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3578 "information.\n", userinfo->sn); |
5146 | 3579 if (args->proxyip) |
8660 | 3580 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3581 "IP for a proxy server was given. Gaim " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3582 "does not support this yet.\n"); |
9933 | 3583 g_free(message); |
4617 | 3584 return 1; |
4656 | 3585 } |
4617 | 3586 |
3587 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3588 /* 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
|
3589 * directory -- remove the star and trailing slash so we don't save |
4617 | 3590 * directories that look like 'dirname\*' -- arl */ |
3591 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3592 if (tmp && (tmp[1] == '*')) { | |
3593 tmp[0] = '\0'; | |
3594 } | |
8660 | 3595 gaim_debug_warning("oscar", |
8446 | 3596 "We're receiving a whole directory! What fun! " |
3597 "Especially since we don't support that!\n"); | |
4617 | 3598 } |
3599 | |
3600 /* Build the file transfer handle */ | |
3601 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3602 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3603 xfer->remote_port = args->port; |
11238 | 3604 |
3605 if (g_utf8_validate(args->info.sendfile.filename, -1, | |
3606 NULL)) { | |
3607 gaim_xfer_set_filename(xfer, | |
3608 args->info.sendfile.filename); | |
3609 } else { | |
3610 gchar * utf8_filename = gaim_utf8_salvage( | |
3611 args->info.sendfile.filename); | |
3612 gaim_xfer_set_filename(xfer, utf8_filename); | |
3613 g_free(utf8_filename); | |
3614 } | |
3615 | |
4617 | 3616 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); |
11084 | 3617 |
3618 /* Ignore <ICQ_COOL_FT> XML that is sent along with ICQ sendfile requests */ | |
3619 if(g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13)) { | |
3620 gaim_debug_info("oscar","Ignoring ICQ file transfer message: %s\n", message); | |
3621 g_free(message); | |
3622 message = NULL; | |
3623 } | |
9933 | 3624 gaim_xfer_set_message(xfer, message); |
5146 | 3625 |
3626 /* Create the oscar-specific data */ | |
5163 | 3627 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3628 if (args->proxyip) |
5146 | 3629 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3630 if (args->verifiedip) |
5146 | 3631 oft_info->verifiedip = g_strdup(args->verifiedip); |
3632 xfer->data = oft_info; | |
4617 | 3633 |
3634 /* Setup our I/O op functions */ | |
8446 | 3635 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3636 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3637 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
|
3638 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3639 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3640 |
3641 /* Keep track of this transfer for later */ | |
3642 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3643 | |
3644 /* Now perform the request */ | |
3645 gaim_xfer_request(xfer); | |
3646 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3647 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3648 GaimXfer *xfer; |
8660 | 3649 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3650 "AAA - File transfer canceled by remote user\n"); |
4617 | 3651 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
|
3652 gaim_xfer_cancel_remote(xfer); |
4617 | 3653 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3654 /* | |
3655 * This gets sent by the receiver of a file | |
3656 * as they connect directly to us. If we don't | |
3657 * get this, then maybe a third party connected | |
3658 * to us, and we shouldn't send them anything. | |
3659 */ | |
11214 | 3660 gaim_debug_info("oscar", |
3661 "AAA - received chan 2 AIM_RENDEZVOUS_ACCEPT; ignoring\n"); | |
4617 | 3662 } else { |
8660 | 3663 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3664 "unknown rendezvous status!\n"); |
3630 | 3665 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3666 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3667 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3668 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3669 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3670 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3671 args->info.icon.length); |
6871 | 3672 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3673 /* 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
|
3674 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3675 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
|
3676 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3677 |
4212 | 3678 if (!args->verifiedip) { |
8983 | 3679 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3680 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3681 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3682 g_free(message); |
4650 | 3683 return 1; |
4212 | 3684 } |
3685 | |
8660 | 3686 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3687 "%s received direct im request from %s (%s)\n", |
10594 | 3688 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3689 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3690 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3691 d->sn = g_strdup(userinfo->sn); |
8983 | 3692 /* Let's use the clientip here, because I think that's what AIM does. |
3693 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3694 * and then ask them to connect to us. */ | |
10594 | 3695 /* |
3696 * I disagree, let's use the verifiedip. I think AIM tries the | |
3697 * verified IP first, then tries the client IP if that fails. In | |
3698 * any case, there's a better chance the verified IP will be correct. | |
3699 * The client IP is what the other person _thinks_ their IP address | |
3700 * is. The verified IP is the address that the AIM server sees the | |
3701 * other person using. | |
3702 */ | |
3703 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
|
3704 memcpy(d->cookie, args->cookie, 8); |
9070 | 3705 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3706 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3707 | |
8971 | 3708 oscar_direct_im_destroy(od, dim); |
8984 | 3709 d->donttryagain = TRUE; |
8971 | 3710 accept_direct_im_request(d); |
3711 } else { | |
8983 | 3712 if (dim && !dim->connected) |
8971 | 3713 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3714 "already connected to that buddy!"); | |
5575 | 3715 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
|
3716 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3717 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3718 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3719 "the two computers and is necessary for IM " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3720 "Images. Because your IP address will be " |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3721 "revealed, this may be considered a privacy " |
9972 | 3722 "risk."), |
3723 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3724 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3725 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3726 /* FIXME: we should actually send a packet on cancel */ | |
3727 } | |
8708 | 3728 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3729 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
|
3730 } else { |
8660 | 3731 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3732 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3733 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3734 |
9933 | 3735 g_free(message); |
3736 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3737 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3738 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3739 |
3453 | 3740 /* |
4230 | 3741 * Authorization Functions |
3742 * Most of these are callbacks from dialogs. They're used by both | |
3743 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3744 */ |
4269 | 3745 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3746 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3747 GaimConnection *gc = data->gc; |
4244 | 3748 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3749 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3750 OscarData *od = gc->proto_data; |
6695 | 3751 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3752 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3753 if (buddy && group) { |
8660 | 3754 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3755 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3756 buddy->name, group->name); |
4889 | 3757 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3758 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3759 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3760 } |
4230 | 3761 } |
4337 | 3762 } |
3763 | |
3764 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3765 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3766 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3767 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3768 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3769 data); |
4230 | 3770 } |
3771 | |
3772 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3773 GaimConnection *gc = data->gc; |
4244 | 3774 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3775 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3776 /* Remove from local list */ |
3777 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3778 gaim_blist_remove_buddy(b); | |
4244 | 3779 } |
3780 | |
5836 | 3781 oscar_free_name_data(data); |
4230 | 3782 } |
3783 | |
9030 | 3784 |
3785 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3786 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3787 GaimBuddy *buddy; |
4269 | 3788 gchar *dialog_msg, *nombre; |
3789 | |
4687 | 3790 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3791 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3792 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3793 else |
4830 | 3794 nombre = NULL; |
3795 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3796 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 | 3797 data->gc = gc; |
3798 data->name = g_strdup(name); | |
3799 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3800 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3801 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3802 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3803 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3804 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3805 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3806 |
3807 g_free(dialog_msg); | |
3808 g_free(nombre); | |
3809 } | |
3810 | |
9030 | 3811 |
3812 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3813 GaimBuddy *buddy; | |
3814 GaimConnection *gc; | |
3815 | |
3816 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3817 | |
3818 buddy = (GaimBuddy *) node; | |
3819 gc = gaim_account_get_connection(buddy->account); | |
3820 gaim_auth_sendrequest(gc, buddy->name); | |
3821 } | |
3822 | |
4230 | 3823 /* When other people ask you for authorization */ |
3824 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3825 GaimConnection *gc = data->gc; |
4244 | 3826 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3827 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3828 OscarData *od = gc->proto_data; |
4889 | 3829 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4244 | 3830 } |
3831 | |
5836 | 3832 oscar_free_name_data(data); |
3141 | 3833 } |
3834 | |
4230 | 3835 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3836 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3837 GaimConnection *gc = data->gc; |
4244 | 3838 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3839 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3840 OscarData *od = gc->proto_data; |
4889 | 3841 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4244 | 3842 } |
4337 | 3843 } |
3844 | |
3845 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3846 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3847 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3848 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3849 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3850 data); |
3141 | 3851 } |
3852 | |
7023 | 3853 /* When someone sends you buddies */ |
3854 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3855 GaimConnection *gc = data->gc; |
4244 | 3856 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3857 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3858 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3859 } |
3860 | |
5836 | 3861 oscar_free_name_data(data); |
3453 | 3862 } |
3863 | |
4075 | 3864 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 | 3865 GaimConnection *gc = sess->aux_data; |
9908 | 3866 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3867 gchar **msg1, **msg2; |
6051 | 3868 int i, numtoks; |
4076 | 3869 |
4121 | 3870 if (!args->type || !args->msg || !args->uin) |
3871 return 1; | |
4194 | 3872 |
8660 | 3873 gaim_debug_info("oscar", |
9908 | 3874 "Received a channel 4 message of type 0x%02hhx.\n", |
3875 args->type); | |
4076 | 3876 |
9919 | 3877 /* |
3878 * Split up the message at the delimeter character, then convert each | |
3879 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3880 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3881 * character in whatever encoding the message was sent in. Type 1 | |
3882 * messages are always made up of only one part, so we can easily account | |
3883 * for this suck-ass part of the protocol by splitting the string into at | |
3884 * most 1 baby string. | |
3885 */ | |
3886 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3887 for (numtoks=0; msg1[numtoks]; numtoks++); |
3888 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3889 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3890 gaim_str_strip_cr(msg1[i]); |
9908 | 3891 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3892 } |
3893 msg2[i] = NULL; | |
3894 | |
3952 | 3895 switch (args->type) { |
4173 | 3896 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3897 if (i >= 1) { |
5556 | 3898 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3899 gchar *tmp; |
3900 | |
3901 /* 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
|
3902 tmp = g_markup_escape_text(msg2[0], -1); |
8493 | 3903 |
4076 | 3904 if (t) { /* This is an offline message */ |
9680 | 3905 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3906 #ifdef HAVE_TM_GMTOFF |
9724 | 3907 time_t now; |
3908 struct tm *tm; | |
3909 now = time(NULL); | |
3910 tm = localtime(&now); | |
3911 t += tm->tm_gmtoff; | |
9698 | 3912 #else |
3913 # ifdef HAVE_TIMEZONE | |
9680 | 3914 tzset(); |
3915 t -= timezone; | |
9698 | 3916 # endif |
3917 #endif | |
8514 | 3918 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3919 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3920 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3921 } |
3922 g_free(uin); | |
8493 | 3923 g_free(tmp); |
4075 | 3924 } |
3316 | 3925 } break; |
3926 | |
4173 | 3927 case 0x04: { /* Someone sent you a URL */ |
4076 | 3928 if (i >= 2) { |
7385 | 3929 if (msg2[1] != NULL) { |
3930 gchar *uin = g_strdup_printf("%u", args->uin); | |
3931 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3932 msg2[1], | |
3933 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3934 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3935 g_free(uin); | |
3936 g_free(message); | |
3937 } | |
3453 | 3938 } |
3939 } break; | |
3940 | |
4173 | 3941 case 0x06: { /* Someone requested authorization */ |
4076 | 3942 if (i >= 6) { |
4230 | 3943 struct name_data *data = g_new(struct name_data, 1); |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3944 gchar *sn = g_strdup_printf("%u", args->uin); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3945 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3946 gchar *dialog_msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3947 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3948 if (msg2[5] != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3949 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
|
3950 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3951 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3952 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3953 dialog_msg = g_strdup_printf( |
10949 | 3954 _("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
|
3955 args->uin, gaim_account_get_username(gc->account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3956 g_free(reason); |
8660 | 3957 gaim_debug_info("oscar", |
5556 | 3958 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3959 args->uin); |
4076 | 3960 data->gc = gc; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3961 data->name = sn; |
4230 | 3962 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3963 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3964 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3965 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3966 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3967 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3968 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3969 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3970 g_free(dialog_msg); |
3971 } | |
3141 | 3972 } break; |
3973 | |
4173 | 3974 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3975 if (i >= 1) { |
7023 | 3976 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
|
3977 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3978 dialog_msg); |
4076 | 3979 g_free(dialog_msg); |
3980 } | |
3141 | 3981 } break; |
3982 | |
4173 | 3983 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3984 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
|
3985 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3986 dialog_msg); |
3141 | 3987 g_free(dialog_msg); |
3988 } break; | |
3989 | |
4333 | 3990 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3991 if (i >= 5) { | |
3992 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
|
3993 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3994 g_free(dialog_msg); |
3995 } | |
3996 } break; | |
3997 | |
4173 | 3998 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3999 if (i >= 6) { |
4194 | 4000 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
|
4001 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 4002 g_free(dialog_msg); |
4003 } | |
4075 | 4004 } break; |
4005 | |
4173 | 4006 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 4007 if (i >= 6) { |
4308 | 4008 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
|
4009 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 4010 g_free(dialog_msg); |
4011 } | |
4075 | 4012 } break; |
4013 | |
4173 | 4014 case 0x12: { |
3141 | 4015 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 4016 /* Someone added you to their buddy list? */ |
3141 | 4017 } break; |
4018 | |
7023 | 4019 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 4020 guint i, num; |
3453 | 4021 gchar **text; |
4173 | 4022 text = g_strsplit(args->msg, "\376", 0); |
3453 | 4023 if (text) { |
4024 num = 0; | |
4025 for (i=0; i<strlen(text[0]); i++) | |
4026 num = num*10 + text[0][i]-48; | |
4027 for (i=0; i<num; i++) { | |
4230 | 4028 struct name_data *data = g_new(struct name_data, 1); |
7023 | 4029 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 | 4030 data->gc = gc; |
4790 | 4031 data->name = g_strdup(text[i*2+1]); |
4032 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4033 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4034 gaim_request_action(gc, NULL, message, |
7023 | 4035 _("Do you want to add this buddy " |
4036 "to your buddy list?"), | |
9972 | 4037 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 4038 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 4039 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 4040 g_free(message); |
4041 } | |
4042 g_strfreev(text); | |
4043 } | |
4044 } break; | |
4045 | |
7023 | 4046 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 4047 /* This is boring and silly. */ |
4048 } break; | |
4049 | |
3141 | 4050 default: { |
8660 | 4051 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4052 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4053 "(type 0x%02hhx).\n", args->type); |
3141 | 4054 } break; |
4055 } | |
4056 | |
4076 | 4057 g_strfreev(msg1); |
4058 g_strfreev(msg2); | |
4059 | |
3141 | 4060 return 1; |
4061 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4062 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4063 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 4064 fu16_t channel; |
4065 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4066 aim_userinfo_t *userinfo; |
2086 | 4067 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4068 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4069 va_start(ap, fr); |
4200 | 4070 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4071 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4072 |
3141 | 4073 switch (channel) { |
4074 case 1: { /* standard message */ | |
4075 struct aim_incomingim_ch1_args *args; | |
4076 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
4077 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
4078 } break; | |
4079 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
4080 case 2: { /* rendezvous */ |
3141 | 4081 struct aim_incomingim_ch2_args *args; |
4082 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
4083 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
4084 } break; | |
4085 | |
4086 case 4: { /* ICQ */ | |
4087 struct aim_incomingim_ch4_args *args; | |
4088 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 4089 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 4090 } break; |
4091 | |
4092 default: { | |
8660 | 4093 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4094 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4095 "0x%04hx).", channel); |
3141 | 4096 } break; |
2086 | 4097 } |
4098 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4099 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4100 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4101 return ret; |
2086 | 4102 } |
4103 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4104 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 4105 GaimConnection *gc = sess->aux_data; |
4106 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 4107 char *buf; |
2086 | 4108 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4109 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4110 aim_userinfo_t *userinfo; |
2086 | 4111 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4112 va_start(ap, fr); |
4200 | 4113 chan = (fu16_t)va_arg(ap, unsigned int); |
4114 userinfo = va_arg(ap, aim_userinfo_t *); | |
4115 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
4116 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 4117 va_end(ap); |
4118 | |
4119 switch(reason) { | |
5420 | 4120 case 0: /* Invalid (0) */ |
4121 buf = g_strdup_printf( | |
4122 ngettext( | |
4276 | 4123 "You missed %hu message from %s because it was invalid.", |
4124 "You missed %hu messages from %s because they were invalid.", | |
4125 nummissed), | |
4282 | 4126 nummissed, |
4127 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4128 break; |
5420 | 4129 case 1: /* Message too large */ |
4130 buf = g_strdup_printf( | |
4131 ngettext( | |
4276 | 4132 "You missed %hu message from %s because it was too large.", |
4133 "You missed %hu messages from %s because they were too large.", | |
4134 nummissed), | |
4282 | 4135 nummissed, |
4136 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4137 break; |
5420 | 4138 case 2: /* Rate exceeded */ |
4139 buf = g_strdup_printf( | |
4140 ngettext( | |
4276 | 4141 "You missed %hu message from %s because the rate limit has been exceeded.", |
4142 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
4143 nummissed), | |
4282 | 4144 nummissed, |
4145 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4146 break; |
5420 | 4147 case 3: /* Evil Sender */ |
4148 buf = g_strdup_printf( | |
4149 ngettext( | |
4276 | 4150 "You missed %hu message from %s because he/she was too evil.", |
4151 "You missed %hu messages from %s because he/she was too evil.", | |
4152 nummissed), | |
4282 | 4153 nummissed, |
4154 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4155 break; |
5420 | 4156 case 4: /* Evil Receiver */ |
4157 buf = g_strdup_printf( | |
4158 ngettext( | |
4276 | 4159 "You missed %hu message from %s because you are too evil.", |
4160 "You missed %hu messages from %s because you are too evil.", | |
4161 nummissed), | |
4282 | 4162 nummissed, |
4163 userinfo->sn); | |
2086 | 4164 break; |
4165 default: | |
5420 | 4166 buf = g_strdup_printf( |
4167 ngettext( | |
4276 | 4168 "You missed %hu message from %s for an unknown reason.", |
4169 "You missed %hu messages from %s for an unknown reason.", | |
4170 nummissed), | |
4282 | 4171 nummissed, |
4172 userinfo->sn); | |
2086 | 4173 break; |
4174 } | |
8733 | 4175 |
9627 | 4176 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4177 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4178 g_free(buf); |
2086 | 4179 |
4180 return 1; | |
4181 } | |
4182 | |
11159 | 4183 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const guchar *cookie) { |
5575 | 4184 GaimConnection *gc = sess->aux_data; |
7283 | 4185 OscarData *od = gc->proto_data; |
4617 | 4186 |
4187 /* BBB */ | |
3630 | 4188 switch (reason) { |
4151 | 4189 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4190 GaimXfer *xfer; |
8971 | 4191 struct oscar_direct_im *dim; |
4192 | |
8660 | 4193 gaim_debug_info("oscar", |
9070 | 4194 "AAA - Other user declined some sort of direct " |
8971 | 4195 "connect attempt (automaticly?)\n"); |
4617 | 4196 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
|
4197 gaim_xfer_cancel_remote(xfer); |
8971 | 4198 else if ((dim = oscar_direct_im_find(od, who))) { |
4199 /* AAA should use find by cookie or something here */ | |
4200 oscar_direct_im_disconnect(od, dim); | |
4201 } | |
4151 | 4202 } break; |
4203 | |
4204 default: { | |
8660 | 4205 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4206 "Received an unknown rendezvous client auto-response " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4207 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4208 } |
3630 | 4209 |
4210 } | |
4211 | |
4212 return 0; | |
4213 } | |
4214 | |
4194 | 4215 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4216 GaimConnection *gc = sess->aux_data; |
4151 | 4217 |
4218 switch(reason) { | |
4219 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4220 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4221 | |
4222 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4223 |
4224 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4225 statusmsg = oscar_icqstatus(state); |
4151 | 4226 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4227 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4228 g_free(statusmsg); | |
4151 | 4229 g_strfreev(splitmsg); |
9244 | 4230 |
9797 | 4231 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4232 |
4233 g_free(title); | |
4234 g_free(dialogmsg); | |
4151 | 4235 } break; |
4236 | |
4237 default: { | |
8660 | 4238 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4239 "Received an unknown client auto-response from %s. " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4240 "Type 0x%04hx\n", who, reason); |
4151 | 4241 } break; |
4242 } /* end of switch */ | |
4243 | |
4244 return 0; | |
4245 } | |
4246 | |
3212 | 4247 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4248 va_list ap; | |
4249 fu16_t chan, reason; | |
4250 char *who; | |
4251 | |
4252 va_start(ap, fr); | |
4200 | 4253 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4254 who = va_arg(ap, char *); |
4200 | 4255 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4256 |
3952 | 4257 if (chan == 0x0002) { /* File transfer declined */ |
11159 | 4258 guchar *cookie = va_arg(ap, guchar *); |
4151 | 4259 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4260 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4261 fu32_t state = 0; |
4151 | 4262 char *msg = NULL; |
4263 if (reason == 0x0003) { | |
4200 | 4264 state = va_arg(ap, fu32_t); |
4151 | 4265 msg = va_arg(ap, char *); |
4266 } | |
4267 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4268 } | |
3952 | 4269 |
3212 | 4270 va_end(ap); |
4271 | |
4272 return 1; | |
4273 } | |
4274 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4275 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4276 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4277 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4278 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4279 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4280 va_start(ap, fr); |
4199 | 4281 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4282 va_end(ap); |
4283 | |
8660 | 4284 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4285 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4286 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4287 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4288 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4289 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4290 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4291 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4292 |
2086 | 4293 return 1; |
4294 } | |
4295 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4296 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4297 GaimConnection *gc = sess->aux_data; |
4617 | 4298 #if 0 |
7283 | 4299 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4300 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4301 #endif |
4617 | 4302 va_list ap; |
4303 fu16_t reason; | |
4304 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4305 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4306 va_start(ap, fr); |
4617 | 4307 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4308 data = va_arg(ap, char *); |
2086 | 4309 va_end(ap); |
4310 | |
8660 | 4311 gaim_debug_error("oscar", |
10130 | 4312 "Message error with data %s and reason %hu\n", |
4313 (data != NULL ? data : ""), reason); | |
4617 | 4314 |
4315 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4316 #if 0 |
4617 | 4317 /* If this was a file transfer request, data is a cookie */ |
4318 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
|
4319 gaim_xfer_cancel_remote(xfer); |
3630 | 4320 return 1; |
4321 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4322 #endif |
3630 | 4323 |
4617 | 4324 /* Data is assumed to be the destination sn */ |
9826 | 4325 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4326 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4327 g_free(buf); | |
4328 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4329 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4330 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4331 } | |
4332 g_free(buf); | |
4333 | |
2086 | 4334 return 1; |
4335 } | |
4336 | |
3595 | 4337 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4338 GaimConnection *gc = sess->aux_data; |
3595 | 4339 va_list ap; |
4340 fu16_t type1, type2; | |
4341 char *sn; | |
4342 | |
4343 va_start(ap, fr); | |
4199 | 4344 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4345 sn = va_arg(ap, char *); |
4199 | 4346 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4347 va_end(ap); |
4348 | |
4349 switch (type2) { | |
4350 case 0x0000: { /* Text has been cleared */ | |
4351 serv_got_typing_stopped(gc, sn); | |
4352 } break; | |
4353 | |
4354 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4355 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4356 } break; |
4357 | |
4358 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4359 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4360 } break; |
4361 | |
4362 default: { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4363 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 | 4364 } break; |
4365 } | |
4366 | |
4367 return 1; | |
4368 } | |
4369 | |
7141 | 4370 /* |
4371 * We get this error when there was an error in the locate family. This | |
7259 | 4372 * happens when you request info of someone who is offline. |
7141 | 4373 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4374 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4375 gchar *buf; |
2086 | 4376 va_list ap; |
5420 | 4377 fu16_t reason; |
2086 | 4378 char *destn; |
4379 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4380 va_start(ap, fr); |
4199 | 4381 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4382 destn = va_arg(ap, char *); |
4383 va_end(ap); | |
4384 | |
7781 | 4385 if (destn == NULL) |
7793 | 4386 return 1; |
10560 | 4387 |
9826 | 4388 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4389 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4390 g_free(buf); | |
9627 | 4391 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4392 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4393 } | |
4394 g_free(buf); | |
2086 | 4395 |
4396 return 1; | |
4397 } | |
4398 | |
7011 | 4399 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4400 GaimConnection *gc = sess->aux_data; |
8700 | 4401 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 4402 OscarData *od = gc->proto_data; |
8700 | 4403 GString *str; |
9244 | 4404 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4405 va_list ap; |
7011 | 4406 aim_userinfo_t *userinfo; |
2086 | 4407 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4408 va_start(ap, fr); |
7011 | 4409 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4410 va_end(ap); |
4411 | |
8700 | 4412 str = g_string_new(""); |
4413 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4414 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4415 |
10116 | 4416 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 4417 time_t t = userinfo->onlinesince - od->timeoffset; |
10116 | 4418 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); |
4419 } | |
4420 | |
4421 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 4422 time_t t = userinfo->membersince - od->timeoffset; |
10116 | 4423 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); |
4424 } | |
7011 | 4425 |
4426 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4427 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4428 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4429 g_free(tmp); |
4430 } | |
4431 | |
8701 | 4432 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4433 |
4434 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4435 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4436 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4437 g_free(tmp); | |
7011 | 4438 if (away_utf8 != NULL) { |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4439 g_string_append_printf(str, "\n<hr>%s<br>", away_utf8); |
7011 | 4440 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4441 } |
7011 | 4442 } |
4443 | |
4444 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4445 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4446 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4447 g_free(tmp); | |
7011 | 4448 if (info_utf8 != NULL) { |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4449 g_string_append_printf(str, "\n<hr>%s<br>", info_utf8); |
7011 | 4450 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4451 } |
7011 | 4452 } |
4453 | |
8701 | 4454 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4455 g_string_free(str, TRUE); |
9244 | 4456 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4457 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4458 g_free(title); |
8700 | 4459 g_free(tmp); |
4151 | 4460 |
2086 | 4461 return 1; |
4462 } | |
4463 | |
8341 | 4464 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4465 { | |
4466 aim_session_t *sess = data; | |
4467 GaimConnection *gc = sess->aux_data; | |
4468 OscarData *od = (OscarData *)gc->proto_data; | |
4469 | |
4470 aim_locate_dorequest(data); | |
4471 od->getinfotimer = 0; | |
4472 | |
4473 return FALSE; | |
4474 } | |
4475 | |
4476 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4477 { | |
4478 GaimConnection *gc = sess->aux_data; | |
4479 OscarData *od = (OscarData *)gc->proto_data; | |
4480 | |
4481 /* | |
4482 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4483 * us from hitting the rate limit due to request away messages and info | |
4484 * too quickly. | |
4485 */ | |
4486 if (od->getinfotimer == 0) | |
10198 | 4487 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4488 |
4489 return 1; | |
4490 } | |
4491 | |
4492 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4493 { | |
2086 | 4494 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4495 fu16_t id; |
2086 | 4496 va_list ap; |
4497 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4498 va_start(ap, fr); |
4199 | 4499 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4500 msg = va_arg(ap, char *); |
4501 va_end(ap); | |
4502 | |
8660 | 4503 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4504 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4505 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4506 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4507 _("Your AIM connection may be lost."), NULL); |
2086 | 4508 |
4509 return 1; | |
4510 } | |
4511 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4512 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4513 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4514 fu16_t type; |
5575 | 4515 GaimConnection *gc = sess->aux_data; |
7283 | 4516 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4517 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4518 va_start(ap, fr); |
4199 | 4519 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4520 |
4521 switch(type) { | |
4522 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4523 fu8_t maxrooms; |
2086 | 4524 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4525 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4526 |
4199 | 4527 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4528 exchangecount = va_arg(ap, int); |
4529 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4530 | |
8660 | 4531 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4532 "chat info: Chat Rights:\n"); |
8660 | 4533 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4534 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4535 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4536 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4537 for (i = 0; i < exchangecount; i++) |
8660 | 4538 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4539 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4540 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4541 while (od->create_rooms) { |
4542 struct create_room *cr = od->create_rooms->data; | |
8660 | 4543 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4544 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4545 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4546 g_free(cr->name); |
4617 | 4547 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4548 g_free(cr); |
2086 | 4549 } |
4550 } | |
4551 break; | |
4552 case 0x0008: { | |
4553 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4554 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4555 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4556 fu32_t createtime; |
2086 | 4557 |
4558 fqcn = va_arg(ap, char *); | |
4200 | 4559 instance = (fu16_t)va_arg(ap, unsigned int); |
4560 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4561 flags = (fu16_t)va_arg(ap, unsigned int); | |
4562 createtime = va_arg(ap, fu32_t); | |
4563 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4564 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4565 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4566 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4567 name = va_arg(ap, char *); | |
4568 ck = va_arg(ap, char *); | |
4194 | 4569 |
8660 | 4570 gaim_debug_misc("oscar", |
5556 | 4571 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4572 fqcn, |
4573 exchange, instance, flags, | |
4574 createtime, | |
4575 maxmsglen, maxoccupancy, createperms, unknown, | |
4576 name, ck); | |
4617 | 4577 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4578 } |
4579 break; | |
4580 default: | |
8660 | 4581 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4582 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4583 break; |
4584 } | |
4194 | 4585 |
4586 va_end(ap); | |
4587 | |
2086 | 4588 return 1; |
4589 } | |
4590 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4591 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4592 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4593 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4594 aim_userinfo_t *info; |
5575 | 4595 GaimConnection *g = sess->aux_data; |
2086 | 4596 |
4597 struct chat_connection *c = NULL; | |
4598 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4599 va_start(ap, fr); |
2086 | 4600 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4601 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4602 va_end(ap); |
4603 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4604 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4605 if (!c) |
4606 return 1; | |
4607 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4608 for (i = 0; i < count; i++) |
9846 | 4609 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4610 |
4611 return 1; | |
4612 } | |
4613 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4614 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4615 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4616 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4617 aim_userinfo_t *info; |
5575 | 4618 GaimConnection *g = sess->aux_data; |
2086 | 4619 |
4620 struct chat_connection *c = NULL; | |
4621 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4622 va_start(ap, fr); |
2086 | 4623 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4624 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4625 va_end(ap); |
4626 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4627 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4628 if (!c) |
4629 return 1; | |
4630 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4631 for (i = 0; i < count; i++) |
8733 | 4632 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4633 |
4634 return 1; | |
4635 } | |
4636 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4637 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
|
4638 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4639 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4640 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4641 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4642 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4643 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4644 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4645 fu32_t creationtime; |
5575 | 4646 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4647 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
|
4648 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4649 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4650 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4651 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4652 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4653 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4654 roomdesc = va_arg(ap, char *); |
4200 | 4655 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4656 creationtime = va_arg(ap, fu32_t); | |
4657 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4658 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4659 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4660 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4661 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4662 |
8660 | 4663 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4664 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4665 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4666 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4667 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4668 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4669 |
2086 | 4670 return 1; |
4671 } | |
4672 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4673 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4674 GaimConnection *gc = sess->aux_data; |
8225 | 4675 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4676 gchar *utf8; | |
2086 | 4677 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4678 aim_userinfo_t *info; |
8225 | 4679 int len; |
2086 | 4680 char *msg; |
8219 | 4681 char *charset; |
2086 | 4682 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4683 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4684 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4685 len = va_arg(ap, int); |
4194 | 4686 msg = va_arg(ap, char *); |
8219 | 4687 charset = va_arg(ap, char *); |
4194 | 4688 va_end(ap); |
2086 | 4689 |
8225 | 4690 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4691 if (utf8 == NULL) |
4692 /* The conversion failed! */ | |
8668 | 4693 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4694 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4695 g_free(utf8); | |
2086 | 4696 |
4697 return 1; | |
4698 } | |
4699 | |
3694 | 4700 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4701 va_list ap; | |
5575 | 4702 GaimConnection *gc = sess->aux_data; |
3694 | 4703 struct aim_emailinfo *emailinfo; |
3725 | 4704 int havenewmail; |
7297 | 4705 char *alertitle, *alerturl; |
3694 | 4706 |
4707 va_start(ap, fr); | |
4708 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4709 havenewmail = va_arg(ap, int); |
7301 | 4710 alertitle = va_arg(ap, char *); |
4711 alerturl = va_arg(ap, char *); | |
3694 | 4712 va_end(ap); |
4713 | |
9661 | 4714 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4715 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4716 emailinfo->domain ? "@" : "", | |
4717 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4718 if (emailinfo->unread && havenewmail) |
4719 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4720 g_free(to); |
3694 | 4721 } |
10157 | 4722 |
7301 | 4723 if (alertitle) |
8660 | 4724 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4725 |
4726 return 1; | |
4727 } | |
4728 | |
4804 | 4729 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4730 GaimConnection *gc = sess->aux_data; |
7283 | 4731 OscarData *od = gc->proto_data; |
4804 | 4732 char *sn; |
4733 | |
4734 sn = od->requesticon->data; | |
8660 | 4735 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4736 "removing %s from hash table\n", sn); |
4804 | 4737 od->requesticon = g_slist_remove(od->requesticon, sn); |
4738 free(sn); | |
4739 | |
4740 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4741 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4742 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4743 |
4744 return 1; | |
4745 } | |
4746 | |
4747 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4748 GaimConnection *gc = sess->aux_data; |
7283 | 4749 OscarData *od = gc->proto_data; |
4804 | 4750 GSList *cur; |
4751 va_list ap; | |
4752 char *sn; | |
11024 | 4753 fu8_t iconcsumtype, *iconcsum, *icon; |
4853 | 4754 fu16_t iconcsumlen, iconlen; |
4804 | 4755 |
4756 va_start(ap, fr); | |
4757 sn = va_arg(ap, char *); | |
11024 | 4758 iconcsumtype = va_arg(ap, int); |
4853 | 4759 iconcsum = va_arg(ap, fu8_t *); |
4760 iconcsumlen = va_arg(ap, int); | |
4804 | 4761 icon = va_arg(ap, fu8_t *); |
4762 iconlen = va_arg(ap, int); | |
4763 va_end(ap); | |
4764 | |
11024 | 4765 /* |
4766 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
4767 * no icon is set. Ignore these. | |
4768 */ | |
4769 if ((iconlen > 0) && (iconlen != 90)) { | |
4853 | 4770 char *b16; |
6695 | 4771 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4772 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4773 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4774 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4775 if (b16) { |
7693 | 4776 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4777 g_free(b16); |
5129 | 4778 } |
4853 | 4779 } |
4804 | 4780 |
4781 cur = od->requesticon; | |
4782 while (cur) { | |
4783 char *cursn = cur->data; | |
4784 if (!aim_sncmp(cursn, sn)) { | |
4785 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4786 free(cursn); | |
4787 cur = od->requesticon; | |
4788 } else | |
4789 cur = cur->next; | |
4790 } | |
4791 | |
4792 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4793 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4794 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4795 |
4796 return 1; | |
4797 } | |
4798 | |
4799 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4800 GaimConnection *gc = data; |
7283 | 4801 OscarData *od = gc->proto_data; |
7011 | 4802 aim_userinfo_t *userinfo; |
4804 | 4803 aim_conn_t *conn; |
4804 | |
4805 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4806 if (!conn) { |
4807 if (!od->iconconnecting) { | |
4808 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4809 od->iconconnecting = TRUE; | |
4810 } | |
4804 | 4811 return FALSE; |
4812 } | |
4813 | |
5842 | 4814 if (od->set_icon) { |
6039 | 4815 struct stat st; |
4816 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4817 if (iconfile == NULL) { | |
8363 | 4818 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4819 } else if (!g_stat(iconfile, &st)) { |
11159 | 4820 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4821 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 4822 if (file) { |
9532 | 4823 /* XXX - Use g_file_get_contents()? */ |
6039 | 4824 fread(buf, 1, st.st_size, file); |
4825 fclose(file); | |
8660 | 4826 gaim_debug_info("oscar", |
6039 | 4827 "Uploading icon to icon server\n"); |
6879 | 4828 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4829 } else |
8660 | 4830 gaim_debug_error("oscar", |
6039 | 4831 "Can't open buddy icon file!\n"); |
4832 g_free(buf); | |
4833 } else { | |
8660 | 4834 gaim_debug_error("oscar", |
6039 | 4835 "Can't stat buddy icon file!\n"); |
5842 | 4836 } |
4837 od->set_icon = FALSE; | |
4838 } | |
4839 | |
4840 if (!od->requesticon) { | |
8660 | 4841 gaim_debug_misc("oscar", |
5842 | 4842 "no more icons to request\n"); |
4843 return FALSE; | |
4844 } | |
4845 | |
7045 | 4846 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4847 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
11024 | 4848 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
4804 | 4849 return FALSE; |
4850 } else { | |
4851 char *sn = od->requesticon->data; | |
4852 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4853 free(sn); | |
4854 } | |
4855 | |
4856 return TRUE; | |
4857 } | |
4858 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4859 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4860 * 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
|
4861 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4862 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4863 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4864 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4865 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4866 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4867 va_start(ap, fr); |
4199 | 4868 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4869 sn = va_arg(ap, char *); |
4870 va_end(ap); | |
4871 | |
8660 | 4872 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4873 |
4874 return 1; | |
4875 } | |
4876 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4877 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
|
4878 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4879 "invalid", |
4194 | 4880 "change", |
4881 "warning", | |
4882 "limit", | |
4883 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4884 }; |
2086 | 4885 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4886 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4887 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4888 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4889 va_start(ap, fr); |
4200 | 4890 code = (fu16_t)va_arg(ap, unsigned int); |
4891 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4892 windowsize = va_arg(ap, fu32_t); | |
4893 clear = va_arg(ap, fu32_t); | |
4894 alert = va_arg(ap, fu32_t); | |
4895 limit = va_arg(ap, fu32_t); | |
4896 disconnect = va_arg(ap, fu32_t); | |
4897 currentavg = va_arg(ap, fu32_t); | |
4898 maxavg = va_arg(ap, fu32_t); | |
2086 | 4899 va_end(ap); |
4900 | |
8660 | 4901 gaim_debug_misc("oscar", |
5556 | 4902 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4903 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4904 (code < 5) ? codes[code] : codes[0], |
4905 rateclass, | |
4906 currentavg, maxavg, | |
4907 alert, clear, | |
4908 limit, disconnect, | |
4909 windowsize); | |
4910 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4911 /* XXX fix these values */ |
2086 | 4912 if (code == AIM_RATE_CODE_CHANGE) { |
4913 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4914 aim_conn_setlatency(fr->conn, 0); |
2086 | 4915 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4916 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4917 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4918 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4919 _("The last action you attempted could not be " |
4920 "performed because you are over the rate limit. " | |
4921 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4922 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4923 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4924 aim_conn_setlatency(fr->conn, 0); |
2086 | 4925 } |
4926 | |
4927 return 1; | |
4928 } | |
4929 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4930 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4931 GaimConnection *gc = sess->aux_data; |
4932 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4933 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4934 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4935 aim_userinfo_t *userinfo; |
2086 | 4936 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4937 va_start(ap, fr); |
4199 | 4938 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4939 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4940 va_end(ap); |
4941 | |
9982 | 4942 /* XXX - What's with the + 0.5? */ |
4943 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4944 |
4945 return 1; | |
4946 } | |
4947 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4948 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4949 GaimConnection *gc = sess->aux_data; |
4950 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4951 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4952 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4953 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4954 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4955 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4956 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4957 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4958 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4959 |
9982 | 4960 warning_level = info->warnlevel/10.0 + 0.5; |
4961 | |
10152 | 4962 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4963 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4964 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4965 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4966 |
4649 | 4967 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4968 GaimConnection *gc = sess->aux_data; |
7283 | 4969 OscarData *od = gc->proto_data; |
4649 | 4970 va_list ap; |
4971 fu16_t code; | |
4972 char *msg; | |
4973 | |
4974 va_start(ap, fr); | |
4975 code = (fu16_t)va_arg(ap, int); | |
4976 msg = va_arg(ap, char *); | |
4977 va_end(ap); | |
4978 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4979 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
10458 | 4980 code, (msg != NULL ? msg : "")); |
4981 | |
4982 g_return_val_if_fail(fr != NULL, 1); | |
4983 g_return_val_if_fail(fr->conn != NULL, 1); | |
4984 | |
4985 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 4986 if (code == 0x0001) { |
6113 | 4987 gc->wants_to_die = TRUE; |
10715 | 4988 gaim_connection_error(gc, _("You have signed on from another location.")); |
4651 | 4989 } else { |
5579 | 4990 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4991 } |
4666 | 4992 od->killme = TRUE; |
10458 | 4993 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
4994 struct chat_connection *cc; | |
4995 GaimConversation *conv; | |
4996 | |
4997 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
4998 conv = gaim_find_chat(gc, cc->id); | |
4999 | |
5000 if (conv != NULL) | |
5001 { | |
5002 gchar *buf; | |
5003 buf = g_strdup_printf(_("You have been disconnected from chat " | |
5004 "room %s."), cc->name); | |
5005 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
5006 g_free(buf); | |
5007 } | |
5008 oscar_chat_kill(gc, cc); | |
4649 | 5009 } |
5010 | |
5011 return 1; | |
5012 } | |
5013 | |
2675 | 5014 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 5015 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5016 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5017 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 5018 |
8660 | 5019 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 5020 aim_ssi_reqrights(sess); |
6350 | 5021 aim_ssi_reqdata(sess); |
4230 | 5022 |
7011 | 5023 aim_locate_reqrights(sess); |
7285 | 5024 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 5025 aim_im_reqparams(sess); |
7334 | 5026 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 5027 |
7283 | 5028 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
5029 | |
2086 | 5030 return 1; |
5031 } | |
5032 | |
2675 | 5033 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5034 GaimConnection *gc = sess->aux_data; |
7283 | 5035 OscarData *od = gc->proto_data; |
2647 | 5036 |
6905 | 5037 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
5038 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
5039 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
5040 | |
2672 | 5041 aim_clientready(sess, fr->conn); |
8660 | 5042 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5043 |
2647 | 5044 if (od->chpass) { |
8660 | 5045 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5046 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 5047 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5048 od->oldp = NULL; |
2647 | 5049 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5050 od->newp = NULL; |
2647 | 5051 od->chpass = FALSE; |
5052 } | |
2979 | 5053 if (od->setnick) { |
8660 | 5054 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 5055 aim_admin_setnick(sess, fr->conn, od->newsn); |
5056 g_free(od->newsn); | |
5057 od->newsn = NULL; | |
5058 od->setnick = FALSE; | |
5059 } | |
2647 | 5060 if (od->conf) { |
8660 | 5061 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5062 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 5063 od->conf = FALSE; |
5064 } | |
5065 if (od->reqemail) { | |
8660 | 5066 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5067 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 5068 od->reqemail = FALSE; |
5069 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5070 if (od->setemail) { |
8660 | 5071 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5072 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5073 g_free(od->email); |
5497 | 5074 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5075 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5076 } |
2647 | 5077 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5078 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5079 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5080 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5081 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
|
5082 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5083 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5084 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5085 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5086 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5087 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5088 |
4194 | 5089 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 5090 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 5091 "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
|
5092 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5093 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5094 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
5095 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5096 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5097 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 5098 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5099 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5100 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5101 |
4617 | 5102 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5103 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5104 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5105 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5106 |
2993 | 5107 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
5108 { | |
5575 | 5109 GaimConnection *gc = sess->aux_data; |
7283 | 5110 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 5111 va_list ap; |
5112 fu16_t maxsiglen; | |
2993 | 5113 |
5114 va_start(ap, fr); | |
4199 | 5115 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 5116 va_end(ap); |
5117 | |
8660 | 5118 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5119 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 5120 |
4617 | 5121 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
5122 | |
5123 if (od->icq) | |
7334 | 5124 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 5125 else |
7334 | 5126 aim_locate_setcaps(od->sess, caps_aim); |
5127 oscar_set_info(gc, gc->account->user_info); | |
2993 | 5128 |
5129 return 1; | |
5130 } | |
5131 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5132 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
|
5133 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5134 fu16_t maxbuddies, maxwatchers; |
5575 | 5135 GaimConnection *gc = sess->aux_data; |
7283 | 5136 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5137 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5138 va_start(ap, fr); |
4199 | 5139 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5140 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5141 va_end(ap); |
5142 | |
8660 | 5143 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5144 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5145 |
4617 | 5146 od->rights.maxbuddies = (guint)maxbuddies; |
5147 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5148 |
2086 | 5149 return 1; |
5150 } | |
5151 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5152 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5153 GaimConnection *gc = sess->aux_data; |
7283 | 5154 OscarData *od = (OscarData *)gc->proto_data; |
10570 | 5155 GaimAccount *account = gaim_connection_get_account(gc); |
7334 | 5156 va_list ap; |
5157 fu16_t maxpermits, maxdenies; | |
2086 | 5158 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5159 va_start(ap, fr); |
4199 | 5160 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5161 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5162 va_end(ap); |
5163 | |
8660 | 5164 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5165 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5166 |
4617 | 5167 od->rights.maxpermits = (guint)maxpermits; |
5168 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5169 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5170 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5171 |
8660 | 5172 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5173 |
2672 | 5174 aim_clientready(sess, fr->conn); |
5948 | 5175 aim_srv_setavailmsg(sess, NULL); |
7474 | 5176 aim_srv_setidle(sess, 0); |
4617 | 5177 |
4664 | 5178 if (od->icq) { |
5179 aim_icq_reqofflinemsgs(sess); | |
10570 | 5180 aim_icq_setsecurity(sess, |
5181 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
5182 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE), | |
5183 gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP)); | |
4664 | 5184 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5185 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5186 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5187 if (sess->authinfo->email) |
5188 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5189 |
5190 return 1; | |
5191 } | |
5192 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5193 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
|
5194 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5195 struct aim_icq_offlinemsg *msg; |
4075 | 5196 struct aim_incomingim_ch4_args args; |
5197 time_t t; | |
2706
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 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5200 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5201 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5202 |
8660 | 5203 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5204 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5205 args.uin = msg->sender; |
5206 args.type = msg->type; | |
4173 | 5207 args.flags = msg->flags; |
4076 | 5208 args.msglen = msg->msglen; |
4075 | 5209 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5210 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5211 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5212 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5213 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5214 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5215 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5216 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
|
5217 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5218 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5219 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5220 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5221 |
7388 | 5222 #if 0 |
5223 /* | |
7465 | 5224 * Update, 2003-11-09: |
5225 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5226 * | |
7388 | 5227 * It may not be my place to do this, but... |
5228 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5229 * stupid, and should not exist for % switches (%x in our case) that request | |
5230 * a year in the preferred representation for the current locale. For that | |
5231 * reason I've chosen to not use this workaround (n., see kluge). | |
5232 * | |
5233 * I have a date. I want to show it to the user in the "preferred" way. | |
5234 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5235 * what the locale wanted. | |
5236 * | |
5237 * If I have a necessity for a full representation of the year in the current | |
5238 * locale, then I'll use a switch that returns a full representation of the | |
5239 * year. | |
5240 * | |
5241 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5242 * (because you're anal, or whatever), then change the f***ing locale. | |
5243 * | |
5244 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5245 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5246 * |
5247 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5248 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5249 */ |
5250 | |
5251 /* | |
5252 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5253 * "last 2 digits" warning. |
5254 */ | |
10157 | 5255 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5256 const struct tm *tm) |
5257 { | |
5258 return strftime(s, max, fmt, tm); | |
5259 } | |
10636 | 5260 |
5261 /* | |
5262 * Before even realizing this was here, I went and did the same thing in util.c. | |
5263 * | |
5264 * Use gaim_strftime() | |
5265 */ | |
5266 | |
7388 | 5267 #endif |
7386 | 5268 |
4624 | 5269 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
|
5270 { |
5575 | 5271 GaimConnection *gc = sess->aux_data; |
8670 | 5272 OscarData *od = (OscarData *)gc->proto_data; |
5273 GaimBuddy *buddy; | |
8853 | 5274 struct buddyinfo *bi = NULL; |
4624 | 5275 gchar who[16]; |
8670 | 5276 GString *str; |
5277 gchar *primary, *utf8; | |
9634 | 5278 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5279 va_list ap; |
4151 | 5280 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5281 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5282 va_start(ap, fr); |
4151 | 5283 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5284 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5285 |
4664 | 5286 if (!info->uin) |
5287 return 0; | |
5288 | |
8670 | 5289 str = g_string_sized_new(100); |
5556 | 5290 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5291 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5292 if (buddy != NULL) | |
5293 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5294 | |
5295 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5296 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5297 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5298 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5299 (bi->ipaddr & 0xff000000) >> 24, | |
5300 (bi->ipaddr & 0x00ff0000) >> 16, | |
5301 (bi->ipaddr & 0x0000ff00) >> 8, | |
5302 (bi->ipaddr & 0x000000ff)); | |
8701 | 5303 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5304 g_free(tstr); |
5305 } | |
8701 | 5306 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5307 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5308 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5309 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5310 g_free(utf8); | |
4625 | 5311 } |
5312 if (info->numaddresses && info->email2) { | |
5313 int i; | |
5314 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5315 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
10683 | 5316 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 5317 g_free(utf8); |
4643 | 5318 } |
4625 | 5319 } |
4624 | 5320 } |
8701 | 5321 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5322 if (info->gender != 0) |
5323 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5324 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5325 char date[30]; |
5326 struct tm tm; | |
5327 tm.tm_mday = (int)info->birthday; | |
5328 tm.tm_mon = (int)info->birthmonth-1; | |
5329 tm.tm_year = (int)info->birthyear-1900; | |
10636 | 5330 gaim_strftime(date, sizeof(date), "%x", &tm); |
8701 | 5331 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5332 } |
4624 | 5333 if (info->age) { |
5334 char age[5]; | |
5335 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5336 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5337 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5338 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5339 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5340 g_free(utf8); | |
4819 | 5341 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5342 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5343 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5344 g_free(utf8); | |
5345 } | |
10683 | 5346 g_string_append_printf(str, "<hr>"); |
4641 | 5347 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5348 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5349 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5350 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5351 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5352 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
10683 | 5353 g_string_append_printf(str, "\n<hr>"); |
4151 | 5354 } |
4641 | 5355 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5356 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5357 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5358 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5359 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5360 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
10683 | 5361 g_string_append_printf(str, "\n<hr>"); |
4624 | 5362 } |
4641 | 5363 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5364 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5365 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5366 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5367 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5368 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5369 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5370 g_free(utf8); | |
4624 | 5371 } |
10683 | 5372 g_string_append_printf(str, "\n<hr>"); |
8670 | 5373 } |
5374 | |
9634 | 5375 if (buddy != NULL) |
5376 alias = gaim_buddy_get_alias(buddy); | |
5377 else | |
5378 alias = who; | |
5379 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5380 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5381 g_free(primary); |
8670 | 5382 g_string_free(str, TRUE); |
4151 | 5383 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5384 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5385 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5386 |
4759 | 5387 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5388 { | |
5575 | 5389 GaimConnection *gc = sess->aux_data; |
4820 | 5390 gchar who[16], *utf8; |
6695 | 5391 GaimBuddy *b; |
4759 | 5392 va_list ap; |
5393 struct aim_icq_info *info; | |
5394 | |
5395 va_start(ap, fr); | |
5396 info = va_arg(ap, struct aim_icq_info *); | |
5397 va_end(ap); | |
5398 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5399 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5400 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5401 serv_got_alias(gc, who, utf8); |
4759 | 5402 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5403 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5404 } |
4820 | 5405 g_free(utf8); |
4759 | 5406 } |
5407 | |
5408 return 1; | |
5409 } | |
5410 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5411 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
|
5412 { |
7032 | 5413 GaimConnection *gc = sess->aux_data; |
5414 gchar *text; | |
5415 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5416 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5417 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5418 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5419 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5420 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5421 url = va_arg(ap, char *); |
4199 | 5422 wid = (fu16_t) va_arg(ap, int); |
5423 hei = (fu16_t) va_arg(ap, int); | |
5424 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5425 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5426 |
7032 | 5427 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5428 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5429 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5430 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5431 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5432 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5433 |
7032 | 5434 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5435 { | |
6873 | 5436 GaimConnection *gc = sess->aux_data; |
5437 gchar *secondary; | |
10439 | 5438 gchar **screennames; |
6873 | 5439 int i, num; |
2086 | 5440 va_list ap; |
6873 | 5441 char *email, *SNs; |
2086 | 5442 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5443 va_start(ap, fr); |
6873 | 5444 email = va_arg(ap, char *); |
2086 | 5445 num = va_arg(ap, int); |
5446 SNs = va_arg(ap, char *); | |
5447 va_end(ap); | |
5448 | |
10439 | 5449 /* TODO: Need to use ngettext() here */ |
8152 | 5450 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5451 |
5452 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5453 for (i = 0; i < num; i++) |
10439 | 5454 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5455 screennames[num] = NULL; | |
5456 | |
5457 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5458 (const char **)screennames, NULL, NULL); | |
6873 | 5459 |
5460 g_free(secondary); | |
10439 | 5461 g_strfreev(screennames); |
2086 | 5462 |
5463 return 1; | |
5464 } | |
5465 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5466 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5467 va_list ap; |
6873 | 5468 char *email; |
5420 | 5469 char *buf; |
2086 | 5470 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5471 va_start(ap, fr); |
6873 | 5472 email = va_arg(ap, char *); |
2086 | 5473 va_end(ap); |
5474 | |
6873 | 5475 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
|
5476 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5477 g_free(buf); |
2086 | 5478 |
5479 return 1; | |
5480 } | |
5481 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5482 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5483 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5484 fu16_t status; |
2086 | 5485 va_list ap; |
5486 char msg[256]; | |
5487 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5488 va_start(ap, fr); |
4199 | 5489 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5490 va_end(ap); |
5491 | |
8660 | 5492 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5493 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5494 status ? "unknown" : "email sent"); |
5495 if (!status) { | |
5302 | 5496 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5497 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5498 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5499 } |
5500 | |
5501 return 1; | |
5502 } | |
5503 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5504 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5505 GaimConnection *gc = sess->aux_data; |
2086 | 5506 va_list ap; |
3912 | 5507 fu16_t perms, err; |
5508 char *url, *sn, *email; | |
5509 int change; | |
2086 | 5510 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5511 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5512 change = va_arg(ap, int); |
4199 | 5513 perms = (fu16_t) va_arg(ap, unsigned int); |
5514 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5515 url = va_arg(ap, char *); |
5516 sn = va_arg(ap, char *); | |
5517 email = va_arg(ap, char *); | |
2086 | 5518 va_end(ap); |
5519 | |
8660 | 5520 gaim_debug_misc("oscar", |
9626 | 5521 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5522 change ? "change" : "request", perms, err, | |
5523 (url != NULL) ? url : "(null)", | |
5524 (sn != NULL) ? sn : "(null)", | |
5525 (email != NULL) ? email : "(null)"); | |
5526 | |
5527 if ((err > 0) && (url != NULL)) { | |
3912 | 5528 char *dialog_msg; |
5529 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5530 switch (err) { | |
5531 case 0x0001: { | |
5532 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5533 } break; | |
5534 case 0x0006: { | |
5535 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5536 } break; | |
5537 case 0x000b: { | |
5538 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5539 } break; | |
5540 case 0x001d: { | |
5541 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); | |
5542 } break; | |
5543 case 0x0021: { | |
5544 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); | |
5545 } break; | |
5546 case 0x0023: { | |
5547 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5548 } break; | |
5549 default: { | |
5550 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5551 } break; | |
5552 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5553 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5554 g_free(dialog_top); |
5555 g_free(dialog_msg); | |
5556 return 1; | |
5557 } | |
5558 | |
9626 | 5559 if (sn != NULL) { |
4585 | 5560 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
|
5561 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5562 g_free(dialog_msg); |
5563 } | |
5564 | |
9626 | 5565 if (email != NULL) { |
5575 | 5566 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5567 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5568 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5569 g_free(dialog_msg); |
2086 | 5570 } |
5571 | |
5572 return 1; | |
5573 } | |
5574 | |
5575 | 5575 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5576 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5577 aim_flap_nop(od->sess, od->conn); |
2086 | 5578 } |
5579 | |
6059 | 5580 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5581 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5582 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5583 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5584 if (typing == GAIM_TYPING) |
4870 | 5585 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5586 else if (typing == GAIM_TYPED) |
4870 | 5587 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5588 else | |
5589 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5590 else { |
5300 | 5591 /* Don't send if this turkey is in our deny list */ |
5592 GSList *list; | |
5593 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5594 if (!list) { | |
7261 | 5595 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5596 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5597 if (typing == GAIM_TYPING) |
5300 | 5598 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5599 else if (typing == GAIM_TYPED) |
5300 | 5600 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5601 else | |
5602 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5603 } | |
3595 | 5604 } |
5605 } | |
2993 | 5606 return 0; |
5607 } | |
9030 | 5608 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5609 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
|
5610 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5611 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5612 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5613 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5614 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
|
5615 int ret = 0; |
10246 | 5616 const char *iconfile = gaim_account_get_buddy_icon(account); |
10781 | 5617 char *tmpmsg = NULL; |
3458 | 5618 |
4838 | 5619 if (dim && dim->connected) { |
5620 /* If we're directly connected, send a direct IM */ | |
6982 | 5621 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5622 } else { |
4738 | 5623 struct buddyinfo *bi; |
3008 | 5624 struct aim_sendimext_args args; |
5625 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5626 gsize len; |
10246 | 5627 GaimConversation *conv; |
5628 | |
5629 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5630 |
5631 if (strstr(message, "<IMG ")) | |
5632 gaim_conversation_write(conv, "", | |
5633 _("Your IM Image was not sent. " | |
5634 "You must be Direct Connected to send IM Images."), | |
5635 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5636 |
10246 | 5637 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5638 if (!bi) { |
5639 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5640 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5641 } |
5642 | |
3008 | 5643 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5644 if (od->icq) { |
11185 | 5645 /* We have to present different "features" (whose meaning |
11172 | 5646 is unclear and are merely a result of protocol inspection) |
5647 to offline ICQ buddies. Otherwise, the official | |
5648 ICQ client doesn't treat those messages as being "ANSI- | |
5649 encoded" (and instead, assumes them to be UTF-8). | |
5650 For more details, see SF issue 1179452. | |
5651 */ | |
5652 GaimBuddy *buddy = gaim_find_buddy(gc->account, name); | |
5653 if (buddy && buddy->present != 0) { | |
5654 args.features = features_icq; | |
5655 args.featureslen = sizeof(features_icq); | |
5656 } else { | |
5657 args.features = features_icq_offline; | |
5658 args.featureslen = sizeof(features_icq_offline); | |
5659 } | |
3008 | 5660 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5661 } else { |
5662 args.features = features_aim; | |
5663 args.featureslen = sizeof(features_aim); | |
4972 | 5664 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5665 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5666 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5667 } |
4269 | 5668 |
4738 | 5669 if (bi->ico_need) { |
8660 | 5670 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5671 "Sending buddy icon request with message\n"); |
3008 | 5672 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5673 bi->ico_need = FALSE; |
3008 | 5674 } |
4269 | 5675 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5676 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5677 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 5678 if (file) { |
11159 | 5679 guchar *buf = g_malloc(st.st_size); |
9532 | 5680 /* XXX - Use g_file_get_contents()? */ |
3008 | 5681 fread(buf, 1, st.st_size, file); |
6039 | 5682 fclose(file); |
4269 | 5683 |
3008 | 5684 args.iconlen = st.st_size; |
4617 | 5685 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5686 args.iconstamp = st.st_mtime; |
5687 | |
7406 | 5688 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5689 bi->ico_informed = FALSE; |
7406 | 5690 bi->ico_sent = FALSE; |
5691 } | |
4738 | 5692 |
5693 if (!bi->ico_informed) { | |
8660 | 5694 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5695 "Claiming to have a buddy icon\n"); |
4738 | 5696 args.flags |= AIM_IMFLAGS_HASICON; |
5697 bi->ico_me_len = args.iconlen; | |
5698 bi->ico_me_csum = args.iconsum; | |
5699 bi->ico_me_time = args.iconstamp; | |
5700 bi->ico_informed = TRUE; | |
5701 } | |
5702 | |
3008 | 5703 g_free(buf); |
2086 | 5704 } |
5705 } | |
4269 | 5706 |
3008 | 5707 args.destsn = name; |
4269 | 5708 |
8985 | 5709 /* |
10781 | 5710 * If we're IMing an ICQ user from an ICQ account, then strip HTML |
5711 * and use \r\n as the newline character. | |
8985 | 5712 */ |
10781 | 5713 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
5714 if (aim_sn_is_icq(name)) | |
5715 /* From ICQ to ICQ */ | |
8995 | 5716 tmpmsg = g_strdup(message); |
10781 | 5717 else |
5718 /* From ICQ to AIM */ | |
5719 tmpmsg = g_markup_escape_text(message, -1); | |
8995 | 5720 } else { |
10785 | 5721 /* From AIM to AIM and AIM to ICQ */ |
5722 tmpmsg = g_strdup(message); | |
8995 | 5723 } |
6310 | 5724 len = strlen(tmpmsg); |
5725 | |
9830 | 5726 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5727 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5728 args.charset, args.charsubset, args.msglen); | |
4617 | 5729 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5730 g_free((char *)args.msg); |
2086 | 5731 } |
4838 | 5732 |
6310 | 5733 g_free(tmpmsg); |
5734 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5735 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5736 return 1; |
6310 | 5737 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5738 return ret; |
2086 | 5739 } |
5740 | |
7011 | 5741 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5742 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5743 |
9975 | 5744 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5745 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5746 else |
7235 | 5747 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5748 } |
5749 | |
8950 | 5750 #if 0 |
7011 | 5751 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5752 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5753 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5754 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5755 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5756 maiden, NULL, NULL, city, state, NULL, 0, web); |
5757 } | |
8950 | 5758 #endif |
2086 | 5759 |
5575 | 5760 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5761 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5762 aim_srv_setidle(od->sess, time); |
2086 | 5763 } |
5764 | |
5954 | 5765 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5766 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5767 int charset = 0; |
6019 | 5768 char *text_html = NULL; |
5129 | 5769 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5770 gsize msglen = 0; |
2993 | 5771 |
4617 | 5772 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5773 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5774 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5775 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5776 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5777 "again when you are fully connected.")); |
4617 | 5778 |
7334 | 5779 if (!text) { |
5780 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5781 return; | |
5782 } | |
10097 | 5783 |
7334 | 5784 text_html = gaim_strdup_withhtml(text); |
9807 | 5785 charset = oscar_charset_check(text_html); |
9826 | 5786 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5787 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5788 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5789 g_free(msg); | |
9826 | 5790 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5791 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5792 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5793 g_free(msg); | |
5794 } else { | |
5795 msglen = strlen(text_html); | |
5796 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5797 } | |
5798 | |
5799 if (msglen > od->rights.maxsiglen) { | |
5800 gchar *errstr; | |
5801 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
|
5802 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5803 "The maximum profile length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5804 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5805 od->rights.maxsiglen), od->rights.maxsiglen); |
5806 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5807 g_free(errstr); | |
5808 } | |
5809 | |
5810 g_free(text_html); | |
2086 | 5811 } |
5812 | |
9991 | 5813 static void |
5814 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5815 { |
9991 | 5816 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5817 OscarData *od = NULL; |
9992 | 5818 GaimStatusType *status_type; |
9991 | 5819 GaimStatusPrimitive primitive; |
5820 GaimPresence *presence; | |
5821 const gchar *status_id; | |
9807 | 5822 int charset = 0; |
10196 | 5823 const gchar *text_html = NULL; |
5129 | 5824 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5825 gsize msglen = 0; |
2993 | 5826 |
9992 | 5827 status_type = gaim_status_get_type(status); |
5828 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5829 status_id = gaim_status_get_id(status); |
5830 presence = gaim_account_get_presence(account); | |
5831 | |
10400 | 5832 if (gc) |
5833 od = (OscarData *)gc->proto_data; | |
10401 | 5834 |
5835 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { | |
9991 | 5836 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5837 _("You have probably requested to set your " |
5838 "away message before the login procedure " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5839 "completed. You remain in a \"present\" " |
10400 | 5840 "state; try setting it again when you are " |
5841 "fully connected.")); | |
10401 | 5842 return; |
5843 } | |
5129 | 5844 |
9992 | 5845 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5846 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5847 | |
7334 | 5848 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5849 |
5850 text_html = gaim_status_get_attr_string(status, "message"); | |
5851 if (text_html != NULL) { | |
5852 aim_srv_setavailmsg(od->sess, text_html); | |
5853 } | |
10196 | 5854 |
5855 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5856 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5857 | |
10196 | 5858 text_html = gaim_status_get_attr_string(status, "message"); |
5859 | |
5860 if (text_html == NULL) { | |
5861 text_html = _("Away"); | |
5862 } | |
5863 | |
5864 charset = oscar_charset_check(text_html); | |
5865 if (charset == AIM_CHARSET_UNICODE) { | |
5866 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5867 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5868 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5869 g_free(msg); | |
5870 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5871 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5872 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5873 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5874 g_free(msg); | |
5875 } else { | |
5876 msglen = strlen(text_html); | |
5877 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5878 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5879 } | |
5880 | |
5881 if (msglen > od->rights.maxawaymsglen) { | |
5882 gchar *errstr; | |
5883 | |
5884 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
|
5885 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5886 "The maximum away message length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5887 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5888 od->rights.maxawaymsglen), od->rights.maxawaymsglen); |
5889 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5890 g_free(errstr); | |
5891 } | |
5892 | |
10197 | 5893 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5894 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5895 | |
5129 | 5896 } else { |
10196 | 5897 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5898 | |
5899 } | |
2993 | 5900 } |
5901 | |
9991 | 5902 static void |
5903 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5904 { |
9991 | 5905 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 5906 OscarData *od = NULL; |
9991 | 5907 const gchar *status_id = gaim_status_get_id(status); |
5908 | |
10646 | 5909 if (gc) |
5910 od = (OscarData *)gc->proto_data; | |
5911 if (!od) | |
5912 return; | |
5913 | |
9991 | 5914 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) |
5575 | 5915 account->perm_deny = 4; |
8265 | 5916 else |
5575 | 5917 account->perm_deny = 3; |
9991 | 5918 |
8265 | 5919 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5920 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5921 |
9991 | 5922 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5923 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5924 |
5925 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5926 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5927 |
5928 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5929 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5930 |
5931 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5932 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5933 |
5934 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5935 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5936 |
5937 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5938 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5939 |
5940 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5941 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5942 |
5943 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5944 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5945 } |
5946 | |
9991 | 5947 static void |
5948 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5949 { |
11251 | 5950 gboolean disconnected = gaim_account_is_disconnected(account); |
10400 | 5951 GaimStatusType *type = gaim_status_get_type(status); |
5952 int primitive = gaim_status_type_get_primitive(type); | |
5953 | |
10747 | 5954 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
5955 | |
10498 | 5956 if (!gaim_status_is_active(status)) |
10485 | 5957 return; |
5958 | |
11251 | 5959 if (primitive != GAIM_STATUS_OFFLINE && disconnected) { |
10738 | 5960 gaim_account_connect(account); |
11251 | 5961 } else if (primitive == GAIM_STATUS_OFFLINE && !disconnected) { |
10400 | 5962 gaim_account_disconnect(account); |
5963 } else { | |
11251 | 5964 if (!gaim_account_is_connected(account)) |
10747 | 5965 return; |
10400 | 5966 |
5967 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
5968 oscar_set_status_icq(account, status); | |
5969 else | |
10560 | 5970 /* QQQ - Should probably also set this for ICQ */ |
10400 | 5971 oscar_set_status_aim(account, status); |
5972 } | |
2086 | 5973 } |
5974 | |
9991 | 5975 static void |
5976 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5977 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5978 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5979 } |
5980 | |
10747 | 5981 static void |
5982 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5983 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5984 |
5985 if (!aim_snvalid(buddy->name)) { | |
8092 | 5986 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5987 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 | 5988 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5989 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5990 g_free(buf); |
8150 | 5991 |
5992 /* Remove from local list */ | |
9285 | 5993 gaim_blist_remove_buddy(buddy); |
8150 | 5994 |
8092 | 5995 return; |
5996 } | |
5997 | |
9285 | 5998 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5999 if (buddy && group) { | |
8660 | 6000 gaim_debug_info("oscar", |
9285 | 6001 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 6002 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 6003 } |
6004 } | |
8150 | 6005 |
10157 | 6006 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 6007 if (od->icq) |
9285 | 6008 aim_icq_getalias(od->sess, buddy->name); |
6009 } | |
6010 | |
6011 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6012 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6013 |
4230 | 6014 if (od->sess->ssi.received_data) { |
8660 | 6015 gaim_debug_info("oscar", |
9285 | 6016 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
6017 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 6018 } |
10866 | 6019 } |
6020 | |
5575 | 6021 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 6022 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 6023 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 6024 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6025 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 6026 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 6027 } |
6028 } | |
6029 | |
5575 | 6030 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 6031 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 6032 if (od->sess->ssi.received_data) { |
6033 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
6034 if (gname) { | |
8660 | 6035 gaim_debug_info("oscar", |
9586 | 6036 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 6037 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 6038 } |
6039 } | |
6040 } | |
6041 | |
11005 | 6042 /* |
6043 * FYI, the OSCAR SSI code removes empty groups automatically. | |
6044 */ | |
9285 | 6045 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 6046 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6047 |
6048 if (od->sess->ssi.received_data) { | |
9285 | 6049 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
6050 GList *cur, *groups = NULL; | |
6051 | |
6052 /* Make a list of what the groups each buddy is in */ | |
6053 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
6054 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6055 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6056 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6057 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6058 node->parent->parent); |
9285 | 6059 } |
6060 | |
10866 | 6061 serv_remove_buddies(gc, moved_buddies, groups); |
6062 serv_add_buddies(gc, moved_buddies); | |
9285 | 6063 g_list_free(groups); |
8660 | 6064 gaim_debug_info("oscar", |
9285 | 6065 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 6066 } else { |
9285 | 6067 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 6068 gaim_debug_info("oscar", |
9285 | 6069 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 6070 } |
6071 } | |
6072 } | |
6073 | |
5968 | 6074 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
6075 aim_session_t *sess = data; | |
6350 | 6076 aim_ssi_reqdata(sess); |
5968 | 6077 return FALSE; |
6078 } | |
6079 | |
4642 | 6080 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6081 GaimConnection *gc = sess->aux_data; |
7283 | 6082 OscarData *od = gc->proto_data; |
4642 | 6083 va_list ap; |
6084 fu16_t reason; | |
6085 | |
6086 va_start(ap, fr); | |
6087 reason = (fu16_t)va_arg(ap, unsigned int); | |
6088 va_end(ap); | |
6089 | |
8660 | 6090 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 6091 |
6092 if (reason == 0x0005) { | |
5892 | 6093 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6094 _("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
|
6095 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 6096 } |
6097 | |
6098 /* Activate SSI */ | |
6099 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6100 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6101 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 6102 aim_ssi_enable(od->sess); |
6103 | |
6104 return 1; | |
6105 } | |
6106 | |
2991 | 6107 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6108 GaimConnection *gc = sess->aux_data; |
7283 | 6109 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 6110 int i; |
6111 va_list ap; | |
6112 int numtypes; | |
4230 | 6113 fu16_t *maxitems; |
2991 | 6114 |
6115 va_start(ap, fr); | |
4230 | 6116 numtypes = va_arg(ap, int); |
6117 maxitems = va_arg(ap, fu16_t *); | |
2991 | 6118 va_end(ap); |
6119 | |
8660 | 6120 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6121 |
4230 | 6122 for (i=0; i<numtypes; i++) |
8660 | 6123 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6124 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6125 |
8660 | 6126 gaim_debug_misc(NULL, "\n"); |
4230 | 6127 |
6128 if (numtypes >= 0) | |
6129 od->rights.maxbuddies = maxitems[0]; | |
6130 if (numtypes >= 1) | |
6131 od->rights.maxgroups = maxitems[1]; | |
6132 if (numtypes >= 2) | |
6133 od->rights.maxpermits = maxitems[2]; | |
6134 if (numtypes >= 3) | |
6135 od->rights.maxdenies = maxitems[3]; | |
2991 | 6136 |
6137 return 1; | |
6138 } | |
6139 | |
6140 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6141 GaimConnection *gc = sess->aux_data; |
6142 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6143 GaimStatus *status; |
7283 | 6144 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6145 GaimGroup *g; |
6146 GaimBuddy *b; | |
2995 | 6147 struct aim_ssi_item *curitem; |
2991 | 6148 int tmp; |
4230 | 6149 va_list ap; |
8219 | 6150 fu16_t fmtver, numitems; |
6151 struct aim_ssi_item *items; | |
6152 fu32_t timestamp; | |
4230 | 6153 |
6154 va_start(ap, fr); | |
6155 fmtver = (fu16_t)va_arg(ap, int); | |
6156 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6157 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6158 timestamp = va_arg(ap, fu32_t); |
8219 | 6159 va_end(ap); |
2991 | 6160 |
8660 | 6161 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6162 "ssi: syncing local list and server list\n"); |
2991 | 6163 |
8219 | 6164 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6165 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 | 6166 return 1; |
6167 } | |
6168 | |
2991 | 6169 /* Clean the buddy list */ |
4889 | 6170 aim_ssi_cleanlist(sess); |
2991 | 6171 |
8150 | 6172 { /* If not in server list then prune from local list */ |
6173 GaimBlistNode *gnode, *cnode, *bnode; | |
6174 GaimBuddyList *blist; | |
9539 | 6175 GSList *cur, *next; |
8150 | 6176 |
6177 /* Buddies */ | |
6178 cur = NULL; | |
6179 if ((blist = gaim_get_blist()) != NULL) { | |
6180 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6181 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6182 continue; | |
6183 g = (GaimGroup *)gnode; | |
6184 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6185 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6186 continue; | |
6187 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6188 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6189 continue; | |
6190 b = (GaimBuddy *)bnode; | |
6191 if (b->account == gc->account) { | |
6192 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6193 /* If the buddy is an ICQ user then load his nickname */ | |
6194 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6195 char *alias; |
8150 | 6196 if (servernick) |
6197 serv_got_alias(gc, b->name, servernick); | |
6198 | |
6199 /* Store local alias on server */ | |
8214 | 6200 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6201 if (!alias && b->alias && strlen(b->alias)) |
6202 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6203 free(alias); | |
6204 } else { | |
8660 | 6205 gaim_debug_info("oscar", |
8150 | 6206 "ssi: removing buddy %s from local list\n", b->name); |
6207 /* We can't actually remove now because it will screw up our looping */ | |
6208 cur = g_slist_prepend(cur, b); | |
6209 } | |
6210 } | |
6211 } | |
6212 } | |
6213 } | |
6214 } | |
8175 | 6215 |
8150 | 6216 while (cur != NULL) { |
6217 b = cur->data; | |
6218 cur = g_slist_remove(cur, b); | |
6219 gaim_blist_remove_buddy(b); | |
6220 } | |
6221 | |
6222 /* Permit list */ | |
6223 if (gc->account->permit) { | |
9539 | 6224 next = gc->account->permit; |
6225 while (next != NULL) { | |
6226 cur = next; | |
6227 next = next->next; | |
8150 | 6228 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6229 gaim_debug_info("oscar", |
8150 | 6230 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6231 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6232 } | |
9539 | 6233 } |
8150 | 6234 } |
6235 | |
6236 /* Deny list */ | |
6237 if (gc->account->deny) { | |
9539 | 6238 next = gc->account->deny; |
6239 while (next != NULL) { | |
6240 cur = next; | |
6241 next = next->next; | |
8150 | 6242 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6243 gaim_debug_info("oscar", |
8150 | 6244 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6245 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6246 } | |
9539 | 6247 } |
8150 | 6248 } |
6249 /* Presence settings (idle time visibility) */ | |
6250 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6251 if (!(tmp & 0x400)) | |
6252 aim_ssi_setpresence(sess, tmp | 0x400); | |
6253 } /* end pruning buddies from local list */ | |
6254 | |
2991 | 6255 /* Add from server list to local list */ |
4230 | 6256 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6257 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6258 switch (curitem->type) { |
4230 | 6259 case 0x0000: { /* Buddy */ |
4251 | 6260 if (curitem->name) { |
4292 | 6261 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6262 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6263 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6264 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6265 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6266 /* Should gname be freed here? -- elb */ |
4754 | 6267 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6268 free(alias); |
8150 | 6269 if (b) { |
4292 | 6270 /* Get server stored alias */ |
4705 | 6271 if (alias_utf8) { |
8150 | 6272 g_free(b->alias); |
6273 b->alias = g_strdup(alias_utf8); | |
4705 | 6274 } |
4282 | 6275 } else { |
8150 | 6276 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6277 |
4754 | 6278 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6279 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6280 gaim_blist_add_group(g, NULL); |
6281 } | |
5146 | 6282 |
8660 | 6283 gaim_debug_info("oscar", |
9285 | 6284 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6285 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6286 } |
8341 | 6287 if (!aim_sncmp(curitem->name, account->username)) { |
6288 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6289 gaim_check_comment(od, comment); | |
6290 free(comment); | |
6291 } | |
7162 | 6292 g_free(gname_utf8); |
6293 g_free(alias_utf8); | |
2991 | 6294 } |
4230 | 6295 } break; |
6296 | |
6297 case 0x0001: { /* Group */ | |
4282 | 6298 /* Shouldn't add empty groups */ |
4230 | 6299 } break; |
6300 | |
6301 case 0x0002: { /* Permit buddy */ | |
2991 | 6302 if (curitem->name) { |
4230 | 6303 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6304 GSList *list; |
5575 | 6305 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6306 if (!list) { |
8660 | 6307 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6308 "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
|
6309 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6310 } |
6311 } | |
4230 | 6312 } break; |
6313 | |
6314 case 0x0003: { /* Deny buddy */ | |
2991 | 6315 if (curitem->name) { |
6316 GSList *list; | |
5575 | 6317 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6318 if (!list) { |
8660 | 6319 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6320 "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
|
6321 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6322 } |
6323 } | |
4230 | 6324 } break; |
6325 | |
6326 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6327 if (curitem->data) { |
6328 fu8_t permdeny; | |
5575 | 6329 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6330 gaim_debug_info("oscar", |
5575 | 6331 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6332 account->perm_deny = permdeny; | |
6333 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6334 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6335 } |
2991 | 6336 } |
6337 } | |
4230 | 6338 } break; |
6339 | |
6340 case 0x0005: { /* Presence setting */ | |
3109 | 6341 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6342 } break; |
2991 | 6343 } /* End of switch on curitem->type */ |
6344 } /* End of for loop */ | |
4230 | 6345 |
9991 | 6346 /* |
6347 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6348 * this. We probably want the SSI status setting to override the local | |
6349 * setting. | |
6350 */ | |
9982 | 6351 status = gaim_presence_get_active_status(account->presence); |
6352 if (gaim_status_is_available(status)) | |
4901 | 6353 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6354 | |
4342 | 6355 /* Activate SSI */ |
6356 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6357 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6358 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6359 "ssi: activating server-stored buddy list\n"); |
4642 | 6360 aim_ssi_enable(sess); |
4342 | 6361 |
2991 | 6362 return 1; |
2086 | 6363 } |
4230 | 6364 |
6365 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6366 GaimConnection *gc = sess->aux_data; |
4230 | 6367 va_list ap; |
6368 struct aim_ssi_tmp *retval; | |
6369 | |
6370 va_start(ap, fr); | |
6371 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6372 va_end(ap); | |
6373 | |
6374 while (retval) { | |
8660 | 6375 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6376 "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 | 6377 |
6378 if (retval->ack != 0xffff) | |
6379 switch (retval->ack) { | |
6380 case 0x0000: { /* added successfully */ | |
6381 } break; | |
6382 | |
4829 | 6383 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6384 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6385 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 | 6386 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6387 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6388 g_free(buf); |
6389 } | |
6390 | |
7023 | 6391 case 0x000e: { /* buddy requires authorization */ |
4828 | 6392 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6393 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6394 } break; |
6395 | |
6396 default: { /* La la la */ | |
5197 | 6397 gchar *buf; |
8660 | 6398 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
|
6399 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 | 6400 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6401 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6402 g_free(buf); |
4230 | 6403 } break; |
6404 } | |
6405 | |
6406 retval = retval->next; | |
6407 } | |
6408 | |
6409 return 1; | |
6410 } | |
6411 | |
8227 | 6412 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6413 GaimConnection *gc = sess->aux_data; | |
6414 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6415 GaimBuddy *b; | |
6416 GaimGroup *g; | |
6417 va_list ap; | |
6418 fu16_t type; | |
6419 const char *name; | |
6420 | |
6421 va_start(ap, fr); | |
6422 type = (fu16_t)va_arg(ap, int); | |
6423 name = va_arg(ap, char *); | |
6424 va_end(ap); | |
6425 | |
6426 if ((type != 0x0000) || (name == NULL)) | |
6427 return 1; | |
6428 | |
6429 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6430 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6431 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6432 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6433 b = gaim_find_buddy(gc->account, name); | |
6434 free(alias); | |
6435 | |
6436 if (b) { | |
6437 /* Get server stored alias */ | |
6438 if (alias_utf8) { | |
6439 g_free(b->alias); | |
6440 b->alias = g_strdup(alias_utf8); | |
6441 } | |
6442 } else { | |
6443 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6444 | |
6445 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6446 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6447 gaim_blist_add_group(g, NULL); | |
6448 } | |
6449 | |
8660 | 6450 gaim_debug_info("oscar", |
9285 | 6451 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6452 gaim_blist_add_buddy(b, NULL, g, NULL); |
6453 } | |
6454 g_free(gname_utf8); | |
6455 g_free(alias_utf8); | |
6456 | |
6457 return 1; | |
6458 } | |
6459 | |
4230 | 6460 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6461 GaimConnection *gc = sess->aux_data; |
4230 | 6462 va_list ap; |
6463 char *sn, *msg; | |
4236 | 6464 gchar *dialog_msg, *nombre; |
4230 | 6465 struct name_data *data; |
6695 | 6466 GaimBuddy *buddy; |
4230 | 6467 |
6468 va_start(ap, fr); | |
6469 sn = va_arg(ap, char *); | |
6470 msg = va_arg(ap, char *); | |
6471 va_end(ap); | |
6472 | |
8660 | 6473 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6474 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6475 |
4687 | 6476 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6477 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6478 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6479 else |
6480 nombre = g_strdup(sn); | |
6481 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6482 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 | 6483 data = g_new(struct name_data, 1); |
6484 data->gc = gc; | |
6485 data->name = g_strdup(sn); | |
6486 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6487 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6488 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6489 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6490 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6491 G_CALLBACK(oscar_free_name_data)); |
4236 | 6492 |
4230 | 6493 g_free(dialog_msg); |
4236 | 6494 g_free(nombre); |
4230 | 6495 |
6496 return 1; | |
6497 } | |
6498 | |
6499 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6500 GaimConnection *gc = sess->aux_data; |
4230 | 6501 va_list ap; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6502 char *sn; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6503 char *msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6504 GaimAccount *account = gaim_connection_get_account(gc); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6505 gchar *nombre; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6506 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6507 gchar *dialog_msg; |
4230 | 6508 struct name_data *data; |
6695 | 6509 GaimBuddy *buddy; |
4230 | 6510 |
6511 va_start(ap, fr); | |
6512 sn = va_arg(ap, char *); | |
6513 msg = va_arg(ap, char *); | |
6514 va_end(ap); | |
6515 | |
8660 | 6516 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6517 "ssi: received authorization request from %s\n", sn); |
4230 | 6518 |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6519 buddy = gaim_find_buddy(account, sn); |
9620 | 6520 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6521 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6522 else |
6523 nombre = g_strdup(sn); | |
6524 | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6525 if (msg != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6526 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
|
6527 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6528 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6529 |
10949 | 6530 dialog_msg = g_strdup_printf( |
6531 _("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
|
6532 nombre, gaim_account_get_username(account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6533 g_free(reason); |
10949 | 6534 |
4230 | 6535 data = g_new(struct name_data, 1); |
6536 data->gc = gc; | |
6537 data->name = g_strdup(sn); | |
6538 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6539 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6540 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6541 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6542 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6543 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6544 |
4230 | 6545 g_free(dialog_msg); |
4236 | 6546 g_free(nombre); |
4230 | 6547 |
6548 return 1; | |
6549 } | |
6550 | |
6551 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6552 GaimConnection *gc = sess->aux_data; |
4230 | 6553 va_list ap; |
6554 char *sn, *msg; | |
4236 | 6555 gchar *dialog_msg, *nombre; |
4230 | 6556 fu8_t reply; |
6695 | 6557 GaimBuddy *buddy; |
4230 | 6558 |
6559 va_start(ap, fr); | |
6560 sn = va_arg(ap, char *); | |
6561 reply = (fu8_t)va_arg(ap, int); | |
6562 msg = va_arg(ap, char *); | |
6563 va_end(ap); | |
6564 | |
8660 | 6565 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6566 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6567 |
4687 | 6568 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6569 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6570 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6571 else |
6572 nombre = g_strdup(sn); | |
6573 | |
4230 | 6574 if (reply) { |
6575 /* Granted */ | |
7023 | 6576 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
|
6577 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6578 } else { |
6579 /* Denied */ | |
7023 | 6580 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
|
6581 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6582 } |
6583 g_free(dialog_msg); | |
4236 | 6584 g_free(nombre); |
4230 | 6585 |
6586 return 1; | |
6587 } | |
6588 | |
6589 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6590 GaimConnection *gc = sess->aux_data; |
4230 | 6591 va_list ap; |
6592 char *sn; | |
6695 | 6593 GaimBuddy *buddy; |
4230 | 6594 |
6595 va_start(ap, fr); | |
6596 sn = va_arg(ap, char *); | |
6597 va_end(ap); | |
6598 | |
4687 | 6599 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6600 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6601 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6602 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6603 |
6604 return 1; | |
6605 } | |
2086 | 6606 |
5575 | 6607 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6608 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6609 struct proto_chat_entry *pce; |
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 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6612 pce->label = _("_Room:"); |
5234 | 6613 pce->identifier = "room"; |
10475 | 6614 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6615 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6616 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6617 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6618 pce->label = _("_Exchange:"); |
5234 | 6619 pce->identifier = "exchange"; |
10475 | 6620 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6621 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6622 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6623 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6624 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6625 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6626 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6627 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6628 |
9754 | 6629 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6630 { | |
6631 GHashTable *defaults; | |
6632 | |
6633 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6634 | |
6635 if (chat_name != NULL) | |
6636 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6637 | |
6638 return defaults; | |
6639 } | |
6640 | |
9917 | 6641 static char *oscar_get_chat_name(GHashTable *data) { |
6642 return g_strdup(g_hash_table_lookup(data, "room")); | |
6643 } | |
6644 | |
8308 | 6645 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6646 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6647 aim_conn_t *cur; |
5234 | 6648 char *name, *exchange; |
6649 | |
6650 name = g_hash_table_lookup(data, "room"); | |
6651 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6652 |
8660 | 6653 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6654 "Attempting to join chat room %s.\n", name); |
8308 | 6655 |
6656 if ((name == NULL) || (*name == '\0')) { | |
6657 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6658 return; | |
6659 } | |
6660 | |
4617 | 6661 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6662 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6663 "chatnav exists, creating room\n"); |
5234 | 6664 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6665 } else { |
6666 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6667 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6668 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6669 "chatnav does not exist, opening chatnav\n"); |
5234 | 6670 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6671 cr->name = g_strdup(name); |
4617 | 6672 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6673 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6674 } |
6675 } | |
6676 | |
8308 | 6677 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6678 OscarData *od = (OscarData *)gc->proto_data; | |
6679 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6680 |
6681 if (ccon == NULL) | |
2086 | 6682 return; |
10404 | 6683 |
8225 | 6684 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6685 ccon->exchange, ccon->name, 0x0); |
6686 } | |
6687 | |
10458 | 6688 static void |
6689 oscar_chat_leave(GaimConnection *gc, int id) | |
6690 { | |
6691 GaimConversation *conv; | |
6692 struct chat_connection *cc; | |
6693 | |
6694 conv = gaim_find_chat(gc, id); | |
6695 | |
6696 g_return_if_fail(conv != NULL); | |
6697 | |
6698 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6699 | |
6700 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6701 oscar_chat_kill(gc, cc); | |
2086 | 6702 } |
6703 | |
8219 | 6704 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6705 OscarData *od = (OscarData *)gc->proto_data; | |
6706 GaimConversation *conv = NULL; | |
2086 | 6707 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6708 char *buf, *buf2; |
9830 | 6709 fu16_t charset, charsubset; |
9807 | 6710 char *charsetstr = NULL; |
10111 | 6711 int len; |
8219 | 6712 |
6713 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6714 return -EINVAL; |
2086 | 6715 |
8219 | 6716 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6717 return -EINVAL; |
2086 | 6718 |
8219 | 6719 buf = gaim_strdup_withhtml(message); |
6720 len = strlen(buf); | |
6721 | |
8962 | 6722 if (strstr(buf, "<IMG ")) |
6723 gaim_conversation_write(conv, "", | |
6724 _("Your IM Image was not sent. " | |
6725 "You cannot send IM Images in AIM chats."), | |
6726 GAIM_MESSAGE_ERROR, time(NULL)); | |
6727 | |
9830 | 6728 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6729 if ((len > c->maxlen) || (len > c->maxvis)) { |
6730 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6731 return -E2BIG; |
8359 | 6732 } |
6733 | |
9831 | 6734 if (charset == AIM_CHARSET_ASCII) |
6735 charsetstr = "us-ascii"; | |
6736 else if (charset == AIM_CHARSET_UNICODE) | |
6737 charsetstr = "unicode-2-0"; | |
6738 else if (charset == AIM_CHARSET_CUSTOM) | |
6739 charsetstr = "iso-8859-1"; | |
9807 | 6740 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6741 g_free(buf2); |
8359 | 6742 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6743 return 0; |
2086 | 6744 } |
6745 | |
10042 | 6746 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6747 { | |
4766 | 6748 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6749 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6750 return "icq"; |
6751 else | |
6752 return "aim"; | |
6753 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6754 |
9975 | 6755 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6756 return "icq"; |
6757 return "aim"; | |
6758 } | |
6759 | |
9972 | 6760 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6761 { |
7334 | 6762 GaimConnection *gc = NULL; |
6763 OscarData *od = NULL; | |
10042 | 6764 GaimAccount *account = NULL; |
6765 GaimPresence *presence; | |
6766 GaimStatus *status; | |
6767 const char *status_id; | |
4687 | 6768 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6769 int i = 0; | |
7334 | 6770 aim_userinfo_t *userinfo = NULL; |
6771 | |
6772 if (b != NULL) | |
6773 account = b->account; | |
6774 if (account != NULL) | |
6775 gc = account->gc; | |
6776 if (gc != NULL) | |
6777 od = gc->proto_data; | |
7945 | 6778 if (od != NULL) |
6779 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6780 |
10042 | 6781 presence = gaim_buddy_get_presence(b); |
6782 status = gaim_presence_get_active_status(presence); | |
6783 status_id = gaim_status_get_id(status); | |
6784 | |
6785 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6786 char *gname; |
7334 | 6787 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6788 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6789 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6790 emblems[i++] = "notauthorized"; | |
6791 } else { | |
6792 emblems[i++] = "offline"; | |
6793 } | |
6794 } | |
4916 | 6795 |
10042 | 6796 if (b->name && aim_sn_is_icq(b->name)) { |
6797 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6798 emblems[i++] = "invisible"; | |
6799 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6800 emblems[i++] = "freeforchat"; |
10042 | 6801 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6802 emblems[i++] = "dnd"; |
10042 | 6803 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6804 emblems[i++] = "na"; |
10042 | 6805 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6806 emblems[i++] = "occupied"; |
10042 | 6807 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6808 emblems[i++] = "away"; |
10042 | 6809 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6810 emblems[i++] = "away"; | |
6811 } | |
6812 | |
6813 if (userinfo != NULL ) { | |
6814 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6815 emblems[i++] = "unconfirmed"; */ | |
6816 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6817 emblems[i++] = "admin"; | |
6818 if (userinfo->flags & AIM_FLAG_AOL) | |
6819 emblems[i++] = "aol"; | |
6820 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6821 emblems[i++] = "wireless"; | |
6822 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6823 emblems[i++] = "activebuddy"; | |
6824 | |
6825 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6826 emblems[i++] = "hiptop"; |
6827 | |
10042 | 6828 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6829 emblems[i++] = "secure"; |
10042 | 6830 } |
7334 | 6831 |
4687 | 6832 *se = emblems[0]; |
6833 *sw = emblems[1]; | |
6834 *nw = emblems[2]; | |
6835 *ne = emblems[3]; | |
6836 } | |
6837 | |
6695 | 6838 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6839 GaimConnection *gc = b->account->gc; |
7283 | 6840 OscarData *od = gc->proto_data; |
7045 | 6841 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6842 GString *str = g_string_new(""); |
5131 | 6843 |
6844 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6845 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6846 |
6847 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6848 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6849 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6850 g_free(charset); |
7011 | 6851 if (away_utf8 != NULL) { |
7091 | 6852 gchar *tmp1, *tmp2; |
9627 | 6853 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6854 g_free(away_utf8); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
6855 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 6856 g_free(tmp2); |
8700 | 6857 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6858 g_free(tmp1); |
8701 | 6859 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6860 g_free(tmp2); |
5836 | 6861 } |
5131 | 6862 } |
8701 | 6863 } |
6864 | |
6865 return g_string_free(str, FALSE); | |
5131 | 6866 } |
6867 | |
10042 | 6868 static char *oscar_status_text(GaimBuddy *b) |
6869 { | |
6870 GaimConnection *gc; | |
6871 OscarData *od; | |
11248 | 6872 GaimPresence *presence; |
5167 | 6873 gchar *ret = NULL; |
6874 | |
10042 | 6875 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6876 od = gc->proto_data; | |
11248 | 6877 presence = gaim_buddy_get_presence(b); |
6878 | |
6879 if (!gaim_presence_is_online(presence)) | |
6880 { | |
5167 | 6881 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6882 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6883 ret = g_strdup(_("Not Authorized")); | |
6884 else | |
6885 ret = g_strdup(_("Offline")); | |
6886 } | |
11248 | 6887 else if (gaim_presence_is_available(presence)) |
6888 { | |
6889 struct buddyinfo *bi; | |
6890 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); | |
6891 if ((bi != NULL) && (bi->availmsg != NULL)) | |
6892 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
6893 } | |
6894 else | |
6895 { | |
6896 if (aim_sn_is_icq(b->name)) | |
6897 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
6898 else | |
6899 ret = g_strdup(_("Away")); | |
6900 } | |
5167 | 6901 |
6902 return ret; | |
6903 } | |
6904 | |
5842 | 6905 |
5844 | 6906 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6907 GaimConnection *gc = sess->aux_data; |
7283 | 6908 OscarData *od = gc->proto_data; |
5892 | 6909 va_list ap; |
5842 | 6910 fu16_t type; |
5892 | 6911 fu8_t flags = 0, length = 0; |
11159 | 6912 guchar *md5 = NULL; |
5892 | 6913 |
7334 | 6914 |
5842 | 6915 va_start(ap, fr); |
6916 type = va_arg(ap, int); | |
5892 | 6917 |
6918 switch(type) { | |
6919 case 0x0000: | |
6920 case 0x0001: { | |
6921 flags = va_arg(ap, int); | |
6922 length = va_arg(ap, int); | |
11159 | 6923 md5 = va_arg(ap, guchar *); |
5892 | 6924 |
6925 if (flags == 0x41) { | |
6926 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6927 od->iconconnecting = TRUE; | |
6928 od->set_icon = TRUE; | |
6929 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6930 } else { | |
6039 | 6931 struct stat st; |
6932 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6933 if (iconfile == NULL) { | |
8363 | 6934 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6935 } else if (!g_stat(iconfile, &st)) { |
11159 | 6936 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6937 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 6938 if (file) { |
9532 | 6939 /* XXX - Use g_file_get_contents()? */ |
6039 | 6940 fread(buf, 1, st.st_size, file); |
6941 fclose(file); | |
8660 | 6942 gaim_debug_info("oscar", |
10042 | 6943 "Uploading icon to icon server\n"); |
6879 | 6944 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6945 } else |
8660 | 6946 gaim_debug_error("oscar", |
10042 | 6947 "Can't open buddy icon file!\n"); |
6039 | 6948 g_free(buf); |
6949 } else { | |
8660 | 6950 gaim_debug_error("oscar", |
10042 | 6951 "Can't stat buddy icon file!\n"); |
5892 | 6952 } |
6953 } | |
8363 | 6954 } else if (flags == 0x81) { |
6955 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6956 if (iconfile == NULL) | |
6957 aim_ssi_delicon(od->sess); | |
6958 else | |
6959 aim_ssi_seticon(od->sess, md5, length); | |
6960 } | |
5892 | 6961 } break; |
6962 | |
6963 case 0x0002: { /* We just set an "available" message? */ | |
6964 } break; | |
6965 } | |
6966 | |
5842 | 6967 va_end(ap); |
5844 | 6968 |
6969 return 0; | |
5842 | 6970 } |
5892 | 6971 |
5575 | 6972 static void oscar_set_permit_deny(GaimConnection *gc) { |
6973 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6974 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 6975 |
8175 | 6976 if (od->sess->ssi.received_data) { |
6977 switch (account->perm_deny) { | |
6978 case GAIM_PRIVACY_ALLOW_ALL: | |
6979 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6980 break; | |
6981 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6982 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6983 break; | |
6984 case GAIM_PRIVACY_ALLOW_USERS: | |
6985 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6986 break; | |
6987 case GAIM_PRIVACY_DENY_ALL: | |
6988 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6989 break; | |
6990 case GAIM_PRIVACY_DENY_USERS: | |
6991 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6992 break; | |
6993 default: | |
6994 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6995 break; | |
6996 } | |
6997 } | |
2086 | 6998 } |
6999 | |
5575 | 7000 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 7001 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7002 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 7003 if (od->sess->ssi.received_data) |
4889 | 7004 aim_ssi_addpermit(od->sess, who); |
2086 | 7005 } |
7006 | |
5575 | 7007 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 7008 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7009 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 7010 if (od->sess->ssi.received_data) |
4889 | 7011 aim_ssi_adddeny(od->sess, who); |
2086 | 7012 } |
7013 | |
5575 | 7014 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 7015 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7016 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 7017 if (od->sess->ssi.received_data) |
4889 | 7018 aim_ssi_delpermit(od->sess, who); |
2086 | 7019 } |
7020 | |
5575 | 7021 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 7022 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7023 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 7024 if (od->sess->ssi.received_data) |
4889 | 7025 aim_ssi_deldeny(od->sess, who); |
2086 | 7026 } |
7027 | |
9975 | 7028 static GList * |
7029 oscar_status_types(GaimAccount *account) | |
2086 | 7030 { |
9975 | 7031 GList *status_types = NULL; |
7032 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
7033 |
9973 | 7034 g_return_val_if_fail(account != NULL, NULL); |
7035 | |
10042 | 7036 /* Oscar-common status types */ |
9991 | 7037 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
7038 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 7039 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 7040 status_types = g_list_append(status_types, type); |
7041 | |
9991 | 7042 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
7043 OSCAR_STATUS_ID_ONLINE, | |
10400 | 7044 _("Online"), FALSE, TRUE, FALSE); |
9976 | 7045 status_types = g_list_append(status_types, type); |
7046 | |
10198 | 7047 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
7048 OSCAR_STATUS_ID_AVAILABLE, | |
7049 _("Available"), TRUE, TRUE, FALSE, | |
7050 "message", _("Message"), | |
7051 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 7052 status_types = g_list_append(status_types, type); |
7053 | |
10195 | 7054 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
7055 OSCAR_STATUS_ID_AWAY, | |
7056 _("Away"), TRUE, TRUE, FALSE, | |
7057 "message", _("Message"), | |
7058 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 7059 status_types = g_list_append(status_types, type); |
7060 | |
7061 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
7062 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 7063 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 7064 status_types = g_list_append(status_types, type); |
7065 | |
7066 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
7067 return status_types; | |
7068 | |
7069 /* ICQ-specific status types */ | |
7070 | |
9991 | 7071 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
7072 OSCAR_STATUS_ID_FREE4CHAT, | |
7073 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 7074 status_types = g_list_append(status_types, type); |
7075 | |
9991 | 7076 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
7077 OSCAR_STATUS_ID_OCCUPIED, | |
7078 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 7079 status_types = g_list_append(status_types, type); |
7080 | |
9991 | 7081 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7082 OSCAR_STATUS_ID_DND, | |
7083 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 7084 status_types = g_list_append(status_types, type); |
7085 | |
9991 | 7086 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7087 OSCAR_STATUS_ID_NA, | |
7088 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 7089 status_types = g_list_append(status_types, type); |
9975 | 7090 |
7091 return status_types; | |
4333 | 7092 } |
7093 | |
7172 | 7094 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 7095 GaimConnection *gc = data->gc; |
7096 OscarData *od = gc->proto_data; | |
7172 | 7097 GaimBuddy *b; |
7098 GaimGroup *g; | |
7099 | |
7100 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
7101 oscar_free_name_data(data); | |
7102 return; | |
7103 } | |
7104 | |
7105 if (!(g = gaim_find_buddys_group(b))) { | |
7106 oscar_free_name_data(data); | |
7107 return; | |
7108 } | |
7109 | |
7110 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 7111 |
7112 if (!aim_sncmp(data->name, gc->account->username)) | |
7113 gaim_check_comment(od, text); | |
7114 | |
7172 | 7115 oscar_free_name_data(data); |
7116 } | |
7117 | |
9030 | 7118 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
7119 | |
7120 GaimBuddy *buddy; | |
7121 GaimConnection *gc; | |
7122 OscarData *od; | |
7123 struct name_data *data; | |
7172 | 7124 GaimGroup *g; |
7125 char *comment; | |
7126 gchar *comment_utf8; | |
9631 | 7127 gchar *title; |
7172 | 7128 |
9030 | 7129 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
7130 | |
7131 buddy = (GaimBuddy *) node; | |
7132 gc = gaim_account_get_connection(buddy->account); | |
7133 od = gc->proto_data; | |
7134 | |
7135 data = g_new(struct name_data, 1); | |
7136 | |
7137 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 7138 return; |
9030 | 7139 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 7140 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
7141 | |
7142 data->gc = gc; | |
9030 | 7143 data->name = g_strdup(buddy->name); |
7172 | 7144 data->nick = NULL; |
7145 | |
9631 | 7146 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7147 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7148 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7149 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7150 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7151 data); | |
9631 | 7152 g_free(title); |
7172 | 7153 |
7154 free(comment); | |
7155 g_free(comment_utf8); | |
7156 } | |
7157 | |
9030 | 7158 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7159 | |
7160 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7161 OscarData *od = gc->proto_data; |
9030 | 7162 |
4333 | 7163 GList *m = NULL; |
9030 | 7164 GaimBlistNodeAction *act; |
7165 | |
7166 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7167 oscar_buddycb_edit_comment, NULL, NULL); |
9030 | 7168 m = g_list_append(m, act); |
7172 | 7169 |
4333 | 7170 if (od->icq) { |
4624 | 7171 #if 0 |
9030 | 7172 act = gaim_blist_node_action_new(_("Get Status Msg"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7173 oscar_get_icqstatusmsg, NULL, NULL); |
9030 | 7174 m = g_list_append(m, act); |
4624 | 7175 #endif |
4333 | 7176 } else { |
7011 | 7177 aim_userinfo_t *userinfo; |
9030 | 7178 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7179 | |
7180 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7181 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7182 | |
7011 | 7183 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7184 act = gaim_blist_node_action_new(_("Direct IM"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7185 oscar_ask_direct_im, NULL, NULL); |
9030 | 7186 m = g_list_append(m, act); |
5917 | 7187 } |
9466 | 7188 #if 0 |
7011 | 7189 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7190 act = gaim_blist_node_action_new(_("Get File"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7191 oscar_ask_getfile, NULL, NULL); |
9030 | 7192 m = g_list_append(m, act); |
5917 | 7193 } |
4826 | 7194 #endif |
4333 | 7195 } |
5131 | 7196 } |
5197 | 7197 |
5131 | 7198 if (od->sess->ssi.received_data) { |
9030 | 7199 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7200 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7201 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7202 gaim_auth_sendrequest_menu, NULL, NULL); |
9030 | 7203 m = g_list_append(m, act); |
4333 | 7204 } |
4916 | 7205 } |
10157 | 7206 |
4333 | 7207 return m; |
7208 } | |
7209 | |
9030 | 7210 |
7211 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7212 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7213 return oscar_buddy_menu((GaimBuddy *) node); | |
7214 } else { | |
7215 return NULL; | |
7216 } | |
7217 } | |
7218 | |
10570 | 7219 static void |
7220 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
7221 { | |
7222 OscarData *od = gc->proto_data; | |
7223 GaimAccount *account = gaim_connection_get_account(gc); | |
7224 GaimRequestField *f; | |
7225 gboolean auth, hide_ip, web_aware; | |
7226 | |
7227 f = gaim_request_fields_get_field(fields, "authorization"); | |
7228 auth = gaim_request_field_bool_get_value(f); | |
7229 | |
7230 f = gaim_request_fields_get_field(fields, "hide_ip"); | |
7231 hide_ip = gaim_request_field_bool_get_value(f); | |
7232 | |
7233 f = gaim_request_fields_get_field(fields, "web_aware"); | |
7234 web_aware = gaim_request_field_bool_get_value(f); | |
7235 | |
7236 gaim_account_set_bool(account, "authorization", auth); | |
7237 gaim_account_set_bool(account, "hide_ip", hide_ip); | |
7238 gaim_account_set_bool(account, "web_aware", web_aware); | |
7239 | |
7240 aim_icq_setsecurity(od->sess, auth, web_aware, hide_ip); | |
7241 } | |
7242 | |
7243 static void | |
7244 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
7245 { | |
7246 GaimConnection *gc = (GaimConnection *) action->context; | |
7247 GaimAccount *account = gaim_connection_get_account(gc); | |
7248 GaimRequestFields *fields; | |
7249 GaimRequestFieldGroup *g; | |
7250 GaimRequestField *f; | |
7251 gboolean auth, hide_ip, web_aware; | |
7252 | |
7253 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7254 hide_ip = gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7255 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7256 | |
7257 fields = gaim_request_fields_new(); | |
7258 | |
7259 g = gaim_request_field_group_new(NULL); | |
7260 | |
7261 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
7262 gaim_request_field_group_add_field(g, f); | |
7263 | |
7264 f = gaim_request_field_bool_new("hide_ip", _("Hide IP address"), hide_ip); | |
7265 gaim_request_field_group_add_field(g, f); | |
7266 | |
7267 f = gaim_request_field_bool_new("web_aware", _("Web aware"), web_aware); | |
7268 gaim_request_field_group_add_field(g, f); | |
7269 | |
7270 gaim_request_fields_add_group(fields, g); | |
7271 | |
7272 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
7273 NULL, fields, | |
7274 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
7275 _("Cancel"), NULL, gc); | |
7276 } | |
9030 | 7277 |
5575 | 7278 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7279 OscarData *od = gc->proto_data; |
5575 | 7280 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7281 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7282 od->setnick = TRUE; | |
7283 od->newsn = g_strdup(nick); | |
7284 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7285 } else { | |
7286 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7287 } | |
7288 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7289 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7290 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7291 } |
7292 } | |
7293 | |
9015 | 7294 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7295 { |
9015 | 7296 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7297 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7298 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7299 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7300 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7301 gc); |
4333 | 7302 } |
7303 | |
9015 | 7304 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7305 { |
9015 | 7306 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7307 OscarData *od = gc->proto_data; |
4333 | 7308 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7309 | |
7310 if (conn) { | |
7311 aim_admin_reqconfirm(od->sess, conn); | |
7312 } else { | |
7313 od->conf = TRUE; | |
7314 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7315 } | |
7316 } | |
7317 | |
9015 | 7318 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7319 { |
9015 | 7320 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7321 OscarData *od = gc->proto_data; |
4333 | 7322 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7323 | |
7324 if (conn) { | |
7325 aim_admin_getinfo(od->sess, conn, 0x11); | |
7326 } else { | |
7327 od->reqemail = TRUE; | |
7328 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7329 } | |
7330 } | |
7331 | |
5575 | 7332 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7333 { |
7283 | 7334 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7335 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
|
7336 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7337 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7338 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7339 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7340 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7341 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7342 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7343 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7344 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7345 |
9015 | 7346 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7347 { |
9015 | 7348 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7349 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7350 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7351 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7352 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7353 gc); |
4333 | 7354 } |
7355 | |
9015 | 7356 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7357 { |
9015 | 7358 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7359 OscarData *od = gc->proto_data; |
4333 | 7360 gchar *nombre, *text, *tmp; |
6695 | 7361 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7362 int num=0; |
7363 | |
6873 | 7364 text = g_strdup(""); |
4333 | 7365 |
4785 | 7366 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7367 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7368 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7369 continue; | |
6695 | 7370 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7371 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7372 continue; |
6695 | 7373 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7374 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7375 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7376 continue; | |
7377 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7378 if (gaim_buddy_get_alias_only(buddy)) |
7379 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7380 else |
7381 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7382 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7383 g_free(text); |
7384 text = tmp; | |
7385 g_free(nombre); | |
7386 num++; | |
7387 } | |
4333 | 7388 } |
2979 | 7389 } |
4333 | 7390 } |
7391 | |
7392 if (!num) { | |
7393 g_free(text); | |
6873 | 7394 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7395 } | |
7396 | |
7397 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7398 "the following buddies"), _("You can re-request " | |
7399 "authorization from these buddies by " | |
7400 "right-clicking on them and selecting " | |
7401 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7402 g_free(text); |
2979 | 7403 } |
7404 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7405 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7406 { |
8950 | 7407 OscarData *od = (OscarData *)gc->proto_data; |
7408 | |
7409 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7410 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7411 |
9015 | 7412 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7413 { |
9015 | 7414 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7415 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7416 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7417 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7418 "searching for."), |
8697 | 7419 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7420 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7421 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7422 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7423 |
9015 | 7424 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7425 { |
9015 | 7426 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7427 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7428 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7429 |
9015 | 7430 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7431 { |
9015 | 7432 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7433 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7434 } |
7435 | |
9015 | 7436 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7437 { |
9015 | 7438 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7439 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7440 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7441 |
9015 | 7442 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7443 { |
9015 | 7444 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7445 OscarData *od = gc->proto_data; |
5575 | 7446 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
|
7447 gaim_notify_uri(gc, substituted); |
5517 | 7448 g_free(substituted); |
4333 | 7449 } |
7450 | |
9015 | 7451 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7452 { |
9015 | 7453 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7454 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7455 } |
7456 | |
5842 | 7457 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7458 { | |
7283 | 7459 OscarData *od = gc->proto_data; |
5844 | 7460 aim_session_t *sess = od->sess; |
5842 | 7461 FILE *file; |
7462 struct stat st; | |
5844 | 7463 |
6039 | 7464 if (iconfile == NULL) { |
8363 | 7465 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7466 } else if (!g_stat(iconfile, &st)) { |
11159 | 7467 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7468 file = g_fopen(iconfile, "rb"); |
5842 | 7469 if (file) { |
6052 | 7470 md5_state_t *state; |
11159 | 7471 guchar md5[16]; |
9532 | 7472 /* XXX - Use g_file_get_contents()? */ |
5842 | 7473 int len = fread(buf, 1, st.st_size, file); |
6039 | 7474 fclose(file); |
6052 | 7475 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7476 md5_init(state); |
7477 md5_append(state, buf, len); | |
7478 md5_finish(state, md5); | |
7479 g_free(state); | |
7480 aim_ssi_seticon(sess, md5, 16); | |
7481 } else | |
8660 | 7482 gaim_debug_error("oscar", |
5842 | 7483 "Can't open buddy icon file!\n"); |
7484 g_free(buf); | |
7485 } else | |
8660 | 7486 gaim_debug_error("oscar", |
5842 | 7487 "Can't stat buddy icon file!\n"); |
7488 } | |
7489 | |
7490 | |
9015 | 7491 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7492 { |
9015 | 7493 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7494 OscarData *od = gc->proto_data; |
4333 | 7495 GList *m = NULL; |
9015 | 7496 GaimPluginAction *act; |
7497 | |
7498 act = gaim_plugin_action_new(_("Set User Info..."), | |
7499 oscar_show_set_info); | |
7500 m = g_list_append(m, act); | |
4333 | 7501 |
10570 | 7502 if (od->icq) |
7503 { | |
9015 | 7504 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7505 oscar_show_set_info_icqurl); | |
7506 m = g_list_append(m, act); | |
8576 | 7507 } |
7508 | |
9015 | 7509 act = gaim_plugin_action_new(_("Change Password..."), |
7510 oscar_change_pass); | |
7511 m = g_list_append(m, act); | |
4617 | 7512 |
10570 | 7513 if (od->sess->authinfo->chpassurl != NULL) |
7514 { | |
9015 | 7515 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7516 oscar_show_chpassurl); | |
7517 m = g_list_append(m, act); | |
7518 | |
7519 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7520 oscar_show_imforwardingurl); | |
7521 m = g_list_append(m, act); | |
7026 | 7522 } |
7523 | |
10570 | 7524 m = g_list_append(m, NULL); |
7525 | |
7526 if (od->icq) | |
7527 { | |
7528 /* ICQ actions */ | |
7529 act = gaim_plugin_action_new(_("Show privacy options..."), | |
7530 oscar_show_icq_privacy_opts); | |
7531 m = g_list_append(m, act); | |
7532 } | |
7533 else | |
7534 { | |
4617 | 7535 /* AIM actions */ |
9015 | 7536 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7537 oscar_show_format_screenname); | |
7538 m = g_list_append(m, act); | |
7539 | |
7540 act = gaim_plugin_action_new(_("Confirm Account"), | |
7541 oscar_confirm_account); | |
7542 m = g_list_append(m, act); | |
7543 | |
7544 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7545 oscar_show_email); | |
7546 m = g_list_append(m, act); | |
7547 | |
7548 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7549 oscar_show_change_email); | |
7550 m = g_list_append(m, act); | |
2086 | 7551 } |
4333 | 7552 |
7553 m = g_list_append(m, NULL); | |
7554 | |
9015 | 7555 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7556 oscar_show_awaitingauth); | |
7557 m = g_list_append(m, act); | |
4333 | 7558 |
2086 | 7559 m = g_list_append(m, NULL); |
4333 | 7560 |
9015 | 7561 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7562 oscar_show_find_email); | |
7563 m = g_list_append(m, act); | |
4333 | 7564 |
8591 | 7565 #if 0 |
9015 | 7566 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7567 show_find_info); | |
7568 m = g_list_append(m, act); | |
8591 | 7569 #endif |
2086 | 7570 |
7571 return m; | |
7572 } | |
7573 | |
5575 | 7574 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7575 { |
7283 | 7576 OscarData *od = gc->proto_data; |
4617 | 7577 |
7578 if (od->icq) { | |
7579 aim_icq_changepasswd(od->sess, new); | |
2086 | 7580 } else { |
4617 | 7581 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7582 if (conn) { | |
7583 aim_admin_changepasswd(od->sess, conn, new, old); | |
7584 } else { | |
7585 od->chpass = TRUE; | |
7586 od->oldp = g_strdup(old); | |
7587 od->newp = g_strdup(new); | |
7588 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7589 } | |
2086 | 7590 } |
7591 } | |
7592 | |
6059 | 7593 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7594 { |
7283 | 7595 OscarData *od = gc->proto_data; |
8971 | 7596 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
|
7597 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7598 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7599 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7600 |
8971 | 7601 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7602 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7603 |
9935 | 7604 static void |
7605 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7606 { | |
7607 GaimConnection *gc = data; | |
7608 OscarData *od = gc->proto_data; | |
7609 aim_session_t *sess = od->sess; | |
7610 fu32_t presence; | |
7611 | |
7612 presence = aim_ssi_getpresence(sess->ssi.local); | |
7613 | |
7614 if (value) { | |
9992 | 7615 /* Based on the packet capture I thought it was the first one */ |
7616 /* Stu thinks it's the second one. */ | |
7617 /* presence |= 0x00400000; */ | |
9971 | 7618 presence &= ~0x00020000; |
9935 | 7619 aim_ssi_setpresence(sess, presence); |
7620 } else { | |
9992 | 7621 /* presence &= ~0x00400000; */ |
9971 | 7622 presence |= 0x00020000; |
9935 | 7623 aim_ssi_setpresence(sess, presence); |
7624 } | |
7625 } | |
7626 | |
10653 | 7627 #if USE_PRPL_PREFERENCES |
9935 | 7628 static GaimPluginPrefFrame * |
9936 | 7629 get_plugin_pref_frame(GaimPlugin *plugin) |
7630 { | |
9935 | 7631 GaimPluginPrefFrame *frame; |
7632 GaimPluginPref *ppref; | |
7633 | |
7634 frame = gaim_plugin_pref_frame_new(); | |
7635 | |
7636 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7637 gaim_plugin_pref_frame_add(frame, ppref); | |
7638 | |
7639 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7640 gaim_plugin_pref_frame_add(frame, ppref); | |
7641 | |
7642 return frame; | |
7643 } | |
10653 | 7644 #endif |
9935 | 7645 |
11153 | 7646 static const char * |
7647 oscar_normalize(const GaimAccount *account, const char *str) | |
7648 { | |
7649 static char buf[BUF_LEN]; | |
7650 char *tmp1, *tmp2; | |
7651 int i, j; | |
7652 | |
7653 g_return_val_if_fail(str != NULL, NULL); | |
7654 | |
7655 strncpy(buf, str, BUF_LEN); | |
7656 for (i=0, j=0; buf[j]; i++, j++) | |
7657 { | |
7658 while (buf[j] == ' ') | |
7659 j++; | |
7660 buf[i] = buf[j]; | |
7661 } | |
7662 buf[i] = '\0'; | |
7663 | |
7664 tmp1 = g_utf8_strdown(buf, -1); | |
7665 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
7666 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
7667 g_free(tmp2); | |
7668 g_free(tmp1); | |
7669 | |
7670 return buf; | |
7671 } | |
7672 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7673 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7674 { |
9308 | 7675 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7676 NULL, /* user_splits */ |
7677 NULL, /* protocol_options */ | |
10674 | 7678 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
7679 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 7680 oscar_list_icon, /* list_icon */ |
7681 oscar_list_emblems, /* list_emblems */ | |
7682 oscar_status_text, /* status_text */ | |
7683 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7684 oscar_status_types, /* status_types */ |
9475 | 7685 oscar_blist_node_menu, /* blist_node_menu */ |
7686 oscar_chat_info, /* chat_info */ | |
9754 | 7687 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7688 oscar_login, /* login */ |
7689 oscar_close, /* close */ | |
7690 oscar_send_im, /* send_im */ | |
7691 oscar_set_info, /* set_info */ | |
7692 oscar_send_typing, /* send_typing */ | |
7693 oscar_get_info, /* get_info */ | |
9973 | 7694 oscar_set_status, /* set_status */ |
9475 | 7695 oscar_set_idle, /* set_idle */ |
7696 oscar_change_passwd, /* change_passwd */ | |
7697 oscar_add_buddy, /* add_buddy */ | |
10866 | 7698 NULL, /* add_buddies */ |
9475 | 7699 oscar_remove_buddy, /* remove_buddy */ |
10866 | 7700 NULL, /* remove_buddies */ |
9475 | 7701 oscar_add_permit, /* add_permit */ |
7702 oscar_add_deny, /* add_deny */ | |
7703 oscar_rem_permit, /* rem_permit */ | |
7704 oscar_rem_deny, /* rem_deny */ | |
7705 oscar_set_permit_deny, /* set_permit_deny */ | |
7706 oscar_warn, /* warn */ | |
7707 oscar_join_chat, /* join_chat */ | |
7708 NULL, /* reject_chat */ | |
9973 | 7709 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7710 oscar_chat_invite, /* chat_invite */ |
7711 oscar_chat_leave, /* chat_leave */ | |
7712 NULL, /* chat_whisper */ | |
7713 oscar_send_chat, /* chat_send */ | |
7714 oscar_keepalive, /* keepalive */ | |
7715 NULL, /* register_user */ | |
7716 NULL, /* get_cb_info */ | |
7717 NULL, /* get_cb_away */ | |
7718 oscar_alias_buddy, /* alias_buddy */ | |
7719 oscar_move_buddy, /* group_buddy */ | |
7720 oscar_rename_group, /* rename_group */ | |
7721 NULL, /* buddy_free */ | |
7722 oscar_convo_closed, /* convo_closed */ | |
11153 | 7723 oscar_normalize, /* normalize */ |
9475 | 7724 oscar_set_icon, /* set_buddy_icon */ |
7725 NULL, /* remove_group */ | |
7726 NULL, /* get_cb_real_name */ | |
7727 NULL, /* set_chat_topic */ | |
7728 NULL, /* find_blist_chat */ | |
7729 NULL, /* roomlist_get_list */ | |
7730 NULL, /* roomlist_cancel */ | |
7731 NULL, /* roomlist_expand_category */ | |
7732 oscar_can_receive_file, /* can_receive_file */ | |
7733 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7734 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7735 |
10653 | 7736 #if USE_PRPL_PREFERENCES |
9935 | 7737 static GaimPluginUiInfo prefs_info = { |
7738 get_plugin_pref_frame | |
7739 }; | |
10653 | 7740 #endif |
9935 | 7741 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7742 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7743 { |
9943 | 7744 GAIM_PLUGIN_MAGIC, |
7745 GAIM_MAJOR_VERSION, | |
7746 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7747 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7748 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7749 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7750 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7751 GAIM_PRIORITY_DEFAULT, /**< priority */ |
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 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7754 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7755 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7756 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7757 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7758 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7759 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7760 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7761 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7762 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7763 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7764 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7765 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7766 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7767 NULL, /**< ui_info */ |
8993 | 7768 &prpl_info, /**< extra_info */ |
10653 | 7769 #if USE_PRPL_PREFERENCES |
10487 | 7770 NULL, /**< prefs_info */ |
10653 | 7771 #else |
7772 NULL, /**< prefs_info */ | |
7773 #endif | |
9015 | 7774 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7775 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7776 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7777 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7778 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7779 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7780 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7781 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7782 gaim_debug_register_category("oscar"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7783 |
9830 | 7784 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7785 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7786 | |
7787 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7788 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7789 | |
7790 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7791 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
11084 | 7792 |
9935 | 7793 gaim_prefs_add_none("/plugins/prpl/oscar"); |
7794 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7795 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7796 } |
7797 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7798 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |