Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 11033:50224ac8184d
[gaim-migrate @ 12919]
Ok, this is debug window filtering. Sadrul was going to do this with a text entry, but I like this better, feel free to disagree with me. It's not the prettiest in a couple places, most notable gtkmain.c where a bunch of categories that don't currently have a home get registered. I added some plugin_(un)load functions to some plugins to place the (un)register functions. Though I didn't do that for the prpls. Comments and cleanups welcome. (Oh, I've been seeing some crashes on quit, but I haven't been able to get it to happen reliably so I'm not sure if it's my code or some transient HEAD oscar/other crash.)
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Tue, 28 Jun 2005 06:13:07 +0000 |
parents | 1d58cc6c4552 |
children | c716cc44bfaa |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
6 * Some code copyright (C) 2001-2003, Sean Egan | |
8151 | 7 * Some code copyright (C) 2001-2004, Mark Doliner <thekingant@users.sourceforge.net> |
6302 | 8 * |
9 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 10 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 11 * |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10485 | 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2086 | 20 * GNU General Public License for more details. |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 * | |
26 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
31 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
32 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
33 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "ft.h" |
6982 | 36 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
37 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
38 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "privacy.h" |
2086 | 40 #include "prpl.h" |
4889 | 41 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
42 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "util.h" |
9943 | 44 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 |
2086 | 46 #include "aim.h" |
5842 | 47 #include "md5.h" |
2086 | 48 |
9976 | 49 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
50 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
51 #define OSCAR_STATUS_ID_ONLINE "online" | |
9991 | 52 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 53 #define OSCAR_STATUS_ID_AWAY "away" |
54 #define OSCAR_STATUS_ID_DND "dnd" | |
55 #define OSCAR_STATUS_ID_NA "na" | |
56 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
57 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
58 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 59 |
2086 | 60 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
61 | |
7283 | 62 #define OSCAR_CONNECT_STEPS 6 |
9830 | 63 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
10570 | 64 #define OSCAR_DEFAULT_AUTHORIZATION TRUE |
65 #define OSCAR_DEFAULT_HIDE_IP TRUE | |
66 #define OSCAR_DEFAULT_WEB_AWARE FALSE | |
7283 | 67 |
10329 | 68 #define FAIM_DEBUG_LEVEL 0 |
69 | |
7376 | 70 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
71 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 72 |
4665 | 73 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
74 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 75 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 76 |
7283 | 77 typedef struct _OscarData OscarData; |
78 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
79 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
80 aim_conn_t *conn; |
2086 | 81 |
82 guint cnpa; | |
83 guint paspa; | |
3694 | 84 guint emlpa; |
4804 | 85 guint icopa; |
2086 | 86 |
4823 | 87 gboolean iconconnecting; |
5842 | 88 gboolean set_icon; |
4823 | 89 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
90 GSList *create_rooms; |
2086 | 91 |
92 gboolean conf; | |
93 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
94 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
95 char *email; |
2979 | 96 gboolean setnick; |
97 char *newsn; | |
2086 | 98 gboolean chpass; |
99 char *oldp; | |
100 char *newp; | |
9971 | 101 |
2086 | 102 GSList *oscar_chats; |
103 GSList *direct_ims; | |
3630 | 104 GSList *file_transfers; |
4738 | 105 GHashTable *buddyinfo; |
4804 | 106 GSList *requesticon; |
2086 | 107 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
108 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
109 gboolean icq; |
4804 | 110 guint icontimer; |
5968 | 111 guint getblisttimer; |
8341 | 112 guint getinfotimer; |
10567 | 113 gint timeoffset; |
2993 | 114 |
115 struct { | |
4230 | 116 guint maxwatchers; /* max users who can watch you */ |
2993 | 117 guint maxbuddies; /* max users you can watch */ |
4230 | 118 guint maxgroups; /* max groups in server list */ |
2993 | 119 guint maxpermits; /* max users on permit list */ |
120 guint maxdenies; /* max users on deny list */ | |
121 guint maxsiglen; /* max size (bytes) of profile */ | |
122 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
123 } rights; | |
2086 | 124 }; |
125 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
126 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
127 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
128 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
129 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
130 |
2086 | 131 struct chat_connection { |
132 char *name; | |
133 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
134 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
135 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
136 aim_conn_t *conn; |
2086 | 137 int inpa; |
138 int id; | |
5575 | 139 GaimConnection *gc; /* i hate this. */ |
8733 | 140 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
141 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
142 int maxvis; |
2086 | 143 }; |
144 | |
8971 | 145 struct oscar_direct_im { |
5575 | 146 GaimConnection *gc; |
2086 | 147 char name[80]; |
148 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
149 aim_conn_t *conn; |
3008 | 150 gboolean connected; |
8978 | 151 gboolean gpc_pend; |
152 gboolean killme; | |
8984 | 153 gboolean donttryagain; |
2086 | 154 }; |
155 | |
156 struct ask_direct { | |
5575 | 157 GaimConnection *gc; |
2086 | 158 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
159 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
160 fu8_t cookie[8]; |
8984 | 161 gboolean donttryagain; |
2086 | 162 }; |
163 | |
7011 | 164 /* |
165 * Various PRPL-specific buddy info that we want to keep track of | |
166 * Some other info is maintained by locate.c, and I'd like to move | |
167 * the rest of this to libfaim, mostly im.c | |
168 */ | |
4738 | 169 struct buddyinfo { |
170 gboolean typingnot; | |
6292 | 171 gchar *availmsg; |
6857 | 172 fu32_t ipaddr; |
5836 | 173 |
174 unsigned long ico_me_len; | |
175 unsigned long ico_me_csum; | |
176 time_t ico_me_time; | |
177 gboolean ico_informed; | |
4738 | 178 |
179 unsigned long ico_len; | |
180 unsigned long ico_csum; | |
181 time_t ico_time; | |
182 gboolean ico_need; | |
7406 | 183 gboolean ico_sent; |
2086 | 184 }; |
185 | |
4230 | 186 struct name_data { |
5575 | 187 GaimConnection *gc; |
4230 | 188 gchar *name; |
3453 | 189 gchar *nick; |
3141 | 190 }; |
191 | |
5129 | 192 static char *msgerrreason[] = { |
193 N_("Invalid error"), | |
194 N_("Invalid SNAC"), | |
195 N_("Rate to host"), | |
196 N_("Rate to client"), | |
197 N_("Not logged in"), | |
198 N_("Service unavailable"), | |
199 N_("Service not defined"), | |
200 N_("Obsolete SNAC"), | |
201 N_("Not supported by host"), | |
202 N_("Not supported by client"), | |
203 N_("Refused by client"), | |
204 N_("Reply too big"), | |
205 N_("Responses lost"), | |
206 N_("Request denied"), | |
207 N_("Busted SNAC payload"), | |
208 N_("Insufficient rights"), | |
209 N_("In local permit/deny"), | |
210 N_("Too evil (sender)"), | |
211 N_("Too evil (receiver)"), | |
212 N_("User temporarily unavailable"), | |
213 N_("No match"), | |
214 N_("List overflow"), | |
215 N_("Request ambiguous"), | |
216 N_("Queue full"), | |
217 N_("Not while on AOL") | |
218 }; | |
219 static int msgerrreasonlen = 25; | |
220 | |
221 /* All the libfaim->gaim callback functions */ | |
222 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 224 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 225 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
226 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 233 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 234 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 235 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
236 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
|
237 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
|
238 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
|
239 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
|
240 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 241 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
242 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
243 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 244 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 245 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
246 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
252 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
253 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
254 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
255 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
256 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 276 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 277 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
278 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
280 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
281 | |
282 /* for DirectIM/image transfer */ | |
283 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
284 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 286 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 287 |
288 /* for file transfer */ | |
289 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
290 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
291 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
292 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
293 | |
294 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 295 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 296 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 297 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 298 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
299 | |
5836 | 300 static void oscar_free_name_data(struct name_data *data) { |
4230 | 301 g_free(data->name); |
302 g_free(data->nick); | |
303 g_free(data); | |
304 } | |
305 | |
5836 | 306 static void oscar_free_buddyinfo(void *data) { |
307 struct buddyinfo *bi = data; | |
6292 | 308 g_free(bi->availmsg); |
5836 | 309 g_free(bi); |
310 } | |
311 | |
9807 | 312 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 313 { |
314 int i = 0; | |
9826 | 315 int charset = AIM_CHARSET_ASCII; |
5129 | 316 |
317 /* Determine how we can send this message. Per the warnings elsewhere | |
318 * in this file, these little checks determine the simplest encoding | |
319 * we can use for a given message send using it. */ | |
320 while (utf8[i]) { | |
321 if ((unsigned char)utf8[i] > 0x7f) { | |
322 /* not ASCII! */ | |
9826 | 323 charset = AIM_CHARSET_CUSTOM; |
5129 | 324 break; |
325 } | |
326 i++; | |
327 } | |
328 while (utf8[i]) { | |
329 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
330 * followed by 0xc0-0xc3 in the second */ | |
331 if ((unsigned char)utf8[i] < 0x80) { | |
332 i++; | |
333 continue; | |
334 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
335 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
336 i += 2; | |
337 continue; | |
338 } | |
9826 | 339 charset = AIM_CHARSET_UNICODE; |
5129 | 340 break; |
341 } | |
342 | |
9807 | 343 return charset; |
5129 | 344 } |
345 | |
8225 | 346 /* |
347 * Take a string of the form charset="bleh" where bleh is | |
348 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
349 * return a newly allocated string containing bleh. | |
350 */ | |
351 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 352 { |
8225 | 353 gchar *ret = NULL; |
354 char *begin, *end; | |
355 | |
9933 | 356 g_return_val_if_fail(encoding != NULL, NULL); |
357 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
358 /* Make sure encoding begins with charset= */ |
10540 | 359 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
360 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
361 { | |
8225 | 362 return NULL; |
10540 | 363 } |
8225 | 364 |
365 begin = strchr(encoding, '"'); | |
366 end = strrchr(encoding, '"'); | |
367 | |
368 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
369 return NULL; | |
370 | |
371 ret = g_strndup(begin+1, (end-1) - begin); | |
372 | |
373 return ret; | |
374 } | |
375 | |
9830 | 376 static gchar * |
377 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 378 { |
379 gchar *utf8 = NULL; | |
9595 | 380 |
381 if ((encoding == NULL) || encoding[0] == '\0') { | |
382 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 383 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 384 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 385 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 386 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 387 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 388 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 389 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 390 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 391 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 392 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
393 } | |
394 | |
395 /* | |
396 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
397 * we have been unable to convert the text to utf-8 from the encoding | |
398 * that was specified. So we check if the text is valid utf-8 then | |
399 * just copy it. | |
400 */ | |
401 if (utf8 == NULL) { | |
9638 | 402 if (textlen != 0 && *text != '\0' |
403 && !g_utf8_validate(text, textlen, NULL)) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
404 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 405 else |
9481 | 406 utf8 = g_strndup(text, textlen); |
5129 | 407 } |
408 | |
409 return utf8; | |
410 } | |
411 | |
9830 | 412 static gchar * |
9908 | 413 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 414 { |
415 gchar *ret = NULL; | |
416 GError *err = NULL; | |
417 | |
9908 | 418 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
419 return NULL; | |
420 | |
421 if (strcasecmp("UTF-8", charsetstr)) { | |
422 if (fallback) | |
423 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
424 else | |
425 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
426 if (err != NULL) { | |
427 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
428 charsetstr, err->message); | |
429 g_error_free(err); | |
430 } | |
431 } else { | |
432 if (g_utf8_validate(data, datalen, NULL)) | |
433 ret = g_strndup(data, datalen); | |
434 else | |
435 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
436 } | |
437 | |
438 return ret; | |
439 } | |
440 | |
441 /* | |
442 * We try decoding using two different character sets. The charset | |
443 * specified in the IM determines the order in which we attempt to | |
444 * decode. We do this because there are lots of broken ICQ clients | |
445 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
446 * able to deal with that crap, then people complain like banshees. | |
447 * charsetstr1 is always set to what the correct encoding should be. | |
448 */ | |
449 static gchar * | |
450 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
451 { | |
452 gchar *ret = NULL; | |
453 const gchar *charsetstr1, *charsetstr2; | |
454 | |
455 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 456 |
457 if ((datalen == 0) || (data == NULL)) | |
458 return NULL; | |
459 | |
9908 | 460 if (charset == AIM_CHARSET_UNICODE) { |
461 charsetstr1 = "UCS-2BE"; | |
462 charsetstr2 = "UTF-8"; | |
463 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 464 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 465 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 466 else |
9908 | 467 charsetstr1 = "ISO-8859-1"; |
468 charsetstr2 = "UTF-8"; | |
469 } else if (charset == AIM_CHARSET_ASCII) { | |
470 /* Should just be "ASCII" */ | |
9914 | 471 charsetstr1 = "ASCII"; |
9908 | 472 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
473 } else if (charset == 0x000d) { | |
9830 | 474 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 475 charsetstr1 = "ISO-8859-1"; |
476 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
477 } else { | |
9830 | 478 /* Unknown, hope for valid UTF-8... */ |
9908 | 479 charsetstr1 = "UTF-8"; |
480 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
481 } | |
482 | |
483 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
484 if (ret == NULL) | |
485 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
486 if (ret == NULL) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
487 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9830 | 488 |
489 return ret; | |
490 } | |
491 | |
492 static void | |
493 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 494 gchar **msg, int *msglen_int, |
9830 | 495 fu16_t *charset, fu16_t *charsubset) |
496 { | |
497 OscarData *od = gc->proto_data; | |
498 GaimAccount *account = gaim_connection_get_account(gc); | |
499 GError *err = NULL; | |
500 aim_userinfo_t *userinfo = NULL; | |
501 const gchar *charsetstr; | |
10039 | 502 gsize msglen; |
9830 | 503 |
504 /* Attempt to send as ASCII */ | |
10098 | 505 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 506 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 507 *charset = AIM_CHARSET_ASCII; |
9830 | 508 *charsubset = 0x0000; |
10039 | 509 *msglen_int = msglen; |
9830 | 510 return; |
511 } | |
512 | |
513 /* | |
10565 | 514 * If we're sending to an ICQ user, and they are in our |
515 * buddy list, and they are advertising the Unicode | |
516 * capability, and they are online, then attempt to send | |
517 * as UCS-2BE. | |
9830 | 518 */ |
9975 | 519 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 520 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
521 | |
10565 | 522 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
523 { | |
524 GaimBuddy *b; | |
525 b = gaim_find_buddy(account, destsn); | |
526 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
527 { | |
528 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
529 if (*msg != NULL) | |
530 { | |
531 *charset = AIM_CHARSET_UNICODE; | |
532 *charsubset = 0x0000; | |
533 *msglen_int = msglen; | |
534 return; | |
535 } | |
9830 | 536 } |
537 } | |
538 | |
539 /* | |
540 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
541 * ICQ then attempt to send as the user specified character encoding. | |
542 */ | |
543 charsetstr = "ISO-8859-1"; | |
9975 | 544 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 545 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
546 | |
10097 | 547 /* |
548 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
549 * can be converted to "charsetstr" | |
550 */ | |
10039 | 551 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 552 if (*msg != NULL) { |
553 *charset = AIM_CHARSET_CUSTOM; | |
554 *charsubset = 0x0000; | |
10039 | 555 *msglen_int = msglen; |
9830 | 556 return; |
557 } | |
558 | |
559 /* | |
560 * Nothing else worked, so send as UCS-2BE. | |
561 */ | |
10039 | 562 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 563 if (*msg != NULL) { |
564 *charset = AIM_CHARSET_UNICODE; | |
565 *charsubset = 0x0000; | |
10039 | 566 *msglen_int = msglen; |
9830 | 567 return; |
568 } | |
569 | |
9908 | 570 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 571 g_error_free(err); |
572 | |
573 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
574 *msg = g_strdup(from); | |
10039 | 575 *msglen_int = strlen(*msg); |
9830 | 576 *charset = AIM_CHARSET_ASCII; |
577 *charsubset = 0x0000; | |
578 return; | |
579 } | |
580 | |
9407 | 581 gchar *oscar_caps_to_string(guint caps) |
8701 | 582 { |
9407 | 583 GString *str; |
584 gchar *tmp; | |
8701 | 585 guint bit = 1; |
586 | |
9407 | 587 str = g_string_new(""); |
588 | |
8701 | 589 if (!caps) { |
590 return NULL; | |
591 } else while (bit <= AIM_CAPS_LAST) { | |
592 if (bit & caps) { | |
593 switch (bit) { | |
594 case AIM_CAPS_BUDDYICON: | |
595 tmp = _("Buddy Icon"); | |
596 break; | |
597 case AIM_CAPS_TALK: | |
598 tmp = _("Voice"); | |
599 break; | |
600 case AIM_CAPS_DIRECTIM: | |
601 tmp = _("AIM Direct IM"); | |
602 break; | |
603 case AIM_CAPS_CHAT: | |
604 tmp = _("Chat"); | |
605 break; | |
606 case AIM_CAPS_GETFILE: | |
607 tmp = _("Get File"); | |
608 break; | |
609 case AIM_CAPS_SENDFILE: | |
610 tmp = _("Send File"); | |
611 break; | |
612 case AIM_CAPS_GAMES: | |
613 case AIM_CAPS_GAMES2: | |
614 tmp = _("Games"); | |
615 break; | |
616 case AIM_CAPS_ADDINS: | |
617 tmp = _("Add-Ins"); | |
618 break; | |
619 case AIM_CAPS_SENDBUDDYLIST: | |
620 tmp = _("Send Buddy List"); | |
621 break; | |
622 case AIM_CAPS_ICQ_DIRECT: | |
623 tmp = _("ICQ Direct Connect"); | |
624 break; | |
625 case AIM_CAPS_APINFO: | |
626 tmp = _("AP User"); | |
627 break; | |
628 case AIM_CAPS_ICQRTF: | |
629 tmp = _("ICQ RTF"); | |
630 break; | |
631 case AIM_CAPS_EMPTY: | |
632 tmp = _("Nihilist"); | |
633 break; | |
634 case AIM_CAPS_ICQSERVERRELAY: | |
635 tmp = _("ICQ Server Relay"); | |
636 break; | |
637 case AIM_CAPS_ICQUTF8OLD: | |
638 tmp = _("Old ICQ UTF8"); | |
639 break; | |
640 case AIM_CAPS_TRILLIANCRYPT: | |
641 tmp = _("Trillian Encryption"); | |
642 break; | |
643 case AIM_CAPS_ICQUTF8: | |
644 tmp = _("ICQ UTF8"); | |
645 break; | |
646 case AIM_CAPS_HIPTOP: | |
647 tmp = _("Hiptop"); | |
648 break; | |
649 case AIM_CAPS_SECUREIM: | |
650 tmp = _("Security Enabled"); | |
651 break; | |
652 case AIM_CAPS_VIDEO: | |
653 tmp = _("Video Chat"); | |
654 break; | |
655 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
656 case AIM_CAPS_ICHATAV: | |
657 tmp = _("iChat AV"); | |
658 break; | |
659 case AIM_CAPS_LIVEVIDEO: | |
660 tmp = _("Live Video"); | |
661 break; | |
662 case AIM_CAPS_CAMERA: | |
663 tmp = _("Camera"); | |
664 break; | |
665 default: | |
666 tmp = NULL; | |
667 break; | |
668 } | |
669 if (tmp) | |
9532 | 670 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 671 } |
672 bit <<= 1; | |
673 } | |
9407 | 674 |
675 return g_string_free(str, FALSE); | |
8701 | 676 } |
677 | |
678 static char *oscar_icqstatus(int state) { | |
679 /* Make a cute little string that shows the status of the dude or dudet */ | |
680 if (state & AIM_ICQ_STATE_CHAT) | |
681 return g_strdup_printf(_("Free For Chat")); | |
682 else if (state & AIM_ICQ_STATE_DND) | |
683 return g_strdup_printf(_("Do Not Disturb")); | |
684 else if (state & AIM_ICQ_STATE_OUT) | |
685 return g_strdup_printf(_("Not Available")); | |
686 else if (state & AIM_ICQ_STATE_BUSY) | |
687 return g_strdup_printf(_("Occupied")); | |
688 else if (state & AIM_ICQ_STATE_AWAY) | |
689 return g_strdup_printf(_("Away")); | |
690 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
691 return g_strdup_printf(_("Web Aware")); | |
692 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
693 return g_strdup_printf(_("Invisible")); | |
694 else | |
695 return g_strdup_printf(_("Online")); | |
696 } | |
697 | |
9973 | 698 static void |
699 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 700 { |
701 gchar *utf8; | |
702 | |
703 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 704 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 705 g_free(utf8); |
706 } | |
707 } | |
708 | |
9973 | 709 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 710 { |
10042 | 711 OscarData *od; |
712 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
713 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
714 GaimStatus *status = NULL; |
8701 | 715 GaimGroup *g = NULL; |
716 struct buddyinfo *bi = NULL; | |
717 char *tmp; | |
718 | |
10042 | 719 od = gc->proto_data; |
720 account = gaim_connection_get_account(gc); | |
721 | |
722 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 723 return; |
724 | |
725 if (userinfo == NULL) | |
726 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
727 | |
728 if (b == NULL) | |
10042 | 729 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 730 |
731 if (b != NULL) | |
10498 | 732 { |
8701 | 733 g = gaim_find_buddys_group(b); |
10498 | 734 presence = gaim_buddy_get_presence(b); |
735 status = gaim_presence_get_active_status(presence); | |
736 } | |
8701 | 737 |
738 if (userinfo != NULL) | |
739 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
740 | |
8733 | 741 if (b != NULL) { |
10498 | 742 if (gaim_presence_is_online(presence)) { |
9975 | 743 if (aim_sn_is_icq(b->name)) { |
8733 | 744 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
745 oscar_string_append(str, newline, _("Status"), tmp); | |
746 g_free(tmp); | |
747 } | |
748 } else { | |
9625 | 749 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 750 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
751 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
752 else | |
753 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 754 } |
8733 | 755 } |
8701 | 756 |
757 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 758 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 759 (bi->ipaddr & 0xff000000) >> 24, |
760 (bi->ipaddr & 0x00ff0000) >> 16, | |
761 (bi->ipaddr & 0x0000ff00) >> 8, | |
762 (bi->ipaddr & 0x000000ff)); | |
763 oscar_string_append(str, newline, _("IP Address"), tmp); | |
764 g_free(tmp); | |
765 } | |
766 | |
767 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
768 tmp = oscar_caps_to_string(userinfo->capabilities); | |
769 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 770 g_free(tmp); |
8701 | 771 } |
772 | |
773 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
774 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
775 if (tmp != NULL) { | |
9625 | 776 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 777 g_free(tmp); |
9625 | 778 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
779 g_free(tmp2); | |
8701 | 780 } |
781 } | |
782 | |
10498 | 783 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_status_is_available(status)) { |
8701 | 784 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
785 oscar_string_append(str, newline, _("Available"), tmp); | |
786 g_free(tmp); | |
787 } | |
788 } | |
789 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
790 static char *extract_name(const char *name) { |
4121 | 791 char *tmp, *x; |
2086 | 792 int i, j; |
4120 | 793 |
794 if (!name) | |
4121 | 795 return NULL; |
10042 | 796 |
4120 | 797 x = strchr(name, '-'); |
4121 | 798 |
2086 | 799 if (!x) return NULL; |
800 x = strchr(++x, '-'); | |
801 if (!x) return NULL; | |
802 tmp = g_strdup(++x); | |
803 | |
804 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
805 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
806 if (x[i] != '%') { |
2086 | 807 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
808 continue; |
2086 | 809 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
810 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
811 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
812 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 813 } |
814 | |
815 tmp[j] = 0; | |
816 return tmp; | |
817 } | |
818 | |
10458 | 819 static struct chat_connection * |
820 find_oscar_chat(GaimConnection *gc, int id) | |
821 { | |
822 OscarData *od = (OscarData *)gc->proto_data; | |
823 GSList *cur; | |
824 struct chat_connection *cc; | |
825 | |
826 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
827 { | |
828 cc = (struct chat_connection *)cur->data; | |
829 if (cc->id == id) | |
830 return cc; | |
831 } | |
832 | |
833 return NULL; | |
834 } | |
835 | |
836 static struct chat_connection * | |
837 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
838 { | |
839 OscarData *od = (OscarData *)gc->proto_data; | |
840 GSList *cur; | |
841 struct chat_connection *cc; | |
842 | |
843 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
844 { | |
845 cc = (struct chat_connection *)cur->data; | |
846 if (cc->conn == conn) | |
847 return cc; | |
848 } | |
849 | |
850 return NULL; | |
851 } | |
852 | |
853 static struct chat_connection * | |
854 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
855 { | |
856 OscarData *od = (OscarData *)gc->proto_data; | |
857 GSList *cur; | |
858 struct chat_connection *cc; | |
859 | |
860 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
861 { | |
862 cc = (struct chat_connection *)cur->data; | |
863 if (cc->conv == conv) | |
864 return cc; | |
865 } | |
866 | |
867 return NULL; | |
868 } | |
869 | |
870 static void | |
871 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
872 { | |
873 OscarData *od = (OscarData *)gc->proto_data; | |
874 | |
875 /* Notify the conversation window that we've left the chat */ | |
876 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
877 | |
878 /* Destroy the chat_connection */ | |
879 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
880 if (cc->inpa > 0) | |
881 gaim_input_remove(cc->inpa); | |
882 aim_conn_kill(od->sess, &cc->conn); | |
883 g_free(cc->name); | |
884 g_free(cc->show); | |
885 g_free(cc); | |
8219 | 886 } |
887 | |
8971 | 888 /***************************************************************************** |
889 * Begin scary direct im stuff | |
890 *****************************************************************************/ | |
891 | |
892 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
893 GSList *d = od->direct_ims; | |
894 struct oscar_direct_im *m = NULL; | |
895 | |
896 while (d) { | |
897 m = (struct oscar_direct_im *)d->data; | |
898 if (!aim_sncmp(who, m->name)) | |
899 return m; | |
900 d = d->next; | |
901 } | |
902 | |
903 return NULL; | |
904 } | |
905 | |
906 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
907 { | |
908 gaim_debug_info("oscar", | |
909 "destroying Direct IM for %s.\n", dim->name); | |
910 | |
911 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 912 if (dim->gpc_pend) { |
913 dim->killme = TRUE; | |
914 return; | |
915 } | |
8971 | 916 if (dim->watcher) |
917 gaim_input_remove(dim->watcher); | |
918 if (dim->conn) { | |
10271 | 919 aim_conn_close(dim->conn); |
8971 | 920 aim_conn_kill(od->sess, &dim->conn); |
921 } | |
922 g_free(dim); | |
923 } | |
924 | |
925 /* the only difference between this and destroy is this writes a conv message */ | |
926 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
927 { | |
928 GaimConversation *conv; | |
929 char buf[256]; | |
930 | |
931 gaim_debug_info("oscar", | |
932 "%s disconnected Direct IM.\n", dim->name); | |
933 | |
934 if (dim->connected) | |
935 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 936 else |
8971 | 937 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
938 | |
10246 | 939 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
940 gaim_connection_get_account(dim->gc)); | |
8971 | 941 if (conv) { |
942 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 943 gaim_conversation_update_progress(conv, 0); |
8971 | 944 } else { |
945 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
946 } | |
947 | |
948 oscar_direct_im_destroy(od, dim); | |
949 | |
950 return; | |
951 } | |
952 | |
953 /* oops i made two of these. this one just calls the other one. */ | |
954 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
955 { | |
956 GaimConnection *gc = sess->aux_data; | |
957 OscarData *od = (OscarData *)gc->proto_data; | |
958 struct oscar_direct_im *dim; | |
959 char *sn; | |
960 | |
961 sn = g_strdup(aim_odc_getsn(conn)); | |
962 dim = oscar_direct_im_find(od, sn); | |
963 oscar_direct_im_disconnect(od, dim); | |
964 g_free(sn); | |
965 } | |
966 | |
967 static void destroy_direct_im_request(struct ask_direct *d) { | |
968 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
969 | |
970 g_free(d->sn); | |
971 g_free(d); | |
972 } | |
973 | |
974 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
975 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
976 struct oscar_direct_im *dim = data; | |
977 GaimConnection *gc = dim->gc; | |
978 OscarData *od = gc->proto_data; | |
979 GaimConversation *conv; | |
980 char buf[256]; | |
981 struct sockaddr name; | |
982 socklen_t name_len = 1; | |
983 | |
984 g_return_if_fail(gc != NULL); | |
985 | |
8978 | 986 dim->gpc_pend = FALSE; |
987 if (dim->killme) { | |
988 oscar_direct_im_destroy(od, dim); | |
989 return; | |
990 } | |
991 | |
8971 | 992 if (!g_list_find(gaim_connections_get_all(), gc)) { |
993 oscar_direct_im_destroy(od, dim); | |
994 return; | |
995 } | |
996 | |
997 if (source < 0) { | |
8984 | 998 if (dim->donttryagain) { |
999 oscar_direct_im_disconnect(od, dim); | |
1000 return; | |
1001 } else { | |
1002 fu8_t cookie[8]; | |
1003 char *who = g_strdup(dim->name); | |
1004 const char *tmp = aim_odc_getcookie(dim->conn); | |
1005 | |
1006 memcpy(cookie, tmp, 8); | |
1007 oscar_direct_im_destroy(od, dim); | |
1008 oscar_direct_im_initiate(gc, who, cookie); | |
1009 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1010 g_free(who); | |
1011 return; | |
1012 } | |
8971 | 1013 } |
1014 | |
1015 dim->conn->fd = source; | |
1016 aim_conn_completeconnect(od->sess, dim->conn); | |
1017 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
1018 | |
1019 /* This is the best way to see if we're connected or not */ | |
8983 | 1020 /* Is this really needed? */ |
8971 | 1021 if (getpeername(source, &name, &name_len) == 0) { |
1022 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1023 dim->connected = TRUE; | |
1024 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1025 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1026 } else { | |
8984 | 1027 if (dim->donttryagain) { |
1028 oscar_direct_im_disconnect(od, dim); | |
1029 return; | |
1030 } else { | |
1031 fu8_t cookie[8]; | |
1032 char *who = g_strdup(dim->name); | |
1033 const char *tmp = aim_odc_getcookie(dim->conn); | |
1034 | |
1035 memcpy(cookie, tmp, 8); | |
1036 oscar_direct_im_destroy(od, dim); | |
1037 oscar_direct_im_initiate(gc, who, cookie); | |
1038 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1039 g_free(who); | |
1040 return; | |
1041 } | |
8983 | 1042 } |
1043 | |
1044 | |
8971 | 1045 } |
1046 | |
1047 static void accept_direct_im_request(struct ask_direct *d) { | |
1048 GaimConnection *gc = d->gc; | |
1049 OscarData *od; | |
1050 struct oscar_direct_im *dim; | |
1051 char *host; int port = 5190; | |
1052 int i, rc; | |
8982 | 1053 char *tmp; |
1054 GaimConversation *conv; | |
8971 | 1055 |
1056 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1057 destroy_direct_im_request(d); | |
1058 return; | |
1059 } | |
1060 | |
1061 od = (OscarData *)gc->proto_data; | |
1062 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1063 | |
1064 dim = oscar_direct_im_find(od, d->sn); | |
1065 if (dim && dim->connected) { | |
1066 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1067 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1068 return; | |
1069 } | |
1070 dim = g_new0(struct oscar_direct_im, 1); | |
1071 dim->gc = d->gc; | |
8984 | 1072 dim->donttryagain = d->donttryagain; |
8971 | 1073 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1074 | |
1075 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1076 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1077 if (!dim->conn) { | |
1078 oscar_direct_im_disconnect(od, dim); | |
1079 destroy_direct_im_request(d); | |
1080 return; | |
1081 } | |
1082 | |
1083 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1084 gaim_odc_incoming, 0); | |
1085 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1086 gaim_odc_typing, 0); | |
1087 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1088 gaim_odc_update_ui, 0); | |
1089 | |
1090 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1091 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1092 if (d->ip[i] == ':') { | |
1093 port = atoi(&(d->ip[i+1])); | |
1094 break; | |
1095 } | |
1096 } | |
1097 host = g_strndup(d->ip, i); | |
1098 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1099 dim->gpc_pend = TRUE; |
8971 | 1100 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1101 |
1102 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1103 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1104 port); | |
1105 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1106 g_free(tmp); | |
8983 | 1107 |
8971 | 1108 g_free(host); |
1109 if (rc < 0) { | |
8978 | 1110 dim->gpc_pend = FALSE; |
8971 | 1111 oscar_direct_im_disconnect(od, dim); |
1112 destroy_direct_im_request(d); | |
1113 return; | |
1114 } | |
1115 | |
1116 destroy_direct_im_request(d); | |
1117 | |
1118 return; | |
1119 } | |
1120 | |
1121 /* | |
1122 * We have just established a socket with the other dude, so set up some handlers. | |
1123 */ | |
1124 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1125 GaimConnection *gc = sess->aux_data; |
7283 | 1126 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1127 GaimConversation *conv; |
8971 | 1128 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1129 char buf[256]; |
8971 | 1130 char *sn; |
1131 va_list ap; | |
1132 aim_conn_t *newconn, *listenerconn; | |
1133 | |
1134 va_start(ap, fr); | |
1135 newconn = va_arg(ap, aim_conn_t *); | |
1136 listenerconn = va_arg(ap, aim_conn_t *); | |
1137 va_end(ap); | |
1138 | |
10271 | 1139 aim_conn_close(listenerconn); |
8971 | 1140 aim_conn_kill(sess, &listenerconn); |
1141 | |
1142 sn = g_strdup(aim_odc_getsn(newconn)); | |
1143 | |
1144 gaim_debug_info("oscar", | |
1145 "DirectIM: initiate success to %s\n", sn); | |
1146 dim = oscar_direct_im_find(od, sn); | |
1147 | |
1148 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1149 gaim_input_remove(dim->watcher); | |
1150 dim->conn = newconn; | |
1151 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1152 dim->connected = TRUE; | |
1153 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1154 g_free(sn); | |
1155 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1156 | |
1157 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1158 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1159 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1160 | |
1161 return 1; | |
1162 } | |
1163 | |
1164 /* | |
1165 * This is called when each chunk of an image is received. It can be used to | |
1166 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1167 * nasty, you sicko. | |
1168 */ | |
1169 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1170 va_list ap; | |
1171 char *sn; | |
1172 double percent; | |
1173 GaimConnection *gc = sess->aux_data; | |
1174 OscarData *od = (OscarData *)gc->proto_data; | |
1175 GaimConversation *c; | |
1176 struct oscar_direct_im *dim; | |
1177 | |
1178 va_start(ap, fr); | |
1179 sn = va_arg(ap, char *); | |
1180 percent = va_arg(ap, double); | |
1181 va_end(ap); | |
1182 | |
1183 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1184 return 1; | |
1185 if (dim->watcher) { | |
1186 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1187 /* The callback will callback? I don't get how that would happen here. */ | |
1188 dim->watcher = 0; | |
1189 } | |
1190 | |
10246 | 1191 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1192 gaim_connection_get_account(gc)); | |
8971 | 1193 if (c != NULL) |
1194 gaim_conversation_update_progress(c, percent); | |
1195 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1196 oscar_callback, dim->conn); | |
1197 | |
1198 return 1; | |
1199 } | |
1200 | |
1201 /* | |
1202 * This is called after a direct IM has been received in its entirety. This | |
1203 * function is passed a long chunk of data which contains the IM with any | |
1204 * data chunks (images) appended to it. | |
1205 * | |
1206 * This function rips out all the data chunks and creates an imgstore for | |
1207 * each one. In order to do this, it first goes through the IM and takes | |
1208 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1209 * with one compatible with the imgstore Gaim core code. For each one, we | |
1210 * then read in chunks of data from the end of the message and actually | |
1211 * create the img store using the given data. | |
1212 * | |
1213 * For somewhat easy reference, here's a sample message | |
1214 * (without the whitespace and asterisks): | |
1215 * | |
1216 * <HTML><BODY BGCOLOR="#ffffff"> | |
1217 * <FONT LANG="0"> | |
1218 * This is a really stupid picture:<BR> | |
1219 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1220 * Yeah it is<BR> | |
1221 * Here is another one:<BR> | |
1222 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1223 * </FONT> | |
1224 * </BODY></HTML> | |
1225 * <BINARY> | |
1226 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1227 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1228 * </BINARY> | |
1229 */ | |
1230 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1231 GaimConnection *gc = sess->aux_data; | |
1232 GaimConvImFlags imflags = 0; | |
1233 gchar *utf8; | |
1234 GString *newmsg = g_string_new(""); | |
1235 GSList *images = NULL; | |
1236 va_list ap; | |
1237 const char *sn, *msg, *msgend, *binary; | |
1238 size_t len; | |
1239 int encoding, isawaymsg; | |
1240 | |
1241 va_start(ap, fr); | |
1242 sn = va_arg(ap, const char *); | |
1243 msg = va_arg(ap, const char *); | |
1244 len = va_arg(ap, size_t); | |
1245 encoding = va_arg(ap, int); | |
1246 isawaymsg = va_arg(ap, int); | |
1247 va_end(ap); | |
1248 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1249 |
8660 | 1250 gaim_debug_info("oscar", |
8971 | 1251 "Got DirectIM message from %s\n", sn); |
1252 | |
1253 if (isawaymsg) | |
1254 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1255 | |
1256 /* message has a binary trailer */ | |
1257 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1258 GData *attribs; | |
1259 const char *tmp, *start, *end, *last = NULL; | |
1260 | |
1261 tmp = msg; | |
1262 | |
1263 /* for each valid image tag... */ | |
1264 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1265 const char *id, *src, *datasize; | |
10504 | 1266 const char *data = NULL; |
1267 char *tag = NULL; | |
8971 | 1268 size_t size; |
1269 int imgid = 0; | |
1270 | |
1271 /* update the location of the last img tag */ | |
1272 last = end; | |
1273 | |
1274 /* grab attributes */ | |
1275 id = g_datalist_get_data(&attribs, "id"); | |
1276 src = g_datalist_get_data(&attribs, "src"); | |
1277 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1278 | |
1279 /* if we have id & datasize, build the data tag */ | |
1280 if (id && datasize) | |
1281 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1282 | |
1283 /* if we have a tag, find the start of the data */ | |
1284 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1285 data += strlen(tag); | |
1286 | |
10504 | 1287 g_free(tag); |
1288 | |
8971 | 1289 /* check the data is here and store it */ |
1290 if (data + (size = atoi(datasize)) <= msgend) | |
1291 imgid = gaim_imgstore_add(data, size, src); | |
1292 | |
1293 /* | |
1294 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1295 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1296 */ | |
1297 /* if we have a stored image... */ | |
1298 if (imgid) { | |
1299 /* append the message up to the tag */ | |
1300 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1301 if (utf8 != NULL) { | |
1302 newmsg = g_string_append(newmsg, utf8); | |
1303 g_free(utf8); | |
1304 } | |
1305 | |
1306 /* write the new image tag */ | |
1307 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1308 | |
1309 /* and record the image number */ | |
1310 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1311 } else { | |
1312 /* otherwise, copy up to the end of the tag */ | |
1313 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1314 if (utf8 != NULL) { | |
1315 newmsg = g_string_append(newmsg, utf8); | |
1316 g_free(utf8); | |
1317 } | |
1318 } | |
1319 | |
1320 /* clear the attribute list */ | |
1321 g_datalist_clear(&attribs); | |
1322 | |
1323 /* continue from the end of the tag */ | |
1324 tmp = end + 1; | |
1325 } | |
1326 | |
1327 /* append any remaining message data (without the > :-) */ | |
1328 if (last++ && (last < binary)) | |
1329 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1330 | |
1331 /* set the flag if we caught any images */ | |
1332 if (images) | |
1333 imflags |= GAIM_CONV_IM_IMAGES; | |
1334 } else { | |
1335 g_string_append_len(newmsg, msg, len); | |
1336 } | |
1337 | |
10318 | 1338 /* Convert to UTF8 */ |
1339 /* (This hasn't been tested very much) */ | |
1340 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1341 if (utf8 != NULL) { | |
1342 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1343 g_free(utf8); | |
1344 } | |
1345 | |
1346 /* free the message */ | |
8971 | 1347 g_string_free(newmsg, TRUE); |
1348 | |
1349 /* unref any images we allocated */ | |
1350 if (images) { | |
1351 GSList *tmp; | |
1352 int id; | |
1353 | |
1354 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1355 id = GPOINTER_TO_INT(tmp->data); | |
1356 gaim_imgstore_unref(id); | |
1357 } | |
1358 | |
1359 g_slist_free(images); | |
1360 } | |
1361 | |
1362 return 1; | |
1363 } | |
1364 | |
1365 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1366 va_list ap; | |
1367 char *sn; | |
1368 int typing; | |
1369 GaimConnection *gc = sess->aux_data; | |
1370 | |
1371 va_start(ap, fr); | |
1372 sn = va_arg(ap, char *); | |
1373 typing = va_arg(ap, int); | |
1374 va_end(ap); | |
1375 | |
1376 if (typing == 0x0002) { | |
1377 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1378 gaim_debug_info("oscar", | |
1379 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1380 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1381 } else if (typing == 0x0001) | |
1382 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1383 else | |
1384 serv_got_typing_stopped(gc, sn); | |
1385 return 1; | |
1386 } | |
1387 | |
1388 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1389 char *buf; | |
1390 size_t len; | |
1391 int ret; | |
1392 GString *msg = g_string_new("<HTML><BODY>"); | |
1393 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1394 GData *attribs; | |
1395 const char *start, *end, *last; | |
1396 int oscar_id = 0; | |
1397 | |
1398 last = message; | |
1399 | |
1400 /* for each valid IMG tag... */ | |
1401 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1402 GaimStoredImage *image = NULL; | |
1403 const char *id; | |
1404 | |
1405 if (start - last) { | |
1406 g_string_append_len(msg, last, start - last); | |
1407 } | |
1408 | |
1409 id = g_datalist_get_data(&attribs, "id"); | |
1410 | |
1411 /* ... if it refers to a valid gaim image ... */ | |
1412 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1413 /* ... append the message from start to the tag ... */ | |
9126 | 1414 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1415 const char *filename = gaim_imgstore_get_filename(image); |
1416 gpointer imgdata = gaim_imgstore_get_data(image); | |
1417 | |
1418 oscar_id++; | |
1419 | |
1420 /* ... insert a new img tag with the oscar id ... */ | |
1421 if (filename) | |
1422 g_string_append_printf(msg, | |
9126 | 1423 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1424 filename, oscar_id, size); |
1425 else | |
1426 g_string_append_printf(msg, | |
9126 | 1427 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1428 oscar_id, size); |
1429 | |
1430 /* ... and append the data to the binary section ... */ | |
9126 | 1431 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1432 oscar_id, size); |
1433 data = g_string_append_len(data, imgdata, size); | |
1434 data = g_string_append(data, "</DATA>"); | |
1435 } | |
1436 /* If the tag is invalid, skip it, thus no else here */ | |
1437 | |
1438 g_datalist_clear(&attribs); | |
1439 | |
1440 /* continue from the end of the tag */ | |
1441 last = end + 1; | |
1442 } | |
1443 | |
1444 /* append any remaining message data (without the > :-) */ | |
1445 if (last && *last) | |
1446 msg = g_string_append(msg, last); | |
1447 | |
1448 /* if we inserted any images in the binary section, append it */ | |
1449 if (oscar_id) { | |
1450 msg = g_string_append_len(msg, data->str, data->len); | |
1451 msg = g_string_append(msg, "</BINARY>"); | |
1452 } | |
1453 | |
1454 len = msg->len; | |
1455 buf = msg->str; | |
1456 g_string_free(msg, FALSE); | |
1457 g_string_free(data, TRUE); | |
1458 | |
1459 | |
1460 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1461 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1462 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1463 else | |
1464 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1465 | |
1466 g_free(buf); | |
1467 | |
1468 return ret; | |
1469 } | |
1470 | |
1471 struct ask_do_dir_im { | |
1472 char *who; | |
1473 GaimConnection *gc; | |
1474 }; | |
1475 | |
1476 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1477 g_free(data->who); | |
1478 g_free(data); | |
1479 } | |
1480 | |
8983 | 1481 /* this function is used to initiate a direct im session with someone. |
1482 * we start listening on a port and send a request. they either connect | |
1483 * or send some kind of reply. If they can't connect, they ask us to | |
1484 * connect to them, and so we do that. | |
1485 * | |
1486 * this function will also get called if the other side initiate's a direct | |
1487 * im and we try to connect and fail. in that case cookie will not be null. | |
1488 * | |
1489 * note that cookie is an 8 byte string that isn't NULL terminated | |
1490 */ | |
1491 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1492 OscarData *od; |
1493 struct oscar_direct_im *dim; | |
1494 int listenfd; | |
8982 | 1495 const char *ip; |
8971 | 1496 |
1497 od = (OscarData *)gc->proto_data; | |
1498 | |
8983 | 1499 dim = oscar_direct_im_find(od, who); |
8971 | 1500 if (dim) { |
1501 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1502 oscar_direct_im_disconnect(od, dim); | |
1503 gaim_debug_info("oscar", | |
1504 "Gave up on old direct IM, trying again\n"); | |
1505 } else { | |
1506 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1507 return; |
8971 | 1508 } |
1509 } | |
1510 dim = g_new0(struct oscar_direct_im, 1); | |
1511 dim->gc = gc; | |
8983 | 1512 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1513 |
1514 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1515 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1516 if (listenfd >= 0) |
1517 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1518 if (dim->conn != NULL) { |
8982 | 1519 char *tmp; |
1520 GaimConversation *conv; | |
1521 | |
8971 | 1522 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1523 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1524 oscar_callback, dim->conn); | |
1525 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1526 gaim_odc_initiate, 0); | |
8982 | 1527 |
8983 | 1528 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1529 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1530 gaim_network_get_port_from_fd(listenfd)); |
1531 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1532 g_free(tmp); | |
8971 | 1533 } else { |
1534 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1535 oscar_direct_im_destroy(od, dim); | |
1536 } | |
8983 | 1537 } |
1538 | |
1539 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1540 GaimConnection *gc = data->gc; | |
1541 | |
1542 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1543 g_free(data->who); | |
1544 g_free(data); | |
1545 return; | |
1546 } | |
1547 | |
1548 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1549 g_free(data->who); |
1550 g_free(data); | |
1551 } | |
1552 | |
1553 /* this is the right click menu cb thingy */ | |
9030 | 1554 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1555 | |
1556 GaimBuddy *buddy; | |
1557 GaimConnection *gc; | |
8971 | 1558 gchar *buf; |
9030 | 1559 struct ask_do_dir_im *data; |
1560 | |
1561 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1562 | |
1563 buddy = (GaimBuddy *) node; | |
1564 gc = gaim_account_get_connection(buddy->account); | |
1565 | |
1566 data = g_new0(struct ask_do_dir_im, 1); | |
1567 data->who = g_strdup(buddy->name); | |
8971 | 1568 data->gc = gc; |
9030 | 1569 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1570 buddy->name); | |
8971 | 1571 |
1572 gaim_request_action(gc, NULL, buf, | |
9030 | 1573 _("Because this reveals your IP address, it " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1574 "may be considered a privacy risk. Do you " |
9030 | 1575 "wish to continue?"), |
1576 0, data, 2, | |
1577 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1578 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1579 g_free(buf); |
1580 } | |
1581 | |
1582 /***************************************************************************** | |
1583 * End scary direct im stuff | |
1584 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1585 |
4617 | 1586 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1587 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1588 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1589 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1590 OscarData *od; |
2086 | 1591 |
1592 if (!gc) { | |
8660 | 1593 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1594 "oscar callback for closed connection (1).\n"); |
2086 | 1595 return; |
1596 } | |
10458 | 1597 |
7283 | 1598 od = (OscarData *)gc->proto_data; |
2086 | 1599 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1600 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1601 /* oh boy. this is probably bad. i guess the only thing we |
1602 * can really do is return? */ | |
8660 | 1603 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1604 "oscar callback for closed connection (2).\n"); |
8660 | 1605 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1606 return; |
1607 } | |
1608 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1609 if (condition & GAIM_INPUT_READ) { |
4617 | 1610 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1611 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1612 "got information on rendezvous listener\n"); |
4617 | 1613 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1614 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1615 "connection error (rendezvous listener)\n"); |
4617 | 1616 aim_conn_kill(od->sess, &conn); |
8446 | 1617 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1618 } |
1619 } else { | |
4617 | 1620 if (aim_get_command(od->sess, conn) >= 0) { |
1621 aim_rxdispatch(od->sess); | |
6029 | 1622 if (od->killme) { |
8660 | 1623 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1624 return; |
1625 } | |
2086 | 1626 } else { |
1627 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
10444 | 1628 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1629 { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1630 gaim_debug_error("oscar", "Major connection error. i.e. " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1631 "invalid data was received on the oscar TCP stream\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1632 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1633 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1634 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1635 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1636 char *buf; |
10458 | 1637 |
1638 gaim_debug_info("oscar", "Lost connection " | |
1639 "to chat room %s\n", cc->name); | |
1640 | |
1641 buf = g_strdup_printf(_("You have lost your connection " | |
1642 "to chat room %s."), cc->name); | |
1643 if (conv != NULL) | |
9627 | 1644 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1645 else | |
1646 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1647 g_free(buf); |
10458 | 1648 |
1649 oscar_chat_kill(gc, cc); | |
1650 | |
2086 | 1651 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1652 if (od->cnpa > 0) |
1653 gaim_input_remove(od->cnpa); | |
1654 od->cnpa = 0; | |
8660 | 1655 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1656 "removing chatnav input watcher\n"); |
4617 | 1657 while (od->create_rooms) { |
1658 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1659 g_free(cr->name); |
4617 | 1660 od->create_rooms = |
1661 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1662 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1663 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1664 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1665 NULL); |
2086 | 1666 } |
4617 | 1667 aim_conn_kill(od->sess, &conn); |
2086 | 1668 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1669 if (od->paspa > 0) |
1670 gaim_input_remove(od->paspa); | |
1671 od->paspa = 0; | |
8660 | 1672 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1673 "removing authconn input watcher\n"); |
4617 | 1674 aim_conn_kill(od->sess, &conn); |
3694 | 1675 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1676 if (od->emlpa > 0) |
1677 gaim_input_remove(od->emlpa); | |
1678 od->emlpa = 0; | |
8660 | 1679 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1680 "removing email input watcher\n"); |
4617 | 1681 aim_conn_kill(od->sess, &conn); |
4804 | 1682 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1683 if (od->icopa > 0) | |
1684 gaim_input_remove(od->icopa); | |
1685 od->icopa = 0; | |
8660 | 1686 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1687 "removing icon input watcher\n"); |
4804 | 1688 aim_conn_kill(od->sess, &conn); |
2086 | 1689 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1690 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1691 gaim_odc_disconnect(od->sess, conn); |
1692 aim_conn_kill(od->sess, &conn); | |
2086 | 1693 } else { |
8660 | 1694 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1695 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1696 conn->type); |
4617 | 1697 aim_conn_kill(od->sess, &conn); |
2086 | 1698 } |
1699 } | |
1700 } | |
1701 } | |
1702 } | |
1703 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1704 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1705 GaimConnection *gc = sess->aux_data; |
7285 | 1706 gchar *s = g_strdup_vprintf(format, va); |
1707 gchar *buf; | |
1708 | |
1709 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1710 gaim_debug_info("oscar", buf); |
7285 | 1711 if (buf[strlen(buf)-1] != '\n') |
8660 | 1712 gaim_debug_info(NULL, "\n"); |
7285 | 1713 g_free(buf); |
2086 | 1714 g_free(s); |
1715 } | |
1716 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1717 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1718 { |
5575 | 1719 GaimConnection *gc = data; |
7283 | 1720 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1721 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1722 aim_conn_t *conn; |
2086 | 1723 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1724 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1725 close(source); |
1726 return; | |
1727 } | |
1728 | |
4617 | 1729 od = gc->proto_data; |
1730 sess = od->sess; | |
2086 | 1731 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1732 conn->fd = source; |
2086 | 1733 |
1734 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1735 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1736 return; |
1737 } | |
1738 | |
1739 aim_conn_completeconnect(sess, conn); | |
4617 | 1740 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1741 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1742 | |
8660 | 1743 gaim_debug_info("oscar", |
7282 | 1744 "Screen name sent, waiting for response\n"); |
7283 | 1745 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1746 ck[1] = 0x65; |
2086 | 1747 } |
1748 | |
10444 | 1749 static void |
1750 oscar_login(GaimAccount *account, GaimStatus *status) | |
1751 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1752 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1753 aim_conn_t *conn; |
5575 | 1754 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1755 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
10400 | 1756 GaimStatusType *status_type; |
1757 GaimStatusPrimitive primitive; | |
1758 | |
1759 status_type = gaim_status_get_type(status); | |
1760 primitive = gaim_status_type_get_primitive(status_type); | |
2086 | 1761 |
8660 | 1762 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
10444 | 1763 |
10400 | 1764 if (primitive == GAIM_STATUS_OFFLINE) |
1765 return; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1766 |
8437 | 1767 if (!aim_snvalid(gaim_account_get_username(account))) { |
1768 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1769 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 | 1770 gaim_connection_error(gc, buf); |
1771 g_free(buf); | |
1772 } | |
1773 | |
9975 | 1774 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1775 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1776 } else { |
6622 | 1777 gc->flags |= GAIM_CONNECTION_HTML; |
1778 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1779 } |
5836 | 1780 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1781 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1782 sess = g_new0(aim_session_t, 1); |
10329 | 1783 aim_session_init(sess, TRUE, FAIM_DEBUG_LEVEL); |
2086 | 1784 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1785 /* |
1786 * We need an immediate queue because we don't use a while-loop | |
1787 * to see if things need to be sent. | |
1788 */ | |
2086 | 1789 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1790 od->sess = sess; |
2086 | 1791 sess->aux_data = gc; |
1792 | |
9935 | 1793 /* Connect to core Gaim signals */ |
10087 | 1794 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1795 |
2086 | 1796 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1797 if (conn == NULL) { | |
10444 | 1798 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1799 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1800 return; |
1801 } | |
1802 | |
4649 | 1803 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1804 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1805 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1806 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1807 |
1808 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1809 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1810 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1811 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1812 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1813 return; |
1814 } | |
7282 | 1815 |
7283 | 1816 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1817 ck[0] = 0x5a; |
5575 | 1818 } |
1819 | |
1820 static void oscar_close(GaimConnection *gc) { | |
7283 | 1821 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1822 |
1823 while (od->oscar_chats) { | |
1824 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1825 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1826 gaim_input_remove(n->inpa); |
2086 | 1827 g_free(n->name); |
1828 g_free(n->show); | |
4617 | 1829 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1830 g_free(n); |
1831 } | |
4617 | 1832 while (od->direct_ims) { |
8971 | 1833 struct oscar_direct_im *n = od->direct_ims->data; |
1834 oscar_direct_im_destroy(od, n); | |
2086 | 1835 } |
4617 | 1836 /* BBB */ |
1837 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1838 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1839 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1840 gaim_xfer_cancel_local(xfer); |
3630 | 1841 } |
4804 | 1842 while (od->requesticon) { |
1843 char *sn = od->requesticon->data; | |
1844 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1845 free(sn); | |
1846 } | |
4738 | 1847 g_hash_table_destroy(od->buddyinfo); |
4617 | 1848 while (od->create_rooms) { |
1849 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1850 g_free(cr->name); |
4617 | 1851 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1852 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1853 } |
4617 | 1854 if (od->email) |
1855 g_free(od->email); | |
1856 if (od->newp) | |
1857 g_free(od->newp); | |
1858 if (od->oldp) | |
1859 g_free(od->oldp); | |
2086 | 1860 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1861 gaim_input_remove(gc->inpa); |
4617 | 1862 if (od->cnpa > 0) |
1863 gaim_input_remove(od->cnpa); | |
1864 if (od->paspa > 0) | |
1865 gaim_input_remove(od->paspa); | |
1866 if (od->emlpa > 0) | |
1867 gaim_input_remove(od->emlpa); | |
4804 | 1868 if (od->icopa > 0) |
1869 gaim_input_remove(od->icopa); | |
6907 | 1870 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1871 gaim_timeout_remove(od->icontimer); |
8341 | 1872 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1873 gaim_timeout_remove(od->getblisttimer); |
8341 | 1874 if (od->getinfotimer > 0) |
1875 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1876 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1877 |
4617 | 1878 aim_session_kill(od->sess); |
1879 g_free(od->sess); | |
1880 od->sess = NULL; | |
2086 | 1881 g_free(gc->proto_data); |
1882 gc->proto_data = NULL; | |
8660 | 1883 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1884 } |
1885 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1886 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1887 GaimConnection *gc = data; |
7283 | 1888 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1889 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1890 aim_conn_t *bosconn; |
2086 | 1891 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1892 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1893 close(source); |
1894 return; | |
1895 } | |
1896 | |
4617 | 1897 od = gc->proto_data; |
1898 sess = od->sess; | |
1899 bosconn = od->conn; | |
4366 | 1900 bosconn->fd = source; |
2086 | 1901 |
1902 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1903 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1904 return; |
1905 } | |
1906 | |
1907 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1908 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1909 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1910 gaim_connection_update_progress(gc, |
7283 | 1911 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1912 ck[4] = 0x61; |
2086 | 1913 } |
1914 | |
4617 | 1915 /* BBB */ |
4656 | 1916 /* |
1917 * This little area in oscar.c is the nexus of file transfer code, | |
1918 * so I wrote a little explanation of what happens. I am such a | |
1919 * ninja. | |
1920 * | |
1921 * The series of events for a file send is: | |
1922 * -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
|
1923 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1924 * listening socket, then asks the remote user to connect to us (and |
1925 * gives them the file name, port, IP, etc.) | |
1926 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1927 * in oscar_sendfile_estblsh) | |
1928 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1929 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1930 * connection. | |
1931 * -We get drunk because file transfer kicks ass. | |
1932 * | |
1933 * The series of events for a file receive is: | |
1934 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1935 * -Gaim user selects file to name and location to save file to and | |
1936 * oscar_xfer_init is called | |
1937 * -It connects to the remote user using the IP they gave us earlier | |
1938 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1939 * them an AIM_CB_OFT_ACK. | |
1940 * -They begin to send us lots of raw data. | |
1941 * -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
|
1942 * the connection. |
4656 | 1943 */ |
1944 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1945 | |
8446 | 1946 /* |
1947 * Miscellaneous xfer functions | |
1948 */ | |
1949 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1950 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1951 GaimXfer *xfer; |
5146 | 1952 struct aim_oft_info *oft_info; |
4656 | 1953 |
1954 while (fts) { | |
1955 xfer = fts->data; | |
5146 | 1956 oft_info = xfer->data; |
1957 | |
8446 | 1958 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1959 return xfer; |
1960 | |
1961 fts = g_slist_next(fts); | |
1962 } | |
1963 | |
1964 return NULL; | |
1965 } | |
1966 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1967 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1968 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1969 GaimXfer *xfer; |
5146 | 1970 struct aim_oft_info *oft_info; |
4656 | 1971 |
1972 while (fts) { | |
1973 xfer = fts->data; | |
5146 | 1974 oft_info = xfer->data; |
1975 | |
1976 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1977 return xfer; |
1978 | |
1979 fts = g_slist_next(fts); | |
1980 } | |
1981 | |
1982 return NULL; | |
1983 } | |
1984 | |
8446 | 1985 static void oscar_xfer_end(GaimXfer *xfer) |
1986 { | |
1987 struct aim_oft_info *oft_info = xfer->data; | |
1988 GaimConnection *gc = oft_info->sess->aux_data; | |
1989 OscarData *od = gc->proto_data; | |
1990 | |
8660 | 1991 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1992 |
1993 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1994 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1995 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1996 } | |
1997 | |
1998 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1999 aim_oft_destroyinfo(oft_info); | |
2000 xfer->data = NULL; | |
2001 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2002 } | |
2003 | |
2004 /* | |
2005 * xfer functions used when receiving files | |
2006 */ | |
2007 | |
2008 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
2009 { | |
2010 struct aim_oft_info *oft_info = xfer->data; | |
2011 GaimConnection *gc = oft_info->sess->aux_data; | |
2012 OscarData *od = gc->proto_data; | |
2013 | |
8660 | 2014 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 2015 |
2016 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
2017 if (oft_info->conn) { | |
2018 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2019 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
2020 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
2021 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
2022 if (xfer->fd == -1) { | |
10654 | 2023 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2024 _("Unable to establish file descriptor.")); |
2025 gaim_xfer_cancel_local(xfer); | |
2026 } | |
2027 } else { | |
10654 | 2028 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2029 _("Unable to create new connection.")); |
2030 gaim_xfer_cancel_local(xfer); | |
2031 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2032 } | |
2033 | |
2034 } | |
2035 | |
2036 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
2037 { | |
10405 | 2038 struct aim_oft_info *oft_info; |
2039 GaimConnection *gc; | |
2040 OscarData *od; | |
2041 | |
2042 g_return_if_fail(xfer != NULL); | |
2043 g_return_if_fail(xfer->data != NULL); | |
2044 | |
2045 oft_info = xfer->data; | |
2046 gc = oft_info->sess->aux_data; | |
2047 od = gc->proto_data; | |
8446 | 2048 |
8660 | 2049 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2050 |
9771 | 2051 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2052 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2053 |
2054 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2055 aim_oft_destroyinfo(oft_info); | |
2056 xfer->data = NULL; | |
2057 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2058 } | |
2059 | |
2060 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
2061 { | |
2062 struct aim_oft_info *oft_info = xfer->data; | |
2063 | |
2064 /* Update our rolling checksum. Like Walmart, yo. */ | |
2065 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2066 } | |
2067 | |
2068 /* | |
2069 * xfer functions used when sending files | |
2070 */ | |
2071 | |
2072 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2073 { | |
2074 struct aim_oft_info *oft_info = xfer->data; | |
2075 GaimConnection *gc = oft_info->sess->aux_data; | |
2076 OscarData *od = gc->proto_data; | |
2077 int listenfd; | |
2078 | |
8660 | 2079 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2080 |
2081 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2082 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2083 oft_info->fh.name[63] = '\0'; | |
2084 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2085 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2086 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2087 | |
2088 /* Create a listening socket and an associated libfaim conn */ | |
2089 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2090 gaim_xfer_cancel_local(xfer); | |
2091 return; | |
2092 } | |
2093 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2094 oft_info->port = xfer->local_port; | |
2095 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2096 gaim_xfer_cancel_local(xfer); | |
2097 return; | |
2098 } | |
8660 | 2099 gaim_debug_misc("oscar", |
8446 | 2100 "port is %hu, ip is %s\n", |
2101 xfer->local_port, oft_info->clientip); | |
2102 if (oft_info->conn) { | |
2103 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2104 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2105 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2106 } else { | |
10654 | 2107 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2108 _("Unable to establish listener socket.")); |
2109 gaim_xfer_cancel_local(xfer); | |
2110 } | |
2111 } | |
2112 | |
2113 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2114 { | |
2115 struct aim_oft_info *oft_info = xfer->data; | |
2116 GaimConnection *gc = oft_info->sess->aux_data; | |
2117 OscarData *od = gc->proto_data; | |
2118 | |
8660 | 2119 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2120 |
9771 | 2121 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2122 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2123 |
2124 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2125 aim_oft_destroyinfo(oft_info); | |
2126 xfer->data = NULL; | |
2127 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2128 } | |
2129 | |
2130 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2131 { | |
2132 struct aim_oft_info *oft_info = xfer->data; | |
2133 | |
2134 /* I'm not sure I like how we do this. --marv | |
2135 * I do. AIM file transfers aren't really meant to be thought | |
2136 * of as a transferring just a single file. The rendezvous | |
2137 * establishes a connection between two computers, and then | |
2138 * those computers can use the same connection for transferring | |
2139 * multiple files. So we don't want the Gaim core up and closing | |
2140 * the socket all willy-nilly. We want to do that in the oscar | |
2141 * prpl, whenever one side or the other says they're finished | |
2142 * using the connection. There might be a better way to intercept | |
2143 * the socket from the core, however... --KingAnt | |
2144 */ | |
2145 | |
2146 /* | |
2147 * If we're done sending, intercept the socket from the core ft code | |
2148 * and wait for the other guy to send the "done" OFT packet. | |
2149 */ | |
2150 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2151 gaim_input_remove(xfer->watcher); | |
2152 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2153 xfer->fd = 0; | |
2154 gaim_xfer_set_completed(xfer, TRUE); | |
2155 } | |
2156 } | |
2157 | |
9466 | 2158 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2159 gboolean can_receive = FALSE; | |
2160 OscarData *od = gc->proto_data; | |
2161 | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
2162 if (od != NULL && !od->icq) { |
9466 | 2163 aim_userinfo_t *userinfo; |
2164 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2165 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2166 can_receive = TRUE; | |
2167 } | |
2168 | |
2169 return can_receive; | |
2170 } | |
2171 | |
2172 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2173 |
2174 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2175 GaimXfer *xfer; |
5146 | 2176 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2177 const char *ip; |
3752 | 2178 |
9030 | 2179 od = (OscarData *)gc->proto_data; |
2180 | |
4617 | 2181 /* You want to send a file to someone else, you're so generous */ |
2182 | |
2183 /* Build the file transfer handle */ | |
9466 | 2184 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2185 |
5146 | 2186 /* Create the oscar-specific data */ |
8838 | 2187 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2188 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2189 xfer->data = oft_info; |
2190 | |
4617 | 2191 /* Setup our I/O op functions */ |
8446 | 2192 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2193 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2194 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2195 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2196 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2197 |
2198 /* Keep track of this transfer for later */ | |
2199 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2200 | |
2201 /* Now perform the request */ | |
9466 | 2202 if (file) |
2203 gaim_xfer_request_accepted(xfer, file); | |
2204 else | |
2205 gaim_xfer_request(xfer); | |
3630 | 2206 } |
2207 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2208 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2209 GaimConnection *gc = sess->aux_data; |
7283 | 2210 OscarData *od = gc->proto_data; |
6029 | 2211 GaimAccount *account = gc->account; |
2212 aim_conn_t *bosconn; | |
2213 char *host; int port; | |
2214 int i, rc; | |
2086 | 2215 va_list ap; |
2704 | 2216 struct aim_authresp_info *info; |
6029 | 2217 |
5575 | 2218 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2219 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2220 va_start(ap, fr); |
2704 | 2221 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2222 va_end(ap); |
2223 | |
8660 | 2224 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2225 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2226 |
4293 | 2227 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2228 char buf[256]; |
2704 | 2229 switch (info->errorcode) { |
2086 | 2230 case 0x05: |
2231 /* Incorrect nick/password */ | |
6498 | 2232 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2233 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2234 break; |
2235 case 0x11: | |
2236 /* Suspended account */ | |
6498 | 2237 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2238 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2239 break; |
3498 | 2240 case 0x14: |
2241 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2242 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2243 break; |
2086 | 2244 case 0x18: |
2245 /* connecting too frequently */ | |
6498 | 2246 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2247 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 | 2248 break; |
2249 case 0x1c: | |
2250 /* client too old */ | |
6498 | 2251 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2252 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
|
2253 gaim_connection_error(gc, buf); |
2086 | 2254 break; |
2255 default: | |
6623 | 2256 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2257 break; |
2258 } | |
8660 | 2259 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2260 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2261 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2262 "Error URL: %s\n", info->errorurl); |
2086 | 2263 od->killme = TRUE; |
2264 return 1; | |
2265 } | |
2266 | |
2267 | |
9992 | 2268 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2269 |
2704 | 2270 if (info->email) { |
8660 | 2271 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2272 } else { |
8660 | 2273 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2274 } |
10042 | 2275 |
8660 | 2276 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2277 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2278 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2279 aim_conn_kill(sess, &fr->conn); |
2086 | 2280 |
2281 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2282 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2283 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2284 od->killme = TRUE; |
2285 return 0; | |
2286 } | |
2287 | |
4649 | 2288 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2289 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2290 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2291 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2292 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2293 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2294 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2295 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2296 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2297 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2298 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2299 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2300 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2301 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2302 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2303 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2304 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2305 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2306 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2307 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2308 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2309 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2310 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
|
2311 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2312 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2313 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2314 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2315 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2316 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2317 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
|
2318 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
|
2319 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
|
2320 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2321 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2322 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4642 | 2323 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2324 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2325 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2326 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2327 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2328 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2329 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2330 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2331 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2332 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
|
2333 |
7283 | 2334 od->conn = bosconn; |
2704 | 2335 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2336 if (info->bosip[i] == ':') { | |
2337 port = atoi(&(info->bosip[i+1])); | |
2086 | 2338 break; |
2339 } | |
2340 } | |
2704 | 2341 host = g_strndup(info->bosip, i); |
2086 | 2342 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2343 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2344 g_free(host); |
4366 | 2345 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2346 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2347 od->killme = TRUE; |
2348 return 0; | |
2349 } | |
4293 | 2350 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2351 gaim_input_remove(gc->inpa); |
2704 | 2352 |
7283 | 2353 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2354 ck[3] = 0x64; |
7282 | 2355 |
2086 | 2356 return 1; |
2357 } | |
2358 | |
10464 | 2359 static void |
2360 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2361 { | |
2362 GaimConnection *gc = user_data; | |
2363 OscarData *od = gc->proto_data; | |
2364 aim_session_t *sess = od->sess; | |
2365 | |
2366 aim_auth_securid_send(sess, msg); | |
2367 } | |
2368 | |
2369 static void | |
2370 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2371 { | |
2372 GaimConnection *gc = user_data; | |
2373 OscarData *od = gc->proto_data; | |
2374 | |
2375 /* Disconnect */ | |
2376 gc->wants_to_die = TRUE; | |
2377 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2378 od->killme = TRUE; | |
2379 } | |
2380 | |
2381 static int | |
2382 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2383 { | |
2384 GaimConnection *gc = sess->aux_data; | |
2385 GaimAccount *account = gaim_connection_get_account(gc); | |
2386 gchar *primary; | |
2387 | |
2388 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2389 | |
2390 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2391 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2392 _("Enter the 6 digit number from the digital display."), | |
2393 FALSE, FALSE, NULL, | |
2394 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2395 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2396 gc); | |
2397 g_free(primary); | |
2398 | |
2399 return 1; | |
2400 } | |
2401 | |
7285 | 2402 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2403 struct pieceofcrap { |
5575 | 2404 GaimConnection *gc; |
2086 | 2405 unsigned long offset; |
2406 unsigned long len; | |
2407 char *modname; | |
2408 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2409 aim_conn_t *conn; |
2086 | 2410 unsigned int inpa; |
2411 }; | |
2412 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2413 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2414 { |
2415 struct pieceofcrap *pos = data; | |
7283 | 2416 OscarData *od = pos->gc->proto_data; |
2086 | 2417 char in = '\0'; |
2418 int x = 0; | |
2419 unsigned char m[17]; | |
2420 | |
2421 while (read(pos->fd, &in, 1) == 1) { | |
2422 if (in == '\n') | |
2423 x++; | |
2424 else if (in != '\r') | |
2425 x = 0; | |
2426 if (x == 2) | |
2427 break; | |
2428 in = '\0'; | |
2429 } | |
2430 if (in != '\n') { | |
4056 | 2431 char buf[256]; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2432 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
|
2433 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2434 gaim_notify_warning(pos->gc, NULL, |
7422 | 2435 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2436 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2437 gaim_input_remove(pos->inpa); |
2086 | 2438 close(pos->fd); |
2439 g_free(pos); | |
2440 return; | |
2441 } | |
2442 read(pos->fd, m, 16); | |
2443 m[16] = '\0'; | |
8660 | 2444 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2445 for (x = 0; x < 16; x++) |
8660 | 2446 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2447 | |
2448 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2449 gaim_input_remove(pos->inpa); |
2086 | 2450 close(pos->fd); |
2451 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2452 g_free(pos); | |
2453 } | |
2454 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2455 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2456 struct pieceofcrap *pos = data; |
5420 | 2457 gchar *buf; |
2086 | 2458 |
4366 | 2459 pos->fd = source; |
2460 | |
2086 | 2461 if (source < 0) { |
5420 | 2462 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
|
2463 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2464 gaim_notify_warning(pos->gc, NULL, |
7422 | 2465 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2466 buf); |
5420 | 2467 g_free(buf); |
2086 | 2468 if (pos->modname) |
2469 g_free(pos->modname); | |
2470 g_free(pos); | |
2471 return; | |
2472 } | |
2473 | |
5420 | 2474 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2475 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2476 write(pos->fd, buf, strlen(buf)); | |
5420 | 2477 g_free(buf); |
2086 | 2478 if (pos->modname) |
2479 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2480 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2481 return; |
2482 } | |
2483 | |
2484 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2485 #define AIM_MAX_FILE_SIZE 98304 | |
2486 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2487 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2488 va_list ap; |
2489 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2490 fu32_t offset, len; |
2086 | 2491 char *modname; |
2492 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2493 va_start(ap, fr); |
4200 | 2494 offset = va_arg(ap, fu32_t); |
2495 len = va_arg(ap, fu32_t); | |
2086 | 2496 modname = va_arg(ap, char *); |
2497 va_end(ap); | |
2498 | |
8660 | 2499 gaim_debug_misc("oscar", |
5556 | 2500 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2501 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2502 |
2086 | 2503 if (len == 0) { |
8660 | 2504 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2505 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2506 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2507 return 1; | |
2508 } | |
9625 | 2509 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2510 #if 0 | |
2086 | 2511 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2512 char *buf; | |
2513 int i = 8; | |
2514 if (modname) | |
2515 i += strlen(modname); | |
2516 buf = g_malloc(i); | |
2517 i = 0; | |
2518 if (modname) { | |
2519 memcpy(buf, modname, strlen(modname)); | |
2520 i += strlen(modname); | |
2521 } | |
2522 buf[i++] = offset & 0xff; | |
2523 buf[i++] = (offset >> 8) & 0xff; | |
2524 buf[i++] = (offset >> 16) & 0xff; | |
2525 buf[i++] = (offset >> 24) & 0xff; | |
2526 buf[i++] = len & 0xff; | |
2527 buf[i++] = (len >> 8) & 0xff; | |
2528 buf[i++] = (len >> 16) & 0xff; | |
2529 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2530 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2531 "hashing request\n"); |
2086 | 2532 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2533 g_free(buf); | |
2534 return 1; | |
2535 } | |
9625 | 2536 #endif |
2086 | 2537 |
2538 pos = g_new0(struct pieceofcrap, 1); | |
2539 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2540 pos->conn = fr->conn; |
2086 | 2541 |
2542 pos->offset = offset; | |
2543 pos->len = len; | |
2544 pos->modname = modname ? g_strdup(modname) : NULL; | |
2545 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2546 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2547 char buf[256]; |
2086 | 2548 if (pos->modname) |
2549 g_free(pos->modname); | |
2550 g_free(pos); | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2551 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
|
2552 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2553 gaim_notify_warning(pos->gc, NULL, |
7422 | 2554 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2555 buf); |
2086 | 2556 } |
2557 | |
2558 return 1; | |
2559 } | |
2560 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2561 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2562 GaimConnection *gc = sess->aux_data; |
7283 | 2563 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2564 GaimAccount *account = gaim_connection_get_account(gc); |
7282 | 2565 #if 0 |
2566 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2567 #endif | |
7011 | 2568 va_list ap; |
2569 char *key; | |
2086 | 2570 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2571 va_start(ap, fr); |
2086 | 2572 key = va_arg(ap, char *); |
2573 va_end(ap); | |
2574 | |
4617 | 2575 if (od->icq) { |
3458 | 2576 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
10740 | 2577 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2578 gaim_connection_get_password(gc), &info, key); | |
3458 | 2579 } else { |
2580 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
10740 | 2581 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2582 gaim_connection_get_password(gc), &info, key); | |
3458 | 2583 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2584 |
7283 | 2585 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2586 ck[2] = 0x6c; |
7282 | 2587 |
2086 | 2588 return 1; |
2589 } | |
2590 | |
2675 | 2591 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2592 GaimConnection *gc = sess->aux_data; |
2647 | 2593 struct chat_connection *chatcon; |
2594 static int id = 1; | |
2595 | |
6905 | 2596 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
|
2597 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
|
2598 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
|
2599 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
|
2600 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2601 |
2672 | 2602 aim_clientready(sess, fr->conn); |
2675 | 2603 |
2647 | 2604 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2605 chatcon->id = id; | |
8733 | 2606 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2607 |
2608 return 1; | |
2609 } | |
2610 | |
2675 | 2611 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2612 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2613 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2614 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2615 |
2616 aim_clientready(sess, fr->conn); | |
2617 | |
2618 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2619 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2620 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2621 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2622 |
3694 | 2623 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2624 | |
2625 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2626 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2627 | |
7282 | 2628 aim_email_sendcookies(sess); |
2629 aim_email_activate(sess); | |
3694 | 2630 aim_clientready(sess, fr->conn); |
2631 | |
2632 return 1; | |
2633 } | |
2634 | |
4804 | 2635 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2636 GaimConnection *gc = sess->aux_data; |
7283 | 2637 OscarData *od = gc->proto_data; |
4804 | 2638 |
2639 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2640 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2641 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2642 | |
2643 aim_clientready(sess, fr->conn); | |
2644 | |
4823 | 2645 od->iconconnecting = FALSE; |
2646 | |
4804 | 2647 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2648 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2649 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2650 |
2651 return 1; | |
2652 } | |
2653 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2654 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2655 GaimConnection *gc = data; |
7283 | 2656 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2657 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2658 aim_conn_t *tstconn; |
2086 | 2659 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2660 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2661 close(source); |
2662 return; | |
2663 } | |
2664 | |
4617 | 2665 od = gc->proto_data; |
2666 sess = od->sess; | |
2086 | 2667 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2668 tstconn->fd = source; |
2086 | 2669 |
2670 if (source < 0) { | |
2671 aim_conn_kill(sess, &tstconn); | |
8660 | 2672 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2673 "unable to connect to chatnav server\n"); |
2086 | 2674 return; |
2675 } | |
2676 | |
2677 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2678 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2679 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2680 } |
2681 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2682 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2683 { |
5575 | 2684 GaimConnection *gc = data; |
7283 | 2685 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2686 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2687 aim_conn_t *tstconn; |
2086 | 2688 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2689 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2690 close(source); |
2691 return; | |
2692 } | |
2693 | |
4617 | 2694 od = gc->proto_data; |
2695 sess = od->sess; | |
2086 | 2696 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2697 tstconn->fd = source; |
2086 | 2698 |
2699 if (source < 0) { | |
2700 aim_conn_kill(sess, &tstconn); | |
8660 | 2701 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2702 "unable to connect to authorizer\n"); |
2086 | 2703 return; |
2704 } | |
2705 | |
2706 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2707 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2708 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2709 } |
2710 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2711 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2712 { |
2713 struct chat_connection *ccon = data; | |
5575 | 2714 GaimConnection *gc = ccon->gc; |
7283 | 2715 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2716 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2717 aim_conn_t *tstconn; |
2086 | 2718 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2719 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2720 close(source); |
2721 g_free(ccon->show); | |
2722 g_free(ccon->name); | |
2723 g_free(ccon); | |
2724 return; | |
2725 } | |
2726 | |
4617 | 2727 od = gc->proto_data; |
2728 sess = od->sess; | |
2086 | 2729 tstconn = ccon->conn; |
4366 | 2730 tstconn->fd = source; |
2086 | 2731 |
2732 if (source < 0) { | |
2733 aim_conn_kill(sess, &tstconn); | |
2734 g_free(ccon->show); | |
2735 g_free(ccon->name); | |
2736 g_free(ccon); | |
2737 return; | |
2738 } | |
2739 | |
2740 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2741 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2742 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2743 } |
2744 | |
3694 | 2745 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2746 GaimConnection *gc = data; |
7283 | 2747 OscarData *od; |
3694 | 2748 aim_session_t *sess; |
2749 aim_conn_t *tstconn; | |
2750 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2751 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2752 close(source); |
2753 return; | |
2754 } | |
2755 | |
4617 | 2756 od = gc->proto_data; |
2757 sess = od->sess; | |
3694 | 2758 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2759 tstconn->fd = source; |
3694 | 2760 |
2761 if (source < 0) { | |
2762 aim_conn_kill(sess, &tstconn); | |
8660 | 2763 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2764 "unable to connect to email server\n"); |
3694 | 2765 return; |
2766 } | |
2767 | |
2768 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2769 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2770 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2771 "email: connected\n"); |
3694 | 2772 } |
2773 | |
4804 | 2774 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2775 GaimConnection *gc = data; |
7283 | 2776 OscarData *od; |
4804 | 2777 aim_session_t *sess; |
2778 aim_conn_t *tstconn; | |
2779 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2780 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2781 close(source); |
2782 return; | |
2783 } | |
2784 | |
2785 od = gc->proto_data; | |
2786 sess = od->sess; | |
2787 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2788 tstconn->fd = source; | |
2789 | |
2790 if (source < 0) { | |
2791 aim_conn_kill(sess, &tstconn); | |
8660 | 2792 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2793 "unable to connect to icon server\n"); |
4804 | 2794 return; |
2795 } | |
2796 | |
2797 aim_conn_completeconnect(sess, tstconn); | |
2798 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2799 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2800 } |
2801 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2802 /* 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
|
2803 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2804 GaimConnection *gc = sess->aux_data; |
2805 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2806 aim_conn_t *tstconn; |
4452 | 2807 int i; |
2086 | 2808 char *host; |
2809 int port; | |
4821 | 2810 va_list ap; |
2811 struct aim_redirect_data *redir; | |
2086 | 2812 |
5575 | 2813 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2814 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2815 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2816 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2817 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2818 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2819 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2820 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2821 port = atoi(&(redir->ip[i+1])); |
2086 | 2822 break; |
2823 } | |
2824 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2825 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2826 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2827 switch(redir->group) { |
2086 | 2828 case 0x7: /* Authorizer */ |
8660 | 2829 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2830 "Reconnecting with authorizor...\n"); |
2086 | 2831 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2832 if (tstconn == NULL) { | |
8660 | 2833 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2834 "unable to reconnect with authorizer\n"); |
2086 | 2835 g_free(host); |
2836 return 1; | |
2837 } | |
4649 | 2838 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2839 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2840 |
2841 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2842 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2843 aim_conn_kill(sess, &tstconn); |
8660 | 2844 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2845 "unable to reconnect with authorizer\n"); |
2086 | 2846 g_free(host); |
2847 return 1; | |
2848 } | |
4293 | 2849 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2850 break; |
2851 | |
2086 | 2852 case 0xd: /* ChatNav */ |
2853 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2854 if (tstconn == NULL) { | |
8660 | 2855 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2856 "unable to connect to chatnav server\n"); |
2086 | 2857 g_free(host); |
2858 return 1; | |
2859 } | |
4649 | 2860 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2861 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2862 |
2863 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2864 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2865 aim_conn_kill(sess, &tstconn); |
8660 | 2866 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2867 "unable to connect to chatnav server\n"); |
2086 | 2868 g_free(host); |
2869 return 1; | |
2870 } | |
4293 | 2871 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2872 break; |
2873 | |
2874 case 0xe: { /* Chat */ | |
2086 | 2875 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2876 |
2086 | 2877 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2878 if (tstconn == NULL) { | |
8660 | 2879 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2880 "unable to connect to chat server\n"); |
2086 | 2881 g_free(host); |
2882 return 1; | |
2883 } | |
2884 | |
4649 | 2885 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2886 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2887 | |
2086 | 2888 ccon = g_new0(struct chat_connection, 1); |
2889 ccon->conn = tstconn; | |
2890 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2891 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2892 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2893 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2894 ccon->show = extract_name(redir->chat.room); |
4634 | 2895 |
2086 | 2896 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2897 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2898 aim_conn_kill(sess, &tstconn); |
8660 | 2899 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2900 "unable to connect to chat server\n"); |
2086 | 2901 g_free(host); |
2902 g_free(ccon->show); | |
2903 g_free(ccon->name); | |
2904 g_free(ccon); | |
2905 return 1; | |
2906 } | |
4293 | 2907 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2908 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2909 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2910 ccon->name, ccon->exchange); |
4194 | 2911 } break; |
3694 | 2912 |
4804 | 2913 case 0x0010: { /* icon */ |
2914 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2915 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2916 "unable to connect to icon server\n"); |
4804 | 2917 g_free(host); |
2918 return 1; | |
2919 } | |
2920 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2921 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2922 | |
2923 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2924 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2925 aim_conn_kill(sess, &tstconn); |
8660 | 2926 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2927 "unable to connect to icon server\n"); |
4804 | 2928 g_free(host); |
2929 return 1; | |
2930 } | |
2931 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2932 } break; | |
2933 | |
3694 | 2934 case 0x0018: { /* email */ |
2935 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2936 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2937 "unable to connect to email server\n"); |
3694 | 2938 g_free(host); |
2939 return 1; | |
2940 } | |
4649 | 2941 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2942 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2943 | |
2944 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2945 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2946 aim_conn_kill(sess, &tstconn); |
8660 | 2947 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2948 "unable to connect to email server\n"); |
3694 | 2949 g_free(host); |
2950 return 1; | |
2951 } | |
4293 | 2952 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2953 } break; |
2954 | |
2086 | 2955 default: /* huh? */ |
8660 | 2956 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2957 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2958 redir->group); |
2086 | 2959 break; |
2960 } | |
2961 | |
2962 g_free(host); | |
2963 return 1; | |
2964 } | |
2965 | |
10042 | 2966 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
2967 { | |
2968 GaimConnection *gc; | |
2969 GaimAccount *account; | |
2970 OscarData *od; | |
4738 | 2971 struct buddyinfo *bi; |
2993 | 2972 time_t time_idle = 0, signon = 0; |
2973 int type = 0; | |
2974 int caps = 0; | |
2086 | 2975 va_list ap; |
4738 | 2976 aim_userinfo_t *info; |
10042 | 2977 gboolean buddy_is_away = FALSE; |
2978 | |
2979 gc = sess->aux_data; | |
2980 account = gaim_connection_get_account(gc); | |
2981 od = gc->proto_data; | |
4194 | 2982 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2983 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2984 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2985 va_end(ap); |
2986 | |
10130 | 2987 g_return_val_if_fail(info != NULL, 1); |
2988 g_return_val_if_fail(info->sn != NULL, 1); | |
2989 | |
2993 | 2990 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2991 caps = info->capabilities; | |
3267 | 2992 |
4766 | 2993 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2994 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 2995 buddy_is_away = TRUE; |
2996 } | |
2997 | |
2993 | 2998 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2999 type = (info->icqinfo.status << 16); |
3013 | 3000 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3001 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3002 buddy_is_away = TRUE; |
3013 | 3003 } |
2993 | 3004 } |
3005 | |
7141 | 3006 if (caps & AIM_CAPS_ICQ_DIRECT) |
3007 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 3008 |
10860 | 3009 /* info->idletime is the number of minutes that this user has been idle */ |
3010 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
3011 time_idle = time(NULL) - info->idletime * 60; | |
2993 | 3012 |
5836 | 3013 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3014 signon = info->onlinesince; | |
3015 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3016 signon = time(NULL) - info->sessionlen; |
2086 | 3017 |
10567 | 3018 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3019 gaim_connection_set_display_name(gc, info->sn); |
10567 | 3020 od->timeoffset = signon - gc->login_time; |
3021 } | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
3022 |
9982 | 3023 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3024 if (!bi) { |
3025 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3026 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3027 } |
4739 | 3028 bi->typingnot = FALSE; |
3029 bi->ico_informed = FALSE; | |
6857 | 3030 bi->ipaddr = info->icqinfo.ipaddr; |
3031 | |
10563 | 3032 /* |
3033 * Handle the available message. If info->avail is NULL then the user | |
3034 * may or may not have an available message, so don't do anything. If | |
3035 * info->avail is set to the empty string, then the user's client DOES | |
3036 * support available messages and the user DOES NOT have one set. | |
3037 * Otherwise info->avail contains the available message. | |
3038 */ | |
7011 | 3039 if (info->avail != NULL) |
10563 | 3040 { |
3041 free(bi->availmsg); | |
3042 if (info->avail[0] != '\0') | |
3043 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); | |
3044 else | |
3045 bi->availmsg = NULL; | |
3046 } | |
4732 | 3047 |
4804 | 3048 /* Server stored icon stuff */ |
4853 | 3049 if (info->iconcsumlen) { |
7125 | 3050 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3051 char *b16 = NULL, *filepath = NULL; |
7093 | 3052 GaimBuddy *b = NULL; |
4853 | 3053 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3054 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3055 b = gaim_find_buddy(account, info->sn); |
7093 | 3056 /* |
3057 * If for some reason the checksum is valid, but cached file is not.. | |
3058 * we want to know. | |
3059 */ | |
7693 | 3060 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3061 if (filename != NULL) { |
3062 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3063 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3064 "icon_checksum"); | |
9801 | 3065 else { |
3066 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3067 filename, NULL); | |
3068 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3069 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3070 "icon_checksum"); | |
3071 g_free(filepath); | |
3072 } | |
7093 | 3073 } else |
3074 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3075 |
4853 | 3076 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3077 GSList *cur = od->requesticon; | |
3078 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3079 cur = cur->next; | |
3080 if (!cur) { | |
9982 | 3081 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3082 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3083 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3084 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3085 } |
3086 } | |
6053 | 3087 g_free(b16); |
4853 | 3088 } |
3089 | |
10042 | 3090 /* XXX - Represent other ICQ statuses */ |
3091 if (buddy_is_away == TRUE) | |
3092 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
3093 else | |
3094 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
10567 | 3095 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
9982 | 3096 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); |
3097 | |
3098 if (time_idle > 0) | |
3099 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 3100 else |
3101 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 3102 |
3103 return 1; | |
3104 } | |
3105 | |
8341 | 3106 static void gaim_check_comment(OscarData *od, const char *str) { |
3107 if ((str == NULL) || strcmp(str, ck)) | |
3108 aim_locate_setcaps(od->sess, caps_aim); | |
3109 else | |
3110 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3111 } | |
3112 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3113 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3114 GaimConnection *gc = sess->aux_data; |
7283 | 3115 OscarData *od = gc->proto_data; |
9982 | 3116 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3117 va_list ap; |
4739 | 3118 aim_userinfo_t *info; |
2086 | 3119 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3120 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3121 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3122 va_end(ap); |
3123 | |
9982 | 3124 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3125 |
7261 | 3126 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3127 |
2086 | 3128 return 1; |
3129 } | |
3130 | |
4617 | 3131 /* BBB */ |
3952 | 3132 /* |
4617 | 3133 * This is called after a remote AIM user has connected to us. We |
3134 * want to do some voodoo with the socket file descriptors, add a | |
3135 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3136 */ |
4656 | 3137 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3138 GaimConnection *gc = sess->aux_data; |
7283 | 3139 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3140 GaimXfer *xfer; |
5146 | 3141 struct aim_oft_info *oft_info; |
3630 | 3142 va_list ap; |
3143 aim_conn_t *conn, *listenerconn; | |
4656 | 3144 |
8660 | 3145 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3146 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3147 va_start(ap, fr); |
3148 conn = va_arg(ap, aim_conn_t *); | |
3149 listenerconn = va_arg(ap, aim_conn_t *); | |
3150 va_end(ap); | |
3151 | |
4617 | 3152 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3153 return 1; | |
3154 | |
5146 | 3155 if (!(oft_info = xfer->data)) |
4617 | 3156 return 1; |
3157 | |
3630 | 3158 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3159 gaim_input_remove(xfer->watcher); |
3630 | 3160 aim_conn_kill(sess, &listenerconn); |
3161 | |
5146 | 3162 oft_info->conn = conn; |
3163 xfer->fd = oft_info->conn->fd; | |
3164 | |
3165 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3166 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3167 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3168 |
3169 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3170 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3171 |
3172 return 0; | |
3173 } | |
3174 | |
3952 | 3175 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3176 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3177 * user in order to transfer a file. |
3952 | 3178 */ |
4617 | 3179 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
|
3180 GaimXfer *xfer; |
5146 | 3181 struct aim_oft_info *oft_info; |
4656 | 3182 |
8660 | 3183 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3184 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3185 if (!(xfer = data)) |
3186 return; | |
5146 | 3187 if (!(oft_info = xfer->data)) |
3630 | 3188 return; |
8446 | 3189 if (source < 0) { |
3190 gaim_xfer_cancel_remote(xfer); | |
4617 | 3191 return; |
8446 | 3192 } |
4617 | 3193 |
3194 xfer->fd = source; | |
5146 | 3195 oft_info->conn->fd = source; |
3196 | |
3197 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3198 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3199 |
3200 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3201 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3202 |
3203 return; | |
3630 | 3204 } |
3205 | |
3952 | 3206 /* |
4617 | 3207 * This is called when a buddy sends us some file info. This happens when they |
3208 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3209 * You should send them the exact same info except use the real cookie. We also |
4617 | 3210 * get like totally ready to like, receive the file, kay? |
3952 | 3211 */ |
4617 | 3212 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3213 GaimConnection *gc = sess->aux_data; |
7283 | 3214 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3215 GaimXfer *xfer; |
5146 | 3216 struct aim_oft_info *oft_info; |
4617 | 3217 va_list ap; |
3218 aim_conn_t *conn; | |
3219 fu8_t *cookie; | |
3220 struct aim_fileheader_t *fh; | |
4656 | 3221 |
8660 | 3222 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3223 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3224 va_start(ap, fr); |
3225 conn = va_arg(ap, aim_conn_t *); | |
3226 cookie = va_arg(ap, fu8_t *); | |
3227 fh = va_arg(ap, struct aim_fileheader_t *); | |
3228 va_end(ap); | |
3229 | |
3230 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3231 return 1; | |
3232 | |
5146 | 3233 if (!(oft_info = xfer->data)) |
4617 | 3234 return 1; |
3235 | |
3236 /* We want to stop listening with a normal thingy */ | |
3237 gaim_input_remove(xfer->watcher); | |
3238 xfer->watcher = 0; | |
3239 | |
5146 | 3240 /* They sent us some information about the file they're sending */ |
3241 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3242 | |
3243 /* Fill in the cookie */ | |
3244 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3245 | |
4617 | 3246 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3247 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3248 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3249 | |
3250 return 0; | |
3630 | 3251 } |
3252 | |
3952 | 3253 /* |
4657 | 3254 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3255 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3256 */ |
4617 | 3257 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3258 GaimConnection *gc = sess->aux_data; |
7283 | 3259 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3260 GaimXfer *xfer; |
4617 | 3261 va_list ap; |
3262 aim_conn_t *conn; | |
3263 fu8_t *cookie; | |
3264 struct aim_fileheader_t *fh; | |
4656 | 3265 |
8660 | 3266 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3267 va_start(ap, fr); |
3268 conn = va_arg(ap, aim_conn_t *); | |
3269 cookie = va_arg(ap, fu8_t *); | |
3270 fh = va_arg(ap, struct aim_fileheader_t *); | |
3271 va_end(ap); | |
3272 | |
3273 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3274 return 1; | |
3275 | |
4656 | 3276 /* We want to stop listening with a normal thingy */ |
3277 gaim_input_remove(xfer->watcher); | |
3278 xfer->watcher = 0; | |
3279 | |
4617 | 3280 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3281 | |
3282 return 0; | |
3630 | 3283 } |
4617 | 3284 |
3285 /* | |
3286 * We just sent a file to someone. They said they got it and everything, | |
3287 * so we can close our direct connection and what not. | |
3288 */ | |
3289 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3290 GaimConnection *gc = sess->aux_data; |
7283 | 3291 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3292 GaimXfer *xfer; |
4617 | 3293 va_list ap; |
3294 aim_conn_t *conn; | |
3295 fu8_t *cookie; | |
3296 struct aim_fileheader_t *fh; | |
4656 | 3297 |
8660 | 3298 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3299 va_start(ap, fr); |
3300 conn = va_arg(ap, aim_conn_t *); | |
3301 cookie = va_arg(ap, fu8_t *); | |
3302 fh = va_arg(ap, struct aim_fileheader_t *); | |
3303 va_end(ap); | |
3304 | |
3305 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3306 return 1; | |
3307 | |
4656 | 3308 xfer->fd = conn->fd; |
4617 | 3309 gaim_xfer_end(xfer); |
3310 | |
3311 return 0; | |
3312 } | |
3630 | 3313 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3314 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3315 GaimConnection *gc = sess->aux_data; |
7283 | 3316 OscarData *od = gc->proto_data; |
8708 | 3317 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3318 GaimConvImFlags flags = 0; |
4738 | 3319 struct buddyinfo *bi; |
5575 | 3320 const char *iconfile; |
9806 | 3321 GString *message; |
3322 gchar *tmp; | |
3323 aim_mpmsg_section_t *curpart; | |
3324 | |
10472 | 3325 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3326 userinfo->sn, args->mpmsg.numparts); |
4738 | 3327 |
10595 | 3328 if (args->mpmsg.numparts == 0) |
3329 return 1; | |
3330 | |
8708 | 3331 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3332 if (!bi) { |
3333 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3334 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3335 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3336 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3337 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3338 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3339 |
4738 | 3340 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3341 bi->typingnot = TRUE; | |
3342 else | |
3343 bi->typingnot = FALSE; | |
3344 | |
4380 | 3345 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3346 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3347 "%s has an icon\n", userinfo->sn); |
4738 | 3348 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3349 bi->ico_need = TRUE; | |
3350 bi->ico_len = args->iconlen; | |
3351 bi->ico_csum = args->iconsum; | |
3352 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3353 } |
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 |
10458 | 3356 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3357 (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
|
3358 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3359 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3360 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3361 if (!g_stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3362 char *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3363 file = g_fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3364 if (file) { |
9532 | 3365 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3366 int len = fread(buf, 1, st.st_size, file); |
8660 | 3367 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3368 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3369 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3370 userinfo->sn, len, st.st_size); |
4617 | 3371 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3372 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3373 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3374 } else |
8660 | 3375 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3376 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3377 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3378 } else |
8660 | 3379 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3380 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3381 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3382 |
9806 | 3383 message = g_string_new(""); |
3384 curpart = args->mpmsg.parts; | |
3385 while (curpart != NULL) { | |
9908 | 3386 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3387 curpart->data, curpart->datalen); |
3388 if (tmp != NULL) { | |
3389 g_string_append(message, tmp); | |
3390 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3391 } |
9806 | 3392 |
3393 curpart = curpart->next; | |
3394 } | |
3395 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3396 |
8666 | 3397 /* |
10781 | 3398 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
9016 | 3399 * because HTML is not sent over ICQ as a means to format a message. |
10781 | 3400 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
3401 * replaced with <br> | |
8995 | 3402 * |
3403 * Note: There *may* be some clients which send messages as HTML formatted - | |
3404 * they need to be special-cased somehow. | |
8666 | 3405 */ |
9982 | 3406 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3407 /* 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
|
3408 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
8493 | 3409 g_free(tmp); |
3410 tmp = tmp2; | |
10783 | 3411 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
10781 | 3412 g_free(tmp); |
3413 tmp = tmp2; | |
8493 | 3414 } |
3415 | |
6982 | 3416 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3417 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3418 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3419 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3420 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3421 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3422 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3423 GaimConnection *gc; |
9933 | 3424 GaimAccount *account; |
9070 | 3425 OscarData *od; |
9933 | 3426 const char *username = NULL; |
3427 char *message = NULL; | |
9070 | 3428 |
3429 g_return_val_if_fail(sess != NULL, 0); | |
3430 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3431 | |
3432 gc = sess->aux_data; | |
9933 | 3433 account = gaim_connection_get_account(gc); |
9070 | 3434 od = gc->proto_data; |
9933 | 3435 username = gaim_account_get_username(account); |
3436 | |
3437 if (args == NULL) | |
4121 | 3438 return 0; |
4194 | 3439 |
9933 | 3440 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3441 userinfo->sn, args->status); | |
3442 | |
3443 if (args->msg != NULL) | |
3444 { | |
3445 if (args->encoding != NULL) | |
3446 { | |
3447 char *encoding = NULL; | |
3448 encoding = oscar_encoding_extract(args->encoding); | |
3449 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3450 g_free(encoding); | |
3451 } else { | |
3452 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3453 message = g_strdup(args->msg); | |
3454 } | |
3455 } | |
2869 | 3456 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3457 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3458 char *name; |
5234 | 3459 GHashTable *components; |
3460 | |
9933 | 3461 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3462 g_free(message); | |
4121 | 3463 return 1; |
9933 | 3464 } |
5234 | 3465 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3466 g_free); | |
4121 | 3467 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3468 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3469 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
|
3470 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3471 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3472 userinfo->sn, |
9933 | 3473 message, |
5234 | 3474 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3475 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3476 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3477 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3478 /* BBB */ |
3479 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3480 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3481 GaimXfer *xfer; |
5146 | 3482 struct aim_oft_info *oft_info; |
3483 | |
3484 if (!args->cookie || !args->port || !args->verifiedip || | |
3485 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3486 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3487 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3488 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3489 "information.\n", userinfo->sn); |
5146 | 3490 if (args->proxyip) |
8660 | 3491 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3492 "IP for a proxy server was given. Gaim " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3493 "does not support this yet.\n"); |
9933 | 3494 g_free(message); |
4617 | 3495 return 1; |
4656 | 3496 } |
4617 | 3497 |
3498 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3499 /* 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
|
3500 * directory -- remove the star and trailing slash so we don't save |
4617 | 3501 * directories that look like 'dirname\*' -- arl */ |
3502 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3503 if (tmp && (tmp[1] == '*')) { | |
3504 tmp[0] = '\0'; | |
3505 } | |
8660 | 3506 gaim_debug_warning("oscar", |
8446 | 3507 "We're receiving a whole directory! What fun! " |
3508 "Especially since we don't support that!\n"); | |
4617 | 3509 } |
3510 | |
3511 /* Build the file transfer handle */ | |
3512 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3513 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3514 xfer->remote_port = args->port; |
4617 | 3515 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3516 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3517 gaim_xfer_set_message(xfer, message); |
5146 | 3518 |
3519 /* Create the oscar-specific data */ | |
5163 | 3520 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3521 if (args->proxyip) |
5146 | 3522 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3523 if (args->verifiedip) |
5146 | 3524 oft_info->verifiedip = g_strdup(args->verifiedip); |
3525 xfer->data = oft_info; | |
4617 | 3526 |
3527 /* Setup our I/O op functions */ | |
8446 | 3528 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3529 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3530 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
|
3531 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3532 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3533 |
3534 /* Keep track of this transfer for later */ | |
3535 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3536 | |
3537 /* Now perform the request */ | |
3538 gaim_xfer_request(xfer); | |
3539 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3540 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3541 GaimXfer *xfer; |
8660 | 3542 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3543 "AAA - File transfer canceled by remote user\n"); |
4617 | 3544 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
|
3545 gaim_xfer_cancel_remote(xfer); |
4617 | 3546 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3547 /* | |
3548 * This gets sent by the receiver of a file | |
3549 * as they connect directly to us. If we don't | |
3550 * get this, then maybe a third party connected | |
3551 * to us, and we shouldn't send them anything. | |
3552 */ | |
3553 } else { | |
8660 | 3554 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3555 "unknown rendezvous status!\n"); |
3630 | 3556 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3557 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3558 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3559 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3560 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3561 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3562 args->info.icon.length); |
6871 | 3563 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3564 /* 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
|
3565 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3566 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
|
3567 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3568 |
4212 | 3569 if (!args->verifiedip) { |
8983 | 3570 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3571 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3572 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3573 g_free(message); |
4650 | 3574 return 1; |
4212 | 3575 } |
3576 | |
8660 | 3577 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3578 "%s received direct im request from %s (%s)\n", |
10594 | 3579 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3580 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3581 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3582 d->sn = g_strdup(userinfo->sn); |
8983 | 3583 /* Let's use the clientip here, because I think that's what AIM does. |
3584 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3585 * and then ask them to connect to us. */ | |
10594 | 3586 /* |
3587 * I disagree, let's use the verifiedip. I think AIM tries the | |
3588 * verified IP first, then tries the client IP if that fails. In | |
3589 * any case, there's a better chance the verified IP will be correct. | |
3590 * The client IP is what the other person _thinks_ their IP address | |
3591 * is. The verified IP is the address that the AIM server sees the | |
3592 * other person using. | |
3593 */ | |
3594 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
|
3595 memcpy(d->cookie, args->cookie, 8); |
9070 | 3596 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3597 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3598 | |
8971 | 3599 oscar_direct_im_destroy(od, dim); |
8984 | 3600 d->donttryagain = TRUE; |
8971 | 3601 accept_direct_im_request(d); |
3602 } else { | |
8983 | 3603 if (dim && !dim->connected) |
8971 | 3604 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3605 "already connected to that buddy!"); | |
5575 | 3606 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
|
3607 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3608 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3609 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3610 "the two computers and is necessary for IM " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3611 "Images. Because your IP address will be " |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3612 "revealed, this may be considered a privacy " |
9972 | 3613 "risk."), |
3614 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3615 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3616 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3617 /* FIXME: we should actually send a packet on cancel */ | |
3618 } | |
8708 | 3619 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3620 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
|
3621 } else { |
8660 | 3622 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3623 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3624 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3625 |
9933 | 3626 g_free(message); |
3627 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3628 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3629 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3630 |
3453 | 3631 /* |
4230 | 3632 * Authorization Functions |
3633 * Most of these are callbacks from dialogs. They're used by both | |
3634 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3635 */ |
4269 | 3636 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3637 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3638 GaimConnection *gc = data->gc; |
4244 | 3639 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3640 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3641 OscarData *od = gc->proto_data; |
6695 | 3642 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3643 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3644 if (buddy && group) { |
8660 | 3645 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3646 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3647 buddy->name, group->name); |
4889 | 3648 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3649 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3650 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3651 } |
4230 | 3652 } |
4337 | 3653 } |
3654 | |
3655 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3656 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3657 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3658 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3659 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3660 data); |
4230 | 3661 } |
3662 | |
3663 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3664 GaimConnection *gc = data->gc; |
4244 | 3665 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3666 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3667 /* Remove from local list */ |
3668 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3669 gaim_blist_remove_buddy(b); | |
4244 | 3670 } |
3671 | |
5836 | 3672 oscar_free_name_data(data); |
4230 | 3673 } |
3674 | |
9030 | 3675 |
3676 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3677 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3678 GaimBuddy *buddy; |
4269 | 3679 gchar *dialog_msg, *nombre; |
3680 | |
4687 | 3681 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3682 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3683 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3684 else |
4830 | 3685 nombre = NULL; |
3686 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3687 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 | 3688 data->gc = gc; |
3689 data->name = g_strdup(name); | |
3690 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3691 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3692 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3693 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3694 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3695 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3696 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3697 |
3698 g_free(dialog_msg); | |
3699 g_free(nombre); | |
3700 } | |
3701 | |
9030 | 3702 |
3703 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3704 GaimBuddy *buddy; | |
3705 GaimConnection *gc; | |
3706 | |
3707 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3708 | |
3709 buddy = (GaimBuddy *) node; | |
3710 gc = gaim_account_get_connection(buddy->account); | |
3711 gaim_auth_sendrequest(gc, buddy->name); | |
3712 } | |
3713 | |
4230 | 3714 /* When other people ask you for authorization */ |
3715 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3716 GaimConnection *gc = data->gc; |
4244 | 3717 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3718 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3719 OscarData *od = gc->proto_data; |
4889 | 3720 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4244 | 3721 } |
3722 | |
5836 | 3723 oscar_free_name_data(data); |
3141 | 3724 } |
3725 | |
4230 | 3726 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3727 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3728 GaimConnection *gc = data->gc; |
4244 | 3729 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3730 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3731 OscarData *od = gc->proto_data; |
4889 | 3732 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4244 | 3733 } |
4337 | 3734 } |
3735 | |
3736 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3737 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3738 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3739 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3740 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3741 data); |
3141 | 3742 } |
3743 | |
7023 | 3744 /* When someone sends you buddies */ |
3745 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3746 GaimConnection *gc = data->gc; |
4244 | 3747 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3748 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3749 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3750 } |
3751 | |
5836 | 3752 oscar_free_name_data(data); |
3453 | 3753 } |
3754 | |
4075 | 3755 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 | 3756 GaimConnection *gc = sess->aux_data; |
9908 | 3757 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3758 gchar **msg1, **msg2; |
6051 | 3759 int i, numtoks; |
4076 | 3760 |
4121 | 3761 if (!args->type || !args->msg || !args->uin) |
3762 return 1; | |
4194 | 3763 |
8660 | 3764 gaim_debug_info("oscar", |
9908 | 3765 "Received a channel 4 message of type 0x%02hhx.\n", |
3766 args->type); | |
4076 | 3767 |
9919 | 3768 /* |
3769 * Split up the message at the delimeter character, then convert each | |
3770 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3771 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3772 * character in whatever encoding the message was sent in. Type 1 | |
3773 * messages are always made up of only one part, so we can easily account | |
3774 * for this suck-ass part of the protocol by splitting the string into at | |
3775 * most 1 baby string. | |
3776 */ | |
3777 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3778 for (numtoks=0; msg1[numtoks]; numtoks++); |
3779 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3780 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3781 gaim_str_strip_cr(msg1[i]); |
9908 | 3782 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3783 } |
3784 msg2[i] = NULL; | |
3785 | |
3952 | 3786 switch (args->type) { |
4173 | 3787 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3788 if (i >= 1) { |
5556 | 3789 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3790 gchar *tmp; |
3791 | |
3792 /* 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
|
3793 tmp = g_markup_escape_text(msg2[0], -1); |
8493 | 3794 |
4076 | 3795 if (t) { /* This is an offline message */ |
9680 | 3796 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3797 #ifdef HAVE_TM_GMTOFF |
9724 | 3798 time_t now; |
3799 struct tm *tm; | |
3800 now = time(NULL); | |
3801 tm = localtime(&now); | |
3802 t += tm->tm_gmtoff; | |
9698 | 3803 #else |
3804 # ifdef HAVE_TIMEZONE | |
9680 | 3805 tzset(); |
3806 t -= timezone; | |
9698 | 3807 # endif |
3808 #endif | |
8514 | 3809 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3810 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3811 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3812 } |
3813 g_free(uin); | |
8493 | 3814 g_free(tmp); |
4075 | 3815 } |
3316 | 3816 } break; |
3817 | |
4173 | 3818 case 0x04: { /* Someone sent you a URL */ |
4076 | 3819 if (i >= 2) { |
7385 | 3820 if (msg2[1] != NULL) { |
3821 gchar *uin = g_strdup_printf("%u", args->uin); | |
3822 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3823 msg2[1], | |
3824 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3825 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3826 g_free(uin); | |
3827 g_free(message); | |
3828 } | |
3453 | 3829 } |
3830 } break; | |
3831 | |
4173 | 3832 case 0x06: { /* Someone requested authorization */ |
4076 | 3833 if (i >= 6) { |
4230 | 3834 struct name_data *data = g_new(struct name_data, 1); |
10949 | 3835 gchar *dialog_msg = g_strdup_printf( |
3836 _("The user %u wants to add %s to their buddy list for the following reason:\n%s"), | |
3837 args->uin, gaim_account_get_username(gc->account), | |
3838 (msg2[5] ? msg2[5] : _("No reason given."))); | |
8660 | 3839 gaim_debug_info("oscar", |
5556 | 3840 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3841 args->uin); |
4076 | 3842 data->gc = gc; |
5556 | 3843 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3844 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3845 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3846 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3847 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3848 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3849 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3850 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3851 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3852 g_free(dialog_msg); |
3853 } | |
3141 | 3854 } break; |
3855 | |
4173 | 3856 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3857 if (i >= 1) { |
7023 | 3858 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
|
3859 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3860 dialog_msg); |
4076 | 3861 g_free(dialog_msg); |
3862 } | |
3141 | 3863 } break; |
3864 | |
4173 | 3865 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3866 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
|
3867 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3868 dialog_msg); |
3141 | 3869 g_free(dialog_msg); |
3870 } break; | |
3871 | |
4333 | 3872 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3873 if (i >= 5) { | |
3874 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
|
3875 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3876 g_free(dialog_msg); |
3877 } | |
3878 } break; | |
3879 | |
4173 | 3880 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3881 if (i >= 6) { |
4194 | 3882 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
|
3883 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3884 g_free(dialog_msg); |
3885 } | |
4075 | 3886 } break; |
3887 | |
4173 | 3888 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3889 if (i >= 6) { |
4308 | 3890 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
|
3891 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3892 g_free(dialog_msg); |
3893 } | |
4075 | 3894 } break; |
3895 | |
4173 | 3896 case 0x12: { |
3141 | 3897 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3898 /* Someone added you to their buddy list? */ |
3141 | 3899 } break; |
3900 | |
7023 | 3901 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3902 guint i, num; |
3453 | 3903 gchar **text; |
4173 | 3904 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3905 if (text) { |
3906 num = 0; | |
3907 for (i=0; i<strlen(text[0]); i++) | |
3908 num = num*10 + text[0][i]-48; | |
3909 for (i=0; i<num; i++) { | |
4230 | 3910 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3911 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 | 3912 data->gc = gc; |
4790 | 3913 data->name = g_strdup(text[i*2+1]); |
3914 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3915 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3916 gaim_request_action(gc, NULL, message, |
7023 | 3917 _("Do you want to add this buddy " |
3918 "to your buddy list?"), | |
9972 | 3919 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3920 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3921 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3922 g_free(message); |
3923 } | |
3924 g_strfreev(text); | |
3925 } | |
3926 } break; | |
3927 | |
7023 | 3928 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3929 /* This is boring and silly. */ |
3930 } break; | |
3931 | |
3141 | 3932 default: { |
8660 | 3933 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3934 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3935 "(type 0x%02hhx).\n", args->type); |
3141 | 3936 } break; |
3937 } | |
3938 | |
4076 | 3939 g_strfreev(msg1); |
3940 g_strfreev(msg2); | |
3941 | |
3141 | 3942 return 1; |
3943 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3944 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3945 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3946 fu16_t channel; |
3947 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3948 aim_userinfo_t *userinfo; |
2086 | 3949 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3950 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3951 va_start(ap, fr); |
4200 | 3952 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3953 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3954 |
3141 | 3955 switch (channel) { |
3956 case 1: { /* standard message */ | |
3957 struct aim_incomingim_ch1_args *args; | |
3958 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3959 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3960 } break; | |
3961 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3962 case 2: { /* rendezvous */ |
3141 | 3963 struct aim_incomingim_ch2_args *args; |
3964 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3965 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3966 } break; | |
3967 | |
3968 case 4: { /* ICQ */ | |
3969 struct aim_incomingim_ch4_args *args; | |
3970 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3971 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3972 } break; |
3973 | |
3974 default: { | |
8660 | 3975 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3976 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3977 "0x%04hx).", channel); |
3141 | 3978 } break; |
2086 | 3979 } |
3980 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3981 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3982 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3983 return ret; |
2086 | 3984 } |
3985 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3986 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3987 GaimConnection *gc = sess->aux_data; |
3988 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3989 char *buf; |
2086 | 3990 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3991 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3992 aim_userinfo_t *userinfo; |
2086 | 3993 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3994 va_start(ap, fr); |
4200 | 3995 chan = (fu16_t)va_arg(ap, unsigned int); |
3996 userinfo = va_arg(ap, aim_userinfo_t *); | |
3997 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3998 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3999 va_end(ap); |
4000 | |
4001 switch(reason) { | |
5420 | 4002 case 0: /* Invalid (0) */ |
4003 buf = g_strdup_printf( | |
4004 ngettext( | |
4276 | 4005 "You missed %hu message from %s because it was invalid.", |
4006 "You missed %hu messages from %s because they were invalid.", | |
4007 nummissed), | |
4282 | 4008 nummissed, |
4009 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4010 break; |
5420 | 4011 case 1: /* Message too large */ |
4012 buf = g_strdup_printf( | |
4013 ngettext( | |
4276 | 4014 "You missed %hu message from %s because it was too large.", |
4015 "You missed %hu messages from %s because they were too large.", | |
4016 nummissed), | |
4282 | 4017 nummissed, |
4018 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4019 break; |
5420 | 4020 case 2: /* Rate exceeded */ |
4021 buf = g_strdup_printf( | |
4022 ngettext( | |
4276 | 4023 "You missed %hu message from %s because the rate limit has been exceeded.", |
4024 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
4025 nummissed), | |
4282 | 4026 nummissed, |
4027 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4028 break; |
5420 | 4029 case 3: /* Evil Sender */ |
4030 buf = g_strdup_printf( | |
4031 ngettext( | |
4276 | 4032 "You missed %hu message from %s because he/she was too evil.", |
4033 "You missed %hu messages from %s because he/she was too evil.", | |
4034 nummissed), | |
4282 | 4035 nummissed, |
4036 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4037 break; |
5420 | 4038 case 4: /* Evil Receiver */ |
4039 buf = g_strdup_printf( | |
4040 ngettext( | |
4276 | 4041 "You missed %hu message from %s because you are too evil.", |
4042 "You missed %hu messages from %s because you are too evil.", | |
4043 nummissed), | |
4282 | 4044 nummissed, |
4045 userinfo->sn); | |
2086 | 4046 break; |
4047 default: | |
5420 | 4048 buf = g_strdup_printf( |
4049 ngettext( | |
4276 | 4050 "You missed %hu message from %s for an unknown reason.", |
4051 "You missed %hu messages from %s for an unknown reason.", | |
4052 nummissed), | |
4282 | 4053 nummissed, |
4054 userinfo->sn); | |
2086 | 4055 break; |
4056 } | |
8733 | 4057 |
9627 | 4058 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4059 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4060 g_free(buf); |
2086 | 4061 |
4062 return 1; | |
4063 } | |
4064 | |
4194 | 4065 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 4066 GaimConnection *gc = sess->aux_data; |
7283 | 4067 OscarData *od = gc->proto_data; |
4617 | 4068 |
4069 /* BBB */ | |
3630 | 4070 switch (reason) { |
4151 | 4071 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4072 GaimXfer *xfer; |
8971 | 4073 struct oscar_direct_im *dim; |
4074 | |
8660 | 4075 gaim_debug_info("oscar", |
9070 | 4076 "AAA - Other user declined some sort of direct " |
8971 | 4077 "connect attempt (automaticly?)\n"); |
4617 | 4078 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
|
4079 gaim_xfer_cancel_remote(xfer); |
8971 | 4080 else if ((dim = oscar_direct_im_find(od, who))) { |
4081 /* AAA should use find by cookie or something here */ | |
4082 oscar_direct_im_disconnect(od, dim); | |
4083 } | |
4151 | 4084 } break; |
4085 | |
4086 default: { | |
8660 | 4087 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4088 "Received an unknown rendezvous client auto-response " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4089 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4090 } |
3630 | 4091 |
4092 } | |
4093 | |
4094 return 0; | |
4095 } | |
4096 | |
4194 | 4097 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4098 GaimConnection *gc = sess->aux_data; |
4151 | 4099 |
4100 switch(reason) { | |
4101 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4102 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4103 | |
4104 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4105 |
4106 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4107 statusmsg = oscar_icqstatus(state); |
4151 | 4108 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4109 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4110 g_free(statusmsg); | |
4151 | 4111 g_strfreev(splitmsg); |
9244 | 4112 |
9797 | 4113 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4114 |
4115 g_free(title); | |
4116 g_free(dialogmsg); | |
4151 | 4117 } break; |
4118 | |
4119 default: { | |
8660 | 4120 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4121 "Received an unknown client auto-response from %s. " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4122 "Type 0x%04hx\n", who, reason); |
4151 | 4123 } break; |
4124 } /* end of switch */ | |
4125 | |
4126 return 0; | |
4127 } | |
4128 | |
3212 | 4129 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4130 va_list ap; | |
4131 fu16_t chan, reason; | |
4132 char *who; | |
4133 | |
4134 va_start(ap, fr); | |
4200 | 4135 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4136 who = va_arg(ap, char *); |
4200 | 4137 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4138 |
3952 | 4139 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4140 char *cookie = va_arg(ap, char *); |
4151 | 4141 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4142 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4143 fu32_t state = 0; |
4151 | 4144 char *msg = NULL; |
4145 if (reason == 0x0003) { | |
4200 | 4146 state = va_arg(ap, fu32_t); |
4151 | 4147 msg = va_arg(ap, char *); |
4148 } | |
4149 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4150 } | |
3952 | 4151 |
3212 | 4152 va_end(ap); |
4153 | |
4154 return 1; | |
4155 } | |
4156 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4157 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4158 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4159 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4160 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4161 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4162 va_start(ap, fr); |
4199 | 4163 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4164 va_end(ap); |
4165 | |
8660 | 4166 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4167 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4168 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4169 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4170 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4171 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4172 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4173 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4174 |
2086 | 4175 return 1; |
4176 } | |
4177 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4178 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4179 GaimConnection *gc = sess->aux_data; |
4617 | 4180 #if 0 |
7283 | 4181 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4182 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4183 #endif |
4617 | 4184 va_list ap; |
4185 fu16_t reason; | |
4186 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4187 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4188 va_start(ap, fr); |
4617 | 4189 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4190 data = va_arg(ap, char *); |
2086 | 4191 va_end(ap); |
4192 | |
8660 | 4193 gaim_debug_error("oscar", |
10130 | 4194 "Message error with data %s and reason %hu\n", |
4195 (data != NULL ? data : ""), reason); | |
4617 | 4196 |
4197 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4198 #if 0 |
4617 | 4199 /* If this was a file transfer request, data is a cookie */ |
4200 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
|
4201 gaim_xfer_cancel_remote(xfer); |
3630 | 4202 return 1; |
4203 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4204 #endif |
3630 | 4205 |
4617 | 4206 /* Data is assumed to be the destination sn */ |
9826 | 4207 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4208 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4209 g_free(buf); | |
4210 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4211 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4212 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4213 } | |
4214 g_free(buf); | |
4215 | |
2086 | 4216 return 1; |
4217 } | |
4218 | |
3595 | 4219 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4220 GaimConnection *gc = sess->aux_data; |
3595 | 4221 va_list ap; |
4222 fu16_t type1, type2; | |
4223 char *sn; | |
4224 | |
4225 va_start(ap, fr); | |
4199 | 4226 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4227 sn = va_arg(ap, char *); |
4199 | 4228 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4229 va_end(ap); |
4230 | |
4231 switch (type2) { | |
4232 case 0x0000: { /* Text has been cleared */ | |
4233 serv_got_typing_stopped(gc, sn); | |
4234 } break; | |
4235 | |
4236 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4237 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4238 } break; |
4239 | |
4240 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4241 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4242 } break; |
4243 | |
4244 default: { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4245 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 | 4246 } break; |
4247 } | |
4248 | |
4249 return 1; | |
4250 } | |
4251 | |
7141 | 4252 /* |
4253 * We get this error when there was an error in the locate family. This | |
7259 | 4254 * happens when you request info of someone who is offline. |
7141 | 4255 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4256 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4257 gchar *buf; |
2086 | 4258 va_list ap; |
5420 | 4259 fu16_t reason; |
2086 | 4260 char *destn; |
4261 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4262 va_start(ap, fr); |
4199 | 4263 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4264 destn = va_arg(ap, char *); |
4265 va_end(ap); | |
4266 | |
7781 | 4267 if (destn == NULL) |
7793 | 4268 return 1; |
10560 | 4269 |
9826 | 4270 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4271 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4272 g_free(buf); | |
9627 | 4273 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4274 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4275 } | |
4276 g_free(buf); | |
2086 | 4277 |
4278 return 1; | |
4279 } | |
4280 | |
7011 | 4281 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4282 GaimConnection *gc = sess->aux_data; |
8700 | 4283 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 4284 OscarData *od = gc->proto_data; |
8700 | 4285 GString *str; |
9244 | 4286 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4287 va_list ap; |
7011 | 4288 aim_userinfo_t *userinfo; |
2086 | 4289 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4290 va_start(ap, fr); |
7011 | 4291 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4292 va_end(ap); |
4293 | |
8700 | 4294 str = g_string_new(""); |
4295 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4296 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4297 |
10116 | 4298 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 4299 time_t t = userinfo->onlinesince - od->timeoffset; |
10116 | 4300 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); |
4301 } | |
4302 | |
4303 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 4304 time_t t = userinfo->membersince - od->timeoffset; |
10116 | 4305 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); |
4306 } | |
7011 | 4307 |
4308 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4309 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4310 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4311 g_free(tmp); |
4312 } | |
4313 | |
8701 | 4314 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4315 |
4316 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4317 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4318 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4319 g_free(tmp); | |
7011 | 4320 if (away_utf8 != NULL) { |
8700 | 4321 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4322 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4323 } |
7011 | 4324 } |
4325 | |
4326 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4327 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4328 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4329 g_free(tmp); | |
7011 | 4330 if (info_utf8 != NULL) { |
8700 | 4331 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4332 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4333 } |
7011 | 4334 } |
4335 | |
8701 | 4336 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4337 g_string_free(str, TRUE); |
9244 | 4338 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4339 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4340 g_free(title); |
8700 | 4341 g_free(tmp); |
4151 | 4342 |
2086 | 4343 return 1; |
4344 } | |
4345 | |
8341 | 4346 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4347 { | |
4348 aim_session_t *sess = data; | |
4349 GaimConnection *gc = sess->aux_data; | |
4350 OscarData *od = (OscarData *)gc->proto_data; | |
4351 | |
4352 aim_locate_dorequest(data); | |
4353 od->getinfotimer = 0; | |
4354 | |
4355 return FALSE; | |
4356 } | |
4357 | |
4358 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4359 { | |
4360 GaimConnection *gc = sess->aux_data; | |
4361 OscarData *od = (OscarData *)gc->proto_data; | |
4362 | |
4363 /* | |
4364 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4365 * us from hitting the rate limit due to request away messages and info | |
4366 * too quickly. | |
4367 */ | |
4368 if (od->getinfotimer == 0) | |
10198 | 4369 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4370 |
4371 return 1; | |
4372 } | |
4373 | |
4374 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4375 { | |
2086 | 4376 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4377 fu16_t id; |
2086 | 4378 va_list ap; |
4379 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4380 va_start(ap, fr); |
4199 | 4381 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4382 msg = va_arg(ap, char *); |
4383 va_end(ap); | |
4384 | |
8660 | 4385 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4386 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4387 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4388 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4389 _("Your AIM connection may be lost."), NULL); |
2086 | 4390 |
4391 return 1; | |
4392 } | |
4393 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4394 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4395 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4396 fu16_t type; |
5575 | 4397 GaimConnection *gc = sess->aux_data; |
7283 | 4398 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4399 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4400 va_start(ap, fr); |
4199 | 4401 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4402 |
4403 switch(type) { | |
4404 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4405 fu8_t maxrooms; |
2086 | 4406 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4407 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4408 |
4199 | 4409 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4410 exchangecount = va_arg(ap, int); |
4411 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4412 | |
8660 | 4413 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4414 "chat info: Chat Rights:\n"); |
8660 | 4415 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4416 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4417 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4418 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4419 for (i = 0; i < exchangecount; i++) |
8660 | 4420 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4421 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4422 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4423 while (od->create_rooms) { |
4424 struct create_room *cr = od->create_rooms->data; | |
8660 | 4425 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4426 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4427 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4428 g_free(cr->name); |
4617 | 4429 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4430 g_free(cr); |
2086 | 4431 } |
4432 } | |
4433 break; | |
4434 case 0x0008: { | |
4435 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4436 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4437 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4438 fu32_t createtime; |
2086 | 4439 |
4440 fqcn = va_arg(ap, char *); | |
4200 | 4441 instance = (fu16_t)va_arg(ap, unsigned int); |
4442 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4443 flags = (fu16_t)va_arg(ap, unsigned int); | |
4444 createtime = va_arg(ap, fu32_t); | |
4445 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4446 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4447 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4448 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4449 name = va_arg(ap, char *); | |
4450 ck = va_arg(ap, char *); | |
4194 | 4451 |
8660 | 4452 gaim_debug_misc("oscar", |
5556 | 4453 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4454 fqcn, |
4455 exchange, instance, flags, | |
4456 createtime, | |
4457 maxmsglen, maxoccupancy, createperms, unknown, | |
4458 name, ck); | |
4617 | 4459 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4460 } |
4461 break; | |
4462 default: | |
8660 | 4463 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4464 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4465 break; |
4466 } | |
4194 | 4467 |
4468 va_end(ap); | |
4469 | |
2086 | 4470 return 1; |
4471 } | |
4472 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4473 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4474 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4475 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4476 aim_userinfo_t *info; |
5575 | 4477 GaimConnection *g = sess->aux_data; |
2086 | 4478 |
4479 struct chat_connection *c = NULL; | |
4480 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4481 va_start(ap, fr); |
2086 | 4482 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4483 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4484 va_end(ap); |
4485 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4486 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4487 if (!c) |
4488 return 1; | |
4489 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4490 for (i = 0; i < count; i++) |
9846 | 4491 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4492 |
4493 return 1; | |
4494 } | |
4495 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4496 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4497 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4498 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4499 aim_userinfo_t *info; |
5575 | 4500 GaimConnection *g = sess->aux_data; |
2086 | 4501 |
4502 struct chat_connection *c = NULL; | |
4503 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4504 va_start(ap, fr); |
2086 | 4505 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4506 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4507 va_end(ap); |
4508 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4509 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4510 if (!c) |
4511 return 1; | |
4512 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4513 for (i = 0; i < count; i++) |
8733 | 4514 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4515 |
4516 return 1; | |
4517 } | |
4518 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4519 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
|
4520 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4521 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4522 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4523 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4524 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4525 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4526 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4527 fu32_t creationtime; |
5575 | 4528 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4529 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
|
4530 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4531 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4532 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4533 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4534 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4535 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4536 roomdesc = va_arg(ap, char *); |
4200 | 4537 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4538 creationtime = va_arg(ap, fu32_t); | |
4539 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4540 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4541 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4542 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4543 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4544 |
8660 | 4545 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4546 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4547 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4548 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4549 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4550 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4551 |
2086 | 4552 return 1; |
4553 } | |
4554 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4555 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4556 GaimConnection *gc = sess->aux_data; |
8225 | 4557 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4558 gchar *utf8; | |
2086 | 4559 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4560 aim_userinfo_t *info; |
8225 | 4561 int len; |
2086 | 4562 char *msg; |
8219 | 4563 char *charset; |
2086 | 4564 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4565 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4566 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4567 len = va_arg(ap, int); |
4194 | 4568 msg = va_arg(ap, char *); |
8219 | 4569 charset = va_arg(ap, char *); |
4194 | 4570 va_end(ap); |
2086 | 4571 |
8225 | 4572 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4573 if (utf8 == NULL) |
4574 /* The conversion failed! */ | |
8668 | 4575 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4576 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4577 g_free(utf8); | |
2086 | 4578 |
4579 return 1; | |
4580 } | |
4581 | |
3694 | 4582 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4583 va_list ap; | |
5575 | 4584 GaimConnection *gc = sess->aux_data; |
3694 | 4585 struct aim_emailinfo *emailinfo; |
3725 | 4586 int havenewmail; |
7297 | 4587 char *alertitle, *alerturl; |
3694 | 4588 |
4589 va_start(ap, fr); | |
4590 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4591 havenewmail = va_arg(ap, int); |
7301 | 4592 alertitle = va_arg(ap, char *); |
4593 alerturl = va_arg(ap, char *); | |
3694 | 4594 va_end(ap); |
4595 | |
9661 | 4596 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4597 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4598 emailinfo->domain ? "@" : "", | |
4599 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4600 if (emailinfo->unread && havenewmail) |
4601 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4602 g_free(to); |
3694 | 4603 } |
10157 | 4604 |
7301 | 4605 if (alertitle) |
8660 | 4606 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4607 |
4608 return 1; | |
4609 } | |
4610 | |
4804 | 4611 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4612 GaimConnection *gc = sess->aux_data; |
7283 | 4613 OscarData *od = gc->proto_data; |
4804 | 4614 char *sn; |
4615 | |
4616 sn = od->requesticon->data; | |
8660 | 4617 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4618 "removing %s from hash table\n", sn); |
4804 | 4619 od->requesticon = g_slist_remove(od->requesticon, sn); |
4620 free(sn); | |
4621 | |
4622 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4623 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4624 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4625 |
4626 return 1; | |
4627 } | |
4628 | |
4629 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4630 GaimConnection *gc = sess->aux_data; |
7283 | 4631 OscarData *od = gc->proto_data; |
4804 | 4632 GSList *cur; |
4633 va_list ap; | |
4634 char *sn; | |
11024 | 4635 fu8_t iconcsumtype, *iconcsum, *icon; |
4853 | 4636 fu16_t iconcsumlen, iconlen; |
4804 | 4637 |
4638 va_start(ap, fr); | |
4639 sn = va_arg(ap, char *); | |
11024 | 4640 iconcsumtype = va_arg(ap, int); |
4853 | 4641 iconcsum = va_arg(ap, fu8_t *); |
4642 iconcsumlen = va_arg(ap, int); | |
4804 | 4643 icon = va_arg(ap, fu8_t *); |
4644 iconlen = va_arg(ap, int); | |
4645 va_end(ap); | |
4646 | |
11024 | 4647 /* |
4648 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
4649 * no icon is set. Ignore these. | |
4650 */ | |
4651 if ((iconlen > 0) && (iconlen != 90)) { | |
4853 | 4652 char *b16; |
6695 | 4653 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4654 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4655 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4656 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4657 if (b16) { |
7693 | 4658 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4659 g_free(b16); |
5129 | 4660 } |
4853 | 4661 } |
4804 | 4662 |
4663 cur = od->requesticon; | |
4664 while (cur) { | |
4665 char *cursn = cur->data; | |
4666 if (!aim_sncmp(cursn, sn)) { | |
4667 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4668 free(cursn); | |
4669 cur = od->requesticon; | |
4670 } else | |
4671 cur = cur->next; | |
4672 } | |
4673 | |
4674 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4675 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4676 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4677 |
4678 return 1; | |
4679 } | |
4680 | |
4681 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4682 GaimConnection *gc = data; |
7283 | 4683 OscarData *od = gc->proto_data; |
7011 | 4684 aim_userinfo_t *userinfo; |
4804 | 4685 aim_conn_t *conn; |
4686 | |
4687 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4688 if (!conn) { |
4689 if (!od->iconconnecting) { | |
4690 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4691 od->iconconnecting = TRUE; | |
4692 } | |
4804 | 4693 return FALSE; |
4694 } | |
4695 | |
5842 | 4696 if (od->set_icon) { |
6039 | 4697 struct stat st; |
4698 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4699 if (iconfile == NULL) { | |
8363 | 4700 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4701 } else if (!g_stat(iconfile, &st)) { |
6039 | 4702 char *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4703 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 4704 if (file) { |
9532 | 4705 /* XXX - Use g_file_get_contents()? */ |
6039 | 4706 fread(buf, 1, st.st_size, file); |
4707 fclose(file); | |
8660 | 4708 gaim_debug_info("oscar", |
6039 | 4709 "Uploading icon to icon server\n"); |
6879 | 4710 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4711 } else |
8660 | 4712 gaim_debug_error("oscar", |
6039 | 4713 "Can't open buddy icon file!\n"); |
4714 g_free(buf); | |
4715 } else { | |
8660 | 4716 gaim_debug_error("oscar", |
6039 | 4717 "Can't stat buddy icon file!\n"); |
5842 | 4718 } |
4719 od->set_icon = FALSE; | |
4720 } | |
4721 | |
4722 if (!od->requesticon) { | |
8660 | 4723 gaim_debug_misc("oscar", |
5842 | 4724 "no more icons to request\n"); |
4725 return FALSE; | |
4726 } | |
4727 | |
7045 | 4728 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4729 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
11024 | 4730 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
4804 | 4731 return FALSE; |
4732 } else { | |
4733 char *sn = od->requesticon->data; | |
4734 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4735 free(sn); | |
4736 } | |
4737 | |
4738 return TRUE; | |
4739 } | |
4740 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4741 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4742 * 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
|
4743 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4744 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4745 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4746 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4747 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4748 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4749 va_start(ap, fr); |
4199 | 4750 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4751 sn = va_arg(ap, char *); |
4752 va_end(ap); | |
4753 | |
8660 | 4754 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4755 |
4756 return 1; | |
4757 } | |
4758 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4759 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
|
4760 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4761 "invalid", |
4194 | 4762 "change", |
4763 "warning", | |
4764 "limit", | |
4765 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4766 }; |
2086 | 4767 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4768 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4769 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4770 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4771 va_start(ap, fr); |
4200 | 4772 code = (fu16_t)va_arg(ap, unsigned int); |
4773 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4774 windowsize = va_arg(ap, fu32_t); | |
4775 clear = va_arg(ap, fu32_t); | |
4776 alert = va_arg(ap, fu32_t); | |
4777 limit = va_arg(ap, fu32_t); | |
4778 disconnect = va_arg(ap, fu32_t); | |
4779 currentavg = va_arg(ap, fu32_t); | |
4780 maxavg = va_arg(ap, fu32_t); | |
2086 | 4781 va_end(ap); |
4782 | |
8660 | 4783 gaim_debug_misc("oscar", |
5556 | 4784 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4785 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4786 (code < 5) ? codes[code] : codes[0], |
4787 rateclass, | |
4788 currentavg, maxavg, | |
4789 alert, clear, | |
4790 limit, disconnect, | |
4791 windowsize); | |
4792 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4793 /* XXX fix these values */ |
2086 | 4794 if (code == AIM_RATE_CODE_CHANGE) { |
4795 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4796 aim_conn_setlatency(fr->conn, 0); |
2086 | 4797 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4798 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4799 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4800 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4801 _("The last action you attempted could not be " |
4802 "performed because you are over the rate limit. " | |
4803 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4804 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4805 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4806 aim_conn_setlatency(fr->conn, 0); |
2086 | 4807 } |
4808 | |
4809 return 1; | |
4810 } | |
4811 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4812 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4813 GaimConnection *gc = sess->aux_data; |
4814 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4815 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4816 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4817 aim_userinfo_t *userinfo; |
2086 | 4818 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4819 va_start(ap, fr); |
4199 | 4820 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4821 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4822 va_end(ap); |
4823 | |
9982 | 4824 /* XXX - What's with the + 0.5? */ |
4825 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4826 |
4827 return 1; | |
4828 } | |
4829 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4830 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4831 GaimConnection *gc = sess->aux_data; |
4832 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4833 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4834 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4835 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4836 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4837 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4838 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4839 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4840 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4841 |
9982 | 4842 warning_level = info->warnlevel/10.0 + 0.5; |
4843 | |
10152 | 4844 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4845 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4846 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4847 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4848 |
4649 | 4849 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4850 GaimConnection *gc = sess->aux_data; |
7283 | 4851 OscarData *od = gc->proto_data; |
4649 | 4852 va_list ap; |
4853 fu16_t code; | |
4854 char *msg; | |
4855 | |
4856 va_start(ap, fr); | |
4857 code = (fu16_t)va_arg(ap, int); | |
4858 msg = va_arg(ap, char *); | |
4859 va_end(ap); | |
4860 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4861 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
10458 | 4862 code, (msg != NULL ? msg : "")); |
4863 | |
4864 g_return_val_if_fail(fr != NULL, 1); | |
4865 g_return_val_if_fail(fr->conn != NULL, 1); | |
4866 | |
4867 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 4868 if (code == 0x0001) { |
6113 | 4869 gc->wants_to_die = TRUE; |
10715 | 4870 gaim_connection_error(gc, _("You have signed on from another location.")); |
4651 | 4871 } else { |
5579 | 4872 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4873 } |
4666 | 4874 od->killme = TRUE; |
10458 | 4875 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
4876 struct chat_connection *cc; | |
4877 GaimConversation *conv; | |
4878 | |
4879 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
4880 conv = gaim_find_chat(gc, cc->id); | |
4881 | |
4882 if (conv != NULL) | |
4883 { | |
4884 gchar *buf; | |
4885 buf = g_strdup_printf(_("You have been disconnected from chat " | |
4886 "room %s."), cc->name); | |
4887 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
4888 g_free(buf); | |
4889 } | |
4890 oscar_chat_kill(gc, cc); | |
4649 | 4891 } |
4892 | |
4893 return 1; | |
4894 } | |
4895 | |
2675 | 4896 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4897 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4898 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4899 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4900 |
8660 | 4901 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4902 aim_ssi_reqrights(sess); |
6350 | 4903 aim_ssi_reqdata(sess); |
4230 | 4904 |
7011 | 4905 aim_locate_reqrights(sess); |
7285 | 4906 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4907 aim_im_reqparams(sess); |
7334 | 4908 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4909 |
7283 | 4910 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4911 | |
2086 | 4912 return 1; |
4913 } | |
4914 | |
2675 | 4915 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4916 GaimConnection *gc = sess->aux_data; |
7283 | 4917 OscarData *od = gc->proto_data; |
2647 | 4918 |
6905 | 4919 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4920 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4921 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4922 | |
2672 | 4923 aim_clientready(sess, fr->conn); |
8660 | 4924 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4925 |
2647 | 4926 if (od->chpass) { |
8660 | 4927 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4928 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4929 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4930 od->oldp = NULL; |
2647 | 4931 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4932 od->newp = NULL; |
2647 | 4933 od->chpass = FALSE; |
4934 } | |
2979 | 4935 if (od->setnick) { |
8660 | 4936 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4937 aim_admin_setnick(sess, fr->conn, od->newsn); |
4938 g_free(od->newsn); | |
4939 od->newsn = NULL; | |
4940 od->setnick = FALSE; | |
4941 } | |
2647 | 4942 if (od->conf) { |
8660 | 4943 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4944 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4945 od->conf = FALSE; |
4946 } | |
4947 if (od->reqemail) { | |
8660 | 4948 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4949 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4950 od->reqemail = FALSE; |
4951 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4952 if (od->setemail) { |
8660 | 4953 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4954 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4955 g_free(od->email); |
5497 | 4956 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4957 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4958 } |
2647 | 4959 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4960 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4961 } |
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 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
|
4964 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4965 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4966 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4967 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4968 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4969 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4970 |
4194 | 4971 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4972 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4973 "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
|
4974 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4975 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4976 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4977 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4978 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4979 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4980 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4981 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4982 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4983 |
4617 | 4984 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4985 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4986 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4987 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4988 |
2993 | 4989 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4990 { | |
5575 | 4991 GaimConnection *gc = sess->aux_data; |
7283 | 4992 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4993 va_list ap; |
4994 fu16_t maxsiglen; | |
2993 | 4995 |
4996 va_start(ap, fr); | |
4199 | 4997 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4998 va_end(ap); |
4999 | |
8660 | 5000 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5001 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 5002 |
4617 | 5003 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
5004 | |
5005 if (od->icq) | |
7334 | 5006 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 5007 else |
7334 | 5008 aim_locate_setcaps(od->sess, caps_aim); |
5009 oscar_set_info(gc, gc->account->user_info); | |
2993 | 5010 |
5011 return 1; | |
5012 } | |
5013 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5014 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
|
5015 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5016 fu16_t maxbuddies, maxwatchers; |
5575 | 5017 GaimConnection *gc = sess->aux_data; |
7283 | 5018 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5019 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5020 va_start(ap, fr); |
4199 | 5021 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5022 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5023 va_end(ap); |
5024 | |
8660 | 5025 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5026 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5027 |
4617 | 5028 od->rights.maxbuddies = (guint)maxbuddies; |
5029 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5030 |
2086 | 5031 return 1; |
5032 } | |
5033 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5034 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5035 GaimConnection *gc = sess->aux_data; |
7283 | 5036 OscarData *od = (OscarData *)gc->proto_data; |
10570 | 5037 GaimAccount *account = gaim_connection_get_account(gc); |
7334 | 5038 va_list ap; |
5039 fu16_t maxpermits, maxdenies; | |
2086 | 5040 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5041 va_start(ap, fr); |
4199 | 5042 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5043 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5044 va_end(ap); |
5045 | |
8660 | 5046 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5047 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5048 |
4617 | 5049 od->rights.maxpermits = (guint)maxpermits; |
5050 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5051 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5052 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5053 |
8660 | 5054 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5055 |
2672 | 5056 aim_clientready(sess, fr->conn); |
5948 | 5057 aim_srv_setavailmsg(sess, NULL); |
7474 | 5058 aim_srv_setidle(sess, 0); |
4617 | 5059 |
4664 | 5060 if (od->icq) { |
5061 aim_icq_reqofflinemsgs(sess); | |
10570 | 5062 aim_icq_setsecurity(sess, |
5063 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
5064 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE), | |
5065 gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP)); | |
4664 | 5066 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5067 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5068 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5069 if (sess->authinfo->email) |
5070 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5071 |
5072 return 1; | |
5073 } | |
5074 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5075 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
|
5076 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5077 struct aim_icq_offlinemsg *msg; |
4075 | 5078 struct aim_incomingim_ch4_args args; |
5079 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5080 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5081 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5082 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5083 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5084 |
8660 | 5085 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5086 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5087 args.uin = msg->sender; |
5088 args.type = msg->type; | |
4173 | 5089 args.flags = msg->flags; |
4076 | 5090 args.msglen = msg->msglen; |
4075 | 5091 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5092 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5093 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5094 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5095 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5096 } |
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 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
|
5099 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5100 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5101 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5102 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5103 |
7388 | 5104 #if 0 |
5105 /* | |
7465 | 5106 * Update, 2003-11-09: |
5107 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5108 * | |
7388 | 5109 * It may not be my place to do this, but... |
5110 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5111 * stupid, and should not exist for % switches (%x in our case) that request | |
5112 * a year in the preferred representation for the current locale. For that | |
5113 * reason I've chosen to not use this workaround (n., see kluge). | |
5114 * | |
5115 * I have a date. I want to show it to the user in the "preferred" way. | |
5116 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5117 * what the locale wanted. | |
5118 * | |
5119 * If I have a necessity for a full representation of the year in the current | |
5120 * locale, then I'll use a switch that returns a full representation of the | |
5121 * year. | |
5122 * | |
5123 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5124 * (because you're anal, or whatever), then change the f***ing locale. | |
5125 * | |
5126 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5127 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5128 * |
5129 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5130 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5131 */ |
5132 | |
5133 /* | |
5134 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5135 * "last 2 digits" warning. |
5136 */ | |
10157 | 5137 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5138 const struct tm *tm) |
5139 { | |
5140 return strftime(s, max, fmt, tm); | |
5141 } | |
10636 | 5142 |
5143 /* | |
5144 * Before even realizing this was here, I went and did the same thing in util.c. | |
5145 * | |
5146 * Use gaim_strftime() | |
5147 */ | |
5148 | |
7388 | 5149 #endif |
7386 | 5150 |
4624 | 5151 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
|
5152 { |
5575 | 5153 GaimConnection *gc = sess->aux_data; |
8670 | 5154 OscarData *od = (OscarData *)gc->proto_data; |
5155 GaimBuddy *buddy; | |
8853 | 5156 struct buddyinfo *bi = NULL; |
4624 | 5157 gchar who[16]; |
8670 | 5158 GString *str; |
5159 gchar *primary, *utf8; | |
9634 | 5160 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5161 va_list ap; |
4151 | 5162 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5163 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5164 va_start(ap, fr); |
4151 | 5165 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5166 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5167 |
4664 | 5168 if (!info->uin) |
5169 return 0; | |
5170 | |
8670 | 5171 str = g_string_sized_new(100); |
5556 | 5172 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5173 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5174 if (buddy != NULL) | |
5175 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5176 | |
5177 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5178 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5179 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5180 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5181 (bi->ipaddr & 0xff000000) >> 24, | |
5182 (bi->ipaddr & 0x00ff0000) >> 16, | |
5183 (bi->ipaddr & 0x0000ff00) >> 8, | |
5184 (bi->ipaddr & 0x000000ff)); | |
8701 | 5185 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5186 g_free(tstr); |
5187 } | |
8701 | 5188 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5189 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5190 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5191 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5192 g_free(utf8); | |
4625 | 5193 } |
5194 if (info->numaddresses && info->email2) { | |
5195 int i; | |
5196 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5197 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
10683 | 5198 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 5199 g_free(utf8); |
4643 | 5200 } |
4625 | 5201 } |
4624 | 5202 } |
8701 | 5203 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5204 if (info->gender != 0) |
5205 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5206 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5207 char date[30]; |
5208 struct tm tm; | |
5209 tm.tm_mday = (int)info->birthday; | |
5210 tm.tm_mon = (int)info->birthmonth-1; | |
5211 tm.tm_year = (int)info->birthyear-1900; | |
10636 | 5212 gaim_strftime(date, sizeof(date), "%x", &tm); |
8701 | 5213 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5214 } |
4624 | 5215 if (info->age) { |
5216 char age[5]; | |
5217 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5218 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5219 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5220 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5221 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5222 g_free(utf8); | |
4819 | 5223 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5224 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5225 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5226 g_free(utf8); | |
5227 } | |
10683 | 5228 g_string_append_printf(str, "<hr>"); |
4641 | 5229 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5230 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5231 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5232 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5233 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5234 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
10683 | 5235 g_string_append_printf(str, "\n<hr>"); |
4151 | 5236 } |
4641 | 5237 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5238 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5239 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5240 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5241 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5242 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
10683 | 5243 g_string_append_printf(str, "\n<hr>"); |
4624 | 5244 } |
4641 | 5245 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5246 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5247 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5248 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5249 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5250 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5251 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5252 g_free(utf8); | |
4624 | 5253 } |
10683 | 5254 g_string_append_printf(str, "\n<hr>"); |
8670 | 5255 } |
5256 | |
9634 | 5257 if (buddy != NULL) |
5258 alias = gaim_buddy_get_alias(buddy); | |
5259 else | |
5260 alias = who; | |
5261 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5262 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5263 g_free(primary); |
8670 | 5264 g_string_free(str, TRUE); |
4151 | 5265 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5266 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5267 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5268 |
4759 | 5269 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5270 { | |
5575 | 5271 GaimConnection *gc = sess->aux_data; |
4820 | 5272 gchar who[16], *utf8; |
6695 | 5273 GaimBuddy *b; |
4759 | 5274 va_list ap; |
5275 struct aim_icq_info *info; | |
5276 | |
5277 va_start(ap, fr); | |
5278 info = va_arg(ap, struct aim_icq_info *); | |
5279 va_end(ap); | |
5280 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5281 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5282 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5283 serv_got_alias(gc, who, utf8); |
4759 | 5284 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5285 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5286 } |
4820 | 5287 g_free(utf8); |
4759 | 5288 } |
5289 | |
5290 return 1; | |
5291 } | |
5292 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5293 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
|
5294 { |
7032 | 5295 GaimConnection *gc = sess->aux_data; |
5296 gchar *text; | |
5297 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5298 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5299 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5300 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5301 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5302 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5303 url = va_arg(ap, char *); |
4199 | 5304 wid = (fu16_t) va_arg(ap, int); |
5305 hei = (fu16_t) va_arg(ap, int); | |
5306 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5307 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5308 |
7032 | 5309 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5310 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5311 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5312 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5313 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5314 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5315 |
7032 | 5316 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5317 { | |
6873 | 5318 GaimConnection *gc = sess->aux_data; |
5319 gchar *secondary; | |
10439 | 5320 gchar **screennames; |
6873 | 5321 int i, num; |
2086 | 5322 va_list ap; |
6873 | 5323 char *email, *SNs; |
2086 | 5324 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5325 va_start(ap, fr); |
6873 | 5326 email = va_arg(ap, char *); |
2086 | 5327 num = va_arg(ap, int); |
5328 SNs = va_arg(ap, char *); | |
5329 va_end(ap); | |
5330 | |
10439 | 5331 /* TODO: Need to use ngettext() here */ |
8152 | 5332 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5333 |
5334 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5335 for (i = 0; i < num; i++) |
10439 | 5336 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5337 screennames[num] = NULL; | |
5338 | |
5339 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5340 (const char **)screennames, NULL, NULL); | |
6873 | 5341 |
5342 g_free(secondary); | |
10439 | 5343 g_strfreev(screennames); |
2086 | 5344 |
5345 return 1; | |
5346 } | |
5347 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5348 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5349 va_list ap; |
6873 | 5350 char *email; |
5420 | 5351 char *buf; |
2086 | 5352 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5353 va_start(ap, fr); |
6873 | 5354 email = va_arg(ap, char *); |
2086 | 5355 va_end(ap); |
5356 | |
6873 | 5357 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
|
5358 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5359 g_free(buf); |
2086 | 5360 |
5361 return 1; | |
5362 } | |
5363 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5364 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5365 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5366 fu16_t status; |
2086 | 5367 va_list ap; |
5368 char msg[256]; | |
5369 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5370 va_start(ap, fr); |
4199 | 5371 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5372 va_end(ap); |
5373 | |
8660 | 5374 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5375 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5376 status ? "unknown" : "email sent"); |
5377 if (!status) { | |
5302 | 5378 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5379 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5380 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5381 } |
5382 | |
5383 return 1; | |
5384 } | |
5385 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5386 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5387 GaimConnection *gc = sess->aux_data; |
2086 | 5388 va_list ap; |
3912 | 5389 fu16_t perms, err; |
5390 char *url, *sn, *email; | |
5391 int change; | |
2086 | 5392 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5393 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5394 change = va_arg(ap, int); |
4199 | 5395 perms = (fu16_t) va_arg(ap, unsigned int); |
5396 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5397 url = va_arg(ap, char *); |
5398 sn = va_arg(ap, char *); | |
5399 email = va_arg(ap, char *); | |
2086 | 5400 va_end(ap); |
5401 | |
8660 | 5402 gaim_debug_misc("oscar", |
9626 | 5403 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5404 change ? "change" : "request", perms, err, | |
5405 (url != NULL) ? url : "(null)", | |
5406 (sn != NULL) ? sn : "(null)", | |
5407 (email != NULL) ? email : "(null)"); | |
5408 | |
5409 if ((err > 0) && (url != NULL)) { | |
3912 | 5410 char *dialog_msg; |
5411 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5412 switch (err) { | |
5413 case 0x0001: { | |
5414 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5415 } break; | |
5416 case 0x0006: { | |
5417 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5418 } break; | |
5419 case 0x000b: { | |
5420 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5421 } break; | |
5422 case 0x001d: { | |
5423 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); | |
5424 } break; | |
5425 case 0x0021: { | |
5426 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); | |
5427 } break; | |
5428 case 0x0023: { | |
5429 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5430 } break; | |
5431 default: { | |
5432 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5433 } break; | |
5434 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5435 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5436 g_free(dialog_top); |
5437 g_free(dialog_msg); | |
5438 return 1; | |
5439 } | |
5440 | |
9626 | 5441 if (sn != NULL) { |
4585 | 5442 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
|
5443 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5444 g_free(dialog_msg); |
5445 } | |
5446 | |
9626 | 5447 if (email != NULL) { |
5575 | 5448 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5449 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5450 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5451 g_free(dialog_msg); |
2086 | 5452 } |
5453 | |
5454 return 1; | |
5455 } | |
5456 | |
5575 | 5457 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5458 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5459 aim_flap_nop(od->sess, od->conn); |
2086 | 5460 } |
5461 | |
6059 | 5462 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5463 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5464 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5465 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5466 if (typing == GAIM_TYPING) |
4870 | 5467 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5468 else if (typing == GAIM_TYPED) |
4870 | 5469 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5470 else | |
5471 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5472 else { |
5300 | 5473 /* Don't send if this turkey is in our deny list */ |
5474 GSList *list; | |
5475 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5476 if (!list) { | |
7261 | 5477 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5478 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5479 if (typing == GAIM_TYPING) |
5300 | 5480 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5481 else if (typing == GAIM_TYPED) |
5300 | 5482 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5483 else | |
5484 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5485 } | |
3595 | 5486 } |
5487 } | |
2993 | 5488 return 0; |
5489 } | |
9030 | 5490 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5491 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
|
5492 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5493 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5494 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5495 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5496 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
|
5497 int ret = 0; |
10246 | 5498 const char *iconfile = gaim_account_get_buddy_icon(account); |
10781 | 5499 char *tmpmsg = NULL; |
3458 | 5500 |
4838 | 5501 if (dim && dim->connected) { |
5502 /* If we're directly connected, send a direct IM */ | |
6982 | 5503 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5504 } else { |
4738 | 5505 struct buddyinfo *bi; |
3008 | 5506 struct aim_sendimext_args args; |
5507 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5508 gsize len; |
10246 | 5509 GaimConversation *conv; |
5510 | |
5511 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5512 |
5513 if (strstr(message, "<IMG ")) | |
5514 gaim_conversation_write(conv, "", | |
5515 _("Your IM Image was not sent. " | |
5516 "You must be Direct Connected to send IM Images."), | |
5517 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5518 |
10246 | 5519 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5520 if (!bi) { |
5521 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5522 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5523 } |
5524 | |
3008 | 5525 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5526 if (od->icq) { |
5527 args.features = features_icq; | |
5528 args.featureslen = sizeof(features_icq); | |
3008 | 5529 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5530 } else { |
5531 args.features = features_aim; | |
5532 args.featureslen = sizeof(features_aim); | |
4972 | 5533 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5534 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5535 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5536 } |
4269 | 5537 |
4738 | 5538 if (bi->ico_need) { |
8660 | 5539 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5540 "Sending buddy icon request with message\n"); |
3008 | 5541 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5542 bi->ico_need = FALSE; |
3008 | 5543 } |
4269 | 5544 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5545 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5546 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 5547 if (file) { |
5548 char *buf = g_malloc(st.st_size); | |
9532 | 5549 /* XXX - Use g_file_get_contents()? */ |
3008 | 5550 fread(buf, 1, st.st_size, file); |
6039 | 5551 fclose(file); |
4269 | 5552 |
3008 | 5553 args.iconlen = st.st_size; |
4617 | 5554 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5555 args.iconstamp = st.st_mtime; |
5556 | |
7406 | 5557 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5558 bi->ico_informed = FALSE; |
7406 | 5559 bi->ico_sent = FALSE; |
5560 } | |
4738 | 5561 |
5562 if (!bi->ico_informed) { | |
8660 | 5563 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5564 "Claiming to have a buddy icon\n"); |
4738 | 5565 args.flags |= AIM_IMFLAGS_HASICON; |
5566 bi->ico_me_len = args.iconlen; | |
5567 bi->ico_me_csum = args.iconsum; | |
5568 bi->ico_me_time = args.iconstamp; | |
5569 bi->ico_informed = TRUE; | |
5570 } | |
5571 | |
3008 | 5572 g_free(buf); |
2086 | 5573 } |
5574 } | |
4269 | 5575 |
3008 | 5576 args.destsn = name; |
4269 | 5577 |
8985 | 5578 /* |
10781 | 5579 * If we're IMing an ICQ user from an ICQ account, then strip HTML |
5580 * and use \r\n as the newline character. | |
8985 | 5581 */ |
10781 | 5582 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
5583 if (aim_sn_is_icq(name)) | |
5584 /* From ICQ to ICQ */ | |
8995 | 5585 tmpmsg = g_strdup(message); |
10781 | 5586 else |
5587 /* From ICQ to AIM */ | |
5588 tmpmsg = g_markup_escape_text(message, -1); | |
8995 | 5589 } else { |
10785 | 5590 /* From AIM to AIM and AIM to ICQ */ |
5591 tmpmsg = g_strdup(message); | |
8995 | 5592 } |
6310 | 5593 len = strlen(tmpmsg); |
5594 | |
9830 | 5595 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5596 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5597 args.charset, args.charsubset, args.msglen); | |
4617 | 5598 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5599 g_free((char *)args.msg); |
2086 | 5600 } |
4838 | 5601 |
6310 | 5602 g_free(tmpmsg); |
5603 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5604 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5605 return 1; |
6310 | 5606 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5607 return ret; |
2086 | 5608 } |
5609 | |
7011 | 5610 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5611 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5612 |
9975 | 5613 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5614 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5615 else |
7235 | 5616 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5617 } |
5618 | |
8950 | 5619 #if 0 |
7011 | 5620 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5621 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5622 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5623 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5624 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5625 maiden, NULL, NULL, city, state, NULL, 0, web); |
5626 } | |
8950 | 5627 #endif |
2086 | 5628 |
5575 | 5629 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5630 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5631 aim_srv_setidle(od->sess, time); |
2086 | 5632 } |
5633 | |
5954 | 5634 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5635 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5636 int charset = 0; |
6019 | 5637 char *text_html = NULL; |
5129 | 5638 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5639 gsize msglen = 0; |
2993 | 5640 |
4617 | 5641 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5642 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5643 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5644 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5645 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5646 "again when you are fully connected.")); |
4617 | 5647 |
7334 | 5648 if (!text) { |
5649 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5650 return; | |
5651 } | |
10097 | 5652 |
7334 | 5653 text_html = gaim_strdup_withhtml(text); |
9807 | 5654 charset = oscar_charset_check(text_html); |
9826 | 5655 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5656 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5657 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5658 g_free(msg); | |
9826 | 5659 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5660 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5661 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5662 g_free(msg); | |
5663 } else { | |
5664 msglen = strlen(text_html); | |
5665 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5666 } | |
5667 | |
5668 if (msglen > od->rights.maxsiglen) { | |
5669 gchar *errstr; | |
5670 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
|
5671 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5672 "The maximum profile length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5673 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5674 od->rights.maxsiglen), od->rights.maxsiglen); |
5675 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5676 g_free(errstr); | |
5677 } | |
5678 | |
5679 g_free(text_html); | |
2086 | 5680 } |
5681 | |
9991 | 5682 static void |
5683 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5684 { |
9991 | 5685 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5686 OscarData *od = NULL; |
9992 | 5687 GaimStatusType *status_type; |
9991 | 5688 GaimStatusPrimitive primitive; |
5689 GaimPresence *presence; | |
5690 const gchar *status_id; | |
9807 | 5691 int charset = 0; |
10196 | 5692 const gchar *text_html = NULL; |
5129 | 5693 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5694 gsize msglen = 0; |
2993 | 5695 |
9992 | 5696 status_type = gaim_status_get_type(status); |
5697 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5698 status_id = gaim_status_get_id(status); |
5699 presence = gaim_account_get_presence(account); | |
5700 | |
10400 | 5701 if (gc) |
5702 od = (OscarData *)gc->proto_data; | |
10401 | 5703 |
5704 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { | |
9991 | 5705 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5706 _("You have probably requested to set your " |
5707 "away message before the login procedure " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5708 "completed. You remain in a \"present\" " |
10400 | 5709 "state; try setting it again when you are " |
5710 "fully connected.")); | |
10401 | 5711 return; |
5712 } | |
5129 | 5713 |
9992 | 5714 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5715 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5716 | |
7334 | 5717 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5718 |
5719 text_html = gaim_status_get_attr_string(status, "message"); | |
5720 if (text_html != NULL) { | |
5721 aim_srv_setavailmsg(od->sess, text_html); | |
5722 } | |
10196 | 5723 |
5724 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5725 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5726 | |
10196 | 5727 text_html = gaim_status_get_attr_string(status, "message"); |
5728 | |
5729 if (text_html == NULL) { | |
5730 text_html = _("Away"); | |
5731 } | |
5732 | |
5733 charset = oscar_charset_check(text_html); | |
5734 if (charset == AIM_CHARSET_UNICODE) { | |
5735 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5736 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5737 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5738 g_free(msg); | |
5739 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5740 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5741 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5742 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5743 g_free(msg); | |
5744 } else { | |
5745 msglen = strlen(text_html); | |
5746 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5747 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5748 } | |
5749 | |
5750 if (msglen > od->rights.maxawaymsglen) { | |
5751 gchar *errstr; | |
5752 | |
5753 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
|
5754 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5755 "The maximum away message length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5756 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5757 od->rights.maxawaymsglen), od->rights.maxawaymsglen); |
5758 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5759 g_free(errstr); | |
5760 } | |
5761 | |
10197 | 5762 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5763 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5764 | |
5129 | 5765 } else { |
10196 | 5766 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5767 | |
5768 } | |
2993 | 5769 } |
5770 | |
9991 | 5771 static void |
5772 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5773 { |
9991 | 5774 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 5775 OscarData *od = NULL; |
9991 | 5776 const gchar *status_id = gaim_status_get_id(status); |
5777 | |
10646 | 5778 if (gc) |
5779 od = (OscarData *)gc->proto_data; | |
5780 if (!od) | |
5781 return; | |
5782 | |
9991 | 5783 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) |
5575 | 5784 account->perm_deny = 4; |
8265 | 5785 else |
5575 | 5786 account->perm_deny = 3; |
9991 | 5787 |
8265 | 5788 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5789 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5790 |
9991 | 5791 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5792 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5793 |
5794 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5795 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5796 |
5797 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5798 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5799 |
5800 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5801 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5802 |
5803 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5804 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5805 |
5806 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5807 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5808 |
5809 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5810 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5811 |
5812 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5813 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5814 } |
5815 | |
9991 | 5816 static void |
5817 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5818 { |
10747 | 5819 gboolean connected = gaim_account_is_connected(account); |
10400 | 5820 GaimStatusType *type = gaim_status_get_type(status); |
5821 int primitive = gaim_status_type_get_primitive(type); | |
5822 | |
10747 | 5823 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
5824 | |
10498 | 5825 if (!gaim_status_is_active(status)) |
10485 | 5826 return; |
5827 | |
10753 | 5828 if (primitive != GAIM_STATUS_OFFLINE && !connected) { |
10738 | 5829 gaim_account_connect(account); |
10747 | 5830 } else if (primitive == GAIM_STATUS_OFFLINE && connected) { |
10400 | 5831 gaim_account_disconnect(account); |
5832 } else { | |
10747 | 5833 if (!connected) |
5834 return; | |
10400 | 5835 |
5836 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
5837 oscar_set_status_icq(account, status); | |
5838 else | |
10560 | 5839 /* QQQ - Should probably also set this for ICQ */ |
10400 | 5840 oscar_set_status_aim(account, status); |
5841 } | |
2086 | 5842 } |
5843 | |
9991 | 5844 static void |
5845 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5846 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5847 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5848 } |
5849 | |
10747 | 5850 static void |
5851 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5852 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5853 |
5854 if (!aim_snvalid(buddy->name)) { | |
8092 | 5855 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5856 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 | 5857 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5858 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5859 g_free(buf); |
8150 | 5860 |
5861 /* Remove from local list */ | |
9285 | 5862 gaim_blist_remove_buddy(buddy); |
8150 | 5863 |
8092 | 5864 return; |
5865 } | |
5866 | |
9285 | 5867 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5868 if (buddy && group) { | |
8660 | 5869 gaim_debug_info("oscar", |
9285 | 5870 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5871 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5872 } |
5873 } | |
8150 | 5874 |
10157 | 5875 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5876 if (od->icq) |
9285 | 5877 aim_icq_getalias(od->sess, buddy->name); |
5878 } | |
5879 | |
5880 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 5881 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5882 |
4230 | 5883 if (od->sess->ssi.received_data) { |
8660 | 5884 gaim_debug_info("oscar", |
9285 | 5885 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5886 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5887 } |
10866 | 5888 } |
5889 | |
5575 | 5890 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5891 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5892 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5893 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5894 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5895 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5896 } |
5897 } | |
5898 | |
5575 | 5899 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5900 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5901 if (od->sess->ssi.received_data) { |
5902 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5903 if (gname) { | |
8660 | 5904 gaim_debug_info("oscar", |
9586 | 5905 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5906 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5907 } |
5908 } | |
5909 } | |
5910 | |
11005 | 5911 /* |
5912 * FYI, the OSCAR SSI code removes empty groups automatically. | |
5913 */ | |
9285 | 5914 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5915 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5916 |
5917 if (od->sess->ssi.received_data) { | |
9285 | 5918 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5919 GList *cur, *groups = NULL; | |
5920 | |
5921 /* Make a list of what the groups each buddy is in */ | |
5922 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5923 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
5924 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
5925 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
5926 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
5927 node->parent->parent); |
9285 | 5928 } |
5929 | |
10866 | 5930 serv_remove_buddies(gc, moved_buddies, groups); |
5931 serv_add_buddies(gc, moved_buddies); | |
9285 | 5932 g_list_free(groups); |
8660 | 5933 gaim_debug_info("oscar", |
9285 | 5934 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5935 } else { |
9285 | 5936 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5937 gaim_debug_info("oscar", |
9285 | 5938 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5939 } |
5940 } | |
5941 } | |
5942 | |
5968 | 5943 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5944 aim_session_t *sess = data; | |
6350 | 5945 aim_ssi_reqdata(sess); |
5968 | 5946 return FALSE; |
5947 } | |
5948 | |
4642 | 5949 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5950 GaimConnection *gc = sess->aux_data; |
7283 | 5951 OscarData *od = gc->proto_data; |
4642 | 5952 va_list ap; |
5953 fu16_t reason; | |
5954 | |
5955 va_start(ap, fr); | |
5956 reason = (fu16_t)va_arg(ap, unsigned int); | |
5957 va_end(ap); | |
5958 | |
8660 | 5959 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5960 |
5961 if (reason == 0x0005) { | |
5892 | 5962 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5963 _("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
|
5964 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5965 } |
5966 | |
5967 /* Activate SSI */ | |
5968 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5969 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5970 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5971 aim_ssi_enable(od->sess); |
5972 | |
5973 return 1; | |
5974 } | |
5975 | |
2991 | 5976 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5977 GaimConnection *gc = sess->aux_data; |
7283 | 5978 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 5979 int i; |
5980 va_list ap; | |
5981 int numtypes; | |
4230 | 5982 fu16_t *maxitems; |
2991 | 5983 |
5984 va_start(ap, fr); | |
4230 | 5985 numtypes = va_arg(ap, int); |
5986 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5987 va_end(ap); |
5988 | |
8660 | 5989 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5990 |
4230 | 5991 for (i=0; i<numtypes; i++) |
8660 | 5992 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5993 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5994 |
8660 | 5995 gaim_debug_misc(NULL, "\n"); |
4230 | 5996 |
5997 if (numtypes >= 0) | |
5998 od->rights.maxbuddies = maxitems[0]; | |
5999 if (numtypes >= 1) | |
6000 od->rights.maxgroups = maxitems[1]; | |
6001 if (numtypes >= 2) | |
6002 od->rights.maxpermits = maxitems[2]; | |
6003 if (numtypes >= 3) | |
6004 od->rights.maxdenies = maxitems[3]; | |
2991 | 6005 |
6006 return 1; | |
6007 } | |
6008 | |
6009 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6010 GaimConnection *gc = sess->aux_data; |
6011 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6012 GaimStatus *status; |
7283 | 6013 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6014 GaimGroup *g; |
6015 GaimBuddy *b; | |
2995 | 6016 struct aim_ssi_item *curitem; |
2991 | 6017 int tmp; |
4230 | 6018 va_list ap; |
8219 | 6019 fu16_t fmtver, numitems; |
6020 struct aim_ssi_item *items; | |
6021 fu32_t timestamp; | |
4230 | 6022 |
6023 va_start(ap, fr); | |
6024 fmtver = (fu16_t)va_arg(ap, int); | |
6025 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6026 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6027 timestamp = va_arg(ap, fu32_t); |
8219 | 6028 va_end(ap); |
2991 | 6029 |
8660 | 6030 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6031 "ssi: syncing local list and server list\n"); |
2991 | 6032 |
8219 | 6033 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6034 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 | 6035 return 1; |
6036 } | |
6037 | |
2991 | 6038 /* Clean the buddy list */ |
4889 | 6039 aim_ssi_cleanlist(sess); |
2991 | 6040 |
8150 | 6041 { /* If not in server list then prune from local list */ |
6042 GaimBlistNode *gnode, *cnode, *bnode; | |
6043 GaimBuddyList *blist; | |
9539 | 6044 GSList *cur, *next; |
8150 | 6045 |
6046 /* Buddies */ | |
6047 cur = NULL; | |
6048 if ((blist = gaim_get_blist()) != NULL) { | |
6049 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6050 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6051 continue; | |
6052 g = (GaimGroup *)gnode; | |
6053 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6054 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6055 continue; | |
6056 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6057 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6058 continue; | |
6059 b = (GaimBuddy *)bnode; | |
6060 if (b->account == gc->account) { | |
6061 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6062 /* If the buddy is an ICQ user then load his nickname */ | |
6063 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6064 char *alias; |
8150 | 6065 if (servernick) |
6066 serv_got_alias(gc, b->name, servernick); | |
6067 | |
6068 /* Store local alias on server */ | |
8214 | 6069 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6070 if (!alias && b->alias && strlen(b->alias)) |
6071 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6072 free(alias); | |
6073 } else { | |
8660 | 6074 gaim_debug_info("oscar", |
8150 | 6075 "ssi: removing buddy %s from local list\n", b->name); |
6076 /* We can't actually remove now because it will screw up our looping */ | |
6077 cur = g_slist_prepend(cur, b); | |
6078 } | |
6079 } | |
6080 } | |
6081 } | |
6082 } | |
6083 } | |
8175 | 6084 |
8150 | 6085 while (cur != NULL) { |
6086 b = cur->data; | |
6087 cur = g_slist_remove(cur, b); | |
6088 gaim_blist_remove_buddy(b); | |
6089 } | |
6090 | |
6091 /* Permit list */ | |
6092 if (gc->account->permit) { | |
9539 | 6093 next = gc->account->permit; |
6094 while (next != NULL) { | |
6095 cur = next; | |
6096 next = next->next; | |
8150 | 6097 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6098 gaim_debug_info("oscar", |
8150 | 6099 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6100 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6101 } | |
9539 | 6102 } |
8150 | 6103 } |
6104 | |
6105 /* Deny list */ | |
6106 if (gc->account->deny) { | |
9539 | 6107 next = gc->account->deny; |
6108 while (next != NULL) { | |
6109 cur = next; | |
6110 next = next->next; | |
8150 | 6111 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6112 gaim_debug_info("oscar", |
8150 | 6113 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6114 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6115 } | |
9539 | 6116 } |
8150 | 6117 } |
6118 /* Presence settings (idle time visibility) */ | |
6119 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6120 if (!(tmp & 0x400)) | |
6121 aim_ssi_setpresence(sess, tmp | 0x400); | |
6122 } /* end pruning buddies from local list */ | |
6123 | |
2991 | 6124 /* Add from server list to local list */ |
4230 | 6125 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6126 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6127 switch (curitem->type) { |
4230 | 6128 case 0x0000: { /* Buddy */ |
4251 | 6129 if (curitem->name) { |
4292 | 6130 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6131 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6132 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6133 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6134 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6135 /* Should gname be freed here? -- elb */ |
4754 | 6136 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6137 free(alias); |
8150 | 6138 if (b) { |
4292 | 6139 /* Get server stored alias */ |
4705 | 6140 if (alias_utf8) { |
8150 | 6141 g_free(b->alias); |
6142 b->alias = g_strdup(alias_utf8); | |
4705 | 6143 } |
4282 | 6144 } else { |
8150 | 6145 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6146 |
4754 | 6147 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6148 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6149 gaim_blist_add_group(g, NULL); |
6150 } | |
5146 | 6151 |
8660 | 6152 gaim_debug_info("oscar", |
9285 | 6153 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6154 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6155 } |
8341 | 6156 if (!aim_sncmp(curitem->name, account->username)) { |
6157 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6158 gaim_check_comment(od, comment); | |
6159 free(comment); | |
6160 } | |
7162 | 6161 g_free(gname_utf8); |
6162 g_free(alias_utf8); | |
2991 | 6163 } |
4230 | 6164 } break; |
6165 | |
6166 case 0x0001: { /* Group */ | |
4282 | 6167 /* Shouldn't add empty groups */ |
4230 | 6168 } break; |
6169 | |
6170 case 0x0002: { /* Permit buddy */ | |
2991 | 6171 if (curitem->name) { |
4230 | 6172 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6173 GSList *list; |
5575 | 6174 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6175 if (!list) { |
8660 | 6176 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6177 "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
|
6178 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6179 } |
6180 } | |
4230 | 6181 } break; |
6182 | |
6183 case 0x0003: { /* Deny buddy */ | |
2991 | 6184 if (curitem->name) { |
6185 GSList *list; | |
5575 | 6186 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6187 if (!list) { |
8660 | 6188 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6189 "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
|
6190 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6191 } |
6192 } | |
4230 | 6193 } break; |
6194 | |
6195 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6196 if (curitem->data) { |
6197 fu8_t permdeny; | |
5575 | 6198 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6199 gaim_debug_info("oscar", |
5575 | 6200 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6201 account->perm_deny = permdeny; | |
6202 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6203 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6204 } |
2991 | 6205 } |
6206 } | |
4230 | 6207 } break; |
6208 | |
6209 case 0x0005: { /* Presence setting */ | |
3109 | 6210 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6211 } break; |
2991 | 6212 } /* End of switch on curitem->type */ |
6213 } /* End of for loop */ | |
4230 | 6214 |
9991 | 6215 /* |
6216 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6217 * this. We probably want the SSI status setting to override the local | |
6218 * setting. | |
6219 */ | |
9982 | 6220 status = gaim_presence_get_active_status(account->presence); |
6221 if (gaim_status_is_available(status)) | |
4901 | 6222 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6223 | |
4342 | 6224 /* Activate SSI */ |
6225 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6226 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6227 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6228 "ssi: activating server-stored buddy list\n"); |
4642 | 6229 aim_ssi_enable(sess); |
4342 | 6230 |
2991 | 6231 return 1; |
2086 | 6232 } |
4230 | 6233 |
6234 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6235 GaimConnection *gc = sess->aux_data; |
4230 | 6236 va_list ap; |
6237 struct aim_ssi_tmp *retval; | |
6238 | |
6239 va_start(ap, fr); | |
6240 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6241 va_end(ap); | |
6242 | |
6243 while (retval) { | |
8660 | 6244 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6245 "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 | 6246 |
6247 if (retval->ack != 0xffff) | |
6248 switch (retval->ack) { | |
6249 case 0x0000: { /* added successfully */ | |
6250 } break; | |
6251 | |
4829 | 6252 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6253 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6254 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 | 6255 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6256 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6257 g_free(buf); |
6258 } | |
6259 | |
7023 | 6260 case 0x000e: { /* buddy requires authorization */ |
4828 | 6261 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6262 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6263 } break; |
6264 | |
6265 default: { /* La la la */ | |
5197 | 6266 gchar *buf; |
8660 | 6267 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
|
6268 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 | 6269 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6270 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6271 g_free(buf); |
4230 | 6272 } break; |
6273 } | |
6274 | |
6275 retval = retval->next; | |
6276 } | |
6277 | |
6278 return 1; | |
6279 } | |
6280 | |
8227 | 6281 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6282 GaimConnection *gc = sess->aux_data; | |
6283 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6284 GaimBuddy *b; | |
6285 GaimGroup *g; | |
6286 va_list ap; | |
6287 fu16_t type; | |
6288 const char *name; | |
6289 | |
6290 va_start(ap, fr); | |
6291 type = (fu16_t)va_arg(ap, int); | |
6292 name = va_arg(ap, char *); | |
6293 va_end(ap); | |
6294 | |
6295 if ((type != 0x0000) || (name == NULL)) | |
6296 return 1; | |
6297 | |
6298 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6299 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6300 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6301 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6302 b = gaim_find_buddy(gc->account, name); | |
6303 free(alias); | |
6304 | |
6305 if (b) { | |
6306 /* Get server stored alias */ | |
6307 if (alias_utf8) { | |
6308 g_free(b->alias); | |
6309 b->alias = g_strdup(alias_utf8); | |
6310 } | |
6311 } else { | |
6312 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6313 | |
6314 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6315 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6316 gaim_blist_add_group(g, NULL); | |
6317 } | |
6318 | |
8660 | 6319 gaim_debug_info("oscar", |
9285 | 6320 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6321 gaim_blist_add_buddy(b, NULL, g, NULL); |
6322 } | |
6323 g_free(gname_utf8); | |
6324 g_free(alias_utf8); | |
6325 | |
6326 return 1; | |
6327 } | |
6328 | |
4230 | 6329 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6330 GaimConnection *gc = sess->aux_data; |
4230 | 6331 va_list ap; |
6332 char *sn, *msg; | |
4236 | 6333 gchar *dialog_msg, *nombre; |
4230 | 6334 struct name_data *data; |
6695 | 6335 GaimBuddy *buddy; |
4230 | 6336 |
6337 va_start(ap, fr); | |
6338 sn = va_arg(ap, char *); | |
6339 msg = va_arg(ap, char *); | |
6340 va_end(ap); | |
6341 | |
8660 | 6342 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6343 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6344 |
4687 | 6345 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6346 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6347 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6348 else |
6349 nombre = g_strdup(sn); | |
6350 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6351 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 | 6352 data = g_new(struct name_data, 1); |
6353 data->gc = gc; | |
6354 data->name = g_strdup(sn); | |
6355 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6356 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6357 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6358 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6359 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6360 G_CALLBACK(oscar_free_name_data)); |
4236 | 6361 |
4230 | 6362 g_free(dialog_msg); |
4236 | 6363 g_free(nombre); |
4230 | 6364 |
6365 return 1; | |
6366 } | |
6367 | |
6368 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6369 GaimConnection *gc = sess->aux_data; |
4230 | 6370 va_list ap; |
6371 char *sn, *msg; | |
4236 | 6372 gchar *dialog_msg, *nombre; |
4230 | 6373 struct name_data *data; |
6695 | 6374 GaimBuddy *buddy; |
4230 | 6375 |
6376 va_start(ap, fr); | |
6377 sn = va_arg(ap, char *); | |
6378 msg = va_arg(ap, char *); | |
6379 va_end(ap); | |
6380 | |
8660 | 6381 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6382 "ssi: received authorization request from %s\n", sn); |
4230 | 6383 |
4687 | 6384 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6385 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6386 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6387 else |
6388 nombre = g_strdup(sn); | |
6389 | |
10949 | 6390 dialog_msg = g_strdup_printf( |
6391 _("The user %s wants to add %s to their buddy list for the following reason:\n%s"), | |
6392 nombre, gaim_account_get_username(gc->account), | |
6393 (msg ? msg : _("No reason given."))); | |
6394 | |
4230 | 6395 data = g_new(struct name_data, 1); |
6396 data->gc = gc; | |
6397 data->name = g_strdup(sn); | |
6398 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6399 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6400 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6401 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6402 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6403 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6404 |
4230 | 6405 g_free(dialog_msg); |
4236 | 6406 g_free(nombre); |
4230 | 6407 |
6408 return 1; | |
6409 } | |
6410 | |
6411 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6412 GaimConnection *gc = sess->aux_data; |
4230 | 6413 va_list ap; |
6414 char *sn, *msg; | |
4236 | 6415 gchar *dialog_msg, *nombre; |
4230 | 6416 fu8_t reply; |
6695 | 6417 GaimBuddy *buddy; |
4230 | 6418 |
6419 va_start(ap, fr); | |
6420 sn = va_arg(ap, char *); | |
6421 reply = (fu8_t)va_arg(ap, int); | |
6422 msg = va_arg(ap, char *); | |
6423 va_end(ap); | |
6424 | |
8660 | 6425 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6426 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6427 |
4687 | 6428 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6429 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6430 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6431 else |
6432 nombre = g_strdup(sn); | |
6433 | |
4230 | 6434 if (reply) { |
6435 /* Granted */ | |
7023 | 6436 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
|
6437 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6438 } else { |
6439 /* Denied */ | |
7023 | 6440 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
|
6441 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6442 } |
6443 g_free(dialog_msg); | |
4236 | 6444 g_free(nombre); |
4230 | 6445 |
6446 return 1; | |
6447 } | |
6448 | |
6449 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6450 GaimConnection *gc = sess->aux_data; |
4230 | 6451 va_list ap; |
6452 char *sn; | |
6695 | 6453 GaimBuddy *buddy; |
4230 | 6454 |
6455 va_start(ap, fr); | |
6456 sn = va_arg(ap, char *); | |
6457 va_end(ap); | |
6458 | |
4687 | 6459 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6460 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6461 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6462 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6463 |
6464 return 1; | |
6465 } | |
2086 | 6466 |
5575 | 6467 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6468 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6469 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6470 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6471 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6472 pce->label = _("_Room:"); |
5234 | 6473 pce->identifier = "room"; |
10475 | 6474 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6475 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6476 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6477 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6478 pce->label = _("_Exchange:"); |
5234 | 6479 pce->identifier = "exchange"; |
10475 | 6480 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6481 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6482 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6483 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6484 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6485 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6486 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6487 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6488 |
9754 | 6489 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6490 { | |
6491 GHashTable *defaults; | |
6492 | |
6493 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6494 | |
6495 if (chat_name != NULL) | |
6496 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6497 | |
6498 return defaults; | |
6499 } | |
6500 | |
9917 | 6501 static char *oscar_get_chat_name(GHashTable *data) { |
6502 return g_strdup(g_hash_table_lookup(data, "room")); | |
6503 } | |
6504 | |
8308 | 6505 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6506 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6507 aim_conn_t *cur; |
5234 | 6508 char *name, *exchange; |
6509 | |
6510 name = g_hash_table_lookup(data, "room"); | |
6511 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6512 |
8660 | 6513 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6514 "Attempting to join chat room %s.\n", name); |
8308 | 6515 |
6516 if ((name == NULL) || (*name == '\0')) { | |
6517 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6518 return; | |
6519 } | |
6520 | |
4617 | 6521 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6522 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6523 "chatnav exists, creating room\n"); |
5234 | 6524 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6525 } else { |
6526 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6527 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6528 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6529 "chatnav does not exist, opening chatnav\n"); |
5234 | 6530 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6531 cr->name = g_strdup(name); |
4617 | 6532 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6533 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6534 } |
6535 } | |
6536 | |
8308 | 6537 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6538 OscarData *od = (OscarData *)gc->proto_data; | |
6539 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6540 |
6541 if (ccon == NULL) | |
2086 | 6542 return; |
10404 | 6543 |
8225 | 6544 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6545 ccon->exchange, ccon->name, 0x0); |
6546 } | |
6547 | |
10458 | 6548 static void |
6549 oscar_chat_leave(GaimConnection *gc, int id) | |
6550 { | |
6551 GaimConversation *conv; | |
6552 struct chat_connection *cc; | |
6553 | |
6554 conv = gaim_find_chat(gc, id); | |
6555 | |
6556 g_return_if_fail(conv != NULL); | |
6557 | |
6558 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6559 | |
6560 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6561 oscar_chat_kill(gc, cc); | |
2086 | 6562 } |
6563 | |
8219 | 6564 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6565 OscarData *od = (OscarData *)gc->proto_data; | |
6566 GaimConversation *conv = NULL; | |
2086 | 6567 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6568 char *buf, *buf2; |
9830 | 6569 fu16_t charset, charsubset; |
9807 | 6570 char *charsetstr = NULL; |
10111 | 6571 int len; |
8219 | 6572 |
6573 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6574 return -EINVAL; |
2086 | 6575 |
8219 | 6576 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6577 return -EINVAL; |
2086 | 6578 |
8219 | 6579 buf = gaim_strdup_withhtml(message); |
6580 len = strlen(buf); | |
6581 | |
8962 | 6582 if (strstr(buf, "<IMG ")) |
6583 gaim_conversation_write(conv, "", | |
6584 _("Your IM Image was not sent. " | |
6585 "You cannot send IM Images in AIM chats."), | |
6586 GAIM_MESSAGE_ERROR, time(NULL)); | |
6587 | |
9830 | 6588 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6589 if ((len > c->maxlen) || (len > c->maxvis)) { |
6590 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6591 return -E2BIG; |
8359 | 6592 } |
6593 | |
9831 | 6594 if (charset == AIM_CHARSET_ASCII) |
6595 charsetstr = "us-ascii"; | |
6596 else if (charset == AIM_CHARSET_UNICODE) | |
6597 charsetstr = "unicode-2-0"; | |
6598 else if (charset == AIM_CHARSET_CUSTOM) | |
6599 charsetstr = "iso-8859-1"; | |
9807 | 6600 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6601 g_free(buf2); |
8359 | 6602 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6603 return 0; |
2086 | 6604 } |
6605 | |
10042 | 6606 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6607 { | |
4766 | 6608 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6609 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6610 return "icq"; |
6611 else | |
6612 return "aim"; | |
6613 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6614 |
9975 | 6615 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6616 return "icq"; |
6617 return "aim"; | |
6618 } | |
6619 | |
9972 | 6620 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6621 { |
7334 | 6622 GaimConnection *gc = NULL; |
6623 OscarData *od = NULL; | |
10042 | 6624 GaimAccount *account = NULL; |
6625 GaimPresence *presence; | |
6626 GaimStatus *status; | |
6627 const char *status_id; | |
4687 | 6628 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6629 int i = 0; | |
7334 | 6630 aim_userinfo_t *userinfo = NULL; |
6631 | |
6632 if (b != NULL) | |
6633 account = b->account; | |
6634 if (account != NULL) | |
6635 gc = account->gc; | |
6636 if (gc != NULL) | |
6637 od = gc->proto_data; | |
7945 | 6638 if (od != NULL) |
6639 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6640 |
10042 | 6641 presence = gaim_buddy_get_presence(b); |
6642 status = gaim_presence_get_active_status(presence); | |
6643 status_id = gaim_status_get_id(status); | |
6644 | |
6645 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6646 char *gname; |
7334 | 6647 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6648 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6649 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6650 emblems[i++] = "notauthorized"; | |
6651 } else { | |
6652 emblems[i++] = "offline"; | |
6653 } | |
6654 } | |
4916 | 6655 |
10042 | 6656 if (b->name && aim_sn_is_icq(b->name)) { |
6657 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6658 emblems[i++] = "invisible"; | |
6659 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6660 emblems[i++] = "freeforchat"; |
10042 | 6661 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6662 emblems[i++] = "dnd"; |
10042 | 6663 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6664 emblems[i++] = "na"; |
10042 | 6665 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6666 emblems[i++] = "occupied"; |
10042 | 6667 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6668 emblems[i++] = "away"; |
10042 | 6669 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6670 emblems[i++] = "away"; | |
6671 } | |
6672 | |
6673 if (userinfo != NULL ) { | |
6674 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6675 emblems[i++] = "unconfirmed"; */ | |
6676 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6677 emblems[i++] = "admin"; | |
6678 if (userinfo->flags & AIM_FLAG_AOL) | |
6679 emblems[i++] = "aol"; | |
6680 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6681 emblems[i++] = "wireless"; | |
6682 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6683 emblems[i++] = "activebuddy"; | |
6684 | |
6685 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6686 emblems[i++] = "hiptop"; |
6687 | |
10042 | 6688 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6689 emblems[i++] = "secure"; |
10042 | 6690 } |
7334 | 6691 |
4687 | 6692 *se = emblems[0]; |
6693 *sw = emblems[1]; | |
6694 *nw = emblems[2]; | |
6695 *ne = emblems[3]; | |
6696 } | |
6697 | |
6695 | 6698 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6699 GaimConnection *gc = b->account->gc; |
7283 | 6700 OscarData *od = gc->proto_data; |
7045 | 6701 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6702 GString *str = g_string_new(""); |
5131 | 6703 |
6704 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6705 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6706 |
6707 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6708 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6709 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6710 g_free(charset); |
7011 | 6711 if (away_utf8 != NULL) { |
7091 | 6712 gchar *tmp1, *tmp2; |
9627 | 6713 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6714 g_free(away_utf8); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
6715 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 6716 g_free(tmp2); |
8700 | 6717 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6718 g_free(tmp1); |
8701 | 6719 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6720 g_free(tmp2); |
5836 | 6721 } |
5131 | 6722 } |
8701 | 6723 } |
6724 | |
6725 return g_string_free(str, FALSE); | |
5131 | 6726 } |
6727 | |
10042 | 6728 static char *oscar_status_text(GaimBuddy *b) |
6729 { | |
6730 GaimConnection *gc; | |
6731 OscarData *od; | |
6732 GaimStatus *status; | |
5167 | 6733 gchar *ret = NULL; |
6734 | |
10042 | 6735 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6736 od = gc->proto_data; | |
6737 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6738 | |
6739 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6740 if (aim_sn_is_icq(b->name)) |
8701 | 6741 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6742 else |
6743 ret = g_strdup(_("Away")); | |
5836 | 6744 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6745 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6746 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6747 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6748 } else { |
5167 | 6749 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6750 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6751 ret = g_strdup(_("Not Authorized")); | |
6752 else | |
6753 ret = g_strdup(_("Offline")); | |
6754 } | |
6755 | |
6756 return ret; | |
6757 } | |
6758 | |
5842 | 6759 |
5844 | 6760 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6761 GaimConnection *gc = sess->aux_data; |
7283 | 6762 OscarData *od = gc->proto_data; |
5892 | 6763 va_list ap; |
5842 | 6764 fu16_t type; |
5892 | 6765 fu8_t flags = 0, length = 0; |
6766 char *md5 = NULL; | |
6767 | |
7334 | 6768 |
5842 | 6769 va_start(ap, fr); |
6770 type = va_arg(ap, int); | |
5892 | 6771 |
6772 switch(type) { | |
6773 case 0x0000: | |
6774 case 0x0001: { | |
6775 flags = va_arg(ap, int); | |
6776 length = va_arg(ap, int); | |
6777 md5 = va_arg(ap, char *); | |
6778 | |
6779 if (flags == 0x41) { | |
6780 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6781 od->iconconnecting = TRUE; | |
6782 od->set_icon = TRUE; | |
6783 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6784 } else { | |
6039 | 6785 struct stat st; |
6786 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6787 if (iconfile == NULL) { | |
8363 | 6788 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6789 } else if (!g_stat(iconfile, &st)) { |
6039 | 6790 char *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6791 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 6792 if (file) { |
9532 | 6793 /* XXX - Use g_file_get_contents()? */ |
6039 | 6794 fread(buf, 1, st.st_size, file); |
6795 fclose(file); | |
8660 | 6796 gaim_debug_info("oscar", |
10042 | 6797 "Uploading icon to icon server\n"); |
6879 | 6798 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6799 } else |
8660 | 6800 gaim_debug_error("oscar", |
10042 | 6801 "Can't open buddy icon file!\n"); |
6039 | 6802 g_free(buf); |
6803 } else { | |
8660 | 6804 gaim_debug_error("oscar", |
10042 | 6805 "Can't stat buddy icon file!\n"); |
5892 | 6806 } |
6807 } | |
8363 | 6808 } else if (flags == 0x81) { |
6809 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6810 if (iconfile == NULL) | |
6811 aim_ssi_delicon(od->sess); | |
6812 else | |
6813 aim_ssi_seticon(od->sess, md5, length); | |
6814 } | |
5892 | 6815 } break; |
6816 | |
6817 case 0x0002: { /* We just set an "available" message? */ | |
6818 } break; | |
6819 } | |
6820 | |
5842 | 6821 va_end(ap); |
5844 | 6822 |
6823 return 0; | |
5842 | 6824 } |
5892 | 6825 |
5575 | 6826 static void oscar_set_permit_deny(GaimConnection *gc) { |
6827 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6828 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 6829 |
8175 | 6830 if (od->sess->ssi.received_data) { |
6831 switch (account->perm_deny) { | |
6832 case GAIM_PRIVACY_ALLOW_ALL: | |
6833 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6834 break; | |
6835 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6836 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6837 break; | |
6838 case GAIM_PRIVACY_ALLOW_USERS: | |
6839 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6840 break; | |
6841 case GAIM_PRIVACY_DENY_ALL: | |
6842 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6843 break; | |
6844 case GAIM_PRIVACY_DENY_USERS: | |
6845 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6846 break; | |
6847 default: | |
6848 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6849 break; | |
6850 } | |
6851 } | |
2086 | 6852 } |
6853 | |
5575 | 6854 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 6855 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6856 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6857 if (od->sess->ssi.received_data) |
4889 | 6858 aim_ssi_addpermit(od->sess, who); |
2086 | 6859 } |
6860 | |
5575 | 6861 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 6862 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6863 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6864 if (od->sess->ssi.received_data) |
4889 | 6865 aim_ssi_adddeny(od->sess, who); |
2086 | 6866 } |
6867 | |
5575 | 6868 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 6869 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6870 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6871 if (od->sess->ssi.received_data) |
4889 | 6872 aim_ssi_delpermit(od->sess, who); |
2086 | 6873 } |
6874 | |
5575 | 6875 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 6876 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6877 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6878 if (od->sess->ssi.received_data) |
4889 | 6879 aim_ssi_deldeny(od->sess, who); |
2086 | 6880 } |
6881 | |
9975 | 6882 static GList * |
6883 oscar_status_types(GaimAccount *account) | |
2086 | 6884 { |
9975 | 6885 GList *status_types = NULL; |
6886 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6887 |
9973 | 6888 g_return_val_if_fail(account != NULL, NULL); |
6889 | |
10042 | 6890 /* Oscar-common status types */ |
9991 | 6891 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
6892 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 6893 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 6894 status_types = g_list_append(status_types, type); |
6895 | |
9991 | 6896 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
6897 OSCAR_STATUS_ID_ONLINE, | |
10400 | 6898 _("Online"), FALSE, TRUE, FALSE); |
9976 | 6899 status_types = g_list_append(status_types, type); |
6900 | |
10198 | 6901 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
6902 OSCAR_STATUS_ID_AVAILABLE, | |
6903 _("Available"), TRUE, TRUE, FALSE, | |
6904 "message", _("Message"), | |
6905 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 6906 status_types = g_list_append(status_types, type); |
6907 | |
10195 | 6908 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
6909 OSCAR_STATUS_ID_AWAY, | |
6910 _("Away"), TRUE, TRUE, FALSE, | |
6911 "message", _("Message"), | |
6912 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 6913 status_types = g_list_append(status_types, type); |
6914 | |
6915 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
6916 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 6917 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 6918 status_types = g_list_append(status_types, type); |
6919 | |
6920 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
6921 return status_types; | |
6922 | |
6923 /* ICQ-specific status types */ | |
6924 | |
9991 | 6925 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6926 OSCAR_STATUS_ID_FREE4CHAT, | |
6927 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 6928 status_types = g_list_append(status_types, type); |
6929 | |
9991 | 6930 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
6931 OSCAR_STATUS_ID_OCCUPIED, | |
6932 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 6933 status_types = g_list_append(status_types, type); |
6934 | |
9991 | 6935 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6936 OSCAR_STATUS_ID_DND, | |
6937 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 6938 status_types = g_list_append(status_types, type); |
6939 | |
9991 | 6940 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6941 OSCAR_STATUS_ID_NA, | |
6942 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 6943 status_types = g_list_append(status_types, type); |
9975 | 6944 |
6945 return status_types; | |
4333 | 6946 } |
6947 | |
7172 | 6948 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6949 GaimConnection *gc = data->gc; |
6950 OscarData *od = gc->proto_data; | |
7172 | 6951 GaimBuddy *b; |
6952 GaimGroup *g; | |
6953 | |
6954 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6955 oscar_free_name_data(data); | |
6956 return; | |
6957 } | |
6958 | |
6959 if (!(g = gaim_find_buddys_group(b))) { | |
6960 oscar_free_name_data(data); | |
6961 return; | |
6962 } | |
6963 | |
6964 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6965 |
6966 if (!aim_sncmp(data->name, gc->account->username)) | |
6967 gaim_check_comment(od, text); | |
6968 | |
7172 | 6969 oscar_free_name_data(data); |
6970 } | |
6971 | |
9030 | 6972 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6973 | |
6974 GaimBuddy *buddy; | |
6975 GaimConnection *gc; | |
6976 OscarData *od; | |
6977 struct name_data *data; | |
7172 | 6978 GaimGroup *g; |
6979 char *comment; | |
6980 gchar *comment_utf8; | |
9631 | 6981 gchar *title; |
7172 | 6982 |
9030 | 6983 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6984 | |
6985 buddy = (GaimBuddy *) node; | |
6986 gc = gaim_account_get_connection(buddy->account); | |
6987 od = gc->proto_data; | |
6988 | |
6989 data = g_new(struct name_data, 1); | |
6990 | |
6991 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6992 return; |
9030 | 6993 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6994 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6995 | |
6996 data->gc = gc; | |
9030 | 6997 data->name = g_strdup(buddy->name); |
7172 | 6998 data->nick = NULL; |
6999 | |
9631 | 7000 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7001 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7002 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7003 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7004 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7005 data); | |
9631 | 7006 g_free(title); |
7172 | 7007 |
7008 free(comment); | |
7009 g_free(comment_utf8); | |
7010 } | |
7011 | |
9030 | 7012 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7013 | |
7014 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7015 OscarData *od = gc->proto_data; |
9030 | 7016 |
4333 | 7017 GList *m = NULL; |
9030 | 7018 GaimBlistNodeAction *act; |
7019 | |
7020 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7021 oscar_buddycb_edit_comment, NULL, NULL); |
9030 | 7022 m = g_list_append(m, act); |
7172 | 7023 |
4333 | 7024 if (od->icq) { |
4624 | 7025 #if 0 |
9030 | 7026 act = gaim_blist_node_action_new(_("Get Status Msg"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7027 oscar_get_icqstatusmsg, NULL, NULL); |
9030 | 7028 m = g_list_append(m, act); |
4624 | 7029 #endif |
4333 | 7030 } else { |
7011 | 7031 aim_userinfo_t *userinfo; |
9030 | 7032 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7033 | |
7034 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7035 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7036 | |
7011 | 7037 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7038 act = gaim_blist_node_action_new(_("Direct IM"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7039 oscar_ask_direct_im, NULL, NULL); |
9030 | 7040 m = g_list_append(m, act); |
5917 | 7041 } |
9466 | 7042 #if 0 |
7011 | 7043 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7044 act = gaim_blist_node_action_new(_("Get File"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7045 oscar_ask_getfile, NULL, NULL); |
9030 | 7046 m = g_list_append(m, act); |
5917 | 7047 } |
4826 | 7048 #endif |
4333 | 7049 } |
5131 | 7050 } |
5197 | 7051 |
5131 | 7052 if (od->sess->ssi.received_data) { |
9030 | 7053 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7054 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7055 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7056 gaim_auth_sendrequest_menu, NULL, NULL); |
9030 | 7057 m = g_list_append(m, act); |
4333 | 7058 } |
4916 | 7059 } |
10157 | 7060 |
4333 | 7061 return m; |
7062 } | |
7063 | |
9030 | 7064 |
7065 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7066 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7067 return oscar_buddy_menu((GaimBuddy *) node); | |
7068 } else { | |
7069 return NULL; | |
7070 } | |
7071 } | |
7072 | |
10570 | 7073 static void |
7074 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
7075 { | |
7076 OscarData *od = gc->proto_data; | |
7077 GaimAccount *account = gaim_connection_get_account(gc); | |
7078 GaimRequestField *f; | |
7079 gboolean auth, hide_ip, web_aware; | |
7080 | |
7081 f = gaim_request_fields_get_field(fields, "authorization"); | |
7082 auth = gaim_request_field_bool_get_value(f); | |
7083 | |
7084 f = gaim_request_fields_get_field(fields, "hide_ip"); | |
7085 hide_ip = gaim_request_field_bool_get_value(f); | |
7086 | |
7087 f = gaim_request_fields_get_field(fields, "web_aware"); | |
7088 web_aware = gaim_request_field_bool_get_value(f); | |
7089 | |
7090 gaim_account_set_bool(account, "authorization", auth); | |
7091 gaim_account_set_bool(account, "hide_ip", hide_ip); | |
7092 gaim_account_set_bool(account, "web_aware", web_aware); | |
7093 | |
7094 aim_icq_setsecurity(od->sess, auth, web_aware, hide_ip); | |
7095 } | |
7096 | |
7097 static void | |
7098 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
7099 { | |
7100 GaimConnection *gc = (GaimConnection *) action->context; | |
7101 GaimAccount *account = gaim_connection_get_account(gc); | |
7102 GaimRequestFields *fields; | |
7103 GaimRequestFieldGroup *g; | |
7104 GaimRequestField *f; | |
7105 gboolean auth, hide_ip, web_aware; | |
7106 | |
7107 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7108 hide_ip = gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7109 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7110 | |
7111 fields = gaim_request_fields_new(); | |
7112 | |
7113 g = gaim_request_field_group_new(NULL); | |
7114 | |
7115 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
7116 gaim_request_field_group_add_field(g, f); | |
7117 | |
7118 f = gaim_request_field_bool_new("hide_ip", _("Hide IP address"), hide_ip); | |
7119 gaim_request_field_group_add_field(g, f); | |
7120 | |
7121 f = gaim_request_field_bool_new("web_aware", _("Web aware"), web_aware); | |
7122 gaim_request_field_group_add_field(g, f); | |
7123 | |
7124 gaim_request_fields_add_group(fields, g); | |
7125 | |
7126 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
7127 NULL, fields, | |
7128 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
7129 _("Cancel"), NULL, gc); | |
7130 } | |
9030 | 7131 |
5575 | 7132 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7133 OscarData *od = gc->proto_data; |
5575 | 7134 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7135 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7136 od->setnick = TRUE; | |
7137 od->newsn = g_strdup(nick); | |
7138 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7139 } else { | |
7140 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7141 } | |
7142 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7143 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7144 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7145 } |
7146 } | |
7147 | |
9015 | 7148 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7149 { |
9015 | 7150 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7151 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7152 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7153 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7154 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7155 gc); |
4333 | 7156 } |
7157 | |
9015 | 7158 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7159 { |
9015 | 7160 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7161 OscarData *od = gc->proto_data; |
4333 | 7162 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7163 | |
7164 if (conn) { | |
7165 aim_admin_reqconfirm(od->sess, conn); | |
7166 } else { | |
7167 od->conf = TRUE; | |
7168 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7169 } | |
7170 } | |
7171 | |
9015 | 7172 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7173 { |
9015 | 7174 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7175 OscarData *od = gc->proto_data; |
4333 | 7176 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7177 | |
7178 if (conn) { | |
7179 aim_admin_getinfo(od->sess, conn, 0x11); | |
7180 } else { | |
7181 od->reqemail = TRUE; | |
7182 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7183 } | |
7184 } | |
7185 | |
5575 | 7186 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7187 { |
7283 | 7188 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7189 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
|
7190 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7191 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7192 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7193 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7194 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7195 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7196 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7197 } |
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 |
9015 | 7200 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7201 { |
9015 | 7202 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7203 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7204 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7205 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7206 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7207 gc); |
4333 | 7208 } |
7209 | |
9015 | 7210 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7211 { |
9015 | 7212 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7213 OscarData *od = gc->proto_data; |
4333 | 7214 gchar *nombre, *text, *tmp; |
6695 | 7215 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7216 int num=0; |
7217 | |
6873 | 7218 text = g_strdup(""); |
4333 | 7219 |
4785 | 7220 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7221 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7222 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7223 continue; | |
6695 | 7224 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7225 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7226 continue; |
6695 | 7227 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7228 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7229 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7230 continue; | |
7231 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7232 if (gaim_buddy_get_alias_only(buddy)) |
7233 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7234 else |
7235 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7236 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7237 g_free(text); |
7238 text = tmp; | |
7239 g_free(nombre); | |
7240 num++; | |
7241 } | |
4333 | 7242 } |
2979 | 7243 } |
4333 | 7244 } |
7245 | |
7246 if (!num) { | |
7247 g_free(text); | |
6873 | 7248 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7249 } | |
7250 | |
7251 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7252 "the following buddies"), _("You can re-request " | |
7253 "authorization from these buddies by " | |
7254 "right-clicking on them and selecting " | |
7255 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7256 g_free(text); |
2979 | 7257 } |
7258 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7259 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7260 { |
8950 | 7261 OscarData *od = (OscarData *)gc->proto_data; |
7262 | |
7263 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7264 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7265 |
9015 | 7266 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7267 { |
9015 | 7268 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7269 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7270 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7271 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7272 "searching for."), |
8697 | 7273 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7274 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7275 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7276 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7277 |
9015 | 7278 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7279 { |
9015 | 7280 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7281 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7282 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7283 |
9015 | 7284 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7285 { |
9015 | 7286 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7287 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7288 } |
7289 | |
9015 | 7290 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7291 { |
9015 | 7292 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7293 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7294 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7295 |
9015 | 7296 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7297 { |
9015 | 7298 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7299 OscarData *od = gc->proto_data; |
5575 | 7300 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
|
7301 gaim_notify_uri(gc, substituted); |
5517 | 7302 g_free(substituted); |
4333 | 7303 } |
7304 | |
9015 | 7305 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7306 { |
9015 | 7307 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7308 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7309 } |
7310 | |
5842 | 7311 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7312 { | |
7283 | 7313 OscarData *od = gc->proto_data; |
5844 | 7314 aim_session_t *sess = od->sess; |
5842 | 7315 FILE *file; |
7316 struct stat st; | |
5844 | 7317 |
6039 | 7318 if (iconfile == NULL) { |
8363 | 7319 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7320 } else if (!g_stat(iconfile, &st)) { |
5842 | 7321 char *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7322 file = g_fopen(iconfile, "rb"); |
5842 | 7323 if (file) { |
6052 | 7324 md5_state_t *state; |
6039 | 7325 char md5[16]; |
9532 | 7326 /* XXX - Use g_file_get_contents()? */ |
5842 | 7327 int len = fread(buf, 1, st.st_size, file); |
6039 | 7328 fclose(file); |
6052 | 7329 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7330 md5_init(state); |
7331 md5_append(state, buf, len); | |
7332 md5_finish(state, md5); | |
7333 g_free(state); | |
7334 aim_ssi_seticon(sess, md5, 16); | |
7335 } else | |
8660 | 7336 gaim_debug_error("oscar", |
5842 | 7337 "Can't open buddy icon file!\n"); |
7338 g_free(buf); | |
7339 } else | |
8660 | 7340 gaim_debug_error("oscar", |
5842 | 7341 "Can't stat buddy icon file!\n"); |
7342 } | |
7343 | |
7344 | |
9015 | 7345 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7346 { |
9015 | 7347 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7348 OscarData *od = gc->proto_data; |
4333 | 7349 GList *m = NULL; |
9015 | 7350 GaimPluginAction *act; |
7351 | |
7352 act = gaim_plugin_action_new(_("Set User Info..."), | |
7353 oscar_show_set_info); | |
7354 m = g_list_append(m, act); | |
4333 | 7355 |
10570 | 7356 if (od->icq) |
7357 { | |
9015 | 7358 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7359 oscar_show_set_info_icqurl); | |
7360 m = g_list_append(m, act); | |
8576 | 7361 } |
7362 | |
9015 | 7363 act = gaim_plugin_action_new(_("Change Password..."), |
7364 oscar_change_pass); | |
7365 m = g_list_append(m, act); | |
4617 | 7366 |
10570 | 7367 if (od->sess->authinfo->chpassurl != NULL) |
7368 { | |
9015 | 7369 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7370 oscar_show_chpassurl); | |
7371 m = g_list_append(m, act); | |
7372 | |
7373 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7374 oscar_show_imforwardingurl); | |
7375 m = g_list_append(m, act); | |
7026 | 7376 } |
7377 | |
10570 | 7378 m = g_list_append(m, NULL); |
7379 | |
7380 if (od->icq) | |
7381 { | |
7382 /* ICQ actions */ | |
7383 act = gaim_plugin_action_new(_("Show privacy options..."), | |
7384 oscar_show_icq_privacy_opts); | |
7385 m = g_list_append(m, act); | |
7386 } | |
7387 else | |
7388 { | |
4617 | 7389 /* AIM actions */ |
9015 | 7390 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7391 oscar_show_format_screenname); | |
7392 m = g_list_append(m, act); | |
7393 | |
7394 act = gaim_plugin_action_new(_("Confirm Account"), | |
7395 oscar_confirm_account); | |
7396 m = g_list_append(m, act); | |
7397 | |
7398 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7399 oscar_show_email); | |
7400 m = g_list_append(m, act); | |
7401 | |
7402 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7403 oscar_show_change_email); | |
7404 m = g_list_append(m, act); | |
2086 | 7405 } |
4333 | 7406 |
7407 m = g_list_append(m, NULL); | |
7408 | |
9015 | 7409 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7410 oscar_show_awaitingauth); | |
7411 m = g_list_append(m, act); | |
4333 | 7412 |
2086 | 7413 m = g_list_append(m, NULL); |
4333 | 7414 |
9015 | 7415 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7416 oscar_show_find_email); | |
7417 m = g_list_append(m, act); | |
4333 | 7418 |
8591 | 7419 #if 0 |
9015 | 7420 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7421 show_find_info); | |
7422 m = g_list_append(m, act); | |
8591 | 7423 #endif |
2086 | 7424 |
7425 return m; | |
7426 } | |
7427 | |
5575 | 7428 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7429 { |
7283 | 7430 OscarData *od = gc->proto_data; |
4617 | 7431 |
7432 if (od->icq) { | |
7433 aim_icq_changepasswd(od->sess, new); | |
2086 | 7434 } else { |
4617 | 7435 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7436 if (conn) { | |
7437 aim_admin_changepasswd(od->sess, conn, new, old); | |
7438 } else { | |
7439 od->chpass = TRUE; | |
7440 od->oldp = g_strdup(old); | |
7441 od->newp = g_strdup(new); | |
7442 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7443 } | |
2086 | 7444 } |
7445 } | |
7446 | |
6059 | 7447 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7448 { |
7283 | 7449 OscarData *od = gc->proto_data; |
8971 | 7450 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
|
7451 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7452 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7453 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7454 |
8971 | 7455 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7456 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7457 |
9935 | 7458 static void |
7459 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7460 { | |
7461 GaimConnection *gc = data; | |
7462 OscarData *od = gc->proto_data; | |
7463 aim_session_t *sess = od->sess; | |
7464 fu32_t presence; | |
7465 | |
7466 presence = aim_ssi_getpresence(sess->ssi.local); | |
7467 | |
7468 if (value) { | |
9992 | 7469 /* Based on the packet capture I thought it was the first one */ |
7470 /* Stu thinks it's the second one. */ | |
7471 /* presence |= 0x00400000; */ | |
9971 | 7472 presence &= ~0x00020000; |
9935 | 7473 aim_ssi_setpresence(sess, presence); |
7474 } else { | |
9992 | 7475 /* presence &= ~0x00400000; */ |
9971 | 7476 presence |= 0x00020000; |
9935 | 7477 aim_ssi_setpresence(sess, presence); |
7478 } | |
7479 } | |
7480 | |
10653 | 7481 #if USE_PRPL_PREFERENCES |
9935 | 7482 static GaimPluginPrefFrame * |
9936 | 7483 get_plugin_pref_frame(GaimPlugin *plugin) |
7484 { | |
9935 | 7485 GaimPluginPrefFrame *frame; |
7486 GaimPluginPref *ppref; | |
7487 | |
7488 frame = gaim_plugin_pref_frame_new(); | |
7489 | |
7490 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7491 gaim_plugin_pref_frame_add(frame, ppref); | |
7492 | |
7493 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7494 gaim_plugin_pref_frame_add(frame, ppref); | |
7495 | |
7496 return frame; | |
7497 } | |
10653 | 7498 #endif |
9935 | 7499 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7500 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7501 { |
9308 | 7502 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7503 NULL, /* user_splits */ |
7504 NULL, /* protocol_options */ | |
10674 | 7505 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
7506 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 7507 oscar_list_icon, /* list_icon */ |
7508 oscar_list_emblems, /* list_emblems */ | |
7509 oscar_status_text, /* status_text */ | |
7510 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7511 oscar_status_types, /* status_types */ |
9475 | 7512 oscar_blist_node_menu, /* blist_node_menu */ |
7513 oscar_chat_info, /* chat_info */ | |
9754 | 7514 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7515 oscar_login, /* login */ |
7516 oscar_close, /* close */ | |
7517 oscar_send_im, /* send_im */ | |
7518 oscar_set_info, /* set_info */ | |
7519 oscar_send_typing, /* send_typing */ | |
7520 oscar_get_info, /* get_info */ | |
9973 | 7521 oscar_set_status, /* set_status */ |
9475 | 7522 oscar_set_idle, /* set_idle */ |
7523 oscar_change_passwd, /* change_passwd */ | |
7524 oscar_add_buddy, /* add_buddy */ | |
10866 | 7525 NULL, /* add_buddies */ |
9475 | 7526 oscar_remove_buddy, /* remove_buddy */ |
10866 | 7527 NULL, /* remove_buddies */ |
9475 | 7528 oscar_add_permit, /* add_permit */ |
7529 oscar_add_deny, /* add_deny */ | |
7530 oscar_rem_permit, /* rem_permit */ | |
7531 oscar_rem_deny, /* rem_deny */ | |
7532 oscar_set_permit_deny, /* set_permit_deny */ | |
7533 oscar_warn, /* warn */ | |
7534 oscar_join_chat, /* join_chat */ | |
7535 NULL, /* reject_chat */ | |
9973 | 7536 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7537 oscar_chat_invite, /* chat_invite */ |
7538 oscar_chat_leave, /* chat_leave */ | |
7539 NULL, /* chat_whisper */ | |
7540 oscar_send_chat, /* chat_send */ | |
7541 oscar_keepalive, /* keepalive */ | |
7542 NULL, /* register_user */ | |
7543 NULL, /* get_cb_info */ | |
7544 NULL, /* get_cb_away */ | |
7545 oscar_alias_buddy, /* alias_buddy */ | |
7546 oscar_move_buddy, /* group_buddy */ | |
7547 oscar_rename_group, /* rename_group */ | |
7548 NULL, /* buddy_free */ | |
7549 oscar_convo_closed, /* convo_closed */ | |
7550 NULL, /* normalize */ | |
7551 oscar_set_icon, /* set_buddy_icon */ | |
7552 NULL, /* remove_group */ | |
7553 NULL, /* get_cb_real_name */ | |
7554 NULL, /* set_chat_topic */ | |
7555 NULL, /* find_blist_chat */ | |
7556 NULL, /* roomlist_get_list */ | |
7557 NULL, /* roomlist_cancel */ | |
7558 NULL, /* roomlist_expand_category */ | |
7559 oscar_can_receive_file, /* can_receive_file */ | |
7560 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7561 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7562 |
10653 | 7563 #if USE_PRPL_PREFERENCES |
9935 | 7564 static GaimPluginUiInfo prefs_info = { |
7565 get_plugin_pref_frame | |
7566 }; | |
10653 | 7567 #endif |
9935 | 7568 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7569 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7570 { |
9943 | 7571 GAIM_PLUGIN_MAGIC, |
7572 GAIM_MAJOR_VERSION, | |
7573 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7574 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7575 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7576 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7577 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7578 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7579 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7580 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7581 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7582 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7583 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7584 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7585 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7586 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7587 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7588 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7589 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7590 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7591 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7592 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7593 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7594 NULL, /**< ui_info */ |
8993 | 7595 &prpl_info, /**< extra_info */ |
10653 | 7596 #if USE_PRPL_PREFERENCES |
10487 | 7597 NULL, /**< prefs_info */ |
10653 | 7598 #else |
7599 NULL, /**< prefs_info */ | |
7600 #endif | |
9015 | 7601 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7602 }; |
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 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7605 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7606 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7607 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7608 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7609 gaim_debug_register_category("oscar"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11024
diff
changeset
|
7610 |
9830 | 7611 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7612 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7613 | |
7614 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7615 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7616 | |
7617 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7618 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
|
7619 |
9935 | 7620 gaim_prefs_add_none("/plugins/prpl/oscar"); |
7621 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7622 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7623 } |
7624 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7625 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |