Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 11160:3adcad067e5f
[gaim-migrate @ 13248]
Default yahoo chat roomlist locale to 'us'
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 26 Jul 2005 04:42:53 +0000 |
parents | bd8ac1d4b2f2 |
children | ccb38cf22483 |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
6 * Some code copyright (C) 2001-2003, Sean Egan | |
11155 | 7 * Some code copyright (C) 2001-2005, Mark Doliner <thekingant@users.sourceforge.net> |
11049 | 8 * Some code copyright (C) 2005, Jonathan Clark <ardentlygnarly@users.sourceforge.net> |
6302 | 9 * |
10 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 11 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 12 * |
13 * This program is free software; you can redistribute it and/or modify | |
14 * it under the terms of the GNU General Public License as published by | |
15 * the Free Software Foundation; either version 2 of the License, or | |
16 * (at your option) any later version. | |
17 * | |
18 * This program is distributed in the hope that it will be useful, | |
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10485 | 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2086 | 21 * GNU General Public License for more details. |
22 * | |
23 * You should have received a copy of the GNU General Public License | |
24 * along with this program; if not, write to the Free Software | |
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
26 * | |
27 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
30 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
31 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
32 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
33 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
34 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
36 #include "ft.h" |
6982 | 37 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
38 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
40 #include "privacy.h" |
2086 | 41 #include "prpl.h" |
4889 | 42 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 #include "util.h" |
9943 | 45 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
46 |
2086 | 47 #include "aim.h" |
5842 | 48 #include "md5.h" |
2086 | 49 |
9976 | 50 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
51 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
52 #define OSCAR_STATUS_ID_ONLINE "online" | |
9991 | 53 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 54 #define OSCAR_STATUS_ID_AWAY "away" |
55 #define OSCAR_STATUS_ID_DND "dnd" | |
56 #define OSCAR_STATUS_ID_NA "na" | |
57 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
58 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
59 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 60 |
2086 | 61 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
62 | |
7283 | 63 #define OSCAR_CONNECT_STEPS 6 |
9830 | 64 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
10570 | 65 #define OSCAR_DEFAULT_AUTHORIZATION TRUE |
66 #define OSCAR_DEFAULT_HIDE_IP TRUE | |
67 #define OSCAR_DEFAULT_WEB_AWARE FALSE | |
7283 | 68 |
11084 | 69 /* Seconds each file transfer ip address will be given to make a connection */ |
70 #define FT_IP_TIMEOUT 15 | |
71 | |
10329 | 72 #define FAIM_DEBUG_LEVEL 0 |
73 | |
7376 | 74 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
75 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 76 |
4665 | 77 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
78 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 79 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 80 |
7283 | 81 typedef struct _OscarData OscarData; |
82 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
83 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
84 aim_conn_t *conn; |
2086 | 85 |
86 guint cnpa; | |
87 guint paspa; | |
3694 | 88 guint emlpa; |
4804 | 89 guint icopa; |
2086 | 90 |
4823 | 91 gboolean iconconnecting; |
5842 | 92 gboolean set_icon; |
4823 | 93 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
94 GSList *create_rooms; |
2086 | 95 |
96 gboolean conf; | |
97 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
98 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
99 char *email; |
2979 | 100 gboolean setnick; |
101 char *newsn; | |
2086 | 102 gboolean chpass; |
103 char *oldp; | |
104 char *newp; | |
9971 | 105 |
2086 | 106 GSList *oscar_chats; |
107 GSList *direct_ims; | |
3630 | 108 GSList *file_transfers; |
4738 | 109 GHashTable *buddyinfo; |
4804 | 110 GSList *requesticon; |
2086 | 111 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
112 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
113 gboolean icq; |
4804 | 114 guint icontimer; |
5968 | 115 guint getblisttimer; |
8341 | 116 guint getinfotimer; |
10567 | 117 gint timeoffset; |
2993 | 118 |
119 struct { | |
4230 | 120 guint maxwatchers; /* max users who can watch you */ |
2993 | 121 guint maxbuddies; /* max users you can watch */ |
4230 | 122 guint maxgroups; /* max groups in server list */ |
2993 | 123 guint maxpermits; /* max users on permit list */ |
124 guint maxdenies; /* max users on deny list */ | |
125 guint maxsiglen; /* max size (bytes) of profile */ | |
126 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
127 } rights; | |
2086 | 128 }; |
129 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
130 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
133 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
134 |
2086 | 135 struct chat_connection { |
136 char *name; | |
137 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
138 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
139 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
140 aim_conn_t *conn; |
2086 | 141 int inpa; |
142 int id; | |
5575 | 143 GaimConnection *gc; /* i hate this. */ |
8733 | 144 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
145 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
146 int maxvis; |
2086 | 147 }; |
148 | |
8971 | 149 struct oscar_direct_im { |
5575 | 150 GaimConnection *gc; |
2086 | 151 char name[80]; |
152 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
153 aim_conn_t *conn; |
3008 | 154 gboolean connected; |
8978 | 155 gboolean gpc_pend; |
156 gboolean killme; | |
8984 | 157 gboolean donttryagain; |
2086 | 158 }; |
159 | |
160 struct ask_direct { | |
5575 | 161 GaimConnection *gc; |
2086 | 162 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
163 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
164 fu8_t cookie[8]; |
8984 | 165 gboolean donttryagain; |
2086 | 166 }; |
167 | |
7011 | 168 /* |
169 * Various PRPL-specific buddy info that we want to keep track of | |
170 * Some other info is maintained by locate.c, and I'd like to move | |
171 * the rest of this to libfaim, mostly im.c | |
172 */ | |
4738 | 173 struct buddyinfo { |
174 gboolean typingnot; | |
6292 | 175 gchar *availmsg; |
6857 | 176 fu32_t ipaddr; |
5836 | 177 |
178 unsigned long ico_me_len; | |
179 unsigned long ico_me_csum; | |
180 time_t ico_me_time; | |
181 gboolean ico_informed; | |
4738 | 182 |
183 unsigned long ico_len; | |
184 unsigned long ico_csum; | |
185 time_t ico_time; | |
186 gboolean ico_need; | |
7406 | 187 gboolean ico_sent; |
2086 | 188 }; |
189 | |
4230 | 190 struct name_data { |
5575 | 191 GaimConnection *gc; |
4230 | 192 gchar *name; |
3453 | 193 gchar *nick; |
3141 | 194 }; |
195 | |
5129 | 196 static char *msgerrreason[] = { |
197 N_("Invalid error"), | |
198 N_("Invalid SNAC"), | |
199 N_("Rate to host"), | |
200 N_("Rate to client"), | |
201 N_("Not logged in"), | |
202 N_("Service unavailable"), | |
203 N_("Service not defined"), | |
204 N_("Obsolete SNAC"), | |
205 N_("Not supported by host"), | |
206 N_("Not supported by client"), | |
207 N_("Refused by client"), | |
208 N_("Reply too big"), | |
209 N_("Responses lost"), | |
210 N_("Request denied"), | |
211 N_("Busted SNAC payload"), | |
212 N_("Insufficient rights"), | |
213 N_("In local permit/deny"), | |
214 N_("Too evil (sender)"), | |
215 N_("Too evil (receiver)"), | |
216 N_("User temporarily unavailable"), | |
217 N_("No match"), | |
218 N_("List overflow"), | |
219 N_("Request ambiguous"), | |
220 N_("Queue full"), | |
221 N_("Not while on AOL") | |
222 }; | |
223 static int msgerrreasonlen = 25; | |
224 | |
225 /* All the libfaim->gaim callback functions */ | |
226 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 228 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 229 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
230 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 237 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 238 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 239 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
240 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
241 static int gaim_conv_chat_join (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
242 static int gaim_conv_chat_leave (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
243 static int gaim_conv_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
244 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 245 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
246 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 248 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 249 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
250 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
256 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
259 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
260 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
261 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 280 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 281 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
282 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
283 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
284 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
285 | |
286 /* for DirectIM/image transfer */ | |
287 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
288 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
289 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 290 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 291 |
292 /* for file transfer */ | |
293 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
294 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
295 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
296 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
297 | |
298 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 299 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
11159 | 300 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie); |
5954 | 301 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 302 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
11084 | 303 static void oscar_xfer_init_recv(GaimXfer *xfer); |
9935 | 304 |
5836 | 305 static void oscar_free_name_data(struct name_data *data) { |
4230 | 306 g_free(data->name); |
307 g_free(data->nick); | |
308 g_free(data); | |
309 } | |
310 | |
5836 | 311 static void oscar_free_buddyinfo(void *data) { |
312 struct buddyinfo *bi = data; | |
6292 | 313 g_free(bi->availmsg); |
5836 | 314 g_free(bi); |
315 } | |
316 | |
9807 | 317 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 318 { |
319 int i = 0; | |
9826 | 320 int charset = AIM_CHARSET_ASCII; |
5129 | 321 |
11081 | 322 /* Determine how we can send this message. Per the warnings elsewhere |
323 * in this file, these little checks determine the simplest encoding | |
5129 | 324 * we can use for a given message send using it. */ |
325 while (utf8[i]) { | |
326 if ((unsigned char)utf8[i] > 0x7f) { | |
327 /* not ASCII! */ | |
9826 | 328 charset = AIM_CHARSET_CUSTOM; |
5129 | 329 break; |
330 } | |
331 i++; | |
332 } | |
333 while (utf8[i]) { | |
334 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
335 * followed by 0xc0-0xc3 in the second */ | |
336 if ((unsigned char)utf8[i] < 0x80) { | |
337 i++; | |
338 continue; | |
339 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
340 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
341 i += 2; | |
342 continue; | |
343 } | |
9826 | 344 charset = AIM_CHARSET_UNICODE; |
5129 | 345 break; |
346 } | |
347 | |
9807 | 348 return charset; |
5129 | 349 } |
350 | |
8225 | 351 /* |
352 * Take a string of the form charset="bleh" where bleh is | |
11081 | 353 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and |
8225 | 354 * return a newly allocated string containing bleh. |
355 */ | |
356 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 357 { |
8225 | 358 gchar *ret = NULL; |
359 char *begin, *end; | |
360 | |
9933 | 361 g_return_val_if_fail(encoding != NULL, NULL); |
362 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
363 /* Make sure encoding begins with charset= */ |
10540 | 364 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
365 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
366 { | |
8225 | 367 return NULL; |
10540 | 368 } |
8225 | 369 |
370 begin = strchr(encoding, '"'); | |
371 end = strrchr(encoding, '"'); | |
372 | |
373 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
374 return NULL; | |
375 | |
376 ret = g_strndup(begin+1, (end-1) - begin); | |
377 | |
378 return ret; | |
379 } | |
380 | |
9830 | 381 static gchar * |
382 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 383 { |
384 gchar *utf8 = NULL; | |
9595 | 385 |
386 if ((encoding == NULL) || encoding[0] == '\0') { | |
387 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 388 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 389 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 390 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 391 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 392 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 393 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 394 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 395 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 396 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 397 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
398 } | |
399 | |
400 /* | |
401 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
402 * we have been unable to convert the text to utf-8 from the encoding | |
403 * that was specified. So we check if the text is valid utf-8 then | |
404 * just copy it. | |
405 */ | |
406 if (utf8 == NULL) { | |
9638 | 407 if (textlen != 0 && *text != '\0' |
408 && !g_utf8_validate(text, textlen, NULL)) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
409 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 410 else |
9481 | 411 utf8 = g_strndup(text, textlen); |
5129 | 412 } |
413 | |
414 return utf8; | |
415 } | |
416 | |
9830 | 417 static gchar * |
11159 | 418 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback) |
9830 | 419 { |
420 gchar *ret = NULL; | |
421 GError *err = NULL; | |
422 | |
9908 | 423 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
424 return NULL; | |
425 | |
426 if (strcasecmp("UTF-8", charsetstr)) { | |
427 if (fallback) | |
428 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
429 else | |
430 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
431 if (err != NULL) { | |
432 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
433 charsetstr, err->message); | |
434 g_error_free(err); | |
435 } | |
436 } else { | |
437 if (g_utf8_validate(data, datalen, NULL)) | |
438 ret = g_strndup(data, datalen); | |
439 else | |
440 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
441 } | |
442 | |
443 return ret; | |
444 } | |
445 | |
446 /* | |
11081 | 447 * This attemps to decode an incoming IM into a UTF8 string. |
448 * | |
9908 | 449 * We try decoding using two different character sets. The charset |
450 * specified in the IM determines the order in which we attempt to | |
451 * decode. We do this because there are lots of broken ICQ clients | |
452 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
453 * able to deal with that crap, then people complain like banshees. | |
454 * charsetstr1 is always set to what the correct encoding should be. | |
455 */ | |
456 static gchar * | |
11159 | 457 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, const gchar *data, gsize datalen) |
9908 | 458 { |
459 gchar *ret = NULL; | |
460 const gchar *charsetstr1, *charsetstr2; | |
461 | |
462 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 463 |
464 if ((datalen == 0) || (data == NULL)) | |
465 return NULL; | |
466 | |
9908 | 467 if (charset == AIM_CHARSET_UNICODE) { |
468 charsetstr1 = "UCS-2BE"; | |
469 charsetstr2 = "UTF-8"; | |
470 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 471 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 472 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 473 else |
9908 | 474 charsetstr1 = "ISO-8859-1"; |
475 charsetstr2 = "UTF-8"; | |
476 } else if (charset == AIM_CHARSET_ASCII) { | |
477 /* Should just be "ASCII" */ | |
9914 | 478 charsetstr1 = "ASCII"; |
9908 | 479 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
480 } else if (charset == 0x000d) { | |
9830 | 481 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 482 charsetstr1 = "ISO-8859-1"; |
483 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
484 } else { | |
9830 | 485 /* Unknown, hope for valid UTF-8... */ |
9908 | 486 charsetstr1 = "UTF-8"; |
487 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
488 } | |
489 | |
490 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
491 if (ret == NULL) | |
492 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
493 if (ret == NULL) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
494 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9830 | 495 |
496 return ret; | |
497 } | |
498 | |
11081 | 499 /* |
500 * Figure out what encoding to use when sending a given outgoing message. | |
501 */ | |
9830 | 502 static void |
503 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 504 gchar **msg, int *msglen_int, |
9830 | 505 fu16_t *charset, fu16_t *charsubset) |
506 { | |
507 OscarData *od = gc->proto_data; | |
508 GaimAccount *account = gaim_connection_get_account(gc); | |
509 GError *err = NULL; | |
510 aim_userinfo_t *userinfo = NULL; | |
511 const gchar *charsetstr; | |
10039 | 512 gsize msglen; |
9830 | 513 |
514 /* Attempt to send as ASCII */ | |
10098 | 515 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 516 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 517 *charset = AIM_CHARSET_ASCII; |
9830 | 518 *charsubset = 0x0000; |
10039 | 519 *msglen_int = msglen; |
9830 | 520 return; |
521 } | |
522 | |
523 /* | |
10565 | 524 * If we're sending to an ICQ user, and they are in our |
525 * buddy list, and they are advertising the Unicode | |
526 * capability, and they are online, then attempt to send | |
527 * as UCS-2BE. | |
9830 | 528 */ |
9975 | 529 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 530 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
531 | |
10565 | 532 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
533 { | |
534 GaimBuddy *b; | |
535 b = gaim_find_buddy(account, destsn); | |
536 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
537 { | |
538 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
539 if (*msg != NULL) | |
540 { | |
541 *charset = AIM_CHARSET_UNICODE; | |
542 *charsubset = 0x0000; | |
543 *msglen_int = msglen; | |
544 return; | |
545 } | |
9830 | 546 } |
547 } | |
548 | |
549 /* | |
550 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
551 * ICQ then attempt to send as the user specified character encoding. | |
552 */ | |
553 charsetstr = "ISO-8859-1"; | |
9975 | 554 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 555 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
556 | |
10097 | 557 /* |
558 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
559 * can be converted to "charsetstr" | |
560 */ | |
10039 | 561 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 562 if (*msg != NULL) { |
563 *charset = AIM_CHARSET_CUSTOM; | |
564 *charsubset = 0x0000; | |
10039 | 565 *msglen_int = msglen; |
9830 | 566 return; |
567 } | |
568 | |
569 /* | |
570 * Nothing else worked, so send as UCS-2BE. | |
571 */ | |
10039 | 572 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 573 if (*msg != NULL) { |
574 *charset = AIM_CHARSET_UNICODE; | |
575 *charsubset = 0x0000; | |
10039 | 576 *msglen_int = msglen; |
9830 | 577 return; |
578 } | |
579 | |
9908 | 580 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 581 g_error_free(err); |
582 | |
583 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
584 *msg = g_strdup(from); | |
10039 | 585 *msglen_int = strlen(*msg); |
9830 | 586 *charset = AIM_CHARSET_ASCII; |
587 *charsubset = 0x0000; | |
588 return; | |
589 } | |
590 | |
9407 | 591 gchar *oscar_caps_to_string(guint caps) |
8701 | 592 { |
9407 | 593 GString *str; |
594 gchar *tmp; | |
8701 | 595 guint bit = 1; |
596 | |
9407 | 597 str = g_string_new(""); |
598 | |
8701 | 599 if (!caps) { |
600 return NULL; | |
601 } else while (bit <= AIM_CAPS_LAST) { | |
602 if (bit & caps) { | |
603 switch (bit) { | |
604 case AIM_CAPS_BUDDYICON: | |
605 tmp = _("Buddy Icon"); | |
606 break; | |
607 case AIM_CAPS_TALK: | |
608 tmp = _("Voice"); | |
609 break; | |
610 case AIM_CAPS_DIRECTIM: | |
611 tmp = _("AIM Direct IM"); | |
612 break; | |
613 case AIM_CAPS_CHAT: | |
614 tmp = _("Chat"); | |
615 break; | |
616 case AIM_CAPS_GETFILE: | |
617 tmp = _("Get File"); | |
618 break; | |
619 case AIM_CAPS_SENDFILE: | |
620 tmp = _("Send File"); | |
621 break; | |
622 case AIM_CAPS_GAMES: | |
623 case AIM_CAPS_GAMES2: | |
624 tmp = _("Games"); | |
625 break; | |
626 case AIM_CAPS_ADDINS: | |
627 tmp = _("Add-Ins"); | |
628 break; | |
629 case AIM_CAPS_SENDBUDDYLIST: | |
630 tmp = _("Send Buddy List"); | |
631 break; | |
632 case AIM_CAPS_ICQ_DIRECT: | |
633 tmp = _("ICQ Direct Connect"); | |
634 break; | |
635 case AIM_CAPS_APINFO: | |
636 tmp = _("AP User"); | |
637 break; | |
638 case AIM_CAPS_ICQRTF: | |
639 tmp = _("ICQ RTF"); | |
640 break; | |
641 case AIM_CAPS_EMPTY: | |
642 tmp = _("Nihilist"); | |
643 break; | |
644 case AIM_CAPS_ICQSERVERRELAY: | |
645 tmp = _("ICQ Server Relay"); | |
646 break; | |
647 case AIM_CAPS_ICQUTF8OLD: | |
648 tmp = _("Old ICQ UTF8"); | |
649 break; | |
650 case AIM_CAPS_TRILLIANCRYPT: | |
651 tmp = _("Trillian Encryption"); | |
652 break; | |
653 case AIM_CAPS_ICQUTF8: | |
654 tmp = _("ICQ UTF8"); | |
655 break; | |
656 case AIM_CAPS_HIPTOP: | |
657 tmp = _("Hiptop"); | |
658 break; | |
659 case AIM_CAPS_SECUREIM: | |
660 tmp = _("Security Enabled"); | |
661 break; | |
662 case AIM_CAPS_VIDEO: | |
663 tmp = _("Video Chat"); | |
664 break; | |
665 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
666 case AIM_CAPS_ICHATAV: | |
667 tmp = _("iChat AV"); | |
668 break; | |
669 case AIM_CAPS_LIVEVIDEO: | |
670 tmp = _("Live Video"); | |
671 break; | |
672 case AIM_CAPS_CAMERA: | |
673 tmp = _("Camera"); | |
674 break; | |
675 default: | |
676 tmp = NULL; | |
677 break; | |
678 } | |
679 if (tmp) | |
9532 | 680 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 681 } |
682 bit <<= 1; | |
683 } | |
9407 | 684 |
685 return g_string_free(str, FALSE); | |
8701 | 686 } |
687 | |
688 static char *oscar_icqstatus(int state) { | |
689 /* Make a cute little string that shows the status of the dude or dudet */ | |
690 if (state & AIM_ICQ_STATE_CHAT) | |
691 return g_strdup_printf(_("Free For Chat")); | |
692 else if (state & AIM_ICQ_STATE_DND) | |
693 return g_strdup_printf(_("Do Not Disturb")); | |
694 else if (state & AIM_ICQ_STATE_OUT) | |
695 return g_strdup_printf(_("Not Available")); | |
696 else if (state & AIM_ICQ_STATE_BUSY) | |
697 return g_strdup_printf(_("Occupied")); | |
698 else if (state & AIM_ICQ_STATE_AWAY) | |
699 return g_strdup_printf(_("Away")); | |
700 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
701 return g_strdup_printf(_("Web Aware")); | |
702 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
703 return g_strdup_printf(_("Invisible")); | |
704 else | |
705 return g_strdup_printf(_("Online")); | |
706 } | |
707 | |
9973 | 708 static void |
709 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 710 { |
711 gchar *utf8; | |
712 | |
713 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 714 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 715 g_free(utf8); |
716 } | |
717 } | |
718 | |
9973 | 719 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 720 { |
10042 | 721 OscarData *od; |
722 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
723 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
724 GaimStatus *status = NULL; |
8701 | 725 GaimGroup *g = NULL; |
726 struct buddyinfo *bi = NULL; | |
727 char *tmp; | |
728 | |
10042 | 729 od = gc->proto_data; |
730 account = gaim_connection_get_account(gc); | |
731 | |
732 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 733 return; |
734 | |
735 if (userinfo == NULL) | |
736 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
737 | |
738 if (b == NULL) | |
10042 | 739 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 740 |
741 if (b != NULL) | |
10498 | 742 { |
8701 | 743 g = gaim_find_buddys_group(b); |
10498 | 744 presence = gaim_buddy_get_presence(b); |
745 status = gaim_presence_get_active_status(presence); | |
746 } | |
8701 | 747 |
748 if (userinfo != NULL) | |
749 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
750 | |
8733 | 751 if (b != NULL) { |
10498 | 752 if (gaim_presence_is_online(presence)) { |
9975 | 753 if (aim_sn_is_icq(b->name)) { |
8733 | 754 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
755 oscar_string_append(str, newline, _("Status"), tmp); | |
756 g_free(tmp); | |
757 } | |
758 } else { | |
9625 | 759 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 760 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
761 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
762 else | |
763 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 764 } |
8733 | 765 } |
8701 | 766 |
767 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 768 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 769 (bi->ipaddr & 0xff000000) >> 24, |
770 (bi->ipaddr & 0x00ff0000) >> 16, | |
771 (bi->ipaddr & 0x0000ff00) >> 8, | |
772 (bi->ipaddr & 0x000000ff)); | |
773 oscar_string_append(str, newline, _("IP Address"), tmp); | |
774 g_free(tmp); | |
775 } | |
776 | |
777 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
778 tmp = oscar_caps_to_string(userinfo->capabilities); | |
779 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 780 g_free(tmp); |
8701 | 781 } |
782 | |
783 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
784 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
785 if (tmp != NULL) { | |
9625 | 786 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 787 g_free(tmp); |
9625 | 788 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
789 g_free(tmp2); | |
8701 | 790 } |
791 } | |
792 | |
10498 | 793 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_status_is_available(status)) { |
8701 | 794 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
795 oscar_string_append(str, newline, _("Available"), tmp); | |
796 g_free(tmp); | |
797 } | |
798 } | |
799 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
800 static char *extract_name(const char *name) { |
4121 | 801 char *tmp, *x; |
2086 | 802 int i, j; |
4120 | 803 |
804 if (!name) | |
4121 | 805 return NULL; |
10042 | 806 |
4120 | 807 x = strchr(name, '-'); |
4121 | 808 |
2086 | 809 if (!x) return NULL; |
810 x = strchr(++x, '-'); | |
811 if (!x) return NULL; | |
812 tmp = g_strdup(++x); | |
813 | |
814 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
815 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
816 if (x[i] != '%') { |
2086 | 817 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
818 continue; |
2086 | 819 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
820 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
821 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
822 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 823 } |
824 | |
825 tmp[j] = 0; | |
826 return tmp; | |
827 } | |
828 | |
10458 | 829 static struct chat_connection * |
830 find_oscar_chat(GaimConnection *gc, int id) | |
831 { | |
832 OscarData *od = (OscarData *)gc->proto_data; | |
833 GSList *cur; | |
834 struct chat_connection *cc; | |
835 | |
836 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
837 { | |
838 cc = (struct chat_connection *)cur->data; | |
839 if (cc->id == id) | |
840 return cc; | |
841 } | |
842 | |
843 return NULL; | |
844 } | |
845 | |
846 static struct chat_connection * | |
847 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
848 { | |
849 OscarData *od = (OscarData *)gc->proto_data; | |
850 GSList *cur; | |
851 struct chat_connection *cc; | |
852 | |
853 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
854 { | |
855 cc = (struct chat_connection *)cur->data; | |
856 if (cc->conn == conn) | |
857 return cc; | |
858 } | |
859 | |
860 return NULL; | |
861 } | |
862 | |
863 static struct chat_connection * | |
864 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
865 { | |
866 OscarData *od = (OscarData *)gc->proto_data; | |
867 GSList *cur; | |
868 struct chat_connection *cc; | |
869 | |
870 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
871 { | |
872 cc = (struct chat_connection *)cur->data; | |
873 if (cc->conv == conv) | |
874 return cc; | |
875 } | |
876 | |
877 return NULL; | |
878 } | |
879 | |
880 static void | |
881 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
882 { | |
883 OscarData *od = (OscarData *)gc->proto_data; | |
884 | |
885 /* Notify the conversation window that we've left the chat */ | |
886 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
887 | |
888 /* Destroy the chat_connection */ | |
889 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
890 if (cc->inpa > 0) | |
891 gaim_input_remove(cc->inpa); | |
892 aim_conn_kill(od->sess, &cc->conn); | |
893 g_free(cc->name); | |
894 g_free(cc->show); | |
895 g_free(cc); | |
8219 | 896 } |
897 | |
8971 | 898 /***************************************************************************** |
899 * Begin scary direct im stuff | |
900 *****************************************************************************/ | |
901 | |
902 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
903 GSList *d = od->direct_ims; | |
904 struct oscar_direct_im *m = NULL; | |
905 | |
906 while (d) { | |
907 m = (struct oscar_direct_im *)d->data; | |
908 if (!aim_sncmp(who, m->name)) | |
909 return m; | |
910 d = d->next; | |
911 } | |
912 | |
913 return NULL; | |
914 } | |
915 | |
916 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
917 { | |
918 gaim_debug_info("oscar", | |
919 "destroying Direct IM for %s.\n", dim->name); | |
920 | |
921 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 922 if (dim->gpc_pend) { |
923 dim->killme = TRUE; | |
924 return; | |
925 } | |
8971 | 926 if (dim->watcher) |
927 gaim_input_remove(dim->watcher); | |
928 if (dim->conn) { | |
10271 | 929 aim_conn_close(dim->conn); |
8971 | 930 aim_conn_kill(od->sess, &dim->conn); |
931 } | |
932 g_free(dim); | |
933 } | |
934 | |
935 /* the only difference between this and destroy is this writes a conv message */ | |
936 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
937 { | |
938 GaimConversation *conv; | |
939 char buf[256]; | |
940 | |
941 gaim_debug_info("oscar", | |
942 "%s disconnected Direct IM.\n", dim->name); | |
943 | |
944 if (dim->connected) | |
945 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 946 else |
8971 | 947 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
948 | |
10246 | 949 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
950 gaim_connection_get_account(dim->gc)); | |
8971 | 951 if (conv) { |
952 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 953 gaim_conversation_update_progress(conv, 0); |
8971 | 954 } else { |
955 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
956 } | |
957 | |
958 oscar_direct_im_destroy(od, dim); | |
959 | |
960 return; | |
961 } | |
962 | |
963 /* oops i made two of these. this one just calls the other one. */ | |
964 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
965 { | |
966 GaimConnection *gc = sess->aux_data; | |
967 OscarData *od = (OscarData *)gc->proto_data; | |
968 struct oscar_direct_im *dim; | |
969 char *sn; | |
970 | |
971 sn = g_strdup(aim_odc_getsn(conn)); | |
972 dim = oscar_direct_im_find(od, sn); | |
973 oscar_direct_im_disconnect(od, dim); | |
974 g_free(sn); | |
975 } | |
976 | |
977 static void destroy_direct_im_request(struct ask_direct *d) { | |
978 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
979 | |
980 g_free(d->sn); | |
981 g_free(d); | |
982 } | |
983 | |
984 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
985 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
986 struct oscar_direct_im *dim = data; | |
987 GaimConnection *gc = dim->gc; | |
988 OscarData *od = gc->proto_data; | |
989 GaimConversation *conv; | |
990 char buf[256]; | |
991 struct sockaddr name; | |
992 socklen_t name_len = 1; | |
993 | |
994 g_return_if_fail(gc != NULL); | |
995 | |
8978 | 996 dim->gpc_pend = FALSE; |
997 if (dim->killme) { | |
998 oscar_direct_im_destroy(od, dim); | |
999 return; | |
1000 } | |
1001 | |
8971 | 1002 if (!g_list_find(gaim_connections_get_all(), gc)) { |
1003 oscar_direct_im_destroy(od, dim); | |
1004 return; | |
1005 } | |
1006 | |
1007 if (source < 0) { | |
8984 | 1008 if (dim->donttryagain) { |
1009 oscar_direct_im_disconnect(od, dim); | |
1010 return; | |
1011 } else { | |
11159 | 1012 guchar cookie[8]; |
8984 | 1013 char *who = g_strdup(dim->name); |
11159 | 1014 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1015 |
1016 memcpy(cookie, tmp, 8); | |
1017 oscar_direct_im_destroy(od, dim); | |
1018 oscar_direct_im_initiate(gc, who, cookie); | |
1019 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1020 g_free(who); | |
1021 return; | |
1022 } | |
8971 | 1023 } |
1024 | |
1025 dim->conn->fd = source; | |
1026 aim_conn_completeconnect(od->sess, dim->conn); | |
1027 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
1028 | |
1029 /* This is the best way to see if we're connected or not */ | |
8983 | 1030 /* Is this really needed? */ |
8971 | 1031 if (getpeername(source, &name, &name_len) == 0) { |
1032 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1033 dim->connected = TRUE; | |
1034 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1035 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1036 } else { | |
8984 | 1037 if (dim->donttryagain) { |
1038 oscar_direct_im_disconnect(od, dim); | |
1039 return; | |
1040 } else { | |
11159 | 1041 guchar cookie[8]; |
8984 | 1042 char *who = g_strdup(dim->name); |
11159 | 1043 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1044 |
1045 memcpy(cookie, tmp, 8); | |
1046 oscar_direct_im_destroy(od, dim); | |
1047 oscar_direct_im_initiate(gc, who, cookie); | |
1048 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1049 g_free(who); | |
1050 return; | |
1051 } | |
8983 | 1052 } |
1053 | |
1054 | |
8971 | 1055 } |
1056 | |
1057 static void accept_direct_im_request(struct ask_direct *d) { | |
1058 GaimConnection *gc = d->gc; | |
1059 OscarData *od; | |
1060 struct oscar_direct_im *dim; | |
1061 char *host; int port = 5190; | |
1062 int i, rc; | |
8982 | 1063 char *tmp; |
1064 GaimConversation *conv; | |
8971 | 1065 |
1066 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1067 destroy_direct_im_request(d); | |
1068 return; | |
1069 } | |
1070 | |
1071 od = (OscarData *)gc->proto_data; | |
1072 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1073 | |
1074 dim = oscar_direct_im_find(od, d->sn); | |
1075 if (dim && dim->connected) { | |
1076 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1077 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1078 return; | |
1079 } | |
1080 dim = g_new0(struct oscar_direct_im, 1); | |
1081 dim->gc = d->gc; | |
8984 | 1082 dim->donttryagain = d->donttryagain; |
8971 | 1083 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1084 | |
1085 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1086 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1087 if (!dim->conn) { | |
1088 oscar_direct_im_disconnect(od, dim); | |
1089 destroy_direct_im_request(d); | |
1090 return; | |
1091 } | |
1092 | |
1093 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1094 gaim_odc_incoming, 0); | |
1095 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1096 gaim_odc_typing, 0); | |
1097 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1098 gaim_odc_update_ui, 0); | |
1099 | |
1100 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1101 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1102 if (d->ip[i] == ':') { | |
1103 port = atoi(&(d->ip[i+1])); | |
1104 break; | |
1105 } | |
1106 } | |
1107 host = g_strndup(d->ip, i); | |
1108 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1109 dim->gpc_pend = TRUE; |
8971 | 1110 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1111 |
1112 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1113 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1114 port); | |
1115 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1116 g_free(tmp); | |
8983 | 1117 |
8971 | 1118 g_free(host); |
1119 if (rc < 0) { | |
8978 | 1120 dim->gpc_pend = FALSE; |
8971 | 1121 oscar_direct_im_disconnect(od, dim); |
1122 destroy_direct_im_request(d); | |
1123 return; | |
1124 } | |
1125 | |
1126 destroy_direct_im_request(d); | |
1127 | |
1128 return; | |
1129 } | |
1130 | |
1131 /* | |
1132 * We have just established a socket with the other dude, so set up some handlers. | |
1133 */ | |
1134 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1135 GaimConnection *gc = sess->aux_data; |
7283 | 1136 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1137 GaimConversation *conv; |
8971 | 1138 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1139 char buf[256]; |
8971 | 1140 char *sn; |
1141 va_list ap; | |
1142 aim_conn_t *newconn, *listenerconn; | |
1143 | |
1144 va_start(ap, fr); | |
1145 newconn = va_arg(ap, aim_conn_t *); | |
1146 listenerconn = va_arg(ap, aim_conn_t *); | |
1147 va_end(ap); | |
1148 | |
10271 | 1149 aim_conn_close(listenerconn); |
8971 | 1150 aim_conn_kill(sess, &listenerconn); |
1151 | |
1152 sn = g_strdup(aim_odc_getsn(newconn)); | |
1153 | |
1154 gaim_debug_info("oscar", | |
1155 "DirectIM: initiate success to %s\n", sn); | |
1156 dim = oscar_direct_im_find(od, sn); | |
1157 | |
1158 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1159 gaim_input_remove(dim->watcher); | |
1160 dim->conn = newconn; | |
1161 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1162 dim->connected = TRUE; | |
1163 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1164 g_free(sn); | |
1165 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1166 | |
1167 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1168 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1169 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1170 | |
1171 return 1; | |
1172 } | |
1173 | |
1174 /* | |
1175 * This is called when each chunk of an image is received. It can be used to | |
1176 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1177 * nasty, you sicko. | |
1178 */ | |
1179 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1180 va_list ap; | |
1181 char *sn; | |
1182 double percent; | |
1183 GaimConnection *gc = sess->aux_data; | |
1184 OscarData *od = (OscarData *)gc->proto_data; | |
1185 GaimConversation *c; | |
1186 struct oscar_direct_im *dim; | |
1187 | |
1188 va_start(ap, fr); | |
1189 sn = va_arg(ap, char *); | |
1190 percent = va_arg(ap, double); | |
1191 va_end(ap); | |
1192 | |
1193 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1194 return 1; | |
1195 if (dim->watcher) { | |
1196 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1197 /* The callback will callback? I don't get how that would happen here. */ | |
1198 dim->watcher = 0; | |
1199 } | |
1200 | |
10246 | 1201 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1202 gaim_connection_get_account(gc)); | |
8971 | 1203 if (c != NULL) |
1204 gaim_conversation_update_progress(c, percent); | |
1205 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1206 oscar_callback, dim->conn); | |
1207 | |
1208 return 1; | |
1209 } | |
1210 | |
1211 /* | |
1212 * This is called after a direct IM has been received in its entirety. This | |
1213 * function is passed a long chunk of data which contains the IM with any | |
1214 * data chunks (images) appended to it. | |
1215 * | |
1216 * This function rips out all the data chunks and creates an imgstore for | |
1217 * each one. In order to do this, it first goes through the IM and takes | |
1218 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1219 * with one compatible with the imgstore Gaim core code. For each one, we | |
1220 * then read in chunks of data from the end of the message and actually | |
1221 * create the img store using the given data. | |
1222 * | |
1223 * For somewhat easy reference, here's a sample message | |
1224 * (without the whitespace and asterisks): | |
1225 * | |
1226 * <HTML><BODY BGCOLOR="#ffffff"> | |
1227 * <FONT LANG="0"> | |
1228 * This is a really stupid picture:<BR> | |
1229 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1230 * Yeah it is<BR> | |
1231 * Here is another one:<BR> | |
1232 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1233 * </FONT> | |
1234 * </BODY></HTML> | |
1235 * <BINARY> | |
1236 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1237 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1238 * </BINARY> | |
1239 */ | |
1240 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1241 GaimConnection *gc = sess->aux_data; | |
1242 GaimConvImFlags imflags = 0; | |
1243 gchar *utf8; | |
1244 GString *newmsg = g_string_new(""); | |
1245 GSList *images = NULL; | |
1246 va_list ap; | |
1247 const char *sn, *msg, *msgend, *binary; | |
1248 size_t len; | |
1249 int encoding, isawaymsg; | |
1250 | |
1251 va_start(ap, fr); | |
1252 sn = va_arg(ap, const char *); | |
1253 msg = va_arg(ap, const char *); | |
1254 len = va_arg(ap, size_t); | |
1255 encoding = va_arg(ap, int); | |
1256 isawaymsg = va_arg(ap, int); | |
1257 va_end(ap); | |
1258 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1259 |
8660 | 1260 gaim_debug_info("oscar", |
8971 | 1261 "Got DirectIM message from %s\n", sn); |
1262 | |
1263 if (isawaymsg) | |
1264 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1265 | |
1266 /* message has a binary trailer */ | |
1267 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1268 GData *attribs; | |
1269 const char *tmp, *start, *end, *last = NULL; | |
1270 | |
1271 tmp = msg; | |
1272 | |
1273 /* for each valid image tag... */ | |
1274 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1275 const char *id, *src, *datasize; | |
10504 | 1276 const char *data = NULL; |
1277 char *tag = NULL; | |
8971 | 1278 size_t size; |
1279 int imgid = 0; | |
1280 | |
1281 /* update the location of the last img tag */ | |
1282 last = end; | |
1283 | |
1284 /* grab attributes */ | |
1285 id = g_datalist_get_data(&attribs, "id"); | |
1286 src = g_datalist_get_data(&attribs, "src"); | |
1287 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1288 | |
1289 /* if we have id & datasize, build the data tag */ | |
1290 if (id && datasize) | |
1291 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1292 | |
1293 /* if we have a tag, find the start of the data */ | |
1294 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1295 data += strlen(tag); | |
1296 | |
10504 | 1297 g_free(tag); |
1298 | |
8971 | 1299 /* check the data is here and store it */ |
1300 if (data + (size = atoi(datasize)) <= msgend) | |
1301 imgid = gaim_imgstore_add(data, size, src); | |
1302 | |
1303 /* | |
1304 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1305 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1306 */ | |
1307 /* if we have a stored image... */ | |
1308 if (imgid) { | |
1309 /* append the message up to the tag */ | |
1310 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1311 if (utf8 != NULL) { | |
1312 newmsg = g_string_append(newmsg, utf8); | |
1313 g_free(utf8); | |
1314 } | |
1315 | |
1316 /* write the new image tag */ | |
1317 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1318 | |
1319 /* and record the image number */ | |
1320 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1321 } else { | |
1322 /* otherwise, copy up to the end of the tag */ | |
1323 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1324 if (utf8 != NULL) { | |
1325 newmsg = g_string_append(newmsg, utf8); | |
1326 g_free(utf8); | |
1327 } | |
1328 } | |
1329 | |
1330 /* clear the attribute list */ | |
1331 g_datalist_clear(&attribs); | |
1332 | |
1333 /* continue from the end of the tag */ | |
1334 tmp = end + 1; | |
1335 } | |
1336 | |
1337 /* append any remaining message data (without the > :-) */ | |
1338 if (last++ && (last < binary)) | |
1339 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1340 | |
1341 /* set the flag if we caught any images */ | |
1342 if (images) | |
1343 imflags |= GAIM_CONV_IM_IMAGES; | |
1344 } else { | |
1345 g_string_append_len(newmsg, msg, len); | |
1346 } | |
1347 | |
10318 | 1348 /* Convert to UTF8 */ |
1349 /* (This hasn't been tested very much) */ | |
1350 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1351 if (utf8 != NULL) { | |
1352 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1353 g_free(utf8); | |
1354 } | |
1355 | |
1356 /* free the message */ | |
8971 | 1357 g_string_free(newmsg, TRUE); |
1358 | |
1359 /* unref any images we allocated */ | |
1360 if (images) { | |
1361 GSList *tmp; | |
1362 int id; | |
1363 | |
1364 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1365 id = GPOINTER_TO_INT(tmp->data); | |
1366 gaim_imgstore_unref(id); | |
1367 } | |
1368 | |
1369 g_slist_free(images); | |
1370 } | |
1371 | |
1372 return 1; | |
1373 } | |
1374 | |
1375 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1376 va_list ap; | |
1377 char *sn; | |
1378 int typing; | |
1379 GaimConnection *gc = sess->aux_data; | |
1380 | |
1381 va_start(ap, fr); | |
1382 sn = va_arg(ap, char *); | |
1383 typing = va_arg(ap, int); | |
1384 va_end(ap); | |
1385 | |
1386 if (typing == 0x0002) { | |
1387 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1388 gaim_debug_info("oscar", | |
1389 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1390 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1391 } else if (typing == 0x0001) | |
1392 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1393 else | |
1394 serv_got_typing_stopped(gc, sn); | |
1395 return 1; | |
1396 } | |
1397 | |
1398 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1399 char *buf; | |
1400 size_t len; | |
1401 int ret; | |
1402 GString *msg = g_string_new("<HTML><BODY>"); | |
1403 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1404 GData *attribs; | |
1405 const char *start, *end, *last; | |
1406 int oscar_id = 0; | |
1407 | |
1408 last = message; | |
1409 | |
1410 /* for each valid IMG tag... */ | |
1411 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1412 GaimStoredImage *image = NULL; | |
1413 const char *id; | |
1414 | |
1415 if (start - last) { | |
1416 g_string_append_len(msg, last, start - last); | |
1417 } | |
1418 | |
1419 id = g_datalist_get_data(&attribs, "id"); | |
1420 | |
1421 /* ... if it refers to a valid gaim image ... */ | |
1422 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1423 /* ... append the message from start to the tag ... */ | |
9126 | 1424 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1425 const char *filename = gaim_imgstore_get_filename(image); |
1426 gpointer imgdata = gaim_imgstore_get_data(image); | |
1427 | |
1428 oscar_id++; | |
1429 | |
1430 /* ... insert a new img tag with the oscar id ... */ | |
1431 if (filename) | |
1432 g_string_append_printf(msg, | |
9126 | 1433 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1434 filename, oscar_id, size); |
1435 else | |
1436 g_string_append_printf(msg, | |
9126 | 1437 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1438 oscar_id, size); |
1439 | |
1440 /* ... and append the data to the binary section ... */ | |
9126 | 1441 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1442 oscar_id, size); |
1443 data = g_string_append_len(data, imgdata, size); | |
1444 data = g_string_append(data, "</DATA>"); | |
1445 } | |
1446 /* If the tag is invalid, skip it, thus no else here */ | |
1447 | |
1448 g_datalist_clear(&attribs); | |
1449 | |
1450 /* continue from the end of the tag */ | |
1451 last = end + 1; | |
1452 } | |
1453 | |
1454 /* append any remaining message data (without the > :-) */ | |
1455 if (last && *last) | |
1456 msg = g_string_append(msg, last); | |
1457 | |
1458 /* if we inserted any images in the binary section, append it */ | |
1459 if (oscar_id) { | |
1460 msg = g_string_append_len(msg, data->str, data->len); | |
1461 msg = g_string_append(msg, "</BINARY>"); | |
1462 } | |
1463 | |
1464 len = msg->len; | |
1465 buf = msg->str; | |
1466 g_string_free(msg, FALSE); | |
1467 g_string_free(data, TRUE); | |
1468 | |
1469 | |
1470 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1471 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1472 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1473 else | |
1474 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1475 | |
1476 g_free(buf); | |
1477 | |
1478 return ret; | |
1479 } | |
1480 | |
1481 struct ask_do_dir_im { | |
1482 char *who; | |
1483 GaimConnection *gc; | |
1484 }; | |
1485 | |
1486 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1487 g_free(data->who); | |
1488 g_free(data); | |
1489 } | |
1490 | |
8983 | 1491 /* this function is used to initiate a direct im session with someone. |
1492 * we start listening on a port and send a request. they either connect | |
1493 * or send some kind of reply. If they can't connect, they ask us to | |
1494 * connect to them, and so we do that. | |
1495 * | |
1496 * this function will also get called if the other side initiate's a direct | |
1497 * im and we try to connect and fail. in that case cookie will not be null. | |
1498 * | |
1499 * note that cookie is an 8 byte string that isn't NULL terminated | |
1500 */ | |
11159 | 1501 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie) { |
8971 | 1502 OscarData *od; |
1503 struct oscar_direct_im *dim; | |
1504 int listenfd; | |
8982 | 1505 const char *ip; |
8971 | 1506 |
1507 od = (OscarData *)gc->proto_data; | |
1508 | |
8983 | 1509 dim = oscar_direct_im_find(od, who); |
8971 | 1510 if (dim) { |
1511 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1512 oscar_direct_im_disconnect(od, dim); | |
1513 gaim_debug_info("oscar", | |
1514 "Gave up on old direct IM, trying again\n"); | |
1515 } else { | |
1516 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1517 return; |
8971 | 1518 } |
1519 } | |
1520 dim = g_new0(struct oscar_direct_im, 1); | |
1521 dim->gc = gc; | |
8983 | 1522 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1523 |
1524 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1525 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1526 if (listenfd >= 0) |
1527 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1528 if (dim->conn != NULL) { |
8982 | 1529 char *tmp; |
1530 GaimConversation *conv; | |
1531 | |
8971 | 1532 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1533 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1534 oscar_callback, dim->conn); | |
1535 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1536 gaim_odc_initiate, 0); | |
8982 | 1537 |
8983 | 1538 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1539 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1540 gaim_network_get_port_from_fd(listenfd)); |
1541 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1542 g_free(tmp); | |
8971 | 1543 } else { |
1544 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1545 oscar_direct_im_destroy(od, dim); | |
1546 } | |
8983 | 1547 } |
1548 | |
1549 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1550 GaimConnection *gc = data->gc; | |
1551 | |
1552 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1553 g_free(data->who); | |
1554 g_free(data); | |
1555 return; | |
1556 } | |
1557 | |
1558 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1559 g_free(data->who); |
1560 g_free(data); | |
1561 } | |
1562 | |
1563 /* this is the right click menu cb thingy */ | |
9030 | 1564 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1565 | |
1566 GaimBuddy *buddy; | |
1567 GaimConnection *gc; | |
8971 | 1568 gchar *buf; |
9030 | 1569 struct ask_do_dir_im *data; |
1570 | |
1571 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1572 | |
1573 buddy = (GaimBuddy *) node; | |
1574 gc = gaim_account_get_connection(buddy->account); | |
1575 | |
1576 data = g_new0(struct ask_do_dir_im, 1); | |
1577 data->who = g_strdup(buddy->name); | |
8971 | 1578 data->gc = gc; |
9030 | 1579 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1580 buddy->name); | |
8971 | 1581 |
1582 gaim_request_action(gc, NULL, buf, | |
9030 | 1583 _("Because this reveals your IP address, it " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1584 "may be considered a privacy risk. Do you " |
9030 | 1585 "wish to continue?"), |
1586 0, data, 2, | |
1587 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1588 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1589 g_free(buf); |
1590 } | |
1591 | |
1592 /***************************************************************************** | |
1593 * End scary direct im stuff | |
1594 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1595 |
4617 | 1596 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1597 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1598 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1599 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1600 OscarData *od; |
2086 | 1601 |
1602 if (!gc) { | |
8660 | 1603 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1604 "oscar callback for closed connection (1).\n"); |
2086 | 1605 return; |
1606 } | |
10458 | 1607 |
7283 | 1608 od = (OscarData *)gc->proto_data; |
2086 | 1609 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1610 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1611 /* oh boy. this is probably bad. i guess the only thing we |
1612 * can really do is return? */ | |
8660 | 1613 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1614 "oscar callback for closed connection (2).\n"); |
8660 | 1615 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1616 return; |
1617 } | |
1618 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1619 if (condition & GAIM_INPUT_READ) { |
4617 | 1620 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1621 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1622 "got information on rendezvous listener\n"); |
4617 | 1623 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1624 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1625 "connection error (rendezvous listener)\n"); |
4617 | 1626 aim_conn_kill(od->sess, &conn); |
8446 | 1627 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1628 } |
1629 } else { | |
4617 | 1630 if (aim_get_command(od->sess, conn) >= 0) { |
1631 aim_rxdispatch(od->sess); | |
6029 | 1632 if (od->killme) { |
8660 | 1633 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1634 return; |
1635 } | |
2086 | 1636 } else { |
1637 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
10444 | 1638 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1639 { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1640 gaim_debug_error("oscar", "Major connection error. i.e. " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1641 "invalid data was received on the oscar TCP stream\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1642 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1643 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1644 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1645 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1646 char *buf; |
10458 | 1647 |
1648 gaim_debug_info("oscar", "Lost connection " | |
1649 "to chat room %s\n", cc->name); | |
1650 | |
1651 buf = g_strdup_printf(_("You have lost your connection " | |
1652 "to chat room %s."), cc->name); | |
1653 if (conv != NULL) | |
9627 | 1654 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1655 else | |
1656 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1657 g_free(buf); |
10458 | 1658 |
1659 oscar_chat_kill(gc, cc); | |
1660 | |
2086 | 1661 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1662 if (od->cnpa > 0) |
1663 gaim_input_remove(od->cnpa); | |
1664 od->cnpa = 0; | |
8660 | 1665 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1666 "removing chatnav input watcher\n"); |
4617 | 1667 while (od->create_rooms) { |
1668 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1669 g_free(cr->name); |
4617 | 1670 od->create_rooms = |
1671 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1672 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1673 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1674 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1675 NULL); |
2086 | 1676 } |
4617 | 1677 aim_conn_kill(od->sess, &conn); |
2086 | 1678 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1679 if (od->paspa > 0) |
1680 gaim_input_remove(od->paspa); | |
1681 od->paspa = 0; | |
8660 | 1682 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1683 "removing authconn input watcher\n"); |
4617 | 1684 aim_conn_kill(od->sess, &conn); |
3694 | 1685 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1686 if (od->emlpa > 0) |
1687 gaim_input_remove(od->emlpa); | |
1688 od->emlpa = 0; | |
8660 | 1689 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1690 "removing email input watcher\n"); |
4617 | 1691 aim_conn_kill(od->sess, &conn); |
4804 | 1692 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1693 if (od->icopa > 0) | |
1694 gaim_input_remove(od->icopa); | |
1695 od->icopa = 0; | |
8660 | 1696 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1697 "removing icon input watcher\n"); |
4804 | 1698 aim_conn_kill(od->sess, &conn); |
2086 | 1699 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1700 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1701 gaim_odc_disconnect(od->sess, conn); |
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 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1714 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1715 GaimConnection *gc = sess->aux_data; |
7285 | 1716 gchar *s = g_strdup_vprintf(format, va); |
1717 gchar *buf; | |
1718 | |
1719 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1720 gaim_debug_info("oscar", buf); |
7285 | 1721 if (buf[strlen(buf)-1] != '\n') |
8660 | 1722 gaim_debug_info(NULL, "\n"); |
7285 | 1723 g_free(buf); |
2086 | 1724 g_free(s); |
1725 } | |
1726 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1727 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1728 { |
5575 | 1729 GaimConnection *gc = data; |
7283 | 1730 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1731 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1732 aim_conn_t *conn; |
2086 | 1733 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1734 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1735 close(source); |
1736 return; | |
1737 } | |
1738 | |
4617 | 1739 od = gc->proto_data; |
1740 sess = od->sess; | |
2086 | 1741 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1742 conn->fd = source; |
2086 | 1743 |
1744 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1745 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1746 return; |
1747 } | |
1748 | |
1749 aim_conn_completeconnect(sess, conn); | |
4617 | 1750 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1751 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1752 | |
8660 | 1753 gaim_debug_info("oscar", |
7282 | 1754 "Screen name sent, waiting for response\n"); |
7283 | 1755 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1756 ck[1] = 0x65; |
2086 | 1757 } |
1758 | |
10444 | 1759 static void |
1760 oscar_login(GaimAccount *account, GaimStatus *status) | |
1761 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1762 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1763 aim_conn_t *conn; |
5575 | 1764 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1765 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
10400 | 1766 GaimStatusType *status_type; |
1767 GaimStatusPrimitive primitive; | |
1768 | |
1769 status_type = gaim_status_get_type(status); | |
1770 primitive = gaim_status_type_get_primitive(status_type); | |
2086 | 1771 |
8660 | 1772 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
10444 | 1773 |
10400 | 1774 if (primitive == GAIM_STATUS_OFFLINE) |
1775 return; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1776 |
8437 | 1777 if (!aim_snvalid(gaim_account_get_username(account))) { |
1778 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1779 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 | 1780 gaim_connection_error(gc, buf); |
1781 g_free(buf); | |
1782 } | |
1783 | |
9975 | 1784 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1785 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1786 } else { |
6622 | 1787 gc->flags |= GAIM_CONNECTION_HTML; |
1788 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1789 } |
5836 | 1790 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1791 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1792 sess = g_new0(aim_session_t, 1); |
10329 | 1793 aim_session_init(sess, TRUE, FAIM_DEBUG_LEVEL); |
2086 | 1794 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1795 /* |
1796 * We need an immediate queue because we don't use a while-loop | |
1797 * to see if things need to be sent. | |
1798 */ | |
2086 | 1799 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1800 od->sess = sess; |
2086 | 1801 sess->aux_data = gc; |
1802 | |
9935 | 1803 /* Connect to core Gaim signals */ |
10087 | 1804 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1805 |
2086 | 1806 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1807 if (conn == NULL) { | |
10444 | 1808 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1809 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1810 return; |
1811 } | |
1812 | |
4649 | 1813 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1814 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1815 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1816 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1817 |
1818 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1819 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1820 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1821 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1822 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1823 return; |
1824 } | |
7282 | 1825 |
7283 | 1826 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1827 ck[0] = 0x5a; |
5575 | 1828 } |
1829 | |
1830 static void oscar_close(GaimConnection *gc) { | |
7283 | 1831 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1832 |
1833 while (od->oscar_chats) { | |
1834 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1835 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1836 gaim_input_remove(n->inpa); |
2086 | 1837 g_free(n->name); |
1838 g_free(n->show); | |
4617 | 1839 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1840 g_free(n); |
1841 } | |
4617 | 1842 while (od->direct_ims) { |
8971 | 1843 struct oscar_direct_im *n = od->direct_ims->data; |
1844 oscar_direct_im_destroy(od, n); | |
2086 | 1845 } |
4617 | 1846 /* BBB */ |
1847 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1848 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1849 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1850 gaim_xfer_cancel_local(xfer); |
3630 | 1851 } |
4804 | 1852 while (od->requesticon) { |
1853 char *sn = od->requesticon->data; | |
1854 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1855 free(sn); | |
1856 } | |
4738 | 1857 g_hash_table_destroy(od->buddyinfo); |
4617 | 1858 while (od->create_rooms) { |
1859 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1860 g_free(cr->name); |
4617 | 1861 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1862 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1863 } |
4617 | 1864 if (od->email) |
1865 g_free(od->email); | |
1866 if (od->newp) | |
1867 g_free(od->newp); | |
1868 if (od->oldp) | |
1869 g_free(od->oldp); | |
2086 | 1870 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1871 gaim_input_remove(gc->inpa); |
4617 | 1872 if (od->cnpa > 0) |
1873 gaim_input_remove(od->cnpa); | |
1874 if (od->paspa > 0) | |
1875 gaim_input_remove(od->paspa); | |
1876 if (od->emlpa > 0) | |
1877 gaim_input_remove(od->emlpa); | |
4804 | 1878 if (od->icopa > 0) |
1879 gaim_input_remove(od->icopa); | |
6907 | 1880 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1881 gaim_timeout_remove(od->icontimer); |
8341 | 1882 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1883 gaim_timeout_remove(od->getblisttimer); |
8341 | 1884 if (od->getinfotimer > 0) |
1885 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1886 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1887 |
4617 | 1888 aim_session_kill(od->sess); |
1889 g_free(od->sess); | |
1890 od->sess = NULL; | |
2086 | 1891 g_free(gc->proto_data); |
1892 gc->proto_data = NULL; | |
8660 | 1893 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1894 } |
1895 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1896 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1897 GaimConnection *gc = data; |
7283 | 1898 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1899 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1900 aim_conn_t *bosconn; |
2086 | 1901 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1902 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1903 close(source); |
1904 return; | |
1905 } | |
1906 | |
4617 | 1907 od = gc->proto_data; |
1908 sess = od->sess; | |
1909 bosconn = od->conn; | |
4366 | 1910 bosconn->fd = source; |
2086 | 1911 |
1912 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1913 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1914 return; |
1915 } | |
1916 | |
1917 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1918 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1919 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1920 gaim_connection_update_progress(gc, |
7283 | 1921 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1922 ck[4] = 0x61; |
2086 | 1923 } |
1924 | |
4617 | 1925 /* BBB */ |
4656 | 1926 /* |
1927 * This little area in oscar.c is the nexus of file transfer code, | |
1928 * so I wrote a little explanation of what happens. I am such a | |
1929 * ninja. | |
1930 * | |
1931 * The series of events for a file send is: | |
1932 * -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
|
1933 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1934 * listening socket, then asks the remote user to connect to us (and |
1935 * gives them the file name, port, IP, etc.) | |
1936 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1937 * in oscar_sendfile_estblsh) | |
1938 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1939 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1940 * connection. | |
1941 * -We get drunk because file transfer kicks ass. | |
1942 * | |
1943 * The series of events for a file receive is: | |
1944 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1945 * -Gaim user selects file to name and location to save file to and | |
1946 * oscar_xfer_init is called | |
1947 * -It connects to the remote user using the IP they gave us earlier | |
1948 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1949 * them an AIM_CB_OFT_ACK. | |
1950 * -They begin to send us lots of raw data. | |
1951 * -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
|
1952 * the connection. |
4656 | 1953 */ |
1954 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1955 | |
8446 | 1956 /* |
1957 * Miscellaneous xfer functions | |
1958 */ | |
1959 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1960 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1961 GaimXfer *xfer; |
5146 | 1962 struct aim_oft_info *oft_info; |
4656 | 1963 |
1964 while (fts) { | |
1965 xfer = fts->data; | |
5146 | 1966 oft_info = xfer->data; |
1967 | |
8446 | 1968 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1969 return xfer; |
1970 | |
1971 fts = g_slist_next(fts); | |
1972 } | |
1973 | |
1974 return NULL; | |
1975 } | |
1976 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1977 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1978 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1979 GaimXfer *xfer; |
5146 | 1980 struct aim_oft_info *oft_info; |
4656 | 1981 |
1982 while (fts) { | |
1983 xfer = fts->data; | |
5146 | 1984 oft_info = xfer->data; |
1985 | |
1986 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1987 return xfer; |
1988 | |
1989 fts = g_slist_next(fts); | |
1990 } | |
1991 | |
1992 return NULL; | |
1993 } | |
1994 | |
8446 | 1995 static void oscar_xfer_end(GaimXfer *xfer) |
1996 { | |
1997 struct aim_oft_info *oft_info = xfer->data; | |
1998 GaimConnection *gc = oft_info->sess->aux_data; | |
1999 OscarData *od = gc->proto_data; | |
2000 | |
8660 | 2001 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 2002 |
2003 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
2004 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
2005 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
2006 } | |
2007 | |
2008 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2009 aim_oft_destroyinfo(oft_info); | |
2010 xfer->data = NULL; | |
2011 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2012 } | |
2013 | |
2014 /* | |
2015 * xfer functions used when receiving files | |
2016 */ | |
2017 | |
11084 | 2018 /* |
2019 * This is a gaim timeout callback for when the clientip looks to be useless (after verifiedip has been tried) | |
2020 * It gives up on the file transfer completely if it doesn't approve of the file transfer status | |
2021 */ | |
2022 static gboolean oscar_clientip_timeout(gpointer data) { | |
2023 GaimXfer *xfer; | |
2024 struct aim_oft_info *oft_info; | |
2025 char *msg = NULL; | |
2026 | |
2027 gaim_debug_info("oscar","AAA - in oscar_clientip_timeout\n"); | |
2028 xfer = (GaimXfer*) data; | |
2029 if(xfer->data) { | |
2030 oft_info = (struct aim_oft_info*) xfer->data; | |
2031 | |
2032 /* Check to see if the clientip has produced any results */ | |
2033 if(oft_info->conn && oft_info->conn->status != AIM_CONN_STATUS_INPROGRESS) { | |
2034 msg = g_strdup_printf(_("Transfer of file %s timed out."),gaim_xfer_get_filename(xfer)); | |
2035 gaim_xfer_conversation_write(xfer, msg, TRUE); | |
2036 g_free(msg); | |
2037 gaim_xfer_unref(xfer); | |
2038 gaim_xfer_cancel_local(xfer); | |
2039 } | |
2040 } | |
2041 return FALSE; | |
2042 } | |
2043 | |
2044 /* | |
2045 * This is a gaim timeout callback for when the verifiedip looks to be useless | |
2046 * It tries the file transfer again using the clientip | |
2047 * | |
2048 * BBB | |
2049 */ | |
2050 static gboolean oscar_verifiedip_timeout(gpointer data) { | |
2051 GaimXfer *xfer; | |
2052 struct aim_oft_info *oft_info; | |
2053 | |
2054 gaim_debug_info("oscar","AAA - in oscar_verifiedip_timeout\n"); | |
2055 xfer = (GaimXfer*) data; | |
2056 if(xfer->data) { | |
2057 oft_info = (struct aim_oft_info*) xfer->data; | |
2058 | |
2059 /* Check to see if the verifiedip has produced any results */ | |
2060 if(oft_info->conn && oft_info->conn->status != AIM_CONN_STATUS_INPROGRESS) { | |
2061 /* gaim_xfer_conversation_write(xfer, | |
2062 "Attempting file transfer via secondary IP address...", FALSE); */ | |
2063 | |
2064 /* The verifiedip connection has worn out its welcome. Goodbye. */ | |
2065 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2066 | |
2067 /* Try the file transfer again with the clientip */ | |
2068 g_free(xfer->remote_ip); | |
2069 xfer->remote_ip = g_strdup(oft_info->clientip); | |
2070 gaim_debug_info("oscar","attempting connection using clientip\n"); | |
2071 oscar_xfer_init_recv(xfer); | |
2072 } | |
2073 } | |
2074 return FALSE; | |
2075 } | |
2076 | |
8446 | 2077 static void oscar_xfer_init_recv(GaimXfer *xfer) |
2078 { | |
2079 struct aim_oft_info *oft_info = xfer->data; | |
2080 GaimConnection *gc = oft_info->sess->aux_data; | |
2081 OscarData *od = gc->proto_data; | |
2082 | |
8660 | 2083 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
11084 | 2084 |
2085 /* Start a timer for this ip address | |
2086 * If the verifiedip fails, try the clientip | |
2087 * If clientip fails, declare the whole file transfer dead | |
2088 * This xfer reference will be released in oscar_clientip_timeout */ | |
2089 if(xfer->data) { | |
2090 gaim_xfer_ref(xfer); | |
2091 /* If clientip & verifiedip are the same, we must prevent an infinite loop */ | |
2092 if(g_ascii_strcasecmp(xfer->remote_ip, oft_info->verifiedip) == 0 | |
2093 && g_ascii_strcasecmp(oft_info->clientip, oft_info->verifiedip) != 0 ) { | |
2094 gaim_timeout_add(FT_IP_TIMEOUT * 1000, oscar_verifiedip_timeout, xfer); | |
2095 } else { | |
2096 gaim_timeout_add(FT_IP_TIMEOUT * 1000, oscar_clientip_timeout, xfer); | |
2097 } | |
2098 } | |
8446 | 2099 |
2100 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
2101 if (oft_info->conn) { | |
2102 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2103 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
2104 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
2105 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
2106 if (xfer->fd == -1) { | |
10654 | 2107 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2108 _("Unable to establish file descriptor.")); |
2109 gaim_xfer_cancel_local(xfer); | |
2110 } | |
2111 } else { | |
10654 | 2112 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2113 _("Unable to create new connection.")); |
2114 gaim_xfer_cancel_local(xfer); | |
2115 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2116 } | |
2117 | |
2118 } | |
2119 | |
2120 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
2121 { | |
10405 | 2122 struct aim_oft_info *oft_info; |
2123 GaimConnection *gc; | |
2124 OscarData *od; | |
2125 | |
2126 g_return_if_fail(xfer != NULL); | |
2127 g_return_if_fail(xfer->data != NULL); | |
2128 | |
2129 oft_info = xfer->data; | |
2130 gc = oft_info->sess->aux_data; | |
2131 od = gc->proto_data; | |
8446 | 2132 |
8660 | 2133 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2134 |
9771 | 2135 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2136 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2137 |
2138 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2139 aim_oft_destroyinfo(oft_info); | |
2140 xfer->data = NULL; | |
2141 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2142 } | |
2143 | |
11159 | 2144 static void oscar_xfer_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2145 { |
2146 struct aim_oft_info *oft_info = xfer->data; | |
2147 | |
2148 /* Update our rolling checksum. Like Walmart, yo. */ | |
2149 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2150 } | |
2151 | |
2152 /* | |
2153 * xfer functions used when sending files | |
2154 */ | |
2155 | |
2156 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2157 { | |
2158 struct aim_oft_info *oft_info = xfer->data; | |
2159 GaimConnection *gc = oft_info->sess->aux_data; | |
2160 OscarData *od = gc->proto_data; | |
2161 int listenfd; | |
2162 | |
8660 | 2163 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2164 |
2165 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2166 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2167 oft_info->fh.name[63] = '\0'; | |
2168 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2169 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2170 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2171 | |
2172 /* Create a listening socket and an associated libfaim conn */ | |
2173 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2174 gaim_xfer_cancel_local(xfer); | |
2175 return; | |
2176 } | |
2177 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2178 oft_info->port = xfer->local_port; | |
2179 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2180 gaim_xfer_cancel_local(xfer); | |
2181 return; | |
2182 } | |
8660 | 2183 gaim_debug_misc("oscar", |
8446 | 2184 "port is %hu, ip is %s\n", |
2185 xfer->local_port, oft_info->clientip); | |
2186 if (oft_info->conn) { | |
2187 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2188 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2189 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2190 } else { | |
10654 | 2191 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2192 _("Unable to establish listener socket.")); |
2193 gaim_xfer_cancel_local(xfer); | |
2194 } | |
2195 } | |
2196 | |
2197 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2198 { | |
2199 struct aim_oft_info *oft_info = xfer->data; | |
2200 GaimConnection *gc = oft_info->sess->aux_data; | |
2201 OscarData *od = gc->proto_data; | |
2202 | |
8660 | 2203 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2204 |
9771 | 2205 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2206 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2207 |
2208 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2209 aim_oft_destroyinfo(oft_info); | |
2210 xfer->data = NULL; | |
2211 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2212 } | |
2213 | |
11159 | 2214 static void oscar_xfer_ack_send(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2215 { |
2216 struct aim_oft_info *oft_info = xfer->data; | |
2217 | |
2218 /* I'm not sure I like how we do this. --marv | |
2219 * I do. AIM file transfers aren't really meant to be thought | |
2220 * of as a transferring just a single file. The rendezvous | |
2221 * establishes a connection between two computers, and then | |
2222 * those computers can use the same connection for transferring | |
2223 * multiple files. So we don't want the Gaim core up and closing | |
2224 * the socket all willy-nilly. We want to do that in the oscar | |
2225 * prpl, whenever one side or the other says they're finished | |
2226 * using the connection. There might be a better way to intercept | |
2227 * the socket from the core, however... --KingAnt | |
2228 */ | |
2229 | |
2230 /* | |
2231 * If we're done sending, intercept the socket from the core ft code | |
2232 * and wait for the other guy to send the "done" OFT packet. | |
2233 */ | |
2234 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2235 gaim_input_remove(xfer->watcher); | |
2236 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2237 xfer->fd = 0; | |
2238 gaim_xfer_set_completed(xfer, TRUE); | |
2239 } | |
2240 } | |
2241 | |
9466 | 2242 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2243 gboolean can_receive = FALSE; | |
2244 OscarData *od = gc->proto_data; | |
2245 | |
11049 | 2246 if (od != NULL) { |
9466 | 2247 aim_userinfo_t *userinfo; |
2248 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2249 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2250 can_receive = TRUE; | |
2251 } | |
2252 | |
2253 return can_receive; | |
2254 } | |
2255 | |
2256 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2257 |
2258 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2259 GaimXfer *xfer; |
5146 | 2260 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2261 const char *ip; |
3752 | 2262 |
9030 | 2263 od = (OscarData *)gc->proto_data; |
2264 | |
4617 | 2265 /* You want to send a file to someone else, you're so generous */ |
2266 | |
2267 /* Build the file transfer handle */ | |
9466 | 2268 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2269 |
5146 | 2270 /* Create the oscar-specific data */ |
8838 | 2271 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2272 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2273 xfer->data = oft_info; |
2274 | |
4617 | 2275 /* Setup our I/O op functions */ |
8446 | 2276 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2277 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2278 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2279 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2280 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2281 |
2282 /* Keep track of this transfer for later */ | |
2283 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2284 | |
2285 /* Now perform the request */ | |
9466 | 2286 if (file) |
2287 gaim_xfer_request_accepted(xfer, file); | |
2288 else | |
2289 gaim_xfer_request(xfer); | |
3630 | 2290 } |
2291 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2292 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2293 GaimConnection *gc = sess->aux_data; |
7283 | 2294 OscarData *od = gc->proto_data; |
6029 | 2295 GaimAccount *account = gc->account; |
2296 aim_conn_t *bosconn; | |
2297 char *host; int port; | |
2298 int i, rc; | |
2086 | 2299 va_list ap; |
2704 | 2300 struct aim_authresp_info *info; |
6029 | 2301 |
5575 | 2302 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2303 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2304 va_start(ap, fr); |
2704 | 2305 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2306 va_end(ap); |
2307 | |
8660 | 2308 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2309 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2310 |
4293 | 2311 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2312 char buf[256]; |
2704 | 2313 switch (info->errorcode) { |
2086 | 2314 case 0x05: |
2315 /* Incorrect nick/password */ | |
6498 | 2316 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2317 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2318 break; |
2319 case 0x11: | |
2320 /* Suspended account */ | |
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, _("Your account is currently suspended.")); |
2086 | 2323 break; |
3498 | 2324 case 0x14: |
2325 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2326 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2327 break; |
2086 | 2328 case 0x18: |
2329 /* connecting too frequently */ | |
6498 | 2330 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2331 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 | 2332 break; |
2333 case 0x1c: | |
2334 /* client too old */ | |
6498 | 2335 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2336 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
|
2337 gaim_connection_error(gc, buf); |
2086 | 2338 break; |
2339 default: | |
6623 | 2340 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2341 break; |
2342 } | |
8660 | 2343 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2344 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2345 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2346 "Error URL: %s\n", info->errorurl); |
2086 | 2347 od->killme = TRUE; |
2348 return 1; | |
2349 } | |
2350 | |
2351 | |
9992 | 2352 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2353 |
2704 | 2354 if (info->email) { |
8660 | 2355 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2356 } else { |
8660 | 2357 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2358 } |
10042 | 2359 |
8660 | 2360 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2361 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2362 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2363 aim_conn_kill(sess, &fr->conn); |
2086 | 2364 |
2365 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2366 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2367 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2368 od->killme = TRUE; |
2369 return 0; | |
2370 } | |
2371 | |
4649 | 2372 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2373 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2374 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2375 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2376 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2377 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2378 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2379 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2380 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2381 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2382 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2383 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2384 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2385 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2386 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2387 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2388 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2389 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2390 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2391 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2392 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2393 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2394 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
|
2395 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2396 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2397 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2398 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2399 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2400 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2401 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
|
2402 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
|
2403 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
|
2404 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2405 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2406 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4642 | 2407 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2408 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2409 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2410 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2411 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2412 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2413 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2414 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2415 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2416 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
|
2417 |
7283 | 2418 od->conn = bosconn; |
2704 | 2419 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2420 if (info->bosip[i] == ':') { | |
2421 port = atoi(&(info->bosip[i+1])); | |
2086 | 2422 break; |
2423 } | |
2424 } | |
2704 | 2425 host = g_strndup(info->bosip, i); |
2086 | 2426 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2427 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2428 g_free(host); |
4366 | 2429 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2430 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2431 od->killme = TRUE; |
2432 return 0; | |
2433 } | |
4293 | 2434 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2435 gaim_input_remove(gc->inpa); |
2704 | 2436 |
7283 | 2437 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2438 ck[3] = 0x64; |
7282 | 2439 |
2086 | 2440 return 1; |
2441 } | |
2442 | |
10464 | 2443 static void |
2444 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2445 { | |
2446 GaimConnection *gc = user_data; | |
2447 OscarData *od = gc->proto_data; | |
2448 aim_session_t *sess = od->sess; | |
2449 | |
2450 aim_auth_securid_send(sess, msg); | |
2451 } | |
2452 | |
2453 static void | |
2454 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2455 { | |
2456 GaimConnection *gc = user_data; | |
2457 OscarData *od = gc->proto_data; | |
2458 | |
2459 /* Disconnect */ | |
2460 gc->wants_to_die = TRUE; | |
2461 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2462 od->killme = TRUE; | |
2463 } | |
2464 | |
2465 static int | |
2466 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2467 { | |
2468 GaimConnection *gc = sess->aux_data; | |
2469 GaimAccount *account = gaim_connection_get_account(gc); | |
2470 gchar *primary; | |
2471 | |
2472 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2473 | |
2474 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2475 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2476 _("Enter the 6 digit number from the digital display."), | |
2477 FALSE, FALSE, NULL, | |
2478 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2479 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2480 gc); | |
2481 g_free(primary); | |
2482 | |
2483 return 1; | |
2484 } | |
2485 | |
7285 | 2486 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2487 struct pieceofcrap { |
5575 | 2488 GaimConnection *gc; |
2086 | 2489 unsigned long offset; |
2490 unsigned long len; | |
2491 char *modname; | |
2492 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2493 aim_conn_t *conn; |
2086 | 2494 unsigned int inpa; |
2495 }; | |
2496 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2497 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2498 { |
2499 struct pieceofcrap *pos = data; | |
7283 | 2500 OscarData *od = pos->gc->proto_data; |
2086 | 2501 char in = '\0'; |
2502 int x = 0; | |
2503 unsigned char m[17]; | |
2504 | |
2505 while (read(pos->fd, &in, 1) == 1) { | |
2506 if (in == '\n') | |
2507 x++; | |
2508 else if (in != '\r') | |
2509 x = 0; | |
2510 if (x == 2) | |
2511 break; | |
2512 in = '\0'; | |
2513 } | |
2514 if (in != '\n') { | |
4056 | 2515 char buf[256]; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2516 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
|
2517 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2518 gaim_notify_warning(pos->gc, NULL, |
7422 | 2519 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2520 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2521 gaim_input_remove(pos->inpa); |
2086 | 2522 close(pos->fd); |
2523 g_free(pos); | |
2524 return; | |
2525 } | |
2526 read(pos->fd, m, 16); | |
2527 m[16] = '\0'; | |
8660 | 2528 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2529 for (x = 0; x < 16; x++) |
8660 | 2530 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2531 | |
2532 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2533 gaim_input_remove(pos->inpa); |
2086 | 2534 close(pos->fd); |
2535 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2536 g_free(pos); | |
2537 } | |
2538 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2539 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2540 struct pieceofcrap *pos = data; |
5420 | 2541 gchar *buf; |
2086 | 2542 |
4366 | 2543 pos->fd = source; |
2544 | |
2086 | 2545 if (source < 0) { |
5420 | 2546 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
|
2547 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2548 gaim_notify_warning(pos->gc, NULL, |
7422 | 2549 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2550 buf); |
5420 | 2551 g_free(buf); |
2086 | 2552 if (pos->modname) |
2553 g_free(pos->modname); | |
2554 g_free(pos); | |
2555 return; | |
2556 } | |
2557 | |
5420 | 2558 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2559 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2560 write(pos->fd, buf, strlen(buf)); | |
5420 | 2561 g_free(buf); |
2086 | 2562 if (pos->modname) |
2563 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2564 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2565 return; |
2566 } | |
2567 | |
2568 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2569 #define AIM_MAX_FILE_SIZE 98304 | |
2570 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2571 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2572 va_list ap; |
2573 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2574 fu32_t offset, len; |
2086 | 2575 char *modname; |
2576 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2577 va_start(ap, fr); |
4200 | 2578 offset = va_arg(ap, fu32_t); |
2579 len = va_arg(ap, fu32_t); | |
2086 | 2580 modname = va_arg(ap, char *); |
2581 va_end(ap); | |
2582 | |
8660 | 2583 gaim_debug_misc("oscar", |
5556 | 2584 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2585 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2586 |
2086 | 2587 if (len == 0) { |
8660 | 2588 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2589 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2590 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2591 return 1; | |
2592 } | |
9625 | 2593 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2594 #if 0 | |
2086 | 2595 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2596 char *buf; | |
2597 int i = 8; | |
2598 if (modname) | |
2599 i += strlen(modname); | |
2600 buf = g_malloc(i); | |
2601 i = 0; | |
2602 if (modname) { | |
2603 memcpy(buf, modname, strlen(modname)); | |
2604 i += strlen(modname); | |
2605 } | |
2606 buf[i++] = offset & 0xff; | |
2607 buf[i++] = (offset >> 8) & 0xff; | |
2608 buf[i++] = (offset >> 16) & 0xff; | |
2609 buf[i++] = (offset >> 24) & 0xff; | |
2610 buf[i++] = len & 0xff; | |
2611 buf[i++] = (len >> 8) & 0xff; | |
2612 buf[i++] = (len >> 16) & 0xff; | |
2613 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2614 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2615 "hashing request\n"); |
2086 | 2616 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2617 g_free(buf); | |
2618 return 1; | |
2619 } | |
9625 | 2620 #endif |
2086 | 2621 |
2622 pos = g_new0(struct pieceofcrap, 1); | |
2623 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2624 pos->conn = fr->conn; |
2086 | 2625 |
2626 pos->offset = offset; | |
2627 pos->len = len; | |
2628 pos->modname = modname ? g_strdup(modname) : NULL; | |
2629 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2630 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2631 char buf[256]; |
2086 | 2632 if (pos->modname) |
2633 g_free(pos->modname); | |
2634 g_free(pos); | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2635 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
|
2636 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2637 gaim_notify_warning(pos->gc, NULL, |
7422 | 2638 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2639 buf); |
2086 | 2640 } |
2641 | |
2642 return 1; | |
2643 } | |
2644 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2645 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2646 GaimConnection *gc = sess->aux_data; |
7283 | 2647 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2648 GaimAccount *account = gaim_connection_get_account(gc); |
7282 | 2649 #if 0 |
2650 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2651 #endif | |
7011 | 2652 va_list ap; |
2653 char *key; | |
2086 | 2654 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2655 va_start(ap, fr); |
2086 | 2656 key = va_arg(ap, char *); |
2657 va_end(ap); | |
2658 | |
4617 | 2659 if (od->icq) { |
3458 | 2660 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
10740 | 2661 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2662 gaim_connection_get_password(gc), &info, key); | |
3458 | 2663 } else { |
2664 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
10740 | 2665 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2666 gaim_connection_get_password(gc), &info, key); | |
3458 | 2667 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2668 |
7283 | 2669 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2670 ck[2] = 0x6c; |
7282 | 2671 |
2086 | 2672 return 1; |
2673 } | |
2674 | |
2675 | 2675 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2676 GaimConnection *gc = sess->aux_data; |
2647 | 2677 struct chat_connection *chatcon; |
2678 static int id = 1; | |
2679 | |
6905 | 2680 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
|
2681 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
|
2682 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
|
2683 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
|
2684 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2685 |
2672 | 2686 aim_clientready(sess, fr->conn); |
2675 | 2687 |
2647 | 2688 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2689 chatcon->id = id; | |
8733 | 2690 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2691 |
2692 return 1; | |
2693 } | |
2694 | |
2675 | 2695 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2696 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2697 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2698 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2699 |
2700 aim_clientready(sess, fr->conn); | |
2701 | |
2702 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2703 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2704 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2705 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2706 |
3694 | 2707 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2708 | |
2709 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2710 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2711 | |
7282 | 2712 aim_email_sendcookies(sess); |
2713 aim_email_activate(sess); | |
3694 | 2714 aim_clientready(sess, fr->conn); |
2715 | |
2716 return 1; | |
2717 } | |
2718 | |
4804 | 2719 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2720 GaimConnection *gc = sess->aux_data; |
7283 | 2721 OscarData *od = gc->proto_data; |
4804 | 2722 |
2723 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2724 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2725 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2726 | |
2727 aim_clientready(sess, fr->conn); | |
2728 | |
4823 | 2729 od->iconconnecting = FALSE; |
2730 | |
4804 | 2731 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2732 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2733 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2734 |
2735 return 1; | |
2736 } | |
2737 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2738 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2739 GaimConnection *gc = data; |
7283 | 2740 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2741 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2742 aim_conn_t *tstconn; |
2086 | 2743 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2744 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2745 close(source); |
2746 return; | |
2747 } | |
2748 | |
4617 | 2749 od = gc->proto_data; |
2750 sess = od->sess; | |
2086 | 2751 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2752 tstconn->fd = source; |
2086 | 2753 |
2754 if (source < 0) { | |
2755 aim_conn_kill(sess, &tstconn); | |
8660 | 2756 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2757 "unable to connect to chatnav server\n"); |
2086 | 2758 return; |
2759 } | |
2760 | |
2761 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2762 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2763 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2764 } |
2765 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2766 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2767 { |
5575 | 2768 GaimConnection *gc = data; |
7283 | 2769 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2770 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2771 aim_conn_t *tstconn; |
2086 | 2772 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2773 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2774 close(source); |
2775 return; | |
2776 } | |
2777 | |
4617 | 2778 od = gc->proto_data; |
2779 sess = od->sess; | |
2086 | 2780 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2781 tstconn->fd = source; |
2086 | 2782 |
2783 if (source < 0) { | |
2784 aim_conn_kill(sess, &tstconn); | |
8660 | 2785 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2786 "unable to connect to authorizer\n"); |
2086 | 2787 return; |
2788 } | |
2789 | |
2790 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2791 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2792 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2793 } |
2794 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2795 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2796 { |
2797 struct chat_connection *ccon = data; | |
5575 | 2798 GaimConnection *gc = ccon->gc; |
7283 | 2799 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2800 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2801 aim_conn_t *tstconn; |
2086 | 2802 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2803 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2804 close(source); |
2805 g_free(ccon->show); | |
2806 g_free(ccon->name); | |
2807 g_free(ccon); | |
2808 return; | |
2809 } | |
2810 | |
4617 | 2811 od = gc->proto_data; |
2812 sess = od->sess; | |
2086 | 2813 tstconn = ccon->conn; |
4366 | 2814 tstconn->fd = source; |
2086 | 2815 |
2816 if (source < 0) { | |
2817 aim_conn_kill(sess, &tstconn); | |
2818 g_free(ccon->show); | |
2819 g_free(ccon->name); | |
2820 g_free(ccon); | |
2821 return; | |
2822 } | |
2823 | |
2824 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2825 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2826 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2827 } |
2828 | |
3694 | 2829 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2830 GaimConnection *gc = data; |
7283 | 2831 OscarData *od; |
3694 | 2832 aim_session_t *sess; |
2833 aim_conn_t *tstconn; | |
2834 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2835 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2836 close(source); |
2837 return; | |
2838 } | |
2839 | |
4617 | 2840 od = gc->proto_data; |
2841 sess = od->sess; | |
3694 | 2842 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2843 tstconn->fd = source; |
3694 | 2844 |
2845 if (source < 0) { | |
2846 aim_conn_kill(sess, &tstconn); | |
8660 | 2847 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2848 "unable to connect to email server\n"); |
3694 | 2849 return; |
2850 } | |
2851 | |
2852 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2853 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2854 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2855 "email: connected\n"); |
3694 | 2856 } |
2857 | |
4804 | 2858 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2859 GaimConnection *gc = data; |
7283 | 2860 OscarData *od; |
4804 | 2861 aim_session_t *sess; |
2862 aim_conn_t *tstconn; | |
2863 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2864 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2865 close(source); |
2866 return; | |
2867 } | |
2868 | |
2869 od = gc->proto_data; | |
2870 sess = od->sess; | |
2871 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2872 tstconn->fd = source; | |
2873 | |
2874 if (source < 0) { | |
2875 aim_conn_kill(sess, &tstconn); | |
8660 | 2876 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2877 "unable to connect to icon server\n"); |
4804 | 2878 return; |
2879 } | |
2880 | |
2881 aim_conn_completeconnect(sess, tstconn); | |
2882 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2883 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2884 } |
2885 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2886 /* 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
|
2887 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2888 GaimConnection *gc = sess->aux_data; |
2889 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2890 aim_conn_t *tstconn; |
4452 | 2891 int i; |
2086 | 2892 char *host; |
2893 int port; | |
4821 | 2894 va_list ap; |
2895 struct aim_redirect_data *redir; | |
2086 | 2896 |
5575 | 2897 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2898 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2899 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2900 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2901 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2902 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2903 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2904 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2905 port = atoi(&(redir->ip[i+1])); |
2086 | 2906 break; |
2907 } | |
2908 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2909 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2910 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2911 switch(redir->group) { |
2086 | 2912 case 0x7: /* Authorizer */ |
8660 | 2913 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2914 "Reconnecting with authorizor...\n"); |
2086 | 2915 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2916 if (tstconn == NULL) { | |
8660 | 2917 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2918 "unable to reconnect with authorizer\n"); |
2086 | 2919 g_free(host); |
2920 return 1; | |
2921 } | |
4649 | 2922 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2923 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2924 |
2925 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2926 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2927 aim_conn_kill(sess, &tstconn); |
8660 | 2928 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2929 "unable to reconnect with authorizer\n"); |
2086 | 2930 g_free(host); |
2931 return 1; | |
2932 } | |
4293 | 2933 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2934 break; |
2935 | |
2086 | 2936 case 0xd: /* ChatNav */ |
2937 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2938 if (tstconn == NULL) { | |
8660 | 2939 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2940 "unable to connect to chatnav server\n"); |
2086 | 2941 g_free(host); |
2942 return 1; | |
2943 } | |
4649 | 2944 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2945 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2946 |
2947 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2948 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2949 aim_conn_kill(sess, &tstconn); |
8660 | 2950 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2951 "unable to connect to chatnav server\n"); |
2086 | 2952 g_free(host); |
2953 return 1; | |
2954 } | |
4293 | 2955 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2956 break; |
2957 | |
2958 case 0xe: { /* Chat */ | |
2086 | 2959 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2960 |
2086 | 2961 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2962 if (tstconn == NULL) { | |
8660 | 2963 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2964 "unable to connect to chat server\n"); |
2086 | 2965 g_free(host); |
2966 return 1; | |
2967 } | |
2968 | |
4649 | 2969 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2970 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2971 | |
2086 | 2972 ccon = g_new0(struct chat_connection, 1); |
2973 ccon->conn = tstconn; | |
2974 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2975 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2976 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2977 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2978 ccon->show = extract_name(redir->chat.room); |
4634 | 2979 |
2086 | 2980 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2981 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2982 aim_conn_kill(sess, &tstconn); |
8660 | 2983 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2984 "unable to connect to chat server\n"); |
2086 | 2985 g_free(host); |
2986 g_free(ccon->show); | |
2987 g_free(ccon->name); | |
2988 g_free(ccon); | |
2989 return 1; | |
2990 } | |
4293 | 2991 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2992 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2993 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2994 ccon->name, ccon->exchange); |
4194 | 2995 } break; |
3694 | 2996 |
4804 | 2997 case 0x0010: { /* icon */ |
2998 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2999 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3000 "unable to connect to icon server\n"); |
4804 | 3001 g_free(host); |
3002 return 1; | |
3003 } | |
3004 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
3005 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
3006 | |
3007 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3008 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 3009 aim_conn_kill(sess, &tstconn); |
8660 | 3010 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3011 "unable to connect to icon server\n"); |
4804 | 3012 g_free(host); |
3013 return 1; | |
3014 } | |
3015 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
3016 } break; | |
3017 | |
3694 | 3018 case 0x0018: { /* email */ |
3019 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 3020 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3021 "unable to connect to email server\n"); |
3694 | 3022 g_free(host); |
3023 return 1; | |
3024 } | |
4649 | 3025 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 3026 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
3027 | |
3028 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3029 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 3030 aim_conn_kill(sess, &tstconn); |
8660 | 3031 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3032 "unable to connect to email server\n"); |
3694 | 3033 g_free(host); |
3034 return 1; | |
3035 } | |
4293 | 3036 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 3037 } break; |
3038 | |
2086 | 3039 default: /* huh? */ |
8660 | 3040 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3041 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3042 redir->group); |
2086 | 3043 break; |
3044 } | |
3045 | |
3046 g_free(host); | |
3047 return 1; | |
3048 } | |
3049 | |
10042 | 3050 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
3051 { | |
3052 GaimConnection *gc; | |
3053 GaimAccount *account; | |
3054 OscarData *od; | |
4738 | 3055 struct buddyinfo *bi; |
2993 | 3056 time_t time_idle = 0, signon = 0; |
3057 int type = 0; | |
3058 int caps = 0; | |
2086 | 3059 va_list ap; |
4738 | 3060 aim_userinfo_t *info; |
10042 | 3061 gboolean buddy_is_away = FALSE; |
3062 | |
3063 gc = sess->aux_data; | |
3064 account = gaim_connection_get_account(gc); | |
3065 od = gc->proto_data; | |
4194 | 3066 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3067 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3068 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3069 va_end(ap); |
3070 | |
10130 | 3071 g_return_val_if_fail(info != NULL, 1); |
3072 g_return_val_if_fail(info->sn != NULL, 1); | |
3073 | |
2993 | 3074 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
3075 caps = info->capabilities; | |
3267 | 3076 |
4766 | 3077 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
3078 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 3079 buddy_is_away = TRUE; |
3080 } | |
3081 | |
2993 | 3082 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 3083 type = (info->icqinfo.status << 16); |
3013 | 3084 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3085 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3086 buddy_is_away = TRUE; |
3013 | 3087 } |
2993 | 3088 } |
3089 | |
7141 | 3090 if (caps & AIM_CAPS_ICQ_DIRECT) |
3091 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 3092 |
10860 | 3093 /* info->idletime is the number of minutes that this user has been idle */ |
3094 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
3095 time_idle = time(NULL) - info->idletime * 60; | |
2993 | 3096 |
5836 | 3097 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3098 signon = info->onlinesince; | |
3099 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3100 signon = time(NULL) - info->sessionlen; |
2086 | 3101 |
10567 | 3102 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3103 gaim_connection_set_display_name(gc, info->sn); |
10567 | 3104 od->timeoffset = signon - gc->login_time; |
3105 } | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
3106 |
9982 | 3107 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3108 if (!bi) { |
3109 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3110 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3111 } |
4739 | 3112 bi->typingnot = FALSE; |
3113 bi->ico_informed = FALSE; | |
6857 | 3114 bi->ipaddr = info->icqinfo.ipaddr; |
3115 | |
10563 | 3116 /* |
3117 * Handle the available message. If info->avail is NULL then the user | |
3118 * may or may not have an available message, so don't do anything. If | |
3119 * info->avail is set to the empty string, then the user's client DOES | |
3120 * support available messages and the user DOES NOT have one set. | |
3121 * Otherwise info->avail contains the available message. | |
3122 */ | |
7011 | 3123 if (info->avail != NULL) |
10563 | 3124 { |
3125 free(bi->availmsg); | |
3126 if (info->avail[0] != '\0') | |
3127 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); | |
3128 else | |
3129 bi->availmsg = NULL; | |
3130 } | |
4732 | 3131 |
4804 | 3132 /* Server stored icon stuff */ |
4853 | 3133 if (info->iconcsumlen) { |
7125 | 3134 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3135 char *b16 = NULL, *filepath = NULL; |
7093 | 3136 GaimBuddy *b = NULL; |
4853 | 3137 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3138 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3139 b = gaim_find_buddy(account, info->sn); |
7093 | 3140 /* |
3141 * If for some reason the checksum is valid, but cached file is not.. | |
3142 * we want to know. | |
3143 */ | |
7693 | 3144 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3145 if (filename != NULL) { |
3146 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3147 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3148 "icon_checksum"); | |
9801 | 3149 else { |
3150 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3151 filename, NULL); | |
3152 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3153 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3154 "icon_checksum"); | |
3155 g_free(filepath); | |
3156 } | |
7093 | 3157 } else |
3158 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3159 |
4853 | 3160 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3161 GSList *cur = od->requesticon; | |
3162 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3163 cur = cur->next; | |
3164 if (!cur) { | |
9982 | 3165 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3166 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3167 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3168 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3169 } |
3170 } | |
6053 | 3171 g_free(b16); |
4853 | 3172 } |
3173 | |
10042 | 3174 /* XXX - Represent other ICQ statuses */ |
3175 if (buddy_is_away == TRUE) | |
3176 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
3177 else | |
3178 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
10567 | 3179 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
9982 | 3180 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); |
3181 | |
3182 if (time_idle > 0) | |
3183 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 3184 else |
3185 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 3186 |
3187 return 1; | |
3188 } | |
3189 | |
8341 | 3190 static void gaim_check_comment(OscarData *od, const char *str) { |
11159 | 3191 if ((str == NULL) || strcmp(str, (const char *)ck)) |
8341 | 3192 aim_locate_setcaps(od->sess, caps_aim); |
3193 else | |
3194 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3195 } | |
3196 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3197 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3198 GaimConnection *gc = sess->aux_data; |
7283 | 3199 OscarData *od = gc->proto_data; |
9982 | 3200 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3201 va_list ap; |
4739 | 3202 aim_userinfo_t *info; |
2086 | 3203 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3204 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3205 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3206 va_end(ap); |
3207 | |
9982 | 3208 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3209 |
7261 | 3210 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3211 |
2086 | 3212 return 1; |
3213 } | |
3214 | |
4617 | 3215 /* BBB */ |
3952 | 3216 /* |
4617 | 3217 * This is called after a remote AIM user has connected to us. We |
3218 * want to do some voodoo with the socket file descriptors, add a | |
3219 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3220 */ |
4656 | 3221 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3222 GaimConnection *gc = sess->aux_data; |
7283 | 3223 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3224 GaimXfer *xfer; |
5146 | 3225 struct aim_oft_info *oft_info; |
3630 | 3226 va_list ap; |
3227 aim_conn_t *conn, *listenerconn; | |
4656 | 3228 |
8660 | 3229 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3230 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3231 va_start(ap, fr); |
3232 conn = va_arg(ap, aim_conn_t *); | |
3233 listenerconn = va_arg(ap, aim_conn_t *); | |
3234 va_end(ap); | |
3235 | |
4617 | 3236 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3237 return 1; | |
3238 | |
5146 | 3239 if (!(oft_info = xfer->data)) |
4617 | 3240 return 1; |
3241 | |
3630 | 3242 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3243 gaim_input_remove(xfer->watcher); |
3630 | 3244 aim_conn_kill(sess, &listenerconn); |
3245 | |
5146 | 3246 oft_info->conn = conn; |
3247 xfer->fd = oft_info->conn->fd; | |
3248 | |
3249 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3250 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3251 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3252 |
3253 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3254 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3255 |
3256 return 0; | |
3257 } | |
3258 | |
3952 | 3259 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3260 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3261 * user in order to transfer a file. |
3952 | 3262 */ |
4617 | 3263 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
|
3264 GaimXfer *xfer; |
5146 | 3265 struct aim_oft_info *oft_info; |
4656 | 3266 |
8660 | 3267 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3268 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3269 if (!(xfer = data)) |
3270 return; | |
5146 | 3271 if (!(oft_info = xfer->data)) |
3630 | 3272 return; |
8446 | 3273 if (source < 0) { |
3274 gaim_xfer_cancel_remote(xfer); | |
4617 | 3275 return; |
8446 | 3276 } |
4617 | 3277 |
3278 xfer->fd = source; | |
5146 | 3279 oft_info->conn->fd = source; |
3280 | |
3281 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3282 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3283 |
3284 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3285 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3286 |
3287 return; | |
3630 | 3288 } |
3289 | |
3952 | 3290 /* |
4617 | 3291 * This is called when a buddy sends us some file info. This happens when they |
3292 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3293 * You should send them the exact same info except use the real cookie. We also |
4617 | 3294 * get like totally ready to like, receive the file, kay? |
3952 | 3295 */ |
4617 | 3296 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3297 GaimConnection *gc = sess->aux_data; |
7283 | 3298 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3299 GaimXfer *xfer; |
5146 | 3300 struct aim_oft_info *oft_info; |
4617 | 3301 va_list ap; |
3302 aim_conn_t *conn; | |
3303 fu8_t *cookie; | |
3304 struct aim_fileheader_t *fh; | |
4656 | 3305 |
8660 | 3306 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3307 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3308 va_start(ap, fr); |
3309 conn = va_arg(ap, aim_conn_t *); | |
3310 cookie = va_arg(ap, fu8_t *); | |
3311 fh = va_arg(ap, struct aim_fileheader_t *); | |
3312 va_end(ap); | |
3313 | |
3314 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3315 return 1; | |
3316 | |
5146 | 3317 if (!(oft_info = xfer->data)) |
4617 | 3318 return 1; |
3319 | |
3320 /* We want to stop listening with a normal thingy */ | |
3321 gaim_input_remove(xfer->watcher); | |
3322 xfer->watcher = 0; | |
3323 | |
5146 | 3324 /* They sent us some information about the file they're sending */ |
3325 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3326 | |
3327 /* Fill in the cookie */ | |
3328 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3329 | |
4617 | 3330 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3331 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3332 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3333 | |
3334 return 0; | |
3630 | 3335 } |
3336 | |
3952 | 3337 /* |
4657 | 3338 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3339 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3340 */ |
4617 | 3341 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3342 GaimConnection *gc = sess->aux_data; |
7283 | 3343 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3344 GaimXfer *xfer; |
4617 | 3345 va_list ap; |
3346 aim_conn_t *conn; | |
3347 fu8_t *cookie; | |
3348 struct aim_fileheader_t *fh; | |
4656 | 3349 |
8660 | 3350 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3351 va_start(ap, fr); |
3352 conn = va_arg(ap, aim_conn_t *); | |
3353 cookie = va_arg(ap, fu8_t *); | |
3354 fh = va_arg(ap, struct aim_fileheader_t *); | |
3355 va_end(ap); | |
3356 | |
3357 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3358 return 1; | |
3359 | |
4656 | 3360 /* We want to stop listening with a normal thingy */ |
3361 gaim_input_remove(xfer->watcher); | |
3362 xfer->watcher = 0; | |
3363 | |
4617 | 3364 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3365 | |
3366 return 0; | |
3630 | 3367 } |
4617 | 3368 |
3369 /* | |
3370 * We just sent a file to someone. They said they got it and everything, | |
3371 * so we can close our direct connection and what not. | |
3372 */ | |
3373 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3374 GaimConnection *gc = sess->aux_data; |
7283 | 3375 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3376 GaimXfer *xfer; |
4617 | 3377 va_list ap; |
3378 aim_conn_t *conn; | |
3379 fu8_t *cookie; | |
3380 struct aim_fileheader_t *fh; | |
4656 | 3381 |
8660 | 3382 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3383 va_start(ap, fr); |
3384 conn = va_arg(ap, aim_conn_t *); | |
3385 cookie = va_arg(ap, fu8_t *); | |
3386 fh = va_arg(ap, struct aim_fileheader_t *); | |
3387 va_end(ap); | |
3388 | |
3389 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3390 return 1; | |
3391 | |
4656 | 3392 xfer->fd = conn->fd; |
4617 | 3393 gaim_xfer_end(xfer); |
3394 | |
3395 return 0; | |
3396 } | |
3630 | 3397 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3398 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3399 GaimConnection *gc = sess->aux_data; |
7283 | 3400 OscarData *od = gc->proto_data; |
8708 | 3401 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3402 GaimConvImFlags flags = 0; |
4738 | 3403 struct buddyinfo *bi; |
5575 | 3404 const char *iconfile; |
9806 | 3405 GString *message; |
3406 gchar *tmp; | |
3407 aim_mpmsg_section_t *curpart; | |
3408 | |
10472 | 3409 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3410 userinfo->sn, args->mpmsg.numparts); |
4738 | 3411 |
10595 | 3412 if (args->mpmsg.numparts == 0) |
3413 return 1; | |
3414 | |
8708 | 3415 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3416 if (!bi) { |
3417 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3418 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3419 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3420 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3421 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3422 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3423 |
4738 | 3424 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3425 bi->typingnot = TRUE; | |
3426 else | |
3427 bi->typingnot = FALSE; | |
3428 | |
4380 | 3429 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3430 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3431 "%s has an icon\n", userinfo->sn); |
4738 | 3432 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3433 bi->ico_need = TRUE; | |
3434 bi->ico_len = args->iconlen; | |
3435 bi->ico_csum = args->iconsum; | |
3436 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3437 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3438 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3439 |
10458 | 3440 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3441 (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
|
3442 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3443 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3444 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3445 if (!g_stat(iconfile, &st)) { |
11159 | 3446 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3447 file = g_fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3448 if (file) { |
9532 | 3449 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3450 int len = fread(buf, 1, st.st_size, file); |
8660 | 3451 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3452 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3453 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3454 userinfo->sn, len, st.st_size); |
4617 | 3455 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3456 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3457 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3458 } else |
8660 | 3459 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3460 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3461 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3462 } else |
8660 | 3463 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3464 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3465 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3466 |
9806 | 3467 message = g_string_new(""); |
3468 curpart = args->mpmsg.parts; | |
3469 while (curpart != NULL) { | |
11159 | 3470 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, |
3471 curpart->charsubset, curpart->data, curpart->datalen); | |
9806 | 3472 if (tmp != NULL) { |
3473 g_string_append(message, tmp); | |
3474 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3475 } |
9806 | 3476 |
3477 curpart = curpart->next; | |
3478 } | |
3479 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3480 |
8666 | 3481 /* |
10781 | 3482 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
9016 | 3483 * because HTML is not sent over ICQ as a means to format a message. |
10781 | 3484 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
3485 * replaced with <br> | |
8995 | 3486 * |
3487 * Note: There *may* be some clients which send messages as HTML formatted - | |
3488 * they need to be special-cased somehow. | |
8666 | 3489 */ |
9982 | 3490 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3491 /* 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
|
3492 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
8493 | 3493 g_free(tmp); |
3494 tmp = tmp2; | |
10783 | 3495 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
10781 | 3496 g_free(tmp); |
3497 tmp = tmp2; | |
8493 | 3498 } |
3499 | |
6982 | 3500 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3501 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3502 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3503 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3504 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3505 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3506 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3507 GaimConnection *gc; |
9933 | 3508 GaimAccount *account; |
9070 | 3509 OscarData *od; |
9933 | 3510 const char *username = NULL; |
3511 char *message = NULL; | |
9070 | 3512 |
3513 g_return_val_if_fail(sess != NULL, 0); | |
3514 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3515 | |
3516 gc = sess->aux_data; | |
9933 | 3517 account = gaim_connection_get_account(gc); |
9070 | 3518 od = gc->proto_data; |
9933 | 3519 username = gaim_account_get_username(account); |
3520 | |
3521 if (args == NULL) | |
4121 | 3522 return 0; |
4194 | 3523 |
9933 | 3524 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3525 userinfo->sn, args->status); | |
3526 | |
3527 if (args->msg != NULL) | |
3528 { | |
3529 if (args->encoding != NULL) | |
3530 { | |
3531 char *encoding = NULL; | |
3532 encoding = oscar_encoding_extract(args->encoding); | |
3533 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3534 g_free(encoding); | |
3535 } else { | |
3536 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3537 message = g_strdup(args->msg); | |
3538 } | |
3539 } | |
2869 | 3540 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3541 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3542 char *name; |
5234 | 3543 GHashTable *components; |
3544 | |
9933 | 3545 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3546 g_free(message); | |
4121 | 3547 return 1; |
9933 | 3548 } |
5234 | 3549 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3550 g_free); | |
4121 | 3551 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3552 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3553 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
|
3554 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3555 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3556 userinfo->sn, |
9933 | 3557 message, |
5234 | 3558 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3559 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3560 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3561 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3562 /* BBB */ |
3563 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3564 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3565 GaimXfer *xfer; |
5146 | 3566 struct aim_oft_info *oft_info; |
3567 | |
3568 if (!args->cookie || !args->port || !args->verifiedip || | |
3569 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3570 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3571 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3572 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3573 "information.\n", userinfo->sn); |
5146 | 3574 if (args->proxyip) |
8660 | 3575 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3576 "IP for a proxy server was given. Gaim " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3577 "does not support this yet.\n"); |
9933 | 3578 g_free(message); |
4617 | 3579 return 1; |
4656 | 3580 } |
4617 | 3581 |
3582 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3583 /* 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
|
3584 * directory -- remove the star and trailing slash so we don't save |
4617 | 3585 * directories that look like 'dirname\*' -- arl */ |
3586 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3587 if (tmp && (tmp[1] == '*')) { | |
3588 tmp[0] = '\0'; | |
3589 } | |
8660 | 3590 gaim_debug_warning("oscar", |
8446 | 3591 "We're receiving a whole directory! What fun! " |
3592 "Especially since we don't support that!\n"); | |
4617 | 3593 } |
3594 | |
3595 /* Build the file transfer handle */ | |
3596 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3597 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3598 xfer->remote_port = args->port; |
4617 | 3599 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3600 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
11084 | 3601 |
3602 /* Ignore <ICQ_COOL_FT> XML that is sent along with ICQ sendfile requests */ | |
3603 if(g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13)) { | |
3604 gaim_debug_info("oscar","Ignoring ICQ file transfer message: %s\n", message); | |
3605 g_free(message); | |
3606 message = NULL; | |
3607 } | |
9933 | 3608 gaim_xfer_set_message(xfer, message); |
5146 | 3609 |
3610 /* Create the oscar-specific data */ | |
5163 | 3611 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3612 if (args->proxyip) |
5146 | 3613 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3614 if (args->verifiedip) |
5146 | 3615 oft_info->verifiedip = g_strdup(args->verifiedip); |
3616 xfer->data = oft_info; | |
4617 | 3617 |
3618 /* Setup our I/O op functions */ | |
8446 | 3619 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3620 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3621 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
|
3622 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3623 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3624 |
3625 /* Keep track of this transfer for later */ | |
3626 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3627 | |
3628 /* Now perform the request */ | |
3629 gaim_xfer_request(xfer); | |
3630 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3631 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3632 GaimXfer *xfer; |
8660 | 3633 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3634 "AAA - File transfer canceled by remote user\n"); |
4617 | 3635 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
|
3636 gaim_xfer_cancel_remote(xfer); |
4617 | 3637 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3638 /* | |
3639 * This gets sent by the receiver of a file | |
3640 * as they connect directly to us. If we don't | |
3641 * get this, then maybe a third party connected | |
3642 * to us, and we shouldn't send them anything. | |
3643 */ | |
3644 } else { | |
8660 | 3645 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3646 "unknown rendezvous status!\n"); |
3630 | 3647 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3648 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3649 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3650 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3651 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3652 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3653 args->info.icon.length); |
6871 | 3654 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3655 /* 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
|
3656 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3657 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
|
3658 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3659 |
4212 | 3660 if (!args->verifiedip) { |
8983 | 3661 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3662 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3663 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3664 g_free(message); |
4650 | 3665 return 1; |
4212 | 3666 } |
3667 | |
8660 | 3668 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3669 "%s received direct im request from %s (%s)\n", |
10594 | 3670 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3671 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3672 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3673 d->sn = g_strdup(userinfo->sn); |
8983 | 3674 /* Let's use the clientip here, because I think that's what AIM does. |
3675 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3676 * and then ask them to connect to us. */ | |
10594 | 3677 /* |
3678 * I disagree, let's use the verifiedip. I think AIM tries the | |
3679 * verified IP first, then tries the client IP if that fails. In | |
3680 * any case, there's a better chance the verified IP will be correct. | |
3681 * The client IP is what the other person _thinks_ their IP address | |
3682 * is. The verified IP is the address that the AIM server sees the | |
3683 * other person using. | |
3684 */ | |
3685 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
|
3686 memcpy(d->cookie, args->cookie, 8); |
9070 | 3687 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3688 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3689 | |
8971 | 3690 oscar_direct_im_destroy(od, dim); |
8984 | 3691 d->donttryagain = TRUE; |
8971 | 3692 accept_direct_im_request(d); |
3693 } else { | |
8983 | 3694 if (dim && !dim->connected) |
8971 | 3695 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3696 "already connected to that buddy!"); | |
5575 | 3697 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
|
3698 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3699 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3700 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3701 "the two computers and is necessary for IM " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3702 "Images. Because your IP address will be " |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3703 "revealed, this may be considered a privacy " |
9972 | 3704 "risk."), |
3705 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3706 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3707 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3708 /* FIXME: we should actually send a packet on cancel */ | |
3709 } | |
8708 | 3710 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3711 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
|
3712 } else { |
8660 | 3713 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3714 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3715 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3716 |
9933 | 3717 g_free(message); |
3718 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3719 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3720 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3721 |
3453 | 3722 /* |
4230 | 3723 * Authorization Functions |
3724 * Most of these are callbacks from dialogs. They're used by both | |
3725 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3726 */ |
4269 | 3727 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3728 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3729 GaimConnection *gc = data->gc; |
4244 | 3730 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3731 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3732 OscarData *od = gc->proto_data; |
6695 | 3733 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3734 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3735 if (buddy && group) { |
8660 | 3736 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3737 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3738 buddy->name, group->name); |
4889 | 3739 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3740 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3741 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3742 } |
4230 | 3743 } |
4337 | 3744 } |
3745 | |
3746 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3747 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3748 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3749 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3750 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3751 data); |
4230 | 3752 } |
3753 | |
3754 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3755 GaimConnection *gc = data->gc; |
4244 | 3756 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3757 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3758 /* Remove from local list */ |
3759 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3760 gaim_blist_remove_buddy(b); | |
4244 | 3761 } |
3762 | |
5836 | 3763 oscar_free_name_data(data); |
4230 | 3764 } |
3765 | |
9030 | 3766 |
3767 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3768 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3769 GaimBuddy *buddy; |
4269 | 3770 gchar *dialog_msg, *nombre; |
3771 | |
4687 | 3772 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3773 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3774 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3775 else |
4830 | 3776 nombre = NULL; |
3777 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3778 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 | 3779 data->gc = gc; |
3780 data->name = g_strdup(name); | |
3781 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3782 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3783 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3784 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3785 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3786 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3787 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3788 |
3789 g_free(dialog_msg); | |
3790 g_free(nombre); | |
3791 } | |
3792 | |
9030 | 3793 |
3794 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3795 GaimBuddy *buddy; | |
3796 GaimConnection *gc; | |
3797 | |
3798 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3799 | |
3800 buddy = (GaimBuddy *) node; | |
3801 gc = gaim_account_get_connection(buddy->account); | |
3802 gaim_auth_sendrequest(gc, buddy->name); | |
3803 } | |
3804 | |
4230 | 3805 /* When other people ask you for authorization */ |
3806 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3807 GaimConnection *gc = data->gc; |
4244 | 3808 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3809 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3810 OscarData *od = gc->proto_data; |
4889 | 3811 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4244 | 3812 } |
3813 | |
5836 | 3814 oscar_free_name_data(data); |
3141 | 3815 } |
3816 | |
4230 | 3817 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3818 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3819 GaimConnection *gc = data->gc; |
4244 | 3820 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3821 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3822 OscarData *od = gc->proto_data; |
4889 | 3823 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4244 | 3824 } |
4337 | 3825 } |
3826 | |
3827 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3828 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3829 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3830 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3831 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3832 data); |
3141 | 3833 } |
3834 | |
7023 | 3835 /* When someone sends you buddies */ |
3836 static void gaim_icq_buddyadd(struct name_data *data) { | |
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)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3840 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3841 } |
3842 | |
5836 | 3843 oscar_free_name_data(data); |
3453 | 3844 } |
3845 | |
4075 | 3846 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 | 3847 GaimConnection *gc = sess->aux_data; |
9908 | 3848 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3849 gchar **msg1, **msg2; |
6051 | 3850 int i, numtoks; |
4076 | 3851 |
4121 | 3852 if (!args->type || !args->msg || !args->uin) |
3853 return 1; | |
4194 | 3854 |
8660 | 3855 gaim_debug_info("oscar", |
9908 | 3856 "Received a channel 4 message of type 0x%02hhx.\n", |
3857 args->type); | |
4076 | 3858 |
9919 | 3859 /* |
3860 * Split up the message at the delimeter character, then convert each | |
3861 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3862 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3863 * character in whatever encoding the message was sent in. Type 1 | |
3864 * messages are always made up of only one part, so we can easily account | |
3865 * for this suck-ass part of the protocol by splitting the string into at | |
3866 * most 1 baby string. | |
3867 */ | |
3868 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3869 for (numtoks=0; msg1[numtoks]; numtoks++); |
3870 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3871 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3872 gaim_str_strip_cr(msg1[i]); |
9908 | 3873 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3874 } |
3875 msg2[i] = NULL; | |
3876 | |
3952 | 3877 switch (args->type) { |
4173 | 3878 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3879 if (i >= 1) { |
5556 | 3880 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3881 gchar *tmp; |
3882 | |
3883 /* 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
|
3884 tmp = g_markup_escape_text(msg2[0], -1); |
8493 | 3885 |
4076 | 3886 if (t) { /* This is an offline message */ |
9680 | 3887 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3888 #ifdef HAVE_TM_GMTOFF |
9724 | 3889 time_t now; |
3890 struct tm *tm; | |
3891 now = time(NULL); | |
3892 tm = localtime(&now); | |
3893 t += tm->tm_gmtoff; | |
9698 | 3894 #else |
3895 # ifdef HAVE_TIMEZONE | |
9680 | 3896 tzset(); |
3897 t -= timezone; | |
9698 | 3898 # endif |
3899 #endif | |
8514 | 3900 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3901 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3902 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3903 } |
3904 g_free(uin); | |
8493 | 3905 g_free(tmp); |
4075 | 3906 } |
3316 | 3907 } break; |
3908 | |
4173 | 3909 case 0x04: { /* Someone sent you a URL */ |
4076 | 3910 if (i >= 2) { |
7385 | 3911 if (msg2[1] != NULL) { |
3912 gchar *uin = g_strdup_printf("%u", args->uin); | |
3913 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3914 msg2[1], | |
3915 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3916 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3917 g_free(uin); | |
3918 g_free(message); | |
3919 } | |
3453 | 3920 } |
3921 } break; | |
3922 | |
4173 | 3923 case 0x06: { /* Someone requested authorization */ |
4076 | 3924 if (i >= 6) { |
4230 | 3925 struct name_data *data = g_new(struct name_data, 1); |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3926 gchar *sn = g_strdup_printf("%u", args->uin); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3927 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3928 gchar *dialog_msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3929 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3930 if (msg2[5] != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3931 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
|
3932 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3933 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3934 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3935 dialog_msg = g_strdup_printf( |
10949 | 3936 _("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
|
3937 args->uin, gaim_account_get_username(gc->account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3938 g_free(reason); |
8660 | 3939 gaim_debug_info("oscar", |
5556 | 3940 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3941 args->uin); |
4076 | 3942 data->gc = gc; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3943 data->name = sn; |
4230 | 3944 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3945 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3946 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3947 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3948 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3949 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3950 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3951 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3952 g_free(dialog_msg); |
3953 } | |
3141 | 3954 } break; |
3955 | |
4173 | 3956 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3957 if (i >= 1) { |
7023 | 3958 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
|
3959 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3960 dialog_msg); |
4076 | 3961 g_free(dialog_msg); |
3962 } | |
3141 | 3963 } break; |
3964 | |
4173 | 3965 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3966 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
|
3967 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3968 dialog_msg); |
3141 | 3969 g_free(dialog_msg); |
3970 } break; | |
3971 | |
4333 | 3972 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3973 if (i >= 5) { | |
3974 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
|
3975 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3976 g_free(dialog_msg); |
3977 } | |
3978 } break; | |
3979 | |
4173 | 3980 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3981 if (i >= 6) { |
4194 | 3982 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
|
3983 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3984 g_free(dialog_msg); |
3985 } | |
4075 | 3986 } break; |
3987 | |
4173 | 3988 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3989 if (i >= 6) { |
4308 | 3990 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
|
3991 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3992 g_free(dialog_msg); |
3993 } | |
4075 | 3994 } break; |
3995 | |
4173 | 3996 case 0x12: { |
3141 | 3997 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3998 /* Someone added you to their buddy list? */ |
3141 | 3999 } break; |
4000 | |
7023 | 4001 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 4002 guint i, num; |
3453 | 4003 gchar **text; |
4173 | 4004 text = g_strsplit(args->msg, "\376", 0); |
3453 | 4005 if (text) { |
4006 num = 0; | |
4007 for (i=0; i<strlen(text[0]); i++) | |
4008 num = num*10 + text[0][i]-48; | |
4009 for (i=0; i<num; i++) { | |
4230 | 4010 struct name_data *data = g_new(struct name_data, 1); |
7023 | 4011 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 | 4012 data->gc = gc; |
4790 | 4013 data->name = g_strdup(text[i*2+1]); |
4014 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4015 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4016 gaim_request_action(gc, NULL, message, |
7023 | 4017 _("Do you want to add this buddy " |
4018 "to your buddy list?"), | |
9972 | 4019 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 4020 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 4021 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 4022 g_free(message); |
4023 } | |
4024 g_strfreev(text); | |
4025 } | |
4026 } break; | |
4027 | |
7023 | 4028 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 4029 /* This is boring and silly. */ |
4030 } break; | |
4031 | |
3141 | 4032 default: { |
8660 | 4033 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4034 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4035 "(type 0x%02hhx).\n", args->type); |
3141 | 4036 } break; |
4037 } | |
4038 | |
4076 | 4039 g_strfreev(msg1); |
4040 g_strfreev(msg2); | |
4041 | |
3141 | 4042 return 1; |
4043 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4044 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4045 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 4046 fu16_t channel; |
4047 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4048 aim_userinfo_t *userinfo; |
2086 | 4049 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4050 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4051 va_start(ap, fr); |
4200 | 4052 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4053 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4054 |
3141 | 4055 switch (channel) { |
4056 case 1: { /* standard message */ | |
4057 struct aim_incomingim_ch1_args *args; | |
4058 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
4059 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
4060 } break; | |
4061 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
4062 case 2: { /* rendezvous */ |
3141 | 4063 struct aim_incomingim_ch2_args *args; |
4064 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
4065 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
4066 } break; | |
4067 | |
4068 case 4: { /* ICQ */ | |
4069 struct aim_incomingim_ch4_args *args; | |
4070 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 4071 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 4072 } break; |
4073 | |
4074 default: { | |
8660 | 4075 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4076 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4077 "0x%04hx).", channel); |
3141 | 4078 } break; |
2086 | 4079 } |
4080 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4081 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4082 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4083 return ret; |
2086 | 4084 } |
4085 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4086 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 4087 GaimConnection *gc = sess->aux_data; |
4088 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 4089 char *buf; |
2086 | 4090 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4091 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4092 aim_userinfo_t *userinfo; |
2086 | 4093 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4094 va_start(ap, fr); |
4200 | 4095 chan = (fu16_t)va_arg(ap, unsigned int); |
4096 userinfo = va_arg(ap, aim_userinfo_t *); | |
4097 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
4098 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 4099 va_end(ap); |
4100 | |
4101 switch(reason) { | |
5420 | 4102 case 0: /* Invalid (0) */ |
4103 buf = g_strdup_printf( | |
4104 ngettext( | |
4276 | 4105 "You missed %hu message from %s because it was invalid.", |
4106 "You missed %hu messages from %s because they were invalid.", | |
4107 nummissed), | |
4282 | 4108 nummissed, |
4109 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4110 break; |
5420 | 4111 case 1: /* Message too large */ |
4112 buf = g_strdup_printf( | |
4113 ngettext( | |
4276 | 4114 "You missed %hu message from %s because it was too large.", |
4115 "You missed %hu messages from %s because they were too large.", | |
4116 nummissed), | |
4282 | 4117 nummissed, |
4118 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4119 break; |
5420 | 4120 case 2: /* Rate exceeded */ |
4121 buf = g_strdup_printf( | |
4122 ngettext( | |
4276 | 4123 "You missed %hu message from %s because the rate limit has been exceeded.", |
4124 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
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 3: /* Evil Sender */ |
4130 buf = g_strdup_printf( | |
4131 ngettext( | |
4276 | 4132 "You missed %hu message from %s because he/she was too evil.", |
4133 "You missed %hu messages from %s because he/she was too evil.", | |
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 4: /* Evil Receiver */ |
4139 buf = g_strdup_printf( | |
4140 ngettext( | |
4276 | 4141 "You missed %hu message from %s because you are too evil.", |
4142 "You missed %hu messages from %s because you are too evil.", | |
4143 nummissed), | |
4282 | 4144 nummissed, |
4145 userinfo->sn); | |
2086 | 4146 break; |
4147 default: | |
5420 | 4148 buf = g_strdup_printf( |
4149 ngettext( | |
4276 | 4150 "You missed %hu message from %s for an unknown reason.", |
4151 "You missed %hu messages from %s for an unknown reason.", | |
4152 nummissed), | |
4282 | 4153 nummissed, |
4154 userinfo->sn); | |
2086 | 4155 break; |
4156 } | |
8733 | 4157 |
9627 | 4158 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4159 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4160 g_free(buf); |
2086 | 4161 |
4162 return 1; | |
4163 } | |
4164 | |
11159 | 4165 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const guchar *cookie) { |
5575 | 4166 GaimConnection *gc = sess->aux_data; |
7283 | 4167 OscarData *od = gc->proto_data; |
4617 | 4168 |
4169 /* BBB */ | |
3630 | 4170 switch (reason) { |
4151 | 4171 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4172 GaimXfer *xfer; |
8971 | 4173 struct oscar_direct_im *dim; |
4174 | |
8660 | 4175 gaim_debug_info("oscar", |
9070 | 4176 "AAA - Other user declined some sort of direct " |
8971 | 4177 "connect attempt (automaticly?)\n"); |
4617 | 4178 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
|
4179 gaim_xfer_cancel_remote(xfer); |
8971 | 4180 else if ((dim = oscar_direct_im_find(od, who))) { |
4181 /* AAA should use find by cookie or something here */ | |
4182 oscar_direct_im_disconnect(od, dim); | |
4183 } | |
4151 | 4184 } break; |
4185 | |
4186 default: { | |
8660 | 4187 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4188 "Received an unknown rendezvous client auto-response " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4189 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4190 } |
3630 | 4191 |
4192 } | |
4193 | |
4194 return 0; | |
4195 } | |
4196 | |
4194 | 4197 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4198 GaimConnection *gc = sess->aux_data; |
4151 | 4199 |
4200 switch(reason) { | |
4201 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4202 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4203 | |
4204 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4205 |
4206 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4207 statusmsg = oscar_icqstatus(state); |
4151 | 4208 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4209 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4210 g_free(statusmsg); | |
4151 | 4211 g_strfreev(splitmsg); |
9244 | 4212 |
9797 | 4213 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4214 |
4215 g_free(title); | |
4216 g_free(dialogmsg); | |
4151 | 4217 } break; |
4218 | |
4219 default: { | |
8660 | 4220 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4221 "Received an unknown client auto-response from %s. " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4222 "Type 0x%04hx\n", who, reason); |
4151 | 4223 } break; |
4224 } /* end of switch */ | |
4225 | |
4226 return 0; | |
4227 } | |
4228 | |
3212 | 4229 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4230 va_list ap; | |
4231 fu16_t chan, reason; | |
4232 char *who; | |
4233 | |
4234 va_start(ap, fr); | |
4200 | 4235 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4236 who = va_arg(ap, char *); |
4200 | 4237 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4238 |
3952 | 4239 if (chan == 0x0002) { /* File transfer declined */ |
11159 | 4240 guchar *cookie = va_arg(ap, guchar *); |
4151 | 4241 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4242 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4243 fu32_t state = 0; |
4151 | 4244 char *msg = NULL; |
4245 if (reason == 0x0003) { | |
4200 | 4246 state = va_arg(ap, fu32_t); |
4151 | 4247 msg = va_arg(ap, char *); |
4248 } | |
4249 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4250 } | |
3952 | 4251 |
3212 | 4252 va_end(ap); |
4253 | |
4254 return 1; | |
4255 } | |
4256 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4257 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4258 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4259 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4260 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4261 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4262 va_start(ap, fr); |
4199 | 4263 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4264 va_end(ap); |
4265 | |
8660 | 4266 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4267 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4268 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4269 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4270 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4271 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4272 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4273 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4274 |
2086 | 4275 return 1; |
4276 } | |
4277 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4278 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4279 GaimConnection *gc = sess->aux_data; |
4617 | 4280 #if 0 |
7283 | 4281 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4282 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4283 #endif |
4617 | 4284 va_list ap; |
4285 fu16_t reason; | |
4286 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4287 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4288 va_start(ap, fr); |
4617 | 4289 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4290 data = va_arg(ap, char *); |
2086 | 4291 va_end(ap); |
4292 | |
8660 | 4293 gaim_debug_error("oscar", |
10130 | 4294 "Message error with data %s and reason %hu\n", |
4295 (data != NULL ? data : ""), reason); | |
4617 | 4296 |
4297 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4298 #if 0 |
4617 | 4299 /* If this was a file transfer request, data is a cookie */ |
4300 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
|
4301 gaim_xfer_cancel_remote(xfer); |
3630 | 4302 return 1; |
4303 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4304 #endif |
3630 | 4305 |
4617 | 4306 /* Data is assumed to be the destination sn */ |
9826 | 4307 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4308 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4309 g_free(buf); | |
4310 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4311 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4312 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4313 } | |
4314 g_free(buf); | |
4315 | |
2086 | 4316 return 1; |
4317 } | |
4318 | |
3595 | 4319 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4320 GaimConnection *gc = sess->aux_data; |
3595 | 4321 va_list ap; |
4322 fu16_t type1, type2; | |
4323 char *sn; | |
4324 | |
4325 va_start(ap, fr); | |
4199 | 4326 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4327 sn = va_arg(ap, char *); |
4199 | 4328 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4329 va_end(ap); |
4330 | |
4331 switch (type2) { | |
4332 case 0x0000: { /* Text has been cleared */ | |
4333 serv_got_typing_stopped(gc, sn); | |
4334 } break; | |
4335 | |
4336 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4337 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4338 } break; |
4339 | |
4340 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4341 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4342 } break; |
4343 | |
4344 default: { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4345 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 | 4346 } break; |
4347 } | |
4348 | |
4349 return 1; | |
4350 } | |
4351 | |
7141 | 4352 /* |
4353 * We get this error when there was an error in the locate family. This | |
7259 | 4354 * happens when you request info of someone who is offline. |
7141 | 4355 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4356 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4357 gchar *buf; |
2086 | 4358 va_list ap; |
5420 | 4359 fu16_t reason; |
2086 | 4360 char *destn; |
4361 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4362 va_start(ap, fr); |
4199 | 4363 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4364 destn = va_arg(ap, char *); |
4365 va_end(ap); | |
4366 | |
7781 | 4367 if (destn == NULL) |
7793 | 4368 return 1; |
10560 | 4369 |
9826 | 4370 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4371 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4372 g_free(buf); | |
9627 | 4373 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4374 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4375 } | |
4376 g_free(buf); | |
2086 | 4377 |
4378 return 1; | |
4379 } | |
4380 | |
7011 | 4381 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4382 GaimConnection *gc = sess->aux_data; |
8700 | 4383 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 4384 OscarData *od = gc->proto_data; |
8700 | 4385 GString *str; |
9244 | 4386 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4387 va_list ap; |
7011 | 4388 aim_userinfo_t *userinfo; |
2086 | 4389 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4390 va_start(ap, fr); |
7011 | 4391 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4392 va_end(ap); |
4393 | |
8700 | 4394 str = g_string_new(""); |
4395 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4396 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4397 |
10116 | 4398 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 4399 time_t t = userinfo->onlinesince - od->timeoffset; |
10116 | 4400 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); |
4401 } | |
4402 | |
4403 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 4404 time_t t = userinfo->membersince - od->timeoffset; |
10116 | 4405 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); |
4406 } | |
7011 | 4407 |
4408 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4409 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4410 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4411 g_free(tmp); |
4412 } | |
4413 | |
8701 | 4414 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4415 |
4416 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4417 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4418 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4419 g_free(tmp); | |
7011 | 4420 if (away_utf8 != NULL) { |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4421 g_string_append_printf(str, "\n<hr>%s<br>", away_utf8); |
7011 | 4422 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4423 } |
7011 | 4424 } |
4425 | |
4426 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4427 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4428 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4429 g_free(tmp); | |
7011 | 4430 if (info_utf8 != NULL) { |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4431 g_string_append_printf(str, "\n<hr>%s<br>", info_utf8); |
7011 | 4432 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4433 } |
7011 | 4434 } |
4435 | |
8701 | 4436 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4437 g_string_free(str, TRUE); |
9244 | 4438 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4439 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4440 g_free(title); |
8700 | 4441 g_free(tmp); |
4151 | 4442 |
2086 | 4443 return 1; |
4444 } | |
4445 | |
8341 | 4446 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4447 { | |
4448 aim_session_t *sess = data; | |
4449 GaimConnection *gc = sess->aux_data; | |
4450 OscarData *od = (OscarData *)gc->proto_data; | |
4451 | |
4452 aim_locate_dorequest(data); | |
4453 od->getinfotimer = 0; | |
4454 | |
4455 return FALSE; | |
4456 } | |
4457 | |
4458 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4459 { | |
4460 GaimConnection *gc = sess->aux_data; | |
4461 OscarData *od = (OscarData *)gc->proto_data; | |
4462 | |
4463 /* | |
4464 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4465 * us from hitting the rate limit due to request away messages and info | |
4466 * too quickly. | |
4467 */ | |
4468 if (od->getinfotimer == 0) | |
10198 | 4469 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4470 |
4471 return 1; | |
4472 } | |
4473 | |
4474 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4475 { | |
2086 | 4476 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4477 fu16_t id; |
2086 | 4478 va_list ap; |
4479 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4480 va_start(ap, fr); |
4199 | 4481 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4482 msg = va_arg(ap, char *); |
4483 va_end(ap); | |
4484 | |
8660 | 4485 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4486 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4487 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4488 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4489 _("Your AIM connection may be lost."), NULL); |
2086 | 4490 |
4491 return 1; | |
4492 } | |
4493 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4494 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4495 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4496 fu16_t type; |
5575 | 4497 GaimConnection *gc = sess->aux_data; |
7283 | 4498 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4499 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4500 va_start(ap, fr); |
4199 | 4501 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4502 |
4503 switch(type) { | |
4504 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4505 fu8_t maxrooms; |
2086 | 4506 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4507 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4508 |
4199 | 4509 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4510 exchangecount = va_arg(ap, int); |
4511 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4512 | |
8660 | 4513 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4514 "chat info: Chat Rights:\n"); |
8660 | 4515 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4516 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4517 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4518 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4519 for (i = 0; i < exchangecount; i++) |
8660 | 4520 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4521 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4522 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4523 while (od->create_rooms) { |
4524 struct create_room *cr = od->create_rooms->data; | |
8660 | 4525 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4526 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4527 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4528 g_free(cr->name); |
4617 | 4529 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4530 g_free(cr); |
2086 | 4531 } |
4532 } | |
4533 break; | |
4534 case 0x0008: { | |
4535 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4536 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4537 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4538 fu32_t createtime; |
2086 | 4539 |
4540 fqcn = va_arg(ap, char *); | |
4200 | 4541 instance = (fu16_t)va_arg(ap, unsigned int); |
4542 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4543 flags = (fu16_t)va_arg(ap, unsigned int); | |
4544 createtime = va_arg(ap, fu32_t); | |
4545 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4546 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4547 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4548 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4549 name = va_arg(ap, char *); | |
4550 ck = va_arg(ap, char *); | |
4194 | 4551 |
8660 | 4552 gaim_debug_misc("oscar", |
5556 | 4553 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4554 fqcn, |
4555 exchange, instance, flags, | |
4556 createtime, | |
4557 maxmsglen, maxoccupancy, createperms, unknown, | |
4558 name, ck); | |
4617 | 4559 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4560 } |
4561 break; | |
4562 default: | |
8660 | 4563 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4564 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4565 break; |
4566 } | |
4194 | 4567 |
4568 va_end(ap); | |
4569 | |
2086 | 4570 return 1; |
4571 } | |
4572 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4573 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4574 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4575 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4576 aim_userinfo_t *info; |
5575 | 4577 GaimConnection *g = sess->aux_data; |
2086 | 4578 |
4579 struct chat_connection *c = NULL; | |
4580 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4581 va_start(ap, fr); |
2086 | 4582 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4583 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4584 va_end(ap); |
4585 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4586 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4587 if (!c) |
4588 return 1; | |
4589 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4590 for (i = 0; i < count; i++) |
9846 | 4591 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4592 |
4593 return 1; | |
4594 } | |
4595 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4596 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4597 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4598 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4599 aim_userinfo_t *info; |
5575 | 4600 GaimConnection *g = sess->aux_data; |
2086 | 4601 |
4602 struct chat_connection *c = NULL; | |
4603 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4604 va_start(ap, fr); |
2086 | 4605 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4606 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4607 va_end(ap); |
4608 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4609 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4610 if (!c) |
4611 return 1; | |
4612 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4613 for (i = 0; i < count; i++) |
8733 | 4614 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4615 |
4616 return 1; | |
4617 } | |
4618 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4619 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
|
4620 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4621 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4622 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4623 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4624 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4625 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4626 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4627 fu32_t creationtime; |
5575 | 4628 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4629 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
|
4630 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4631 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4632 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4633 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4634 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4635 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4636 roomdesc = va_arg(ap, char *); |
4200 | 4637 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4638 creationtime = va_arg(ap, fu32_t); | |
4639 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4640 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4641 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4642 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4643 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4644 |
8660 | 4645 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4646 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4647 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4648 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4649 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4650 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4651 |
2086 | 4652 return 1; |
4653 } | |
4654 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4655 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4656 GaimConnection *gc = sess->aux_data; |
8225 | 4657 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4658 gchar *utf8; | |
2086 | 4659 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4660 aim_userinfo_t *info; |
8225 | 4661 int len; |
2086 | 4662 char *msg; |
8219 | 4663 char *charset; |
2086 | 4664 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4665 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4666 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4667 len = va_arg(ap, int); |
4194 | 4668 msg = va_arg(ap, char *); |
8219 | 4669 charset = va_arg(ap, char *); |
4194 | 4670 va_end(ap); |
2086 | 4671 |
8225 | 4672 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4673 if (utf8 == NULL) |
4674 /* The conversion failed! */ | |
8668 | 4675 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4676 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4677 g_free(utf8); | |
2086 | 4678 |
4679 return 1; | |
4680 } | |
4681 | |
3694 | 4682 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4683 va_list ap; | |
5575 | 4684 GaimConnection *gc = sess->aux_data; |
3694 | 4685 struct aim_emailinfo *emailinfo; |
3725 | 4686 int havenewmail; |
7297 | 4687 char *alertitle, *alerturl; |
3694 | 4688 |
4689 va_start(ap, fr); | |
4690 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4691 havenewmail = va_arg(ap, int); |
7301 | 4692 alertitle = va_arg(ap, char *); |
4693 alerturl = va_arg(ap, char *); | |
3694 | 4694 va_end(ap); |
4695 | |
9661 | 4696 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4697 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4698 emailinfo->domain ? "@" : "", | |
4699 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4700 if (emailinfo->unread && havenewmail) |
4701 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4702 g_free(to); |
3694 | 4703 } |
10157 | 4704 |
7301 | 4705 if (alertitle) |
8660 | 4706 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4707 |
4708 return 1; | |
4709 } | |
4710 | |
4804 | 4711 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4712 GaimConnection *gc = sess->aux_data; |
7283 | 4713 OscarData *od = gc->proto_data; |
4804 | 4714 char *sn; |
4715 | |
4716 sn = od->requesticon->data; | |
8660 | 4717 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4718 "removing %s from hash table\n", sn); |
4804 | 4719 od->requesticon = g_slist_remove(od->requesticon, sn); |
4720 free(sn); | |
4721 | |
4722 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4723 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4724 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4725 |
4726 return 1; | |
4727 } | |
4728 | |
4729 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4730 GaimConnection *gc = sess->aux_data; |
7283 | 4731 OscarData *od = gc->proto_data; |
4804 | 4732 GSList *cur; |
4733 va_list ap; | |
4734 char *sn; | |
11024 | 4735 fu8_t iconcsumtype, *iconcsum, *icon; |
4853 | 4736 fu16_t iconcsumlen, iconlen; |
4804 | 4737 |
4738 va_start(ap, fr); | |
4739 sn = va_arg(ap, char *); | |
11024 | 4740 iconcsumtype = va_arg(ap, int); |
4853 | 4741 iconcsum = va_arg(ap, fu8_t *); |
4742 iconcsumlen = va_arg(ap, int); | |
4804 | 4743 icon = va_arg(ap, fu8_t *); |
4744 iconlen = va_arg(ap, int); | |
4745 va_end(ap); | |
4746 | |
11024 | 4747 /* |
4748 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
4749 * no icon is set. Ignore these. | |
4750 */ | |
4751 if ((iconlen > 0) && (iconlen != 90)) { | |
4853 | 4752 char *b16; |
6695 | 4753 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4754 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4755 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4756 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4757 if (b16) { |
7693 | 4758 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4759 g_free(b16); |
5129 | 4760 } |
4853 | 4761 } |
4804 | 4762 |
4763 cur = od->requesticon; | |
4764 while (cur) { | |
4765 char *cursn = cur->data; | |
4766 if (!aim_sncmp(cursn, sn)) { | |
4767 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4768 free(cursn); | |
4769 cur = od->requesticon; | |
4770 } else | |
4771 cur = cur->next; | |
4772 } | |
4773 | |
4774 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4775 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4776 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4777 |
4778 return 1; | |
4779 } | |
4780 | |
4781 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4782 GaimConnection *gc = data; |
7283 | 4783 OscarData *od = gc->proto_data; |
7011 | 4784 aim_userinfo_t *userinfo; |
4804 | 4785 aim_conn_t *conn; |
4786 | |
4787 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4788 if (!conn) { |
4789 if (!od->iconconnecting) { | |
4790 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4791 od->iconconnecting = TRUE; | |
4792 } | |
4804 | 4793 return FALSE; |
4794 } | |
4795 | |
5842 | 4796 if (od->set_icon) { |
6039 | 4797 struct stat st; |
4798 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4799 if (iconfile == NULL) { | |
8363 | 4800 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4801 } else if (!g_stat(iconfile, &st)) { |
11159 | 4802 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4803 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 4804 if (file) { |
9532 | 4805 /* XXX - Use g_file_get_contents()? */ |
6039 | 4806 fread(buf, 1, st.st_size, file); |
4807 fclose(file); | |
8660 | 4808 gaim_debug_info("oscar", |
6039 | 4809 "Uploading icon to icon server\n"); |
6879 | 4810 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4811 } else |
8660 | 4812 gaim_debug_error("oscar", |
6039 | 4813 "Can't open buddy icon file!\n"); |
4814 g_free(buf); | |
4815 } else { | |
8660 | 4816 gaim_debug_error("oscar", |
6039 | 4817 "Can't stat buddy icon file!\n"); |
5842 | 4818 } |
4819 od->set_icon = FALSE; | |
4820 } | |
4821 | |
4822 if (!od->requesticon) { | |
8660 | 4823 gaim_debug_misc("oscar", |
5842 | 4824 "no more icons to request\n"); |
4825 return FALSE; | |
4826 } | |
4827 | |
7045 | 4828 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4829 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
11024 | 4830 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
4804 | 4831 return FALSE; |
4832 } else { | |
4833 char *sn = od->requesticon->data; | |
4834 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4835 free(sn); | |
4836 } | |
4837 | |
4838 return TRUE; | |
4839 } | |
4840 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4841 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4842 * 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
|
4843 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4844 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4845 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4846 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4847 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4848 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4849 va_start(ap, fr); |
4199 | 4850 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4851 sn = va_arg(ap, char *); |
4852 va_end(ap); | |
4853 | |
8660 | 4854 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4855 |
4856 return 1; | |
4857 } | |
4858 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4859 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
|
4860 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4861 "invalid", |
4194 | 4862 "change", |
4863 "warning", | |
4864 "limit", | |
4865 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4866 }; |
2086 | 4867 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4868 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4869 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4870 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4871 va_start(ap, fr); |
4200 | 4872 code = (fu16_t)va_arg(ap, unsigned int); |
4873 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4874 windowsize = va_arg(ap, fu32_t); | |
4875 clear = va_arg(ap, fu32_t); | |
4876 alert = va_arg(ap, fu32_t); | |
4877 limit = va_arg(ap, fu32_t); | |
4878 disconnect = va_arg(ap, fu32_t); | |
4879 currentavg = va_arg(ap, fu32_t); | |
4880 maxavg = va_arg(ap, fu32_t); | |
2086 | 4881 va_end(ap); |
4882 | |
8660 | 4883 gaim_debug_misc("oscar", |
5556 | 4884 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4885 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4886 (code < 5) ? codes[code] : codes[0], |
4887 rateclass, | |
4888 currentavg, maxavg, | |
4889 alert, clear, | |
4890 limit, disconnect, | |
4891 windowsize); | |
4892 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4893 /* XXX fix these values */ |
2086 | 4894 if (code == AIM_RATE_CODE_CHANGE) { |
4895 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4896 aim_conn_setlatency(fr->conn, 0); |
2086 | 4897 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4898 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4899 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4900 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4901 _("The last action you attempted could not be " |
4902 "performed because you are over the rate limit. " | |
4903 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4904 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4905 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4906 aim_conn_setlatency(fr->conn, 0); |
2086 | 4907 } |
4908 | |
4909 return 1; | |
4910 } | |
4911 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4912 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4913 GaimConnection *gc = sess->aux_data; |
4914 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4915 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4916 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4917 aim_userinfo_t *userinfo; |
2086 | 4918 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4919 va_start(ap, fr); |
4199 | 4920 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4921 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4922 va_end(ap); |
4923 | |
9982 | 4924 /* XXX - What's with the + 0.5? */ |
4925 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4926 |
4927 return 1; | |
4928 } | |
4929 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4930 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4931 GaimConnection *gc = sess->aux_data; |
4932 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4933 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4934 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4935 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4936 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4937 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4938 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4939 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4940 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4941 |
9982 | 4942 warning_level = info->warnlevel/10.0 + 0.5; |
4943 | |
10152 | 4944 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4945 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4946 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4947 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4948 |
4649 | 4949 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4950 GaimConnection *gc = sess->aux_data; |
7283 | 4951 OscarData *od = gc->proto_data; |
4649 | 4952 va_list ap; |
4953 fu16_t code; | |
4954 char *msg; | |
4955 | |
4956 va_start(ap, fr); | |
4957 code = (fu16_t)va_arg(ap, int); | |
4958 msg = va_arg(ap, char *); | |
4959 va_end(ap); | |
4960 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4961 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
10458 | 4962 code, (msg != NULL ? msg : "")); |
4963 | |
4964 g_return_val_if_fail(fr != NULL, 1); | |
4965 g_return_val_if_fail(fr->conn != NULL, 1); | |
4966 | |
4967 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 4968 if (code == 0x0001) { |
6113 | 4969 gc->wants_to_die = TRUE; |
10715 | 4970 gaim_connection_error(gc, _("You have signed on from another location.")); |
4651 | 4971 } else { |
5579 | 4972 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4973 } |
4666 | 4974 od->killme = TRUE; |
10458 | 4975 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
4976 struct chat_connection *cc; | |
4977 GaimConversation *conv; | |
4978 | |
4979 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
4980 conv = gaim_find_chat(gc, cc->id); | |
4981 | |
4982 if (conv != NULL) | |
4983 { | |
4984 gchar *buf; | |
4985 buf = g_strdup_printf(_("You have been disconnected from chat " | |
4986 "room %s."), cc->name); | |
4987 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
4988 g_free(buf); | |
4989 } | |
4990 oscar_chat_kill(gc, cc); | |
4649 | 4991 } |
4992 | |
4993 return 1; | |
4994 } | |
4995 | |
2675 | 4996 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4997 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4998 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4999 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 5000 |
8660 | 5001 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 5002 aim_ssi_reqrights(sess); |
6350 | 5003 aim_ssi_reqdata(sess); |
4230 | 5004 |
7011 | 5005 aim_locate_reqrights(sess); |
7285 | 5006 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 5007 aim_im_reqparams(sess); |
7334 | 5008 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 5009 |
7283 | 5010 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
5011 | |
2086 | 5012 return 1; |
5013 } | |
5014 | |
2675 | 5015 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5016 GaimConnection *gc = sess->aux_data; |
7283 | 5017 OscarData *od = gc->proto_data; |
2647 | 5018 |
6905 | 5019 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
5020 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
5021 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
5022 | |
2672 | 5023 aim_clientready(sess, fr->conn); |
8660 | 5024 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5025 |
2647 | 5026 if (od->chpass) { |
8660 | 5027 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5028 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 5029 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5030 od->oldp = NULL; |
2647 | 5031 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5032 od->newp = NULL; |
2647 | 5033 od->chpass = FALSE; |
5034 } | |
2979 | 5035 if (od->setnick) { |
8660 | 5036 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 5037 aim_admin_setnick(sess, fr->conn, od->newsn); |
5038 g_free(od->newsn); | |
5039 od->newsn = NULL; | |
5040 od->setnick = FALSE; | |
5041 } | |
2647 | 5042 if (od->conf) { |
8660 | 5043 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5044 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 5045 od->conf = FALSE; |
5046 } | |
5047 if (od->reqemail) { | |
8660 | 5048 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5049 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 5050 od->reqemail = FALSE; |
5051 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5052 if (od->setemail) { |
8660 | 5053 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5054 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5055 g_free(od->email); |
5497 | 5056 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5057 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5058 } |
2647 | 5059 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5060 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5061 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5062 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5063 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
|
5064 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5065 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5066 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5067 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5068 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5069 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5070 |
4194 | 5071 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 5072 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 5073 "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
|
5074 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5075 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5076 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
5077 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5078 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5079 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 5080 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5081 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5082 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5083 |
4617 | 5084 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5085 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5086 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5087 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5088 |
2993 | 5089 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
5090 { | |
5575 | 5091 GaimConnection *gc = sess->aux_data; |
7283 | 5092 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 5093 va_list ap; |
5094 fu16_t maxsiglen; | |
2993 | 5095 |
5096 va_start(ap, fr); | |
4199 | 5097 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 5098 va_end(ap); |
5099 | |
8660 | 5100 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5101 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 5102 |
4617 | 5103 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
5104 | |
5105 if (od->icq) | |
7334 | 5106 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 5107 else |
7334 | 5108 aim_locate_setcaps(od->sess, caps_aim); |
5109 oscar_set_info(gc, gc->account->user_info); | |
2993 | 5110 |
5111 return 1; | |
5112 } | |
5113 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5114 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
|
5115 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5116 fu16_t maxbuddies, maxwatchers; |
5575 | 5117 GaimConnection *gc = sess->aux_data; |
7283 | 5118 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5119 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5120 va_start(ap, fr); |
4199 | 5121 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5122 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5123 va_end(ap); |
5124 | |
8660 | 5125 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5126 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5127 |
4617 | 5128 od->rights.maxbuddies = (guint)maxbuddies; |
5129 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5130 |
2086 | 5131 return 1; |
5132 } | |
5133 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5134 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5135 GaimConnection *gc = sess->aux_data; |
7283 | 5136 OscarData *od = (OscarData *)gc->proto_data; |
10570 | 5137 GaimAccount *account = gaim_connection_get_account(gc); |
7334 | 5138 va_list ap; |
5139 fu16_t maxpermits, maxdenies; | |
2086 | 5140 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5141 va_start(ap, fr); |
4199 | 5142 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5143 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5144 va_end(ap); |
5145 | |
8660 | 5146 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5147 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5148 |
4617 | 5149 od->rights.maxpermits = (guint)maxpermits; |
5150 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5151 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5152 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5153 |
8660 | 5154 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5155 |
2672 | 5156 aim_clientready(sess, fr->conn); |
5948 | 5157 aim_srv_setavailmsg(sess, NULL); |
7474 | 5158 aim_srv_setidle(sess, 0); |
4617 | 5159 |
4664 | 5160 if (od->icq) { |
5161 aim_icq_reqofflinemsgs(sess); | |
10570 | 5162 aim_icq_setsecurity(sess, |
5163 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
5164 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE), | |
5165 gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP)); | |
4664 | 5166 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5167 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5168 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5169 if (sess->authinfo->email) |
5170 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5171 |
5172 return 1; | |
5173 } | |
5174 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5175 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
|
5176 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5177 struct aim_icq_offlinemsg *msg; |
4075 | 5178 struct aim_incomingim_ch4_args args; |
5179 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5180 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5181 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5182 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5183 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5184 |
8660 | 5185 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5186 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5187 args.uin = msg->sender; |
5188 args.type = msg->type; | |
4173 | 5189 args.flags = msg->flags; |
4076 | 5190 args.msglen = msg->msglen; |
4075 | 5191 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5192 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5193 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5194 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5195 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5196 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5197 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5198 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
|
5199 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5200 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5201 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5202 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5203 |
7388 | 5204 #if 0 |
5205 /* | |
7465 | 5206 * Update, 2003-11-09: |
5207 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5208 * | |
7388 | 5209 * It may not be my place to do this, but... |
5210 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5211 * stupid, and should not exist for % switches (%x in our case) that request | |
5212 * a year in the preferred representation for the current locale. For that | |
5213 * reason I've chosen to not use this workaround (n., see kluge). | |
5214 * | |
5215 * I have a date. I want to show it to the user in the "preferred" way. | |
5216 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5217 * what the locale wanted. | |
5218 * | |
5219 * If I have a necessity for a full representation of the year in the current | |
5220 * locale, then I'll use a switch that returns a full representation of the | |
5221 * year. | |
5222 * | |
5223 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5224 * (because you're anal, or whatever), then change the f***ing locale. | |
5225 * | |
5226 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5227 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5228 * |
5229 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5230 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5231 */ |
5232 | |
5233 /* | |
5234 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5235 * "last 2 digits" warning. |
5236 */ | |
10157 | 5237 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5238 const struct tm *tm) |
5239 { | |
5240 return strftime(s, max, fmt, tm); | |
5241 } | |
10636 | 5242 |
5243 /* | |
5244 * Before even realizing this was here, I went and did the same thing in util.c. | |
5245 * | |
5246 * Use gaim_strftime() | |
5247 */ | |
5248 | |
7388 | 5249 #endif |
7386 | 5250 |
4624 | 5251 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
|
5252 { |
5575 | 5253 GaimConnection *gc = sess->aux_data; |
8670 | 5254 OscarData *od = (OscarData *)gc->proto_data; |
5255 GaimBuddy *buddy; | |
8853 | 5256 struct buddyinfo *bi = NULL; |
4624 | 5257 gchar who[16]; |
8670 | 5258 GString *str; |
5259 gchar *primary, *utf8; | |
9634 | 5260 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5261 va_list ap; |
4151 | 5262 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5263 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5264 va_start(ap, fr); |
4151 | 5265 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5266 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5267 |
4664 | 5268 if (!info->uin) |
5269 return 0; | |
5270 | |
8670 | 5271 str = g_string_sized_new(100); |
5556 | 5272 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5273 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5274 if (buddy != NULL) | |
5275 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5276 | |
5277 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5278 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5279 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5280 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5281 (bi->ipaddr & 0xff000000) >> 24, | |
5282 (bi->ipaddr & 0x00ff0000) >> 16, | |
5283 (bi->ipaddr & 0x0000ff00) >> 8, | |
5284 (bi->ipaddr & 0x000000ff)); | |
8701 | 5285 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5286 g_free(tstr); |
5287 } | |
8701 | 5288 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5289 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5290 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5291 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5292 g_free(utf8); | |
4625 | 5293 } |
5294 if (info->numaddresses && info->email2) { | |
5295 int i; | |
5296 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5297 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
10683 | 5298 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 5299 g_free(utf8); |
4643 | 5300 } |
4625 | 5301 } |
4624 | 5302 } |
8701 | 5303 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5304 if (info->gender != 0) |
5305 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5306 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5307 char date[30]; |
5308 struct tm tm; | |
5309 tm.tm_mday = (int)info->birthday; | |
5310 tm.tm_mon = (int)info->birthmonth-1; | |
5311 tm.tm_year = (int)info->birthyear-1900; | |
10636 | 5312 gaim_strftime(date, sizeof(date), "%x", &tm); |
8701 | 5313 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5314 } |
4624 | 5315 if (info->age) { |
5316 char age[5]; | |
5317 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5318 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5319 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5320 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5321 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5322 g_free(utf8); | |
4819 | 5323 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5324 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5325 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5326 g_free(utf8); | |
5327 } | |
10683 | 5328 g_string_append_printf(str, "<hr>"); |
4641 | 5329 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5330 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5331 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5332 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5333 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5334 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
10683 | 5335 g_string_append_printf(str, "\n<hr>"); |
4151 | 5336 } |
4641 | 5337 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5338 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5339 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5340 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5341 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5342 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
10683 | 5343 g_string_append_printf(str, "\n<hr>"); |
4624 | 5344 } |
4641 | 5345 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5346 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5347 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5348 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5349 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5350 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5351 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5352 g_free(utf8); | |
4624 | 5353 } |
10683 | 5354 g_string_append_printf(str, "\n<hr>"); |
8670 | 5355 } |
5356 | |
9634 | 5357 if (buddy != NULL) |
5358 alias = gaim_buddy_get_alias(buddy); | |
5359 else | |
5360 alias = who; | |
5361 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5362 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5363 g_free(primary); |
8670 | 5364 g_string_free(str, TRUE); |
4151 | 5365 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5366 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5367 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5368 |
4759 | 5369 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5370 { | |
5575 | 5371 GaimConnection *gc = sess->aux_data; |
4820 | 5372 gchar who[16], *utf8; |
6695 | 5373 GaimBuddy *b; |
4759 | 5374 va_list ap; |
5375 struct aim_icq_info *info; | |
5376 | |
5377 va_start(ap, fr); | |
5378 info = va_arg(ap, struct aim_icq_info *); | |
5379 va_end(ap); | |
5380 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5381 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5382 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5383 serv_got_alias(gc, who, utf8); |
4759 | 5384 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5385 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5386 } |
4820 | 5387 g_free(utf8); |
4759 | 5388 } |
5389 | |
5390 return 1; | |
5391 } | |
5392 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5393 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
|
5394 { |
7032 | 5395 GaimConnection *gc = sess->aux_data; |
5396 gchar *text; | |
5397 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5398 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5399 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5400 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5401 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5402 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5403 url = va_arg(ap, char *); |
4199 | 5404 wid = (fu16_t) va_arg(ap, int); |
5405 hei = (fu16_t) va_arg(ap, int); | |
5406 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5407 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5408 |
7032 | 5409 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5410 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5411 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5412 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5413 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5414 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5415 |
7032 | 5416 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5417 { | |
6873 | 5418 GaimConnection *gc = sess->aux_data; |
5419 gchar *secondary; | |
10439 | 5420 gchar **screennames; |
6873 | 5421 int i, num; |
2086 | 5422 va_list ap; |
6873 | 5423 char *email, *SNs; |
2086 | 5424 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5425 va_start(ap, fr); |
6873 | 5426 email = va_arg(ap, char *); |
2086 | 5427 num = va_arg(ap, int); |
5428 SNs = va_arg(ap, char *); | |
5429 va_end(ap); | |
5430 | |
10439 | 5431 /* TODO: Need to use ngettext() here */ |
8152 | 5432 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5433 |
5434 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5435 for (i = 0; i < num; i++) |
10439 | 5436 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5437 screennames[num] = NULL; | |
5438 | |
5439 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5440 (const char **)screennames, NULL, NULL); | |
6873 | 5441 |
5442 g_free(secondary); | |
10439 | 5443 g_strfreev(screennames); |
2086 | 5444 |
5445 return 1; | |
5446 } | |
5447 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5448 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5449 va_list ap; |
6873 | 5450 char *email; |
5420 | 5451 char *buf; |
2086 | 5452 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5453 va_start(ap, fr); |
6873 | 5454 email = va_arg(ap, char *); |
2086 | 5455 va_end(ap); |
5456 | |
6873 | 5457 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
|
5458 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5459 g_free(buf); |
2086 | 5460 |
5461 return 1; | |
5462 } | |
5463 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5464 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5465 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5466 fu16_t status; |
2086 | 5467 va_list ap; |
5468 char msg[256]; | |
5469 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5470 va_start(ap, fr); |
4199 | 5471 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5472 va_end(ap); |
5473 | |
8660 | 5474 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5475 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5476 status ? "unknown" : "email sent"); |
5477 if (!status) { | |
5302 | 5478 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5479 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5480 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5481 } |
5482 | |
5483 return 1; | |
5484 } | |
5485 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5486 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5487 GaimConnection *gc = sess->aux_data; |
2086 | 5488 va_list ap; |
3912 | 5489 fu16_t perms, err; |
5490 char *url, *sn, *email; | |
5491 int change; | |
2086 | 5492 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5493 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5494 change = va_arg(ap, int); |
4199 | 5495 perms = (fu16_t) va_arg(ap, unsigned int); |
5496 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5497 url = va_arg(ap, char *); |
5498 sn = va_arg(ap, char *); | |
5499 email = va_arg(ap, char *); | |
2086 | 5500 va_end(ap); |
5501 | |
8660 | 5502 gaim_debug_misc("oscar", |
9626 | 5503 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5504 change ? "change" : "request", perms, err, | |
5505 (url != NULL) ? url : "(null)", | |
5506 (sn != NULL) ? sn : "(null)", | |
5507 (email != NULL) ? email : "(null)"); | |
5508 | |
5509 if ((err > 0) && (url != NULL)) { | |
3912 | 5510 char *dialog_msg; |
5511 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5512 switch (err) { | |
5513 case 0x0001: { | |
5514 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5515 } break; | |
5516 case 0x0006: { | |
5517 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5518 } break; | |
5519 case 0x000b: { | |
5520 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5521 } break; | |
5522 case 0x001d: { | |
5523 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); | |
5524 } break; | |
5525 case 0x0021: { | |
5526 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); | |
5527 } break; | |
5528 case 0x0023: { | |
5529 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5530 } break; | |
5531 default: { | |
5532 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5533 } break; | |
5534 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5535 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5536 g_free(dialog_top); |
5537 g_free(dialog_msg); | |
5538 return 1; | |
5539 } | |
5540 | |
9626 | 5541 if (sn != NULL) { |
4585 | 5542 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
|
5543 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5544 g_free(dialog_msg); |
5545 } | |
5546 | |
9626 | 5547 if (email != NULL) { |
5575 | 5548 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5549 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5550 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5551 g_free(dialog_msg); |
2086 | 5552 } |
5553 | |
5554 return 1; | |
5555 } | |
5556 | |
5575 | 5557 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5558 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5559 aim_flap_nop(od->sess, od->conn); |
2086 | 5560 } |
5561 | |
6059 | 5562 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5563 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5564 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5565 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5566 if (typing == GAIM_TYPING) |
4870 | 5567 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5568 else if (typing == GAIM_TYPED) |
4870 | 5569 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5570 else | |
5571 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5572 else { |
5300 | 5573 /* Don't send if this turkey is in our deny list */ |
5574 GSList *list; | |
5575 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5576 if (!list) { | |
7261 | 5577 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5578 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5579 if (typing == GAIM_TYPING) |
5300 | 5580 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5581 else if (typing == GAIM_TYPED) |
5300 | 5582 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5583 else | |
5584 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5585 } | |
3595 | 5586 } |
5587 } | |
2993 | 5588 return 0; |
5589 } | |
9030 | 5590 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5591 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
|
5592 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5593 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5594 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5595 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5596 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
|
5597 int ret = 0; |
10246 | 5598 const char *iconfile = gaim_account_get_buddy_icon(account); |
10781 | 5599 char *tmpmsg = NULL; |
3458 | 5600 |
4838 | 5601 if (dim && dim->connected) { |
5602 /* If we're directly connected, send a direct IM */ | |
6982 | 5603 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5604 } else { |
4738 | 5605 struct buddyinfo *bi; |
3008 | 5606 struct aim_sendimext_args args; |
5607 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5608 gsize len; |
10246 | 5609 GaimConversation *conv; |
5610 | |
5611 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5612 |
5613 if (strstr(message, "<IMG ")) | |
5614 gaim_conversation_write(conv, "", | |
5615 _("Your IM Image was not sent. " | |
5616 "You must be Direct Connected to send IM Images."), | |
5617 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5618 |
10246 | 5619 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5620 if (!bi) { |
5621 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5622 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5623 } |
5624 | |
3008 | 5625 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5626 if (od->icq) { |
5627 args.features = features_icq; | |
5628 args.featureslen = sizeof(features_icq); | |
3008 | 5629 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5630 } else { |
5631 args.features = features_aim; | |
5632 args.featureslen = sizeof(features_aim); | |
4972 | 5633 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5634 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5635 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5636 } |
4269 | 5637 |
4738 | 5638 if (bi->ico_need) { |
8660 | 5639 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5640 "Sending buddy icon request with message\n"); |
3008 | 5641 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5642 bi->ico_need = FALSE; |
3008 | 5643 } |
4269 | 5644 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5645 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5646 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 5647 if (file) { |
11159 | 5648 guchar *buf = g_malloc(st.st_size); |
9532 | 5649 /* XXX - Use g_file_get_contents()? */ |
3008 | 5650 fread(buf, 1, st.st_size, file); |
6039 | 5651 fclose(file); |
4269 | 5652 |
3008 | 5653 args.iconlen = st.st_size; |
4617 | 5654 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5655 args.iconstamp = st.st_mtime; |
5656 | |
7406 | 5657 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5658 bi->ico_informed = FALSE; |
7406 | 5659 bi->ico_sent = FALSE; |
5660 } | |
4738 | 5661 |
5662 if (!bi->ico_informed) { | |
8660 | 5663 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5664 "Claiming to have a buddy icon\n"); |
4738 | 5665 args.flags |= AIM_IMFLAGS_HASICON; |
5666 bi->ico_me_len = args.iconlen; | |
5667 bi->ico_me_csum = args.iconsum; | |
5668 bi->ico_me_time = args.iconstamp; | |
5669 bi->ico_informed = TRUE; | |
5670 } | |
5671 | |
3008 | 5672 g_free(buf); |
2086 | 5673 } |
5674 } | |
4269 | 5675 |
3008 | 5676 args.destsn = name; |
4269 | 5677 |
8985 | 5678 /* |
10781 | 5679 * If we're IMing an ICQ user from an ICQ account, then strip HTML |
5680 * and use \r\n as the newline character. | |
8985 | 5681 */ |
10781 | 5682 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
5683 if (aim_sn_is_icq(name)) | |
5684 /* From ICQ to ICQ */ | |
8995 | 5685 tmpmsg = g_strdup(message); |
10781 | 5686 else |
5687 /* From ICQ to AIM */ | |
5688 tmpmsg = g_markup_escape_text(message, -1); | |
8995 | 5689 } else { |
10785 | 5690 /* From AIM to AIM and AIM to ICQ */ |
5691 tmpmsg = g_strdup(message); | |
8995 | 5692 } |
6310 | 5693 len = strlen(tmpmsg); |
5694 | |
9830 | 5695 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5696 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5697 args.charset, args.charsubset, args.msglen); | |
4617 | 5698 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5699 g_free((char *)args.msg); |
2086 | 5700 } |
4838 | 5701 |
6310 | 5702 g_free(tmpmsg); |
5703 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5704 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5705 return 1; |
6310 | 5706 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5707 return ret; |
2086 | 5708 } |
5709 | |
7011 | 5710 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5711 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5712 |
9975 | 5713 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5714 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5715 else |
7235 | 5716 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5717 } |
5718 | |
8950 | 5719 #if 0 |
7011 | 5720 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5721 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5722 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5723 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5724 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5725 maiden, NULL, NULL, city, state, NULL, 0, web); |
5726 } | |
8950 | 5727 #endif |
2086 | 5728 |
5575 | 5729 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5730 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5731 aim_srv_setidle(od->sess, time); |
2086 | 5732 } |
5733 | |
5954 | 5734 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5735 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5736 int charset = 0; |
6019 | 5737 char *text_html = NULL; |
5129 | 5738 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5739 gsize msglen = 0; |
2993 | 5740 |
4617 | 5741 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5742 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5743 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5744 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5745 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5746 "again when you are fully connected.")); |
4617 | 5747 |
7334 | 5748 if (!text) { |
5749 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5750 return; | |
5751 } | |
10097 | 5752 |
7334 | 5753 text_html = gaim_strdup_withhtml(text); |
9807 | 5754 charset = oscar_charset_check(text_html); |
9826 | 5755 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5756 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5757 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5758 g_free(msg); | |
9826 | 5759 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5760 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5761 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5762 g_free(msg); | |
5763 } else { | |
5764 msglen = strlen(text_html); | |
5765 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5766 } | |
5767 | |
5768 if (msglen > od->rights.maxsiglen) { | |
5769 gchar *errstr; | |
5770 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
|
5771 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5772 "The maximum profile length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5773 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5774 od->rights.maxsiglen), od->rights.maxsiglen); |
5775 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5776 g_free(errstr); | |
5777 } | |
5778 | |
5779 g_free(text_html); | |
2086 | 5780 } |
5781 | |
9991 | 5782 static void |
5783 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5784 { |
9991 | 5785 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5786 OscarData *od = NULL; |
9992 | 5787 GaimStatusType *status_type; |
9991 | 5788 GaimStatusPrimitive primitive; |
5789 GaimPresence *presence; | |
5790 const gchar *status_id; | |
9807 | 5791 int charset = 0; |
10196 | 5792 const gchar *text_html = NULL; |
5129 | 5793 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5794 gsize msglen = 0; |
2993 | 5795 |
9992 | 5796 status_type = gaim_status_get_type(status); |
5797 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5798 status_id = gaim_status_get_id(status); |
5799 presence = gaim_account_get_presence(account); | |
5800 | |
10400 | 5801 if (gc) |
5802 od = (OscarData *)gc->proto_data; | |
10401 | 5803 |
5804 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { | |
9991 | 5805 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5806 _("You have probably requested to set your " |
5807 "away message before the login procedure " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5808 "completed. You remain in a \"present\" " |
10400 | 5809 "state; try setting it again when you are " |
5810 "fully connected.")); | |
10401 | 5811 return; |
5812 } | |
5129 | 5813 |
9992 | 5814 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5815 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5816 | |
7334 | 5817 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5818 |
5819 text_html = gaim_status_get_attr_string(status, "message"); | |
5820 if (text_html != NULL) { | |
5821 aim_srv_setavailmsg(od->sess, text_html); | |
5822 } | |
10196 | 5823 |
5824 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5825 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5826 | |
10196 | 5827 text_html = gaim_status_get_attr_string(status, "message"); |
5828 | |
5829 if (text_html == NULL) { | |
5830 text_html = _("Away"); | |
5831 } | |
5832 | |
5833 charset = oscar_charset_check(text_html); | |
5834 if (charset == AIM_CHARSET_UNICODE) { | |
5835 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5836 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5837 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5838 g_free(msg); | |
5839 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5840 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5841 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5842 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5843 g_free(msg); | |
5844 } else { | |
5845 msglen = strlen(text_html); | |
5846 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5847 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5848 } | |
5849 | |
5850 if (msglen > od->rights.maxawaymsglen) { | |
5851 gchar *errstr; | |
5852 | |
5853 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
|
5854 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5855 "The maximum away message length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5856 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5857 od->rights.maxawaymsglen), od->rights.maxawaymsglen); |
5858 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5859 g_free(errstr); | |
5860 } | |
5861 | |
10197 | 5862 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5863 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5864 | |
5129 | 5865 } else { |
10196 | 5866 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5867 | |
5868 } | |
2993 | 5869 } |
5870 | |
9991 | 5871 static void |
5872 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5873 { |
9991 | 5874 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 5875 OscarData *od = NULL; |
9991 | 5876 const gchar *status_id = gaim_status_get_id(status); |
5877 | |
10646 | 5878 if (gc) |
5879 od = (OscarData *)gc->proto_data; | |
5880 if (!od) | |
5881 return; | |
5882 | |
9991 | 5883 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) |
5575 | 5884 account->perm_deny = 4; |
8265 | 5885 else |
5575 | 5886 account->perm_deny = 3; |
9991 | 5887 |
8265 | 5888 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5889 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5890 |
9991 | 5891 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5892 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5893 |
5894 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5895 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5896 |
5897 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5898 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5899 |
5900 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5901 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5902 |
5903 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5904 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5905 |
5906 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5907 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5908 |
5909 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5910 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5911 |
5912 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5913 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5914 } |
5915 | |
9991 | 5916 static void |
5917 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5918 { |
10747 | 5919 gboolean connected = gaim_account_is_connected(account); |
10400 | 5920 GaimStatusType *type = gaim_status_get_type(status); |
5921 int primitive = gaim_status_type_get_primitive(type); | |
5922 | |
10747 | 5923 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
5924 | |
10498 | 5925 if (!gaim_status_is_active(status)) |
10485 | 5926 return; |
5927 | |
10753 | 5928 if (primitive != GAIM_STATUS_OFFLINE && !connected) { |
10738 | 5929 gaim_account_connect(account); |
10747 | 5930 } else if (primitive == GAIM_STATUS_OFFLINE && connected) { |
10400 | 5931 gaim_account_disconnect(account); |
5932 } else { | |
10747 | 5933 if (!connected) |
5934 return; | |
10400 | 5935 |
5936 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
5937 oscar_set_status_icq(account, status); | |
5938 else | |
10560 | 5939 /* QQQ - Should probably also set this for ICQ */ |
10400 | 5940 oscar_set_status_aim(account, status); |
5941 } | |
2086 | 5942 } |
5943 | |
9991 | 5944 static void |
5945 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5946 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5947 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5948 } |
5949 | |
10747 | 5950 static void |
5951 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5952 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5953 |
5954 if (!aim_snvalid(buddy->name)) { | |
8092 | 5955 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5956 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 | 5957 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5958 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5959 g_free(buf); |
8150 | 5960 |
5961 /* Remove from local list */ | |
9285 | 5962 gaim_blist_remove_buddy(buddy); |
8150 | 5963 |
8092 | 5964 return; |
5965 } | |
5966 | |
9285 | 5967 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5968 if (buddy && group) { | |
8660 | 5969 gaim_debug_info("oscar", |
9285 | 5970 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5971 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5972 } |
5973 } | |
8150 | 5974 |
10157 | 5975 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5976 if (od->icq) |
9285 | 5977 aim_icq_getalias(od->sess, buddy->name); |
5978 } | |
5979 | |
5980 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5981 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5982 |
4230 | 5983 if (od->sess->ssi.received_data) { |
8660 | 5984 gaim_debug_info("oscar", |
9285 | 5985 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5986 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5987 } |
10866 | 5988 } |
5989 | |
5575 | 5990 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5991 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5992 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5993 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5994 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5995 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5996 } |
5997 } | |
5998 | |
5575 | 5999 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 6000 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 6001 if (od->sess->ssi.received_data) { |
6002 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
6003 if (gname) { | |
8660 | 6004 gaim_debug_info("oscar", |
9586 | 6005 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 6006 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 6007 } |
6008 } | |
6009 } | |
6010 | |
11005 | 6011 /* |
6012 * FYI, the OSCAR SSI code removes empty groups automatically. | |
6013 */ | |
9285 | 6014 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 6015 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6016 |
6017 if (od->sess->ssi.received_data) { | |
9285 | 6018 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
6019 GList *cur, *groups = NULL; | |
6020 | |
6021 /* Make a list of what the groups each buddy is in */ | |
6022 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
6023 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6024 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6025 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6026 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6027 node->parent->parent); |
9285 | 6028 } |
6029 | |
10866 | 6030 serv_remove_buddies(gc, moved_buddies, groups); |
6031 serv_add_buddies(gc, moved_buddies); | |
9285 | 6032 g_list_free(groups); |
8660 | 6033 gaim_debug_info("oscar", |
9285 | 6034 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 6035 } else { |
9285 | 6036 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 6037 gaim_debug_info("oscar", |
9285 | 6038 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 6039 } |
6040 } | |
6041 } | |
6042 | |
5968 | 6043 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
6044 aim_session_t *sess = data; | |
6350 | 6045 aim_ssi_reqdata(sess); |
5968 | 6046 return FALSE; |
6047 } | |
6048 | |
4642 | 6049 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6050 GaimConnection *gc = sess->aux_data; |
7283 | 6051 OscarData *od = gc->proto_data; |
4642 | 6052 va_list ap; |
6053 fu16_t reason; | |
6054 | |
6055 va_start(ap, fr); | |
6056 reason = (fu16_t)va_arg(ap, unsigned int); | |
6057 va_end(ap); | |
6058 | |
8660 | 6059 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 6060 |
6061 if (reason == 0x0005) { | |
5892 | 6062 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6063 _("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
|
6064 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 6065 } |
6066 | |
6067 /* Activate SSI */ | |
6068 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6069 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6070 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 6071 aim_ssi_enable(od->sess); |
6072 | |
6073 return 1; | |
6074 } | |
6075 | |
2991 | 6076 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6077 GaimConnection *gc = sess->aux_data; |
7283 | 6078 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 6079 int i; |
6080 va_list ap; | |
6081 int numtypes; | |
4230 | 6082 fu16_t *maxitems; |
2991 | 6083 |
6084 va_start(ap, fr); | |
4230 | 6085 numtypes = va_arg(ap, int); |
6086 maxitems = va_arg(ap, fu16_t *); | |
2991 | 6087 va_end(ap); |
6088 | |
8660 | 6089 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6090 |
4230 | 6091 for (i=0; i<numtypes; i++) |
8660 | 6092 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6093 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6094 |
8660 | 6095 gaim_debug_misc(NULL, "\n"); |
4230 | 6096 |
6097 if (numtypes >= 0) | |
6098 od->rights.maxbuddies = maxitems[0]; | |
6099 if (numtypes >= 1) | |
6100 od->rights.maxgroups = maxitems[1]; | |
6101 if (numtypes >= 2) | |
6102 od->rights.maxpermits = maxitems[2]; | |
6103 if (numtypes >= 3) | |
6104 od->rights.maxdenies = maxitems[3]; | |
2991 | 6105 |
6106 return 1; | |
6107 } | |
6108 | |
6109 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6110 GaimConnection *gc = sess->aux_data; |
6111 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6112 GaimStatus *status; |
7283 | 6113 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6114 GaimGroup *g; |
6115 GaimBuddy *b; | |
2995 | 6116 struct aim_ssi_item *curitem; |
2991 | 6117 int tmp; |
4230 | 6118 va_list ap; |
8219 | 6119 fu16_t fmtver, numitems; |
6120 struct aim_ssi_item *items; | |
6121 fu32_t timestamp; | |
4230 | 6122 |
6123 va_start(ap, fr); | |
6124 fmtver = (fu16_t)va_arg(ap, int); | |
6125 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6126 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6127 timestamp = va_arg(ap, fu32_t); |
8219 | 6128 va_end(ap); |
2991 | 6129 |
8660 | 6130 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6131 "ssi: syncing local list and server list\n"); |
2991 | 6132 |
8219 | 6133 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6134 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 | 6135 return 1; |
6136 } | |
6137 | |
2991 | 6138 /* Clean the buddy list */ |
4889 | 6139 aim_ssi_cleanlist(sess); |
2991 | 6140 |
8150 | 6141 { /* If not in server list then prune from local list */ |
6142 GaimBlistNode *gnode, *cnode, *bnode; | |
6143 GaimBuddyList *blist; | |
9539 | 6144 GSList *cur, *next; |
8150 | 6145 |
6146 /* Buddies */ | |
6147 cur = NULL; | |
6148 if ((blist = gaim_get_blist()) != NULL) { | |
6149 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6150 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6151 continue; | |
6152 g = (GaimGroup *)gnode; | |
6153 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6154 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6155 continue; | |
6156 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6157 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6158 continue; | |
6159 b = (GaimBuddy *)bnode; | |
6160 if (b->account == gc->account) { | |
6161 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6162 /* If the buddy is an ICQ user then load his nickname */ | |
6163 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6164 char *alias; |
8150 | 6165 if (servernick) |
6166 serv_got_alias(gc, b->name, servernick); | |
6167 | |
6168 /* Store local alias on server */ | |
8214 | 6169 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6170 if (!alias && b->alias && strlen(b->alias)) |
6171 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6172 free(alias); | |
6173 } else { | |
8660 | 6174 gaim_debug_info("oscar", |
8150 | 6175 "ssi: removing buddy %s from local list\n", b->name); |
6176 /* We can't actually remove now because it will screw up our looping */ | |
6177 cur = g_slist_prepend(cur, b); | |
6178 } | |
6179 } | |
6180 } | |
6181 } | |
6182 } | |
6183 } | |
8175 | 6184 |
8150 | 6185 while (cur != NULL) { |
6186 b = cur->data; | |
6187 cur = g_slist_remove(cur, b); | |
6188 gaim_blist_remove_buddy(b); | |
6189 } | |
6190 | |
6191 /* Permit list */ | |
6192 if (gc->account->permit) { | |
9539 | 6193 next = gc->account->permit; |
6194 while (next != NULL) { | |
6195 cur = next; | |
6196 next = next->next; | |
8150 | 6197 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6198 gaim_debug_info("oscar", |
8150 | 6199 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6200 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6201 } | |
9539 | 6202 } |
8150 | 6203 } |
6204 | |
6205 /* Deny list */ | |
6206 if (gc->account->deny) { | |
9539 | 6207 next = gc->account->deny; |
6208 while (next != NULL) { | |
6209 cur = next; | |
6210 next = next->next; | |
8150 | 6211 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6212 gaim_debug_info("oscar", |
8150 | 6213 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6214 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6215 } | |
9539 | 6216 } |
8150 | 6217 } |
6218 /* Presence settings (idle time visibility) */ | |
6219 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6220 if (!(tmp & 0x400)) | |
6221 aim_ssi_setpresence(sess, tmp | 0x400); | |
6222 } /* end pruning buddies from local list */ | |
6223 | |
2991 | 6224 /* Add from server list to local list */ |
4230 | 6225 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6226 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6227 switch (curitem->type) { |
4230 | 6228 case 0x0000: { /* Buddy */ |
4251 | 6229 if (curitem->name) { |
4292 | 6230 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6231 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6232 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6233 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6234 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6235 /* Should gname be freed here? -- elb */ |
4754 | 6236 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6237 free(alias); |
8150 | 6238 if (b) { |
4292 | 6239 /* Get server stored alias */ |
4705 | 6240 if (alias_utf8) { |
8150 | 6241 g_free(b->alias); |
6242 b->alias = g_strdup(alias_utf8); | |
4705 | 6243 } |
4282 | 6244 } else { |
8150 | 6245 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6246 |
4754 | 6247 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6248 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6249 gaim_blist_add_group(g, NULL); |
6250 } | |
5146 | 6251 |
8660 | 6252 gaim_debug_info("oscar", |
9285 | 6253 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6254 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6255 } |
8341 | 6256 if (!aim_sncmp(curitem->name, account->username)) { |
6257 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6258 gaim_check_comment(od, comment); | |
6259 free(comment); | |
6260 } | |
7162 | 6261 g_free(gname_utf8); |
6262 g_free(alias_utf8); | |
2991 | 6263 } |
4230 | 6264 } break; |
6265 | |
6266 case 0x0001: { /* Group */ | |
4282 | 6267 /* Shouldn't add empty groups */ |
4230 | 6268 } break; |
6269 | |
6270 case 0x0002: { /* Permit buddy */ | |
2991 | 6271 if (curitem->name) { |
4230 | 6272 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6273 GSList *list; |
5575 | 6274 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6275 if (!list) { |
8660 | 6276 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6277 "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
|
6278 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6279 } |
6280 } | |
4230 | 6281 } break; |
6282 | |
6283 case 0x0003: { /* Deny buddy */ | |
2991 | 6284 if (curitem->name) { |
6285 GSList *list; | |
5575 | 6286 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6287 if (!list) { |
8660 | 6288 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6289 "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
|
6290 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6291 } |
6292 } | |
4230 | 6293 } break; |
6294 | |
6295 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6296 if (curitem->data) { |
6297 fu8_t permdeny; | |
5575 | 6298 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6299 gaim_debug_info("oscar", |
5575 | 6300 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6301 account->perm_deny = permdeny; | |
6302 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6303 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6304 } |
2991 | 6305 } |
6306 } | |
4230 | 6307 } break; |
6308 | |
6309 case 0x0005: { /* Presence setting */ | |
3109 | 6310 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6311 } break; |
2991 | 6312 } /* End of switch on curitem->type */ |
6313 } /* End of for loop */ | |
4230 | 6314 |
9991 | 6315 /* |
6316 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6317 * this. We probably want the SSI status setting to override the local | |
6318 * setting. | |
6319 */ | |
9982 | 6320 status = gaim_presence_get_active_status(account->presence); |
6321 if (gaim_status_is_available(status)) | |
4901 | 6322 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6323 | |
4342 | 6324 /* Activate SSI */ |
6325 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6326 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6327 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6328 "ssi: activating server-stored buddy list\n"); |
4642 | 6329 aim_ssi_enable(sess); |
4342 | 6330 |
2991 | 6331 return 1; |
2086 | 6332 } |
4230 | 6333 |
6334 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6335 GaimConnection *gc = sess->aux_data; |
4230 | 6336 va_list ap; |
6337 struct aim_ssi_tmp *retval; | |
6338 | |
6339 va_start(ap, fr); | |
6340 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6341 va_end(ap); | |
6342 | |
6343 while (retval) { | |
8660 | 6344 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6345 "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 | 6346 |
6347 if (retval->ack != 0xffff) | |
6348 switch (retval->ack) { | |
6349 case 0x0000: { /* added successfully */ | |
6350 } break; | |
6351 | |
4829 | 6352 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6353 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6354 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 | 6355 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6356 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6357 g_free(buf); |
6358 } | |
6359 | |
7023 | 6360 case 0x000e: { /* buddy requires authorization */ |
4828 | 6361 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6362 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6363 } break; |
6364 | |
6365 default: { /* La la la */ | |
5197 | 6366 gchar *buf; |
8660 | 6367 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
|
6368 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 | 6369 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6370 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6371 g_free(buf); |
4230 | 6372 } break; |
6373 } | |
6374 | |
6375 retval = retval->next; | |
6376 } | |
6377 | |
6378 return 1; | |
6379 } | |
6380 | |
8227 | 6381 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6382 GaimConnection *gc = sess->aux_data; | |
6383 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6384 GaimBuddy *b; | |
6385 GaimGroup *g; | |
6386 va_list ap; | |
6387 fu16_t type; | |
6388 const char *name; | |
6389 | |
6390 va_start(ap, fr); | |
6391 type = (fu16_t)va_arg(ap, int); | |
6392 name = va_arg(ap, char *); | |
6393 va_end(ap); | |
6394 | |
6395 if ((type != 0x0000) || (name == NULL)) | |
6396 return 1; | |
6397 | |
6398 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6399 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6400 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6401 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6402 b = gaim_find_buddy(gc->account, name); | |
6403 free(alias); | |
6404 | |
6405 if (b) { | |
6406 /* Get server stored alias */ | |
6407 if (alias_utf8) { | |
6408 g_free(b->alias); | |
6409 b->alias = g_strdup(alias_utf8); | |
6410 } | |
6411 } else { | |
6412 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6413 | |
6414 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6415 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6416 gaim_blist_add_group(g, NULL); | |
6417 } | |
6418 | |
8660 | 6419 gaim_debug_info("oscar", |
9285 | 6420 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6421 gaim_blist_add_buddy(b, NULL, g, NULL); |
6422 } | |
6423 g_free(gname_utf8); | |
6424 g_free(alias_utf8); | |
6425 | |
6426 return 1; | |
6427 } | |
6428 | |
4230 | 6429 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6430 GaimConnection *gc = sess->aux_data; |
4230 | 6431 va_list ap; |
6432 char *sn, *msg; | |
4236 | 6433 gchar *dialog_msg, *nombre; |
4230 | 6434 struct name_data *data; |
6695 | 6435 GaimBuddy *buddy; |
4230 | 6436 |
6437 va_start(ap, fr); | |
6438 sn = va_arg(ap, char *); | |
6439 msg = va_arg(ap, char *); | |
6440 va_end(ap); | |
6441 | |
8660 | 6442 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6443 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6444 |
4687 | 6445 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6446 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6447 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6448 else |
6449 nombre = g_strdup(sn); | |
6450 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6451 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 | 6452 data = g_new(struct name_data, 1); |
6453 data->gc = gc; | |
6454 data->name = g_strdup(sn); | |
6455 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6456 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6457 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6458 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6459 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6460 G_CALLBACK(oscar_free_name_data)); |
4236 | 6461 |
4230 | 6462 g_free(dialog_msg); |
4236 | 6463 g_free(nombre); |
4230 | 6464 |
6465 return 1; | |
6466 } | |
6467 | |
6468 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6469 GaimConnection *gc = sess->aux_data; |
4230 | 6470 va_list ap; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6471 char *sn; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6472 char *msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6473 GaimAccount *account = gaim_connection_get_account(gc); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6474 gchar *nombre; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6475 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6476 gchar *dialog_msg; |
4230 | 6477 struct name_data *data; |
6695 | 6478 GaimBuddy *buddy; |
4230 | 6479 |
6480 va_start(ap, fr); | |
6481 sn = va_arg(ap, char *); | |
6482 msg = va_arg(ap, char *); | |
6483 va_end(ap); | |
6484 | |
8660 | 6485 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6486 "ssi: received authorization request from %s\n", sn); |
4230 | 6487 |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6488 buddy = gaim_find_buddy(account, sn); |
9620 | 6489 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6490 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6491 else |
6492 nombre = g_strdup(sn); | |
6493 | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6494 if (msg != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6495 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
|
6496 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6497 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6498 |
10949 | 6499 dialog_msg = g_strdup_printf( |
6500 _("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
|
6501 nombre, gaim_account_get_username(account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6502 g_free(reason); |
10949 | 6503 |
4230 | 6504 data = g_new(struct name_data, 1); |
6505 data->gc = gc; | |
6506 data->name = g_strdup(sn); | |
6507 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6508 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6509 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6510 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6511 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6512 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6513 |
4230 | 6514 g_free(dialog_msg); |
4236 | 6515 g_free(nombre); |
4230 | 6516 |
6517 return 1; | |
6518 } | |
6519 | |
6520 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6521 GaimConnection *gc = sess->aux_data; |
4230 | 6522 va_list ap; |
6523 char *sn, *msg; | |
4236 | 6524 gchar *dialog_msg, *nombre; |
4230 | 6525 fu8_t reply; |
6695 | 6526 GaimBuddy *buddy; |
4230 | 6527 |
6528 va_start(ap, fr); | |
6529 sn = va_arg(ap, char *); | |
6530 reply = (fu8_t)va_arg(ap, int); | |
6531 msg = va_arg(ap, char *); | |
6532 va_end(ap); | |
6533 | |
8660 | 6534 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6535 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6536 |
4687 | 6537 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6538 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6539 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6540 else |
6541 nombre = g_strdup(sn); | |
6542 | |
4230 | 6543 if (reply) { |
6544 /* Granted */ | |
7023 | 6545 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
|
6546 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6547 } else { |
6548 /* Denied */ | |
7023 | 6549 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
|
6550 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6551 } |
6552 g_free(dialog_msg); | |
4236 | 6553 g_free(nombre); |
4230 | 6554 |
6555 return 1; | |
6556 } | |
6557 | |
6558 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6559 GaimConnection *gc = sess->aux_data; |
4230 | 6560 va_list ap; |
6561 char *sn; | |
6695 | 6562 GaimBuddy *buddy; |
4230 | 6563 |
6564 va_start(ap, fr); | |
6565 sn = va_arg(ap, char *); | |
6566 va_end(ap); | |
6567 | |
4687 | 6568 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6569 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6570 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6571 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6572 |
6573 return 1; | |
6574 } | |
2086 | 6575 |
5575 | 6576 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6577 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6578 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6579 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6580 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6581 pce->label = _("_Room:"); |
5234 | 6582 pce->identifier = "room"; |
10475 | 6583 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6584 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6585 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6586 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6587 pce->label = _("_Exchange:"); |
5234 | 6588 pce->identifier = "exchange"; |
10475 | 6589 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6590 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6591 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6592 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6593 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6594 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6595 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6596 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6597 |
9754 | 6598 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6599 { | |
6600 GHashTable *defaults; | |
6601 | |
6602 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6603 | |
6604 if (chat_name != NULL) | |
6605 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6606 | |
6607 return defaults; | |
6608 } | |
6609 | |
9917 | 6610 static char *oscar_get_chat_name(GHashTable *data) { |
6611 return g_strdup(g_hash_table_lookup(data, "room")); | |
6612 } | |
6613 | |
8308 | 6614 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6615 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6616 aim_conn_t *cur; |
5234 | 6617 char *name, *exchange; |
6618 | |
6619 name = g_hash_table_lookup(data, "room"); | |
6620 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6621 |
8660 | 6622 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6623 "Attempting to join chat room %s.\n", name); |
8308 | 6624 |
6625 if ((name == NULL) || (*name == '\0')) { | |
6626 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6627 return; | |
6628 } | |
6629 | |
4617 | 6630 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6631 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6632 "chatnav exists, creating room\n"); |
5234 | 6633 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6634 } else { |
6635 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6636 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6637 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6638 "chatnav does not exist, opening chatnav\n"); |
5234 | 6639 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6640 cr->name = g_strdup(name); |
4617 | 6641 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6642 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6643 } |
6644 } | |
6645 | |
8308 | 6646 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6647 OscarData *od = (OscarData *)gc->proto_data; | |
6648 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6649 |
6650 if (ccon == NULL) | |
2086 | 6651 return; |
10404 | 6652 |
8225 | 6653 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6654 ccon->exchange, ccon->name, 0x0); |
6655 } | |
6656 | |
10458 | 6657 static void |
6658 oscar_chat_leave(GaimConnection *gc, int id) | |
6659 { | |
6660 GaimConversation *conv; | |
6661 struct chat_connection *cc; | |
6662 | |
6663 conv = gaim_find_chat(gc, id); | |
6664 | |
6665 g_return_if_fail(conv != NULL); | |
6666 | |
6667 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6668 | |
6669 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6670 oscar_chat_kill(gc, cc); | |
2086 | 6671 } |
6672 | |
8219 | 6673 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6674 OscarData *od = (OscarData *)gc->proto_data; | |
6675 GaimConversation *conv = NULL; | |
2086 | 6676 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6677 char *buf, *buf2; |
9830 | 6678 fu16_t charset, charsubset; |
9807 | 6679 char *charsetstr = NULL; |
10111 | 6680 int len; |
8219 | 6681 |
6682 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6683 return -EINVAL; |
2086 | 6684 |
8219 | 6685 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6686 return -EINVAL; |
2086 | 6687 |
8219 | 6688 buf = gaim_strdup_withhtml(message); |
6689 len = strlen(buf); | |
6690 | |
8962 | 6691 if (strstr(buf, "<IMG ")) |
6692 gaim_conversation_write(conv, "", | |
6693 _("Your IM Image was not sent. " | |
6694 "You cannot send IM Images in AIM chats."), | |
6695 GAIM_MESSAGE_ERROR, time(NULL)); | |
6696 | |
9830 | 6697 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6698 if ((len > c->maxlen) || (len > c->maxvis)) { |
6699 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6700 return -E2BIG; |
8359 | 6701 } |
6702 | |
9831 | 6703 if (charset == AIM_CHARSET_ASCII) |
6704 charsetstr = "us-ascii"; | |
6705 else if (charset == AIM_CHARSET_UNICODE) | |
6706 charsetstr = "unicode-2-0"; | |
6707 else if (charset == AIM_CHARSET_CUSTOM) | |
6708 charsetstr = "iso-8859-1"; | |
9807 | 6709 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6710 g_free(buf2); |
8359 | 6711 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6712 return 0; |
2086 | 6713 } |
6714 | |
10042 | 6715 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6716 { | |
4766 | 6717 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6718 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6719 return "icq"; |
6720 else | |
6721 return "aim"; | |
6722 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6723 |
9975 | 6724 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6725 return "icq"; |
6726 return "aim"; | |
6727 } | |
6728 | |
9972 | 6729 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6730 { |
7334 | 6731 GaimConnection *gc = NULL; |
6732 OscarData *od = NULL; | |
10042 | 6733 GaimAccount *account = NULL; |
6734 GaimPresence *presence; | |
6735 GaimStatus *status; | |
6736 const char *status_id; | |
4687 | 6737 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6738 int i = 0; | |
7334 | 6739 aim_userinfo_t *userinfo = NULL; |
6740 | |
6741 if (b != NULL) | |
6742 account = b->account; | |
6743 if (account != NULL) | |
6744 gc = account->gc; | |
6745 if (gc != NULL) | |
6746 od = gc->proto_data; | |
7945 | 6747 if (od != NULL) |
6748 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6749 |
10042 | 6750 presence = gaim_buddy_get_presence(b); |
6751 status = gaim_presence_get_active_status(presence); | |
6752 status_id = gaim_status_get_id(status); | |
6753 | |
6754 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6755 char *gname; |
7334 | 6756 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6757 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6758 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6759 emblems[i++] = "notauthorized"; | |
6760 } else { | |
6761 emblems[i++] = "offline"; | |
6762 } | |
6763 } | |
4916 | 6764 |
10042 | 6765 if (b->name && aim_sn_is_icq(b->name)) { |
6766 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6767 emblems[i++] = "invisible"; | |
6768 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6769 emblems[i++] = "freeforchat"; |
10042 | 6770 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6771 emblems[i++] = "dnd"; |
10042 | 6772 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6773 emblems[i++] = "na"; |
10042 | 6774 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6775 emblems[i++] = "occupied"; |
10042 | 6776 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6777 emblems[i++] = "away"; |
10042 | 6778 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6779 emblems[i++] = "away"; | |
6780 } | |
6781 | |
6782 if (userinfo != NULL ) { | |
6783 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6784 emblems[i++] = "unconfirmed"; */ | |
6785 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6786 emblems[i++] = "admin"; | |
6787 if (userinfo->flags & AIM_FLAG_AOL) | |
6788 emblems[i++] = "aol"; | |
6789 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6790 emblems[i++] = "wireless"; | |
6791 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6792 emblems[i++] = "activebuddy"; | |
6793 | |
6794 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6795 emblems[i++] = "hiptop"; |
6796 | |
10042 | 6797 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6798 emblems[i++] = "secure"; |
10042 | 6799 } |
7334 | 6800 |
4687 | 6801 *se = emblems[0]; |
6802 *sw = emblems[1]; | |
6803 *nw = emblems[2]; | |
6804 *ne = emblems[3]; | |
6805 } | |
6806 | |
6695 | 6807 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6808 GaimConnection *gc = b->account->gc; |
7283 | 6809 OscarData *od = gc->proto_data; |
7045 | 6810 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6811 GString *str = g_string_new(""); |
5131 | 6812 |
6813 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6814 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6815 |
6816 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6817 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6818 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6819 g_free(charset); |
7011 | 6820 if (away_utf8 != NULL) { |
7091 | 6821 gchar *tmp1, *tmp2; |
9627 | 6822 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6823 g_free(away_utf8); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
6824 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 6825 g_free(tmp2); |
8700 | 6826 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6827 g_free(tmp1); |
8701 | 6828 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6829 g_free(tmp2); |
5836 | 6830 } |
5131 | 6831 } |
8701 | 6832 } |
6833 | |
6834 return g_string_free(str, FALSE); | |
5131 | 6835 } |
6836 | |
10042 | 6837 static char *oscar_status_text(GaimBuddy *b) |
6838 { | |
6839 GaimConnection *gc; | |
6840 OscarData *od; | |
6841 GaimStatus *status; | |
5167 | 6842 gchar *ret = NULL; |
6843 | |
10042 | 6844 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6845 od = gc->proto_data; | |
6846 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6847 | |
6848 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6849 if (aim_sn_is_icq(b->name)) |
8701 | 6850 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6851 else |
6852 ret = g_strdup(_("Away")); | |
5836 | 6853 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6854 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6855 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6856 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6857 } else { |
5167 | 6858 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6859 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6860 ret = g_strdup(_("Not Authorized")); | |
6861 else | |
6862 ret = g_strdup(_("Offline")); | |
6863 } | |
6864 | |
6865 return ret; | |
6866 } | |
6867 | |
5842 | 6868 |
5844 | 6869 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6870 GaimConnection *gc = sess->aux_data; |
7283 | 6871 OscarData *od = gc->proto_data; |
5892 | 6872 va_list ap; |
5842 | 6873 fu16_t type; |
5892 | 6874 fu8_t flags = 0, length = 0; |
11159 | 6875 guchar *md5 = NULL; |
5892 | 6876 |
7334 | 6877 |
5842 | 6878 va_start(ap, fr); |
6879 type = va_arg(ap, int); | |
5892 | 6880 |
6881 switch(type) { | |
6882 case 0x0000: | |
6883 case 0x0001: { | |
6884 flags = va_arg(ap, int); | |
6885 length = va_arg(ap, int); | |
11159 | 6886 md5 = va_arg(ap, guchar *); |
5892 | 6887 |
6888 if (flags == 0x41) { | |
6889 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6890 od->iconconnecting = TRUE; | |
6891 od->set_icon = TRUE; | |
6892 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6893 } else { | |
6039 | 6894 struct stat st; |
6895 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6896 if (iconfile == NULL) { | |
8363 | 6897 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6898 } else if (!g_stat(iconfile, &st)) { |
11159 | 6899 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6900 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 6901 if (file) { |
9532 | 6902 /* XXX - Use g_file_get_contents()? */ |
6039 | 6903 fread(buf, 1, st.st_size, file); |
6904 fclose(file); | |
8660 | 6905 gaim_debug_info("oscar", |
10042 | 6906 "Uploading icon to icon server\n"); |
6879 | 6907 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6908 } else |
8660 | 6909 gaim_debug_error("oscar", |
10042 | 6910 "Can't open buddy icon file!\n"); |
6039 | 6911 g_free(buf); |
6912 } else { | |
8660 | 6913 gaim_debug_error("oscar", |
10042 | 6914 "Can't stat buddy icon file!\n"); |
5892 | 6915 } |
6916 } | |
8363 | 6917 } else if (flags == 0x81) { |
6918 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6919 if (iconfile == NULL) | |
6920 aim_ssi_delicon(od->sess); | |
6921 else | |
6922 aim_ssi_seticon(od->sess, md5, length); | |
6923 } | |
5892 | 6924 } break; |
6925 | |
6926 case 0x0002: { /* We just set an "available" message? */ | |
6927 } break; | |
6928 } | |
6929 | |
5842 | 6930 va_end(ap); |
5844 | 6931 |
6932 return 0; | |
5842 | 6933 } |
5892 | 6934 |
5575 | 6935 static void oscar_set_permit_deny(GaimConnection *gc) { |
6936 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6937 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 6938 |
8175 | 6939 if (od->sess->ssi.received_data) { |
6940 switch (account->perm_deny) { | |
6941 case GAIM_PRIVACY_ALLOW_ALL: | |
6942 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6943 break; | |
6944 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6945 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6946 break; | |
6947 case GAIM_PRIVACY_ALLOW_USERS: | |
6948 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6949 break; | |
6950 case GAIM_PRIVACY_DENY_ALL: | |
6951 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6952 break; | |
6953 case GAIM_PRIVACY_DENY_USERS: | |
6954 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6955 break; | |
6956 default: | |
6957 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6958 break; | |
6959 } | |
6960 } | |
2086 | 6961 } |
6962 | |
5575 | 6963 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 6964 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6965 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6966 if (od->sess->ssi.received_data) |
4889 | 6967 aim_ssi_addpermit(od->sess, who); |
2086 | 6968 } |
6969 | |
5575 | 6970 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 6971 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6972 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6973 if (od->sess->ssi.received_data) |
4889 | 6974 aim_ssi_adddeny(od->sess, who); |
2086 | 6975 } |
6976 | |
5575 | 6977 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 6978 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6979 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6980 if (od->sess->ssi.received_data) |
4889 | 6981 aim_ssi_delpermit(od->sess, who); |
2086 | 6982 } |
6983 | |
5575 | 6984 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 6985 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6986 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6987 if (od->sess->ssi.received_data) |
4889 | 6988 aim_ssi_deldeny(od->sess, who); |
2086 | 6989 } |
6990 | |
9975 | 6991 static GList * |
6992 oscar_status_types(GaimAccount *account) | |
2086 | 6993 { |
9975 | 6994 GList *status_types = NULL; |
6995 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6996 |
9973 | 6997 g_return_val_if_fail(account != NULL, NULL); |
6998 | |
10042 | 6999 /* Oscar-common status types */ |
9991 | 7000 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
7001 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 7002 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 7003 status_types = g_list_append(status_types, type); |
7004 | |
9991 | 7005 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
7006 OSCAR_STATUS_ID_ONLINE, | |
10400 | 7007 _("Online"), FALSE, TRUE, FALSE); |
9976 | 7008 status_types = g_list_append(status_types, type); |
7009 | |
10198 | 7010 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
7011 OSCAR_STATUS_ID_AVAILABLE, | |
7012 _("Available"), TRUE, TRUE, FALSE, | |
7013 "message", _("Message"), | |
7014 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 7015 status_types = g_list_append(status_types, type); |
7016 | |
10195 | 7017 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
7018 OSCAR_STATUS_ID_AWAY, | |
7019 _("Away"), TRUE, TRUE, FALSE, | |
7020 "message", _("Message"), | |
7021 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 7022 status_types = g_list_append(status_types, type); |
7023 | |
7024 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
7025 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 7026 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 7027 status_types = g_list_append(status_types, type); |
7028 | |
7029 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
7030 return status_types; | |
7031 | |
7032 /* ICQ-specific status types */ | |
7033 | |
9991 | 7034 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
7035 OSCAR_STATUS_ID_FREE4CHAT, | |
7036 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 7037 status_types = g_list_append(status_types, type); |
7038 | |
9991 | 7039 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
7040 OSCAR_STATUS_ID_OCCUPIED, | |
7041 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 7042 status_types = g_list_append(status_types, type); |
7043 | |
9991 | 7044 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7045 OSCAR_STATUS_ID_DND, | |
7046 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 7047 status_types = g_list_append(status_types, type); |
7048 | |
9991 | 7049 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7050 OSCAR_STATUS_ID_NA, | |
7051 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 7052 status_types = g_list_append(status_types, type); |
9975 | 7053 |
7054 return status_types; | |
4333 | 7055 } |
7056 | |
7172 | 7057 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 7058 GaimConnection *gc = data->gc; |
7059 OscarData *od = gc->proto_data; | |
7172 | 7060 GaimBuddy *b; |
7061 GaimGroup *g; | |
7062 | |
7063 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
7064 oscar_free_name_data(data); | |
7065 return; | |
7066 } | |
7067 | |
7068 if (!(g = gaim_find_buddys_group(b))) { | |
7069 oscar_free_name_data(data); | |
7070 return; | |
7071 } | |
7072 | |
7073 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 7074 |
7075 if (!aim_sncmp(data->name, gc->account->username)) | |
7076 gaim_check_comment(od, text); | |
7077 | |
7172 | 7078 oscar_free_name_data(data); |
7079 } | |
7080 | |
9030 | 7081 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
7082 | |
7083 GaimBuddy *buddy; | |
7084 GaimConnection *gc; | |
7085 OscarData *od; | |
7086 struct name_data *data; | |
7172 | 7087 GaimGroup *g; |
7088 char *comment; | |
7089 gchar *comment_utf8; | |
9631 | 7090 gchar *title; |
7172 | 7091 |
9030 | 7092 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
7093 | |
7094 buddy = (GaimBuddy *) node; | |
7095 gc = gaim_account_get_connection(buddy->account); | |
7096 od = gc->proto_data; | |
7097 | |
7098 data = g_new(struct name_data, 1); | |
7099 | |
7100 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 7101 return; |
9030 | 7102 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 7103 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
7104 | |
7105 data->gc = gc; | |
9030 | 7106 data->name = g_strdup(buddy->name); |
7172 | 7107 data->nick = NULL; |
7108 | |
9631 | 7109 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7110 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7111 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7112 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7113 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7114 data); | |
9631 | 7115 g_free(title); |
7172 | 7116 |
7117 free(comment); | |
7118 g_free(comment_utf8); | |
7119 } | |
7120 | |
9030 | 7121 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7122 | |
7123 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7124 OscarData *od = gc->proto_data; |
9030 | 7125 |
4333 | 7126 GList *m = NULL; |
9030 | 7127 GaimBlistNodeAction *act; |
7128 | |
7129 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7130 oscar_buddycb_edit_comment, NULL, NULL); |
9030 | 7131 m = g_list_append(m, act); |
7172 | 7132 |
4333 | 7133 if (od->icq) { |
4624 | 7134 #if 0 |
9030 | 7135 act = gaim_blist_node_action_new(_("Get Status Msg"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7136 oscar_get_icqstatusmsg, NULL, NULL); |
9030 | 7137 m = g_list_append(m, act); |
4624 | 7138 #endif |
4333 | 7139 } else { |
7011 | 7140 aim_userinfo_t *userinfo; |
9030 | 7141 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7142 | |
7143 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7144 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7145 | |
7011 | 7146 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7147 act = gaim_blist_node_action_new(_("Direct IM"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7148 oscar_ask_direct_im, NULL, NULL); |
9030 | 7149 m = g_list_append(m, act); |
5917 | 7150 } |
9466 | 7151 #if 0 |
7011 | 7152 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7153 act = gaim_blist_node_action_new(_("Get File"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7154 oscar_ask_getfile, NULL, NULL); |
9030 | 7155 m = g_list_append(m, act); |
5917 | 7156 } |
4826 | 7157 #endif |
4333 | 7158 } |
5131 | 7159 } |
5197 | 7160 |
5131 | 7161 if (od->sess->ssi.received_data) { |
9030 | 7162 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7163 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7164 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7165 gaim_auth_sendrequest_menu, NULL, NULL); |
9030 | 7166 m = g_list_append(m, act); |
4333 | 7167 } |
4916 | 7168 } |
10157 | 7169 |
4333 | 7170 return m; |
7171 } | |
7172 | |
9030 | 7173 |
7174 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7175 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7176 return oscar_buddy_menu((GaimBuddy *) node); | |
7177 } else { | |
7178 return NULL; | |
7179 } | |
7180 } | |
7181 | |
10570 | 7182 static void |
7183 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
7184 { | |
7185 OscarData *od = gc->proto_data; | |
7186 GaimAccount *account = gaim_connection_get_account(gc); | |
7187 GaimRequestField *f; | |
7188 gboolean auth, hide_ip, web_aware; | |
7189 | |
7190 f = gaim_request_fields_get_field(fields, "authorization"); | |
7191 auth = gaim_request_field_bool_get_value(f); | |
7192 | |
7193 f = gaim_request_fields_get_field(fields, "hide_ip"); | |
7194 hide_ip = gaim_request_field_bool_get_value(f); | |
7195 | |
7196 f = gaim_request_fields_get_field(fields, "web_aware"); | |
7197 web_aware = gaim_request_field_bool_get_value(f); | |
7198 | |
7199 gaim_account_set_bool(account, "authorization", auth); | |
7200 gaim_account_set_bool(account, "hide_ip", hide_ip); | |
7201 gaim_account_set_bool(account, "web_aware", web_aware); | |
7202 | |
7203 aim_icq_setsecurity(od->sess, auth, web_aware, hide_ip); | |
7204 } | |
7205 | |
7206 static void | |
7207 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
7208 { | |
7209 GaimConnection *gc = (GaimConnection *) action->context; | |
7210 GaimAccount *account = gaim_connection_get_account(gc); | |
7211 GaimRequestFields *fields; | |
7212 GaimRequestFieldGroup *g; | |
7213 GaimRequestField *f; | |
7214 gboolean auth, hide_ip, web_aware; | |
7215 | |
7216 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7217 hide_ip = gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7218 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7219 | |
7220 fields = gaim_request_fields_new(); | |
7221 | |
7222 g = gaim_request_field_group_new(NULL); | |
7223 | |
7224 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
7225 gaim_request_field_group_add_field(g, f); | |
7226 | |
7227 f = gaim_request_field_bool_new("hide_ip", _("Hide IP address"), hide_ip); | |
7228 gaim_request_field_group_add_field(g, f); | |
7229 | |
7230 f = gaim_request_field_bool_new("web_aware", _("Web aware"), web_aware); | |
7231 gaim_request_field_group_add_field(g, f); | |
7232 | |
7233 gaim_request_fields_add_group(fields, g); | |
7234 | |
7235 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
7236 NULL, fields, | |
7237 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
7238 _("Cancel"), NULL, gc); | |
7239 } | |
9030 | 7240 |
5575 | 7241 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7242 OscarData *od = gc->proto_data; |
5575 | 7243 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7244 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7245 od->setnick = TRUE; | |
7246 od->newsn = g_strdup(nick); | |
7247 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7248 } else { | |
7249 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7250 } | |
7251 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7252 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7253 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7254 } |
7255 } | |
7256 | |
9015 | 7257 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7258 { |
9015 | 7259 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7260 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7261 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7262 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7263 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7264 gc); |
4333 | 7265 } |
7266 | |
9015 | 7267 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7268 { |
9015 | 7269 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7270 OscarData *od = gc->proto_data; |
4333 | 7271 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7272 | |
7273 if (conn) { | |
7274 aim_admin_reqconfirm(od->sess, conn); | |
7275 } else { | |
7276 od->conf = TRUE; | |
7277 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7278 } | |
7279 } | |
7280 | |
9015 | 7281 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7282 { |
9015 | 7283 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7284 OscarData *od = gc->proto_data; |
4333 | 7285 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7286 | |
7287 if (conn) { | |
7288 aim_admin_getinfo(od->sess, conn, 0x11); | |
7289 } else { | |
7290 od->reqemail = TRUE; | |
7291 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7292 } | |
7293 } | |
7294 | |
5575 | 7295 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7296 { |
7283 | 7297 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7298 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
|
7299 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7300 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7301 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7302 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7303 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7304 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7305 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7306 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7307 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7308 |
9015 | 7309 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7310 { |
9015 | 7311 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7312 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7313 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7314 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7315 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7316 gc); |
4333 | 7317 } |
7318 | |
9015 | 7319 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7320 { |
9015 | 7321 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7322 OscarData *od = gc->proto_data; |
4333 | 7323 gchar *nombre, *text, *tmp; |
6695 | 7324 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7325 int num=0; |
7326 | |
6873 | 7327 text = g_strdup(""); |
4333 | 7328 |
4785 | 7329 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7330 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7331 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7332 continue; | |
6695 | 7333 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7334 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7335 continue; |
6695 | 7336 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7337 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7338 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7339 continue; | |
7340 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7341 if (gaim_buddy_get_alias_only(buddy)) |
7342 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7343 else |
7344 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7345 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7346 g_free(text); |
7347 text = tmp; | |
7348 g_free(nombre); | |
7349 num++; | |
7350 } | |
4333 | 7351 } |
2979 | 7352 } |
4333 | 7353 } |
7354 | |
7355 if (!num) { | |
7356 g_free(text); | |
6873 | 7357 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7358 } | |
7359 | |
7360 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7361 "the following buddies"), _("You can re-request " | |
7362 "authorization from these buddies by " | |
7363 "right-clicking on them and selecting " | |
7364 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7365 g_free(text); |
2979 | 7366 } |
7367 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7368 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7369 { |
8950 | 7370 OscarData *od = (OscarData *)gc->proto_data; |
7371 | |
7372 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7373 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7374 |
9015 | 7375 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7376 { |
9015 | 7377 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7378 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7379 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7380 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7381 "searching for."), |
8697 | 7382 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7383 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7384 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7385 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7386 |
9015 | 7387 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7388 { |
9015 | 7389 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7390 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7391 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7392 |
9015 | 7393 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7394 { |
9015 | 7395 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7396 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7397 } |
7398 | |
9015 | 7399 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7400 { |
9015 | 7401 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7402 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7403 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7404 |
9015 | 7405 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7406 { |
9015 | 7407 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7408 OscarData *od = gc->proto_data; |
5575 | 7409 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
|
7410 gaim_notify_uri(gc, substituted); |
5517 | 7411 g_free(substituted); |
4333 | 7412 } |
7413 | |
9015 | 7414 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7415 { |
9015 | 7416 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7417 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7418 } |
7419 | |
5842 | 7420 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7421 { | |
7283 | 7422 OscarData *od = gc->proto_data; |
5844 | 7423 aim_session_t *sess = od->sess; |
5842 | 7424 FILE *file; |
7425 struct stat st; | |
5844 | 7426 |
6039 | 7427 if (iconfile == NULL) { |
8363 | 7428 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7429 } else if (!g_stat(iconfile, &st)) { |
11159 | 7430 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7431 file = g_fopen(iconfile, "rb"); |
5842 | 7432 if (file) { |
6052 | 7433 md5_state_t *state; |
11159 | 7434 guchar md5[16]; |
9532 | 7435 /* XXX - Use g_file_get_contents()? */ |
5842 | 7436 int len = fread(buf, 1, st.st_size, file); |
6039 | 7437 fclose(file); |
6052 | 7438 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7439 md5_init(state); |
7440 md5_append(state, buf, len); | |
7441 md5_finish(state, md5); | |
7442 g_free(state); | |
7443 aim_ssi_seticon(sess, md5, 16); | |
7444 } else | |
8660 | 7445 gaim_debug_error("oscar", |
5842 | 7446 "Can't open buddy icon file!\n"); |
7447 g_free(buf); | |
7448 } else | |
8660 | 7449 gaim_debug_error("oscar", |
5842 | 7450 "Can't stat buddy icon file!\n"); |
7451 } | |
7452 | |
7453 | |
9015 | 7454 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7455 { |
9015 | 7456 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7457 OscarData *od = gc->proto_data; |
4333 | 7458 GList *m = NULL; |
9015 | 7459 GaimPluginAction *act; |
7460 | |
7461 act = gaim_plugin_action_new(_("Set User Info..."), | |
7462 oscar_show_set_info); | |
7463 m = g_list_append(m, act); | |
4333 | 7464 |
10570 | 7465 if (od->icq) |
7466 { | |
9015 | 7467 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7468 oscar_show_set_info_icqurl); | |
7469 m = g_list_append(m, act); | |
8576 | 7470 } |
7471 | |
9015 | 7472 act = gaim_plugin_action_new(_("Change Password..."), |
7473 oscar_change_pass); | |
7474 m = g_list_append(m, act); | |
4617 | 7475 |
10570 | 7476 if (od->sess->authinfo->chpassurl != NULL) |
7477 { | |
9015 | 7478 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7479 oscar_show_chpassurl); | |
7480 m = g_list_append(m, act); | |
7481 | |
7482 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7483 oscar_show_imforwardingurl); | |
7484 m = g_list_append(m, act); | |
7026 | 7485 } |
7486 | |
10570 | 7487 m = g_list_append(m, NULL); |
7488 | |
7489 if (od->icq) | |
7490 { | |
7491 /* ICQ actions */ | |
7492 act = gaim_plugin_action_new(_("Show privacy options..."), | |
7493 oscar_show_icq_privacy_opts); | |
7494 m = g_list_append(m, act); | |
7495 } | |
7496 else | |
7497 { | |
4617 | 7498 /* AIM actions */ |
9015 | 7499 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7500 oscar_show_format_screenname); | |
7501 m = g_list_append(m, act); | |
7502 | |
7503 act = gaim_plugin_action_new(_("Confirm Account"), | |
7504 oscar_confirm_account); | |
7505 m = g_list_append(m, act); | |
7506 | |
7507 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7508 oscar_show_email); | |
7509 m = g_list_append(m, act); | |
7510 | |
7511 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7512 oscar_show_change_email); | |
7513 m = g_list_append(m, act); | |
2086 | 7514 } |
4333 | 7515 |
7516 m = g_list_append(m, NULL); | |
7517 | |
9015 | 7518 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7519 oscar_show_awaitingauth); | |
7520 m = g_list_append(m, act); | |
4333 | 7521 |
2086 | 7522 m = g_list_append(m, NULL); |
4333 | 7523 |
9015 | 7524 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7525 oscar_show_find_email); | |
7526 m = g_list_append(m, act); | |
4333 | 7527 |
8591 | 7528 #if 0 |
9015 | 7529 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7530 show_find_info); | |
7531 m = g_list_append(m, act); | |
8591 | 7532 #endif |
2086 | 7533 |
7534 return m; | |
7535 } | |
7536 | |
5575 | 7537 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7538 { |
7283 | 7539 OscarData *od = gc->proto_data; |
4617 | 7540 |
7541 if (od->icq) { | |
7542 aim_icq_changepasswd(od->sess, new); | |
2086 | 7543 } else { |
4617 | 7544 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7545 if (conn) { | |
7546 aim_admin_changepasswd(od->sess, conn, new, old); | |
7547 } else { | |
7548 od->chpass = TRUE; | |
7549 od->oldp = g_strdup(old); | |
7550 od->newp = g_strdup(new); | |
7551 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7552 } | |
2086 | 7553 } |
7554 } | |
7555 | |
6059 | 7556 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7557 { |
7283 | 7558 OscarData *od = gc->proto_data; |
8971 | 7559 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
|
7560 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7561 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7562 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7563 |
8971 | 7564 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7565 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7566 |
9935 | 7567 static void |
7568 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7569 { | |
7570 GaimConnection *gc = data; | |
7571 OscarData *od = gc->proto_data; | |
7572 aim_session_t *sess = od->sess; | |
7573 fu32_t presence; | |
7574 | |
7575 presence = aim_ssi_getpresence(sess->ssi.local); | |
7576 | |
7577 if (value) { | |
9992 | 7578 /* Based on the packet capture I thought it was the first one */ |
7579 /* Stu thinks it's the second one. */ | |
7580 /* presence |= 0x00400000; */ | |
9971 | 7581 presence &= ~0x00020000; |
9935 | 7582 aim_ssi_setpresence(sess, presence); |
7583 } else { | |
9992 | 7584 /* presence &= ~0x00400000; */ |
9971 | 7585 presence |= 0x00020000; |
9935 | 7586 aim_ssi_setpresence(sess, presence); |
7587 } | |
7588 } | |
7589 | |
10653 | 7590 #if USE_PRPL_PREFERENCES |
9935 | 7591 static GaimPluginPrefFrame * |
9936 | 7592 get_plugin_pref_frame(GaimPlugin *plugin) |
7593 { | |
9935 | 7594 GaimPluginPrefFrame *frame; |
7595 GaimPluginPref *ppref; | |
7596 | |
7597 frame = gaim_plugin_pref_frame_new(); | |
7598 | |
7599 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7600 gaim_plugin_pref_frame_add(frame, ppref); | |
7601 | |
7602 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7603 gaim_plugin_pref_frame_add(frame, ppref); | |
7604 | |
7605 return frame; | |
7606 } | |
10653 | 7607 #endif |
9935 | 7608 |
11153 | 7609 static const char * |
7610 oscar_normalize(const GaimAccount *account, const char *str) | |
7611 { | |
7612 static char buf[BUF_LEN]; | |
7613 char *tmp1, *tmp2; | |
7614 int i, j; | |
7615 | |
7616 g_return_val_if_fail(str != NULL, NULL); | |
7617 | |
7618 strncpy(buf, str, BUF_LEN); | |
7619 for (i=0, j=0; buf[j]; i++, j++) | |
7620 { | |
7621 while (buf[j] == ' ') | |
7622 j++; | |
7623 buf[i] = buf[j]; | |
7624 } | |
7625 buf[i] = '\0'; | |
7626 | |
7627 tmp1 = g_utf8_strdown(buf, -1); | |
7628 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
7629 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
7630 g_free(tmp2); | |
7631 g_free(tmp1); | |
7632 | |
7633 return buf; | |
7634 } | |
7635 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7636 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7637 { |
9308 | 7638 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7639 NULL, /* user_splits */ |
7640 NULL, /* protocol_options */ | |
10674 | 7641 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
7642 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 7643 oscar_list_icon, /* list_icon */ |
7644 oscar_list_emblems, /* list_emblems */ | |
7645 oscar_status_text, /* status_text */ | |
7646 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7647 oscar_status_types, /* status_types */ |
9475 | 7648 oscar_blist_node_menu, /* blist_node_menu */ |
7649 oscar_chat_info, /* chat_info */ | |
9754 | 7650 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7651 oscar_login, /* login */ |
7652 oscar_close, /* close */ | |
7653 oscar_send_im, /* send_im */ | |
7654 oscar_set_info, /* set_info */ | |
7655 oscar_send_typing, /* send_typing */ | |
7656 oscar_get_info, /* get_info */ | |
9973 | 7657 oscar_set_status, /* set_status */ |
9475 | 7658 oscar_set_idle, /* set_idle */ |
7659 oscar_change_passwd, /* change_passwd */ | |
7660 oscar_add_buddy, /* add_buddy */ | |
10866 | 7661 NULL, /* add_buddies */ |
9475 | 7662 oscar_remove_buddy, /* remove_buddy */ |
10866 | 7663 NULL, /* remove_buddies */ |
9475 | 7664 oscar_add_permit, /* add_permit */ |
7665 oscar_add_deny, /* add_deny */ | |
7666 oscar_rem_permit, /* rem_permit */ | |
7667 oscar_rem_deny, /* rem_deny */ | |
7668 oscar_set_permit_deny, /* set_permit_deny */ | |
7669 oscar_warn, /* warn */ | |
7670 oscar_join_chat, /* join_chat */ | |
7671 NULL, /* reject_chat */ | |
9973 | 7672 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7673 oscar_chat_invite, /* chat_invite */ |
7674 oscar_chat_leave, /* chat_leave */ | |
7675 NULL, /* chat_whisper */ | |
7676 oscar_send_chat, /* chat_send */ | |
7677 oscar_keepalive, /* keepalive */ | |
7678 NULL, /* register_user */ | |
7679 NULL, /* get_cb_info */ | |
7680 NULL, /* get_cb_away */ | |
7681 oscar_alias_buddy, /* alias_buddy */ | |
7682 oscar_move_buddy, /* group_buddy */ | |
7683 oscar_rename_group, /* rename_group */ | |
7684 NULL, /* buddy_free */ | |
7685 oscar_convo_closed, /* convo_closed */ | |
11153 | 7686 oscar_normalize, /* normalize */ |
9475 | 7687 oscar_set_icon, /* set_buddy_icon */ |
7688 NULL, /* remove_group */ | |
7689 NULL, /* get_cb_real_name */ | |
7690 NULL, /* set_chat_topic */ | |
7691 NULL, /* find_blist_chat */ | |
7692 NULL, /* roomlist_get_list */ | |
7693 NULL, /* roomlist_cancel */ | |
7694 NULL, /* roomlist_expand_category */ | |
7695 oscar_can_receive_file, /* can_receive_file */ | |
7696 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7697 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7698 |
10653 | 7699 #if USE_PRPL_PREFERENCES |
9935 | 7700 static GaimPluginUiInfo prefs_info = { |
7701 get_plugin_pref_frame | |
7702 }; | |
10653 | 7703 #endif |
9935 | 7704 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7705 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7706 { |
9943 | 7707 GAIM_PLUGIN_MAGIC, |
7708 GAIM_MAJOR_VERSION, | |
7709 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7710 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7711 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7712 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7713 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7714 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7715 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7716 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7717 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7718 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7719 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7720 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7721 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7722 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7723 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7724 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7725 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7726 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7727 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7728 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7729 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7730 NULL, /**< ui_info */ |
8993 | 7731 &prpl_info, /**< extra_info */ |
10653 | 7732 #if USE_PRPL_PREFERENCES |
10487 | 7733 NULL, /**< prefs_info */ |
10653 | 7734 #else |
7735 NULL, /**< prefs_info */ | |
7736 #endif | |
9015 | 7737 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7738 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7739 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7740 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7741 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7742 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7743 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7744 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7745 gaim_debug_register_category("oscar"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7746 |
9830 | 7747 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7748 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7749 | |
7750 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7751 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7752 | |
7753 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7754 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
11084 | 7755 |
9935 | 7756 gaim_prefs_add_none("/plugins/prpl/oscar"); |
7757 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7758 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7759 } |
7760 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7761 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |