Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 11049:c716cc44bfaa
[gaim-migrate @ 12983]
Enabled sending files to ICQ users
committer: Tailor Script <tailor@pidgin.im>
author | Jonathan Clark <ardentlygnarly> |
---|---|
date | Sat, 02 Jul 2005 16:44:01 +0000 |
parents | 50224ac8184d |
children | 3fc99df46dae |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
6 * Some code copyright (C) 2001-2003, Sean Egan | |
8151 | 7 * Some code copyright (C) 2001-2004, Mark Doliner <thekingant@users.sourceforge.net> |
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 |
10329 | 69 #define FAIM_DEBUG_LEVEL 0 |
70 | |
7376 | 71 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
72 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 73 |
4665 | 74 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
75 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 76 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 77 |
7283 | 78 typedef struct _OscarData OscarData; |
79 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
80 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
81 aim_conn_t *conn; |
2086 | 82 |
83 guint cnpa; | |
84 guint paspa; | |
3694 | 85 guint emlpa; |
4804 | 86 guint icopa; |
2086 | 87 |
4823 | 88 gboolean iconconnecting; |
5842 | 89 gboolean set_icon; |
4823 | 90 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
91 GSList *create_rooms; |
2086 | 92 |
93 gboolean conf; | |
94 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
95 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
96 char *email; |
2979 | 97 gboolean setnick; |
98 char *newsn; | |
2086 | 99 gboolean chpass; |
100 char *oldp; | |
101 char *newp; | |
9971 | 102 |
2086 | 103 GSList *oscar_chats; |
104 GSList *direct_ims; | |
3630 | 105 GSList *file_transfers; |
4738 | 106 GHashTable *buddyinfo; |
4804 | 107 GSList *requesticon; |
2086 | 108 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
109 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
110 gboolean icq; |
4804 | 111 guint icontimer; |
5968 | 112 guint getblisttimer; |
8341 | 113 guint getinfotimer; |
10567 | 114 gint timeoffset; |
2993 | 115 |
116 struct { | |
4230 | 117 guint maxwatchers; /* max users who can watch you */ |
2993 | 118 guint maxbuddies; /* max users you can watch */ |
4230 | 119 guint maxgroups; /* max groups in server list */ |
2993 | 120 guint maxpermits; /* max users on permit list */ |
121 guint maxdenies; /* max users on deny list */ | |
122 guint maxsiglen; /* max size (bytes) of profile */ | |
123 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
124 } rights; | |
2086 | 125 }; |
126 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
127 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
128 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
129 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
130 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 |
2086 | 132 struct chat_connection { |
133 char *name; | |
134 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
135 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
136 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
137 aim_conn_t *conn; |
2086 | 138 int inpa; |
139 int id; | |
5575 | 140 GaimConnection *gc; /* i hate this. */ |
8733 | 141 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
142 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
143 int maxvis; |
2086 | 144 }; |
145 | |
8971 | 146 struct oscar_direct_im { |
5575 | 147 GaimConnection *gc; |
2086 | 148 char name[80]; |
149 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
150 aim_conn_t *conn; |
3008 | 151 gboolean connected; |
8978 | 152 gboolean gpc_pend; |
153 gboolean killme; | |
8984 | 154 gboolean donttryagain; |
2086 | 155 }; |
156 | |
157 struct ask_direct { | |
5575 | 158 GaimConnection *gc; |
2086 | 159 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
160 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
161 fu8_t cookie[8]; |
8984 | 162 gboolean donttryagain; |
2086 | 163 }; |
164 | |
7011 | 165 /* |
166 * Various PRPL-specific buddy info that we want to keep track of | |
167 * Some other info is maintained by locate.c, and I'd like to move | |
168 * the rest of this to libfaim, mostly im.c | |
169 */ | |
4738 | 170 struct buddyinfo { |
171 gboolean typingnot; | |
6292 | 172 gchar *availmsg; |
6857 | 173 fu32_t ipaddr; |
5836 | 174 |
175 unsigned long ico_me_len; | |
176 unsigned long ico_me_csum; | |
177 time_t ico_me_time; | |
178 gboolean ico_informed; | |
4738 | 179 |
180 unsigned long ico_len; | |
181 unsigned long ico_csum; | |
182 time_t ico_time; | |
183 gboolean ico_need; | |
7406 | 184 gboolean ico_sent; |
2086 | 185 }; |
186 | |
4230 | 187 struct name_data { |
5575 | 188 GaimConnection *gc; |
4230 | 189 gchar *name; |
3453 | 190 gchar *nick; |
3141 | 191 }; |
192 | |
5129 | 193 static char *msgerrreason[] = { |
194 N_("Invalid error"), | |
195 N_("Invalid SNAC"), | |
196 N_("Rate to host"), | |
197 N_("Rate to client"), | |
198 N_("Not logged in"), | |
199 N_("Service unavailable"), | |
200 N_("Service not defined"), | |
201 N_("Obsolete SNAC"), | |
202 N_("Not supported by host"), | |
203 N_("Not supported by client"), | |
204 N_("Refused by client"), | |
205 N_("Reply too big"), | |
206 N_("Responses lost"), | |
207 N_("Request denied"), | |
208 N_("Busted SNAC payload"), | |
209 N_("Insufficient rights"), | |
210 N_("In local permit/deny"), | |
211 N_("Too evil (sender)"), | |
212 N_("Too evil (receiver)"), | |
213 N_("User temporarily unavailable"), | |
214 N_("No match"), | |
215 N_("List overflow"), | |
216 N_("Request ambiguous"), | |
217 N_("Queue full"), | |
218 N_("Not while on AOL") | |
219 }; | |
220 static int msgerrreasonlen = 25; | |
221 | |
222 /* All the libfaim->gaim callback functions */ | |
223 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
224 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 225 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 226 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
227 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 234 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 235 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 236 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
237 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
|
238 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
|
239 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
|
240 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
|
241 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 242 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
243 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
244 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 245 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 246 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
247 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
253 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
254 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
255 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
256 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 277 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 278 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
279 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
280 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
281 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
282 | |
283 /* for DirectIM/image transfer */ | |
284 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
286 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 287 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 288 |
289 /* for file transfer */ | |
290 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
291 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
292 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
293 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
294 | |
295 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 296 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 297 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 298 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 299 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
300 | |
5836 | 301 static void oscar_free_name_data(struct name_data *data) { |
4230 | 302 g_free(data->name); |
303 g_free(data->nick); | |
304 g_free(data); | |
305 } | |
306 | |
5836 | 307 static void oscar_free_buddyinfo(void *data) { |
308 struct buddyinfo *bi = data; | |
6292 | 309 g_free(bi->availmsg); |
5836 | 310 g_free(bi); |
311 } | |
312 | |
9807 | 313 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 314 { |
315 int i = 0; | |
9826 | 316 int charset = AIM_CHARSET_ASCII; |
5129 | 317 |
318 /* Determine how we can send this message. Per the warnings elsewhere | |
319 * in this file, these little checks determine the simplest encoding | |
320 * we can use for a given message send using it. */ | |
321 while (utf8[i]) { | |
322 if ((unsigned char)utf8[i] > 0x7f) { | |
323 /* not ASCII! */ | |
9826 | 324 charset = AIM_CHARSET_CUSTOM; |
5129 | 325 break; |
326 } | |
327 i++; | |
328 } | |
329 while (utf8[i]) { | |
330 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
331 * followed by 0xc0-0xc3 in the second */ | |
332 if ((unsigned char)utf8[i] < 0x80) { | |
333 i++; | |
334 continue; | |
335 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
336 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
337 i += 2; | |
338 continue; | |
339 } | |
9826 | 340 charset = AIM_CHARSET_UNICODE; |
5129 | 341 break; |
342 } | |
343 | |
9807 | 344 return charset; |
5129 | 345 } |
346 | |
8225 | 347 /* |
348 * Take a string of the form charset="bleh" where bleh is | |
349 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
350 * return a newly allocated string containing bleh. | |
351 */ | |
352 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 353 { |
8225 | 354 gchar *ret = NULL; |
355 char *begin, *end; | |
356 | |
9933 | 357 g_return_val_if_fail(encoding != NULL, NULL); |
358 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
359 /* Make sure encoding begins with charset= */ |
10540 | 360 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
361 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
362 { | |
8225 | 363 return NULL; |
10540 | 364 } |
8225 | 365 |
366 begin = strchr(encoding, '"'); | |
367 end = strrchr(encoding, '"'); | |
368 | |
369 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
370 return NULL; | |
371 | |
372 ret = g_strndup(begin+1, (end-1) - begin); | |
373 | |
374 return ret; | |
375 } | |
376 | |
9830 | 377 static gchar * |
378 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 379 { |
380 gchar *utf8 = NULL; | |
9595 | 381 |
382 if ((encoding == NULL) || encoding[0] == '\0') { | |
383 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 384 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 385 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 386 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 387 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 388 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 389 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 390 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 391 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 392 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 393 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
394 } | |
395 | |
396 /* | |
397 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
398 * we have been unable to convert the text to utf-8 from the encoding | |
399 * that was specified. So we check if the text is valid utf-8 then | |
400 * just copy it. | |
401 */ | |
402 if (utf8 == NULL) { | |
9638 | 403 if (textlen != 0 && *text != '\0' |
404 && !g_utf8_validate(text, textlen, NULL)) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
405 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 406 else |
9481 | 407 utf8 = g_strndup(text, textlen); |
5129 | 408 } |
409 | |
410 return utf8; | |
411 } | |
412 | |
9830 | 413 static gchar * |
9908 | 414 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 415 { |
416 gchar *ret = NULL; | |
417 GError *err = NULL; | |
418 | |
9908 | 419 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
420 return NULL; | |
421 | |
422 if (strcasecmp("UTF-8", charsetstr)) { | |
423 if (fallback) | |
424 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
425 else | |
426 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
427 if (err != NULL) { | |
428 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
429 charsetstr, err->message); | |
430 g_error_free(err); | |
431 } | |
432 } else { | |
433 if (g_utf8_validate(data, datalen, NULL)) | |
434 ret = g_strndup(data, datalen); | |
435 else | |
436 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
437 } | |
438 | |
439 return ret; | |
440 } | |
441 | |
442 /* | |
443 * We try decoding using two different character sets. The charset | |
444 * specified in the IM determines the order in which we attempt to | |
445 * decode. We do this because there are lots of broken ICQ clients | |
446 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
447 * able to deal with that crap, then people complain like banshees. | |
448 * charsetstr1 is always set to what the correct encoding should be. | |
449 */ | |
450 static gchar * | |
451 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
452 { | |
453 gchar *ret = NULL; | |
454 const gchar *charsetstr1, *charsetstr2; | |
455 | |
456 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 457 |
458 if ((datalen == 0) || (data == NULL)) | |
459 return NULL; | |
460 | |
9908 | 461 if (charset == AIM_CHARSET_UNICODE) { |
462 charsetstr1 = "UCS-2BE"; | |
463 charsetstr2 = "UTF-8"; | |
464 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 465 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 466 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 467 else |
9908 | 468 charsetstr1 = "ISO-8859-1"; |
469 charsetstr2 = "UTF-8"; | |
470 } else if (charset == AIM_CHARSET_ASCII) { | |
471 /* Should just be "ASCII" */ | |
9914 | 472 charsetstr1 = "ASCII"; |
9908 | 473 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
474 } else if (charset == 0x000d) { | |
9830 | 475 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 476 charsetstr1 = "ISO-8859-1"; |
477 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
478 } else { | |
9830 | 479 /* Unknown, hope for valid UTF-8... */ |
9908 | 480 charsetstr1 = "UTF-8"; |
481 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
482 } | |
483 | |
484 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
485 if (ret == NULL) | |
486 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
487 if (ret == NULL) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
488 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9830 | 489 |
490 return ret; | |
491 } | |
492 | |
493 static void | |
494 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 495 gchar **msg, int *msglen_int, |
9830 | 496 fu16_t *charset, fu16_t *charsubset) |
497 { | |
498 OscarData *od = gc->proto_data; | |
499 GaimAccount *account = gaim_connection_get_account(gc); | |
500 GError *err = NULL; | |
501 aim_userinfo_t *userinfo = NULL; | |
502 const gchar *charsetstr; | |
10039 | 503 gsize msglen; |
9830 | 504 |
505 /* Attempt to send as ASCII */ | |
10098 | 506 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 507 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 508 *charset = AIM_CHARSET_ASCII; |
9830 | 509 *charsubset = 0x0000; |
10039 | 510 *msglen_int = msglen; |
9830 | 511 return; |
512 } | |
513 | |
514 /* | |
10565 | 515 * If we're sending to an ICQ user, and they are in our |
516 * buddy list, and they are advertising the Unicode | |
517 * capability, and they are online, then attempt to send | |
518 * as UCS-2BE. | |
9830 | 519 */ |
9975 | 520 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 521 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
522 | |
10565 | 523 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
524 { | |
525 GaimBuddy *b; | |
526 b = gaim_find_buddy(account, destsn); | |
527 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
528 { | |
529 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
530 if (*msg != NULL) | |
531 { | |
532 *charset = AIM_CHARSET_UNICODE; | |
533 *charsubset = 0x0000; | |
534 *msglen_int = msglen; | |
535 return; | |
536 } | |
9830 | 537 } |
538 } | |
539 | |
540 /* | |
541 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
542 * ICQ then attempt to send as the user specified character encoding. | |
543 */ | |
544 charsetstr = "ISO-8859-1"; | |
9975 | 545 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 546 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
547 | |
10097 | 548 /* |
549 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
550 * can be converted to "charsetstr" | |
551 */ | |
10039 | 552 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 553 if (*msg != NULL) { |
554 *charset = AIM_CHARSET_CUSTOM; | |
555 *charsubset = 0x0000; | |
10039 | 556 *msglen_int = msglen; |
9830 | 557 return; |
558 } | |
559 | |
560 /* | |
561 * Nothing else worked, so send as UCS-2BE. | |
562 */ | |
10039 | 563 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 564 if (*msg != NULL) { |
565 *charset = AIM_CHARSET_UNICODE; | |
566 *charsubset = 0x0000; | |
10039 | 567 *msglen_int = msglen; |
9830 | 568 return; |
569 } | |
570 | |
9908 | 571 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 572 g_error_free(err); |
573 | |
574 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
575 *msg = g_strdup(from); | |
10039 | 576 *msglen_int = strlen(*msg); |
9830 | 577 *charset = AIM_CHARSET_ASCII; |
578 *charsubset = 0x0000; | |
579 return; | |
580 } | |
581 | |
9407 | 582 gchar *oscar_caps_to_string(guint caps) |
8701 | 583 { |
9407 | 584 GString *str; |
585 gchar *tmp; | |
8701 | 586 guint bit = 1; |
587 | |
9407 | 588 str = g_string_new(""); |
589 | |
8701 | 590 if (!caps) { |
591 return NULL; | |
592 } else while (bit <= AIM_CAPS_LAST) { | |
593 if (bit & caps) { | |
594 switch (bit) { | |
595 case AIM_CAPS_BUDDYICON: | |
596 tmp = _("Buddy Icon"); | |
597 break; | |
598 case AIM_CAPS_TALK: | |
599 tmp = _("Voice"); | |
600 break; | |
601 case AIM_CAPS_DIRECTIM: | |
602 tmp = _("AIM Direct IM"); | |
603 break; | |
604 case AIM_CAPS_CHAT: | |
605 tmp = _("Chat"); | |
606 break; | |
607 case AIM_CAPS_GETFILE: | |
608 tmp = _("Get File"); | |
609 break; | |
610 case AIM_CAPS_SENDFILE: | |
611 tmp = _("Send File"); | |
612 break; | |
613 case AIM_CAPS_GAMES: | |
614 case AIM_CAPS_GAMES2: | |
615 tmp = _("Games"); | |
616 break; | |
617 case AIM_CAPS_ADDINS: | |
618 tmp = _("Add-Ins"); | |
619 break; | |
620 case AIM_CAPS_SENDBUDDYLIST: | |
621 tmp = _("Send Buddy List"); | |
622 break; | |
623 case AIM_CAPS_ICQ_DIRECT: | |
624 tmp = _("ICQ Direct Connect"); | |
625 break; | |
626 case AIM_CAPS_APINFO: | |
627 tmp = _("AP User"); | |
628 break; | |
629 case AIM_CAPS_ICQRTF: | |
630 tmp = _("ICQ RTF"); | |
631 break; | |
632 case AIM_CAPS_EMPTY: | |
633 tmp = _("Nihilist"); | |
634 break; | |
635 case AIM_CAPS_ICQSERVERRELAY: | |
636 tmp = _("ICQ Server Relay"); | |
637 break; | |
638 case AIM_CAPS_ICQUTF8OLD: | |
639 tmp = _("Old ICQ UTF8"); | |
640 break; | |
641 case AIM_CAPS_TRILLIANCRYPT: | |
642 tmp = _("Trillian Encryption"); | |
643 break; | |
644 case AIM_CAPS_ICQUTF8: | |
645 tmp = _("ICQ UTF8"); | |
646 break; | |
647 case AIM_CAPS_HIPTOP: | |
648 tmp = _("Hiptop"); | |
649 break; | |
650 case AIM_CAPS_SECUREIM: | |
651 tmp = _("Security Enabled"); | |
652 break; | |
653 case AIM_CAPS_VIDEO: | |
654 tmp = _("Video Chat"); | |
655 break; | |
656 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
657 case AIM_CAPS_ICHATAV: | |
658 tmp = _("iChat AV"); | |
659 break; | |
660 case AIM_CAPS_LIVEVIDEO: | |
661 tmp = _("Live Video"); | |
662 break; | |
663 case AIM_CAPS_CAMERA: | |
664 tmp = _("Camera"); | |
665 break; | |
666 default: | |
667 tmp = NULL; | |
668 break; | |
669 } | |
670 if (tmp) | |
9532 | 671 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 672 } |
673 bit <<= 1; | |
674 } | |
9407 | 675 |
676 return g_string_free(str, FALSE); | |
8701 | 677 } |
678 | |
679 static char *oscar_icqstatus(int state) { | |
680 /* Make a cute little string that shows the status of the dude or dudet */ | |
681 if (state & AIM_ICQ_STATE_CHAT) | |
682 return g_strdup_printf(_("Free For Chat")); | |
683 else if (state & AIM_ICQ_STATE_DND) | |
684 return g_strdup_printf(_("Do Not Disturb")); | |
685 else if (state & AIM_ICQ_STATE_OUT) | |
686 return g_strdup_printf(_("Not Available")); | |
687 else if (state & AIM_ICQ_STATE_BUSY) | |
688 return g_strdup_printf(_("Occupied")); | |
689 else if (state & AIM_ICQ_STATE_AWAY) | |
690 return g_strdup_printf(_("Away")); | |
691 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
692 return g_strdup_printf(_("Web Aware")); | |
693 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
694 return g_strdup_printf(_("Invisible")); | |
695 else | |
696 return g_strdup_printf(_("Online")); | |
697 } | |
698 | |
9973 | 699 static void |
700 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 701 { |
702 gchar *utf8; | |
703 | |
704 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 705 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 706 g_free(utf8); |
707 } | |
708 } | |
709 | |
9973 | 710 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 711 { |
10042 | 712 OscarData *od; |
713 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
714 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
715 GaimStatus *status = NULL; |
8701 | 716 GaimGroup *g = NULL; |
717 struct buddyinfo *bi = NULL; | |
718 char *tmp; | |
719 | |
10042 | 720 od = gc->proto_data; |
721 account = gaim_connection_get_account(gc); | |
722 | |
723 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 724 return; |
725 | |
726 if (userinfo == NULL) | |
727 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
728 | |
729 if (b == NULL) | |
10042 | 730 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 731 |
732 if (b != NULL) | |
10498 | 733 { |
8701 | 734 g = gaim_find_buddys_group(b); |
10498 | 735 presence = gaim_buddy_get_presence(b); |
736 status = gaim_presence_get_active_status(presence); | |
737 } | |
8701 | 738 |
739 if (userinfo != NULL) | |
740 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
741 | |
8733 | 742 if (b != NULL) { |
10498 | 743 if (gaim_presence_is_online(presence)) { |
9975 | 744 if (aim_sn_is_icq(b->name)) { |
8733 | 745 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
746 oscar_string_append(str, newline, _("Status"), tmp); | |
747 g_free(tmp); | |
748 } | |
749 } else { | |
9625 | 750 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 751 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
752 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
753 else | |
754 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 755 } |
8733 | 756 } |
8701 | 757 |
758 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 759 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 760 (bi->ipaddr & 0xff000000) >> 24, |
761 (bi->ipaddr & 0x00ff0000) >> 16, | |
762 (bi->ipaddr & 0x0000ff00) >> 8, | |
763 (bi->ipaddr & 0x000000ff)); | |
764 oscar_string_append(str, newline, _("IP Address"), tmp); | |
765 g_free(tmp); | |
766 } | |
767 | |
768 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
769 tmp = oscar_caps_to_string(userinfo->capabilities); | |
770 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 771 g_free(tmp); |
8701 | 772 } |
773 | |
774 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
775 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
776 if (tmp != NULL) { | |
9625 | 777 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 778 g_free(tmp); |
9625 | 779 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
780 g_free(tmp2); | |
8701 | 781 } |
782 } | |
783 | |
10498 | 784 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_status_is_available(status)) { |
8701 | 785 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
786 oscar_string_append(str, newline, _("Available"), tmp); | |
787 g_free(tmp); | |
788 } | |
789 } | |
790 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
791 static char *extract_name(const char *name) { |
4121 | 792 char *tmp, *x; |
2086 | 793 int i, j; |
4120 | 794 |
795 if (!name) | |
4121 | 796 return NULL; |
10042 | 797 |
4120 | 798 x = strchr(name, '-'); |
4121 | 799 |
2086 | 800 if (!x) return NULL; |
801 x = strchr(++x, '-'); | |
802 if (!x) return NULL; | |
803 tmp = g_strdup(++x); | |
804 | |
805 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
806 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
807 if (x[i] != '%') { |
2086 | 808 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
809 continue; |
2086 | 810 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
811 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
812 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
813 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 814 } |
815 | |
816 tmp[j] = 0; | |
817 return tmp; | |
818 } | |
819 | |
10458 | 820 static struct chat_connection * |
821 find_oscar_chat(GaimConnection *gc, int id) | |
822 { | |
823 OscarData *od = (OscarData *)gc->proto_data; | |
824 GSList *cur; | |
825 struct chat_connection *cc; | |
826 | |
827 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
828 { | |
829 cc = (struct chat_connection *)cur->data; | |
830 if (cc->id == id) | |
831 return cc; | |
832 } | |
833 | |
834 return NULL; | |
835 } | |
836 | |
837 static struct chat_connection * | |
838 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
839 { | |
840 OscarData *od = (OscarData *)gc->proto_data; | |
841 GSList *cur; | |
842 struct chat_connection *cc; | |
843 | |
844 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
845 { | |
846 cc = (struct chat_connection *)cur->data; | |
847 if (cc->conn == conn) | |
848 return cc; | |
849 } | |
850 | |
851 return NULL; | |
852 } | |
853 | |
854 static struct chat_connection * | |
855 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
856 { | |
857 OscarData *od = (OscarData *)gc->proto_data; | |
858 GSList *cur; | |
859 struct chat_connection *cc; | |
860 | |
861 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
862 { | |
863 cc = (struct chat_connection *)cur->data; | |
864 if (cc->conv == conv) | |
865 return cc; | |
866 } | |
867 | |
868 return NULL; | |
869 } | |
870 | |
871 static void | |
872 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
873 { | |
874 OscarData *od = (OscarData *)gc->proto_data; | |
875 | |
876 /* Notify the conversation window that we've left the chat */ | |
877 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
878 | |
879 /* Destroy the chat_connection */ | |
880 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
881 if (cc->inpa > 0) | |
882 gaim_input_remove(cc->inpa); | |
883 aim_conn_kill(od->sess, &cc->conn); | |
884 g_free(cc->name); | |
885 g_free(cc->show); | |
886 g_free(cc); | |
8219 | 887 } |
888 | |
8971 | 889 /***************************************************************************** |
890 * Begin scary direct im stuff | |
891 *****************************************************************************/ | |
892 | |
893 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
894 GSList *d = od->direct_ims; | |
895 struct oscar_direct_im *m = NULL; | |
896 | |
897 while (d) { | |
898 m = (struct oscar_direct_im *)d->data; | |
899 if (!aim_sncmp(who, m->name)) | |
900 return m; | |
901 d = d->next; | |
902 } | |
903 | |
904 return NULL; | |
905 } | |
906 | |
907 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
908 { | |
909 gaim_debug_info("oscar", | |
910 "destroying Direct IM for %s.\n", dim->name); | |
911 | |
912 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 913 if (dim->gpc_pend) { |
914 dim->killme = TRUE; | |
915 return; | |
916 } | |
8971 | 917 if (dim->watcher) |
918 gaim_input_remove(dim->watcher); | |
919 if (dim->conn) { | |
10271 | 920 aim_conn_close(dim->conn); |
8971 | 921 aim_conn_kill(od->sess, &dim->conn); |
922 } | |
923 g_free(dim); | |
924 } | |
925 | |
926 /* the only difference between this and destroy is this writes a conv message */ | |
927 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
928 { | |
929 GaimConversation *conv; | |
930 char buf[256]; | |
931 | |
932 gaim_debug_info("oscar", | |
933 "%s disconnected Direct IM.\n", dim->name); | |
934 | |
935 if (dim->connected) | |
936 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 937 else |
8971 | 938 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
939 | |
10246 | 940 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
941 gaim_connection_get_account(dim->gc)); | |
8971 | 942 if (conv) { |
943 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 944 gaim_conversation_update_progress(conv, 0); |
8971 | 945 } else { |
946 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
947 } | |
948 | |
949 oscar_direct_im_destroy(od, dim); | |
950 | |
951 return; | |
952 } | |
953 | |
954 /* oops i made two of these. this one just calls the other one. */ | |
955 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
956 { | |
957 GaimConnection *gc = sess->aux_data; | |
958 OscarData *od = (OscarData *)gc->proto_data; | |
959 struct oscar_direct_im *dim; | |
960 char *sn; | |
961 | |
962 sn = g_strdup(aim_odc_getsn(conn)); | |
963 dim = oscar_direct_im_find(od, sn); | |
964 oscar_direct_im_disconnect(od, dim); | |
965 g_free(sn); | |
966 } | |
967 | |
968 static void destroy_direct_im_request(struct ask_direct *d) { | |
969 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
970 | |
971 g_free(d->sn); | |
972 g_free(d); | |
973 } | |
974 | |
975 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
976 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
977 struct oscar_direct_im *dim = data; | |
978 GaimConnection *gc = dim->gc; | |
979 OscarData *od = gc->proto_data; | |
980 GaimConversation *conv; | |
981 char buf[256]; | |
982 struct sockaddr name; | |
983 socklen_t name_len = 1; | |
984 | |
985 g_return_if_fail(gc != NULL); | |
986 | |
8978 | 987 dim->gpc_pend = FALSE; |
988 if (dim->killme) { | |
989 oscar_direct_im_destroy(od, dim); | |
990 return; | |
991 } | |
992 | |
8971 | 993 if (!g_list_find(gaim_connections_get_all(), gc)) { |
994 oscar_direct_im_destroy(od, dim); | |
995 return; | |
996 } | |
997 | |
998 if (source < 0) { | |
8984 | 999 if (dim->donttryagain) { |
1000 oscar_direct_im_disconnect(od, dim); | |
1001 return; | |
1002 } else { | |
1003 fu8_t cookie[8]; | |
1004 char *who = g_strdup(dim->name); | |
1005 const char *tmp = aim_odc_getcookie(dim->conn); | |
1006 | |
1007 memcpy(cookie, tmp, 8); | |
1008 oscar_direct_im_destroy(od, dim); | |
1009 oscar_direct_im_initiate(gc, who, cookie); | |
1010 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1011 g_free(who); | |
1012 return; | |
1013 } | |
8971 | 1014 } |
1015 | |
1016 dim->conn->fd = source; | |
1017 aim_conn_completeconnect(od->sess, dim->conn); | |
1018 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
1019 | |
1020 /* This is the best way to see if we're connected or not */ | |
8983 | 1021 /* Is this really needed? */ |
8971 | 1022 if (getpeername(source, &name, &name_len) == 0) { |
1023 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1024 dim->connected = TRUE; | |
1025 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1026 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1027 } else { | |
8984 | 1028 if (dim->donttryagain) { |
1029 oscar_direct_im_disconnect(od, dim); | |
1030 return; | |
1031 } else { | |
1032 fu8_t cookie[8]; | |
1033 char *who = g_strdup(dim->name); | |
1034 const char *tmp = aim_odc_getcookie(dim->conn); | |
1035 | |
1036 memcpy(cookie, tmp, 8); | |
1037 oscar_direct_im_destroy(od, dim); | |
1038 oscar_direct_im_initiate(gc, who, cookie); | |
1039 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1040 g_free(who); | |
1041 return; | |
1042 } | |
8983 | 1043 } |
1044 | |
1045 | |
8971 | 1046 } |
1047 | |
1048 static void accept_direct_im_request(struct ask_direct *d) { | |
1049 GaimConnection *gc = d->gc; | |
1050 OscarData *od; | |
1051 struct oscar_direct_im *dim; | |
1052 char *host; int port = 5190; | |
1053 int i, rc; | |
8982 | 1054 char *tmp; |
1055 GaimConversation *conv; | |
8971 | 1056 |
1057 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1058 destroy_direct_im_request(d); | |
1059 return; | |
1060 } | |
1061 | |
1062 od = (OscarData *)gc->proto_data; | |
1063 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1064 | |
1065 dim = oscar_direct_im_find(od, d->sn); | |
1066 if (dim && dim->connected) { | |
1067 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1068 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1069 return; | |
1070 } | |
1071 dim = g_new0(struct oscar_direct_im, 1); | |
1072 dim->gc = d->gc; | |
8984 | 1073 dim->donttryagain = d->donttryagain; |
8971 | 1074 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1075 | |
1076 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1077 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1078 if (!dim->conn) { | |
1079 oscar_direct_im_disconnect(od, dim); | |
1080 destroy_direct_im_request(d); | |
1081 return; | |
1082 } | |
1083 | |
1084 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1085 gaim_odc_incoming, 0); | |
1086 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1087 gaim_odc_typing, 0); | |
1088 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1089 gaim_odc_update_ui, 0); | |
1090 | |
1091 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1092 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1093 if (d->ip[i] == ':') { | |
1094 port = atoi(&(d->ip[i+1])); | |
1095 break; | |
1096 } | |
1097 } | |
1098 host = g_strndup(d->ip, i); | |
1099 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1100 dim->gpc_pend = TRUE; |
8971 | 1101 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1102 |
1103 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1104 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1105 port); | |
1106 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1107 g_free(tmp); | |
8983 | 1108 |
8971 | 1109 g_free(host); |
1110 if (rc < 0) { | |
8978 | 1111 dim->gpc_pend = FALSE; |
8971 | 1112 oscar_direct_im_disconnect(od, dim); |
1113 destroy_direct_im_request(d); | |
1114 return; | |
1115 } | |
1116 | |
1117 destroy_direct_im_request(d); | |
1118 | |
1119 return; | |
1120 } | |
1121 | |
1122 /* | |
1123 * We have just established a socket with the other dude, so set up some handlers. | |
1124 */ | |
1125 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1126 GaimConnection *gc = sess->aux_data; |
7283 | 1127 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1128 GaimConversation *conv; |
8971 | 1129 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1130 char buf[256]; |
8971 | 1131 char *sn; |
1132 va_list ap; | |
1133 aim_conn_t *newconn, *listenerconn; | |
1134 | |
1135 va_start(ap, fr); | |
1136 newconn = va_arg(ap, aim_conn_t *); | |
1137 listenerconn = va_arg(ap, aim_conn_t *); | |
1138 va_end(ap); | |
1139 | |
10271 | 1140 aim_conn_close(listenerconn); |
8971 | 1141 aim_conn_kill(sess, &listenerconn); |
1142 | |
1143 sn = g_strdup(aim_odc_getsn(newconn)); | |
1144 | |
1145 gaim_debug_info("oscar", | |
1146 "DirectIM: initiate success to %s\n", sn); | |
1147 dim = oscar_direct_im_find(od, sn); | |
1148 | |
1149 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1150 gaim_input_remove(dim->watcher); | |
1151 dim->conn = newconn; | |
1152 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1153 dim->connected = TRUE; | |
1154 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1155 g_free(sn); | |
1156 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1157 | |
1158 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1159 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1160 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1161 | |
1162 return 1; | |
1163 } | |
1164 | |
1165 /* | |
1166 * This is called when each chunk of an image is received. It can be used to | |
1167 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1168 * nasty, you sicko. | |
1169 */ | |
1170 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1171 va_list ap; | |
1172 char *sn; | |
1173 double percent; | |
1174 GaimConnection *gc = sess->aux_data; | |
1175 OscarData *od = (OscarData *)gc->proto_data; | |
1176 GaimConversation *c; | |
1177 struct oscar_direct_im *dim; | |
1178 | |
1179 va_start(ap, fr); | |
1180 sn = va_arg(ap, char *); | |
1181 percent = va_arg(ap, double); | |
1182 va_end(ap); | |
1183 | |
1184 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1185 return 1; | |
1186 if (dim->watcher) { | |
1187 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1188 /* The callback will callback? I don't get how that would happen here. */ | |
1189 dim->watcher = 0; | |
1190 } | |
1191 | |
10246 | 1192 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1193 gaim_connection_get_account(gc)); | |
8971 | 1194 if (c != NULL) |
1195 gaim_conversation_update_progress(c, percent); | |
1196 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1197 oscar_callback, dim->conn); | |
1198 | |
1199 return 1; | |
1200 } | |
1201 | |
1202 /* | |
1203 * This is called after a direct IM has been received in its entirety. This | |
1204 * function is passed a long chunk of data which contains the IM with any | |
1205 * data chunks (images) appended to it. | |
1206 * | |
1207 * This function rips out all the data chunks and creates an imgstore for | |
1208 * each one. In order to do this, it first goes through the IM and takes | |
1209 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1210 * with one compatible with the imgstore Gaim core code. For each one, we | |
1211 * then read in chunks of data from the end of the message and actually | |
1212 * create the img store using the given data. | |
1213 * | |
1214 * For somewhat easy reference, here's a sample message | |
1215 * (without the whitespace and asterisks): | |
1216 * | |
1217 * <HTML><BODY BGCOLOR="#ffffff"> | |
1218 * <FONT LANG="0"> | |
1219 * This is a really stupid picture:<BR> | |
1220 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1221 * Yeah it is<BR> | |
1222 * Here is another one:<BR> | |
1223 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1224 * </FONT> | |
1225 * </BODY></HTML> | |
1226 * <BINARY> | |
1227 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1228 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1229 * </BINARY> | |
1230 */ | |
1231 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1232 GaimConnection *gc = sess->aux_data; | |
1233 GaimConvImFlags imflags = 0; | |
1234 gchar *utf8; | |
1235 GString *newmsg = g_string_new(""); | |
1236 GSList *images = NULL; | |
1237 va_list ap; | |
1238 const char *sn, *msg, *msgend, *binary; | |
1239 size_t len; | |
1240 int encoding, isawaymsg; | |
1241 | |
1242 va_start(ap, fr); | |
1243 sn = va_arg(ap, const char *); | |
1244 msg = va_arg(ap, const char *); | |
1245 len = va_arg(ap, size_t); | |
1246 encoding = va_arg(ap, int); | |
1247 isawaymsg = va_arg(ap, int); | |
1248 va_end(ap); | |
1249 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1250 |
8660 | 1251 gaim_debug_info("oscar", |
8971 | 1252 "Got DirectIM message from %s\n", sn); |
1253 | |
1254 if (isawaymsg) | |
1255 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1256 | |
1257 /* message has a binary trailer */ | |
1258 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1259 GData *attribs; | |
1260 const char *tmp, *start, *end, *last = NULL; | |
1261 | |
1262 tmp = msg; | |
1263 | |
1264 /* for each valid image tag... */ | |
1265 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1266 const char *id, *src, *datasize; | |
10504 | 1267 const char *data = NULL; |
1268 char *tag = NULL; | |
8971 | 1269 size_t size; |
1270 int imgid = 0; | |
1271 | |
1272 /* update the location of the last img tag */ | |
1273 last = end; | |
1274 | |
1275 /* grab attributes */ | |
1276 id = g_datalist_get_data(&attribs, "id"); | |
1277 src = g_datalist_get_data(&attribs, "src"); | |
1278 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1279 | |
1280 /* if we have id & datasize, build the data tag */ | |
1281 if (id && datasize) | |
1282 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1283 | |
1284 /* if we have a tag, find the start of the data */ | |
1285 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1286 data += strlen(tag); | |
1287 | |
10504 | 1288 g_free(tag); |
1289 | |
8971 | 1290 /* check the data is here and store it */ |
1291 if (data + (size = atoi(datasize)) <= msgend) | |
1292 imgid = gaim_imgstore_add(data, size, src); | |
1293 | |
1294 /* | |
1295 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1296 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1297 */ | |
1298 /* if we have a stored image... */ | |
1299 if (imgid) { | |
1300 /* append the message up to the tag */ | |
1301 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1302 if (utf8 != NULL) { | |
1303 newmsg = g_string_append(newmsg, utf8); | |
1304 g_free(utf8); | |
1305 } | |
1306 | |
1307 /* write the new image tag */ | |
1308 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1309 | |
1310 /* and record the image number */ | |
1311 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1312 } else { | |
1313 /* otherwise, copy up to the end of the tag */ | |
1314 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1315 if (utf8 != NULL) { | |
1316 newmsg = g_string_append(newmsg, utf8); | |
1317 g_free(utf8); | |
1318 } | |
1319 } | |
1320 | |
1321 /* clear the attribute list */ | |
1322 g_datalist_clear(&attribs); | |
1323 | |
1324 /* continue from the end of the tag */ | |
1325 tmp = end + 1; | |
1326 } | |
1327 | |
1328 /* append any remaining message data (without the > :-) */ | |
1329 if (last++ && (last < binary)) | |
1330 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1331 | |
1332 /* set the flag if we caught any images */ | |
1333 if (images) | |
1334 imflags |= GAIM_CONV_IM_IMAGES; | |
1335 } else { | |
1336 g_string_append_len(newmsg, msg, len); | |
1337 } | |
1338 | |
10318 | 1339 /* Convert to UTF8 */ |
1340 /* (This hasn't been tested very much) */ | |
1341 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1342 if (utf8 != NULL) { | |
1343 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1344 g_free(utf8); | |
1345 } | |
1346 | |
1347 /* free the message */ | |
8971 | 1348 g_string_free(newmsg, TRUE); |
1349 | |
1350 /* unref any images we allocated */ | |
1351 if (images) { | |
1352 GSList *tmp; | |
1353 int id; | |
1354 | |
1355 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1356 id = GPOINTER_TO_INT(tmp->data); | |
1357 gaim_imgstore_unref(id); | |
1358 } | |
1359 | |
1360 g_slist_free(images); | |
1361 } | |
1362 | |
1363 return 1; | |
1364 } | |
1365 | |
1366 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1367 va_list ap; | |
1368 char *sn; | |
1369 int typing; | |
1370 GaimConnection *gc = sess->aux_data; | |
1371 | |
1372 va_start(ap, fr); | |
1373 sn = va_arg(ap, char *); | |
1374 typing = va_arg(ap, int); | |
1375 va_end(ap); | |
1376 | |
1377 if (typing == 0x0002) { | |
1378 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1379 gaim_debug_info("oscar", | |
1380 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1381 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1382 } else if (typing == 0x0001) | |
1383 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1384 else | |
1385 serv_got_typing_stopped(gc, sn); | |
1386 return 1; | |
1387 } | |
1388 | |
1389 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1390 char *buf; | |
1391 size_t len; | |
1392 int ret; | |
1393 GString *msg = g_string_new("<HTML><BODY>"); | |
1394 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1395 GData *attribs; | |
1396 const char *start, *end, *last; | |
1397 int oscar_id = 0; | |
1398 | |
1399 last = message; | |
1400 | |
1401 /* for each valid IMG tag... */ | |
1402 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1403 GaimStoredImage *image = NULL; | |
1404 const char *id; | |
1405 | |
1406 if (start - last) { | |
1407 g_string_append_len(msg, last, start - last); | |
1408 } | |
1409 | |
1410 id = g_datalist_get_data(&attribs, "id"); | |
1411 | |
1412 /* ... if it refers to a valid gaim image ... */ | |
1413 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1414 /* ... append the message from start to the tag ... */ | |
9126 | 1415 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1416 const char *filename = gaim_imgstore_get_filename(image); |
1417 gpointer imgdata = gaim_imgstore_get_data(image); | |
1418 | |
1419 oscar_id++; | |
1420 | |
1421 /* ... insert a new img tag with the oscar id ... */ | |
1422 if (filename) | |
1423 g_string_append_printf(msg, | |
9126 | 1424 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1425 filename, oscar_id, size); |
1426 else | |
1427 g_string_append_printf(msg, | |
9126 | 1428 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1429 oscar_id, size); |
1430 | |
1431 /* ... and append the data to the binary section ... */ | |
9126 | 1432 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1433 oscar_id, size); |
1434 data = g_string_append_len(data, imgdata, size); | |
1435 data = g_string_append(data, "</DATA>"); | |
1436 } | |
1437 /* If the tag is invalid, skip it, thus no else here */ | |
1438 | |
1439 g_datalist_clear(&attribs); | |
1440 | |
1441 /* continue from the end of the tag */ | |
1442 last = end + 1; | |
1443 } | |
1444 | |
1445 /* append any remaining message data (without the > :-) */ | |
1446 if (last && *last) | |
1447 msg = g_string_append(msg, last); | |
1448 | |
1449 /* if we inserted any images in the binary section, append it */ | |
1450 if (oscar_id) { | |
1451 msg = g_string_append_len(msg, data->str, data->len); | |
1452 msg = g_string_append(msg, "</BINARY>"); | |
1453 } | |
1454 | |
1455 len = msg->len; | |
1456 buf = msg->str; | |
1457 g_string_free(msg, FALSE); | |
1458 g_string_free(data, TRUE); | |
1459 | |
1460 | |
1461 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1462 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1463 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1464 else | |
1465 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1466 | |
1467 g_free(buf); | |
1468 | |
1469 return ret; | |
1470 } | |
1471 | |
1472 struct ask_do_dir_im { | |
1473 char *who; | |
1474 GaimConnection *gc; | |
1475 }; | |
1476 | |
1477 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1478 g_free(data->who); | |
1479 g_free(data); | |
1480 } | |
1481 | |
8983 | 1482 /* this function is used to initiate a direct im session with someone. |
1483 * we start listening on a port and send a request. they either connect | |
1484 * or send some kind of reply. If they can't connect, they ask us to | |
1485 * connect to them, and so we do that. | |
1486 * | |
1487 * this function will also get called if the other side initiate's a direct | |
1488 * im and we try to connect and fail. in that case cookie will not be null. | |
1489 * | |
1490 * note that cookie is an 8 byte string that isn't NULL terminated | |
1491 */ | |
1492 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1493 OscarData *od; |
1494 struct oscar_direct_im *dim; | |
1495 int listenfd; | |
8982 | 1496 const char *ip; |
8971 | 1497 |
1498 od = (OscarData *)gc->proto_data; | |
1499 | |
8983 | 1500 dim = oscar_direct_im_find(od, who); |
8971 | 1501 if (dim) { |
1502 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1503 oscar_direct_im_disconnect(od, dim); | |
1504 gaim_debug_info("oscar", | |
1505 "Gave up on old direct IM, trying again\n"); | |
1506 } else { | |
1507 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1508 return; |
8971 | 1509 } |
1510 } | |
1511 dim = g_new0(struct oscar_direct_im, 1); | |
1512 dim->gc = gc; | |
8983 | 1513 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1514 |
1515 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1516 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1517 if (listenfd >= 0) |
1518 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1519 if (dim->conn != NULL) { |
8982 | 1520 char *tmp; |
1521 GaimConversation *conv; | |
1522 | |
8971 | 1523 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1524 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1525 oscar_callback, dim->conn); | |
1526 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1527 gaim_odc_initiate, 0); | |
8982 | 1528 |
8983 | 1529 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1530 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1531 gaim_network_get_port_from_fd(listenfd)); |
1532 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1533 g_free(tmp); | |
8971 | 1534 } else { |
1535 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1536 oscar_direct_im_destroy(od, dim); | |
1537 } | |
8983 | 1538 } |
1539 | |
1540 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1541 GaimConnection *gc = data->gc; | |
1542 | |
1543 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1544 g_free(data->who); | |
1545 g_free(data); | |
1546 return; | |
1547 } | |
1548 | |
1549 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1550 g_free(data->who); |
1551 g_free(data); | |
1552 } | |
1553 | |
1554 /* this is the right click menu cb thingy */ | |
9030 | 1555 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1556 | |
1557 GaimBuddy *buddy; | |
1558 GaimConnection *gc; | |
8971 | 1559 gchar *buf; |
9030 | 1560 struct ask_do_dir_im *data; |
1561 | |
1562 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1563 | |
1564 buddy = (GaimBuddy *) node; | |
1565 gc = gaim_account_get_connection(buddy->account); | |
1566 | |
1567 data = g_new0(struct ask_do_dir_im, 1); | |
1568 data->who = g_strdup(buddy->name); | |
8971 | 1569 data->gc = gc; |
9030 | 1570 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1571 buddy->name); | |
8971 | 1572 |
1573 gaim_request_action(gc, NULL, buf, | |
9030 | 1574 _("Because this reveals your IP address, it " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1575 "may be considered a privacy risk. Do you " |
9030 | 1576 "wish to continue?"), |
1577 0, data, 2, | |
1578 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1579 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1580 g_free(buf); |
1581 } | |
1582 | |
1583 /***************************************************************************** | |
1584 * End scary direct im stuff | |
1585 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1586 |
4617 | 1587 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1588 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1589 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1590 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1591 OscarData *od; |
2086 | 1592 |
1593 if (!gc) { | |
8660 | 1594 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1595 "oscar callback for closed connection (1).\n"); |
2086 | 1596 return; |
1597 } | |
10458 | 1598 |
7283 | 1599 od = (OscarData *)gc->proto_data; |
2086 | 1600 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1601 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1602 /* oh boy. this is probably bad. i guess the only thing we |
1603 * can really do is return? */ | |
8660 | 1604 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1605 "oscar callback for closed connection (2).\n"); |
8660 | 1606 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1607 return; |
1608 } | |
1609 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1610 if (condition & GAIM_INPUT_READ) { |
4617 | 1611 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1612 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1613 "got information on rendezvous listener\n"); |
4617 | 1614 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1615 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1616 "connection error (rendezvous listener)\n"); |
4617 | 1617 aim_conn_kill(od->sess, &conn); |
8446 | 1618 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1619 } |
1620 } else { | |
4617 | 1621 if (aim_get_command(od->sess, conn) >= 0) { |
1622 aim_rxdispatch(od->sess); | |
6029 | 1623 if (od->killme) { |
8660 | 1624 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1625 return; |
1626 } | |
2086 | 1627 } else { |
1628 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
10444 | 1629 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1630 { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1631 gaim_debug_error("oscar", "Major connection error. i.e. " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1632 "invalid data was received on the oscar TCP stream\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1633 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1634 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1635 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1636 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1637 char *buf; |
10458 | 1638 |
1639 gaim_debug_info("oscar", "Lost connection " | |
1640 "to chat room %s\n", cc->name); | |
1641 | |
1642 buf = g_strdup_printf(_("You have lost your connection " | |
1643 "to chat room %s."), cc->name); | |
1644 if (conv != NULL) | |
9627 | 1645 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1646 else | |
1647 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1648 g_free(buf); |
10458 | 1649 |
1650 oscar_chat_kill(gc, cc); | |
1651 | |
2086 | 1652 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1653 if (od->cnpa > 0) |
1654 gaim_input_remove(od->cnpa); | |
1655 od->cnpa = 0; | |
8660 | 1656 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1657 "removing chatnav input watcher\n"); |
4617 | 1658 while (od->create_rooms) { |
1659 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1660 g_free(cr->name); |
4617 | 1661 od->create_rooms = |
1662 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1663 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1664 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1665 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1666 NULL); |
2086 | 1667 } |
4617 | 1668 aim_conn_kill(od->sess, &conn); |
2086 | 1669 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1670 if (od->paspa > 0) |
1671 gaim_input_remove(od->paspa); | |
1672 od->paspa = 0; | |
8660 | 1673 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1674 "removing authconn input watcher\n"); |
4617 | 1675 aim_conn_kill(od->sess, &conn); |
3694 | 1676 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1677 if (od->emlpa > 0) |
1678 gaim_input_remove(od->emlpa); | |
1679 od->emlpa = 0; | |
8660 | 1680 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1681 "removing email input watcher\n"); |
4617 | 1682 aim_conn_kill(od->sess, &conn); |
4804 | 1683 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1684 if (od->icopa > 0) | |
1685 gaim_input_remove(od->icopa); | |
1686 od->icopa = 0; | |
8660 | 1687 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1688 "removing icon input watcher\n"); |
4804 | 1689 aim_conn_kill(od->sess, &conn); |
2086 | 1690 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1691 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1692 gaim_odc_disconnect(od->sess, conn); |
1693 aim_conn_kill(od->sess, &conn); | |
2086 | 1694 } else { |
8660 | 1695 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1696 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1697 conn->type); |
4617 | 1698 aim_conn_kill(od->sess, &conn); |
2086 | 1699 } |
1700 } | |
1701 } | |
1702 } | |
1703 } | |
1704 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1705 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1706 GaimConnection *gc = sess->aux_data; |
7285 | 1707 gchar *s = g_strdup_vprintf(format, va); |
1708 gchar *buf; | |
1709 | |
1710 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1711 gaim_debug_info("oscar", buf); |
7285 | 1712 if (buf[strlen(buf)-1] != '\n') |
8660 | 1713 gaim_debug_info(NULL, "\n"); |
7285 | 1714 g_free(buf); |
2086 | 1715 g_free(s); |
1716 } | |
1717 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1718 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1719 { |
5575 | 1720 GaimConnection *gc = data; |
7283 | 1721 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1722 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1723 aim_conn_t *conn; |
2086 | 1724 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1725 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1726 close(source); |
1727 return; | |
1728 } | |
1729 | |
4617 | 1730 od = gc->proto_data; |
1731 sess = od->sess; | |
2086 | 1732 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1733 conn->fd = source; |
2086 | 1734 |
1735 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1736 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1737 return; |
1738 } | |
1739 | |
1740 aim_conn_completeconnect(sess, conn); | |
4617 | 1741 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1742 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1743 | |
8660 | 1744 gaim_debug_info("oscar", |
7282 | 1745 "Screen name sent, waiting for response\n"); |
7283 | 1746 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1747 ck[1] = 0x65; |
2086 | 1748 } |
1749 | |
10444 | 1750 static void |
1751 oscar_login(GaimAccount *account, GaimStatus *status) | |
1752 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1753 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1754 aim_conn_t *conn; |
5575 | 1755 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1756 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
10400 | 1757 GaimStatusType *status_type; |
1758 GaimStatusPrimitive primitive; | |
1759 | |
1760 status_type = gaim_status_get_type(status); | |
1761 primitive = gaim_status_type_get_primitive(status_type); | |
2086 | 1762 |
8660 | 1763 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
10444 | 1764 |
10400 | 1765 if (primitive == GAIM_STATUS_OFFLINE) |
1766 return; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1767 |
8437 | 1768 if (!aim_snvalid(gaim_account_get_username(account))) { |
1769 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1770 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 | 1771 gaim_connection_error(gc, buf); |
1772 g_free(buf); | |
1773 } | |
1774 | |
9975 | 1775 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1776 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1777 } else { |
6622 | 1778 gc->flags |= GAIM_CONNECTION_HTML; |
1779 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1780 } |
5836 | 1781 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1782 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1783 sess = g_new0(aim_session_t, 1); |
10329 | 1784 aim_session_init(sess, TRUE, FAIM_DEBUG_LEVEL); |
2086 | 1785 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1786 /* |
1787 * We need an immediate queue because we don't use a while-loop | |
1788 * to see if things need to be sent. | |
1789 */ | |
2086 | 1790 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1791 od->sess = sess; |
2086 | 1792 sess->aux_data = gc; |
1793 | |
9935 | 1794 /* Connect to core Gaim signals */ |
10087 | 1795 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1796 |
2086 | 1797 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1798 if (conn == NULL) { | |
10444 | 1799 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1800 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1801 return; |
1802 } | |
1803 | |
4649 | 1804 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1805 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1806 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1807 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1808 |
1809 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1810 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1811 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1812 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1813 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1814 return; |
1815 } | |
7282 | 1816 |
7283 | 1817 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1818 ck[0] = 0x5a; |
5575 | 1819 } |
1820 | |
1821 static void oscar_close(GaimConnection *gc) { | |
7283 | 1822 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1823 |
1824 while (od->oscar_chats) { | |
1825 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1826 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1827 gaim_input_remove(n->inpa); |
2086 | 1828 g_free(n->name); |
1829 g_free(n->show); | |
4617 | 1830 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1831 g_free(n); |
1832 } | |
4617 | 1833 while (od->direct_ims) { |
8971 | 1834 struct oscar_direct_im *n = od->direct_ims->data; |
1835 oscar_direct_im_destroy(od, n); | |
2086 | 1836 } |
4617 | 1837 /* BBB */ |
1838 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1839 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1840 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1841 gaim_xfer_cancel_local(xfer); |
3630 | 1842 } |
4804 | 1843 while (od->requesticon) { |
1844 char *sn = od->requesticon->data; | |
1845 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1846 free(sn); | |
1847 } | |
4738 | 1848 g_hash_table_destroy(od->buddyinfo); |
4617 | 1849 while (od->create_rooms) { |
1850 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1851 g_free(cr->name); |
4617 | 1852 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1853 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1854 } |
4617 | 1855 if (od->email) |
1856 g_free(od->email); | |
1857 if (od->newp) | |
1858 g_free(od->newp); | |
1859 if (od->oldp) | |
1860 g_free(od->oldp); | |
2086 | 1861 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1862 gaim_input_remove(gc->inpa); |
4617 | 1863 if (od->cnpa > 0) |
1864 gaim_input_remove(od->cnpa); | |
1865 if (od->paspa > 0) | |
1866 gaim_input_remove(od->paspa); | |
1867 if (od->emlpa > 0) | |
1868 gaim_input_remove(od->emlpa); | |
4804 | 1869 if (od->icopa > 0) |
1870 gaim_input_remove(od->icopa); | |
6907 | 1871 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1872 gaim_timeout_remove(od->icontimer); |
8341 | 1873 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1874 gaim_timeout_remove(od->getblisttimer); |
8341 | 1875 if (od->getinfotimer > 0) |
1876 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1877 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1878 |
4617 | 1879 aim_session_kill(od->sess); |
1880 g_free(od->sess); | |
1881 od->sess = NULL; | |
2086 | 1882 g_free(gc->proto_data); |
1883 gc->proto_data = NULL; | |
8660 | 1884 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1885 } |
1886 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1887 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1888 GaimConnection *gc = data; |
7283 | 1889 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1890 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1891 aim_conn_t *bosconn; |
2086 | 1892 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1893 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1894 close(source); |
1895 return; | |
1896 } | |
1897 | |
4617 | 1898 od = gc->proto_data; |
1899 sess = od->sess; | |
1900 bosconn = od->conn; | |
4366 | 1901 bosconn->fd = source; |
2086 | 1902 |
1903 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1904 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1905 return; |
1906 } | |
1907 | |
1908 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1909 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1910 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1911 gaim_connection_update_progress(gc, |
7283 | 1912 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1913 ck[4] = 0x61; |
2086 | 1914 } |
1915 | |
4617 | 1916 /* BBB */ |
4656 | 1917 /* |
1918 * This little area in oscar.c is the nexus of file transfer code, | |
1919 * so I wrote a little explanation of what happens. I am such a | |
1920 * ninja. | |
1921 * | |
1922 * The series of events for a file send is: | |
1923 * -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
|
1924 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1925 * listening socket, then asks the remote user to connect to us (and |
1926 * gives them the file name, port, IP, etc.) | |
1927 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1928 * in oscar_sendfile_estblsh) | |
1929 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1930 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1931 * connection. | |
1932 * -We get drunk because file transfer kicks ass. | |
1933 * | |
1934 * The series of events for a file receive is: | |
1935 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1936 * -Gaim user selects file to name and location to save file to and | |
1937 * oscar_xfer_init is called | |
1938 * -It connects to the remote user using the IP they gave us earlier | |
1939 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1940 * them an AIM_CB_OFT_ACK. | |
1941 * -They begin to send us lots of raw data. | |
1942 * -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
|
1943 * the connection. |
4656 | 1944 */ |
1945 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1946 | |
8446 | 1947 /* |
1948 * Miscellaneous xfer functions | |
1949 */ | |
1950 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1951 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1952 GaimXfer *xfer; |
5146 | 1953 struct aim_oft_info *oft_info; |
4656 | 1954 |
1955 while (fts) { | |
1956 xfer = fts->data; | |
5146 | 1957 oft_info = xfer->data; |
1958 | |
8446 | 1959 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1960 return xfer; |
1961 | |
1962 fts = g_slist_next(fts); | |
1963 } | |
1964 | |
1965 return NULL; | |
1966 } | |
1967 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1968 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1969 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1970 GaimXfer *xfer; |
5146 | 1971 struct aim_oft_info *oft_info; |
4656 | 1972 |
1973 while (fts) { | |
1974 xfer = fts->data; | |
5146 | 1975 oft_info = xfer->data; |
1976 | |
1977 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1978 return xfer; |
1979 | |
1980 fts = g_slist_next(fts); | |
1981 } | |
1982 | |
1983 return NULL; | |
1984 } | |
1985 | |
8446 | 1986 static void oscar_xfer_end(GaimXfer *xfer) |
1987 { | |
1988 struct aim_oft_info *oft_info = xfer->data; | |
1989 GaimConnection *gc = oft_info->sess->aux_data; | |
1990 OscarData *od = gc->proto_data; | |
1991 | |
8660 | 1992 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1993 |
1994 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1995 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1996 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1997 } | |
1998 | |
1999 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2000 aim_oft_destroyinfo(oft_info); | |
2001 xfer->data = NULL; | |
2002 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2003 } | |
2004 | |
2005 /* | |
2006 * xfer functions used when receiving files | |
2007 */ | |
2008 | |
2009 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
2010 { | |
2011 struct aim_oft_info *oft_info = xfer->data; | |
2012 GaimConnection *gc = oft_info->sess->aux_data; | |
2013 OscarData *od = gc->proto_data; | |
2014 | |
8660 | 2015 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 2016 |
2017 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
2018 if (oft_info->conn) { | |
2019 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2020 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
2021 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
2022 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
2023 if (xfer->fd == -1) { | |
10654 | 2024 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2025 _("Unable to establish file descriptor.")); |
2026 gaim_xfer_cancel_local(xfer); | |
2027 } | |
2028 } else { | |
10654 | 2029 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2030 _("Unable to create new connection.")); |
2031 gaim_xfer_cancel_local(xfer); | |
2032 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2033 } | |
2034 | |
2035 } | |
2036 | |
2037 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
2038 { | |
10405 | 2039 struct aim_oft_info *oft_info; |
2040 GaimConnection *gc; | |
2041 OscarData *od; | |
2042 | |
2043 g_return_if_fail(xfer != NULL); | |
2044 g_return_if_fail(xfer->data != NULL); | |
2045 | |
2046 oft_info = xfer->data; | |
2047 gc = oft_info->sess->aux_data; | |
2048 od = gc->proto_data; | |
8446 | 2049 |
8660 | 2050 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2051 |
9771 | 2052 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2053 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2054 |
2055 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2056 aim_oft_destroyinfo(oft_info); | |
2057 xfer->data = NULL; | |
2058 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2059 } | |
2060 | |
2061 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
2062 { | |
2063 struct aim_oft_info *oft_info = xfer->data; | |
2064 | |
2065 /* Update our rolling checksum. Like Walmart, yo. */ | |
2066 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2067 } | |
2068 | |
2069 /* | |
2070 * xfer functions used when sending files | |
2071 */ | |
2072 | |
2073 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2074 { | |
2075 struct aim_oft_info *oft_info = xfer->data; | |
2076 GaimConnection *gc = oft_info->sess->aux_data; | |
2077 OscarData *od = gc->proto_data; | |
2078 int listenfd; | |
2079 | |
8660 | 2080 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2081 |
2082 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2083 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2084 oft_info->fh.name[63] = '\0'; | |
2085 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2086 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2087 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2088 | |
2089 /* Create a listening socket and an associated libfaim conn */ | |
2090 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2091 gaim_xfer_cancel_local(xfer); | |
2092 return; | |
2093 } | |
2094 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2095 oft_info->port = xfer->local_port; | |
2096 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2097 gaim_xfer_cancel_local(xfer); | |
2098 return; | |
2099 } | |
8660 | 2100 gaim_debug_misc("oscar", |
8446 | 2101 "port is %hu, ip is %s\n", |
2102 xfer->local_port, oft_info->clientip); | |
2103 if (oft_info->conn) { | |
2104 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2105 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2106 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2107 } else { | |
10654 | 2108 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2109 _("Unable to establish listener socket.")); |
2110 gaim_xfer_cancel_local(xfer); | |
2111 } | |
2112 } | |
2113 | |
2114 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2115 { | |
2116 struct aim_oft_info *oft_info = xfer->data; | |
2117 GaimConnection *gc = oft_info->sess->aux_data; | |
2118 OscarData *od = gc->proto_data; | |
2119 | |
8660 | 2120 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2121 |
9771 | 2122 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2123 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2124 |
2125 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2126 aim_oft_destroyinfo(oft_info); | |
2127 xfer->data = NULL; | |
2128 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2129 } | |
2130 | |
2131 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2132 { | |
2133 struct aim_oft_info *oft_info = xfer->data; | |
2134 | |
2135 /* I'm not sure I like how we do this. --marv | |
2136 * I do. AIM file transfers aren't really meant to be thought | |
2137 * of as a transferring just a single file. The rendezvous | |
2138 * establishes a connection between two computers, and then | |
2139 * those computers can use the same connection for transferring | |
2140 * multiple files. So we don't want the Gaim core up and closing | |
2141 * the socket all willy-nilly. We want to do that in the oscar | |
2142 * prpl, whenever one side or the other says they're finished | |
2143 * using the connection. There might be a better way to intercept | |
2144 * the socket from the core, however... --KingAnt | |
2145 */ | |
2146 | |
2147 /* | |
2148 * If we're done sending, intercept the socket from the core ft code | |
2149 * and wait for the other guy to send the "done" OFT packet. | |
2150 */ | |
2151 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2152 gaim_input_remove(xfer->watcher); | |
2153 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2154 xfer->fd = 0; | |
2155 gaim_xfer_set_completed(xfer, TRUE); | |
2156 } | |
2157 } | |
2158 | |
9466 | 2159 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2160 gboolean can_receive = FALSE; | |
2161 OscarData *od = gc->proto_data; | |
2162 | |
11049 | 2163 if (od != NULL) { |
9466 | 2164 aim_userinfo_t *userinfo; |
2165 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2166 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2167 can_receive = TRUE; | |
2168 } | |
2169 | |
2170 return can_receive; | |
2171 } | |
2172 | |
2173 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2174 |
2175 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2176 GaimXfer *xfer; |
5146 | 2177 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2178 const char *ip; |
3752 | 2179 |
9030 | 2180 od = (OscarData *)gc->proto_data; |
2181 | |
4617 | 2182 /* You want to send a file to someone else, you're so generous */ |
2183 | |
2184 /* Build the file transfer handle */ | |
9466 | 2185 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2186 |
5146 | 2187 /* Create the oscar-specific data */ |
8838 | 2188 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2189 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2190 xfer->data = oft_info; |
2191 | |
4617 | 2192 /* Setup our I/O op functions */ |
8446 | 2193 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2194 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2195 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2196 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2197 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2198 |
2199 /* Keep track of this transfer for later */ | |
2200 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2201 | |
2202 /* Now perform the request */ | |
9466 | 2203 if (file) |
2204 gaim_xfer_request_accepted(xfer, file); | |
2205 else | |
2206 gaim_xfer_request(xfer); | |
3630 | 2207 } |
2208 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2209 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2210 GaimConnection *gc = sess->aux_data; |
7283 | 2211 OscarData *od = gc->proto_data; |
6029 | 2212 GaimAccount *account = gc->account; |
2213 aim_conn_t *bosconn; | |
2214 char *host; int port; | |
2215 int i, rc; | |
2086 | 2216 va_list ap; |
2704 | 2217 struct aim_authresp_info *info; |
6029 | 2218 |
5575 | 2219 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2220 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2221 va_start(ap, fr); |
2704 | 2222 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2223 va_end(ap); |
2224 | |
8660 | 2225 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2226 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2227 |
4293 | 2228 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2229 char buf[256]; |
2704 | 2230 switch (info->errorcode) { |
2086 | 2231 case 0x05: |
2232 /* Incorrect nick/password */ | |
6498 | 2233 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2234 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2235 break; |
2236 case 0x11: | |
2237 /* Suspended account */ | |
6498 | 2238 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2239 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2240 break; |
3498 | 2241 case 0x14: |
2242 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2243 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2244 break; |
2086 | 2245 case 0x18: |
2246 /* connecting too frequently */ | |
6498 | 2247 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2248 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 | 2249 break; |
2250 case 0x1c: | |
2251 /* client too old */ | |
6498 | 2252 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2253 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
|
2254 gaim_connection_error(gc, buf); |
2086 | 2255 break; |
2256 default: | |
6623 | 2257 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2258 break; |
2259 } | |
8660 | 2260 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2261 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2262 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2263 "Error URL: %s\n", info->errorurl); |
2086 | 2264 od->killme = TRUE; |
2265 return 1; | |
2266 } | |
2267 | |
2268 | |
9992 | 2269 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2270 |
2704 | 2271 if (info->email) { |
8660 | 2272 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2273 } else { |
8660 | 2274 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2275 } |
10042 | 2276 |
8660 | 2277 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2278 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2279 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2280 aim_conn_kill(sess, &fr->conn); |
2086 | 2281 |
2282 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2283 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2284 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2285 od->killme = TRUE; |
2286 return 0; | |
2287 } | |
2288 | |
4649 | 2289 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2290 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2291 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2292 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2293 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2294 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2295 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2296 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2297 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2298 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2299 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2300 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2301 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2302 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2303 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2304 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2305 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2306 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2307 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2308 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2309 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2310 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2311 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
|
2312 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2313 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2314 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2315 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2316 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2317 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2318 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
|
2319 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
|
2320 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
|
2321 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2322 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2323 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4642 | 2324 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2325 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2326 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2327 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2328 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2329 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2330 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2331 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2332 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2333 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
|
2334 |
7283 | 2335 od->conn = bosconn; |
2704 | 2336 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2337 if (info->bosip[i] == ':') { | |
2338 port = atoi(&(info->bosip[i+1])); | |
2086 | 2339 break; |
2340 } | |
2341 } | |
2704 | 2342 host = g_strndup(info->bosip, i); |
2086 | 2343 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2344 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2345 g_free(host); |
4366 | 2346 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2347 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2348 od->killme = TRUE; |
2349 return 0; | |
2350 } | |
4293 | 2351 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2352 gaim_input_remove(gc->inpa); |
2704 | 2353 |
7283 | 2354 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2355 ck[3] = 0x64; |
7282 | 2356 |
2086 | 2357 return 1; |
2358 } | |
2359 | |
10464 | 2360 static void |
2361 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2362 { | |
2363 GaimConnection *gc = user_data; | |
2364 OscarData *od = gc->proto_data; | |
2365 aim_session_t *sess = od->sess; | |
2366 | |
2367 aim_auth_securid_send(sess, msg); | |
2368 } | |
2369 | |
2370 static void | |
2371 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2372 { | |
2373 GaimConnection *gc = user_data; | |
2374 OscarData *od = gc->proto_data; | |
2375 | |
2376 /* Disconnect */ | |
2377 gc->wants_to_die = TRUE; | |
2378 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2379 od->killme = TRUE; | |
2380 } | |
2381 | |
2382 static int | |
2383 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2384 { | |
2385 GaimConnection *gc = sess->aux_data; | |
2386 GaimAccount *account = gaim_connection_get_account(gc); | |
2387 gchar *primary; | |
2388 | |
2389 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2390 | |
2391 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2392 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2393 _("Enter the 6 digit number from the digital display."), | |
2394 FALSE, FALSE, NULL, | |
2395 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2396 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2397 gc); | |
2398 g_free(primary); | |
2399 | |
2400 return 1; | |
2401 } | |
2402 | |
7285 | 2403 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2404 struct pieceofcrap { |
5575 | 2405 GaimConnection *gc; |
2086 | 2406 unsigned long offset; |
2407 unsigned long len; | |
2408 char *modname; | |
2409 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2410 aim_conn_t *conn; |
2086 | 2411 unsigned int inpa; |
2412 }; | |
2413 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2414 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2415 { |
2416 struct pieceofcrap *pos = data; | |
7283 | 2417 OscarData *od = pos->gc->proto_data; |
2086 | 2418 char in = '\0'; |
2419 int x = 0; | |
2420 unsigned char m[17]; | |
2421 | |
2422 while (read(pos->fd, &in, 1) == 1) { | |
2423 if (in == '\n') | |
2424 x++; | |
2425 else if (in != '\r') | |
2426 x = 0; | |
2427 if (x == 2) | |
2428 break; | |
2429 in = '\0'; | |
2430 } | |
2431 if (in != '\n') { | |
4056 | 2432 char buf[256]; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2433 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
|
2434 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2435 gaim_notify_warning(pos->gc, NULL, |
7422 | 2436 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2437 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2438 gaim_input_remove(pos->inpa); |
2086 | 2439 close(pos->fd); |
2440 g_free(pos); | |
2441 return; | |
2442 } | |
2443 read(pos->fd, m, 16); | |
2444 m[16] = '\0'; | |
8660 | 2445 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2446 for (x = 0; x < 16; x++) |
8660 | 2447 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2448 | |
2449 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2450 gaim_input_remove(pos->inpa); |
2086 | 2451 close(pos->fd); |
2452 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2453 g_free(pos); | |
2454 } | |
2455 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2456 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2457 struct pieceofcrap *pos = data; |
5420 | 2458 gchar *buf; |
2086 | 2459 |
4366 | 2460 pos->fd = source; |
2461 | |
2086 | 2462 if (source < 0) { |
5420 | 2463 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
|
2464 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2465 gaim_notify_warning(pos->gc, NULL, |
7422 | 2466 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2467 buf); |
5420 | 2468 g_free(buf); |
2086 | 2469 if (pos->modname) |
2470 g_free(pos->modname); | |
2471 g_free(pos); | |
2472 return; | |
2473 } | |
2474 | |
5420 | 2475 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2476 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2477 write(pos->fd, buf, strlen(buf)); | |
5420 | 2478 g_free(buf); |
2086 | 2479 if (pos->modname) |
2480 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2481 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2482 return; |
2483 } | |
2484 | |
2485 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2486 #define AIM_MAX_FILE_SIZE 98304 | |
2487 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2488 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2489 va_list ap; |
2490 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2491 fu32_t offset, len; |
2086 | 2492 char *modname; |
2493 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2494 va_start(ap, fr); |
4200 | 2495 offset = va_arg(ap, fu32_t); |
2496 len = va_arg(ap, fu32_t); | |
2086 | 2497 modname = va_arg(ap, char *); |
2498 va_end(ap); | |
2499 | |
8660 | 2500 gaim_debug_misc("oscar", |
5556 | 2501 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2502 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2503 |
2086 | 2504 if (len == 0) { |
8660 | 2505 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2506 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2507 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2508 return 1; | |
2509 } | |
9625 | 2510 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2511 #if 0 | |
2086 | 2512 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2513 char *buf; | |
2514 int i = 8; | |
2515 if (modname) | |
2516 i += strlen(modname); | |
2517 buf = g_malloc(i); | |
2518 i = 0; | |
2519 if (modname) { | |
2520 memcpy(buf, modname, strlen(modname)); | |
2521 i += strlen(modname); | |
2522 } | |
2523 buf[i++] = offset & 0xff; | |
2524 buf[i++] = (offset >> 8) & 0xff; | |
2525 buf[i++] = (offset >> 16) & 0xff; | |
2526 buf[i++] = (offset >> 24) & 0xff; | |
2527 buf[i++] = len & 0xff; | |
2528 buf[i++] = (len >> 8) & 0xff; | |
2529 buf[i++] = (len >> 16) & 0xff; | |
2530 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2531 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2532 "hashing request\n"); |
2086 | 2533 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2534 g_free(buf); | |
2535 return 1; | |
2536 } | |
9625 | 2537 #endif |
2086 | 2538 |
2539 pos = g_new0(struct pieceofcrap, 1); | |
2540 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2541 pos->conn = fr->conn; |
2086 | 2542 |
2543 pos->offset = offset; | |
2544 pos->len = len; | |
2545 pos->modname = modname ? g_strdup(modname) : NULL; | |
2546 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2547 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2548 char buf[256]; |
2086 | 2549 if (pos->modname) |
2550 g_free(pos->modname); | |
2551 g_free(pos); | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2552 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
|
2553 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2554 gaim_notify_warning(pos->gc, NULL, |
7422 | 2555 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2556 buf); |
2086 | 2557 } |
2558 | |
2559 return 1; | |
2560 } | |
2561 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2562 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2563 GaimConnection *gc = sess->aux_data; |
7283 | 2564 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2565 GaimAccount *account = gaim_connection_get_account(gc); |
7282 | 2566 #if 0 |
2567 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2568 #endif | |
7011 | 2569 va_list ap; |
2570 char *key; | |
2086 | 2571 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2572 va_start(ap, fr); |
2086 | 2573 key = va_arg(ap, char *); |
2574 va_end(ap); | |
2575 | |
4617 | 2576 if (od->icq) { |
3458 | 2577 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
10740 | 2578 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2579 gaim_connection_get_password(gc), &info, key); | |
3458 | 2580 } else { |
2581 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
10740 | 2582 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2583 gaim_connection_get_password(gc), &info, key); | |
3458 | 2584 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2585 |
7283 | 2586 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2587 ck[2] = 0x6c; |
7282 | 2588 |
2086 | 2589 return 1; |
2590 } | |
2591 | |
2675 | 2592 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2593 GaimConnection *gc = sess->aux_data; |
2647 | 2594 struct chat_connection *chatcon; |
2595 static int id = 1; | |
2596 | |
6905 | 2597 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
|
2598 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
|
2599 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
|
2600 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
|
2601 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2602 |
2672 | 2603 aim_clientready(sess, fr->conn); |
2675 | 2604 |
2647 | 2605 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2606 chatcon->id = id; | |
8733 | 2607 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2608 |
2609 return 1; | |
2610 } | |
2611 | |
2675 | 2612 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2613 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2614 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2615 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2616 |
2617 aim_clientready(sess, fr->conn); | |
2618 | |
2619 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2620 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2621 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2622 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2623 |
3694 | 2624 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2625 | |
2626 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2627 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2628 | |
7282 | 2629 aim_email_sendcookies(sess); |
2630 aim_email_activate(sess); | |
3694 | 2631 aim_clientready(sess, fr->conn); |
2632 | |
2633 return 1; | |
2634 } | |
2635 | |
4804 | 2636 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2637 GaimConnection *gc = sess->aux_data; |
7283 | 2638 OscarData *od = gc->proto_data; |
4804 | 2639 |
2640 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2641 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2642 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2643 | |
2644 aim_clientready(sess, fr->conn); | |
2645 | |
4823 | 2646 od->iconconnecting = FALSE; |
2647 | |
4804 | 2648 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2649 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2650 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2651 |
2652 return 1; | |
2653 } | |
2654 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2655 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2656 GaimConnection *gc = data; |
7283 | 2657 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2658 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2659 aim_conn_t *tstconn; |
2086 | 2660 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2661 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2662 close(source); |
2663 return; | |
2664 } | |
2665 | |
4617 | 2666 od = gc->proto_data; |
2667 sess = od->sess; | |
2086 | 2668 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2669 tstconn->fd = source; |
2086 | 2670 |
2671 if (source < 0) { | |
2672 aim_conn_kill(sess, &tstconn); | |
8660 | 2673 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2674 "unable to connect to chatnav server\n"); |
2086 | 2675 return; |
2676 } | |
2677 | |
2678 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2679 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2680 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2681 } |
2682 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2683 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2684 { |
5575 | 2685 GaimConnection *gc = data; |
7283 | 2686 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2687 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2688 aim_conn_t *tstconn; |
2086 | 2689 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2690 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2691 close(source); |
2692 return; | |
2693 } | |
2694 | |
4617 | 2695 od = gc->proto_data; |
2696 sess = od->sess; | |
2086 | 2697 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2698 tstconn->fd = source; |
2086 | 2699 |
2700 if (source < 0) { | |
2701 aim_conn_kill(sess, &tstconn); | |
8660 | 2702 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2703 "unable to connect to authorizer\n"); |
2086 | 2704 return; |
2705 } | |
2706 | |
2707 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2708 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2709 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2710 } |
2711 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2712 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2713 { |
2714 struct chat_connection *ccon = data; | |
5575 | 2715 GaimConnection *gc = ccon->gc; |
7283 | 2716 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2717 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2718 aim_conn_t *tstconn; |
2086 | 2719 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2720 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2721 close(source); |
2722 g_free(ccon->show); | |
2723 g_free(ccon->name); | |
2724 g_free(ccon); | |
2725 return; | |
2726 } | |
2727 | |
4617 | 2728 od = gc->proto_data; |
2729 sess = od->sess; | |
2086 | 2730 tstconn = ccon->conn; |
4366 | 2731 tstconn->fd = source; |
2086 | 2732 |
2733 if (source < 0) { | |
2734 aim_conn_kill(sess, &tstconn); | |
2735 g_free(ccon->show); | |
2736 g_free(ccon->name); | |
2737 g_free(ccon); | |
2738 return; | |
2739 } | |
2740 | |
2741 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2742 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2743 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2744 } |
2745 | |
3694 | 2746 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2747 GaimConnection *gc = data; |
7283 | 2748 OscarData *od; |
3694 | 2749 aim_session_t *sess; |
2750 aim_conn_t *tstconn; | |
2751 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2752 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2753 close(source); |
2754 return; | |
2755 } | |
2756 | |
4617 | 2757 od = gc->proto_data; |
2758 sess = od->sess; | |
3694 | 2759 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2760 tstconn->fd = source; |
3694 | 2761 |
2762 if (source < 0) { | |
2763 aim_conn_kill(sess, &tstconn); | |
8660 | 2764 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2765 "unable to connect to email server\n"); |
3694 | 2766 return; |
2767 } | |
2768 | |
2769 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2770 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2771 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2772 "email: connected\n"); |
3694 | 2773 } |
2774 | |
4804 | 2775 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2776 GaimConnection *gc = data; |
7283 | 2777 OscarData *od; |
4804 | 2778 aim_session_t *sess; |
2779 aim_conn_t *tstconn; | |
2780 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2781 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2782 close(source); |
2783 return; | |
2784 } | |
2785 | |
2786 od = gc->proto_data; | |
2787 sess = od->sess; | |
2788 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2789 tstconn->fd = source; | |
2790 | |
2791 if (source < 0) { | |
2792 aim_conn_kill(sess, &tstconn); | |
8660 | 2793 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2794 "unable to connect to icon server\n"); |
4804 | 2795 return; |
2796 } | |
2797 | |
2798 aim_conn_completeconnect(sess, tstconn); | |
2799 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2800 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2801 } |
2802 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2803 /* 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
|
2804 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2805 GaimConnection *gc = sess->aux_data; |
2806 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2807 aim_conn_t *tstconn; |
4452 | 2808 int i; |
2086 | 2809 char *host; |
2810 int port; | |
4821 | 2811 va_list ap; |
2812 struct aim_redirect_data *redir; | |
2086 | 2813 |
5575 | 2814 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2815 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2816 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2817 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2818 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2819 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2820 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2821 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2822 port = atoi(&(redir->ip[i+1])); |
2086 | 2823 break; |
2824 } | |
2825 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2826 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2827 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2828 switch(redir->group) { |
2086 | 2829 case 0x7: /* Authorizer */ |
8660 | 2830 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2831 "Reconnecting with authorizor...\n"); |
2086 | 2832 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2833 if (tstconn == NULL) { | |
8660 | 2834 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2835 "unable to reconnect with authorizer\n"); |
2086 | 2836 g_free(host); |
2837 return 1; | |
2838 } | |
4649 | 2839 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2840 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2841 |
2842 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2843 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2844 aim_conn_kill(sess, &tstconn); |
8660 | 2845 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2846 "unable to reconnect with authorizer\n"); |
2086 | 2847 g_free(host); |
2848 return 1; | |
2849 } | |
4293 | 2850 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2851 break; |
2852 | |
2086 | 2853 case 0xd: /* ChatNav */ |
2854 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2855 if (tstconn == NULL) { | |
8660 | 2856 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2857 "unable to connect to chatnav server\n"); |
2086 | 2858 g_free(host); |
2859 return 1; | |
2860 } | |
4649 | 2861 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2862 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2863 |
2864 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2865 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2866 aim_conn_kill(sess, &tstconn); |
8660 | 2867 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2868 "unable to connect to chatnav server\n"); |
2086 | 2869 g_free(host); |
2870 return 1; | |
2871 } | |
4293 | 2872 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2873 break; |
2874 | |
2875 case 0xe: { /* Chat */ | |
2086 | 2876 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2877 |
2086 | 2878 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2879 if (tstconn == NULL) { | |
8660 | 2880 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2881 "unable to connect to chat server\n"); |
2086 | 2882 g_free(host); |
2883 return 1; | |
2884 } | |
2885 | |
4649 | 2886 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2887 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2888 | |
2086 | 2889 ccon = g_new0(struct chat_connection, 1); |
2890 ccon->conn = tstconn; | |
2891 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2892 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2893 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2894 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2895 ccon->show = extract_name(redir->chat.room); |
4634 | 2896 |
2086 | 2897 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2898 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2899 aim_conn_kill(sess, &tstconn); |
8660 | 2900 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2901 "unable to connect to chat server\n"); |
2086 | 2902 g_free(host); |
2903 g_free(ccon->show); | |
2904 g_free(ccon->name); | |
2905 g_free(ccon); | |
2906 return 1; | |
2907 } | |
4293 | 2908 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2909 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2910 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2911 ccon->name, ccon->exchange); |
4194 | 2912 } break; |
3694 | 2913 |
4804 | 2914 case 0x0010: { /* icon */ |
2915 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2916 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2917 "unable to connect to icon server\n"); |
4804 | 2918 g_free(host); |
2919 return 1; | |
2920 } | |
2921 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2922 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2923 | |
2924 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2925 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2926 aim_conn_kill(sess, &tstconn); |
8660 | 2927 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2928 "unable to connect to icon server\n"); |
4804 | 2929 g_free(host); |
2930 return 1; | |
2931 } | |
2932 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2933 } break; | |
2934 | |
3694 | 2935 case 0x0018: { /* email */ |
2936 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2937 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2938 "unable to connect to email server\n"); |
3694 | 2939 g_free(host); |
2940 return 1; | |
2941 } | |
4649 | 2942 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2943 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2944 | |
2945 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2946 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2947 aim_conn_kill(sess, &tstconn); |
8660 | 2948 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2949 "unable to connect to email server\n"); |
3694 | 2950 g_free(host); |
2951 return 1; | |
2952 } | |
4293 | 2953 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2954 } break; |
2955 | |
2086 | 2956 default: /* huh? */ |
8660 | 2957 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2958 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2959 redir->group); |
2086 | 2960 break; |
2961 } | |
2962 | |
2963 g_free(host); | |
2964 return 1; | |
2965 } | |
2966 | |
10042 | 2967 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
2968 { | |
2969 GaimConnection *gc; | |
2970 GaimAccount *account; | |
2971 OscarData *od; | |
4738 | 2972 struct buddyinfo *bi; |
2993 | 2973 time_t time_idle = 0, signon = 0; |
2974 int type = 0; | |
2975 int caps = 0; | |
2086 | 2976 va_list ap; |
4738 | 2977 aim_userinfo_t *info; |
10042 | 2978 gboolean buddy_is_away = FALSE; |
2979 | |
2980 gc = sess->aux_data; | |
2981 account = gaim_connection_get_account(gc); | |
2982 od = gc->proto_data; | |
4194 | 2983 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2984 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2985 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2986 va_end(ap); |
2987 | |
10130 | 2988 g_return_val_if_fail(info != NULL, 1); |
2989 g_return_val_if_fail(info->sn != NULL, 1); | |
2990 | |
2993 | 2991 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2992 caps = info->capabilities; | |
3267 | 2993 |
4766 | 2994 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2995 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 2996 buddy_is_away = TRUE; |
2997 } | |
2998 | |
2993 | 2999 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 3000 type = (info->icqinfo.status << 16); |
3013 | 3001 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3002 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3003 buddy_is_away = TRUE; |
3013 | 3004 } |
2993 | 3005 } |
3006 | |
7141 | 3007 if (caps & AIM_CAPS_ICQ_DIRECT) |
3008 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 3009 |
10860 | 3010 /* info->idletime is the number of minutes that this user has been idle */ |
3011 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
3012 time_idle = time(NULL) - info->idletime * 60; | |
2993 | 3013 |
5836 | 3014 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3015 signon = info->onlinesince; | |
3016 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3017 signon = time(NULL) - info->sessionlen; |
2086 | 3018 |
10567 | 3019 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3020 gaim_connection_set_display_name(gc, info->sn); |
10567 | 3021 od->timeoffset = signon - gc->login_time; |
3022 } | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
3023 |
9982 | 3024 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3025 if (!bi) { |
3026 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3027 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3028 } |
4739 | 3029 bi->typingnot = FALSE; |
3030 bi->ico_informed = FALSE; | |
6857 | 3031 bi->ipaddr = info->icqinfo.ipaddr; |
3032 | |
10563 | 3033 /* |
3034 * Handle the available message. If info->avail is NULL then the user | |
3035 * may or may not have an available message, so don't do anything. If | |
3036 * info->avail is set to the empty string, then the user's client DOES | |
3037 * support available messages and the user DOES NOT have one set. | |
3038 * Otherwise info->avail contains the available message. | |
3039 */ | |
7011 | 3040 if (info->avail != NULL) |
10563 | 3041 { |
3042 free(bi->availmsg); | |
3043 if (info->avail[0] != '\0') | |
3044 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); | |
3045 else | |
3046 bi->availmsg = NULL; | |
3047 } | |
4732 | 3048 |
4804 | 3049 /* Server stored icon stuff */ |
4853 | 3050 if (info->iconcsumlen) { |
7125 | 3051 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3052 char *b16 = NULL, *filepath = NULL; |
7093 | 3053 GaimBuddy *b = NULL; |
4853 | 3054 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3055 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3056 b = gaim_find_buddy(account, info->sn); |
7093 | 3057 /* |
3058 * If for some reason the checksum is valid, but cached file is not.. | |
3059 * we want to know. | |
3060 */ | |
7693 | 3061 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3062 if (filename != NULL) { |
3063 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3064 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3065 "icon_checksum"); | |
9801 | 3066 else { |
3067 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3068 filename, NULL); | |
3069 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3070 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3071 "icon_checksum"); | |
3072 g_free(filepath); | |
3073 } | |
7093 | 3074 } else |
3075 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3076 |
4853 | 3077 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3078 GSList *cur = od->requesticon; | |
3079 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3080 cur = cur->next; | |
3081 if (!cur) { | |
9982 | 3082 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3083 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3084 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3085 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3086 } |
3087 } | |
6053 | 3088 g_free(b16); |
4853 | 3089 } |
3090 | |
10042 | 3091 /* XXX - Represent other ICQ statuses */ |
3092 if (buddy_is_away == TRUE) | |
3093 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
3094 else | |
3095 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
10567 | 3096 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
9982 | 3097 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); |
3098 | |
3099 if (time_idle > 0) | |
3100 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 3101 else |
3102 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 3103 |
3104 return 1; | |
3105 } | |
3106 | |
8341 | 3107 static void gaim_check_comment(OscarData *od, const char *str) { |
3108 if ((str == NULL) || strcmp(str, ck)) | |
3109 aim_locate_setcaps(od->sess, caps_aim); | |
3110 else | |
3111 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3112 } | |
3113 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3114 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3115 GaimConnection *gc = sess->aux_data; |
7283 | 3116 OscarData *od = gc->proto_data; |
9982 | 3117 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3118 va_list ap; |
4739 | 3119 aim_userinfo_t *info; |
2086 | 3120 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3121 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3122 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3123 va_end(ap); |
3124 | |
9982 | 3125 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3126 |
7261 | 3127 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3128 |
2086 | 3129 return 1; |
3130 } | |
3131 | |
4617 | 3132 /* BBB */ |
3952 | 3133 /* |
4617 | 3134 * This is called after a remote AIM user has connected to us. We |
3135 * want to do some voodoo with the socket file descriptors, add a | |
3136 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3137 */ |
4656 | 3138 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3139 GaimConnection *gc = sess->aux_data; |
7283 | 3140 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3141 GaimXfer *xfer; |
5146 | 3142 struct aim_oft_info *oft_info; |
3630 | 3143 va_list ap; |
3144 aim_conn_t *conn, *listenerconn; | |
4656 | 3145 |
8660 | 3146 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3147 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3148 va_start(ap, fr); |
3149 conn = va_arg(ap, aim_conn_t *); | |
3150 listenerconn = va_arg(ap, aim_conn_t *); | |
3151 va_end(ap); | |
3152 | |
4617 | 3153 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3154 return 1; | |
3155 | |
5146 | 3156 if (!(oft_info = xfer->data)) |
4617 | 3157 return 1; |
3158 | |
3630 | 3159 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3160 gaim_input_remove(xfer->watcher); |
3630 | 3161 aim_conn_kill(sess, &listenerconn); |
3162 | |
5146 | 3163 oft_info->conn = conn; |
3164 xfer->fd = oft_info->conn->fd; | |
3165 | |
3166 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3167 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3168 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3169 |
3170 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3171 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3172 |
3173 return 0; | |
3174 } | |
3175 | |
3952 | 3176 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3177 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3178 * user in order to transfer a file. |
3952 | 3179 */ |
4617 | 3180 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
|
3181 GaimXfer *xfer; |
5146 | 3182 struct aim_oft_info *oft_info; |
4656 | 3183 |
8660 | 3184 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3185 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3186 if (!(xfer = data)) |
3187 return; | |
5146 | 3188 if (!(oft_info = xfer->data)) |
3630 | 3189 return; |
8446 | 3190 if (source < 0) { |
3191 gaim_xfer_cancel_remote(xfer); | |
4617 | 3192 return; |
8446 | 3193 } |
4617 | 3194 |
3195 xfer->fd = source; | |
5146 | 3196 oft_info->conn->fd = source; |
3197 | |
3198 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3199 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3200 |
3201 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3202 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3203 |
3204 return; | |
3630 | 3205 } |
3206 | |
3952 | 3207 /* |
4617 | 3208 * This is called when a buddy sends us some file info. This happens when they |
3209 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3210 * You should send them the exact same info except use the real cookie. We also |
4617 | 3211 * get like totally ready to like, receive the file, kay? |
3952 | 3212 */ |
4617 | 3213 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3214 GaimConnection *gc = sess->aux_data; |
7283 | 3215 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3216 GaimXfer *xfer; |
5146 | 3217 struct aim_oft_info *oft_info; |
4617 | 3218 va_list ap; |
3219 aim_conn_t *conn; | |
3220 fu8_t *cookie; | |
3221 struct aim_fileheader_t *fh; | |
4656 | 3222 |
8660 | 3223 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3224 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3225 va_start(ap, fr); |
3226 conn = va_arg(ap, aim_conn_t *); | |
3227 cookie = va_arg(ap, fu8_t *); | |
3228 fh = va_arg(ap, struct aim_fileheader_t *); | |
3229 va_end(ap); | |
3230 | |
3231 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3232 return 1; | |
3233 | |
5146 | 3234 if (!(oft_info = xfer->data)) |
4617 | 3235 return 1; |
3236 | |
3237 /* We want to stop listening with a normal thingy */ | |
3238 gaim_input_remove(xfer->watcher); | |
3239 xfer->watcher = 0; | |
3240 | |
5146 | 3241 /* They sent us some information about the file they're sending */ |
3242 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3243 | |
3244 /* Fill in the cookie */ | |
3245 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3246 | |
4617 | 3247 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3248 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3249 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3250 | |
3251 return 0; | |
3630 | 3252 } |
3253 | |
3952 | 3254 /* |
4657 | 3255 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3256 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3257 */ |
4617 | 3258 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3259 GaimConnection *gc = sess->aux_data; |
7283 | 3260 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3261 GaimXfer *xfer; |
4617 | 3262 va_list ap; |
3263 aim_conn_t *conn; | |
3264 fu8_t *cookie; | |
3265 struct aim_fileheader_t *fh; | |
4656 | 3266 |
8660 | 3267 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3268 va_start(ap, fr); |
3269 conn = va_arg(ap, aim_conn_t *); | |
3270 cookie = va_arg(ap, fu8_t *); | |
3271 fh = va_arg(ap, struct aim_fileheader_t *); | |
3272 va_end(ap); | |
3273 | |
3274 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3275 return 1; | |
3276 | |
4656 | 3277 /* We want to stop listening with a normal thingy */ |
3278 gaim_input_remove(xfer->watcher); | |
3279 xfer->watcher = 0; | |
3280 | |
4617 | 3281 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3282 | |
3283 return 0; | |
3630 | 3284 } |
4617 | 3285 |
3286 /* | |
3287 * We just sent a file to someone. They said they got it and everything, | |
3288 * so we can close our direct connection and what not. | |
3289 */ | |
3290 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3291 GaimConnection *gc = sess->aux_data; |
7283 | 3292 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3293 GaimXfer *xfer; |
4617 | 3294 va_list ap; |
3295 aim_conn_t *conn; | |
3296 fu8_t *cookie; | |
3297 struct aim_fileheader_t *fh; | |
4656 | 3298 |
8660 | 3299 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3300 va_start(ap, fr); |
3301 conn = va_arg(ap, aim_conn_t *); | |
3302 cookie = va_arg(ap, fu8_t *); | |
3303 fh = va_arg(ap, struct aim_fileheader_t *); | |
3304 va_end(ap); | |
3305 | |
3306 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3307 return 1; | |
3308 | |
4656 | 3309 xfer->fd = conn->fd; |
4617 | 3310 gaim_xfer_end(xfer); |
3311 | |
3312 return 0; | |
3313 } | |
3630 | 3314 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3315 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3316 GaimConnection *gc = sess->aux_data; |
7283 | 3317 OscarData *od = gc->proto_data; |
8708 | 3318 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3319 GaimConvImFlags flags = 0; |
4738 | 3320 struct buddyinfo *bi; |
5575 | 3321 const char *iconfile; |
9806 | 3322 GString *message; |
3323 gchar *tmp; | |
3324 aim_mpmsg_section_t *curpart; | |
3325 | |
10472 | 3326 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3327 userinfo->sn, args->mpmsg.numparts); |
4738 | 3328 |
10595 | 3329 if (args->mpmsg.numparts == 0) |
3330 return 1; | |
3331 | |
8708 | 3332 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3333 if (!bi) { |
3334 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3335 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3336 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3337 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3338 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3339 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3340 |
4738 | 3341 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3342 bi->typingnot = TRUE; | |
3343 else | |
3344 bi->typingnot = FALSE; | |
3345 | |
4380 | 3346 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3347 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3348 "%s has an icon\n", userinfo->sn); |
4738 | 3349 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3350 bi->ico_need = TRUE; | |
3351 bi->ico_len = args->iconlen; | |
3352 bi->ico_csum = args->iconsum; | |
3353 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3354 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3355 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3356 |
10458 | 3357 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3358 (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
|
3359 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3360 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3361 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3362 if (!g_stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3363 char *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3364 file = g_fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3365 if (file) { |
9532 | 3366 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3367 int len = fread(buf, 1, st.st_size, file); |
8660 | 3368 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3369 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3370 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3371 userinfo->sn, len, st.st_size); |
4617 | 3372 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3373 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3374 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3375 } else |
8660 | 3376 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3377 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3378 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3379 } else |
8660 | 3380 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3381 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3382 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3383 |
9806 | 3384 message = g_string_new(""); |
3385 curpart = args->mpmsg.parts; | |
3386 while (curpart != NULL) { | |
9908 | 3387 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3388 curpart->data, curpart->datalen); |
3389 if (tmp != NULL) { | |
3390 g_string_append(message, tmp); | |
3391 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3392 } |
9806 | 3393 |
3394 curpart = curpart->next; | |
3395 } | |
3396 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3397 |
8666 | 3398 /* |
10781 | 3399 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
9016 | 3400 * because HTML is not sent over ICQ as a means to format a message. |
10781 | 3401 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
3402 * replaced with <br> | |
8995 | 3403 * |
3404 * Note: There *may* be some clients which send messages as HTML formatted - | |
3405 * they need to be special-cased somehow. | |
8666 | 3406 */ |
9982 | 3407 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3408 /* 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
|
3409 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
8493 | 3410 g_free(tmp); |
3411 tmp = tmp2; | |
10783 | 3412 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
10781 | 3413 g_free(tmp); |
3414 tmp = tmp2; | |
8493 | 3415 } |
3416 | |
6982 | 3417 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3418 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3419 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3420 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3421 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3422 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3423 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3424 GaimConnection *gc; |
9933 | 3425 GaimAccount *account; |
9070 | 3426 OscarData *od; |
9933 | 3427 const char *username = NULL; |
3428 char *message = NULL; | |
9070 | 3429 |
3430 g_return_val_if_fail(sess != NULL, 0); | |
3431 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3432 | |
3433 gc = sess->aux_data; | |
9933 | 3434 account = gaim_connection_get_account(gc); |
9070 | 3435 od = gc->proto_data; |
9933 | 3436 username = gaim_account_get_username(account); |
3437 | |
3438 if (args == NULL) | |
4121 | 3439 return 0; |
4194 | 3440 |
9933 | 3441 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3442 userinfo->sn, args->status); | |
3443 | |
3444 if (args->msg != NULL) | |
3445 { | |
3446 if (args->encoding != NULL) | |
3447 { | |
3448 char *encoding = NULL; | |
3449 encoding = oscar_encoding_extract(args->encoding); | |
3450 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3451 g_free(encoding); | |
3452 } else { | |
3453 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3454 message = g_strdup(args->msg); | |
3455 } | |
3456 } | |
2869 | 3457 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3458 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3459 char *name; |
5234 | 3460 GHashTable *components; |
3461 | |
9933 | 3462 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3463 g_free(message); | |
4121 | 3464 return 1; |
9933 | 3465 } |
5234 | 3466 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3467 g_free); | |
4121 | 3468 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3469 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3470 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
|
3471 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3472 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3473 userinfo->sn, |
9933 | 3474 message, |
5234 | 3475 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3476 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3477 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3478 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3479 /* BBB */ |
3480 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3481 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3482 GaimXfer *xfer; |
5146 | 3483 struct aim_oft_info *oft_info; |
3484 | |
3485 if (!args->cookie || !args->port || !args->verifiedip || | |
3486 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3487 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3488 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3489 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3490 "information.\n", userinfo->sn); |
5146 | 3491 if (args->proxyip) |
8660 | 3492 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3493 "IP for a proxy server was given. Gaim " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3494 "does not support this yet.\n"); |
9933 | 3495 g_free(message); |
4617 | 3496 return 1; |
4656 | 3497 } |
4617 | 3498 |
3499 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3500 /* 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
|
3501 * directory -- remove the star and trailing slash so we don't save |
4617 | 3502 * directories that look like 'dirname\*' -- arl */ |
3503 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3504 if (tmp && (tmp[1] == '*')) { | |
3505 tmp[0] = '\0'; | |
3506 } | |
8660 | 3507 gaim_debug_warning("oscar", |
8446 | 3508 "We're receiving a whole directory! What fun! " |
3509 "Especially since we don't support that!\n"); | |
4617 | 3510 } |
3511 | |
3512 /* Build the file transfer handle */ | |
3513 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3514 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3515 xfer->remote_port = args->port; |
4617 | 3516 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3517 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3518 gaim_xfer_set_message(xfer, message); |
5146 | 3519 |
3520 /* Create the oscar-specific data */ | |
5163 | 3521 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3522 if (args->proxyip) |
5146 | 3523 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3524 if (args->verifiedip) |
5146 | 3525 oft_info->verifiedip = g_strdup(args->verifiedip); |
3526 xfer->data = oft_info; | |
4617 | 3527 |
3528 /* Setup our I/O op functions */ | |
8446 | 3529 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3530 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3531 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
|
3532 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3533 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3534 |
3535 /* Keep track of this transfer for later */ | |
3536 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3537 | |
3538 /* Now perform the request */ | |
3539 gaim_xfer_request(xfer); | |
3540 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3541 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3542 GaimXfer *xfer; |
8660 | 3543 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3544 "AAA - File transfer canceled by remote user\n"); |
4617 | 3545 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
|
3546 gaim_xfer_cancel_remote(xfer); |
4617 | 3547 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3548 /* | |
3549 * This gets sent by the receiver of a file | |
3550 * as they connect directly to us. If we don't | |
3551 * get this, then maybe a third party connected | |
3552 * to us, and we shouldn't send them anything. | |
3553 */ | |
3554 } else { | |
8660 | 3555 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3556 "unknown rendezvous status!\n"); |
3630 | 3557 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3558 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3559 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3560 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3561 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3562 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3563 args->info.icon.length); |
6871 | 3564 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3565 /* 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
|
3566 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3567 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
|
3568 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3569 |
4212 | 3570 if (!args->verifiedip) { |
8983 | 3571 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3572 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3573 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3574 g_free(message); |
4650 | 3575 return 1; |
4212 | 3576 } |
3577 | |
8660 | 3578 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3579 "%s received direct im request from %s (%s)\n", |
10594 | 3580 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3581 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3582 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3583 d->sn = g_strdup(userinfo->sn); |
8983 | 3584 /* Let's use the clientip here, because I think that's what AIM does. |
3585 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3586 * and then ask them to connect to us. */ | |
10594 | 3587 /* |
3588 * I disagree, let's use the verifiedip. I think AIM tries the | |
3589 * verified IP first, then tries the client IP if that fails. In | |
3590 * any case, there's a better chance the verified IP will be correct. | |
3591 * The client IP is what the other person _thinks_ their IP address | |
3592 * is. The verified IP is the address that the AIM server sees the | |
3593 * other person using. | |
3594 */ | |
3595 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
|
3596 memcpy(d->cookie, args->cookie, 8); |
9070 | 3597 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3598 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3599 | |
8971 | 3600 oscar_direct_im_destroy(od, dim); |
8984 | 3601 d->donttryagain = TRUE; |
8971 | 3602 accept_direct_im_request(d); |
3603 } else { | |
8983 | 3604 if (dim && !dim->connected) |
8971 | 3605 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3606 "already connected to that buddy!"); | |
5575 | 3607 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
|
3608 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3609 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3610 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3611 "the two computers and is necessary for IM " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3612 "Images. Because your IP address will be " |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3613 "revealed, this may be considered a privacy " |
9972 | 3614 "risk."), |
3615 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3616 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3617 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3618 /* FIXME: we should actually send a packet on cancel */ | |
3619 } | |
8708 | 3620 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3621 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
|
3622 } else { |
8660 | 3623 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3624 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3625 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3626 |
9933 | 3627 g_free(message); |
3628 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3629 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3630 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3631 |
3453 | 3632 /* |
4230 | 3633 * Authorization Functions |
3634 * Most of these are callbacks from dialogs. They're used by both | |
3635 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3636 */ |
4269 | 3637 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3638 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3639 GaimConnection *gc = data->gc; |
4244 | 3640 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3641 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3642 OscarData *od = gc->proto_data; |
6695 | 3643 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3644 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3645 if (buddy && group) { |
8660 | 3646 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3647 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3648 buddy->name, group->name); |
4889 | 3649 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3650 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3651 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3652 } |
4230 | 3653 } |
4337 | 3654 } |
3655 | |
3656 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3657 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3658 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3659 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3660 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3661 data); |
4230 | 3662 } |
3663 | |
3664 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3665 GaimConnection *gc = data->gc; |
4244 | 3666 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3667 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3668 /* Remove from local list */ |
3669 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3670 gaim_blist_remove_buddy(b); | |
4244 | 3671 } |
3672 | |
5836 | 3673 oscar_free_name_data(data); |
4230 | 3674 } |
3675 | |
9030 | 3676 |
3677 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3678 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3679 GaimBuddy *buddy; |
4269 | 3680 gchar *dialog_msg, *nombre; |
3681 | |
4687 | 3682 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3683 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3684 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3685 else |
4830 | 3686 nombre = NULL; |
3687 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3688 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 | 3689 data->gc = gc; |
3690 data->name = g_strdup(name); | |
3691 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3692 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3693 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3694 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3695 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3696 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3697 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3698 |
3699 g_free(dialog_msg); | |
3700 g_free(nombre); | |
3701 } | |
3702 | |
9030 | 3703 |
3704 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3705 GaimBuddy *buddy; | |
3706 GaimConnection *gc; | |
3707 | |
3708 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3709 | |
3710 buddy = (GaimBuddy *) node; | |
3711 gc = gaim_account_get_connection(buddy->account); | |
3712 gaim_auth_sendrequest(gc, buddy->name); | |
3713 } | |
3714 | |
4230 | 3715 /* When other people ask you for authorization */ |
3716 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3717 GaimConnection *gc = data->gc; |
4244 | 3718 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3719 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3720 OscarData *od = gc->proto_data; |
4889 | 3721 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4244 | 3722 } |
3723 | |
5836 | 3724 oscar_free_name_data(data); |
3141 | 3725 } |
3726 | |
4230 | 3727 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3728 static void gaim_auth_dontgrant(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; |
4889 | 3733 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4244 | 3734 } |
4337 | 3735 } |
3736 | |
3737 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3738 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3739 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3740 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3741 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3742 data); |
3141 | 3743 } |
3744 | |
7023 | 3745 /* When someone sends you buddies */ |
3746 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3747 GaimConnection *gc = data->gc; |
4244 | 3748 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3749 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3750 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3751 } |
3752 | |
5836 | 3753 oscar_free_name_data(data); |
3453 | 3754 } |
3755 | |
4075 | 3756 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 | 3757 GaimConnection *gc = sess->aux_data; |
9908 | 3758 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3759 gchar **msg1, **msg2; |
6051 | 3760 int i, numtoks; |
4076 | 3761 |
4121 | 3762 if (!args->type || !args->msg || !args->uin) |
3763 return 1; | |
4194 | 3764 |
8660 | 3765 gaim_debug_info("oscar", |
9908 | 3766 "Received a channel 4 message of type 0x%02hhx.\n", |
3767 args->type); | |
4076 | 3768 |
9919 | 3769 /* |
3770 * Split up the message at the delimeter character, then convert each | |
3771 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3772 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3773 * character in whatever encoding the message was sent in. Type 1 | |
3774 * messages are always made up of only one part, so we can easily account | |
3775 * for this suck-ass part of the protocol by splitting the string into at | |
3776 * most 1 baby string. | |
3777 */ | |
3778 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3779 for (numtoks=0; msg1[numtoks]; numtoks++); |
3780 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3781 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3782 gaim_str_strip_cr(msg1[i]); |
9908 | 3783 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3784 } |
3785 msg2[i] = NULL; | |
3786 | |
3952 | 3787 switch (args->type) { |
4173 | 3788 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3789 if (i >= 1) { |
5556 | 3790 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3791 gchar *tmp; |
3792 | |
3793 /* 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
|
3794 tmp = g_markup_escape_text(msg2[0], -1); |
8493 | 3795 |
4076 | 3796 if (t) { /* This is an offline message */ |
9680 | 3797 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3798 #ifdef HAVE_TM_GMTOFF |
9724 | 3799 time_t now; |
3800 struct tm *tm; | |
3801 now = time(NULL); | |
3802 tm = localtime(&now); | |
3803 t += tm->tm_gmtoff; | |
9698 | 3804 #else |
3805 # ifdef HAVE_TIMEZONE | |
9680 | 3806 tzset(); |
3807 t -= timezone; | |
9698 | 3808 # endif |
3809 #endif | |
8514 | 3810 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3811 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3812 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3813 } |
3814 g_free(uin); | |
8493 | 3815 g_free(tmp); |
4075 | 3816 } |
3316 | 3817 } break; |
3818 | |
4173 | 3819 case 0x04: { /* Someone sent you a URL */ |
4076 | 3820 if (i >= 2) { |
7385 | 3821 if (msg2[1] != NULL) { |
3822 gchar *uin = g_strdup_printf("%u", args->uin); | |
3823 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3824 msg2[1], | |
3825 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3826 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3827 g_free(uin); | |
3828 g_free(message); | |
3829 } | |
3453 | 3830 } |
3831 } break; | |
3832 | |
4173 | 3833 case 0x06: { /* Someone requested authorization */ |
4076 | 3834 if (i >= 6) { |
4230 | 3835 struct name_data *data = g_new(struct name_data, 1); |
10949 | 3836 gchar *dialog_msg = g_strdup_printf( |
3837 _("The user %u wants to add %s to their buddy list for the following reason:\n%s"), | |
3838 args->uin, gaim_account_get_username(gc->account), | |
3839 (msg2[5] ? msg2[5] : _("No reason given."))); | |
8660 | 3840 gaim_debug_info("oscar", |
5556 | 3841 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3842 args->uin); |
4076 | 3843 data->gc = gc; |
5556 | 3844 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3845 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3846 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3847 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3848 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3849 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3850 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3851 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3852 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3853 g_free(dialog_msg); |
3854 } | |
3141 | 3855 } break; |
3856 | |
4173 | 3857 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3858 if (i >= 1) { |
7023 | 3859 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
|
3860 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3861 dialog_msg); |
4076 | 3862 g_free(dialog_msg); |
3863 } | |
3141 | 3864 } break; |
3865 | |
4173 | 3866 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3867 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
|
3868 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3869 dialog_msg); |
3141 | 3870 g_free(dialog_msg); |
3871 } break; | |
3872 | |
4333 | 3873 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3874 if (i >= 5) { | |
3875 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
|
3876 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3877 g_free(dialog_msg); |
3878 } | |
3879 } break; | |
3880 | |
4173 | 3881 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3882 if (i >= 6) { |
4194 | 3883 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
|
3884 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3885 g_free(dialog_msg); |
3886 } | |
4075 | 3887 } break; |
3888 | |
4173 | 3889 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3890 if (i >= 6) { |
4308 | 3891 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
|
3892 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3893 g_free(dialog_msg); |
3894 } | |
4075 | 3895 } break; |
3896 | |
4173 | 3897 case 0x12: { |
3141 | 3898 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3899 /* Someone added you to their buddy list? */ |
3141 | 3900 } break; |
3901 | |
7023 | 3902 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3903 guint i, num; |
3453 | 3904 gchar **text; |
4173 | 3905 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3906 if (text) { |
3907 num = 0; | |
3908 for (i=0; i<strlen(text[0]); i++) | |
3909 num = num*10 + text[0][i]-48; | |
3910 for (i=0; i<num; i++) { | |
4230 | 3911 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3912 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 | 3913 data->gc = gc; |
4790 | 3914 data->name = g_strdup(text[i*2+1]); |
3915 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3916 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3917 gaim_request_action(gc, NULL, message, |
7023 | 3918 _("Do you want to add this buddy " |
3919 "to your buddy list?"), | |
9972 | 3920 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3921 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3922 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3923 g_free(message); |
3924 } | |
3925 g_strfreev(text); | |
3926 } | |
3927 } break; | |
3928 | |
7023 | 3929 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3930 /* This is boring and silly. */ |
3931 } break; | |
3932 | |
3141 | 3933 default: { |
8660 | 3934 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3935 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3936 "(type 0x%02hhx).\n", args->type); |
3141 | 3937 } break; |
3938 } | |
3939 | |
4076 | 3940 g_strfreev(msg1); |
3941 g_strfreev(msg2); | |
3942 | |
3141 | 3943 return 1; |
3944 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3945 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3946 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3947 fu16_t channel; |
3948 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3949 aim_userinfo_t *userinfo; |
2086 | 3950 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3951 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3952 va_start(ap, fr); |
4200 | 3953 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3954 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3955 |
3141 | 3956 switch (channel) { |
3957 case 1: { /* standard message */ | |
3958 struct aim_incomingim_ch1_args *args; | |
3959 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3960 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3961 } break; | |
3962 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3963 case 2: { /* rendezvous */ |
3141 | 3964 struct aim_incomingim_ch2_args *args; |
3965 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3966 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3967 } break; | |
3968 | |
3969 case 4: { /* ICQ */ | |
3970 struct aim_incomingim_ch4_args *args; | |
3971 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3972 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3973 } break; |
3974 | |
3975 default: { | |
8660 | 3976 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3977 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3978 "0x%04hx).", channel); |
3141 | 3979 } break; |
2086 | 3980 } |
3981 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3982 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3983 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3984 return ret; |
2086 | 3985 } |
3986 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3987 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3988 GaimConnection *gc = sess->aux_data; |
3989 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3990 char *buf; |
2086 | 3991 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3992 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3993 aim_userinfo_t *userinfo; |
2086 | 3994 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3995 va_start(ap, fr); |
4200 | 3996 chan = (fu16_t)va_arg(ap, unsigned int); |
3997 userinfo = va_arg(ap, aim_userinfo_t *); | |
3998 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3999 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 4000 va_end(ap); |
4001 | |
4002 switch(reason) { | |
5420 | 4003 case 0: /* Invalid (0) */ |
4004 buf = g_strdup_printf( | |
4005 ngettext( | |
4276 | 4006 "You missed %hu message from %s because it was invalid.", |
4007 "You missed %hu messages from %s because they were invalid.", | |
4008 nummissed), | |
4282 | 4009 nummissed, |
4010 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4011 break; |
5420 | 4012 case 1: /* Message too large */ |
4013 buf = g_strdup_printf( | |
4014 ngettext( | |
4276 | 4015 "You missed %hu message from %s because it was too large.", |
4016 "You missed %hu messages from %s because they were too large.", | |
4017 nummissed), | |
4282 | 4018 nummissed, |
4019 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4020 break; |
5420 | 4021 case 2: /* Rate exceeded */ |
4022 buf = g_strdup_printf( | |
4023 ngettext( | |
4276 | 4024 "You missed %hu message from %s because the rate limit has been exceeded.", |
4025 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
4026 nummissed), | |
4282 | 4027 nummissed, |
4028 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4029 break; |
5420 | 4030 case 3: /* Evil Sender */ |
4031 buf = g_strdup_printf( | |
4032 ngettext( | |
4276 | 4033 "You missed %hu message from %s because he/she was too evil.", |
4034 "You missed %hu messages from %s because he/she was too evil.", | |
4035 nummissed), | |
4282 | 4036 nummissed, |
4037 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4038 break; |
5420 | 4039 case 4: /* Evil Receiver */ |
4040 buf = g_strdup_printf( | |
4041 ngettext( | |
4276 | 4042 "You missed %hu message from %s because you are too evil.", |
4043 "You missed %hu messages from %s because you are too evil.", | |
4044 nummissed), | |
4282 | 4045 nummissed, |
4046 userinfo->sn); | |
2086 | 4047 break; |
4048 default: | |
5420 | 4049 buf = g_strdup_printf( |
4050 ngettext( | |
4276 | 4051 "You missed %hu message from %s for an unknown reason.", |
4052 "You missed %hu messages from %s for an unknown reason.", | |
4053 nummissed), | |
4282 | 4054 nummissed, |
4055 userinfo->sn); | |
2086 | 4056 break; |
4057 } | |
8733 | 4058 |
9627 | 4059 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4060 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4061 g_free(buf); |
2086 | 4062 |
4063 return 1; | |
4064 } | |
4065 | |
4194 | 4066 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 4067 GaimConnection *gc = sess->aux_data; |
7283 | 4068 OscarData *od = gc->proto_data; |
4617 | 4069 |
4070 /* BBB */ | |
3630 | 4071 switch (reason) { |
4151 | 4072 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4073 GaimXfer *xfer; |
8971 | 4074 struct oscar_direct_im *dim; |
4075 | |
8660 | 4076 gaim_debug_info("oscar", |
9070 | 4077 "AAA - Other user declined some sort of direct " |
8971 | 4078 "connect attempt (automaticly?)\n"); |
4617 | 4079 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
|
4080 gaim_xfer_cancel_remote(xfer); |
8971 | 4081 else if ((dim = oscar_direct_im_find(od, who))) { |
4082 /* AAA should use find by cookie or something here */ | |
4083 oscar_direct_im_disconnect(od, dim); | |
4084 } | |
4151 | 4085 } break; |
4086 | |
4087 default: { | |
8660 | 4088 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4089 "Received an unknown rendezvous client auto-response " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4090 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4091 } |
3630 | 4092 |
4093 } | |
4094 | |
4095 return 0; | |
4096 } | |
4097 | |
4194 | 4098 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4099 GaimConnection *gc = sess->aux_data; |
4151 | 4100 |
4101 switch(reason) { | |
4102 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4103 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4104 | |
4105 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4106 |
4107 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4108 statusmsg = oscar_icqstatus(state); |
4151 | 4109 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4110 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4111 g_free(statusmsg); | |
4151 | 4112 g_strfreev(splitmsg); |
9244 | 4113 |
9797 | 4114 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4115 |
4116 g_free(title); | |
4117 g_free(dialogmsg); | |
4151 | 4118 } break; |
4119 | |
4120 default: { | |
8660 | 4121 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4122 "Received an unknown client auto-response from %s. " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4123 "Type 0x%04hx\n", who, reason); |
4151 | 4124 } break; |
4125 } /* end of switch */ | |
4126 | |
4127 return 0; | |
4128 } | |
4129 | |
3212 | 4130 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4131 va_list ap; | |
4132 fu16_t chan, reason; | |
4133 char *who; | |
4134 | |
4135 va_start(ap, fr); | |
4200 | 4136 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4137 who = va_arg(ap, char *); |
4200 | 4138 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4139 |
3952 | 4140 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4141 char *cookie = va_arg(ap, char *); |
4151 | 4142 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4143 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4144 fu32_t state = 0; |
4151 | 4145 char *msg = NULL; |
4146 if (reason == 0x0003) { | |
4200 | 4147 state = va_arg(ap, fu32_t); |
4151 | 4148 msg = va_arg(ap, char *); |
4149 } | |
4150 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4151 } | |
3952 | 4152 |
3212 | 4153 va_end(ap); |
4154 | |
4155 return 1; | |
4156 } | |
4157 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4158 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4159 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4160 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4161 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4162 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4163 va_start(ap, fr); |
4199 | 4164 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4165 va_end(ap); |
4166 | |
8660 | 4167 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4168 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4169 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4170 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4171 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4172 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4173 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4174 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4175 |
2086 | 4176 return 1; |
4177 } | |
4178 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4179 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4180 GaimConnection *gc = sess->aux_data; |
4617 | 4181 #if 0 |
7283 | 4182 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4183 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4184 #endif |
4617 | 4185 va_list ap; |
4186 fu16_t reason; | |
4187 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4188 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4189 va_start(ap, fr); |
4617 | 4190 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4191 data = va_arg(ap, char *); |
2086 | 4192 va_end(ap); |
4193 | |
8660 | 4194 gaim_debug_error("oscar", |
10130 | 4195 "Message error with data %s and reason %hu\n", |
4196 (data != NULL ? data : ""), reason); | |
4617 | 4197 |
4198 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4199 #if 0 |
4617 | 4200 /* If this was a file transfer request, data is a cookie */ |
4201 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
|
4202 gaim_xfer_cancel_remote(xfer); |
3630 | 4203 return 1; |
4204 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4205 #endif |
3630 | 4206 |
4617 | 4207 /* Data is assumed to be the destination sn */ |
9826 | 4208 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4209 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4210 g_free(buf); | |
4211 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4212 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4213 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4214 } | |
4215 g_free(buf); | |
4216 | |
2086 | 4217 return 1; |
4218 } | |
4219 | |
3595 | 4220 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4221 GaimConnection *gc = sess->aux_data; |
3595 | 4222 va_list ap; |
4223 fu16_t type1, type2; | |
4224 char *sn; | |
4225 | |
4226 va_start(ap, fr); | |
4199 | 4227 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4228 sn = va_arg(ap, char *); |
4199 | 4229 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4230 va_end(ap); |
4231 | |
4232 switch (type2) { | |
4233 case 0x0000: { /* Text has been cleared */ | |
4234 serv_got_typing_stopped(gc, sn); | |
4235 } break; | |
4236 | |
4237 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4238 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4239 } break; |
4240 | |
4241 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4242 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4243 } break; |
4244 | |
4245 default: { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4246 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 | 4247 } break; |
4248 } | |
4249 | |
4250 return 1; | |
4251 } | |
4252 | |
7141 | 4253 /* |
4254 * We get this error when there was an error in the locate family. This | |
7259 | 4255 * happens when you request info of someone who is offline. |
7141 | 4256 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4257 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4258 gchar *buf; |
2086 | 4259 va_list ap; |
5420 | 4260 fu16_t reason; |
2086 | 4261 char *destn; |
4262 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4263 va_start(ap, fr); |
4199 | 4264 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4265 destn = va_arg(ap, char *); |
4266 va_end(ap); | |
4267 | |
7781 | 4268 if (destn == NULL) |
7793 | 4269 return 1; |
10560 | 4270 |
9826 | 4271 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4272 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4273 g_free(buf); | |
9627 | 4274 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4275 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4276 } | |
4277 g_free(buf); | |
2086 | 4278 |
4279 return 1; | |
4280 } | |
4281 | |
7011 | 4282 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4283 GaimConnection *gc = sess->aux_data; |
8700 | 4284 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 4285 OscarData *od = gc->proto_data; |
8700 | 4286 GString *str; |
9244 | 4287 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4288 va_list ap; |
7011 | 4289 aim_userinfo_t *userinfo; |
2086 | 4290 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4291 va_start(ap, fr); |
7011 | 4292 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4293 va_end(ap); |
4294 | |
8700 | 4295 str = g_string_new(""); |
4296 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4297 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4298 |
10116 | 4299 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 4300 time_t t = userinfo->onlinesince - od->timeoffset; |
10116 | 4301 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); |
4302 } | |
4303 | |
4304 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 4305 time_t t = userinfo->membersince - od->timeoffset; |
10116 | 4306 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); |
4307 } | |
7011 | 4308 |
4309 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4310 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4311 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4312 g_free(tmp); |
4313 } | |
4314 | |
8701 | 4315 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4316 |
4317 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4318 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4319 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4320 g_free(tmp); | |
7011 | 4321 if (away_utf8 != NULL) { |
8700 | 4322 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4323 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4324 } |
7011 | 4325 } |
4326 | |
4327 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4328 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4329 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4330 g_free(tmp); | |
7011 | 4331 if (info_utf8 != NULL) { |
8700 | 4332 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4333 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4334 } |
7011 | 4335 } |
4336 | |
8701 | 4337 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4338 g_string_free(str, TRUE); |
9244 | 4339 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4340 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4341 g_free(title); |
8700 | 4342 g_free(tmp); |
4151 | 4343 |
2086 | 4344 return 1; |
4345 } | |
4346 | |
8341 | 4347 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4348 { | |
4349 aim_session_t *sess = data; | |
4350 GaimConnection *gc = sess->aux_data; | |
4351 OscarData *od = (OscarData *)gc->proto_data; | |
4352 | |
4353 aim_locate_dorequest(data); | |
4354 od->getinfotimer = 0; | |
4355 | |
4356 return FALSE; | |
4357 } | |
4358 | |
4359 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4360 { | |
4361 GaimConnection *gc = sess->aux_data; | |
4362 OscarData *od = (OscarData *)gc->proto_data; | |
4363 | |
4364 /* | |
4365 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4366 * us from hitting the rate limit due to request away messages and info | |
4367 * too quickly. | |
4368 */ | |
4369 if (od->getinfotimer == 0) | |
10198 | 4370 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4371 |
4372 return 1; | |
4373 } | |
4374 | |
4375 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4376 { | |
2086 | 4377 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4378 fu16_t id; |
2086 | 4379 va_list ap; |
4380 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4381 va_start(ap, fr); |
4199 | 4382 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4383 msg = va_arg(ap, char *); |
4384 va_end(ap); | |
4385 | |
8660 | 4386 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4387 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4388 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4389 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4390 _("Your AIM connection may be lost."), NULL); |
2086 | 4391 |
4392 return 1; | |
4393 } | |
4394 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4395 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4396 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4397 fu16_t type; |
5575 | 4398 GaimConnection *gc = sess->aux_data; |
7283 | 4399 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4400 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4401 va_start(ap, fr); |
4199 | 4402 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4403 |
4404 switch(type) { | |
4405 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4406 fu8_t maxrooms; |
2086 | 4407 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4408 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4409 |
4199 | 4410 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4411 exchangecount = va_arg(ap, int); |
4412 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4413 | |
8660 | 4414 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4415 "chat info: Chat Rights:\n"); |
8660 | 4416 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4417 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4418 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4419 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4420 for (i = 0; i < exchangecount; i++) |
8660 | 4421 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4422 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4423 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4424 while (od->create_rooms) { |
4425 struct create_room *cr = od->create_rooms->data; | |
8660 | 4426 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4427 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4428 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4429 g_free(cr->name); |
4617 | 4430 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4431 g_free(cr); |
2086 | 4432 } |
4433 } | |
4434 break; | |
4435 case 0x0008: { | |
4436 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4437 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4438 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4439 fu32_t createtime; |
2086 | 4440 |
4441 fqcn = va_arg(ap, char *); | |
4200 | 4442 instance = (fu16_t)va_arg(ap, unsigned int); |
4443 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4444 flags = (fu16_t)va_arg(ap, unsigned int); | |
4445 createtime = va_arg(ap, fu32_t); | |
4446 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4447 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4448 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4449 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4450 name = va_arg(ap, char *); | |
4451 ck = va_arg(ap, char *); | |
4194 | 4452 |
8660 | 4453 gaim_debug_misc("oscar", |
5556 | 4454 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4455 fqcn, |
4456 exchange, instance, flags, | |
4457 createtime, | |
4458 maxmsglen, maxoccupancy, createperms, unknown, | |
4459 name, ck); | |
4617 | 4460 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4461 } |
4462 break; | |
4463 default: | |
8660 | 4464 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4465 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4466 break; |
4467 } | |
4194 | 4468 |
4469 va_end(ap); | |
4470 | |
2086 | 4471 return 1; |
4472 } | |
4473 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4474 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4475 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4476 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4477 aim_userinfo_t *info; |
5575 | 4478 GaimConnection *g = sess->aux_data; |
2086 | 4479 |
4480 struct chat_connection *c = NULL; | |
4481 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4482 va_start(ap, fr); |
2086 | 4483 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4484 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4485 va_end(ap); |
4486 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4487 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4488 if (!c) |
4489 return 1; | |
4490 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4491 for (i = 0; i < count; i++) |
9846 | 4492 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4493 |
4494 return 1; | |
4495 } | |
4496 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4497 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4498 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4499 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4500 aim_userinfo_t *info; |
5575 | 4501 GaimConnection *g = sess->aux_data; |
2086 | 4502 |
4503 struct chat_connection *c = NULL; | |
4504 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4505 va_start(ap, fr); |
2086 | 4506 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4507 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4508 va_end(ap); |
4509 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4510 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4511 if (!c) |
4512 return 1; | |
4513 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4514 for (i = 0; i < count; i++) |
8733 | 4515 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4516 |
4517 return 1; | |
4518 } | |
4519 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4520 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
|
4521 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4522 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4523 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4524 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4525 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4526 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4527 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4528 fu32_t creationtime; |
5575 | 4529 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4530 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
|
4531 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4532 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4533 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4534 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4535 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4536 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4537 roomdesc = va_arg(ap, char *); |
4200 | 4538 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4539 creationtime = va_arg(ap, fu32_t); | |
4540 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4541 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4542 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4543 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4544 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4545 |
8660 | 4546 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4547 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4548 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4549 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4550 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4551 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4552 |
2086 | 4553 return 1; |
4554 } | |
4555 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4556 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4557 GaimConnection *gc = sess->aux_data; |
8225 | 4558 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4559 gchar *utf8; | |
2086 | 4560 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4561 aim_userinfo_t *info; |
8225 | 4562 int len; |
2086 | 4563 char *msg; |
8219 | 4564 char *charset; |
2086 | 4565 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4566 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4567 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4568 len = va_arg(ap, int); |
4194 | 4569 msg = va_arg(ap, char *); |
8219 | 4570 charset = va_arg(ap, char *); |
4194 | 4571 va_end(ap); |
2086 | 4572 |
8225 | 4573 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4574 if (utf8 == NULL) |
4575 /* The conversion failed! */ | |
8668 | 4576 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4577 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4578 g_free(utf8); | |
2086 | 4579 |
4580 return 1; | |
4581 } | |
4582 | |
3694 | 4583 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4584 va_list ap; | |
5575 | 4585 GaimConnection *gc = sess->aux_data; |
3694 | 4586 struct aim_emailinfo *emailinfo; |
3725 | 4587 int havenewmail; |
7297 | 4588 char *alertitle, *alerturl; |
3694 | 4589 |
4590 va_start(ap, fr); | |
4591 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4592 havenewmail = va_arg(ap, int); |
7301 | 4593 alertitle = va_arg(ap, char *); |
4594 alerturl = va_arg(ap, char *); | |
3694 | 4595 va_end(ap); |
4596 | |
9661 | 4597 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4598 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4599 emailinfo->domain ? "@" : "", | |
4600 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4601 if (emailinfo->unread && havenewmail) |
4602 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4603 g_free(to); |
3694 | 4604 } |
10157 | 4605 |
7301 | 4606 if (alertitle) |
8660 | 4607 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4608 |
4609 return 1; | |
4610 } | |
4611 | |
4804 | 4612 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4613 GaimConnection *gc = sess->aux_data; |
7283 | 4614 OscarData *od = gc->proto_data; |
4804 | 4615 char *sn; |
4616 | |
4617 sn = od->requesticon->data; | |
8660 | 4618 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4619 "removing %s from hash table\n", sn); |
4804 | 4620 od->requesticon = g_slist_remove(od->requesticon, sn); |
4621 free(sn); | |
4622 | |
4623 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4624 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4625 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4626 |
4627 return 1; | |
4628 } | |
4629 | |
4630 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4631 GaimConnection *gc = sess->aux_data; |
7283 | 4632 OscarData *od = gc->proto_data; |
4804 | 4633 GSList *cur; |
4634 va_list ap; | |
4635 char *sn; | |
11024 | 4636 fu8_t iconcsumtype, *iconcsum, *icon; |
4853 | 4637 fu16_t iconcsumlen, iconlen; |
4804 | 4638 |
4639 va_start(ap, fr); | |
4640 sn = va_arg(ap, char *); | |
11024 | 4641 iconcsumtype = va_arg(ap, int); |
4853 | 4642 iconcsum = va_arg(ap, fu8_t *); |
4643 iconcsumlen = va_arg(ap, int); | |
4804 | 4644 icon = va_arg(ap, fu8_t *); |
4645 iconlen = va_arg(ap, int); | |
4646 va_end(ap); | |
4647 | |
11024 | 4648 /* |
4649 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
4650 * no icon is set. Ignore these. | |
4651 */ | |
4652 if ((iconlen > 0) && (iconlen != 90)) { | |
4853 | 4653 char *b16; |
6695 | 4654 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4655 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4656 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4657 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4658 if (b16) { |
7693 | 4659 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4660 g_free(b16); |
5129 | 4661 } |
4853 | 4662 } |
4804 | 4663 |
4664 cur = od->requesticon; | |
4665 while (cur) { | |
4666 char *cursn = cur->data; | |
4667 if (!aim_sncmp(cursn, sn)) { | |
4668 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4669 free(cursn); | |
4670 cur = od->requesticon; | |
4671 } else | |
4672 cur = cur->next; | |
4673 } | |
4674 | |
4675 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4676 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4677 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4678 |
4679 return 1; | |
4680 } | |
4681 | |
4682 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4683 GaimConnection *gc = data; |
7283 | 4684 OscarData *od = gc->proto_data; |
7011 | 4685 aim_userinfo_t *userinfo; |
4804 | 4686 aim_conn_t *conn; |
4687 | |
4688 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4689 if (!conn) { |
4690 if (!od->iconconnecting) { | |
4691 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4692 od->iconconnecting = TRUE; | |
4693 } | |
4804 | 4694 return FALSE; |
4695 } | |
4696 | |
5842 | 4697 if (od->set_icon) { |
6039 | 4698 struct stat st; |
4699 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4700 if (iconfile == NULL) { | |
8363 | 4701 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4702 } else if (!g_stat(iconfile, &st)) { |
6039 | 4703 char *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4704 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 4705 if (file) { |
9532 | 4706 /* XXX - Use g_file_get_contents()? */ |
6039 | 4707 fread(buf, 1, st.st_size, file); |
4708 fclose(file); | |
8660 | 4709 gaim_debug_info("oscar", |
6039 | 4710 "Uploading icon to icon server\n"); |
6879 | 4711 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4712 } else |
8660 | 4713 gaim_debug_error("oscar", |
6039 | 4714 "Can't open buddy icon file!\n"); |
4715 g_free(buf); | |
4716 } else { | |
8660 | 4717 gaim_debug_error("oscar", |
6039 | 4718 "Can't stat buddy icon file!\n"); |
5842 | 4719 } |
4720 od->set_icon = FALSE; | |
4721 } | |
4722 | |
4723 if (!od->requesticon) { | |
8660 | 4724 gaim_debug_misc("oscar", |
5842 | 4725 "no more icons to request\n"); |
4726 return FALSE; | |
4727 } | |
4728 | |
7045 | 4729 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4730 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
11024 | 4731 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
4804 | 4732 return FALSE; |
4733 } else { | |
4734 char *sn = od->requesticon->data; | |
4735 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4736 free(sn); | |
4737 } | |
4738 | |
4739 return TRUE; | |
4740 } | |
4741 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4742 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4743 * 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
|
4744 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4745 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4746 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4747 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4748 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4749 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4750 va_start(ap, fr); |
4199 | 4751 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4752 sn = va_arg(ap, char *); |
4753 va_end(ap); | |
4754 | |
8660 | 4755 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4756 |
4757 return 1; | |
4758 } | |
4759 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4760 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
|
4761 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4762 "invalid", |
4194 | 4763 "change", |
4764 "warning", | |
4765 "limit", | |
4766 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4767 }; |
2086 | 4768 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4769 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4770 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4771 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4772 va_start(ap, fr); |
4200 | 4773 code = (fu16_t)va_arg(ap, unsigned int); |
4774 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4775 windowsize = va_arg(ap, fu32_t); | |
4776 clear = va_arg(ap, fu32_t); | |
4777 alert = va_arg(ap, fu32_t); | |
4778 limit = va_arg(ap, fu32_t); | |
4779 disconnect = va_arg(ap, fu32_t); | |
4780 currentavg = va_arg(ap, fu32_t); | |
4781 maxavg = va_arg(ap, fu32_t); | |
2086 | 4782 va_end(ap); |
4783 | |
8660 | 4784 gaim_debug_misc("oscar", |
5556 | 4785 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4786 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4787 (code < 5) ? codes[code] : codes[0], |
4788 rateclass, | |
4789 currentavg, maxavg, | |
4790 alert, clear, | |
4791 limit, disconnect, | |
4792 windowsize); | |
4793 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4794 /* XXX fix these values */ |
2086 | 4795 if (code == AIM_RATE_CODE_CHANGE) { |
4796 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4797 aim_conn_setlatency(fr->conn, 0); |
2086 | 4798 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4799 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4800 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4801 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4802 _("The last action you attempted could not be " |
4803 "performed because you are over the rate limit. " | |
4804 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4805 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4806 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4807 aim_conn_setlatency(fr->conn, 0); |
2086 | 4808 } |
4809 | |
4810 return 1; | |
4811 } | |
4812 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4813 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4814 GaimConnection *gc = sess->aux_data; |
4815 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4816 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4817 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4818 aim_userinfo_t *userinfo; |
2086 | 4819 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4820 va_start(ap, fr); |
4199 | 4821 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4822 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4823 va_end(ap); |
4824 | |
9982 | 4825 /* XXX - What's with the + 0.5? */ |
4826 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4827 |
4828 return 1; | |
4829 } | |
4830 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4831 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4832 GaimConnection *gc = sess->aux_data; |
4833 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4834 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4835 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4836 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4837 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4838 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4839 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4840 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4841 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4842 |
9982 | 4843 warning_level = info->warnlevel/10.0 + 0.5; |
4844 | |
10152 | 4845 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4846 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4847 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4848 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4849 |
4649 | 4850 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4851 GaimConnection *gc = sess->aux_data; |
7283 | 4852 OscarData *od = gc->proto_data; |
4649 | 4853 va_list ap; |
4854 fu16_t code; | |
4855 char *msg; | |
4856 | |
4857 va_start(ap, fr); | |
4858 code = (fu16_t)va_arg(ap, int); | |
4859 msg = va_arg(ap, char *); | |
4860 va_end(ap); | |
4861 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4862 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
10458 | 4863 code, (msg != NULL ? msg : "")); |
4864 | |
4865 g_return_val_if_fail(fr != NULL, 1); | |
4866 g_return_val_if_fail(fr->conn != NULL, 1); | |
4867 | |
4868 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 4869 if (code == 0x0001) { |
6113 | 4870 gc->wants_to_die = TRUE; |
10715 | 4871 gaim_connection_error(gc, _("You have signed on from another location.")); |
4651 | 4872 } else { |
5579 | 4873 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4874 } |
4666 | 4875 od->killme = TRUE; |
10458 | 4876 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
4877 struct chat_connection *cc; | |
4878 GaimConversation *conv; | |
4879 | |
4880 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
4881 conv = gaim_find_chat(gc, cc->id); | |
4882 | |
4883 if (conv != NULL) | |
4884 { | |
4885 gchar *buf; | |
4886 buf = g_strdup_printf(_("You have been disconnected from chat " | |
4887 "room %s."), cc->name); | |
4888 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
4889 g_free(buf); | |
4890 } | |
4891 oscar_chat_kill(gc, cc); | |
4649 | 4892 } |
4893 | |
4894 return 1; | |
4895 } | |
4896 | |
2675 | 4897 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4898 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4899 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4900 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4901 |
8660 | 4902 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4903 aim_ssi_reqrights(sess); |
6350 | 4904 aim_ssi_reqdata(sess); |
4230 | 4905 |
7011 | 4906 aim_locate_reqrights(sess); |
7285 | 4907 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4908 aim_im_reqparams(sess); |
7334 | 4909 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4910 |
7283 | 4911 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4912 | |
2086 | 4913 return 1; |
4914 } | |
4915 | |
2675 | 4916 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4917 GaimConnection *gc = sess->aux_data; |
7283 | 4918 OscarData *od = gc->proto_data; |
2647 | 4919 |
6905 | 4920 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4921 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4922 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4923 | |
2672 | 4924 aim_clientready(sess, fr->conn); |
8660 | 4925 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4926 |
2647 | 4927 if (od->chpass) { |
8660 | 4928 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4929 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4930 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4931 od->oldp = NULL; |
2647 | 4932 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4933 od->newp = NULL; |
2647 | 4934 od->chpass = FALSE; |
4935 } | |
2979 | 4936 if (od->setnick) { |
8660 | 4937 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4938 aim_admin_setnick(sess, fr->conn, od->newsn); |
4939 g_free(od->newsn); | |
4940 od->newsn = NULL; | |
4941 od->setnick = FALSE; | |
4942 } | |
2647 | 4943 if (od->conf) { |
8660 | 4944 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4945 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4946 od->conf = FALSE; |
4947 } | |
4948 if (od->reqemail) { | |
8660 | 4949 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4950 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4951 od->reqemail = FALSE; |
4952 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4953 if (od->setemail) { |
8660 | 4954 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4955 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4956 g_free(od->email); |
5497 | 4957 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4958 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4959 } |
2647 | 4960 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4961 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4962 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4963 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4964 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
|
4965 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4966 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4967 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4968 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4969 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4970 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4971 |
4194 | 4972 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4973 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4974 "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
|
4975 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4976 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4977 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4978 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4979 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4980 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4981 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4982 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4983 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4984 |
4617 | 4985 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4986 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4987 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4988 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4989 |
2993 | 4990 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4991 { | |
5575 | 4992 GaimConnection *gc = sess->aux_data; |
7283 | 4993 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4994 va_list ap; |
4995 fu16_t maxsiglen; | |
2993 | 4996 |
4997 va_start(ap, fr); | |
4199 | 4998 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4999 va_end(ap); |
5000 | |
8660 | 5001 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5002 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 5003 |
4617 | 5004 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
5005 | |
5006 if (od->icq) | |
7334 | 5007 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 5008 else |
7334 | 5009 aim_locate_setcaps(od->sess, caps_aim); |
5010 oscar_set_info(gc, gc->account->user_info); | |
2993 | 5011 |
5012 return 1; | |
5013 } | |
5014 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5015 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
|
5016 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5017 fu16_t maxbuddies, maxwatchers; |
5575 | 5018 GaimConnection *gc = sess->aux_data; |
7283 | 5019 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5020 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5021 va_start(ap, fr); |
4199 | 5022 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5023 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5024 va_end(ap); |
5025 | |
8660 | 5026 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5027 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5028 |
4617 | 5029 od->rights.maxbuddies = (guint)maxbuddies; |
5030 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5031 |
2086 | 5032 return 1; |
5033 } | |
5034 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5035 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5036 GaimConnection *gc = sess->aux_data; |
7283 | 5037 OscarData *od = (OscarData *)gc->proto_data; |
10570 | 5038 GaimAccount *account = gaim_connection_get_account(gc); |
7334 | 5039 va_list ap; |
5040 fu16_t maxpermits, maxdenies; | |
2086 | 5041 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5042 va_start(ap, fr); |
4199 | 5043 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5044 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5045 va_end(ap); |
5046 | |
8660 | 5047 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5048 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5049 |
4617 | 5050 od->rights.maxpermits = (guint)maxpermits; |
5051 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5052 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5053 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5054 |
8660 | 5055 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5056 |
2672 | 5057 aim_clientready(sess, fr->conn); |
5948 | 5058 aim_srv_setavailmsg(sess, NULL); |
7474 | 5059 aim_srv_setidle(sess, 0); |
4617 | 5060 |
4664 | 5061 if (od->icq) { |
5062 aim_icq_reqofflinemsgs(sess); | |
10570 | 5063 aim_icq_setsecurity(sess, |
5064 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
5065 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE), | |
5066 gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP)); | |
4664 | 5067 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5068 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5069 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5070 if (sess->authinfo->email) |
5071 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5072 |
5073 return 1; | |
5074 } | |
5075 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5076 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
|
5077 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5078 struct aim_icq_offlinemsg *msg; |
4075 | 5079 struct aim_incomingim_ch4_args args; |
5080 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5081 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5082 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5083 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5084 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5085 |
8660 | 5086 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5087 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5088 args.uin = msg->sender; |
5089 args.type = msg->type; | |
4173 | 5090 args.flags = msg->flags; |
4076 | 5091 args.msglen = msg->msglen; |
4075 | 5092 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5093 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5094 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5095 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5096 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5097 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5098 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5099 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
|
5100 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5101 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5102 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5103 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5104 |
7388 | 5105 #if 0 |
5106 /* | |
7465 | 5107 * Update, 2003-11-09: |
5108 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5109 * | |
7388 | 5110 * It may not be my place to do this, but... |
5111 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5112 * stupid, and should not exist for % switches (%x in our case) that request | |
5113 * a year in the preferred representation for the current locale. For that | |
5114 * reason I've chosen to not use this workaround (n., see kluge). | |
5115 * | |
5116 * I have a date. I want to show it to the user in the "preferred" way. | |
5117 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5118 * what the locale wanted. | |
5119 * | |
5120 * If I have a necessity for a full representation of the year in the current | |
5121 * locale, then I'll use a switch that returns a full representation of the | |
5122 * year. | |
5123 * | |
5124 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5125 * (because you're anal, or whatever), then change the f***ing locale. | |
5126 * | |
5127 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5128 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5129 * |
5130 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5131 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5132 */ |
5133 | |
5134 /* | |
5135 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5136 * "last 2 digits" warning. |
5137 */ | |
10157 | 5138 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5139 const struct tm *tm) |
5140 { | |
5141 return strftime(s, max, fmt, tm); | |
5142 } | |
10636 | 5143 |
5144 /* | |
5145 * Before even realizing this was here, I went and did the same thing in util.c. | |
5146 * | |
5147 * Use gaim_strftime() | |
5148 */ | |
5149 | |
7388 | 5150 #endif |
7386 | 5151 |
4624 | 5152 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
|
5153 { |
5575 | 5154 GaimConnection *gc = sess->aux_data; |
8670 | 5155 OscarData *od = (OscarData *)gc->proto_data; |
5156 GaimBuddy *buddy; | |
8853 | 5157 struct buddyinfo *bi = NULL; |
4624 | 5158 gchar who[16]; |
8670 | 5159 GString *str; |
5160 gchar *primary, *utf8; | |
9634 | 5161 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5162 va_list ap; |
4151 | 5163 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5164 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5165 va_start(ap, fr); |
4151 | 5166 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5167 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5168 |
4664 | 5169 if (!info->uin) |
5170 return 0; | |
5171 | |
8670 | 5172 str = g_string_sized_new(100); |
5556 | 5173 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5174 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5175 if (buddy != NULL) | |
5176 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5177 | |
5178 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5179 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5180 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5181 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5182 (bi->ipaddr & 0xff000000) >> 24, | |
5183 (bi->ipaddr & 0x00ff0000) >> 16, | |
5184 (bi->ipaddr & 0x0000ff00) >> 8, | |
5185 (bi->ipaddr & 0x000000ff)); | |
8701 | 5186 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5187 g_free(tstr); |
5188 } | |
8701 | 5189 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5190 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5191 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5192 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5193 g_free(utf8); | |
4625 | 5194 } |
5195 if (info->numaddresses && info->email2) { | |
5196 int i; | |
5197 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5198 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
10683 | 5199 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 5200 g_free(utf8); |
4643 | 5201 } |
4625 | 5202 } |
4624 | 5203 } |
8701 | 5204 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5205 if (info->gender != 0) |
5206 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5207 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5208 char date[30]; |
5209 struct tm tm; | |
5210 tm.tm_mday = (int)info->birthday; | |
5211 tm.tm_mon = (int)info->birthmonth-1; | |
5212 tm.tm_year = (int)info->birthyear-1900; | |
10636 | 5213 gaim_strftime(date, sizeof(date), "%x", &tm); |
8701 | 5214 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5215 } |
4624 | 5216 if (info->age) { |
5217 char age[5]; | |
5218 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5219 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5220 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5221 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5222 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5223 g_free(utf8); | |
4819 | 5224 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5225 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5226 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5227 g_free(utf8); | |
5228 } | |
10683 | 5229 g_string_append_printf(str, "<hr>"); |
4641 | 5230 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5231 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5232 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5233 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5234 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5235 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
10683 | 5236 g_string_append_printf(str, "\n<hr>"); |
4151 | 5237 } |
4641 | 5238 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5239 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5240 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5241 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5242 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5243 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
10683 | 5244 g_string_append_printf(str, "\n<hr>"); |
4624 | 5245 } |
4641 | 5246 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5247 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5248 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5249 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5250 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5251 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5252 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5253 g_free(utf8); | |
4624 | 5254 } |
10683 | 5255 g_string_append_printf(str, "\n<hr>"); |
8670 | 5256 } |
5257 | |
9634 | 5258 if (buddy != NULL) |
5259 alias = gaim_buddy_get_alias(buddy); | |
5260 else | |
5261 alias = who; | |
5262 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5263 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5264 g_free(primary); |
8670 | 5265 g_string_free(str, TRUE); |
4151 | 5266 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5267 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5268 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5269 |
4759 | 5270 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5271 { | |
5575 | 5272 GaimConnection *gc = sess->aux_data; |
4820 | 5273 gchar who[16], *utf8; |
6695 | 5274 GaimBuddy *b; |
4759 | 5275 va_list ap; |
5276 struct aim_icq_info *info; | |
5277 | |
5278 va_start(ap, fr); | |
5279 info = va_arg(ap, struct aim_icq_info *); | |
5280 va_end(ap); | |
5281 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5282 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5283 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5284 serv_got_alias(gc, who, utf8); |
4759 | 5285 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5286 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5287 } |
4820 | 5288 g_free(utf8); |
4759 | 5289 } |
5290 | |
5291 return 1; | |
5292 } | |
5293 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5294 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
|
5295 { |
7032 | 5296 GaimConnection *gc = sess->aux_data; |
5297 gchar *text; | |
5298 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5299 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5300 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5301 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5302 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5303 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5304 url = va_arg(ap, char *); |
4199 | 5305 wid = (fu16_t) va_arg(ap, int); |
5306 hei = (fu16_t) va_arg(ap, int); | |
5307 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5308 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5309 |
7032 | 5310 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5311 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5312 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5313 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5314 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5315 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5316 |
7032 | 5317 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5318 { | |
6873 | 5319 GaimConnection *gc = sess->aux_data; |
5320 gchar *secondary; | |
10439 | 5321 gchar **screennames; |
6873 | 5322 int i, num; |
2086 | 5323 va_list ap; |
6873 | 5324 char *email, *SNs; |
2086 | 5325 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5326 va_start(ap, fr); |
6873 | 5327 email = va_arg(ap, char *); |
2086 | 5328 num = va_arg(ap, int); |
5329 SNs = va_arg(ap, char *); | |
5330 va_end(ap); | |
5331 | |
10439 | 5332 /* TODO: Need to use ngettext() here */ |
8152 | 5333 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5334 |
5335 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5336 for (i = 0; i < num; i++) |
10439 | 5337 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5338 screennames[num] = NULL; | |
5339 | |
5340 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5341 (const char **)screennames, NULL, NULL); | |
6873 | 5342 |
5343 g_free(secondary); | |
10439 | 5344 g_strfreev(screennames); |
2086 | 5345 |
5346 return 1; | |
5347 } | |
5348 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5349 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5350 va_list ap; |
6873 | 5351 char *email; |
5420 | 5352 char *buf; |
2086 | 5353 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5354 va_start(ap, fr); |
6873 | 5355 email = va_arg(ap, char *); |
2086 | 5356 va_end(ap); |
5357 | |
6873 | 5358 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
|
5359 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5360 g_free(buf); |
2086 | 5361 |
5362 return 1; | |
5363 } | |
5364 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5365 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5366 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5367 fu16_t status; |
2086 | 5368 va_list ap; |
5369 char msg[256]; | |
5370 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5371 va_start(ap, fr); |
4199 | 5372 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5373 va_end(ap); |
5374 | |
8660 | 5375 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5376 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5377 status ? "unknown" : "email sent"); |
5378 if (!status) { | |
5302 | 5379 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5380 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5381 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5382 } |
5383 | |
5384 return 1; | |
5385 } | |
5386 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5387 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5388 GaimConnection *gc = sess->aux_data; |
2086 | 5389 va_list ap; |
3912 | 5390 fu16_t perms, err; |
5391 char *url, *sn, *email; | |
5392 int change; | |
2086 | 5393 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5394 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5395 change = va_arg(ap, int); |
4199 | 5396 perms = (fu16_t) va_arg(ap, unsigned int); |
5397 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5398 url = va_arg(ap, char *); |
5399 sn = va_arg(ap, char *); | |
5400 email = va_arg(ap, char *); | |
2086 | 5401 va_end(ap); |
5402 | |
8660 | 5403 gaim_debug_misc("oscar", |
9626 | 5404 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5405 change ? "change" : "request", perms, err, | |
5406 (url != NULL) ? url : "(null)", | |
5407 (sn != NULL) ? sn : "(null)", | |
5408 (email != NULL) ? email : "(null)"); | |
5409 | |
5410 if ((err > 0) && (url != NULL)) { | |
3912 | 5411 char *dialog_msg; |
5412 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5413 switch (err) { | |
5414 case 0x0001: { | |
5415 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5416 } break; | |
5417 case 0x0006: { | |
5418 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5419 } break; | |
5420 case 0x000b: { | |
5421 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5422 } break; | |
5423 case 0x001d: { | |
5424 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); | |
5425 } break; | |
5426 case 0x0021: { | |
5427 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); | |
5428 } break; | |
5429 case 0x0023: { | |
5430 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5431 } break; | |
5432 default: { | |
5433 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5434 } break; | |
5435 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5436 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5437 g_free(dialog_top); |
5438 g_free(dialog_msg); | |
5439 return 1; | |
5440 } | |
5441 | |
9626 | 5442 if (sn != NULL) { |
4585 | 5443 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
|
5444 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5445 g_free(dialog_msg); |
5446 } | |
5447 | |
9626 | 5448 if (email != NULL) { |
5575 | 5449 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5450 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5451 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5452 g_free(dialog_msg); |
2086 | 5453 } |
5454 | |
5455 return 1; | |
5456 } | |
5457 | |
5575 | 5458 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5459 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5460 aim_flap_nop(od->sess, od->conn); |
2086 | 5461 } |
5462 | |
6059 | 5463 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5464 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5465 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5466 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5467 if (typing == GAIM_TYPING) |
4870 | 5468 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5469 else if (typing == GAIM_TYPED) |
4870 | 5470 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5471 else | |
5472 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5473 else { |
5300 | 5474 /* Don't send if this turkey is in our deny list */ |
5475 GSList *list; | |
5476 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5477 if (!list) { | |
7261 | 5478 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5479 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5480 if (typing == GAIM_TYPING) |
5300 | 5481 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5482 else if (typing == GAIM_TYPED) |
5300 | 5483 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5484 else | |
5485 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5486 } | |
3595 | 5487 } |
5488 } | |
2993 | 5489 return 0; |
5490 } | |
9030 | 5491 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5492 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
|
5493 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5494 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5495 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5496 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5497 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
|
5498 int ret = 0; |
10246 | 5499 const char *iconfile = gaim_account_get_buddy_icon(account); |
10781 | 5500 char *tmpmsg = NULL; |
3458 | 5501 |
4838 | 5502 if (dim && dim->connected) { |
5503 /* If we're directly connected, send a direct IM */ | |
6982 | 5504 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5505 } else { |
4738 | 5506 struct buddyinfo *bi; |
3008 | 5507 struct aim_sendimext_args args; |
5508 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5509 gsize len; |
10246 | 5510 GaimConversation *conv; |
5511 | |
5512 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5513 |
5514 if (strstr(message, "<IMG ")) | |
5515 gaim_conversation_write(conv, "", | |
5516 _("Your IM Image was not sent. " | |
5517 "You must be Direct Connected to send IM Images."), | |
5518 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5519 |
10246 | 5520 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5521 if (!bi) { |
5522 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5523 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5524 } |
5525 | |
3008 | 5526 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5527 if (od->icq) { |
5528 args.features = features_icq; | |
5529 args.featureslen = sizeof(features_icq); | |
3008 | 5530 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5531 } else { |
5532 args.features = features_aim; | |
5533 args.featureslen = sizeof(features_aim); | |
4972 | 5534 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5535 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5536 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5537 } |
4269 | 5538 |
4738 | 5539 if (bi->ico_need) { |
8660 | 5540 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5541 "Sending buddy icon request with message\n"); |
3008 | 5542 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5543 bi->ico_need = FALSE; |
3008 | 5544 } |
4269 | 5545 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5546 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5547 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 5548 if (file) { |
5549 char *buf = g_malloc(st.st_size); | |
9532 | 5550 /* XXX - Use g_file_get_contents()? */ |
3008 | 5551 fread(buf, 1, st.st_size, file); |
6039 | 5552 fclose(file); |
4269 | 5553 |
3008 | 5554 args.iconlen = st.st_size; |
4617 | 5555 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5556 args.iconstamp = st.st_mtime; |
5557 | |
7406 | 5558 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5559 bi->ico_informed = FALSE; |
7406 | 5560 bi->ico_sent = FALSE; |
5561 } | |
4738 | 5562 |
5563 if (!bi->ico_informed) { | |
8660 | 5564 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5565 "Claiming to have a buddy icon\n"); |
4738 | 5566 args.flags |= AIM_IMFLAGS_HASICON; |
5567 bi->ico_me_len = args.iconlen; | |
5568 bi->ico_me_csum = args.iconsum; | |
5569 bi->ico_me_time = args.iconstamp; | |
5570 bi->ico_informed = TRUE; | |
5571 } | |
5572 | |
3008 | 5573 g_free(buf); |
2086 | 5574 } |
5575 } | |
4269 | 5576 |
3008 | 5577 args.destsn = name; |
4269 | 5578 |
8985 | 5579 /* |
10781 | 5580 * If we're IMing an ICQ user from an ICQ account, then strip HTML |
5581 * and use \r\n as the newline character. | |
8985 | 5582 */ |
10781 | 5583 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
5584 if (aim_sn_is_icq(name)) | |
5585 /* From ICQ to ICQ */ | |
8995 | 5586 tmpmsg = g_strdup(message); |
10781 | 5587 else |
5588 /* From ICQ to AIM */ | |
5589 tmpmsg = g_markup_escape_text(message, -1); | |
8995 | 5590 } else { |
10785 | 5591 /* From AIM to AIM and AIM to ICQ */ |
5592 tmpmsg = g_strdup(message); | |
8995 | 5593 } |
6310 | 5594 len = strlen(tmpmsg); |
5595 | |
9830 | 5596 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5597 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5598 args.charset, args.charsubset, args.msglen); | |
4617 | 5599 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5600 g_free((char *)args.msg); |
2086 | 5601 } |
4838 | 5602 |
6310 | 5603 g_free(tmpmsg); |
5604 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5605 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5606 return 1; |
6310 | 5607 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5608 return ret; |
2086 | 5609 } |
5610 | |
7011 | 5611 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5612 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5613 |
9975 | 5614 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5615 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5616 else |
7235 | 5617 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5618 } |
5619 | |
8950 | 5620 #if 0 |
7011 | 5621 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5622 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5623 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5624 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5625 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5626 maiden, NULL, NULL, city, state, NULL, 0, web); |
5627 } | |
8950 | 5628 #endif |
2086 | 5629 |
5575 | 5630 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5631 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5632 aim_srv_setidle(od->sess, time); |
2086 | 5633 } |
5634 | |
5954 | 5635 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5636 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5637 int charset = 0; |
6019 | 5638 char *text_html = NULL; |
5129 | 5639 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5640 gsize msglen = 0; |
2993 | 5641 |
4617 | 5642 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5643 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5644 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5645 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5646 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5647 "again when you are fully connected.")); |
4617 | 5648 |
7334 | 5649 if (!text) { |
5650 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5651 return; | |
5652 } | |
10097 | 5653 |
7334 | 5654 text_html = gaim_strdup_withhtml(text); |
9807 | 5655 charset = oscar_charset_check(text_html); |
9826 | 5656 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5657 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5658 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5659 g_free(msg); | |
9826 | 5660 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5661 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5662 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5663 g_free(msg); | |
5664 } else { | |
5665 msglen = strlen(text_html); | |
5666 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5667 } | |
5668 | |
5669 if (msglen > od->rights.maxsiglen) { | |
5670 gchar *errstr; | |
5671 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
|
5672 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5673 "The maximum profile length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5674 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5675 od->rights.maxsiglen), od->rights.maxsiglen); |
5676 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5677 g_free(errstr); | |
5678 } | |
5679 | |
5680 g_free(text_html); | |
2086 | 5681 } |
5682 | |
9991 | 5683 static void |
5684 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5685 { |
9991 | 5686 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5687 OscarData *od = NULL; |
9992 | 5688 GaimStatusType *status_type; |
9991 | 5689 GaimStatusPrimitive primitive; |
5690 GaimPresence *presence; | |
5691 const gchar *status_id; | |
9807 | 5692 int charset = 0; |
10196 | 5693 const gchar *text_html = NULL; |
5129 | 5694 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5695 gsize msglen = 0; |
2993 | 5696 |
9992 | 5697 status_type = gaim_status_get_type(status); |
5698 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5699 status_id = gaim_status_get_id(status); |
5700 presence = gaim_account_get_presence(account); | |
5701 | |
10400 | 5702 if (gc) |
5703 od = (OscarData *)gc->proto_data; | |
10401 | 5704 |
5705 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { | |
9991 | 5706 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5707 _("You have probably requested to set your " |
5708 "away message before the login procedure " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5709 "completed. You remain in a \"present\" " |
10400 | 5710 "state; try setting it again when you are " |
5711 "fully connected.")); | |
10401 | 5712 return; |
5713 } | |
5129 | 5714 |
9992 | 5715 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5716 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5717 | |
7334 | 5718 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5719 |
5720 text_html = gaim_status_get_attr_string(status, "message"); | |
5721 if (text_html != NULL) { | |
5722 aim_srv_setavailmsg(od->sess, text_html); | |
5723 } | |
10196 | 5724 |
5725 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5726 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5727 | |
10196 | 5728 text_html = gaim_status_get_attr_string(status, "message"); |
5729 | |
5730 if (text_html == NULL) { | |
5731 text_html = _("Away"); | |
5732 } | |
5733 | |
5734 charset = oscar_charset_check(text_html); | |
5735 if (charset == AIM_CHARSET_UNICODE) { | |
5736 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5737 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5738 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5739 g_free(msg); | |
5740 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5741 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5742 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5743 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5744 g_free(msg); | |
5745 } else { | |
5746 msglen = strlen(text_html); | |
5747 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5748 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5749 } | |
5750 | |
5751 if (msglen > od->rights.maxawaymsglen) { | |
5752 gchar *errstr; | |
5753 | |
5754 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
|
5755 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5756 "The maximum away message length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5757 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5758 od->rights.maxawaymsglen), od->rights.maxawaymsglen); |
5759 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5760 g_free(errstr); | |
5761 } | |
5762 | |
10197 | 5763 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5764 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5765 | |
5129 | 5766 } else { |
10196 | 5767 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5768 | |
5769 } | |
2993 | 5770 } |
5771 | |
9991 | 5772 static void |
5773 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5774 { |
9991 | 5775 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 5776 OscarData *od = NULL; |
9991 | 5777 const gchar *status_id = gaim_status_get_id(status); |
5778 | |
10646 | 5779 if (gc) |
5780 od = (OscarData *)gc->proto_data; | |
5781 if (!od) | |
5782 return; | |
5783 | |
9991 | 5784 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) |
5575 | 5785 account->perm_deny = 4; |
8265 | 5786 else |
5575 | 5787 account->perm_deny = 3; |
9991 | 5788 |
8265 | 5789 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5790 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5791 |
9991 | 5792 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5793 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5794 |
5795 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5796 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5797 |
5798 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5799 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5800 |
5801 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5802 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5803 |
5804 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5805 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5806 |
5807 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5808 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5809 |
5810 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5811 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5812 |
5813 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5814 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5815 } |
5816 | |
9991 | 5817 static void |
5818 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5819 { |
10747 | 5820 gboolean connected = gaim_account_is_connected(account); |
10400 | 5821 GaimStatusType *type = gaim_status_get_type(status); |
5822 int primitive = gaim_status_type_get_primitive(type); | |
5823 | |
10747 | 5824 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
5825 | |
10498 | 5826 if (!gaim_status_is_active(status)) |
10485 | 5827 return; |
5828 | |
10753 | 5829 if (primitive != GAIM_STATUS_OFFLINE && !connected) { |
10738 | 5830 gaim_account_connect(account); |
10747 | 5831 } else if (primitive == GAIM_STATUS_OFFLINE && connected) { |
10400 | 5832 gaim_account_disconnect(account); |
5833 } else { | |
10747 | 5834 if (!connected) |
5835 return; | |
10400 | 5836 |
5837 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
5838 oscar_set_status_icq(account, status); | |
5839 else | |
10560 | 5840 /* QQQ - Should probably also set this for ICQ */ |
10400 | 5841 oscar_set_status_aim(account, status); |
5842 } | |
2086 | 5843 } |
5844 | |
9991 | 5845 static void |
5846 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5847 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5848 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5849 } |
5850 | |
10747 | 5851 static void |
5852 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5853 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5854 |
5855 if (!aim_snvalid(buddy->name)) { | |
8092 | 5856 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5857 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 | 5858 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5859 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5860 g_free(buf); |
8150 | 5861 |
5862 /* Remove from local list */ | |
9285 | 5863 gaim_blist_remove_buddy(buddy); |
8150 | 5864 |
8092 | 5865 return; |
5866 } | |
5867 | |
9285 | 5868 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5869 if (buddy && group) { | |
8660 | 5870 gaim_debug_info("oscar", |
9285 | 5871 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5872 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5873 } |
5874 } | |
8150 | 5875 |
10157 | 5876 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5877 if (od->icq) |
9285 | 5878 aim_icq_getalias(od->sess, buddy->name); |
5879 } | |
5880 | |
5881 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5882 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5883 |
4230 | 5884 if (od->sess->ssi.received_data) { |
8660 | 5885 gaim_debug_info("oscar", |
9285 | 5886 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5887 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5888 } |
10866 | 5889 } |
5890 | |
5575 | 5891 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5892 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5893 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5894 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5895 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5896 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5897 } |
5898 } | |
5899 | |
5575 | 5900 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5901 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5902 if (od->sess->ssi.received_data) { |
5903 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5904 if (gname) { | |
8660 | 5905 gaim_debug_info("oscar", |
9586 | 5906 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5907 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5908 } |
5909 } | |
5910 } | |
5911 | |
11005 | 5912 /* |
5913 * FYI, the OSCAR SSI code removes empty groups automatically. | |
5914 */ | |
9285 | 5915 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5916 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5917 |
5918 if (od->sess->ssi.received_data) { | |
9285 | 5919 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5920 GList *cur, *groups = NULL; | |
5921 | |
5922 /* Make a list of what the groups each buddy is in */ | |
5923 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5924 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
5925 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
5926 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
5927 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
5928 node->parent->parent); |
9285 | 5929 } |
5930 | |
10866 | 5931 serv_remove_buddies(gc, moved_buddies, groups); |
5932 serv_add_buddies(gc, moved_buddies); | |
9285 | 5933 g_list_free(groups); |
8660 | 5934 gaim_debug_info("oscar", |
9285 | 5935 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5936 } else { |
9285 | 5937 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5938 gaim_debug_info("oscar", |
9285 | 5939 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5940 } |
5941 } | |
5942 } | |
5943 | |
5968 | 5944 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5945 aim_session_t *sess = data; | |
6350 | 5946 aim_ssi_reqdata(sess); |
5968 | 5947 return FALSE; |
5948 } | |
5949 | |
4642 | 5950 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5951 GaimConnection *gc = sess->aux_data; |
7283 | 5952 OscarData *od = gc->proto_data; |
4642 | 5953 va_list ap; |
5954 fu16_t reason; | |
5955 | |
5956 va_start(ap, fr); | |
5957 reason = (fu16_t)va_arg(ap, unsigned int); | |
5958 va_end(ap); | |
5959 | |
8660 | 5960 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5961 |
5962 if (reason == 0x0005) { | |
5892 | 5963 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5964 _("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
|
5965 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5966 } |
5967 | |
5968 /* Activate SSI */ | |
5969 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5970 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5971 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5972 aim_ssi_enable(od->sess); |
5973 | |
5974 return 1; | |
5975 } | |
5976 | |
2991 | 5977 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5978 GaimConnection *gc = sess->aux_data; |
7283 | 5979 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 5980 int i; |
5981 va_list ap; | |
5982 int numtypes; | |
4230 | 5983 fu16_t *maxitems; |
2991 | 5984 |
5985 va_start(ap, fr); | |
4230 | 5986 numtypes = va_arg(ap, int); |
5987 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5988 va_end(ap); |
5989 | |
8660 | 5990 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5991 |
4230 | 5992 for (i=0; i<numtypes; i++) |
8660 | 5993 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5994 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5995 |
8660 | 5996 gaim_debug_misc(NULL, "\n"); |
4230 | 5997 |
5998 if (numtypes >= 0) | |
5999 od->rights.maxbuddies = maxitems[0]; | |
6000 if (numtypes >= 1) | |
6001 od->rights.maxgroups = maxitems[1]; | |
6002 if (numtypes >= 2) | |
6003 od->rights.maxpermits = maxitems[2]; | |
6004 if (numtypes >= 3) | |
6005 od->rights.maxdenies = maxitems[3]; | |
2991 | 6006 |
6007 return 1; | |
6008 } | |
6009 | |
6010 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6011 GaimConnection *gc = sess->aux_data; |
6012 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6013 GaimStatus *status; |
7283 | 6014 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6015 GaimGroup *g; |
6016 GaimBuddy *b; | |
2995 | 6017 struct aim_ssi_item *curitem; |
2991 | 6018 int tmp; |
4230 | 6019 va_list ap; |
8219 | 6020 fu16_t fmtver, numitems; |
6021 struct aim_ssi_item *items; | |
6022 fu32_t timestamp; | |
4230 | 6023 |
6024 va_start(ap, fr); | |
6025 fmtver = (fu16_t)va_arg(ap, int); | |
6026 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6027 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6028 timestamp = va_arg(ap, fu32_t); |
8219 | 6029 va_end(ap); |
2991 | 6030 |
8660 | 6031 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6032 "ssi: syncing local list and server list\n"); |
2991 | 6033 |
8219 | 6034 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6035 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 | 6036 return 1; |
6037 } | |
6038 | |
2991 | 6039 /* Clean the buddy list */ |
4889 | 6040 aim_ssi_cleanlist(sess); |
2991 | 6041 |
8150 | 6042 { /* If not in server list then prune from local list */ |
6043 GaimBlistNode *gnode, *cnode, *bnode; | |
6044 GaimBuddyList *blist; | |
9539 | 6045 GSList *cur, *next; |
8150 | 6046 |
6047 /* Buddies */ | |
6048 cur = NULL; | |
6049 if ((blist = gaim_get_blist()) != NULL) { | |
6050 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6051 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6052 continue; | |
6053 g = (GaimGroup *)gnode; | |
6054 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6055 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6056 continue; | |
6057 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6058 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6059 continue; | |
6060 b = (GaimBuddy *)bnode; | |
6061 if (b->account == gc->account) { | |
6062 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6063 /* If the buddy is an ICQ user then load his nickname */ | |
6064 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6065 char *alias; |
8150 | 6066 if (servernick) |
6067 serv_got_alias(gc, b->name, servernick); | |
6068 | |
6069 /* Store local alias on server */ | |
8214 | 6070 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6071 if (!alias && b->alias && strlen(b->alias)) |
6072 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6073 free(alias); | |
6074 } else { | |
8660 | 6075 gaim_debug_info("oscar", |
8150 | 6076 "ssi: removing buddy %s from local list\n", b->name); |
6077 /* We can't actually remove now because it will screw up our looping */ | |
6078 cur = g_slist_prepend(cur, b); | |
6079 } | |
6080 } | |
6081 } | |
6082 } | |
6083 } | |
6084 } | |
8175 | 6085 |
8150 | 6086 while (cur != NULL) { |
6087 b = cur->data; | |
6088 cur = g_slist_remove(cur, b); | |
6089 gaim_blist_remove_buddy(b); | |
6090 } | |
6091 | |
6092 /* Permit list */ | |
6093 if (gc->account->permit) { | |
9539 | 6094 next = gc->account->permit; |
6095 while (next != NULL) { | |
6096 cur = next; | |
6097 next = next->next; | |
8150 | 6098 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6099 gaim_debug_info("oscar", |
8150 | 6100 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6101 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6102 } | |
9539 | 6103 } |
8150 | 6104 } |
6105 | |
6106 /* Deny list */ | |
6107 if (gc->account->deny) { | |
9539 | 6108 next = gc->account->deny; |
6109 while (next != NULL) { | |
6110 cur = next; | |
6111 next = next->next; | |
8150 | 6112 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6113 gaim_debug_info("oscar", |
8150 | 6114 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6115 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6116 } | |
9539 | 6117 } |
8150 | 6118 } |
6119 /* Presence settings (idle time visibility) */ | |
6120 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6121 if (!(tmp & 0x400)) | |
6122 aim_ssi_setpresence(sess, tmp | 0x400); | |
6123 } /* end pruning buddies from local list */ | |
6124 | |
2991 | 6125 /* Add from server list to local list */ |
4230 | 6126 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6127 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6128 switch (curitem->type) { |
4230 | 6129 case 0x0000: { /* Buddy */ |
4251 | 6130 if (curitem->name) { |
4292 | 6131 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6132 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6133 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6134 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6135 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6136 /* Should gname be freed here? -- elb */ |
4754 | 6137 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6138 free(alias); |
8150 | 6139 if (b) { |
4292 | 6140 /* Get server stored alias */ |
4705 | 6141 if (alias_utf8) { |
8150 | 6142 g_free(b->alias); |
6143 b->alias = g_strdup(alias_utf8); | |
4705 | 6144 } |
4282 | 6145 } else { |
8150 | 6146 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6147 |
4754 | 6148 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6149 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6150 gaim_blist_add_group(g, NULL); |
6151 } | |
5146 | 6152 |
8660 | 6153 gaim_debug_info("oscar", |
9285 | 6154 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6155 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6156 } |
8341 | 6157 if (!aim_sncmp(curitem->name, account->username)) { |
6158 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6159 gaim_check_comment(od, comment); | |
6160 free(comment); | |
6161 } | |
7162 | 6162 g_free(gname_utf8); |
6163 g_free(alias_utf8); | |
2991 | 6164 } |
4230 | 6165 } break; |
6166 | |
6167 case 0x0001: { /* Group */ | |
4282 | 6168 /* Shouldn't add empty groups */ |
4230 | 6169 } break; |
6170 | |
6171 case 0x0002: { /* Permit buddy */ | |
2991 | 6172 if (curitem->name) { |
4230 | 6173 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6174 GSList *list; |
5575 | 6175 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6176 if (!list) { |
8660 | 6177 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6178 "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
|
6179 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6180 } |
6181 } | |
4230 | 6182 } break; |
6183 | |
6184 case 0x0003: { /* Deny buddy */ | |
2991 | 6185 if (curitem->name) { |
6186 GSList *list; | |
5575 | 6187 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6188 if (!list) { |
8660 | 6189 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6190 "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
|
6191 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6192 } |
6193 } | |
4230 | 6194 } break; |
6195 | |
6196 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6197 if (curitem->data) { |
6198 fu8_t permdeny; | |
5575 | 6199 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6200 gaim_debug_info("oscar", |
5575 | 6201 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6202 account->perm_deny = permdeny; | |
6203 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6204 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6205 } |
2991 | 6206 } |
6207 } | |
4230 | 6208 } break; |
6209 | |
6210 case 0x0005: { /* Presence setting */ | |
3109 | 6211 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6212 } break; |
2991 | 6213 } /* End of switch on curitem->type */ |
6214 } /* End of for loop */ | |
4230 | 6215 |
9991 | 6216 /* |
6217 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6218 * this. We probably want the SSI status setting to override the local | |
6219 * setting. | |
6220 */ | |
9982 | 6221 status = gaim_presence_get_active_status(account->presence); |
6222 if (gaim_status_is_available(status)) | |
4901 | 6223 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6224 | |
4342 | 6225 /* Activate SSI */ |
6226 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6227 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6228 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6229 "ssi: activating server-stored buddy list\n"); |
4642 | 6230 aim_ssi_enable(sess); |
4342 | 6231 |
2991 | 6232 return 1; |
2086 | 6233 } |
4230 | 6234 |
6235 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6236 GaimConnection *gc = sess->aux_data; |
4230 | 6237 va_list ap; |
6238 struct aim_ssi_tmp *retval; | |
6239 | |
6240 va_start(ap, fr); | |
6241 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6242 va_end(ap); | |
6243 | |
6244 while (retval) { | |
8660 | 6245 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6246 "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 | 6247 |
6248 if (retval->ack != 0xffff) | |
6249 switch (retval->ack) { | |
6250 case 0x0000: { /* added successfully */ | |
6251 } break; | |
6252 | |
4829 | 6253 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6254 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6255 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 | 6256 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6257 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6258 g_free(buf); |
6259 } | |
6260 | |
7023 | 6261 case 0x000e: { /* buddy requires authorization */ |
4828 | 6262 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6263 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6264 } break; |
6265 | |
6266 default: { /* La la la */ | |
5197 | 6267 gchar *buf; |
8660 | 6268 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
|
6269 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 | 6270 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6271 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6272 g_free(buf); |
4230 | 6273 } break; |
6274 } | |
6275 | |
6276 retval = retval->next; | |
6277 } | |
6278 | |
6279 return 1; | |
6280 } | |
6281 | |
8227 | 6282 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6283 GaimConnection *gc = sess->aux_data; | |
6284 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6285 GaimBuddy *b; | |
6286 GaimGroup *g; | |
6287 va_list ap; | |
6288 fu16_t type; | |
6289 const char *name; | |
6290 | |
6291 va_start(ap, fr); | |
6292 type = (fu16_t)va_arg(ap, int); | |
6293 name = va_arg(ap, char *); | |
6294 va_end(ap); | |
6295 | |
6296 if ((type != 0x0000) || (name == NULL)) | |
6297 return 1; | |
6298 | |
6299 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6300 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6301 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6302 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6303 b = gaim_find_buddy(gc->account, name); | |
6304 free(alias); | |
6305 | |
6306 if (b) { | |
6307 /* Get server stored alias */ | |
6308 if (alias_utf8) { | |
6309 g_free(b->alias); | |
6310 b->alias = g_strdup(alias_utf8); | |
6311 } | |
6312 } else { | |
6313 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6314 | |
6315 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6316 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6317 gaim_blist_add_group(g, NULL); | |
6318 } | |
6319 | |
8660 | 6320 gaim_debug_info("oscar", |
9285 | 6321 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6322 gaim_blist_add_buddy(b, NULL, g, NULL); |
6323 } | |
6324 g_free(gname_utf8); | |
6325 g_free(alias_utf8); | |
6326 | |
6327 return 1; | |
6328 } | |
6329 | |
4230 | 6330 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6331 GaimConnection *gc = sess->aux_data; |
4230 | 6332 va_list ap; |
6333 char *sn, *msg; | |
4236 | 6334 gchar *dialog_msg, *nombre; |
4230 | 6335 struct name_data *data; |
6695 | 6336 GaimBuddy *buddy; |
4230 | 6337 |
6338 va_start(ap, fr); | |
6339 sn = va_arg(ap, char *); | |
6340 msg = va_arg(ap, char *); | |
6341 va_end(ap); | |
6342 | |
8660 | 6343 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6344 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6345 |
4687 | 6346 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6347 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6348 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6349 else |
6350 nombre = g_strdup(sn); | |
6351 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6352 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 | 6353 data = g_new(struct name_data, 1); |
6354 data->gc = gc; | |
6355 data->name = g_strdup(sn); | |
6356 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6357 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6358 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6359 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6360 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6361 G_CALLBACK(oscar_free_name_data)); |
4236 | 6362 |
4230 | 6363 g_free(dialog_msg); |
4236 | 6364 g_free(nombre); |
4230 | 6365 |
6366 return 1; | |
6367 } | |
6368 | |
6369 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6370 GaimConnection *gc = sess->aux_data; |
4230 | 6371 va_list ap; |
6372 char *sn, *msg; | |
4236 | 6373 gchar *dialog_msg, *nombre; |
4230 | 6374 struct name_data *data; |
6695 | 6375 GaimBuddy *buddy; |
4230 | 6376 |
6377 va_start(ap, fr); | |
6378 sn = va_arg(ap, char *); | |
6379 msg = va_arg(ap, char *); | |
6380 va_end(ap); | |
6381 | |
8660 | 6382 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6383 "ssi: received authorization request from %s\n", sn); |
4230 | 6384 |
4687 | 6385 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6386 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6387 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6388 else |
6389 nombre = g_strdup(sn); | |
6390 | |
10949 | 6391 dialog_msg = g_strdup_printf( |
6392 _("The user %s wants to add %s to their buddy list for the following reason:\n%s"), | |
6393 nombre, gaim_account_get_username(gc->account), | |
6394 (msg ? msg : _("No reason given."))); | |
6395 | |
4230 | 6396 data = g_new(struct name_data, 1); |
6397 data->gc = gc; | |
6398 data->name = g_strdup(sn); | |
6399 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6400 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6401 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6402 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6403 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6404 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6405 |
4230 | 6406 g_free(dialog_msg); |
4236 | 6407 g_free(nombre); |
4230 | 6408 |
6409 return 1; | |
6410 } | |
6411 | |
6412 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6413 GaimConnection *gc = sess->aux_data; |
4230 | 6414 va_list ap; |
6415 char *sn, *msg; | |
4236 | 6416 gchar *dialog_msg, *nombre; |
4230 | 6417 fu8_t reply; |
6695 | 6418 GaimBuddy *buddy; |
4230 | 6419 |
6420 va_start(ap, fr); | |
6421 sn = va_arg(ap, char *); | |
6422 reply = (fu8_t)va_arg(ap, int); | |
6423 msg = va_arg(ap, char *); | |
6424 va_end(ap); | |
6425 | |
8660 | 6426 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6427 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6428 |
4687 | 6429 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6430 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6431 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6432 else |
6433 nombre = g_strdup(sn); | |
6434 | |
4230 | 6435 if (reply) { |
6436 /* Granted */ | |
7023 | 6437 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
|
6438 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6439 } else { |
6440 /* Denied */ | |
7023 | 6441 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
|
6442 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6443 } |
6444 g_free(dialog_msg); | |
4236 | 6445 g_free(nombre); |
4230 | 6446 |
6447 return 1; | |
6448 } | |
6449 | |
6450 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6451 GaimConnection *gc = sess->aux_data; |
4230 | 6452 va_list ap; |
6453 char *sn; | |
6695 | 6454 GaimBuddy *buddy; |
4230 | 6455 |
6456 va_start(ap, fr); | |
6457 sn = va_arg(ap, char *); | |
6458 va_end(ap); | |
6459 | |
4687 | 6460 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6461 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6462 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6463 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6464 |
6465 return 1; | |
6466 } | |
2086 | 6467 |
5575 | 6468 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6469 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6470 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6471 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6472 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6473 pce->label = _("_Room:"); |
5234 | 6474 pce->identifier = "room"; |
10475 | 6475 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6476 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6477 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6478 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6479 pce->label = _("_Exchange:"); |
5234 | 6480 pce->identifier = "exchange"; |
10475 | 6481 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6482 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6483 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6484 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6485 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6486 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6487 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6488 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6489 |
9754 | 6490 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6491 { | |
6492 GHashTable *defaults; | |
6493 | |
6494 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6495 | |
6496 if (chat_name != NULL) | |
6497 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6498 | |
6499 return defaults; | |
6500 } | |
6501 | |
9917 | 6502 static char *oscar_get_chat_name(GHashTable *data) { |
6503 return g_strdup(g_hash_table_lookup(data, "room")); | |
6504 } | |
6505 | |
8308 | 6506 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6507 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6508 aim_conn_t *cur; |
5234 | 6509 char *name, *exchange; |
6510 | |
6511 name = g_hash_table_lookup(data, "room"); | |
6512 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6513 |
8660 | 6514 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6515 "Attempting to join chat room %s.\n", name); |
8308 | 6516 |
6517 if ((name == NULL) || (*name == '\0')) { | |
6518 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6519 return; | |
6520 } | |
6521 | |
4617 | 6522 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6523 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6524 "chatnav exists, creating room\n"); |
5234 | 6525 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6526 } else { |
6527 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6528 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6529 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6530 "chatnav does not exist, opening chatnav\n"); |
5234 | 6531 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6532 cr->name = g_strdup(name); |
4617 | 6533 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6534 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6535 } |
6536 } | |
6537 | |
8308 | 6538 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6539 OscarData *od = (OscarData *)gc->proto_data; | |
6540 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6541 |
6542 if (ccon == NULL) | |
2086 | 6543 return; |
10404 | 6544 |
8225 | 6545 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6546 ccon->exchange, ccon->name, 0x0); |
6547 } | |
6548 | |
10458 | 6549 static void |
6550 oscar_chat_leave(GaimConnection *gc, int id) | |
6551 { | |
6552 GaimConversation *conv; | |
6553 struct chat_connection *cc; | |
6554 | |
6555 conv = gaim_find_chat(gc, id); | |
6556 | |
6557 g_return_if_fail(conv != NULL); | |
6558 | |
6559 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6560 | |
6561 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6562 oscar_chat_kill(gc, cc); | |
2086 | 6563 } |
6564 | |
8219 | 6565 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6566 OscarData *od = (OscarData *)gc->proto_data; | |
6567 GaimConversation *conv = NULL; | |
2086 | 6568 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6569 char *buf, *buf2; |
9830 | 6570 fu16_t charset, charsubset; |
9807 | 6571 char *charsetstr = NULL; |
10111 | 6572 int len; |
8219 | 6573 |
6574 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6575 return -EINVAL; |
2086 | 6576 |
8219 | 6577 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6578 return -EINVAL; |
2086 | 6579 |
8219 | 6580 buf = gaim_strdup_withhtml(message); |
6581 len = strlen(buf); | |
6582 | |
8962 | 6583 if (strstr(buf, "<IMG ")) |
6584 gaim_conversation_write(conv, "", | |
6585 _("Your IM Image was not sent. " | |
6586 "You cannot send IM Images in AIM chats."), | |
6587 GAIM_MESSAGE_ERROR, time(NULL)); | |
6588 | |
9830 | 6589 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6590 if ((len > c->maxlen) || (len > c->maxvis)) { |
6591 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6592 return -E2BIG; |
8359 | 6593 } |
6594 | |
9831 | 6595 if (charset == AIM_CHARSET_ASCII) |
6596 charsetstr = "us-ascii"; | |
6597 else if (charset == AIM_CHARSET_UNICODE) | |
6598 charsetstr = "unicode-2-0"; | |
6599 else if (charset == AIM_CHARSET_CUSTOM) | |
6600 charsetstr = "iso-8859-1"; | |
9807 | 6601 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6602 g_free(buf2); |
8359 | 6603 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6604 return 0; |
2086 | 6605 } |
6606 | |
10042 | 6607 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6608 { | |
4766 | 6609 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6610 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6611 return "icq"; |
6612 else | |
6613 return "aim"; | |
6614 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6615 |
9975 | 6616 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6617 return "icq"; |
6618 return "aim"; | |
6619 } | |
6620 | |
9972 | 6621 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6622 { |
7334 | 6623 GaimConnection *gc = NULL; |
6624 OscarData *od = NULL; | |
10042 | 6625 GaimAccount *account = NULL; |
6626 GaimPresence *presence; | |
6627 GaimStatus *status; | |
6628 const char *status_id; | |
4687 | 6629 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6630 int i = 0; | |
7334 | 6631 aim_userinfo_t *userinfo = NULL; |
6632 | |
6633 if (b != NULL) | |
6634 account = b->account; | |
6635 if (account != NULL) | |
6636 gc = account->gc; | |
6637 if (gc != NULL) | |
6638 od = gc->proto_data; | |
7945 | 6639 if (od != NULL) |
6640 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6641 |
10042 | 6642 presence = gaim_buddy_get_presence(b); |
6643 status = gaim_presence_get_active_status(presence); | |
6644 status_id = gaim_status_get_id(status); | |
6645 | |
6646 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6647 char *gname; |
7334 | 6648 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6649 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6650 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6651 emblems[i++] = "notauthorized"; | |
6652 } else { | |
6653 emblems[i++] = "offline"; | |
6654 } | |
6655 } | |
4916 | 6656 |
10042 | 6657 if (b->name && aim_sn_is_icq(b->name)) { |
6658 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6659 emblems[i++] = "invisible"; | |
6660 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6661 emblems[i++] = "freeforchat"; |
10042 | 6662 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6663 emblems[i++] = "dnd"; |
10042 | 6664 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6665 emblems[i++] = "na"; |
10042 | 6666 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6667 emblems[i++] = "occupied"; |
10042 | 6668 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6669 emblems[i++] = "away"; |
10042 | 6670 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6671 emblems[i++] = "away"; | |
6672 } | |
6673 | |
6674 if (userinfo != NULL ) { | |
6675 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6676 emblems[i++] = "unconfirmed"; */ | |
6677 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6678 emblems[i++] = "admin"; | |
6679 if (userinfo->flags & AIM_FLAG_AOL) | |
6680 emblems[i++] = "aol"; | |
6681 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6682 emblems[i++] = "wireless"; | |
6683 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6684 emblems[i++] = "activebuddy"; | |
6685 | |
6686 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6687 emblems[i++] = "hiptop"; |
6688 | |
10042 | 6689 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6690 emblems[i++] = "secure"; |
10042 | 6691 } |
7334 | 6692 |
4687 | 6693 *se = emblems[0]; |
6694 *sw = emblems[1]; | |
6695 *nw = emblems[2]; | |
6696 *ne = emblems[3]; | |
6697 } | |
6698 | |
6695 | 6699 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6700 GaimConnection *gc = b->account->gc; |
7283 | 6701 OscarData *od = gc->proto_data; |
7045 | 6702 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6703 GString *str = g_string_new(""); |
5131 | 6704 |
6705 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6706 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6707 |
6708 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6709 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6710 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6711 g_free(charset); |
7011 | 6712 if (away_utf8 != NULL) { |
7091 | 6713 gchar *tmp1, *tmp2; |
9627 | 6714 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6715 g_free(away_utf8); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
6716 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 6717 g_free(tmp2); |
8700 | 6718 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6719 g_free(tmp1); |
8701 | 6720 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6721 g_free(tmp2); |
5836 | 6722 } |
5131 | 6723 } |
8701 | 6724 } |
6725 | |
6726 return g_string_free(str, FALSE); | |
5131 | 6727 } |
6728 | |
10042 | 6729 static char *oscar_status_text(GaimBuddy *b) |
6730 { | |
6731 GaimConnection *gc; | |
6732 OscarData *od; | |
6733 GaimStatus *status; | |
5167 | 6734 gchar *ret = NULL; |
6735 | |
10042 | 6736 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6737 od = gc->proto_data; | |
6738 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6739 | |
6740 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6741 if (aim_sn_is_icq(b->name)) |
8701 | 6742 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6743 else |
6744 ret = g_strdup(_("Away")); | |
5836 | 6745 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6746 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6747 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6748 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6749 } else { |
5167 | 6750 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6751 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6752 ret = g_strdup(_("Not Authorized")); | |
6753 else | |
6754 ret = g_strdup(_("Offline")); | |
6755 } | |
6756 | |
6757 return ret; | |
6758 } | |
6759 | |
5842 | 6760 |
5844 | 6761 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6762 GaimConnection *gc = sess->aux_data; |
7283 | 6763 OscarData *od = gc->proto_data; |
5892 | 6764 va_list ap; |
5842 | 6765 fu16_t type; |
5892 | 6766 fu8_t flags = 0, length = 0; |
6767 char *md5 = NULL; | |
6768 | |
7334 | 6769 |
5842 | 6770 va_start(ap, fr); |
6771 type = va_arg(ap, int); | |
5892 | 6772 |
6773 switch(type) { | |
6774 case 0x0000: | |
6775 case 0x0001: { | |
6776 flags = va_arg(ap, int); | |
6777 length = va_arg(ap, int); | |
6778 md5 = va_arg(ap, char *); | |
6779 | |
6780 if (flags == 0x41) { | |
6781 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6782 od->iconconnecting = TRUE; | |
6783 od->set_icon = TRUE; | |
6784 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6785 } else { | |
6039 | 6786 struct stat st; |
6787 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6788 if (iconfile == NULL) { | |
8363 | 6789 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6790 } else if (!g_stat(iconfile, &st)) { |
6039 | 6791 char *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6792 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 6793 if (file) { |
9532 | 6794 /* XXX - Use g_file_get_contents()? */ |
6039 | 6795 fread(buf, 1, st.st_size, file); |
6796 fclose(file); | |
8660 | 6797 gaim_debug_info("oscar", |
10042 | 6798 "Uploading icon to icon server\n"); |
6879 | 6799 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6800 } else |
8660 | 6801 gaim_debug_error("oscar", |
10042 | 6802 "Can't open buddy icon file!\n"); |
6039 | 6803 g_free(buf); |
6804 } else { | |
8660 | 6805 gaim_debug_error("oscar", |
10042 | 6806 "Can't stat buddy icon file!\n"); |
5892 | 6807 } |
6808 } | |
8363 | 6809 } else if (flags == 0x81) { |
6810 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6811 if (iconfile == NULL) | |
6812 aim_ssi_delicon(od->sess); | |
6813 else | |
6814 aim_ssi_seticon(od->sess, md5, length); | |
6815 } | |
5892 | 6816 } break; |
6817 | |
6818 case 0x0002: { /* We just set an "available" message? */ | |
6819 } break; | |
6820 } | |
6821 | |
5842 | 6822 va_end(ap); |
5844 | 6823 |
6824 return 0; | |
5842 | 6825 } |
5892 | 6826 |
5575 | 6827 static void oscar_set_permit_deny(GaimConnection *gc) { |
6828 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6829 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 6830 |
8175 | 6831 if (od->sess->ssi.received_data) { |
6832 switch (account->perm_deny) { | |
6833 case GAIM_PRIVACY_ALLOW_ALL: | |
6834 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6835 break; | |
6836 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6837 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6838 break; | |
6839 case GAIM_PRIVACY_ALLOW_USERS: | |
6840 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6841 break; | |
6842 case GAIM_PRIVACY_DENY_ALL: | |
6843 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6844 break; | |
6845 case GAIM_PRIVACY_DENY_USERS: | |
6846 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6847 break; | |
6848 default: | |
6849 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6850 break; | |
6851 } | |
6852 } | |
2086 | 6853 } |
6854 | |
5575 | 6855 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 6856 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6857 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6858 if (od->sess->ssi.received_data) |
4889 | 6859 aim_ssi_addpermit(od->sess, who); |
2086 | 6860 } |
6861 | |
5575 | 6862 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 6863 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6864 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6865 if (od->sess->ssi.received_data) |
4889 | 6866 aim_ssi_adddeny(od->sess, who); |
2086 | 6867 } |
6868 | |
5575 | 6869 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 6870 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6871 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6872 if (od->sess->ssi.received_data) |
4889 | 6873 aim_ssi_delpermit(od->sess, who); |
2086 | 6874 } |
6875 | |
5575 | 6876 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 6877 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6878 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6879 if (od->sess->ssi.received_data) |
4889 | 6880 aim_ssi_deldeny(od->sess, who); |
2086 | 6881 } |
6882 | |
9975 | 6883 static GList * |
6884 oscar_status_types(GaimAccount *account) | |
2086 | 6885 { |
9975 | 6886 GList *status_types = NULL; |
6887 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6888 |
9973 | 6889 g_return_val_if_fail(account != NULL, NULL); |
6890 | |
10042 | 6891 /* Oscar-common status types */ |
9991 | 6892 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
6893 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 6894 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 6895 status_types = g_list_append(status_types, type); |
6896 | |
9991 | 6897 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
6898 OSCAR_STATUS_ID_ONLINE, | |
10400 | 6899 _("Online"), FALSE, TRUE, FALSE); |
9976 | 6900 status_types = g_list_append(status_types, type); |
6901 | |
10198 | 6902 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
6903 OSCAR_STATUS_ID_AVAILABLE, | |
6904 _("Available"), TRUE, TRUE, FALSE, | |
6905 "message", _("Message"), | |
6906 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 6907 status_types = g_list_append(status_types, type); |
6908 | |
10195 | 6909 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
6910 OSCAR_STATUS_ID_AWAY, | |
6911 _("Away"), TRUE, TRUE, FALSE, | |
6912 "message", _("Message"), | |
6913 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 6914 status_types = g_list_append(status_types, type); |
6915 | |
6916 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
6917 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 6918 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 6919 status_types = g_list_append(status_types, type); |
6920 | |
6921 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
6922 return status_types; | |
6923 | |
6924 /* ICQ-specific status types */ | |
6925 | |
9991 | 6926 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6927 OSCAR_STATUS_ID_FREE4CHAT, | |
6928 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 6929 status_types = g_list_append(status_types, type); |
6930 | |
9991 | 6931 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
6932 OSCAR_STATUS_ID_OCCUPIED, | |
6933 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 6934 status_types = g_list_append(status_types, type); |
6935 | |
9991 | 6936 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6937 OSCAR_STATUS_ID_DND, | |
6938 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 6939 status_types = g_list_append(status_types, type); |
6940 | |
9991 | 6941 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6942 OSCAR_STATUS_ID_NA, | |
6943 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 6944 status_types = g_list_append(status_types, type); |
9975 | 6945 |
6946 return status_types; | |
4333 | 6947 } |
6948 | |
7172 | 6949 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6950 GaimConnection *gc = data->gc; |
6951 OscarData *od = gc->proto_data; | |
7172 | 6952 GaimBuddy *b; |
6953 GaimGroup *g; | |
6954 | |
6955 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6956 oscar_free_name_data(data); | |
6957 return; | |
6958 } | |
6959 | |
6960 if (!(g = gaim_find_buddys_group(b))) { | |
6961 oscar_free_name_data(data); | |
6962 return; | |
6963 } | |
6964 | |
6965 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6966 |
6967 if (!aim_sncmp(data->name, gc->account->username)) | |
6968 gaim_check_comment(od, text); | |
6969 | |
7172 | 6970 oscar_free_name_data(data); |
6971 } | |
6972 | |
9030 | 6973 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6974 | |
6975 GaimBuddy *buddy; | |
6976 GaimConnection *gc; | |
6977 OscarData *od; | |
6978 struct name_data *data; | |
7172 | 6979 GaimGroup *g; |
6980 char *comment; | |
6981 gchar *comment_utf8; | |
9631 | 6982 gchar *title; |
7172 | 6983 |
9030 | 6984 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6985 | |
6986 buddy = (GaimBuddy *) node; | |
6987 gc = gaim_account_get_connection(buddy->account); | |
6988 od = gc->proto_data; | |
6989 | |
6990 data = g_new(struct name_data, 1); | |
6991 | |
6992 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6993 return; |
9030 | 6994 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6995 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6996 | |
6997 data->gc = gc; | |
9030 | 6998 data->name = g_strdup(buddy->name); |
7172 | 6999 data->nick = NULL; |
7000 | |
9631 | 7001 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7002 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7003 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7004 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7005 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7006 data); | |
9631 | 7007 g_free(title); |
7172 | 7008 |
7009 free(comment); | |
7010 g_free(comment_utf8); | |
7011 } | |
7012 | |
9030 | 7013 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7014 | |
7015 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7016 OscarData *od = gc->proto_data; |
9030 | 7017 |
4333 | 7018 GList *m = NULL; |
9030 | 7019 GaimBlistNodeAction *act; |
7020 | |
7021 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7022 oscar_buddycb_edit_comment, NULL, NULL); |
9030 | 7023 m = g_list_append(m, act); |
7172 | 7024 |
4333 | 7025 if (od->icq) { |
4624 | 7026 #if 0 |
9030 | 7027 act = gaim_blist_node_action_new(_("Get Status Msg"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7028 oscar_get_icqstatusmsg, NULL, NULL); |
9030 | 7029 m = g_list_append(m, act); |
4624 | 7030 #endif |
4333 | 7031 } else { |
7011 | 7032 aim_userinfo_t *userinfo; |
9030 | 7033 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7034 | |
7035 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7036 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7037 | |
7011 | 7038 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7039 act = gaim_blist_node_action_new(_("Direct IM"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7040 oscar_ask_direct_im, NULL, NULL); |
9030 | 7041 m = g_list_append(m, act); |
5917 | 7042 } |
9466 | 7043 #if 0 |
7011 | 7044 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7045 act = gaim_blist_node_action_new(_("Get File"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7046 oscar_ask_getfile, NULL, NULL); |
9030 | 7047 m = g_list_append(m, act); |
5917 | 7048 } |
4826 | 7049 #endif |
4333 | 7050 } |
5131 | 7051 } |
5197 | 7052 |
5131 | 7053 if (od->sess->ssi.received_data) { |
9030 | 7054 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7055 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7056 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7057 gaim_auth_sendrequest_menu, NULL, NULL); |
9030 | 7058 m = g_list_append(m, act); |
4333 | 7059 } |
4916 | 7060 } |
10157 | 7061 |
4333 | 7062 return m; |
7063 } | |
7064 | |
9030 | 7065 |
7066 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7067 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7068 return oscar_buddy_menu((GaimBuddy *) node); | |
7069 } else { | |
7070 return NULL; | |
7071 } | |
7072 } | |
7073 | |
10570 | 7074 static void |
7075 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
7076 { | |
7077 OscarData *od = gc->proto_data; | |
7078 GaimAccount *account = gaim_connection_get_account(gc); | |
7079 GaimRequestField *f; | |
7080 gboolean auth, hide_ip, web_aware; | |
7081 | |
7082 f = gaim_request_fields_get_field(fields, "authorization"); | |
7083 auth = gaim_request_field_bool_get_value(f); | |
7084 | |
7085 f = gaim_request_fields_get_field(fields, "hide_ip"); | |
7086 hide_ip = gaim_request_field_bool_get_value(f); | |
7087 | |
7088 f = gaim_request_fields_get_field(fields, "web_aware"); | |
7089 web_aware = gaim_request_field_bool_get_value(f); | |
7090 | |
7091 gaim_account_set_bool(account, "authorization", auth); | |
7092 gaim_account_set_bool(account, "hide_ip", hide_ip); | |
7093 gaim_account_set_bool(account, "web_aware", web_aware); | |
7094 | |
7095 aim_icq_setsecurity(od->sess, auth, web_aware, hide_ip); | |
7096 } | |
7097 | |
7098 static void | |
7099 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
7100 { | |
7101 GaimConnection *gc = (GaimConnection *) action->context; | |
7102 GaimAccount *account = gaim_connection_get_account(gc); | |
7103 GaimRequestFields *fields; | |
7104 GaimRequestFieldGroup *g; | |
7105 GaimRequestField *f; | |
7106 gboolean auth, hide_ip, web_aware; | |
7107 | |
7108 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7109 hide_ip = gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7110 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7111 | |
7112 fields = gaim_request_fields_new(); | |
7113 | |
7114 g = gaim_request_field_group_new(NULL); | |
7115 | |
7116 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
7117 gaim_request_field_group_add_field(g, f); | |
7118 | |
7119 f = gaim_request_field_bool_new("hide_ip", _("Hide IP address"), hide_ip); | |
7120 gaim_request_field_group_add_field(g, f); | |
7121 | |
7122 f = gaim_request_field_bool_new("web_aware", _("Web aware"), web_aware); | |
7123 gaim_request_field_group_add_field(g, f); | |
7124 | |
7125 gaim_request_fields_add_group(fields, g); | |
7126 | |
7127 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
7128 NULL, fields, | |
7129 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
7130 _("Cancel"), NULL, gc); | |
7131 } | |
9030 | 7132 |
5575 | 7133 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7134 OscarData *od = gc->proto_data; |
5575 | 7135 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7136 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7137 od->setnick = TRUE; | |
7138 od->newsn = g_strdup(nick); | |
7139 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7140 } else { | |
7141 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7142 } | |
7143 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7144 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7145 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7146 } |
7147 } | |
7148 | |
9015 | 7149 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7150 { |
9015 | 7151 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7152 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7153 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7154 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7155 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7156 gc); |
4333 | 7157 } |
7158 | |
9015 | 7159 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7160 { |
9015 | 7161 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7162 OscarData *od = gc->proto_data; |
4333 | 7163 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7164 | |
7165 if (conn) { | |
7166 aim_admin_reqconfirm(od->sess, conn); | |
7167 } else { | |
7168 od->conf = TRUE; | |
7169 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7170 } | |
7171 } | |
7172 | |
9015 | 7173 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7174 { |
9015 | 7175 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7176 OscarData *od = gc->proto_data; |
4333 | 7177 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7178 | |
7179 if (conn) { | |
7180 aim_admin_getinfo(od->sess, conn, 0x11); | |
7181 } else { | |
7182 od->reqemail = TRUE; | |
7183 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7184 } | |
7185 } | |
7186 | |
5575 | 7187 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7188 { |
7283 | 7189 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7190 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
|
7191 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7192 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7193 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7194 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7195 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7196 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7197 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7198 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7199 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7200 |
9015 | 7201 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7202 { |
9015 | 7203 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7204 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7205 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7206 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7207 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7208 gc); |
4333 | 7209 } |
7210 | |
9015 | 7211 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7212 { |
9015 | 7213 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7214 OscarData *od = gc->proto_data; |
4333 | 7215 gchar *nombre, *text, *tmp; |
6695 | 7216 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7217 int num=0; |
7218 | |
6873 | 7219 text = g_strdup(""); |
4333 | 7220 |
4785 | 7221 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7222 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7223 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7224 continue; | |
6695 | 7225 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7226 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7227 continue; |
6695 | 7228 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7229 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7230 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7231 continue; | |
7232 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7233 if (gaim_buddy_get_alias_only(buddy)) |
7234 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7235 else |
7236 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7237 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7238 g_free(text); |
7239 text = tmp; | |
7240 g_free(nombre); | |
7241 num++; | |
7242 } | |
4333 | 7243 } |
2979 | 7244 } |
4333 | 7245 } |
7246 | |
7247 if (!num) { | |
7248 g_free(text); | |
6873 | 7249 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7250 } | |
7251 | |
7252 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7253 "the following buddies"), _("You can re-request " | |
7254 "authorization from these buddies by " | |
7255 "right-clicking on them and selecting " | |
7256 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7257 g_free(text); |
2979 | 7258 } |
7259 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7260 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7261 { |
8950 | 7262 OscarData *od = (OscarData *)gc->proto_data; |
7263 | |
7264 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7265 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7266 |
9015 | 7267 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7268 { |
9015 | 7269 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7270 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7271 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7272 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7273 "searching for."), |
8697 | 7274 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7275 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7276 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7277 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7278 |
9015 | 7279 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7280 { |
9015 | 7281 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7282 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7283 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7284 |
9015 | 7285 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7286 { |
9015 | 7287 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7288 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7289 } |
7290 | |
9015 | 7291 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7292 { |
9015 | 7293 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7294 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7295 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7296 |
9015 | 7297 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7298 { |
9015 | 7299 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7300 OscarData *od = gc->proto_data; |
5575 | 7301 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
|
7302 gaim_notify_uri(gc, substituted); |
5517 | 7303 g_free(substituted); |
4333 | 7304 } |
7305 | |
9015 | 7306 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7307 { |
9015 | 7308 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7309 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7310 } |
7311 | |
5842 | 7312 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7313 { | |
7283 | 7314 OscarData *od = gc->proto_data; |
5844 | 7315 aim_session_t *sess = od->sess; |
5842 | 7316 FILE *file; |
7317 struct stat st; | |
5844 | 7318 |
6039 | 7319 if (iconfile == NULL) { |
8363 | 7320 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7321 } else if (!g_stat(iconfile, &st)) { |
5842 | 7322 char *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7323 file = g_fopen(iconfile, "rb"); |
5842 | 7324 if (file) { |
6052 | 7325 md5_state_t *state; |
6039 | 7326 char md5[16]; |
9532 | 7327 /* XXX - Use g_file_get_contents()? */ |
5842 | 7328 int len = fread(buf, 1, st.st_size, file); |
6039 | 7329 fclose(file); |
6052 | 7330 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7331 md5_init(state); |
7332 md5_append(state, buf, len); | |
7333 md5_finish(state, md5); | |
7334 g_free(state); | |
7335 aim_ssi_seticon(sess, md5, 16); | |
7336 } else | |
8660 | 7337 gaim_debug_error("oscar", |
5842 | 7338 "Can't open buddy icon file!\n"); |
7339 g_free(buf); | |
7340 } else | |
8660 | 7341 gaim_debug_error("oscar", |
5842 | 7342 "Can't stat buddy icon file!\n"); |
7343 } | |
7344 | |
7345 | |
9015 | 7346 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7347 { |
9015 | 7348 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7349 OscarData *od = gc->proto_data; |
4333 | 7350 GList *m = NULL; |
9015 | 7351 GaimPluginAction *act; |
7352 | |
7353 act = gaim_plugin_action_new(_("Set User Info..."), | |
7354 oscar_show_set_info); | |
7355 m = g_list_append(m, act); | |
4333 | 7356 |
10570 | 7357 if (od->icq) |
7358 { | |
9015 | 7359 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7360 oscar_show_set_info_icqurl); | |
7361 m = g_list_append(m, act); | |
8576 | 7362 } |
7363 | |
9015 | 7364 act = gaim_plugin_action_new(_("Change Password..."), |
7365 oscar_change_pass); | |
7366 m = g_list_append(m, act); | |
4617 | 7367 |
10570 | 7368 if (od->sess->authinfo->chpassurl != NULL) |
7369 { | |
9015 | 7370 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7371 oscar_show_chpassurl); | |
7372 m = g_list_append(m, act); | |
7373 | |
7374 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7375 oscar_show_imforwardingurl); | |
7376 m = g_list_append(m, act); | |
7026 | 7377 } |
7378 | |
10570 | 7379 m = g_list_append(m, NULL); |
7380 | |
7381 if (od->icq) | |
7382 { | |
7383 /* ICQ actions */ | |
7384 act = gaim_plugin_action_new(_("Show privacy options..."), | |
7385 oscar_show_icq_privacy_opts); | |
7386 m = g_list_append(m, act); | |
7387 } | |
7388 else | |
7389 { | |
4617 | 7390 /* AIM actions */ |
9015 | 7391 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7392 oscar_show_format_screenname); | |
7393 m = g_list_append(m, act); | |
7394 | |
7395 act = gaim_plugin_action_new(_("Confirm Account"), | |
7396 oscar_confirm_account); | |
7397 m = g_list_append(m, act); | |
7398 | |
7399 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7400 oscar_show_email); | |
7401 m = g_list_append(m, act); | |
7402 | |
7403 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7404 oscar_show_change_email); | |
7405 m = g_list_append(m, act); | |
2086 | 7406 } |
4333 | 7407 |
7408 m = g_list_append(m, NULL); | |
7409 | |
9015 | 7410 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7411 oscar_show_awaitingauth); | |
7412 m = g_list_append(m, act); | |
4333 | 7413 |
2086 | 7414 m = g_list_append(m, NULL); |
4333 | 7415 |
9015 | 7416 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7417 oscar_show_find_email); | |
7418 m = g_list_append(m, act); | |
4333 | 7419 |
8591 | 7420 #if 0 |
9015 | 7421 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7422 show_find_info); | |
7423 m = g_list_append(m, act); | |
8591 | 7424 #endif |
2086 | 7425 |
7426 return m; | |
7427 } | |
7428 | |
5575 | 7429 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7430 { |
7283 | 7431 OscarData *od = gc->proto_data; |
4617 | 7432 |
7433 if (od->icq) { | |
7434 aim_icq_changepasswd(od->sess, new); | |
2086 | 7435 } else { |
4617 | 7436 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7437 if (conn) { | |
7438 aim_admin_changepasswd(od->sess, conn, new, old); | |
7439 } else { | |
7440 od->chpass = TRUE; | |
7441 od->oldp = g_strdup(old); | |
7442 od->newp = g_strdup(new); | |
7443 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7444 } | |
2086 | 7445 } |
7446 } | |
7447 | |
6059 | 7448 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7449 { |
7283 | 7450 OscarData *od = gc->proto_data; |
8971 | 7451 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
|
7452 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7453 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7454 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7455 |
8971 | 7456 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7457 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7458 |
9935 | 7459 static void |
7460 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7461 { | |
7462 GaimConnection *gc = data; | |
7463 OscarData *od = gc->proto_data; | |
7464 aim_session_t *sess = od->sess; | |
7465 fu32_t presence; | |
7466 | |
7467 presence = aim_ssi_getpresence(sess->ssi.local); | |
7468 | |
7469 if (value) { | |
9992 | 7470 /* Based on the packet capture I thought it was the first one */ |
7471 /* Stu thinks it's the second one. */ | |
7472 /* presence |= 0x00400000; */ | |
9971 | 7473 presence &= ~0x00020000; |
9935 | 7474 aim_ssi_setpresence(sess, presence); |
7475 } else { | |
9992 | 7476 /* presence &= ~0x00400000; */ |
9971 | 7477 presence |= 0x00020000; |
9935 | 7478 aim_ssi_setpresence(sess, presence); |
7479 } | |
7480 } | |
7481 | |
10653 | 7482 #if USE_PRPL_PREFERENCES |
9935 | 7483 static GaimPluginPrefFrame * |
9936 | 7484 get_plugin_pref_frame(GaimPlugin *plugin) |
7485 { | |
9935 | 7486 GaimPluginPrefFrame *frame; |
7487 GaimPluginPref *ppref; | |
7488 | |
7489 frame = gaim_plugin_pref_frame_new(); | |
7490 | |
7491 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7492 gaim_plugin_pref_frame_add(frame, ppref); | |
7493 | |
7494 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7495 gaim_plugin_pref_frame_add(frame, ppref); | |
7496 | |
7497 return frame; | |
7498 } | |
10653 | 7499 #endif |
9935 | 7500 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7501 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7502 { |
9308 | 7503 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7504 NULL, /* user_splits */ |
7505 NULL, /* protocol_options */ | |
10674 | 7506 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
7507 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 7508 oscar_list_icon, /* list_icon */ |
7509 oscar_list_emblems, /* list_emblems */ | |
7510 oscar_status_text, /* status_text */ | |
7511 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7512 oscar_status_types, /* status_types */ |
9475 | 7513 oscar_blist_node_menu, /* blist_node_menu */ |
7514 oscar_chat_info, /* chat_info */ | |
9754 | 7515 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7516 oscar_login, /* login */ |
7517 oscar_close, /* close */ | |
7518 oscar_send_im, /* send_im */ | |
7519 oscar_set_info, /* set_info */ | |
7520 oscar_send_typing, /* send_typing */ | |
7521 oscar_get_info, /* get_info */ | |
9973 | 7522 oscar_set_status, /* set_status */ |
9475 | 7523 oscar_set_idle, /* set_idle */ |
7524 oscar_change_passwd, /* change_passwd */ | |
7525 oscar_add_buddy, /* add_buddy */ | |
10866 | 7526 NULL, /* add_buddies */ |
9475 | 7527 oscar_remove_buddy, /* remove_buddy */ |
10866 | 7528 NULL, /* remove_buddies */ |
9475 | 7529 oscar_add_permit, /* add_permit */ |
7530 oscar_add_deny, /* add_deny */ | |
7531 oscar_rem_permit, /* rem_permit */ | |
7532 oscar_rem_deny, /* rem_deny */ | |
7533 oscar_set_permit_deny, /* set_permit_deny */ | |
7534 oscar_warn, /* warn */ | |
7535 oscar_join_chat, /* join_chat */ | |
7536 NULL, /* reject_chat */ | |
9973 | 7537 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7538 oscar_chat_invite, /* chat_invite */ |
7539 oscar_chat_leave, /* chat_leave */ | |
7540 NULL, /* chat_whisper */ | |
7541 oscar_send_chat, /* chat_send */ | |
7542 oscar_keepalive, /* keepalive */ | |
7543 NULL, /* register_user */ | |
7544 NULL, /* get_cb_info */ | |
7545 NULL, /* get_cb_away */ | |
7546 oscar_alias_buddy, /* alias_buddy */ | |
7547 oscar_move_buddy, /* group_buddy */ | |
7548 oscar_rename_group, /* rename_group */ | |
7549 NULL, /* buddy_free */ | |
7550 oscar_convo_closed, /* convo_closed */ | |
7551 NULL, /* normalize */ | |
7552 oscar_set_icon, /* set_buddy_icon */ | |
7553 NULL, /* remove_group */ | |
7554 NULL, /* get_cb_real_name */ | |
7555 NULL, /* set_chat_topic */ | |
7556 NULL, /* find_blist_chat */ | |
7557 NULL, /* roomlist_get_list */ | |
7558 NULL, /* roomlist_cancel */ | |
7559 NULL, /* roomlist_expand_category */ | |
7560 oscar_can_receive_file, /* can_receive_file */ | |
7561 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7562 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7563 |
10653 | 7564 #if USE_PRPL_PREFERENCES |
9935 | 7565 static GaimPluginUiInfo prefs_info = { |
7566 get_plugin_pref_frame | |
7567 }; | |
10653 | 7568 #endif |
9935 | 7569 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7570 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7571 { |
9943 | 7572 GAIM_PLUGIN_MAGIC, |
7573 GAIM_MAJOR_VERSION, | |
7574 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7575 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7576 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7577 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7578 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7579 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7580 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7581 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7582 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7583 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7584 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7585 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7586 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7587 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7588 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7589 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7590 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7591 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7592 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7593 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7594 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7595 NULL, /**< ui_info */ |
8993 | 7596 &prpl_info, /**< extra_info */ |
10653 | 7597 #if USE_PRPL_PREFERENCES |
10487 | 7598 NULL, /**< prefs_info */ |
10653 | 7599 #else |
7600 NULL, /**< prefs_info */ | |
7601 #endif | |
9015 | 7602 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7603 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7604 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7605 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7606 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7607 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7608 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7609 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7610 gaim_debug_register_category("oscar"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7611 |
9830 | 7612 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7613 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7614 | |
7615 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7616 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7617 | |
7618 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7619 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7620 |
9935 | 7621 gaim_prefs_add_none("/plugins/prpl/oscar"); |
7622 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7623 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7624 } |
7625 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7626 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |