Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 10570:2b05acfeec65
[gaim-migrate @ 11960]
sf patch #1036930, from Ettore Simone with updates from Stu Tomlinson
Add support for setting the ICQ web presence, authorization and IP
hiding preferences. I know the authorization setting works. The IP
hiding preference didn't seem to have any affect on licq. And the web
aware setting made something different happen, but I still didn't
seem to be web aware. I think there might be another setting that
needs setting.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 04 Feb 2005 04:50:08 +0000 |
parents | 54f7939df8e3 |
children | 77ef3f2f0df8 |
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 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
70 static GaimPlugin *my_protocol = NULL; |
4249 | 71 |
7376 | 72 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
73 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 74 |
4665 | 75 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
76 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 77 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 78 |
7283 | 79 typedef struct _OscarData OscarData; |
80 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
81 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
82 aim_conn_t *conn; |
2086 | 83 |
84 guint cnpa; | |
85 guint paspa; | |
3694 | 86 guint emlpa; |
4804 | 87 guint icopa; |
2086 | 88 |
4823 | 89 gboolean iconconnecting; |
5842 | 90 gboolean set_icon; |
4823 | 91 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
92 GSList *create_rooms; |
2086 | 93 |
94 gboolean conf; | |
95 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
96 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
97 char *email; |
2979 | 98 gboolean setnick; |
99 char *newsn; | |
2086 | 100 gboolean chpass; |
101 char *oldp; | |
102 char *newp; | |
9971 | 103 |
2086 | 104 GSList *oscar_chats; |
105 GSList *direct_ims; | |
3630 | 106 GSList *file_transfers; |
4738 | 107 GHashTable *buddyinfo; |
4804 | 108 GSList *requesticon; |
2086 | 109 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
110 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
111 gboolean icq; |
4804 | 112 guint icontimer; |
5968 | 113 guint getblisttimer; |
8341 | 114 guint getinfotimer; |
10567 | 115 gint timeoffset; |
2993 | 116 |
117 struct { | |
4230 | 118 guint maxwatchers; /* max users who can watch you */ |
2993 | 119 guint maxbuddies; /* max users you can watch */ |
4230 | 120 guint maxgroups; /* max groups in server list */ |
2993 | 121 guint maxpermits; /* max users on permit list */ |
122 guint maxdenies; /* max users on deny list */ | |
123 guint maxsiglen; /* max size (bytes) of profile */ | |
124 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
125 } rights; | |
2086 | 126 }; |
127 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
128 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
129 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
130 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 |
2086 | 133 struct chat_connection { |
134 char *name; | |
135 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
136 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
137 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
138 aim_conn_t *conn; |
2086 | 139 int inpa; |
140 int id; | |
5575 | 141 GaimConnection *gc; /* i hate this. */ |
8733 | 142 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
143 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
144 int maxvis; |
2086 | 145 }; |
146 | |
8971 | 147 struct oscar_direct_im { |
5575 | 148 GaimConnection *gc; |
2086 | 149 char name[80]; |
150 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
151 aim_conn_t *conn; |
3008 | 152 gboolean connected; |
8978 | 153 gboolean gpc_pend; |
154 gboolean killme; | |
8984 | 155 gboolean donttryagain; |
2086 | 156 }; |
157 | |
158 struct ask_direct { | |
5575 | 159 GaimConnection *gc; |
2086 | 160 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
161 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
162 fu8_t cookie[8]; |
8984 | 163 gboolean donttryagain; |
2086 | 164 }; |
165 | |
7011 | 166 /* |
167 * Various PRPL-specific buddy info that we want to keep track of | |
168 * Some other info is maintained by locate.c, and I'd like to move | |
169 * the rest of this to libfaim, mostly im.c | |
170 */ | |
4738 | 171 struct buddyinfo { |
172 gboolean typingnot; | |
6292 | 173 gchar *availmsg; |
6857 | 174 fu32_t ipaddr; |
5836 | 175 |
176 unsigned long ico_me_len; | |
177 unsigned long ico_me_csum; | |
178 time_t ico_me_time; | |
179 gboolean ico_informed; | |
4738 | 180 |
181 unsigned long ico_len; | |
182 unsigned long ico_csum; | |
183 time_t ico_time; | |
184 gboolean ico_need; | |
7406 | 185 gboolean ico_sent; |
2086 | 186 }; |
187 | |
4230 | 188 struct name_data { |
5575 | 189 GaimConnection *gc; |
4230 | 190 gchar *name; |
3453 | 191 gchar *nick; |
3141 | 192 }; |
193 | |
5129 | 194 static char *msgerrreason[] = { |
195 N_("Invalid error"), | |
196 N_("Invalid SNAC"), | |
197 N_("Rate to host"), | |
198 N_("Rate to client"), | |
199 N_("Not logged in"), | |
200 N_("Service unavailable"), | |
201 N_("Service not defined"), | |
202 N_("Obsolete SNAC"), | |
203 N_("Not supported by host"), | |
204 N_("Not supported by client"), | |
205 N_("Refused by client"), | |
206 N_("Reply too big"), | |
207 N_("Responses lost"), | |
208 N_("Request denied"), | |
209 N_("Busted SNAC payload"), | |
210 N_("Insufficient rights"), | |
211 N_("In local permit/deny"), | |
212 N_("Too evil (sender)"), | |
213 N_("Too evil (receiver)"), | |
214 N_("User temporarily unavailable"), | |
215 N_("No match"), | |
216 N_("List overflow"), | |
217 N_("Request ambiguous"), | |
218 N_("Queue full"), | |
219 N_("Not while on AOL") | |
220 }; | |
221 static int msgerrreasonlen = 25; | |
222 | |
223 /* All the libfaim->gaim callback functions */ | |
224 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
225 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 226 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 227 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
228 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 235 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 236 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 237 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
238 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
|
239 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
|
240 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
|
241 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
|
242 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 243 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
244 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
245 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 246 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 247 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
248 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
254 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
255 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
256 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
259 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
274 #ifndef NOSSI | |
275 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 279 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 280 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
281 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
282 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
283 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
284 #endif | |
285 | |
286 /* for DirectIM/image transfer */ | |
287 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
288 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
289 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 290 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 291 |
292 /* for file transfer */ | |
293 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
294 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
295 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
296 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
297 | |
298 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 299 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 300 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 301 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 302 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
303 | |
5836 | 304 static void oscar_free_name_data(struct name_data *data) { |
4230 | 305 g_free(data->name); |
306 g_free(data->nick); | |
307 g_free(data); | |
308 } | |
309 | |
5836 | 310 static void oscar_free_buddyinfo(void *data) { |
311 struct buddyinfo *bi = data; | |
6292 | 312 g_free(bi->availmsg); |
5836 | 313 g_free(bi); |
314 } | |
315 | |
9807 | 316 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 317 { |
318 int i = 0; | |
9826 | 319 int charset = AIM_CHARSET_ASCII; |
5129 | 320 |
321 /* Determine how we can send this message. Per the warnings elsewhere | |
322 * in this file, these little checks determine the simplest encoding | |
323 * we can use for a given message send using it. */ | |
324 while (utf8[i]) { | |
325 if ((unsigned char)utf8[i] > 0x7f) { | |
326 /* not ASCII! */ | |
9826 | 327 charset = AIM_CHARSET_CUSTOM; |
5129 | 328 break; |
329 } | |
330 i++; | |
331 } | |
332 while (utf8[i]) { | |
333 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
334 * followed by 0xc0-0xc3 in the second */ | |
335 if ((unsigned char)utf8[i] < 0x80) { | |
336 i++; | |
337 continue; | |
338 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
339 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
340 i += 2; | |
341 continue; | |
342 } | |
9826 | 343 charset = AIM_CHARSET_UNICODE; |
5129 | 344 break; |
345 } | |
346 | |
9807 | 347 return charset; |
5129 | 348 } |
349 | |
8225 | 350 /* |
351 * Take a string of the form charset="bleh" where bleh is | |
352 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
353 * return a newly allocated string containing bleh. | |
354 */ | |
355 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 356 { |
8225 | 357 gchar *ret = NULL; |
358 char *begin, *end; | |
359 | |
9933 | 360 g_return_val_if_fail(encoding != NULL, NULL); |
361 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
362 /* Make sure encoding begins with charset= */ |
10540 | 363 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
364 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
365 { | |
8225 | 366 return NULL; |
10540 | 367 } |
8225 | 368 |
369 begin = strchr(encoding, '"'); | |
370 end = strrchr(encoding, '"'); | |
371 | |
372 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
373 return NULL; | |
374 | |
375 ret = g_strndup(begin+1, (end-1) - begin); | |
376 | |
377 return ret; | |
378 } | |
379 | |
9830 | 380 static gchar * |
381 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 382 { |
383 gchar *utf8 = NULL; | |
9595 | 384 |
385 if ((encoding == NULL) || encoding[0] == '\0') { | |
386 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 387 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 388 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 389 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 390 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 391 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 392 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 393 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 394 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 395 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 396 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
397 } | |
398 | |
399 /* | |
400 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
401 * we have been unable to convert the text to utf-8 from the encoding | |
402 * that was specified. So we check if the text is valid utf-8 then | |
403 * just copy it. | |
404 */ | |
405 if (utf8 == NULL) { | |
9638 | 406 if (textlen != 0 && *text != '\0' |
407 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 408 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 409 else |
9481 | 410 utf8 = g_strndup(text, textlen); |
5129 | 411 } |
412 | |
413 return utf8; | |
414 } | |
415 | |
9830 | 416 static gchar * |
9908 | 417 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 418 { |
419 gchar *ret = NULL; | |
420 GError *err = NULL; | |
421 | |
9908 | 422 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
423 return NULL; | |
424 | |
425 if (strcasecmp("UTF-8", charsetstr)) { | |
426 if (fallback) | |
427 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
428 else | |
429 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
430 if (err != NULL) { | |
431 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
432 charsetstr, err->message); | |
433 g_error_free(err); | |
434 } | |
435 } else { | |
436 if (g_utf8_validate(data, datalen, NULL)) | |
437 ret = g_strndup(data, datalen); | |
438 else | |
439 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
440 } | |
441 | |
442 return ret; | |
443 } | |
444 | |
445 /* | |
446 * We try decoding using two different character sets. The charset | |
447 * specified in the IM determines the order in which we attempt to | |
448 * decode. We do this because there are lots of broken ICQ clients | |
449 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
450 * able to deal with that crap, then people complain like banshees. | |
451 * charsetstr1 is always set to what the correct encoding should be. | |
452 */ | |
453 static gchar * | |
454 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
455 { | |
456 gchar *ret = NULL; | |
457 const gchar *charsetstr1, *charsetstr2; | |
458 | |
459 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 460 |
461 if ((datalen == 0) || (data == NULL)) | |
462 return NULL; | |
463 | |
9908 | 464 if (charset == AIM_CHARSET_UNICODE) { |
465 charsetstr1 = "UCS-2BE"; | |
466 charsetstr2 = "UTF-8"; | |
467 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 468 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 469 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 470 else |
9908 | 471 charsetstr1 = "ISO-8859-1"; |
472 charsetstr2 = "UTF-8"; | |
473 } else if (charset == AIM_CHARSET_ASCII) { | |
474 /* Should just be "ASCII" */ | |
9914 | 475 charsetstr1 = "ASCII"; |
9908 | 476 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
477 } else if (charset == 0x000d) { | |
9830 | 478 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 479 charsetstr1 = "ISO-8859-1"; |
480 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
481 } else { | |
9830 | 482 /* Unknown, hope for valid UTF-8... */ |
9908 | 483 charsetstr1 = "UTF-8"; |
484 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
485 } | |
486 | |
487 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
488 if (ret == NULL) | |
489 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
490 if (ret == NULL) | |
491 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 492 |
493 return ret; | |
494 } | |
495 | |
496 static void | |
497 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 498 gchar **msg, int *msglen_int, |
9830 | 499 fu16_t *charset, fu16_t *charsubset) |
500 { | |
501 OscarData *od = gc->proto_data; | |
502 GaimAccount *account = gaim_connection_get_account(gc); | |
503 GError *err = NULL; | |
504 aim_userinfo_t *userinfo = NULL; | |
505 const gchar *charsetstr; | |
10039 | 506 gsize msglen; |
9830 | 507 |
508 /* Attempt to send as ASCII */ | |
10098 | 509 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 510 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 511 *charset = AIM_CHARSET_ASCII; |
9830 | 512 *charsubset = 0x0000; |
10039 | 513 *msglen_int = msglen; |
9830 | 514 return; |
515 } | |
516 | |
517 /* | |
10565 | 518 * If we're sending to an ICQ user, and they are in our |
519 * buddy list, and they are advertising the Unicode | |
520 * capability, and they are online, then attempt to send | |
521 * as UCS-2BE. | |
9830 | 522 */ |
9975 | 523 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 524 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
525 | |
10565 | 526 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
527 { | |
528 GaimBuddy *b; | |
529 b = gaim_find_buddy(account, destsn); | |
530 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
531 { | |
532 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
533 if (*msg != NULL) | |
534 { | |
535 *charset = AIM_CHARSET_UNICODE; | |
536 *charsubset = 0x0000; | |
537 *msglen_int = msglen; | |
538 return; | |
539 } | |
9830 | 540 } |
541 } | |
542 | |
543 /* | |
544 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
545 * ICQ then attempt to send as the user specified character encoding. | |
546 */ | |
547 charsetstr = "ISO-8859-1"; | |
9975 | 548 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 549 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
550 | |
10097 | 551 /* |
552 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
553 * can be converted to "charsetstr" | |
554 */ | |
10039 | 555 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 556 if (*msg != NULL) { |
557 *charset = AIM_CHARSET_CUSTOM; | |
558 *charsubset = 0x0000; | |
10039 | 559 *msglen_int = msglen; |
9830 | 560 return; |
561 } | |
562 | |
563 /* | |
564 * Nothing else worked, so send as UCS-2BE. | |
565 */ | |
10039 | 566 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 567 if (*msg != NULL) { |
568 *charset = AIM_CHARSET_UNICODE; | |
569 *charsubset = 0x0000; | |
10039 | 570 *msglen_int = msglen; |
9830 | 571 return; |
572 } | |
573 | |
9908 | 574 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 575 g_error_free(err); |
576 | |
577 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
578 *msg = g_strdup(from); | |
10039 | 579 *msglen_int = strlen(*msg); |
9830 | 580 *charset = AIM_CHARSET_ASCII; |
581 *charsubset = 0x0000; | |
582 return; | |
583 } | |
584 | |
9407 | 585 gchar *oscar_caps_to_string(guint caps) |
8701 | 586 { |
9407 | 587 GString *str; |
588 gchar *tmp; | |
8701 | 589 guint bit = 1; |
590 | |
9407 | 591 str = g_string_new(""); |
592 | |
8701 | 593 if (!caps) { |
594 return NULL; | |
595 } else while (bit <= AIM_CAPS_LAST) { | |
596 if (bit & caps) { | |
597 switch (bit) { | |
598 case AIM_CAPS_BUDDYICON: | |
599 tmp = _("Buddy Icon"); | |
600 break; | |
601 case AIM_CAPS_TALK: | |
602 tmp = _("Voice"); | |
603 break; | |
604 case AIM_CAPS_DIRECTIM: | |
605 tmp = _("AIM Direct IM"); | |
606 break; | |
607 case AIM_CAPS_CHAT: | |
608 tmp = _("Chat"); | |
609 break; | |
610 case AIM_CAPS_GETFILE: | |
611 tmp = _("Get File"); | |
612 break; | |
613 case AIM_CAPS_SENDFILE: | |
614 tmp = _("Send File"); | |
615 break; | |
616 case AIM_CAPS_GAMES: | |
617 case AIM_CAPS_GAMES2: | |
618 tmp = _("Games"); | |
619 break; | |
620 case AIM_CAPS_ADDINS: | |
621 tmp = _("Add-Ins"); | |
622 break; | |
623 case AIM_CAPS_SENDBUDDYLIST: | |
624 tmp = _("Send Buddy List"); | |
625 break; | |
626 case AIM_CAPS_ICQ_DIRECT: | |
627 tmp = _("ICQ Direct Connect"); | |
628 break; | |
629 case AIM_CAPS_APINFO: | |
630 tmp = _("AP User"); | |
631 break; | |
632 case AIM_CAPS_ICQRTF: | |
633 tmp = _("ICQ RTF"); | |
634 break; | |
635 case AIM_CAPS_EMPTY: | |
636 tmp = _("Nihilist"); | |
637 break; | |
638 case AIM_CAPS_ICQSERVERRELAY: | |
639 tmp = _("ICQ Server Relay"); | |
640 break; | |
641 case AIM_CAPS_ICQUTF8OLD: | |
642 tmp = _("Old ICQ UTF8"); | |
643 break; | |
644 case AIM_CAPS_TRILLIANCRYPT: | |
645 tmp = _("Trillian Encryption"); | |
646 break; | |
647 case AIM_CAPS_ICQUTF8: | |
648 tmp = _("ICQ UTF8"); | |
649 break; | |
650 case AIM_CAPS_HIPTOP: | |
651 tmp = _("Hiptop"); | |
652 break; | |
653 case AIM_CAPS_SECUREIM: | |
654 tmp = _("Security Enabled"); | |
655 break; | |
656 case AIM_CAPS_VIDEO: | |
657 tmp = _("Video Chat"); | |
658 break; | |
659 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
660 case AIM_CAPS_ICHATAV: | |
661 tmp = _("iChat AV"); | |
662 break; | |
663 case AIM_CAPS_LIVEVIDEO: | |
664 tmp = _("Live Video"); | |
665 break; | |
666 case AIM_CAPS_CAMERA: | |
667 tmp = _("Camera"); | |
668 break; | |
669 default: | |
670 tmp = NULL; | |
671 break; | |
672 } | |
673 if (tmp) | |
9532 | 674 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 675 } |
676 bit <<= 1; | |
677 } | |
9407 | 678 |
679 return g_string_free(str, FALSE); | |
8701 | 680 } |
681 | |
682 static char *oscar_icqstatus(int state) { | |
683 /* Make a cute little string that shows the status of the dude or dudet */ | |
684 if (state & AIM_ICQ_STATE_CHAT) | |
685 return g_strdup_printf(_("Free For Chat")); | |
686 else if (state & AIM_ICQ_STATE_DND) | |
687 return g_strdup_printf(_("Do Not Disturb")); | |
688 else if (state & AIM_ICQ_STATE_OUT) | |
689 return g_strdup_printf(_("Not Available")); | |
690 else if (state & AIM_ICQ_STATE_BUSY) | |
691 return g_strdup_printf(_("Occupied")); | |
692 else if (state & AIM_ICQ_STATE_AWAY) | |
693 return g_strdup_printf(_("Away")); | |
694 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
695 return g_strdup_printf(_("Web Aware")); | |
696 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
697 return g_strdup_printf(_("Invisible")); | |
698 else | |
699 return g_strdup_printf(_("Online")); | |
700 } | |
701 | |
9973 | 702 static void |
703 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 704 { |
705 gchar *utf8; | |
706 | |
707 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 708 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 709 g_free(utf8); |
710 } | |
711 } | |
712 | |
9973 | 713 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 714 { |
10042 | 715 OscarData *od; |
716 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
717 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
718 GaimStatus *status = NULL; |
8701 | 719 GaimGroup *g = NULL; |
720 struct buddyinfo *bi = NULL; | |
721 char *tmp; | |
722 | |
10042 | 723 od = gc->proto_data; |
724 account = gaim_connection_get_account(gc); | |
725 | |
726 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 727 return; |
728 | |
729 if (userinfo == NULL) | |
730 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
731 | |
732 if (b == NULL) | |
10042 | 733 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 734 |
735 if (b != NULL) | |
10498 | 736 { |
8701 | 737 g = gaim_find_buddys_group(b); |
10498 | 738 presence = gaim_buddy_get_presence(b); |
739 status = gaim_presence_get_active_status(presence); | |
740 } | |
8701 | 741 |
742 if (userinfo != NULL) | |
743 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
744 | |
8733 | 745 if (b != NULL) { |
10498 | 746 if (gaim_presence_is_online(presence)) { |
9975 | 747 if (aim_sn_is_icq(b->name)) { |
8733 | 748 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
749 oscar_string_append(str, newline, _("Status"), tmp); | |
750 g_free(tmp); | |
751 } | |
752 } else { | |
9625 | 753 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 754 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
755 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
756 else | |
757 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 758 } |
8733 | 759 } |
8701 | 760 |
761 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 762 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 763 (bi->ipaddr & 0xff000000) >> 24, |
764 (bi->ipaddr & 0x00ff0000) >> 16, | |
765 (bi->ipaddr & 0x0000ff00) >> 8, | |
766 (bi->ipaddr & 0x000000ff)); | |
767 oscar_string_append(str, newline, _("IP Address"), tmp); | |
768 g_free(tmp); | |
769 } | |
770 | |
771 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
772 tmp = oscar_caps_to_string(userinfo->capabilities); | |
773 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 774 g_free(tmp); |
8701 | 775 } |
776 | |
777 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
778 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
779 if (tmp != NULL) { | |
9625 | 780 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 781 g_free(tmp); |
9625 | 782 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
783 g_free(tmp2); | |
8701 | 784 } |
785 } | |
786 | |
10498 | 787 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_status_is_available(status)) { |
8701 | 788 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
789 oscar_string_append(str, newline, _("Available"), tmp); | |
790 g_free(tmp); | |
791 } | |
792 } | |
793 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
794 static char *extract_name(const char *name) { |
4121 | 795 char *tmp, *x; |
2086 | 796 int i, j; |
4120 | 797 |
798 if (!name) | |
4121 | 799 return NULL; |
10042 | 800 |
4120 | 801 x = strchr(name, '-'); |
4121 | 802 |
2086 | 803 if (!x) return NULL; |
804 x = strchr(++x, '-'); | |
805 if (!x) return NULL; | |
806 tmp = g_strdup(++x); | |
807 | |
808 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
809 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
810 if (x[i] != '%') { |
2086 | 811 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
812 continue; |
2086 | 813 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
814 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
815 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
816 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 817 } |
818 | |
819 tmp[j] = 0; | |
820 return tmp; | |
821 } | |
822 | |
10458 | 823 static struct chat_connection * |
824 find_oscar_chat(GaimConnection *gc, int id) | |
825 { | |
826 OscarData *od = (OscarData *)gc->proto_data; | |
827 GSList *cur; | |
828 struct chat_connection *cc; | |
829 | |
830 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
831 { | |
832 cc = (struct chat_connection *)cur->data; | |
833 if (cc->id == id) | |
834 return cc; | |
835 } | |
836 | |
837 return NULL; | |
838 } | |
839 | |
840 static struct chat_connection * | |
841 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
842 { | |
843 OscarData *od = (OscarData *)gc->proto_data; | |
844 GSList *cur; | |
845 struct chat_connection *cc; | |
846 | |
847 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
848 { | |
849 cc = (struct chat_connection *)cur->data; | |
850 if (cc->conn == conn) | |
851 return cc; | |
852 } | |
853 | |
854 return NULL; | |
855 } | |
856 | |
857 static struct chat_connection * | |
858 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
859 { | |
860 OscarData *od = (OscarData *)gc->proto_data; | |
861 GSList *cur; | |
862 struct chat_connection *cc; | |
863 | |
864 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
865 { | |
866 cc = (struct chat_connection *)cur->data; | |
867 if (cc->conv == conv) | |
868 return cc; | |
869 } | |
870 | |
871 return NULL; | |
872 } | |
873 | |
874 static void | |
875 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
876 { | |
877 OscarData *od = (OscarData *)gc->proto_data; | |
878 | |
879 /* Notify the conversation window that we've left the chat */ | |
880 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
881 | |
882 /* Destroy the chat_connection */ | |
883 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
884 if (cc->inpa > 0) | |
885 gaim_input_remove(cc->inpa); | |
886 aim_conn_kill(od->sess, &cc->conn); | |
887 g_free(cc->name); | |
888 g_free(cc->show); | |
889 g_free(cc); | |
8219 | 890 } |
891 | |
8971 | 892 /***************************************************************************** |
893 * Begin scary direct im stuff | |
894 *****************************************************************************/ | |
895 | |
896 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
897 GSList *d = od->direct_ims; | |
898 struct oscar_direct_im *m = NULL; | |
899 | |
900 while (d) { | |
901 m = (struct oscar_direct_im *)d->data; | |
902 if (!aim_sncmp(who, m->name)) | |
903 return m; | |
904 d = d->next; | |
905 } | |
906 | |
907 return NULL; | |
908 } | |
909 | |
910 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
911 { | |
912 gaim_debug_info("oscar", | |
913 "destroying Direct IM for %s.\n", dim->name); | |
914 | |
915 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 916 if (dim->gpc_pend) { |
917 dim->killme = TRUE; | |
918 return; | |
919 } | |
8971 | 920 if (dim->watcher) |
921 gaim_input_remove(dim->watcher); | |
922 if (dim->conn) { | |
10271 | 923 aim_conn_close(dim->conn); |
8971 | 924 aim_conn_kill(od->sess, &dim->conn); |
925 } | |
926 g_free(dim); | |
927 } | |
928 | |
929 /* the only difference between this and destroy is this writes a conv message */ | |
930 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
931 { | |
932 GaimConversation *conv; | |
933 char buf[256]; | |
934 | |
935 gaim_debug_info("oscar", | |
936 "%s disconnected Direct IM.\n", dim->name); | |
937 | |
938 if (dim->connected) | |
939 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 940 else |
8971 | 941 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
942 | |
10246 | 943 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
944 gaim_connection_get_account(dim->gc)); | |
8971 | 945 if (conv) { |
946 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 947 gaim_conversation_update_progress(conv, 0); |
8971 | 948 } else { |
949 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
950 } | |
951 | |
952 oscar_direct_im_destroy(od, dim); | |
953 | |
954 return; | |
955 } | |
956 | |
957 /* oops i made two of these. this one just calls the other one. */ | |
958 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
959 { | |
960 GaimConnection *gc = sess->aux_data; | |
961 OscarData *od = (OscarData *)gc->proto_data; | |
962 struct oscar_direct_im *dim; | |
963 char *sn; | |
964 | |
965 sn = g_strdup(aim_odc_getsn(conn)); | |
966 dim = oscar_direct_im_find(od, sn); | |
967 oscar_direct_im_disconnect(od, dim); | |
968 g_free(sn); | |
969 } | |
970 | |
971 static void destroy_direct_im_request(struct ask_direct *d) { | |
972 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
973 | |
974 g_free(d->sn); | |
975 g_free(d); | |
976 } | |
977 | |
978 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
979 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
980 struct oscar_direct_im *dim = data; | |
981 GaimConnection *gc = dim->gc; | |
982 OscarData *od = gc->proto_data; | |
983 GaimConversation *conv; | |
984 char buf[256]; | |
985 struct sockaddr name; | |
986 socklen_t name_len = 1; | |
987 | |
988 g_return_if_fail(gc != NULL); | |
989 | |
8978 | 990 dim->gpc_pend = FALSE; |
991 if (dim->killme) { | |
992 oscar_direct_im_destroy(od, dim); | |
993 return; | |
994 } | |
995 | |
8971 | 996 if (!g_list_find(gaim_connections_get_all(), gc)) { |
997 oscar_direct_im_destroy(od, dim); | |
998 return; | |
999 } | |
1000 | |
1001 if (source < 0) { | |
8984 | 1002 if (dim->donttryagain) { |
1003 oscar_direct_im_disconnect(od, dim); | |
1004 return; | |
1005 } else { | |
1006 fu8_t cookie[8]; | |
1007 char *who = g_strdup(dim->name); | |
1008 const char *tmp = aim_odc_getcookie(dim->conn); | |
1009 | |
1010 memcpy(cookie, tmp, 8); | |
1011 oscar_direct_im_destroy(od, dim); | |
1012 oscar_direct_im_initiate(gc, who, cookie); | |
1013 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1014 g_free(who); | |
1015 return; | |
1016 } | |
8971 | 1017 } |
1018 | |
1019 dim->conn->fd = source; | |
1020 aim_conn_completeconnect(od->sess, dim->conn); | |
1021 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
1022 | |
1023 /* This is the best way to see if we're connected or not */ | |
8983 | 1024 /* Is this really needed? */ |
8971 | 1025 if (getpeername(source, &name, &name_len) == 0) { |
1026 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1027 dim->connected = TRUE; | |
1028 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1029 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1030 } else { | |
8984 | 1031 if (dim->donttryagain) { |
1032 oscar_direct_im_disconnect(od, dim); | |
1033 return; | |
1034 } else { | |
1035 fu8_t cookie[8]; | |
1036 char *who = g_strdup(dim->name); | |
1037 const char *tmp = aim_odc_getcookie(dim->conn); | |
1038 | |
1039 memcpy(cookie, tmp, 8); | |
1040 oscar_direct_im_destroy(od, dim); | |
1041 oscar_direct_im_initiate(gc, who, cookie); | |
1042 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1043 g_free(who); | |
1044 return; | |
1045 } | |
8983 | 1046 } |
1047 | |
1048 | |
8971 | 1049 } |
1050 | |
1051 static void accept_direct_im_request(struct ask_direct *d) { | |
1052 GaimConnection *gc = d->gc; | |
1053 OscarData *od; | |
1054 struct oscar_direct_im *dim; | |
1055 char *host; int port = 5190; | |
1056 int i, rc; | |
8982 | 1057 char *tmp; |
1058 GaimConversation *conv; | |
8971 | 1059 |
1060 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1061 destroy_direct_im_request(d); | |
1062 return; | |
1063 } | |
1064 | |
1065 od = (OscarData *)gc->proto_data; | |
1066 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1067 | |
1068 dim = oscar_direct_im_find(od, d->sn); | |
1069 if (dim && dim->connected) { | |
1070 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1071 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1072 return; | |
1073 } | |
1074 dim = g_new0(struct oscar_direct_im, 1); | |
1075 dim->gc = d->gc; | |
8984 | 1076 dim->donttryagain = d->donttryagain; |
8971 | 1077 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1078 | |
1079 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1080 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1081 if (!dim->conn) { | |
1082 oscar_direct_im_disconnect(od, dim); | |
1083 destroy_direct_im_request(d); | |
1084 return; | |
1085 } | |
1086 | |
1087 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1088 gaim_odc_incoming, 0); | |
1089 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1090 gaim_odc_typing, 0); | |
1091 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1092 gaim_odc_update_ui, 0); | |
1093 | |
1094 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1095 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1096 if (d->ip[i] == ':') { | |
1097 port = atoi(&(d->ip[i+1])); | |
1098 break; | |
1099 } | |
1100 } | |
1101 host = g_strndup(d->ip, i); | |
1102 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1103 dim->gpc_pend = TRUE; |
8971 | 1104 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1105 |
1106 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1107 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1108 port); | |
1109 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1110 g_free(tmp); | |
8983 | 1111 |
8971 | 1112 g_free(host); |
1113 if (rc < 0) { | |
8978 | 1114 dim->gpc_pend = FALSE; |
8971 | 1115 oscar_direct_im_disconnect(od, dim); |
1116 destroy_direct_im_request(d); | |
1117 return; | |
1118 } | |
1119 | |
1120 destroy_direct_im_request(d); | |
1121 | |
1122 return; | |
1123 } | |
1124 | |
1125 /* | |
1126 * We have just established a socket with the other dude, so set up some handlers. | |
1127 */ | |
1128 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1129 GaimConnection *gc = sess->aux_data; |
7283 | 1130 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1131 GaimConversation *conv; |
8971 | 1132 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1133 char buf[256]; |
8971 | 1134 char *sn; |
1135 va_list ap; | |
1136 aim_conn_t *newconn, *listenerconn; | |
1137 | |
1138 va_start(ap, fr); | |
1139 newconn = va_arg(ap, aim_conn_t *); | |
1140 listenerconn = va_arg(ap, aim_conn_t *); | |
1141 va_end(ap); | |
1142 | |
10271 | 1143 aim_conn_close(listenerconn); |
8971 | 1144 aim_conn_kill(sess, &listenerconn); |
1145 | |
1146 sn = g_strdup(aim_odc_getsn(newconn)); | |
1147 | |
1148 gaim_debug_info("oscar", | |
1149 "DirectIM: initiate success to %s\n", sn); | |
1150 dim = oscar_direct_im_find(od, sn); | |
1151 | |
1152 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1153 gaim_input_remove(dim->watcher); | |
1154 dim->conn = newconn; | |
1155 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1156 dim->connected = TRUE; | |
1157 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1158 g_free(sn); | |
1159 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1160 | |
1161 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1162 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1163 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1164 | |
1165 return 1; | |
1166 } | |
1167 | |
1168 /* | |
1169 * This is called when each chunk of an image is received. It can be used to | |
1170 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1171 * nasty, you sicko. | |
1172 */ | |
1173 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1174 va_list ap; | |
1175 char *sn; | |
1176 double percent; | |
1177 GaimConnection *gc = sess->aux_data; | |
1178 OscarData *od = (OscarData *)gc->proto_data; | |
1179 GaimConversation *c; | |
1180 struct oscar_direct_im *dim; | |
1181 | |
1182 va_start(ap, fr); | |
1183 sn = va_arg(ap, char *); | |
1184 percent = va_arg(ap, double); | |
1185 va_end(ap); | |
1186 | |
1187 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1188 return 1; | |
1189 if (dim->watcher) { | |
1190 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1191 /* The callback will callback? I don't get how that would happen here. */ | |
1192 dim->watcher = 0; | |
1193 } | |
1194 | |
10246 | 1195 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1196 gaim_connection_get_account(gc)); | |
8971 | 1197 if (c != NULL) |
1198 gaim_conversation_update_progress(c, percent); | |
1199 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1200 oscar_callback, dim->conn); | |
1201 | |
1202 return 1; | |
1203 } | |
1204 | |
1205 /* | |
1206 * This is called after a direct IM has been received in its entirety. This | |
1207 * function is passed a long chunk of data which contains the IM with any | |
1208 * data chunks (images) appended to it. | |
1209 * | |
1210 * This function rips out all the data chunks and creates an imgstore for | |
1211 * each one. In order to do this, it first goes through the IM and takes | |
1212 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1213 * with one compatible with the imgstore Gaim core code. For each one, we | |
1214 * then read in chunks of data from the end of the message and actually | |
1215 * create the img store using the given data. | |
1216 * | |
1217 * For somewhat easy reference, here's a sample message | |
1218 * (without the whitespace and asterisks): | |
1219 * | |
1220 * <HTML><BODY BGCOLOR="#ffffff"> | |
1221 * <FONT LANG="0"> | |
1222 * This is a really stupid picture:<BR> | |
1223 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1224 * Yeah it is<BR> | |
1225 * Here is another one:<BR> | |
1226 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1227 * </FONT> | |
1228 * </BODY></HTML> | |
1229 * <BINARY> | |
1230 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1231 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1232 * </BINARY> | |
1233 */ | |
1234 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1235 GaimConnection *gc = sess->aux_data; | |
1236 GaimConvImFlags imflags = 0; | |
1237 gchar *utf8; | |
1238 GString *newmsg = g_string_new(""); | |
1239 GSList *images = NULL; | |
1240 va_list ap; | |
1241 const char *sn, *msg, *msgend, *binary; | |
1242 size_t len; | |
1243 int encoding, isawaymsg; | |
1244 | |
1245 va_start(ap, fr); | |
1246 sn = va_arg(ap, const char *); | |
1247 msg = va_arg(ap, const char *); | |
1248 len = va_arg(ap, size_t); | |
1249 encoding = va_arg(ap, int); | |
1250 isawaymsg = va_arg(ap, int); | |
1251 va_end(ap); | |
1252 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1253 |
8660 | 1254 gaim_debug_info("oscar", |
8971 | 1255 "Got DirectIM message from %s\n", sn); |
1256 | |
1257 if (isawaymsg) | |
1258 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1259 | |
1260 /* message has a binary trailer */ | |
1261 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1262 GData *attribs; | |
1263 const char *tmp, *start, *end, *last = NULL; | |
1264 | |
1265 tmp = msg; | |
1266 | |
1267 /* for each valid image tag... */ | |
1268 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1269 const char *id, *src, *datasize; | |
10504 | 1270 const char *data = NULL; |
1271 char *tag = NULL; | |
8971 | 1272 size_t size; |
1273 int imgid = 0; | |
1274 | |
1275 /* update the location of the last img tag */ | |
1276 last = end; | |
1277 | |
1278 /* grab attributes */ | |
1279 id = g_datalist_get_data(&attribs, "id"); | |
1280 src = g_datalist_get_data(&attribs, "src"); | |
1281 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1282 | |
1283 /* if we have id & datasize, build the data tag */ | |
1284 if (id && datasize) | |
1285 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1286 | |
1287 /* if we have a tag, find the start of the data */ | |
1288 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1289 data += strlen(tag); | |
1290 | |
10504 | 1291 g_free(tag); |
1292 | |
8971 | 1293 /* check the data is here and store it */ |
1294 if (data + (size = atoi(datasize)) <= msgend) | |
1295 imgid = gaim_imgstore_add(data, size, src); | |
1296 | |
1297 /* | |
1298 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1299 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1300 */ | |
1301 /* if we have a stored image... */ | |
1302 if (imgid) { | |
1303 /* append the message up to the tag */ | |
1304 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1305 if (utf8 != NULL) { | |
1306 newmsg = g_string_append(newmsg, utf8); | |
1307 g_free(utf8); | |
1308 } | |
1309 | |
1310 /* write the new image tag */ | |
1311 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1312 | |
1313 /* and record the image number */ | |
1314 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1315 } else { | |
1316 /* otherwise, copy up to the end of the tag */ | |
1317 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1318 if (utf8 != NULL) { | |
1319 newmsg = g_string_append(newmsg, utf8); | |
1320 g_free(utf8); | |
1321 } | |
1322 } | |
1323 | |
1324 /* clear the attribute list */ | |
1325 g_datalist_clear(&attribs); | |
1326 | |
1327 /* continue from the end of the tag */ | |
1328 tmp = end + 1; | |
1329 } | |
1330 | |
1331 /* append any remaining message data (without the > :-) */ | |
1332 if (last++ && (last < binary)) | |
1333 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1334 | |
1335 /* set the flag if we caught any images */ | |
1336 if (images) | |
1337 imflags |= GAIM_CONV_IM_IMAGES; | |
1338 } else { | |
1339 g_string_append_len(newmsg, msg, len); | |
1340 } | |
1341 | |
10318 | 1342 /* Convert to UTF8 */ |
1343 /* (This hasn't been tested very much) */ | |
1344 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1345 if (utf8 != NULL) { | |
1346 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1347 g_free(utf8); | |
1348 } | |
1349 | |
1350 /* free the message */ | |
8971 | 1351 g_string_free(newmsg, TRUE); |
1352 | |
1353 /* unref any images we allocated */ | |
1354 if (images) { | |
1355 GSList *tmp; | |
1356 int id; | |
1357 | |
1358 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1359 id = GPOINTER_TO_INT(tmp->data); | |
1360 gaim_imgstore_unref(id); | |
1361 } | |
1362 | |
1363 g_slist_free(images); | |
1364 } | |
1365 | |
1366 return 1; | |
1367 } | |
1368 | |
1369 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1370 va_list ap; | |
1371 char *sn; | |
1372 int typing; | |
1373 GaimConnection *gc = sess->aux_data; | |
1374 | |
1375 va_start(ap, fr); | |
1376 sn = va_arg(ap, char *); | |
1377 typing = va_arg(ap, int); | |
1378 va_end(ap); | |
1379 | |
1380 if (typing == 0x0002) { | |
1381 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1382 gaim_debug_info("oscar", | |
1383 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1384 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1385 } else if (typing == 0x0001) | |
1386 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1387 else | |
1388 serv_got_typing_stopped(gc, sn); | |
1389 return 1; | |
1390 } | |
1391 | |
1392 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1393 char *buf; | |
1394 size_t len; | |
1395 int ret; | |
1396 GString *msg = g_string_new("<HTML><BODY>"); | |
1397 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1398 GData *attribs; | |
1399 const char *start, *end, *last; | |
1400 int oscar_id = 0; | |
1401 | |
1402 last = message; | |
1403 | |
1404 /* for each valid IMG tag... */ | |
1405 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1406 GaimStoredImage *image = NULL; | |
1407 const char *id; | |
1408 | |
1409 if (start - last) { | |
1410 g_string_append_len(msg, last, start - last); | |
1411 } | |
1412 | |
1413 id = g_datalist_get_data(&attribs, "id"); | |
1414 | |
1415 /* ... if it refers to a valid gaim image ... */ | |
1416 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1417 /* ... append the message from start to the tag ... */ | |
9126 | 1418 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1419 const char *filename = gaim_imgstore_get_filename(image); |
1420 gpointer imgdata = gaim_imgstore_get_data(image); | |
1421 | |
1422 oscar_id++; | |
1423 | |
1424 /* ... insert a new img tag with the oscar id ... */ | |
1425 if (filename) | |
1426 g_string_append_printf(msg, | |
9126 | 1427 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1428 filename, oscar_id, size); |
1429 else | |
1430 g_string_append_printf(msg, | |
9126 | 1431 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1432 oscar_id, size); |
1433 | |
1434 /* ... and append the data to the binary section ... */ | |
9126 | 1435 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1436 oscar_id, size); |
1437 data = g_string_append_len(data, imgdata, size); | |
1438 data = g_string_append(data, "</DATA>"); | |
1439 } | |
1440 /* If the tag is invalid, skip it, thus no else here */ | |
1441 | |
1442 g_datalist_clear(&attribs); | |
1443 | |
1444 /* continue from the end of the tag */ | |
1445 last = end + 1; | |
1446 } | |
1447 | |
1448 /* append any remaining message data (without the > :-) */ | |
1449 if (last && *last) | |
1450 msg = g_string_append(msg, last); | |
1451 | |
1452 /* if we inserted any images in the binary section, append it */ | |
1453 if (oscar_id) { | |
1454 msg = g_string_append_len(msg, data->str, data->len); | |
1455 msg = g_string_append(msg, "</BINARY>"); | |
1456 } | |
1457 | |
1458 len = msg->len; | |
1459 buf = msg->str; | |
1460 g_string_free(msg, FALSE); | |
1461 g_string_free(data, TRUE); | |
1462 | |
1463 | |
1464 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1465 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1466 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1467 else | |
1468 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1469 | |
1470 g_free(buf); | |
1471 | |
1472 return ret; | |
1473 } | |
1474 | |
1475 struct ask_do_dir_im { | |
1476 char *who; | |
1477 GaimConnection *gc; | |
1478 }; | |
1479 | |
1480 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1481 g_free(data->who); | |
1482 g_free(data); | |
1483 } | |
1484 | |
8983 | 1485 /* this function is used to initiate a direct im session with someone. |
1486 * we start listening on a port and send a request. they either connect | |
1487 * or send some kind of reply. If they can't connect, they ask us to | |
1488 * connect to them, and so we do that. | |
1489 * | |
1490 * this function will also get called if the other side initiate's a direct | |
1491 * im and we try to connect and fail. in that case cookie will not be null. | |
1492 * | |
1493 * note that cookie is an 8 byte string that isn't NULL terminated | |
1494 */ | |
1495 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1496 OscarData *od; |
1497 struct oscar_direct_im *dim; | |
1498 int listenfd; | |
8982 | 1499 const char *ip; |
8971 | 1500 |
1501 od = (OscarData *)gc->proto_data; | |
1502 | |
8983 | 1503 dim = oscar_direct_im_find(od, who); |
8971 | 1504 if (dim) { |
1505 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1506 oscar_direct_im_disconnect(od, dim); | |
1507 gaim_debug_info("oscar", | |
1508 "Gave up on old direct IM, trying again\n"); | |
1509 } else { | |
1510 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1511 return; |
8971 | 1512 } |
1513 } | |
1514 dim = g_new0(struct oscar_direct_im, 1); | |
1515 dim->gc = gc; | |
8983 | 1516 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1517 |
1518 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1519 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1520 if (listenfd >= 0) |
1521 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1522 if (dim->conn != NULL) { |
8982 | 1523 char *tmp; |
1524 GaimConversation *conv; | |
1525 | |
8971 | 1526 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1527 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1528 oscar_callback, dim->conn); | |
1529 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1530 gaim_odc_initiate, 0); | |
8982 | 1531 |
8983 | 1532 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1533 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1534 gaim_network_get_port_from_fd(listenfd)); |
1535 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1536 g_free(tmp); | |
8971 | 1537 } else { |
1538 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1539 oscar_direct_im_destroy(od, dim); | |
1540 } | |
8983 | 1541 } |
1542 | |
1543 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1544 GaimConnection *gc = data->gc; | |
1545 | |
1546 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1547 g_free(data->who); | |
1548 g_free(data); | |
1549 return; | |
1550 } | |
1551 | |
1552 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1553 g_free(data->who); |
1554 g_free(data); | |
1555 } | |
1556 | |
1557 /* this is the right click menu cb thingy */ | |
9030 | 1558 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1559 | |
1560 GaimBuddy *buddy; | |
1561 GaimConnection *gc; | |
8971 | 1562 gchar *buf; |
9030 | 1563 struct ask_do_dir_im *data; |
1564 | |
1565 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1566 | |
1567 buddy = (GaimBuddy *) node; | |
1568 gc = gaim_account_get_connection(buddy->account); | |
1569 | |
1570 data = g_new0(struct ask_do_dir_im, 1); | |
1571 data->who = g_strdup(buddy->name); | |
8971 | 1572 data->gc = gc; |
9030 | 1573 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1574 buddy->name); | |
8971 | 1575 |
1576 gaim_request_action(gc, NULL, buf, | |
9030 | 1577 _("Because this reveals your IP address, it " |
1578 "may be considered a privacy risk. Do you " | |
1579 "wish to continue?"), | |
1580 0, data, 2, | |
1581 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1582 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1583 g_free(buf); |
1584 } | |
1585 | |
1586 /***************************************************************************** | |
1587 * End scary direct im stuff | |
1588 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1589 |
4617 | 1590 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1591 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1592 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1593 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1594 OscarData *od; |
2086 | 1595 |
1596 if (!gc) { | |
8660 | 1597 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1598 "oscar callback for closed connection (1).\n"); |
2086 | 1599 return; |
1600 } | |
10458 | 1601 |
7283 | 1602 od = (OscarData *)gc->proto_data; |
2086 | 1603 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1604 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1605 /* oh boy. this is probably bad. i guess the only thing we |
1606 * can really do is return? */ | |
8660 | 1607 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1608 "oscar callback for closed connection (2).\n"); |
8660 | 1609 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1610 return; |
1611 } | |
1612 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1613 if (condition & GAIM_INPUT_READ) { |
4617 | 1614 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1615 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1616 "got information on rendezvous listener\n"); |
4617 | 1617 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1618 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1619 "connection error (rendezvous listener)\n"); |
4617 | 1620 aim_conn_kill(od->sess, &conn); |
8446 | 1621 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1622 } |
1623 } else { | |
4617 | 1624 if (aim_get_command(od->sess, conn) >= 0) { |
1625 aim_rxdispatch(od->sess); | |
6029 | 1626 if (od->killme) { |
8660 | 1627 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1628 return; |
1629 } | |
2086 | 1630 } else { |
1631 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
10444 | 1632 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1633 { | |
1634 gaim_debug_error("oscar", "Major connection error. i.e. " | |
1635 "invalid data was received on the oscar TCP stream\n"); | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1636 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1637 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1638 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1639 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1640 char *buf; |
10458 | 1641 |
1642 gaim_debug_info("oscar", "Lost connection " | |
1643 "to chat room %s\n", cc->name); | |
1644 | |
1645 buf = g_strdup_printf(_("You have lost your connection " | |
1646 "to chat room %s."), cc->name); | |
1647 if (conv != NULL) | |
9627 | 1648 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1649 else | |
1650 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1651 g_free(buf); |
10458 | 1652 |
1653 oscar_chat_kill(gc, cc); | |
1654 | |
2086 | 1655 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1656 if (od->cnpa > 0) |
1657 gaim_input_remove(od->cnpa); | |
1658 od->cnpa = 0; | |
8660 | 1659 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1660 "removing chatnav input watcher\n"); |
4617 | 1661 while (od->create_rooms) { |
1662 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1663 g_free(cr->name); |
4617 | 1664 od->create_rooms = |
1665 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1666 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1667 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1668 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1669 NULL); |
2086 | 1670 } |
4617 | 1671 aim_conn_kill(od->sess, &conn); |
2086 | 1672 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1673 if (od->paspa > 0) |
1674 gaim_input_remove(od->paspa); | |
1675 od->paspa = 0; | |
8660 | 1676 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1677 "removing authconn input watcher\n"); |
4617 | 1678 aim_conn_kill(od->sess, &conn); |
3694 | 1679 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1680 if (od->emlpa > 0) |
1681 gaim_input_remove(od->emlpa); | |
1682 od->emlpa = 0; | |
8660 | 1683 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1684 "removing email input watcher\n"); |
4617 | 1685 aim_conn_kill(od->sess, &conn); |
4804 | 1686 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1687 if (od->icopa > 0) | |
1688 gaim_input_remove(od->icopa); | |
1689 od->icopa = 0; | |
8660 | 1690 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1691 "removing icon input watcher\n"); |
4804 | 1692 aim_conn_kill(od->sess, &conn); |
2086 | 1693 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1694 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1695 gaim_odc_disconnect(od->sess, conn); |
1696 aim_conn_kill(od->sess, &conn); | |
2086 | 1697 } else { |
8660 | 1698 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1699 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1700 conn->type); |
4617 | 1701 aim_conn_kill(od->sess, &conn); |
2086 | 1702 } |
1703 } | |
1704 } | |
1705 } | |
1706 } | |
1707 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1708 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1709 GaimConnection *gc = sess->aux_data; |
7285 | 1710 gchar *s = g_strdup_vprintf(format, va); |
1711 gchar *buf; | |
1712 | |
1713 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1714 gaim_debug_info("oscar", buf); |
7285 | 1715 if (buf[strlen(buf)-1] != '\n') |
8660 | 1716 gaim_debug_info(NULL, "\n"); |
7285 | 1717 g_free(buf); |
2086 | 1718 g_free(s); |
1719 } | |
1720 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1721 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1722 { |
5575 | 1723 GaimConnection *gc = data; |
7283 | 1724 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1725 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1726 aim_conn_t *conn; |
2086 | 1727 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1728 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1729 close(source); |
1730 return; | |
1731 } | |
1732 | |
4617 | 1733 od = gc->proto_data; |
1734 sess = od->sess; | |
2086 | 1735 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1736 conn->fd = source; |
2086 | 1737 |
1738 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1739 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1740 return; |
1741 } | |
1742 | |
1743 aim_conn_completeconnect(sess, conn); | |
4617 | 1744 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1745 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1746 | |
8660 | 1747 gaim_debug_info("oscar", |
7282 | 1748 "Screen name sent, waiting for response\n"); |
7283 | 1749 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1750 ck[1] = 0x65; |
2086 | 1751 } |
1752 | |
10444 | 1753 static void |
1754 oscar_login(GaimAccount *account, GaimStatus *status) | |
1755 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1756 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1757 aim_conn_t *conn; |
5575 | 1758 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1759 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
10400 | 1760 GaimStatusType *status_type; |
1761 GaimStatusPrimitive primitive; | |
1762 | |
1763 status_type = gaim_status_get_type(status); | |
1764 primitive = gaim_status_type_get_primitive(status_type); | |
2086 | 1765 |
8660 | 1766 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
10444 | 1767 |
10400 | 1768 if (primitive == GAIM_STATUS_OFFLINE) |
1769 return; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1770 |
8437 | 1771 if (!aim_snvalid(gaim_account_get_username(account))) { |
1772 gchar *buf; | |
8590 | 1773 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 | 1774 gaim_connection_error(gc, buf); |
1775 g_free(buf); | |
1776 } | |
1777 | |
9975 | 1778 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1779 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1780 } else { |
6622 | 1781 gc->flags |= GAIM_CONNECTION_HTML; |
1782 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1783 } |
5836 | 1784 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1785 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1786 sess = g_new0(aim_session_t, 1); |
10329 | 1787 aim_session_init(sess, TRUE, FAIM_DEBUG_LEVEL); |
2086 | 1788 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1789 /* |
1790 * We need an immediate queue because we don't use a while-loop | |
1791 * to see if things need to be sent. | |
1792 */ | |
2086 | 1793 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1794 od->sess = sess; |
2086 | 1795 sess->aux_data = gc; |
1796 | |
9935 | 1797 /* Connect to core Gaim signals */ |
10087 | 1798 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1799 |
2086 | 1800 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1801 if (conn == NULL) { | |
10444 | 1802 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1803 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1804 return; |
1805 } | |
1806 | |
4649 | 1807 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1808 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1809 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1810 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1811 |
1812 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1813 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1814 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1815 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1816 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1817 return; |
1818 } | |
7282 | 1819 |
7283 | 1820 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1821 ck[0] = 0x5a; |
5575 | 1822 } |
1823 | |
1824 static void oscar_close(GaimConnection *gc) { | |
7283 | 1825 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1826 |
1827 while (od->oscar_chats) { | |
1828 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1829 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1830 gaim_input_remove(n->inpa); |
2086 | 1831 g_free(n->name); |
1832 g_free(n->show); | |
4617 | 1833 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1834 g_free(n); |
1835 } | |
4617 | 1836 while (od->direct_ims) { |
8971 | 1837 struct oscar_direct_im *n = od->direct_ims->data; |
1838 oscar_direct_im_destroy(od, n); | |
2086 | 1839 } |
4617 | 1840 /* BBB */ |
1841 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1842 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1843 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1844 gaim_xfer_cancel_local(xfer); |
3630 | 1845 } |
4804 | 1846 while (od->requesticon) { |
1847 char *sn = od->requesticon->data; | |
1848 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1849 free(sn); | |
1850 } | |
4738 | 1851 g_hash_table_destroy(od->buddyinfo); |
4617 | 1852 while (od->create_rooms) { |
1853 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1854 g_free(cr->name); |
4617 | 1855 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1856 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1857 } |
4617 | 1858 if (od->email) |
1859 g_free(od->email); | |
1860 if (od->newp) | |
1861 g_free(od->newp); | |
1862 if (od->oldp) | |
1863 g_free(od->oldp); | |
2086 | 1864 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1865 gaim_input_remove(gc->inpa); |
4617 | 1866 if (od->cnpa > 0) |
1867 gaim_input_remove(od->cnpa); | |
1868 if (od->paspa > 0) | |
1869 gaim_input_remove(od->paspa); | |
1870 if (od->emlpa > 0) | |
1871 gaim_input_remove(od->emlpa); | |
4804 | 1872 if (od->icopa > 0) |
1873 gaim_input_remove(od->icopa); | |
6907 | 1874 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1875 gaim_timeout_remove(od->icontimer); |
8341 | 1876 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1877 gaim_timeout_remove(od->getblisttimer); |
8341 | 1878 if (od->getinfotimer > 0) |
1879 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1880 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1881 |
4617 | 1882 aim_session_kill(od->sess); |
1883 g_free(od->sess); | |
1884 od->sess = NULL; | |
2086 | 1885 g_free(gc->proto_data); |
1886 gc->proto_data = NULL; | |
8660 | 1887 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1888 } |
1889 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1890 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1891 GaimConnection *gc = data; |
7283 | 1892 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1893 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1894 aim_conn_t *bosconn; |
2086 | 1895 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1896 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1897 close(source); |
1898 return; | |
1899 } | |
1900 | |
4617 | 1901 od = gc->proto_data; |
1902 sess = od->sess; | |
1903 bosconn = od->conn; | |
4366 | 1904 bosconn->fd = source; |
2086 | 1905 |
1906 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1907 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1908 return; |
1909 } | |
1910 | |
1911 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1912 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1913 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1914 gaim_connection_update_progress(gc, |
7283 | 1915 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1916 ck[4] = 0x61; |
2086 | 1917 } |
1918 | |
4617 | 1919 /* BBB */ |
4656 | 1920 /* |
1921 * This little area in oscar.c is the nexus of file transfer code, | |
1922 * so I wrote a little explanation of what happens. I am such a | |
1923 * ninja. | |
1924 * | |
1925 * The series of events for a file send is: | |
1926 * -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
|
1927 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1928 * listening socket, then asks the remote user to connect to us (and |
1929 * gives them the file name, port, IP, etc.) | |
1930 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1931 * in oscar_sendfile_estblsh) | |
1932 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1933 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1934 * connection. | |
1935 * -We get drunk because file transfer kicks ass. | |
1936 * | |
1937 * The series of events for a file receive is: | |
1938 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1939 * -Gaim user selects file to name and location to save file to and | |
1940 * oscar_xfer_init is called | |
1941 * -It connects to the remote user using the IP they gave us earlier | |
1942 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1943 * them an AIM_CB_OFT_ACK. | |
1944 * -They begin to send us lots of raw data. | |
1945 * -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
|
1946 * the connection. |
4656 | 1947 */ |
1948 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1949 | |
8446 | 1950 /* |
1951 * Miscellaneous xfer functions | |
1952 */ | |
1953 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1954 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1955 GaimXfer *xfer; |
5146 | 1956 struct aim_oft_info *oft_info; |
4656 | 1957 |
1958 while (fts) { | |
1959 xfer = fts->data; | |
5146 | 1960 oft_info = xfer->data; |
1961 | |
8446 | 1962 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1963 return xfer; |
1964 | |
1965 fts = g_slist_next(fts); | |
1966 } | |
1967 | |
1968 return NULL; | |
1969 } | |
1970 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1971 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1972 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1973 GaimXfer *xfer; |
5146 | 1974 struct aim_oft_info *oft_info; |
4656 | 1975 |
1976 while (fts) { | |
1977 xfer = fts->data; | |
5146 | 1978 oft_info = xfer->data; |
1979 | |
1980 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1981 return xfer; |
1982 | |
1983 fts = g_slist_next(fts); | |
1984 } | |
1985 | |
1986 return NULL; | |
1987 } | |
1988 | |
8446 | 1989 static void oscar_xfer_end(GaimXfer *xfer) |
1990 { | |
1991 struct aim_oft_info *oft_info = xfer->data; | |
1992 GaimConnection *gc = oft_info->sess->aux_data; | |
1993 OscarData *od = gc->proto_data; | |
1994 | |
8660 | 1995 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1996 |
1997 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1998 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1999 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
2000 } | |
2001 | |
2002 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2003 aim_oft_destroyinfo(oft_info); | |
2004 xfer->data = NULL; | |
2005 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2006 } | |
2007 | |
2008 /* | |
2009 * xfer functions used when receiving files | |
2010 */ | |
2011 | |
2012 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
2013 { | |
2014 struct aim_oft_info *oft_info = xfer->data; | |
2015 GaimConnection *gc = oft_info->sess->aux_data; | |
2016 OscarData *od = gc->proto_data; | |
2017 | |
8660 | 2018 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 2019 |
2020 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
2021 if (oft_info->conn) { | |
2022 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2023 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
2024 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
2025 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
2026 if (xfer->fd == -1) { | |
2027 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
2028 _("Unable to establish file descriptor.")); | |
2029 gaim_xfer_cancel_local(xfer); | |
2030 } | |
2031 } else { | |
2032 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
2033 _("Unable to create new connection.")); | |
2034 gaim_xfer_cancel_local(xfer); | |
2035 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2036 } | |
2037 | |
2038 } | |
2039 | |
2040 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
2041 { | |
10405 | 2042 struct aim_oft_info *oft_info; |
2043 GaimConnection *gc; | |
2044 OscarData *od; | |
2045 | |
2046 g_return_if_fail(xfer != NULL); | |
2047 g_return_if_fail(xfer->data != NULL); | |
2048 | |
2049 oft_info = xfer->data; | |
2050 gc = oft_info->sess->aux_data; | |
2051 od = gc->proto_data; | |
8446 | 2052 |
8660 | 2053 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2054 |
9771 | 2055 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2056 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2057 |
2058 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2059 aim_oft_destroyinfo(oft_info); | |
2060 xfer->data = NULL; | |
2061 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2062 } | |
2063 | |
2064 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
2065 { | |
2066 struct aim_oft_info *oft_info = xfer->data; | |
2067 | |
2068 /* Update our rolling checksum. Like Walmart, yo. */ | |
2069 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2070 } | |
2071 | |
2072 /* | |
2073 * xfer functions used when sending files | |
2074 */ | |
2075 | |
2076 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2077 { | |
2078 struct aim_oft_info *oft_info = xfer->data; | |
2079 GaimConnection *gc = oft_info->sess->aux_data; | |
2080 OscarData *od = gc->proto_data; | |
2081 int listenfd; | |
2082 | |
8660 | 2083 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2084 |
2085 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2086 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2087 oft_info->fh.name[63] = '\0'; | |
2088 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2089 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2090 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2091 | |
2092 /* Create a listening socket and an associated libfaim conn */ | |
2093 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2094 gaim_xfer_cancel_local(xfer); | |
2095 return; | |
2096 } | |
2097 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2098 oft_info->port = xfer->local_port; | |
2099 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2100 gaim_xfer_cancel_local(xfer); | |
2101 return; | |
2102 } | |
8660 | 2103 gaim_debug_misc("oscar", |
8446 | 2104 "port is %hu, ip is %s\n", |
2105 xfer->local_port, oft_info->clientip); | |
2106 if (oft_info->conn) { | |
2107 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2108 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2109 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2110 } else { | |
2111 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2112 _("Unable to establish listener socket.")); | |
2113 gaim_xfer_cancel_local(xfer); | |
2114 } | |
2115 } | |
2116 | |
2117 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2118 { | |
2119 struct aim_oft_info *oft_info = xfer->data; | |
2120 GaimConnection *gc = oft_info->sess->aux_data; | |
2121 OscarData *od = gc->proto_data; | |
2122 | |
8660 | 2123 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2124 |
9771 | 2125 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2126 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2127 |
2128 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2129 aim_oft_destroyinfo(oft_info); | |
2130 xfer->data = NULL; | |
2131 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2132 } | |
2133 | |
2134 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2135 { | |
2136 struct aim_oft_info *oft_info = xfer->data; | |
2137 | |
2138 /* I'm not sure I like how we do this. --marv | |
2139 * I do. AIM file transfers aren't really meant to be thought | |
2140 * of as a transferring just a single file. The rendezvous | |
2141 * establishes a connection between two computers, and then | |
2142 * those computers can use the same connection for transferring | |
2143 * multiple files. So we don't want the Gaim core up and closing | |
2144 * the socket all willy-nilly. We want to do that in the oscar | |
2145 * prpl, whenever one side or the other says they're finished | |
2146 * using the connection. There might be a better way to intercept | |
2147 * the socket from the core, however... --KingAnt | |
2148 */ | |
2149 | |
2150 /* | |
2151 * If we're done sending, intercept the socket from the core ft code | |
2152 * and wait for the other guy to send the "done" OFT packet. | |
2153 */ | |
2154 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2155 gaim_input_remove(xfer->watcher); | |
2156 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2157 xfer->fd = 0; | |
2158 gaim_xfer_set_completed(xfer, TRUE); | |
2159 } | |
2160 } | |
2161 | |
9466 | 2162 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2163 gboolean can_receive = FALSE; | |
2164 OscarData *od = gc->proto_data; | |
2165 | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
2166 if (od != NULL && !od->icq) { |
9466 | 2167 aim_userinfo_t *userinfo; |
2168 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2169 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2170 can_receive = TRUE; | |
2171 } | |
2172 | |
2173 return can_receive; | |
2174 } | |
2175 | |
2176 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2177 |
2178 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2179 GaimXfer *xfer; |
5146 | 2180 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2181 const char *ip; |
3752 | 2182 |
9030 | 2183 od = (OscarData *)gc->proto_data; |
2184 | |
4617 | 2185 /* You want to send a file to someone else, you're so generous */ |
2186 | |
2187 /* Build the file transfer handle */ | |
9466 | 2188 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2189 |
5146 | 2190 /* Create the oscar-specific data */ |
8838 | 2191 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2192 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2193 xfer->data = oft_info; |
2194 | |
4617 | 2195 /* Setup our I/O op functions */ |
8446 | 2196 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2197 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2198 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2199 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2200 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2201 |
2202 /* Keep track of this transfer for later */ | |
2203 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2204 | |
2205 /* Now perform the request */ | |
9466 | 2206 if (file) |
2207 gaim_xfer_request_accepted(xfer, file); | |
2208 else | |
2209 gaim_xfer_request(xfer); | |
3630 | 2210 } |
2211 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2212 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2213 GaimConnection *gc = sess->aux_data; |
7283 | 2214 OscarData *od = gc->proto_data; |
6029 | 2215 GaimAccount *account = gc->account; |
2216 aim_conn_t *bosconn; | |
2217 char *host; int port; | |
2218 int i, rc; | |
2086 | 2219 va_list ap; |
2704 | 2220 struct aim_authresp_info *info; |
6029 | 2221 |
5575 | 2222 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2223 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2224 va_start(ap, fr); |
2704 | 2225 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2226 va_end(ap); |
2227 | |
8660 | 2228 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2229 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2230 |
4293 | 2231 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2232 char buf[256]; |
2704 | 2233 switch (info->errorcode) { |
2086 | 2234 case 0x05: |
2235 /* Incorrect nick/password */ | |
6498 | 2236 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2237 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2238 break; |
2239 case 0x11: | |
2240 /* Suspended account */ | |
6498 | 2241 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2242 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2243 break; |
3498 | 2244 case 0x14: |
2245 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2246 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2247 break; |
2086 | 2248 case 0x18: |
2249 /* connecting too frequently */ | |
6498 | 2250 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2251 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 | 2252 break; |
2253 case 0x1c: | |
2254 /* client too old */ | |
6498 | 2255 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2256 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
|
2257 gaim_connection_error(gc, buf); |
2086 | 2258 break; |
2259 default: | |
6623 | 2260 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2261 break; |
2262 } | |
8660 | 2263 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2264 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2265 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2266 "Error URL: %s\n", info->errorurl); |
2086 | 2267 od->killme = TRUE; |
2268 return 1; | |
2269 } | |
2270 | |
2271 | |
9992 | 2272 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2273 |
2704 | 2274 if (info->email) { |
8660 | 2275 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2276 } else { |
8660 | 2277 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2278 } |
10042 | 2279 |
8660 | 2280 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2281 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2282 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2283 aim_conn_kill(sess, &fr->conn); |
2086 | 2284 |
2285 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2286 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2287 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2288 od->killme = TRUE; |
2289 return 0; | |
2290 } | |
2291 | |
4649 | 2292 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2293 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2294 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2295 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2296 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2297 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2298 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2299 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2300 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2301 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2302 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2303 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2304 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2305 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2306 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2307 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2308 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2309 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2310 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2311 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2312 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2313 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2314 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
|
2315 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2316 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2317 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2318 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2319 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2320 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2321 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
|
2322 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
|
2323 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
|
2324 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2325 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2326 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2327 #ifndef NOSSI |
4642 | 2328 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2329 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2330 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2331 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2332 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2333 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2334 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2335 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2336 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2337 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2338 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2339 |
7283 | 2340 od->conn = bosconn; |
2704 | 2341 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2342 if (info->bosip[i] == ':') { | |
2343 port = atoi(&(info->bosip[i+1])); | |
2086 | 2344 break; |
2345 } | |
2346 } | |
2704 | 2347 host = g_strndup(info->bosip, i); |
2086 | 2348 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2349 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2350 g_free(host); |
4366 | 2351 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2352 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2353 od->killme = TRUE; |
2354 return 0; | |
2355 } | |
4293 | 2356 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2357 gaim_input_remove(gc->inpa); |
2704 | 2358 |
7283 | 2359 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2360 ck[3] = 0x64; |
7282 | 2361 |
2086 | 2362 return 1; |
2363 } | |
2364 | |
10464 | 2365 static void |
2366 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2367 { | |
2368 GaimConnection *gc = user_data; | |
2369 OscarData *od = gc->proto_data; | |
2370 aim_session_t *sess = od->sess; | |
2371 | |
2372 aim_auth_securid_send(sess, msg); | |
2373 } | |
2374 | |
2375 static void | |
2376 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2377 { | |
2378 GaimConnection *gc = user_data; | |
2379 OscarData *od = gc->proto_data; | |
2380 | |
2381 /* Disconnect */ | |
2382 gc->wants_to_die = TRUE; | |
2383 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2384 od->killme = TRUE; | |
2385 } | |
2386 | |
2387 static int | |
2388 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2389 { | |
2390 GaimConnection *gc = sess->aux_data; | |
2391 GaimAccount *account = gaim_connection_get_account(gc); | |
2392 gchar *primary; | |
2393 | |
2394 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2395 | |
2396 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2397 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2398 _("Enter the 6 digit number from the digital display."), | |
2399 FALSE, FALSE, NULL, | |
2400 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2401 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2402 gc); | |
2403 g_free(primary); | |
2404 | |
2405 return 1; | |
2406 } | |
2407 | |
7285 | 2408 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2409 struct pieceofcrap { |
5575 | 2410 GaimConnection *gc; |
2086 | 2411 unsigned long offset; |
2412 unsigned long len; | |
2413 char *modname; | |
2414 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2415 aim_conn_t *conn; |
2086 | 2416 unsigned int inpa; |
2417 }; | |
2418 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2419 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2420 { |
2421 struct pieceofcrap *pos = data; | |
7283 | 2422 OscarData *od = pos->gc->proto_data; |
2086 | 2423 char in = '\0'; |
2424 int x = 0; | |
2425 unsigned char m[17]; | |
2426 | |
2427 while (read(pos->fd, &in, 1) == 1) { | |
2428 if (in == '\n') | |
2429 x++; | |
2430 else if (in != '\r') | |
2431 x = 0; | |
2432 if (x == 2) | |
2433 break; | |
2434 in = '\0'; | |
2435 } | |
2436 if (in != '\n') { | |
4056 | 2437 char buf[256]; |
2438 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
|
2439 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2440 gaim_notify_warning(pos->gc, NULL, |
7422 | 2441 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2442 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2443 gaim_input_remove(pos->inpa); |
2086 | 2444 close(pos->fd); |
2445 g_free(pos); | |
2446 return; | |
2447 } | |
2448 read(pos->fd, m, 16); | |
2449 m[16] = '\0'; | |
8660 | 2450 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2451 for (x = 0; x < 16; x++) |
8660 | 2452 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2453 | |
2454 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2455 gaim_input_remove(pos->inpa); |
2086 | 2456 close(pos->fd); |
2457 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2458 g_free(pos); | |
2459 } | |
2460 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2461 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2462 struct pieceofcrap *pos = data; |
5420 | 2463 gchar *buf; |
2086 | 2464 |
4366 | 2465 pos->fd = source; |
2466 | |
2086 | 2467 if (source < 0) { |
5420 | 2468 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
|
2469 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2470 gaim_notify_warning(pos->gc, NULL, |
7422 | 2471 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2472 buf); |
5420 | 2473 g_free(buf); |
2086 | 2474 if (pos->modname) |
2475 g_free(pos->modname); | |
2476 g_free(pos); | |
2477 return; | |
2478 } | |
2479 | |
5420 | 2480 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2481 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2482 write(pos->fd, buf, strlen(buf)); | |
5420 | 2483 g_free(buf); |
2086 | 2484 if (pos->modname) |
2485 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2486 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2487 return; |
2488 } | |
2489 | |
2490 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2491 #define AIM_MAX_FILE_SIZE 98304 | |
2492 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2493 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2494 va_list ap; |
2495 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2496 fu32_t offset, len; |
2086 | 2497 char *modname; |
2498 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2499 va_start(ap, fr); |
4200 | 2500 offset = va_arg(ap, fu32_t); |
2501 len = va_arg(ap, fu32_t); | |
2086 | 2502 modname = va_arg(ap, char *); |
2503 va_end(ap); | |
2504 | |
8660 | 2505 gaim_debug_misc("oscar", |
5556 | 2506 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2507 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2508 |
2086 | 2509 if (len == 0) { |
8660 | 2510 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2511 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2512 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2513 return 1; | |
2514 } | |
9625 | 2515 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2516 #if 0 | |
2086 | 2517 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2518 char *buf; | |
2519 int i = 8; | |
2520 if (modname) | |
2521 i += strlen(modname); | |
2522 buf = g_malloc(i); | |
2523 i = 0; | |
2524 if (modname) { | |
2525 memcpy(buf, modname, strlen(modname)); | |
2526 i += strlen(modname); | |
2527 } | |
2528 buf[i++] = offset & 0xff; | |
2529 buf[i++] = (offset >> 8) & 0xff; | |
2530 buf[i++] = (offset >> 16) & 0xff; | |
2531 buf[i++] = (offset >> 24) & 0xff; | |
2532 buf[i++] = len & 0xff; | |
2533 buf[i++] = (len >> 8) & 0xff; | |
2534 buf[i++] = (len >> 16) & 0xff; | |
2535 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2536 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2537 "hashing request\n"); |
2086 | 2538 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2539 g_free(buf); | |
2540 return 1; | |
2541 } | |
9625 | 2542 #endif |
2086 | 2543 |
2544 pos = g_new0(struct pieceofcrap, 1); | |
2545 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2546 pos->conn = fr->conn; |
2086 | 2547 |
2548 pos->offset = offset; | |
2549 pos->len = len; | |
2550 pos->modname = modname ? g_strdup(modname) : NULL; | |
2551 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2552 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2553 char buf[256]; |
2086 | 2554 if (pos->modname) |
2555 g_free(pos->modname); | |
2556 g_free(pos); | |
4056 | 2557 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
|
2558 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2559 gaim_notify_warning(pos->gc, NULL, |
7422 | 2560 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2561 buf); |
2086 | 2562 } |
2563 | |
2564 return 1; | |
2565 } | |
2566 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2567 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2568 GaimConnection *gc = sess->aux_data; |
7283 | 2569 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2570 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2571 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2572 #if 0 |
2573 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2574 #endif | |
7011 | 2575 va_list ap; |
2576 char *key; | |
2086 | 2577 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2578 va_start(ap, fr); |
2086 | 2579 key = va_arg(ap, char *); |
2580 va_end(ap); | |
2581 | |
4617 | 2582 if (od->icq) { |
3458 | 2583 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2584 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2585 gaim_account_get_password(account), &info, key); |
3458 | 2586 } else { |
2587 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2588 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2589 gaim_account_get_password(account), &info, key); |
3458 | 2590 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2591 |
7283 | 2592 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2593 ck[2] = 0x6c; |
7282 | 2594 |
2086 | 2595 return 1; |
2596 } | |
2597 | |
2675 | 2598 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2599 GaimConnection *gc = sess->aux_data; |
2647 | 2600 struct chat_connection *chatcon; |
2601 static int id = 1; | |
2602 | |
6905 | 2603 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
|
2604 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
|
2605 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
|
2606 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
|
2607 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2608 |
2672 | 2609 aim_clientready(sess, fr->conn); |
2675 | 2610 |
2647 | 2611 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2612 chatcon->id = id; | |
8733 | 2613 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2614 |
2615 return 1; | |
2616 } | |
2617 | |
2675 | 2618 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2619 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2620 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2621 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2622 |
2623 aim_clientready(sess, fr->conn); | |
2624 | |
2625 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2626 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2627 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2628 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2629 |
3694 | 2630 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2631 | |
2632 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2633 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2634 | |
7282 | 2635 aim_email_sendcookies(sess); |
2636 aim_email_activate(sess); | |
3694 | 2637 aim_clientready(sess, fr->conn); |
2638 | |
2639 return 1; | |
2640 } | |
2641 | |
4804 | 2642 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2643 GaimConnection *gc = sess->aux_data; |
7283 | 2644 OscarData *od = gc->proto_data; |
4804 | 2645 |
2646 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2647 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2648 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2649 | |
2650 aim_clientready(sess, fr->conn); | |
2651 | |
4823 | 2652 od->iconconnecting = FALSE; |
2653 | |
4804 | 2654 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2655 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2656 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2657 |
2658 return 1; | |
2659 } | |
2660 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2661 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2662 GaimConnection *gc = data; |
7283 | 2663 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2664 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2665 aim_conn_t *tstconn; |
2086 | 2666 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2667 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2668 close(source); |
2669 return; | |
2670 } | |
2671 | |
4617 | 2672 od = gc->proto_data; |
2673 sess = od->sess; | |
2086 | 2674 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2675 tstconn->fd = source; |
2086 | 2676 |
2677 if (source < 0) { | |
2678 aim_conn_kill(sess, &tstconn); | |
8660 | 2679 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2680 "unable to connect to chatnav server\n"); |
2086 | 2681 return; |
2682 } | |
2683 | |
2684 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2685 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2686 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2687 } |
2688 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2689 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2690 { |
5575 | 2691 GaimConnection *gc = data; |
7283 | 2692 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2693 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2694 aim_conn_t *tstconn; |
2086 | 2695 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2696 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2697 close(source); |
2698 return; | |
2699 } | |
2700 | |
4617 | 2701 od = gc->proto_data; |
2702 sess = od->sess; | |
2086 | 2703 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2704 tstconn->fd = source; |
2086 | 2705 |
2706 if (source < 0) { | |
2707 aim_conn_kill(sess, &tstconn); | |
8660 | 2708 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2709 "unable to connect to authorizer\n"); |
2086 | 2710 return; |
2711 } | |
2712 | |
2713 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2714 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2715 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2716 } |
2717 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2718 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2719 { |
2720 struct chat_connection *ccon = data; | |
5575 | 2721 GaimConnection *gc = ccon->gc; |
7283 | 2722 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2723 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2724 aim_conn_t *tstconn; |
2086 | 2725 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2726 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2727 close(source); |
2728 g_free(ccon->show); | |
2729 g_free(ccon->name); | |
2730 g_free(ccon); | |
2731 return; | |
2732 } | |
2733 | |
4617 | 2734 od = gc->proto_data; |
2735 sess = od->sess; | |
2086 | 2736 tstconn = ccon->conn; |
4366 | 2737 tstconn->fd = source; |
2086 | 2738 |
2739 if (source < 0) { | |
2740 aim_conn_kill(sess, &tstconn); | |
2741 g_free(ccon->show); | |
2742 g_free(ccon->name); | |
2743 g_free(ccon); | |
2744 return; | |
2745 } | |
2746 | |
2747 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2748 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2749 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2750 } |
2751 | |
3694 | 2752 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2753 GaimConnection *gc = data; |
7283 | 2754 OscarData *od; |
3694 | 2755 aim_session_t *sess; |
2756 aim_conn_t *tstconn; | |
2757 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2758 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2759 close(source); |
2760 return; | |
2761 } | |
2762 | |
4617 | 2763 od = gc->proto_data; |
2764 sess = od->sess; | |
3694 | 2765 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2766 tstconn->fd = source; |
3694 | 2767 |
2768 if (source < 0) { | |
2769 aim_conn_kill(sess, &tstconn); | |
8660 | 2770 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2771 "unable to connect to email server\n"); |
3694 | 2772 return; |
2773 } | |
2774 | |
2775 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2776 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2777 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2778 "email: connected\n"); |
3694 | 2779 } |
2780 | |
4804 | 2781 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2782 GaimConnection *gc = data; |
7283 | 2783 OscarData *od; |
4804 | 2784 aim_session_t *sess; |
2785 aim_conn_t *tstconn; | |
2786 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2787 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2788 close(source); |
2789 return; | |
2790 } | |
2791 | |
2792 od = gc->proto_data; | |
2793 sess = od->sess; | |
2794 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2795 tstconn->fd = source; | |
2796 | |
2797 if (source < 0) { | |
2798 aim_conn_kill(sess, &tstconn); | |
8660 | 2799 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2800 "unable to connect to icon server\n"); |
4804 | 2801 return; |
2802 } | |
2803 | |
2804 aim_conn_completeconnect(sess, tstconn); | |
2805 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2806 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2807 } |
2808 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2809 /* 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
|
2810 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2811 GaimConnection *gc = sess->aux_data; |
2812 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2813 aim_conn_t *tstconn; |
4452 | 2814 int i; |
2086 | 2815 char *host; |
2816 int port; | |
4821 | 2817 va_list ap; |
2818 struct aim_redirect_data *redir; | |
2086 | 2819 |
5575 | 2820 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2821 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2822 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2823 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2824 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2825 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2826 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2827 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2828 port = atoi(&(redir->ip[i+1])); |
2086 | 2829 break; |
2830 } | |
2831 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2832 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2833 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2834 switch(redir->group) { |
2086 | 2835 case 0x7: /* Authorizer */ |
8660 | 2836 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2837 "Reconnecting with authorizor...\n"); |
2086 | 2838 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2839 if (tstconn == NULL) { | |
8660 | 2840 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2841 "unable to reconnect with authorizer\n"); |
2086 | 2842 g_free(host); |
2843 return 1; | |
2844 } | |
4649 | 2845 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2846 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2847 |
2848 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2849 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2850 aim_conn_kill(sess, &tstconn); |
8660 | 2851 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2852 "unable to reconnect with authorizer\n"); |
2086 | 2853 g_free(host); |
2854 return 1; | |
2855 } | |
4293 | 2856 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2857 break; |
2858 | |
2086 | 2859 case 0xd: /* ChatNav */ |
2860 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2861 if (tstconn == NULL) { | |
8660 | 2862 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2863 "unable to connect to chatnav server\n"); |
2086 | 2864 g_free(host); |
2865 return 1; | |
2866 } | |
4649 | 2867 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2868 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2869 |
2870 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2871 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2872 aim_conn_kill(sess, &tstconn); |
8660 | 2873 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2874 "unable to connect to chatnav server\n"); |
2086 | 2875 g_free(host); |
2876 return 1; | |
2877 } | |
4293 | 2878 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2879 break; |
2880 | |
2881 case 0xe: { /* Chat */ | |
2086 | 2882 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2883 |
2086 | 2884 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2885 if (tstconn == NULL) { | |
8660 | 2886 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2887 "unable to connect to chat server\n"); |
2086 | 2888 g_free(host); |
2889 return 1; | |
2890 } | |
2891 | |
4649 | 2892 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2893 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2894 | |
2086 | 2895 ccon = g_new0(struct chat_connection, 1); |
2896 ccon->conn = tstconn; | |
2897 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2898 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2899 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2900 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2901 ccon->show = extract_name(redir->chat.room); |
4634 | 2902 |
2086 | 2903 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2904 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2905 aim_conn_kill(sess, &tstconn); |
8660 | 2906 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2907 "unable to connect to chat server\n"); |
2086 | 2908 g_free(host); |
2909 g_free(ccon->show); | |
2910 g_free(ccon->name); | |
2911 g_free(ccon); | |
2912 return 1; | |
2913 } | |
4293 | 2914 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2915 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2916 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2917 ccon->name, ccon->exchange); |
4194 | 2918 } break; |
3694 | 2919 |
4804 | 2920 case 0x0010: { /* icon */ |
2921 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2922 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2923 "unable to connect to icon server\n"); |
4804 | 2924 g_free(host); |
2925 return 1; | |
2926 } | |
2927 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2928 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2929 | |
2930 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2931 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2932 aim_conn_kill(sess, &tstconn); |
8660 | 2933 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2934 "unable to connect to icon server\n"); |
4804 | 2935 g_free(host); |
2936 return 1; | |
2937 } | |
2938 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2939 } break; | |
2940 | |
3694 | 2941 case 0x0018: { /* email */ |
2942 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2943 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2944 "unable to connect to email server\n"); |
3694 | 2945 g_free(host); |
2946 return 1; | |
2947 } | |
4649 | 2948 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2949 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2950 | |
2951 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2952 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2953 aim_conn_kill(sess, &tstconn); |
8660 | 2954 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2955 "unable to connect to email server\n"); |
3694 | 2956 g_free(host); |
2957 return 1; | |
2958 } | |
4293 | 2959 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2960 } break; |
2961 | |
2086 | 2962 default: /* huh? */ |
8660 | 2963 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2964 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2965 redir->group); |
2086 | 2966 break; |
2967 } | |
2968 | |
2969 g_free(host); | |
2970 return 1; | |
2971 } | |
2972 | |
10042 | 2973 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
2974 { | |
2975 GaimConnection *gc; | |
2976 GaimAccount *account; | |
2977 OscarData *od; | |
4738 | 2978 struct buddyinfo *bi; |
2993 | 2979 time_t time_idle = 0, signon = 0; |
2980 int type = 0; | |
2981 int caps = 0; | |
2086 | 2982 va_list ap; |
4738 | 2983 aim_userinfo_t *info; |
10042 | 2984 gboolean buddy_is_away = FALSE; |
2985 | |
2986 gc = sess->aux_data; | |
2987 account = gaim_connection_get_account(gc); | |
2988 od = gc->proto_data; | |
4194 | 2989 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2990 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2991 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2992 va_end(ap); |
2993 | |
10130 | 2994 g_return_val_if_fail(info != NULL, 1); |
2995 g_return_val_if_fail(info->sn != NULL, 1); | |
2996 | |
2993 | 2997 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2998 caps = info->capabilities; | |
3267 | 2999 |
4766 | 3000 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
3001 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 3002 buddy_is_away = TRUE; |
3003 } | |
3004 | |
2993 | 3005 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 3006 type = (info->icqinfo.status << 16); |
3013 | 3007 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3008 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3009 buddy_is_away = TRUE; |
3013 | 3010 } |
2993 | 3011 } |
3012 | |
7141 | 3013 if (caps & AIM_CAPS_ICQ_DIRECT) |
3014 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 3015 |
3016 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 3017 time(&time_idle); |
3018 time_idle -= info->idletime*60; | |
9295 | 3019 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 3020 } |
3021 | |
5836 | 3022 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3023 signon = info->onlinesince; | |
3024 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3025 signon = time(NULL) - info->sessionlen; |
2086 | 3026 |
10567 | 3027 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3028 gaim_connection_set_display_name(gc, info->sn); |
10567 | 3029 od->timeoffset = signon - gc->login_time; |
3030 } | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
3031 |
9982 | 3032 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3033 if (!bi) { |
3034 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3035 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3036 } |
4739 | 3037 bi->typingnot = FALSE; |
3038 bi->ico_informed = FALSE; | |
6857 | 3039 bi->ipaddr = info->icqinfo.ipaddr; |
3040 | |
10563 | 3041 /* |
3042 * Handle the available message. If info->avail is NULL then the user | |
3043 * may or may not have an available message, so don't do anything. If | |
3044 * info->avail is set to the empty string, then the user's client DOES | |
3045 * support available messages and the user DOES NOT have one set. | |
3046 * Otherwise info->avail contains the available message. | |
3047 */ | |
7011 | 3048 if (info->avail != NULL) |
10563 | 3049 { |
3050 free(bi->availmsg); | |
3051 if (info->avail[0] != '\0') | |
3052 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); | |
3053 else | |
3054 bi->availmsg = NULL; | |
3055 } | |
4732 | 3056 |
4804 | 3057 /* Server stored icon stuff */ |
4853 | 3058 if (info->iconcsumlen) { |
7125 | 3059 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3060 char *b16 = NULL, *filepath = NULL; |
7093 | 3061 GaimBuddy *b = NULL; |
4853 | 3062 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3063 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3064 b = gaim_find_buddy(account, info->sn); |
7093 | 3065 /* |
3066 * If for some reason the checksum is valid, but cached file is not.. | |
3067 * we want to know. | |
3068 */ | |
7693 | 3069 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3070 if (filename != NULL) { |
3071 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3072 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3073 "icon_checksum"); | |
9801 | 3074 else { |
3075 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3076 filename, NULL); | |
3077 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3078 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3079 "icon_checksum"); | |
3080 g_free(filepath); | |
3081 } | |
7093 | 3082 } else |
3083 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3084 |
4853 | 3085 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3086 GSList *cur = od->requesticon; | |
3087 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3088 cur = cur->next; | |
3089 if (!cur) { | |
9982 | 3090 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3091 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3092 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3093 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3094 } |
3095 } | |
6053 | 3096 g_free(b16); |
4853 | 3097 } |
3098 | |
10042 | 3099 /* XXX - Represent other ICQ statuses */ |
3100 if (buddy_is_away == TRUE) | |
3101 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
3102 else | |
3103 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
10567 | 3104 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
9982 | 3105 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); |
3106 | |
3107 if (time_idle > 0) | |
3108 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 3109 else |
3110 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 3111 |
3112 return 1; | |
3113 } | |
3114 | |
8341 | 3115 static void gaim_check_comment(OscarData *od, const char *str) { |
3116 if ((str == NULL) || strcmp(str, ck)) | |
3117 aim_locate_setcaps(od->sess, caps_aim); | |
3118 else | |
3119 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3120 } | |
3121 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3122 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3123 GaimConnection *gc = sess->aux_data; |
7283 | 3124 OscarData *od = gc->proto_data; |
9982 | 3125 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3126 va_list ap; |
4739 | 3127 aim_userinfo_t *info; |
2086 | 3128 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3129 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3130 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3131 va_end(ap); |
3132 | |
9982 | 3133 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3134 |
7261 | 3135 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3136 |
2086 | 3137 return 1; |
3138 } | |
3139 | |
4617 | 3140 /* BBB */ |
3952 | 3141 /* |
4617 | 3142 * This is called after a remote AIM user has connected to us. We |
3143 * want to do some voodoo with the socket file descriptors, add a | |
3144 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3145 */ |
4656 | 3146 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3147 GaimConnection *gc = sess->aux_data; |
7283 | 3148 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3149 GaimXfer *xfer; |
5146 | 3150 struct aim_oft_info *oft_info; |
3630 | 3151 va_list ap; |
3152 aim_conn_t *conn, *listenerconn; | |
4656 | 3153 |
8660 | 3154 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3155 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3156 va_start(ap, fr); |
3157 conn = va_arg(ap, aim_conn_t *); | |
3158 listenerconn = va_arg(ap, aim_conn_t *); | |
3159 va_end(ap); | |
3160 | |
4617 | 3161 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3162 return 1; | |
3163 | |
5146 | 3164 if (!(oft_info = xfer->data)) |
4617 | 3165 return 1; |
3166 | |
3630 | 3167 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3168 gaim_input_remove(xfer->watcher); |
3630 | 3169 aim_conn_kill(sess, &listenerconn); |
3170 | |
5146 | 3171 oft_info->conn = conn; |
3172 xfer->fd = oft_info->conn->fd; | |
3173 | |
3174 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3175 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3176 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3177 |
3178 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3179 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3180 |
3181 return 0; | |
3182 } | |
3183 | |
3952 | 3184 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3185 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3186 * user in order to transfer a file. |
3952 | 3187 */ |
4617 | 3188 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
|
3189 GaimXfer *xfer; |
5146 | 3190 struct aim_oft_info *oft_info; |
4656 | 3191 |
8660 | 3192 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3193 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3194 if (!(xfer = data)) |
3195 return; | |
5146 | 3196 if (!(oft_info = xfer->data)) |
3630 | 3197 return; |
8446 | 3198 if (source < 0) { |
3199 gaim_xfer_cancel_remote(xfer); | |
4617 | 3200 return; |
8446 | 3201 } |
4617 | 3202 |
3203 xfer->fd = source; | |
5146 | 3204 oft_info->conn->fd = source; |
3205 | |
3206 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3207 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3208 |
3209 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3210 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3211 |
3212 return; | |
3630 | 3213 } |
3214 | |
3952 | 3215 /* |
4617 | 3216 * This is called when a buddy sends us some file info. This happens when they |
3217 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3218 * You should send them the exact same info except use the real cookie. We also |
4617 | 3219 * get like totally ready to like, receive the file, kay? |
3952 | 3220 */ |
4617 | 3221 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3222 GaimConnection *gc = sess->aux_data; |
7283 | 3223 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3224 GaimXfer *xfer; |
5146 | 3225 struct aim_oft_info *oft_info; |
4617 | 3226 va_list ap; |
3227 aim_conn_t *conn; | |
3228 fu8_t *cookie; | |
3229 struct aim_fileheader_t *fh; | |
4656 | 3230 |
8660 | 3231 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3232 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3233 va_start(ap, fr); |
3234 conn = va_arg(ap, aim_conn_t *); | |
3235 cookie = va_arg(ap, fu8_t *); | |
3236 fh = va_arg(ap, struct aim_fileheader_t *); | |
3237 va_end(ap); | |
3238 | |
3239 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3240 return 1; | |
3241 | |
5146 | 3242 if (!(oft_info = xfer->data)) |
4617 | 3243 return 1; |
3244 | |
3245 /* We want to stop listening with a normal thingy */ | |
3246 gaim_input_remove(xfer->watcher); | |
3247 xfer->watcher = 0; | |
3248 | |
5146 | 3249 /* They sent us some information about the file they're sending */ |
3250 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3251 | |
3252 /* Fill in the cookie */ | |
3253 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3254 | |
4617 | 3255 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3256 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3257 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3258 | |
3259 return 0; | |
3630 | 3260 } |
3261 | |
3952 | 3262 /* |
4657 | 3263 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3264 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3265 */ |
4617 | 3266 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3267 GaimConnection *gc = sess->aux_data; |
7283 | 3268 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3269 GaimXfer *xfer; |
4617 | 3270 va_list ap; |
3271 aim_conn_t *conn; | |
3272 fu8_t *cookie; | |
3273 struct aim_fileheader_t *fh; | |
4656 | 3274 |
8660 | 3275 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3276 va_start(ap, fr); |
3277 conn = va_arg(ap, aim_conn_t *); | |
3278 cookie = va_arg(ap, fu8_t *); | |
3279 fh = va_arg(ap, struct aim_fileheader_t *); | |
3280 va_end(ap); | |
3281 | |
3282 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3283 return 1; | |
3284 | |
4656 | 3285 /* We want to stop listening with a normal thingy */ |
3286 gaim_input_remove(xfer->watcher); | |
3287 xfer->watcher = 0; | |
3288 | |
4617 | 3289 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3290 | |
3291 return 0; | |
3630 | 3292 } |
4617 | 3293 |
3294 /* | |
3295 * We just sent a file to someone. They said they got it and everything, | |
3296 * so we can close our direct connection and what not. | |
3297 */ | |
3298 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3299 GaimConnection *gc = sess->aux_data; |
7283 | 3300 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3301 GaimXfer *xfer; |
4617 | 3302 va_list ap; |
3303 aim_conn_t *conn; | |
3304 fu8_t *cookie; | |
3305 struct aim_fileheader_t *fh; | |
4656 | 3306 |
8660 | 3307 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3308 va_start(ap, fr); |
3309 conn = va_arg(ap, aim_conn_t *); | |
3310 cookie = va_arg(ap, fu8_t *); | |
3311 fh = va_arg(ap, struct aim_fileheader_t *); | |
3312 va_end(ap); | |
3313 | |
3314 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3315 return 1; | |
3316 | |
4656 | 3317 xfer->fd = conn->fd; |
4617 | 3318 gaim_xfer_end(xfer); |
3319 | |
3320 return 0; | |
3321 } | |
3630 | 3322 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3323 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3324 GaimConnection *gc = sess->aux_data; |
7283 | 3325 OscarData *od = gc->proto_data; |
8708 | 3326 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3327 GaimConvImFlags flags = 0; |
4738 | 3328 struct buddyinfo *bi; |
5575 | 3329 const char *iconfile; |
9806 | 3330 GString *message; |
3331 gchar *tmp; | |
3332 aim_mpmsg_section_t *curpart; | |
3333 | |
10472 | 3334 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3335 userinfo->sn, args->mpmsg.numparts); |
4738 | 3336 |
8708 | 3337 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3338 if (!bi) { |
3339 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3340 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3341 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3342 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3343 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3344 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3345 |
4738 | 3346 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3347 bi->typingnot = TRUE; | |
3348 else | |
3349 bi->typingnot = FALSE; | |
3350 | |
4380 | 3351 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3352 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3353 "%s has an icon\n", userinfo->sn); |
4738 | 3354 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3355 bi->ico_need = TRUE; | |
3356 bi->ico_len = args->iconlen; | |
3357 bi->ico_csum = args->iconsum; | |
3358 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3359 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3360 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3361 |
10458 | 3362 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3363 (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
|
3364 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3365 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3366 |
5575 | 3367 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3368 char *buf = g_malloc(st.st_size); |
5575 | 3369 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3370 if (file) { |
9532 | 3371 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3372 int len = fread(buf, 1, st.st_size, file); |
8660 | 3373 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3374 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3375 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3376 userinfo->sn, len, st.st_size); |
4617 | 3377 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3378 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3379 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3380 } else |
8660 | 3381 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3382 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3383 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3384 } else |
8660 | 3385 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3386 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3387 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3388 |
9806 | 3389 message = g_string_new(""); |
3390 curpart = args->mpmsg.parts; | |
3391 while (curpart != NULL) { | |
9908 | 3392 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3393 curpart->data, curpart->datalen); |
3394 if (tmp != NULL) { | |
3395 g_string_append(message, tmp); | |
3396 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3397 } |
9806 | 3398 |
3399 curpart = curpart->next; | |
3400 } | |
3401 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3402 |
8666 | 3403 /* |
8995 | 3404 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3405 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3406 * so any HTML we receive is intended to be displayed |
3407 * | |
3408 * Note: There *may* be some clients which send messages as HTML formatted - | |
3409 * they need to be special-cased somehow. | |
8666 | 3410 */ |
9982 | 3411 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3412 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3413 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3414 g_free(tmp); |
3415 tmp = tmp2; | |
3416 } | |
3417 | |
6982 | 3418 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3419 g_free(tmp); |
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 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3422 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3423 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3424 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3425 GaimConnection *gc; |
9933 | 3426 GaimAccount *account; |
9070 | 3427 OscarData *od; |
9933 | 3428 const char *username = NULL; |
3429 char *message = NULL; | |
9070 | 3430 |
3431 g_return_val_if_fail(sess != NULL, 0); | |
3432 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3433 | |
3434 gc = sess->aux_data; | |
9933 | 3435 account = gaim_connection_get_account(gc); |
9070 | 3436 od = gc->proto_data; |
9933 | 3437 username = gaim_account_get_username(account); |
3438 | |
3439 if (args == NULL) | |
4121 | 3440 return 0; |
4194 | 3441 |
9933 | 3442 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3443 userinfo->sn, args->status); | |
3444 | |
3445 if (args->msg != NULL) | |
3446 { | |
3447 if (args->encoding != NULL) | |
3448 { | |
3449 char *encoding = NULL; | |
3450 encoding = oscar_encoding_extract(args->encoding); | |
3451 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3452 g_free(encoding); | |
3453 } else { | |
3454 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3455 message = g_strdup(args->msg); | |
3456 } | |
3457 } | |
2869 | 3458 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3459 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3460 char *name; |
5234 | 3461 GHashTable *components; |
3462 | |
9933 | 3463 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3464 g_free(message); | |
4121 | 3465 return 1; |
9933 | 3466 } |
5234 | 3467 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3468 g_free); | |
4121 | 3469 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3470 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3471 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
|
3472 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3473 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3474 userinfo->sn, |
9933 | 3475 message, |
5234 | 3476 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3477 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3478 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3479 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3480 /* BBB */ |
3481 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3482 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3483 GaimXfer *xfer; |
5146 | 3484 struct aim_oft_info *oft_info; |
3485 | |
3486 if (!args->cookie || !args->port || !args->verifiedip || | |
3487 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3488 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3489 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3490 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3491 "information.\n", userinfo->sn); |
5146 | 3492 if (args->proxyip) |
8660 | 3493 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3494 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3495 "does not support this yet.\n"); |
9933 | 3496 g_free(message); |
4617 | 3497 return 1; |
4656 | 3498 } |
4617 | 3499 |
3500 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3501 /* 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
|
3502 * directory -- remove the star and trailing slash so we don't save |
4617 | 3503 * directories that look like 'dirname\*' -- arl */ |
3504 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3505 if (tmp && (tmp[1] == '*')) { | |
3506 tmp[0] = '\0'; | |
3507 } | |
8660 | 3508 gaim_debug_warning("oscar", |
8446 | 3509 "We're receiving a whole directory! What fun! " |
3510 "Especially since we don't support that!\n"); | |
4617 | 3511 } |
3512 | |
3513 /* Build the file transfer handle */ | |
3514 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3515 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3516 xfer->remote_port = args->port; |
4617 | 3517 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3518 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3519 gaim_xfer_set_message(xfer, message); |
5146 | 3520 |
3521 /* Create the oscar-specific data */ | |
5163 | 3522 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3523 if (args->proxyip) |
5146 | 3524 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3525 if (args->verifiedip) |
5146 | 3526 oft_info->verifiedip = g_strdup(args->verifiedip); |
3527 xfer->data = oft_info; | |
4617 | 3528 |
3529 /* Setup our I/O op functions */ | |
8446 | 3530 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3531 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3532 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
|
3533 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3534 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3535 |
3536 /* Keep track of this transfer for later */ | |
3537 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3538 | |
3539 /* Now perform the request */ | |
3540 gaim_xfer_request(xfer); | |
3541 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3542 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3543 GaimXfer *xfer; |
8660 | 3544 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3545 "AAA - File transfer canceled by remote user\n"); |
4617 | 3546 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
|
3547 gaim_xfer_cancel_remote(xfer); |
4617 | 3548 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3549 /* | |
3550 * This gets sent by the receiver of a file | |
3551 * as they connect directly to us. If we don't | |
3552 * get this, then maybe a third party connected | |
3553 * to us, and we shouldn't send them anything. | |
3554 */ | |
3555 } else { | |
8660 | 3556 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3557 "unknown rendezvous status!\n"); |
3630 | 3558 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3559 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3560 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3561 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3562 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3563 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3564 args->info.icon.length); |
6871 | 3565 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3566 /* 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
|
3567 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3568 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
|
3569 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3570 |
4212 | 3571 if (!args->verifiedip) { |
8983 | 3572 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3573 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3574 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3575 g_free(message); |
4650 | 3576 return 1; |
4212 | 3577 } |
3578 | |
8660 | 3579 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3580 "%s received direct im request from %s (%s)\n", |
8983 | 3581 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3582 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3583 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3584 d->sn = g_strdup(userinfo->sn); |
8983 | 3585 /* Let's use the clientip here, because I think that's what AIM does. |
3586 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3587 * and then ask them to connect to us. */ | |
3588 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->clientip, args->port?args->port:5190); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3589 memcpy(d->cookie, args->cookie, 8); |
9070 | 3590 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3591 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3592 | |
8971 | 3593 oscar_direct_im_destroy(od, dim); |
8984 | 3594 d->donttryagain = TRUE; |
8971 | 3595 accept_direct_im_request(d); |
3596 } else { | |
8983 | 3597 if (dim && !dim->connected) |
8971 | 3598 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3599 "already connected to that buddy!"); | |
5575 | 3600 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
|
3601 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3602 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3603 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3604 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3605 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3606 "revealed, this may be considered a privacy " |
9972 | 3607 "risk."), |
3608 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3609 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3610 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3611 /* FIXME: we should actually send a packet on cancel */ | |
3612 } | |
8708 | 3613 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3614 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
|
3615 } else { |
8660 | 3616 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3617 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3618 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3619 |
9933 | 3620 g_free(message); |
3621 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3622 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3623 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3624 |
3453 | 3625 /* |
4230 | 3626 * Authorization Functions |
3627 * Most of these are callbacks from dialogs. They're used by both | |
3628 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3629 */ |
4269 | 3630 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3631 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3632 GaimConnection *gc = data->gc; |
4244 | 3633 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3634 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3635 OscarData *od = gc->proto_data; |
6695 | 3636 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3637 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3638 if (buddy && group) { |
8660 | 3639 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3640 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3641 buddy->name, group->name); |
4889 | 3642 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3643 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3644 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3645 } |
4230 | 3646 } |
4337 | 3647 } |
3648 | |
3649 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3650 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3651 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3652 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3653 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3654 data); |
4230 | 3655 } |
3656 | |
3657 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3658 GaimConnection *gc = data->gc; |
4244 | 3659 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3660 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3661 /* Remove from local list */ |
3662 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3663 gaim_blist_remove_buddy(b); | |
4244 | 3664 } |
3665 | |
5836 | 3666 oscar_free_name_data(data); |
4230 | 3667 } |
3668 | |
9030 | 3669 |
3670 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3671 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3672 GaimBuddy *buddy; |
4269 | 3673 gchar *dialog_msg, *nombre; |
3674 | |
4687 | 3675 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3676 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3677 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3678 else |
4830 | 3679 nombre = NULL; |
3680 | |
3681 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 | 3682 data->gc = gc; |
3683 data->name = g_strdup(name); | |
3684 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3685 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3686 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3687 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3688 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3689 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3690 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3691 |
3692 g_free(dialog_msg); | |
3693 g_free(nombre); | |
3694 } | |
3695 | |
9030 | 3696 |
3697 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3698 GaimBuddy *buddy; | |
3699 GaimConnection *gc; | |
3700 | |
3701 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3702 | |
3703 buddy = (GaimBuddy *) node; | |
3704 gc = gaim_account_get_connection(buddy->account); | |
3705 gaim_auth_sendrequest(gc, buddy->name); | |
3706 } | |
3707 | |
4230 | 3708 /* When other people ask you for authorization */ |
3709 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3710 GaimConnection *gc = data->gc; |
4244 | 3711 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3712 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3713 OscarData *od = gc->proto_data; |
4236 | 3714 #ifdef NOSSI |
6695 | 3715 GaimBuddy *buddy; |
4244 | 3716 gchar message; |
3717 message = 0; | |
4687 | 3718 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3719 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3720 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3721 #else |
4889 | 3722 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3723 #endif |
4244 | 3724 } |
3725 | |
5836 | 3726 oscar_free_name_data(data); |
3141 | 3727 } |
3728 | |
4230 | 3729 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3730 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3731 GaimConnection *gc = data->gc; |
4244 | 3732 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3733 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3734 OscarData *od = gc->proto_data; |
4230 | 3735 #ifdef NOSSI |
4617 | 3736 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3737 #else |
4889 | 3738 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3739 #endif |
4244 | 3740 } |
4337 | 3741 } |
3742 | |
3743 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3744 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3745 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3746 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3747 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3748 data); |
3141 | 3749 } |
3750 | |
7023 | 3751 /* When someone sends you buddies */ |
3752 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3753 GaimConnection *gc = data->gc; |
4244 | 3754 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3755 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3756 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3757 } |
3758 | |
5836 | 3759 oscar_free_name_data(data); |
3453 | 3760 } |
3761 | |
4075 | 3762 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 | 3763 GaimConnection *gc = sess->aux_data; |
9908 | 3764 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3765 gchar **msg1, **msg2; |
6051 | 3766 int i, numtoks; |
4076 | 3767 |
4121 | 3768 if (!args->type || !args->msg || !args->uin) |
3769 return 1; | |
4194 | 3770 |
8660 | 3771 gaim_debug_info("oscar", |
9908 | 3772 "Received a channel 4 message of type 0x%02hhx.\n", |
3773 args->type); | |
4076 | 3774 |
9919 | 3775 /* |
3776 * Split up the message at the delimeter character, then convert each | |
3777 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3778 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3779 * character in whatever encoding the message was sent in. Type 1 | |
3780 * messages are always made up of only one part, so we can easily account | |
3781 * for this suck-ass part of the protocol by splitting the string into at | |
3782 * most 1 baby string. | |
3783 */ | |
3784 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3785 for (numtoks=0; msg1[numtoks]; numtoks++); |
3786 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3787 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3788 gaim_str_strip_cr(msg1[i]); |
9908 | 3789 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3790 } |
3791 msg2[i] = NULL; | |
3792 | |
3952 | 3793 switch (args->type) { |
4173 | 3794 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3795 if (i >= 1) { |
5556 | 3796 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3797 gchar *tmp; |
3798 | |
3799 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3800 tmp = gaim_escape_html(msg2[0]); |
8493 | 3801 |
4076 | 3802 if (t) { /* This is an offline message */ |
9680 | 3803 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3804 #ifdef HAVE_TM_GMTOFF |
9724 | 3805 time_t now; |
3806 struct tm *tm; | |
3807 now = time(NULL); | |
3808 tm = localtime(&now); | |
3809 t += tm->tm_gmtoff; | |
9698 | 3810 #else |
3811 # ifdef HAVE_TIMEZONE | |
9680 | 3812 tzset(); |
3813 t -= timezone; | |
9698 | 3814 # endif |
3815 #endif | |
8514 | 3816 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3817 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3818 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3819 } |
3820 g_free(uin); | |
8493 | 3821 g_free(tmp); |
4075 | 3822 } |
3316 | 3823 } break; |
3824 | |
4173 | 3825 case 0x04: { /* Someone sent you a URL */ |
4076 | 3826 if (i >= 2) { |
7385 | 3827 if (msg2[1] != NULL) { |
3828 gchar *uin = g_strdup_printf("%u", args->uin); | |
3829 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3830 msg2[1], | |
3831 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3832 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3833 g_free(uin); | |
3834 g_free(message); | |
3835 } | |
3453 | 3836 } |
3837 } break; | |
3838 | |
4173 | 3839 case 0x06: { /* Someone requested authorization */ |
4076 | 3840 if (i >= 6) { |
4230 | 3841 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3842 gchar *dialog_msg = g_strdup_printf(_("The user %u wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); |
8660 | 3843 gaim_debug_info("oscar", |
5556 | 3844 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3845 args->uin); |
4076 | 3846 data->gc = gc; |
5556 | 3847 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3848 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3849 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3850 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3851 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3852 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3853 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3854 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3855 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3856 g_free(dialog_msg); |
3857 } | |
3141 | 3858 } break; |
3859 | |
4173 | 3860 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3861 if (i >= 1) { |
7023 | 3862 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
|
3863 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3864 dialog_msg); |
4076 | 3865 g_free(dialog_msg); |
3866 } | |
3141 | 3867 } break; |
3868 | |
4173 | 3869 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3870 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
|
3871 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3872 dialog_msg); |
3141 | 3873 g_free(dialog_msg); |
3874 } break; | |
3875 | |
4333 | 3876 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3877 if (i >= 5) { | |
3878 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
|
3879 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3880 g_free(dialog_msg); |
3881 } | |
3882 } break; | |
3883 | |
4173 | 3884 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3885 if (i >= 6) { |
4194 | 3886 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
|
3887 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3888 g_free(dialog_msg); |
3889 } | |
4075 | 3890 } break; |
3891 | |
4173 | 3892 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3893 if (i >= 6) { |
4308 | 3894 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
|
3895 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3896 g_free(dialog_msg); |
3897 } | |
4075 | 3898 } break; |
3899 | |
4173 | 3900 case 0x12: { |
3141 | 3901 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3902 /* Someone added you to their buddy list? */ |
3141 | 3903 } break; |
3904 | |
7023 | 3905 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3906 guint i, num; |
3453 | 3907 gchar **text; |
4173 | 3908 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3909 if (text) { |
3910 num = 0; | |
3911 for (i=0; i<strlen(text[0]); i++) | |
3912 num = num*10 + text[0][i]-48; | |
3913 for (i=0; i<num; i++) { | |
4230 | 3914 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3915 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 | 3916 data->gc = gc; |
4790 | 3917 data->name = g_strdup(text[i*2+1]); |
3918 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3919 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3920 gaim_request_action(gc, NULL, message, |
7023 | 3921 _("Do you want to add this buddy " |
3922 "to your buddy list?"), | |
9972 | 3923 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3924 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3925 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3926 g_free(message); |
3927 } | |
3928 g_strfreev(text); | |
3929 } | |
3930 } break; | |
3931 | |
7023 | 3932 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3933 /* This is boring and silly. */ |
3934 } break; | |
3935 | |
3141 | 3936 default: { |
8660 | 3937 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3938 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3939 "(type 0x%02hhx).\n", args->type); |
3141 | 3940 } break; |
3941 } | |
3942 | |
4076 | 3943 g_strfreev(msg1); |
3944 g_strfreev(msg2); | |
3945 | |
3141 | 3946 return 1; |
3947 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3948 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3949 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3950 fu16_t channel; |
3951 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3952 aim_userinfo_t *userinfo; |
2086 | 3953 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3954 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3955 va_start(ap, fr); |
4200 | 3956 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3957 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3958 |
3141 | 3959 switch (channel) { |
3960 case 1: { /* standard message */ | |
3961 struct aim_incomingim_ch1_args *args; | |
3962 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3963 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3964 } break; | |
3965 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3966 case 2: { /* rendezvous */ |
3141 | 3967 struct aim_incomingim_ch2_args *args; |
3968 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3969 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3970 } break; | |
3971 | |
3972 case 4: { /* ICQ */ | |
3973 struct aim_incomingim_ch4_args *args; | |
3974 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3975 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3976 } break; |
3977 | |
3978 default: { | |
8660 | 3979 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3980 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3981 "0x%04hx).", channel); |
3141 | 3982 } break; |
2086 | 3983 } |
3984 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3985 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3986 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3987 return ret; |
2086 | 3988 } |
3989 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3990 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3991 GaimConnection *gc = sess->aux_data; |
3992 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3993 char *buf; |
2086 | 3994 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3995 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3996 aim_userinfo_t *userinfo; |
2086 | 3997 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3998 va_start(ap, fr); |
4200 | 3999 chan = (fu16_t)va_arg(ap, unsigned int); |
4000 userinfo = va_arg(ap, aim_userinfo_t *); | |
4001 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
4002 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 4003 va_end(ap); |
4004 | |
4005 switch(reason) { | |
5420 | 4006 case 0: /* Invalid (0) */ |
4007 buf = g_strdup_printf( | |
4008 ngettext( | |
4276 | 4009 "You missed %hu message from %s because it was invalid.", |
4010 "You missed %hu messages from %s because they were invalid.", | |
4011 nummissed), | |
4282 | 4012 nummissed, |
4013 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4014 break; |
5420 | 4015 case 1: /* Message too large */ |
4016 buf = g_strdup_printf( | |
4017 ngettext( | |
4276 | 4018 "You missed %hu message from %s because it was too large.", |
4019 "You missed %hu messages from %s because they were too large.", | |
4020 nummissed), | |
4282 | 4021 nummissed, |
4022 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4023 break; |
5420 | 4024 case 2: /* Rate exceeded */ |
4025 buf = g_strdup_printf( | |
4026 ngettext( | |
4276 | 4027 "You missed %hu message from %s because the rate limit has been exceeded.", |
4028 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
4029 nummissed), | |
4282 | 4030 nummissed, |
4031 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4032 break; |
5420 | 4033 case 3: /* Evil Sender */ |
4034 buf = g_strdup_printf( | |
4035 ngettext( | |
4276 | 4036 "You missed %hu message from %s because he/she was too evil.", |
4037 "You missed %hu messages from %s because he/she was too evil.", | |
4038 nummissed), | |
4282 | 4039 nummissed, |
4040 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4041 break; |
5420 | 4042 case 4: /* Evil Receiver */ |
4043 buf = g_strdup_printf( | |
4044 ngettext( | |
4276 | 4045 "You missed %hu message from %s because you are too evil.", |
4046 "You missed %hu messages from %s because you are too evil.", | |
4047 nummissed), | |
4282 | 4048 nummissed, |
4049 userinfo->sn); | |
2086 | 4050 break; |
4051 default: | |
5420 | 4052 buf = g_strdup_printf( |
4053 ngettext( | |
4276 | 4054 "You missed %hu message from %s for an unknown reason.", |
4055 "You missed %hu messages from %s for an unknown reason.", | |
4056 nummissed), | |
4282 | 4057 nummissed, |
4058 userinfo->sn); | |
2086 | 4059 break; |
4060 } | |
8733 | 4061 |
9627 | 4062 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4063 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4064 g_free(buf); |
2086 | 4065 |
4066 return 1; | |
4067 } | |
4068 | |
4194 | 4069 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 4070 GaimConnection *gc = sess->aux_data; |
7283 | 4071 OscarData *od = gc->proto_data; |
4617 | 4072 |
4073 /* BBB */ | |
3630 | 4074 switch (reason) { |
4151 | 4075 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4076 GaimXfer *xfer; |
8971 | 4077 struct oscar_direct_im *dim; |
4078 | |
8660 | 4079 gaim_debug_info("oscar", |
9070 | 4080 "AAA - Other user declined some sort of direct " |
8971 | 4081 "connect attempt (automaticly?)\n"); |
4617 | 4082 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
|
4083 gaim_xfer_cancel_remote(xfer); |
8971 | 4084 else if ((dim = oscar_direct_im_find(od, who))) { |
4085 /* AAA should use find by cookie or something here */ | |
4086 oscar_direct_im_disconnect(od, dim); | |
4087 } | |
4151 | 4088 } break; |
4089 | |
4090 default: { | |
8660 | 4091 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4092 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4093 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4094 } |
3630 | 4095 |
4096 } | |
4097 | |
4098 return 0; | |
4099 } | |
4100 | |
4194 | 4101 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4102 GaimConnection *gc = sess->aux_data; |
4151 | 4103 |
4104 switch(reason) { | |
4105 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4106 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4107 | |
4108 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4109 |
4110 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4111 statusmsg = oscar_icqstatus(state); |
4151 | 4112 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4113 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4114 g_free(statusmsg); | |
4151 | 4115 g_strfreev(splitmsg); |
9244 | 4116 |
9797 | 4117 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4118 |
4119 g_free(title); | |
4120 g_free(dialogmsg); | |
4151 | 4121 } break; |
4122 | |
4123 default: { | |
8660 | 4124 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4125 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4126 "Type 0x%04hx\n", who, reason); |
4151 | 4127 } break; |
4128 } /* end of switch */ | |
4129 | |
4130 return 0; | |
4131 } | |
4132 | |
3212 | 4133 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4134 va_list ap; | |
4135 fu16_t chan, reason; | |
4136 char *who; | |
4137 | |
4138 va_start(ap, fr); | |
4200 | 4139 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4140 who = va_arg(ap, char *); |
4200 | 4141 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4142 |
3952 | 4143 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4144 char *cookie = va_arg(ap, char *); |
4151 | 4145 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4146 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4147 fu32_t state = 0; |
4151 | 4148 char *msg = NULL; |
4149 if (reason == 0x0003) { | |
4200 | 4150 state = va_arg(ap, fu32_t); |
4151 | 4151 msg = va_arg(ap, char *); |
4152 } | |
4153 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4154 } | |
3952 | 4155 |
3212 | 4156 va_end(ap); |
4157 | |
4158 return 1; | |
4159 } | |
4160 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4161 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4162 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4163 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4164 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4165 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4166 va_start(ap, fr); |
4199 | 4167 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4168 va_end(ap); |
4169 | |
8660 | 4170 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4171 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4172 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4173 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4174 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4175 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4176 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4177 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4178 |
2086 | 4179 return 1; |
4180 } | |
4181 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4182 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4183 GaimConnection *gc = sess->aux_data; |
4617 | 4184 #if 0 |
7283 | 4185 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4186 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4187 #endif |
4617 | 4188 va_list ap; |
4189 fu16_t reason; | |
4190 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4191 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4192 va_start(ap, fr); |
4617 | 4193 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4194 data = va_arg(ap, char *); |
2086 | 4195 va_end(ap); |
4196 | |
8660 | 4197 gaim_debug_error("oscar", |
10130 | 4198 "Message error with data %s and reason %hu\n", |
4199 (data != NULL ? data : ""), reason); | |
4617 | 4200 |
4201 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4202 #if 0 |
4617 | 4203 /* If this was a file transfer request, data is a cookie */ |
4204 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
|
4205 gaim_xfer_cancel_remote(xfer); |
3630 | 4206 return 1; |
4207 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4208 #endif |
3630 | 4209 |
4617 | 4210 /* Data is assumed to be the destination sn */ |
9826 | 4211 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4212 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4213 g_free(buf); | |
4214 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4215 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4216 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4217 } | |
4218 g_free(buf); | |
4219 | |
2086 | 4220 return 1; |
4221 } | |
4222 | |
3595 | 4223 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4224 GaimConnection *gc = sess->aux_data; |
3595 | 4225 va_list ap; |
4226 fu16_t type1, type2; | |
4227 char *sn; | |
4228 | |
4229 va_start(ap, fr); | |
4199 | 4230 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4231 sn = va_arg(ap, char *); |
4199 | 4232 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4233 va_end(ap); |
4234 | |
4235 switch (type2) { | |
4236 case 0x0000: { /* Text has been cleared */ | |
4237 serv_got_typing_stopped(gc, sn); | |
4238 } break; | |
4239 | |
4240 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4241 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4242 } break; |
4243 | |
4244 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4245 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4246 } break; |
4247 | |
4248 default: { | |
8660 | 4249 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 | 4250 } break; |
4251 } | |
4252 | |
4253 return 1; | |
4254 } | |
4255 | |
7141 | 4256 /* |
4257 * We get this error when there was an error in the locate family. This | |
7259 | 4258 * happens when you request info of someone who is offline. |
7141 | 4259 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4260 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4261 gchar *buf; |
2086 | 4262 va_list ap; |
5420 | 4263 fu16_t reason; |
2086 | 4264 char *destn; |
4265 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4266 va_start(ap, fr); |
4199 | 4267 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4268 destn = va_arg(ap, char *); |
4269 va_end(ap); | |
4270 | |
7781 | 4271 if (destn == NULL) |
7793 | 4272 return 1; |
10560 | 4273 |
9826 | 4274 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4275 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4276 g_free(buf); | |
9627 | 4277 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4278 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4279 } | |
4280 g_free(buf); | |
2086 | 4281 |
4282 return 1; | |
4283 } | |
4284 | |
7011 | 4285 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4286 GaimConnection *gc = sess->aux_data; |
8700 | 4287 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 4288 OscarData *od = gc->proto_data; |
8700 | 4289 GString *str; |
9244 | 4290 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4291 va_list ap; |
7011 | 4292 aim_userinfo_t *userinfo; |
2086 | 4293 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4294 va_start(ap, fr); |
7011 | 4295 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4296 va_end(ap); |
4297 | |
8700 | 4298 str = g_string_new(""); |
4299 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4300 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4301 |
10116 | 4302 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 4303 time_t t = userinfo->onlinesince - od->timeoffset; |
10116 | 4304 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); |
4305 } | |
4306 | |
4307 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 4308 time_t t = userinfo->membersince - od->timeoffset; |
10116 | 4309 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); |
4310 } | |
7011 | 4311 |
4312 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4313 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4314 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4315 g_free(tmp); |
4316 } | |
4317 | |
8701 | 4318 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4319 |
4320 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4321 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4322 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4323 g_free(tmp); | |
7011 | 4324 if (away_utf8 != NULL) { |
8700 | 4325 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4326 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4327 } |
7011 | 4328 } |
4329 | |
4330 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4331 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4332 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4333 g_free(tmp); | |
7011 | 4334 if (info_utf8 != NULL) { |
8700 | 4335 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4336 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4337 } |
7011 | 4338 } |
4339 | |
8701 | 4340 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4341 g_string_free(str, TRUE); |
9244 | 4342 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4343 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4344 g_free(title); |
8700 | 4345 g_free(tmp); |
4151 | 4346 |
2086 | 4347 return 1; |
4348 } | |
4349 | |
8341 | 4350 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4351 { | |
4352 aim_session_t *sess = data; | |
4353 GaimConnection *gc = sess->aux_data; | |
4354 OscarData *od = (OscarData *)gc->proto_data; | |
4355 | |
4356 aim_locate_dorequest(data); | |
4357 od->getinfotimer = 0; | |
4358 | |
4359 return FALSE; | |
4360 } | |
4361 | |
4362 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4363 { | |
4364 GaimConnection *gc = sess->aux_data; | |
4365 OscarData *od = (OscarData *)gc->proto_data; | |
4366 | |
4367 /* | |
4368 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4369 * us from hitting the rate limit due to request away messages and info | |
4370 * too quickly. | |
4371 */ | |
4372 if (od->getinfotimer == 0) | |
10198 | 4373 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4374 |
4375 return 1; | |
4376 } | |
4377 | |
4378 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4379 { | |
2086 | 4380 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4381 fu16_t id; |
2086 | 4382 va_list ap; |
4383 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4384 va_start(ap, fr); |
4199 | 4385 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4386 msg = va_arg(ap, char *); |
4387 va_end(ap); | |
4388 | |
8660 | 4389 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4390 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4391 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4392 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4393 _("Your AIM connection may be lost."), NULL); |
2086 | 4394 |
4395 return 1; | |
4396 } | |
4397 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4398 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4399 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4400 fu16_t type; |
5575 | 4401 GaimConnection *gc = sess->aux_data; |
7283 | 4402 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4403 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4404 va_start(ap, fr); |
4199 | 4405 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4406 |
4407 switch(type) { | |
4408 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4409 fu8_t maxrooms; |
2086 | 4410 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4411 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4412 |
4199 | 4413 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4414 exchangecount = va_arg(ap, int); |
4415 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4416 | |
8660 | 4417 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4418 "chat info: Chat Rights:\n"); |
8660 | 4419 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4420 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4421 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4422 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4423 for (i = 0; i < exchangecount; i++) |
8660 | 4424 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4425 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4426 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4427 while (od->create_rooms) { |
4428 struct create_room *cr = od->create_rooms->data; | |
8660 | 4429 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4430 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4431 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4432 g_free(cr->name); |
4617 | 4433 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4434 g_free(cr); |
2086 | 4435 } |
4436 } | |
4437 break; | |
4438 case 0x0008: { | |
4439 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4440 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4441 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4442 fu32_t createtime; |
2086 | 4443 |
4444 fqcn = va_arg(ap, char *); | |
4200 | 4445 instance = (fu16_t)va_arg(ap, unsigned int); |
4446 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4447 flags = (fu16_t)va_arg(ap, unsigned int); | |
4448 createtime = va_arg(ap, fu32_t); | |
4449 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4450 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4451 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4452 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4453 name = va_arg(ap, char *); | |
4454 ck = va_arg(ap, char *); | |
4194 | 4455 |
8660 | 4456 gaim_debug_misc("oscar", |
5556 | 4457 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4458 fqcn, |
4459 exchange, instance, flags, | |
4460 createtime, | |
4461 maxmsglen, maxoccupancy, createperms, unknown, | |
4462 name, ck); | |
4617 | 4463 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4464 } |
4465 break; | |
4466 default: | |
8660 | 4467 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4468 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4469 break; |
4470 } | |
4194 | 4471 |
4472 va_end(ap); | |
4473 | |
2086 | 4474 return 1; |
4475 } | |
4476 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4477 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4478 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4479 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4480 aim_userinfo_t *info; |
5575 | 4481 GaimConnection *g = sess->aux_data; |
2086 | 4482 |
4483 struct chat_connection *c = NULL; | |
4484 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4485 va_start(ap, fr); |
2086 | 4486 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4487 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4488 va_end(ap); |
4489 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4490 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4491 if (!c) |
4492 return 1; | |
4493 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4494 for (i = 0; i < count; i++) |
9846 | 4495 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4496 |
4497 return 1; | |
4498 } | |
4499 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4500 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4501 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4502 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4503 aim_userinfo_t *info; |
5575 | 4504 GaimConnection *g = sess->aux_data; |
2086 | 4505 |
4506 struct chat_connection *c = NULL; | |
4507 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4508 va_start(ap, fr); |
2086 | 4509 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4510 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4511 va_end(ap); |
4512 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4513 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4514 if (!c) |
4515 return 1; | |
4516 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4517 for (i = 0; i < count; i++) |
8733 | 4518 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4519 |
4520 return 1; | |
4521 } | |
4522 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4523 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
|
4524 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4525 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4526 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4527 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4528 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4529 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4530 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4531 fu32_t creationtime; |
5575 | 4532 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4533 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
|
4534 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4535 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4536 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4537 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4538 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4539 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4540 roomdesc = va_arg(ap, char *); |
4200 | 4541 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4542 creationtime = va_arg(ap, fu32_t); | |
4543 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4544 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4545 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4546 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4547 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4548 |
8660 | 4549 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4550 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4551 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4552 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4553 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4554 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4555 |
2086 | 4556 return 1; |
4557 } | |
4558 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4559 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4560 GaimConnection *gc = sess->aux_data; |
8225 | 4561 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4562 gchar *utf8; | |
2086 | 4563 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4564 aim_userinfo_t *info; |
8225 | 4565 int len; |
2086 | 4566 char *msg; |
8219 | 4567 char *charset; |
2086 | 4568 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4569 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4570 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4571 len = va_arg(ap, int); |
4194 | 4572 msg = va_arg(ap, char *); |
8219 | 4573 charset = va_arg(ap, char *); |
4194 | 4574 va_end(ap); |
2086 | 4575 |
8225 | 4576 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4577 if (utf8 == NULL) |
4578 /* The conversion failed! */ | |
8668 | 4579 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4580 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4581 g_free(utf8); | |
2086 | 4582 |
4583 return 1; | |
4584 } | |
4585 | |
3694 | 4586 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4587 va_list ap; | |
5575 | 4588 GaimConnection *gc = sess->aux_data; |
3694 | 4589 struct aim_emailinfo *emailinfo; |
3725 | 4590 int havenewmail; |
7297 | 4591 char *alertitle, *alerturl; |
3694 | 4592 |
4593 va_start(ap, fr); | |
4594 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4595 havenewmail = va_arg(ap, int); |
7301 | 4596 alertitle = va_arg(ap, char *); |
4597 alerturl = va_arg(ap, char *); | |
3694 | 4598 va_end(ap); |
4599 | |
9661 | 4600 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4601 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4602 emailinfo->domain ? "@" : "", | |
4603 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4604 if (emailinfo->unread && havenewmail) |
4605 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4606 g_free(to); |
3694 | 4607 } |
10157 | 4608 |
7301 | 4609 if (alertitle) |
8660 | 4610 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4611 |
4612 return 1; | |
4613 } | |
4614 | |
4804 | 4615 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4616 GaimConnection *gc = sess->aux_data; |
7283 | 4617 OscarData *od = gc->proto_data; |
4804 | 4618 char *sn; |
4619 | |
4620 sn = od->requesticon->data; | |
8660 | 4621 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4622 "removing %s from hash table\n", sn); |
4804 | 4623 od->requesticon = g_slist_remove(od->requesticon, sn); |
4624 free(sn); | |
4625 | |
4626 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4627 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4628 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4629 |
4630 return 1; | |
4631 } | |
4632 | |
4633 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4634 GaimConnection *gc = sess->aux_data; |
7283 | 4635 OscarData *od = gc->proto_data; |
4804 | 4636 GSList *cur; |
4637 va_list ap; | |
4638 char *sn; | |
4853 | 4639 fu8_t *iconcsum, *icon; |
4640 fu16_t iconcsumlen, iconlen; | |
4804 | 4641 |
4642 va_start(ap, fr); | |
4643 sn = va_arg(ap, char *); | |
4853 | 4644 iconcsum = va_arg(ap, fu8_t *); |
4645 iconcsumlen = va_arg(ap, int); | |
4804 | 4646 icon = va_arg(ap, fu8_t *); |
4647 iconlen = va_arg(ap, int); | |
4648 va_end(ap); | |
4649 | |
4853 | 4650 if (iconlen > 0) { |
4651 char *b16; | |
6695 | 4652 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4653 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4654 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4655 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4656 if (b16) { |
7693 | 4657 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4658 g_free(b16); |
5129 | 4659 } |
4853 | 4660 } |
4804 | 4661 |
4662 cur = od->requesticon; | |
4663 while (cur) { | |
4664 char *cursn = cur->data; | |
4665 if (!aim_sncmp(cursn, sn)) { | |
4666 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4667 free(cursn); | |
4668 cur = od->requesticon; | |
4669 } else | |
4670 cur = cur->next; | |
4671 } | |
4672 | |
4673 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4674 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4675 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4676 |
4677 return 1; | |
4678 } | |
4679 | |
4680 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4681 GaimConnection *gc = data; |
7283 | 4682 OscarData *od = gc->proto_data; |
7011 | 4683 aim_userinfo_t *userinfo; |
4804 | 4684 aim_conn_t *conn; |
4685 | |
4686 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4687 if (!conn) { |
4688 if (!od->iconconnecting) { | |
4689 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4690 od->iconconnecting = TRUE; | |
4691 } | |
4804 | 4692 return FALSE; |
4693 } | |
4694 | |
5842 | 4695 if (od->set_icon) { |
6039 | 4696 struct stat st; |
4697 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4698 if (iconfile == NULL) { | |
8363 | 4699 aim_ssi_delicon(od->sess); |
6039 | 4700 } else if (!stat(iconfile, &st)) { |
4701 char *buf = g_malloc(st.st_size); | |
4702 FILE *file = fopen(iconfile, "rb"); | |
4703 if (file) { | |
9532 | 4704 /* XXX - Use g_file_get_contents()? */ |
6039 | 4705 fread(buf, 1, st.st_size, file); |
4706 fclose(file); | |
8660 | 4707 gaim_debug_info("oscar", |
6039 | 4708 "Uploading icon to icon server\n"); |
6879 | 4709 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4710 } else |
8660 | 4711 gaim_debug_error("oscar", |
6039 | 4712 "Can't open buddy icon file!\n"); |
4713 g_free(buf); | |
4714 } else { | |
8660 | 4715 gaim_debug_error("oscar", |
6039 | 4716 "Can't stat buddy icon file!\n"); |
5842 | 4717 } |
4718 od->set_icon = FALSE; | |
4719 } | |
4720 | |
4721 if (!od->requesticon) { | |
8660 | 4722 gaim_debug_misc("oscar", |
5842 | 4723 "no more icons to request\n"); |
4724 return FALSE; | |
4725 } | |
4726 | |
7045 | 4727 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4728 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4729 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4730 return FALSE; |
4731 } else { | |
4732 char *sn = od->requesticon->data; | |
4733 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4734 free(sn); | |
4735 } | |
4736 | |
4737 return TRUE; | |
4738 } | |
4739 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4740 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4741 * 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
|
4742 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4743 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4744 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4745 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4746 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4747 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4748 va_start(ap, fr); |
4199 | 4749 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4750 sn = va_arg(ap, char *); |
4751 va_end(ap); | |
4752 | |
8660 | 4753 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4754 |
4755 return 1; | |
4756 } | |
4757 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4758 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
|
4759 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4760 "invalid", |
4194 | 4761 "change", |
4762 "warning", | |
4763 "limit", | |
4764 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4765 }; |
2086 | 4766 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4767 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4768 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4769 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4770 va_start(ap, fr); |
4200 | 4771 code = (fu16_t)va_arg(ap, unsigned int); |
4772 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4773 windowsize = va_arg(ap, fu32_t); | |
4774 clear = va_arg(ap, fu32_t); | |
4775 alert = va_arg(ap, fu32_t); | |
4776 limit = va_arg(ap, fu32_t); | |
4777 disconnect = va_arg(ap, fu32_t); | |
4778 currentavg = va_arg(ap, fu32_t); | |
4779 maxavg = va_arg(ap, fu32_t); | |
2086 | 4780 va_end(ap); |
4781 | |
8660 | 4782 gaim_debug_misc("oscar", |
5556 | 4783 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4784 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4785 (code < 5) ? codes[code] : codes[0], |
4786 rateclass, | |
4787 currentavg, maxavg, | |
4788 alert, clear, | |
4789 limit, disconnect, | |
4790 windowsize); | |
4791 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4792 /* XXX fix these values */ |
2086 | 4793 if (code == AIM_RATE_CODE_CHANGE) { |
4794 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4795 aim_conn_setlatency(fr->conn, 0); |
2086 | 4796 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4797 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4798 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4799 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4800 _("The last action you attempted could not be " |
4801 "performed because you are over the rate limit. " | |
4802 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4803 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4804 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4805 aim_conn_setlatency(fr->conn, 0); |
2086 | 4806 } |
4807 | |
4808 return 1; | |
4809 } | |
4810 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4811 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4812 GaimConnection *gc = sess->aux_data; |
4813 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4814 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4815 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4816 aim_userinfo_t *userinfo; |
2086 | 4817 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4818 va_start(ap, fr); |
4199 | 4819 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4820 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4821 va_end(ap); |
4822 | |
9982 | 4823 /* XXX - What's with the + 0.5? */ |
4824 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4825 |
4826 return 1; | |
4827 } | |
4828 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4829 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4830 GaimConnection *gc = sess->aux_data; |
4831 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4832 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4833 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4834 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4835 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4836 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4837 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4838 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4839 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4840 |
9982 | 4841 warning_level = info->warnlevel/10.0 + 0.5; |
4842 | |
10152 | 4843 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4844 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4845 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4846 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4847 |
4649 | 4848 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4849 GaimConnection *gc = sess->aux_data; |
7283 | 4850 OscarData *od = gc->proto_data; |
4649 | 4851 va_list ap; |
4852 fu16_t code; | |
4853 char *msg; | |
4854 | |
4855 va_start(ap, fr); | |
4856 code = (fu16_t)va_arg(ap, int); | |
4857 msg = va_arg(ap, char *); | |
4858 va_end(ap); | |
4859 | |
10458 | 4860 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
4861 code, (msg != NULL ? msg : "")); | |
4862 | |
4863 g_return_val_if_fail(fr != NULL, 1); | |
4864 g_return_val_if_fail(fr->conn != NULL, 1); | |
4865 | |
4866 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 4867 if (code == 0x0001) { |
6113 | 4868 gc->wants_to_die = TRUE; |
5579 | 4869 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4870 } else { |
5579 | 4871 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4872 } |
4666 | 4873 od->killme = TRUE; |
10458 | 4874 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
4875 struct chat_connection *cc; | |
4876 GaimConversation *conv; | |
4877 | |
4878 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
4879 conv = gaim_find_chat(gc, cc->id); | |
4880 | |
4881 if (conv != NULL) | |
4882 { | |
4883 gchar *buf; | |
4884 buf = g_strdup_printf(_("You have been disconnected from chat " | |
4885 "room %s."), cc->name); | |
4886 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
4887 g_free(buf); | |
4888 } | |
4889 oscar_chat_kill(gc, cc); | |
4649 | 4890 } |
4891 | |
4892 return 1; | |
4893 } | |
4894 | |
2675 | 4895 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4896 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4897 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4898 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4899 |
4900 #ifndef NOSSI | |
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 #endif |
4905 | |
7011 | 4906 aim_locate_reqrights(sess); |
7285 | 4907 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4908 aim_im_reqparams(sess); |
7334 | 4909 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4910 |
4911 #ifdef NOSSI | |
8660 | 4912 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4913 aim_bos_reqrights(sess, fr->conn); |
4230 | 4914 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4915 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4916 #endif | |
2086 | 4917 |
7283 | 4918 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4919 | |
2086 | 4920 return 1; |
4921 } | |
4922 | |
2675 | 4923 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4924 GaimConnection *gc = sess->aux_data; |
7283 | 4925 OscarData *od = gc->proto_data; |
2647 | 4926 |
6905 | 4927 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4928 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4929 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4930 | |
2672 | 4931 aim_clientready(sess, fr->conn); |
8660 | 4932 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4933 |
2647 | 4934 if (od->chpass) { |
8660 | 4935 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4936 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4937 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4938 od->oldp = NULL; |
2647 | 4939 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4940 od->newp = NULL; |
2647 | 4941 od->chpass = FALSE; |
4942 } | |
2979 | 4943 if (od->setnick) { |
8660 | 4944 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4945 aim_admin_setnick(sess, fr->conn, od->newsn); |
4946 g_free(od->newsn); | |
4947 od->newsn = NULL; | |
4948 od->setnick = FALSE; | |
4949 } | |
2647 | 4950 if (od->conf) { |
8660 | 4951 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4952 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4953 od->conf = FALSE; |
4954 } | |
4955 if (od->reqemail) { | |
8660 | 4956 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4957 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4958 od->reqemail = FALSE; |
4959 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4960 if (od->setemail) { |
8660 | 4961 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4962 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4963 g_free(od->email); |
5497 | 4964 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4965 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4966 } |
2647 | 4967 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4968 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4969 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4970 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4971 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
|
4972 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4973 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4974 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4975 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4976 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4977 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4978 |
4194 | 4979 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4980 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4981 "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
|
4982 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4983 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4984 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4985 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4986 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4987 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4988 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4989 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4990 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4991 |
4617 | 4992 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4993 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4994 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4995 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4996 |
2993 | 4997 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4998 { | |
5575 | 4999 GaimConnection *gc = sess->aux_data; |
7283 | 5000 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 5001 va_list ap; |
5002 fu16_t maxsiglen; | |
2993 | 5003 |
5004 va_start(ap, fr); | |
4199 | 5005 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 5006 va_end(ap); |
5007 | |
8660 | 5008 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5009 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 5010 |
4617 | 5011 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
5012 | |
5013 if (od->icq) | |
7334 | 5014 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 5015 else |
7334 | 5016 aim_locate_setcaps(od->sess, caps_aim); |
5017 oscar_set_info(gc, gc->account->user_info); | |
2993 | 5018 |
5019 return 1; | |
5020 } | |
5021 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5022 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
|
5023 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5024 fu16_t maxbuddies, maxwatchers; |
5575 | 5025 GaimConnection *gc = sess->aux_data; |
7283 | 5026 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5027 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5028 va_start(ap, fr); |
4199 | 5029 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5030 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5031 va_end(ap); |
5032 | |
8660 | 5033 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5034 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5035 |
4617 | 5036 od->rights.maxbuddies = (guint)maxbuddies; |
5037 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5038 |
2086 | 5039 return 1; |
5040 } | |
5041 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5042 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5043 GaimConnection *gc = sess->aux_data; |
7283 | 5044 OscarData *od = (OscarData *)gc->proto_data; |
10570 | 5045 GaimAccount *account = gaim_connection_get_account(gc); |
7334 | 5046 va_list ap; |
5047 fu16_t maxpermits, maxdenies; | |
2086 | 5048 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5049 va_start(ap, fr); |
4199 | 5050 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5051 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5052 va_end(ap); |
5053 | |
8660 | 5054 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5055 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5056 |
4617 | 5057 od->rights.maxpermits = (guint)maxpermits; |
5058 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5059 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5060 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5061 serv_finish_login(gc); |
5062 | |
8660 | 5063 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5064 |
2672 | 5065 aim_clientready(sess, fr->conn); |
5948 | 5066 aim_srv_setavailmsg(sess, NULL); |
7474 | 5067 aim_srv_setidle(sess, 0); |
4617 | 5068 |
4664 | 5069 if (od->icq) { |
5070 aim_icq_reqofflinemsgs(sess); | |
10570 | 5071 aim_icq_setsecurity(sess, |
5072 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
5073 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE), | |
5074 gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP)); | |
4664 | 5075 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5076 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5077 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5078 if (sess->authinfo->email) |
5079 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5080 |
5081 return 1; | |
5082 } | |
5083 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5084 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
|
5085 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5086 struct aim_icq_offlinemsg *msg; |
4075 | 5087 struct aim_incomingim_ch4_args args; |
5088 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5089 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5090 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5091 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5092 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5093 |
8660 | 5094 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5095 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5096 args.uin = msg->sender; |
5097 args.type = msg->type; | |
4173 | 5098 args.flags = msg->flags; |
4076 | 5099 args.msglen = msg->msglen; |
4075 | 5100 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5101 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5102 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5103 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5104 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5105 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5106 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5107 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
|
5108 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5109 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5110 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5111 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5112 |
7388 | 5113 #if 0 |
5114 /* | |
7465 | 5115 * Update, 2003-11-09: |
5116 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5117 * | |
7388 | 5118 * It may not be my place to do this, but... |
5119 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5120 * stupid, and should not exist for % switches (%x in our case) that request | |
5121 * a year in the preferred representation for the current locale. For that | |
5122 * reason I've chosen to not use this workaround (n., see kluge). | |
5123 * | |
5124 * I have a date. I want to show it to the user in the "preferred" way. | |
5125 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5126 * what the locale wanted. | |
5127 * | |
5128 * If I have a necessity for a full representation of the year in the current | |
5129 * locale, then I'll use a switch that returns a full representation of the | |
5130 * year. | |
5131 * | |
5132 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5133 * (because you're anal, or whatever), then change the f***ing locale. | |
5134 * | |
5135 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5136 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5137 * |
5138 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5139 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5140 */ |
5141 | |
5142 /* | |
5143 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5144 * "last 2 digits" warning. |
5145 */ | |
10157 | 5146 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5147 const struct tm *tm) |
5148 { | |
5149 return strftime(s, max, fmt, tm); | |
5150 } | |
7388 | 5151 #endif |
7386 | 5152 |
4624 | 5153 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
|
5154 { |
5575 | 5155 GaimConnection *gc = sess->aux_data; |
8670 | 5156 OscarData *od = (OscarData *)gc->proto_data; |
5157 GaimBuddy *buddy; | |
8853 | 5158 struct buddyinfo *bi = NULL; |
4624 | 5159 gchar who[16]; |
8670 | 5160 GString *str; |
5161 gchar *primary, *utf8; | |
9634 | 5162 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5163 va_list ap; |
4151 | 5164 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5165 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5166 va_start(ap, fr); |
4151 | 5167 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5168 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5169 |
4664 | 5170 if (!info->uin) |
5171 return 0; | |
5172 | |
8670 | 5173 str = g_string_sized_new(100); |
5556 | 5174 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5175 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5176 if (buddy != NULL) | |
5177 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5178 | |
5179 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5180 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5181 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5182 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5183 (bi->ipaddr & 0xff000000) >> 24, | |
5184 (bi->ipaddr & 0x00ff0000) >> 16, | |
5185 (bi->ipaddr & 0x0000ff00) >> 8, | |
5186 (bi->ipaddr & 0x000000ff)); | |
8701 | 5187 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5188 g_free(tstr); |
5189 } | |
8701 | 5190 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5191 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5192 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5193 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5194 g_free(utf8); | |
4625 | 5195 } |
5196 if (info->numaddresses && info->email2) { | |
5197 int i; | |
5198 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5199 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5200 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5201 g_free(utf8); | |
4643 | 5202 } |
4625 | 5203 } |
4624 | 5204 } |
8701 | 5205 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5206 if (info->gender != 0) |
5207 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5208 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5209 char date[30]; |
5210 struct tm tm; | |
5211 tm.tm_mday = (int)info->birthday; | |
5212 tm.tm_mon = (int)info->birthmonth-1; | |
5213 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5214 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5215 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5216 } |
4624 | 5217 if (info->age) { |
5218 char age[5]; | |
5219 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5220 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5221 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5222 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5223 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5224 g_free(utf8); | |
4819 | 5225 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5226 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5227 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5228 g_free(utf8); | |
5229 } | |
5230 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5231 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5232 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5233 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5234 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5235 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5236 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5237 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5238 } |
4641 | 5239 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5240 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5241 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5242 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5243 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5244 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5245 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5246 } |
4641 | 5247 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5248 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5249 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5250 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5251 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5252 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5253 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5254 g_free(utf8); | |
4624 | 5255 } |
8670 | 5256 g_string_append_printf(str, "\n<hr>\n"); |
5257 } | |
5258 | |
9634 | 5259 if (buddy != NULL) |
5260 alias = gaim_buddy_get_alias(buddy); | |
5261 else | |
5262 alias = who; | |
5263 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5264 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5265 g_free(primary); |
8670 | 5266 g_string_free(str, TRUE); |
4151 | 5267 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5268 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5269 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5270 |
4759 | 5271 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5272 { | |
5575 | 5273 GaimConnection *gc = sess->aux_data; |
4820 | 5274 gchar who[16], *utf8; |
6695 | 5275 GaimBuddy *b; |
4759 | 5276 va_list ap; |
5277 struct aim_icq_info *info; | |
5278 | |
5279 va_start(ap, fr); | |
5280 info = va_arg(ap, struct aim_icq_info *); | |
5281 va_end(ap); | |
5282 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5283 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5284 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5285 serv_got_alias(gc, who, utf8); |
4759 | 5286 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5287 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5288 } |
4820 | 5289 g_free(utf8); |
4759 | 5290 } |
5291 | |
5292 return 1; | |
5293 } | |
5294 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5295 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
|
5296 { |
7032 | 5297 GaimConnection *gc = sess->aux_data; |
5298 gchar *text; | |
5299 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5300 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5301 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5302 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5303 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5304 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5305 url = va_arg(ap, char *); |
4199 | 5306 wid = (fu16_t) va_arg(ap, int); |
5307 hei = (fu16_t) va_arg(ap, int); | |
5308 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5309 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5310 |
7032 | 5311 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5312 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5313 g_free(text); | |
2768
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 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5316 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5317 |
7032 | 5318 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5319 { | |
6873 | 5320 GaimConnection *gc = sess->aux_data; |
5321 gchar *secondary; | |
10439 | 5322 gchar **screennames; |
6873 | 5323 int i, num; |
2086 | 5324 va_list ap; |
6873 | 5325 char *email, *SNs; |
2086 | 5326 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5327 va_start(ap, fr); |
6873 | 5328 email = va_arg(ap, char *); |
2086 | 5329 num = va_arg(ap, int); |
5330 SNs = va_arg(ap, char *); | |
5331 va_end(ap); | |
5332 | |
10439 | 5333 /* TODO: Need to use ngettext() here */ |
8152 | 5334 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5335 |
5336 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5337 for (i = 0; i < num; i++) |
10439 | 5338 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5339 screennames[num] = NULL; | |
5340 | |
5341 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5342 (const char **)screennames, NULL, NULL); | |
6873 | 5343 |
5344 g_free(secondary); | |
10439 | 5345 g_strfreev(screennames); |
2086 | 5346 |
5347 return 1; | |
5348 } | |
5349 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5350 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5351 va_list ap; |
6873 | 5352 char *email; |
5420 | 5353 char *buf; |
2086 | 5354 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5355 va_start(ap, fr); |
6873 | 5356 email = va_arg(ap, char *); |
2086 | 5357 va_end(ap); |
5358 | |
6873 | 5359 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
|
5360 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5361 g_free(buf); |
2086 | 5362 |
5363 return 1; | |
5364 } | |
5365 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5366 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5367 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5368 fu16_t status; |
2086 | 5369 va_list ap; |
5370 char msg[256]; | |
5371 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5372 va_start(ap, fr); |
4199 | 5373 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5374 va_end(ap); |
5375 | |
8660 | 5376 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5377 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5378 status ? "unknown" : "email sent"); |
5379 if (!status) { | |
5302 | 5380 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5381 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5382 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5383 } |
5384 | |
5385 return 1; | |
5386 } | |
5387 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5388 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5389 GaimConnection *gc = sess->aux_data; |
2086 | 5390 va_list ap; |
3912 | 5391 fu16_t perms, err; |
5392 char *url, *sn, *email; | |
5393 int change; | |
2086 | 5394 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5395 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5396 change = va_arg(ap, int); |
4199 | 5397 perms = (fu16_t) va_arg(ap, unsigned int); |
5398 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5399 url = va_arg(ap, char *); |
5400 sn = va_arg(ap, char *); | |
5401 email = va_arg(ap, char *); | |
2086 | 5402 va_end(ap); |
5403 | |
8660 | 5404 gaim_debug_misc("oscar", |
9626 | 5405 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5406 change ? "change" : "request", perms, err, | |
5407 (url != NULL) ? url : "(null)", | |
5408 (sn != NULL) ? sn : "(null)", | |
5409 (email != NULL) ? email : "(null)"); | |
5410 | |
5411 if ((err > 0) && (url != NULL)) { | |
3912 | 5412 char *dialog_msg; |
5413 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5414 switch (err) { | |
5415 case 0x0001: { | |
5416 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5417 } break; | |
5418 case 0x0006: { | |
5419 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5420 } break; | |
5421 case 0x000b: { | |
5422 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5423 } break; | |
5424 case 0x001d: { | |
5425 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); | |
5426 } break; | |
5427 case 0x0021: { | |
5428 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); | |
5429 } break; | |
5430 case 0x0023: { | |
5431 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5432 } break; | |
5433 default: { | |
5434 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5435 } break; | |
5436 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5437 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5438 g_free(dialog_top); |
5439 g_free(dialog_msg); | |
5440 return 1; | |
5441 } | |
5442 | |
9626 | 5443 if (sn != NULL) { |
4585 | 5444 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
|
5445 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5446 g_free(dialog_msg); |
5447 } | |
5448 | |
9626 | 5449 if (email != NULL) { |
5575 | 5450 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5451 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5452 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5453 g_free(dialog_msg); |
2086 | 5454 } |
5455 | |
5456 return 1; | |
5457 } | |
5458 | |
5575 | 5459 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5460 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5461 aim_flap_nop(od->sess, od->conn); |
2086 | 5462 } |
5463 | |
6059 | 5464 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5465 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5466 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5467 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5468 if (typing == GAIM_TYPING) |
4870 | 5469 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5470 else if (typing == GAIM_TYPED) |
4870 | 5471 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5472 else | |
5473 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5474 else { |
5300 | 5475 /* Don't send if this turkey is in our deny list */ |
5476 GSList *list; | |
5477 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5478 if (!list) { | |
7261 | 5479 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5480 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5481 if (typing == GAIM_TYPING) |
5300 | 5482 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5483 else if (typing == GAIM_TYPED) |
5300 | 5484 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5485 else | |
5486 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5487 } | |
3595 | 5488 } |
5489 } | |
2993 | 5490 return 0; |
5491 } | |
9030 | 5492 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5493 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
|
5494 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5495 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5496 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5497 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5498 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
|
5499 int ret = 0; |
10246 | 5500 const char *iconfile = gaim_account_get_buddy_icon(account); |
8800 | 5501 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5502 |
4838 | 5503 if (dim && dim->connected) { |
5504 /* If we're directly connected, send a direct IM */ | |
6982 | 5505 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5506 } else { |
4738 | 5507 struct buddyinfo *bi; |
3008 | 5508 struct aim_sendimext_args args; |
5509 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5510 gsize len; |
10246 | 5511 GaimConversation *conv; |
5512 | |
5513 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5514 |
5515 if (strstr(message, "<IMG ")) | |
5516 gaim_conversation_write(conv, "", | |
5517 _("Your IM Image was not sent. " | |
5518 "You must be Direct Connected to send IM Images."), | |
5519 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5520 |
10246 | 5521 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5522 if (!bi) { |
5523 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5524 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5525 } |
5526 | |
3008 | 5527 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5528 if (od->icq) { |
5529 args.features = features_icq; | |
5530 args.featureslen = sizeof(features_icq); | |
3008 | 5531 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5532 } else { |
5533 args.features = features_aim; | |
5534 args.featureslen = sizeof(features_aim); | |
4972 | 5535 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5536 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5537 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5538 } |
4269 | 5539 |
4738 | 5540 if (bi->ico_need) { |
8660 | 5541 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5542 "Sending buddy icon request with message\n"); |
3008 | 5543 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5544 bi->ico_need = FALSE; |
3008 | 5545 } |
4269 | 5546 |
5575 | 5547 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5548 FILE *file = fopen(iconfile, "rb"); |
3008 | 5549 if (file) { |
5550 char *buf = g_malloc(st.st_size); | |
9532 | 5551 /* XXX - Use g_file_get_contents()? */ |
3008 | 5552 fread(buf, 1, st.st_size, file); |
6039 | 5553 fclose(file); |
4269 | 5554 |
3008 | 5555 args.iconlen = st.st_size; |
4617 | 5556 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5557 args.iconstamp = st.st_mtime; |
5558 | |
7406 | 5559 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5560 bi->ico_informed = FALSE; |
7406 | 5561 bi->ico_sent = FALSE; |
5562 } | |
4738 | 5563 |
5564 if (!bi->ico_informed) { | |
8660 | 5565 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5566 "Claiming to have a buddy icon\n"); |
4738 | 5567 args.flags |= AIM_IMFLAGS_HASICON; |
5568 bi->ico_me_len = args.iconlen; | |
5569 bi->ico_me_csum = args.iconsum; | |
5570 bi->ico_me_time = args.iconstamp; | |
5571 bi->ico_informed = TRUE; | |
5572 } | |
5573 | |
3008 | 5574 g_free(buf); |
2086 | 5575 } |
5576 } | |
4269 | 5577 |
3008 | 5578 args.destsn = name; |
4269 | 5579 |
8985 | 5580 /* |
5581 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5582 * strip all HTML | |
5583 */ | |
9975 | 5584 if (aim_sn_is_icq(name) ) { |
8995 | 5585 /* being sent to an ICQ user */ |
10246 | 5586 if (!aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5587 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5588 tmpmsg = gaim_str_add_cr(message); | |
5589 } else { | |
5590 /* from an ICQ user - do nothing */ | |
5591 tmpmsg = g_strdup(message); | |
5592 } | |
5593 } else { | |
5594 /* being sent to an AIM user */ | |
10246 | 5595 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5596 /* from an ICQ user */ |
5597 tmpmsg2 = gaim_strdup_withhtml(message); | |
5598 tmpmsg = gaim_escape_html(tmpmsg2); | |
5599 g_free(tmpmsg2); | |
5600 } else | |
5601 tmpmsg = gaim_strdup_withhtml(message); | |
5602 } | |
6310 | 5603 len = strlen(tmpmsg); |
5604 | |
9830 | 5605 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5606 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5607 args.charset, args.charsubset, args.msglen); | |
4617 | 5608 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5609 g_free((char *)args.msg); |
2086 | 5610 } |
4838 | 5611 |
6310 | 5612 g_free(tmpmsg); |
5613 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5614 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5615 return 1; |
6310 | 5616 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5617 return ret; |
2086 | 5618 } |
5619 | |
7011 | 5620 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5621 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5622 |
9975 | 5623 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5624 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5625 else |
7235 | 5626 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5627 } |
5628 | |
8950 | 5629 #if 0 |
7011 | 5630 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5631 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5632 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5633 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5634 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5635 maiden, NULL, NULL, city, state, NULL, 0, web); |
5636 } | |
8950 | 5637 #endif |
2086 | 5638 |
5575 | 5639 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5640 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5641 aim_srv_setidle(od->sess, time); |
2086 | 5642 } |
5643 | |
5954 | 5644 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5645 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5646 int charset = 0; |
6019 | 5647 char *text_html = NULL; |
5129 | 5648 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5649 gsize msglen = 0; |
2993 | 5650 |
4617 | 5651 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5652 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5653 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5654 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5655 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5656 "again when you are fully connected.")); |
4617 | 5657 |
7334 | 5658 if (!text) { |
5659 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5660 return; | |
5661 } | |
10097 | 5662 |
7334 | 5663 text_html = gaim_strdup_withhtml(text); |
9807 | 5664 charset = oscar_charset_check(text_html); |
9826 | 5665 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5666 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5667 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5668 g_free(msg); | |
9826 | 5669 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5670 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5671 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5672 g_free(msg); | |
5673 } else { | |
5674 msglen = strlen(text_html); | |
5675 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5676 } | |
5677 | |
5678 if (msglen > od->rights.maxsiglen) { | |
5679 gchar *errstr; | |
5680 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5681 "has been exceeded. Gaim has truncated it for you.", | |
5682 "The maximum profile length of %d bytes " | |
5683 "has been exceeded. Gaim has truncated it for you.", | |
5684 od->rights.maxsiglen), od->rights.maxsiglen); | |
5685 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5686 g_free(errstr); | |
5687 } | |
5688 | |
5689 g_free(text_html); | |
2993 | 5690 |
5691 return; | |
2086 | 5692 } |
5693 | |
9991 | 5694 static void |
5695 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5696 { |
9991 | 5697 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5698 OscarData *od = NULL; |
9992 | 5699 GaimStatusType *status_type; |
9991 | 5700 GaimStatusPrimitive primitive; |
5701 GaimPresence *presence; | |
5702 const gchar *status_id; | |
9807 | 5703 int charset = 0; |
10196 | 5704 const gchar *text_html = NULL; |
5129 | 5705 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5706 gsize msglen = 0; |
2993 | 5707 |
9992 | 5708 status_type = gaim_status_get_type(status); |
5709 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5710 status_id = gaim_status_get_id(status); |
5711 presence = gaim_account_get_presence(account); | |
5712 | |
10196 | 5713 gaim_debug_info("oscar", "Setting status to %s\n", status_id); |
5714 | |
10400 | 5715 if (gc) |
5716 od = (OscarData *)gc->proto_data; | |
10401 | 5717 |
5718 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { | |
9991 | 5719 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5720 _("You have probably requested to set your " |
5721 "away message before the login procedure " | |
5722 "completed. You remain in a \"present\" " | |
5723 "state; try setting it again when you are " | |
5724 "fully connected.")); | |
10401 | 5725 return; |
5726 } | |
5129 | 5727 |
9992 | 5728 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5729 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5730 | |
7334 | 5731 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5732 |
5733 text_html = gaim_status_get_attr_string(status, "message"); | |
5734 if (text_html != NULL) { | |
5735 aim_srv_setavailmsg(od->sess, text_html); | |
5736 } | |
10196 | 5737 |
5738 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5739 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5740 | |
10196 | 5741 text_html = gaim_status_get_attr_string(status, "message"); |
5742 | |
5743 if (text_html == NULL) { | |
5744 text_html = _("Away"); | |
5745 } | |
5746 | |
5747 charset = oscar_charset_check(text_html); | |
5748 if (charset == AIM_CHARSET_UNICODE) { | |
5749 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5750 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5751 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5752 g_free(msg); | |
5753 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5754 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5755 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5756 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5757 g_free(msg); | |
5758 } else { | |
5759 msglen = strlen(text_html); | |
5760 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5761 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5762 } | |
5763 | |
5764 if (msglen > od->rights.maxawaymsglen) { | |
5765 gchar *errstr; | |
5766 | |
5767 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
5768 "has been exceeded. Gaim has truncated it for you.", | |
5769 "The maximum away message length of %d bytes " | |
5770 "has been exceeded. Gaim has truncated it for you.", | |
5771 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5772 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5773 g_free(errstr); | |
5774 } | |
5775 | |
10197 | 5776 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5777 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5778 | |
5129 | 5779 } else { |
10196 | 5780 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5781 | |
5782 } | |
2993 | 5783 } |
5784 | |
9991 | 5785 static void |
5786 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5787 { |
9991 | 5788 GaimConnection *gc = gaim_account_get_connection(account); |
5789 OscarData *od = (OscarData *)gc->proto_data; | |
5790 const gchar *status_id = gaim_status_get_id(status); | |
5791 | |
5792 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) | |
5575 | 5793 account->perm_deny = 4; |
8265 | 5794 else |
5575 | 5795 account->perm_deny = 3; |
9991 | 5796 |
8265 | 5797 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5798 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5799 |
9991 | 5800 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5801 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5802 |
5803 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5804 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5805 |
5806 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5807 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5808 |
5809 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5810 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5811 |
5812 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5813 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5814 |
5815 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5816 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5817 |
5818 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5819 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5820 |
5821 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5822 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5823 |
5824 return; | |
5825 } | |
5826 | |
9991 | 5827 static void |
5828 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5829 { |
9991 | 5830 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5831 GaimStatusType *type = gaim_status_get_type(status); |
5832 int primitive = gaim_status_type_get_primitive(type); | |
5833 | |
10498 | 5834 if (!gaim_status_is_active(status)) |
10485 | 5835 return; |
5836 | |
10400 | 5837 if (primitive == !GAIM_STATUS_OFFLINE && !gc) { |
5838 gaim_account_connect(account, status); | |
5839 } else if (primitive == GAIM_STATUS_OFFLINE && gc) { | |
5840 gaim_account_disconnect(account); | |
5841 } else { | |
5842 | |
5843 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
5844 oscar_set_status_icq(account, status); | |
5845 else | |
10560 | 5846 /* QQQ - Should probably also set this for ICQ */ |
10400 | 5847 oscar_set_status_aim(account, status); |
5848 } | |
2993 | 5849 return; |
2086 | 5850 } |
5851 | |
9991 | 5852 static void |
5853 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5854 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5855 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5856 } |
5857 | |
9285 | 5858 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5859 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5860 |
5861 if (!aim_snvalid(buddy->name)) { | |
8092 | 5862 gchar *buf; |
9285 | 5863 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 | 5864 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5865 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5866 g_free(buf); |
8150 | 5867 |
5868 /* Remove from local list */ | |
9285 | 5869 gaim_blist_remove_buddy(buddy); |
8150 | 5870 |
8092 | 5871 return; |
5872 } | |
5873 | |
4230 | 5874 #ifdef NOSSI |
9285 | 5875 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5876 #else |
9285 | 5877 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5878 if (buddy && group) { | |
8660 | 5879 gaim_debug_info("oscar", |
9285 | 5880 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5881 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5882 } |
5883 } | |
5884 #endif | |
8150 | 5885 |
10157 | 5886 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5887 if (od->icq) |
9285 | 5888 aim_icq_getalias(od->sess, buddy->name); |
5889 } | |
5890 | |
5891 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5892 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5893 #ifdef NOSSI |
5894 char buf[MSG_LEN]; | |
5895 int n=0; | |
9285 | 5896 |
4230 | 5897 while (buddies) { |
9381 | 5898 GaimBuddy *buddy = buddies->data; |
4230 | 5899 if (n > MSG_LEN - 18) { |
7285 | 5900 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5901 n = 0; |
3092 | 5902 } |
9381 | 5903 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5904 buddies = buddies->next; |
5905 } | |
7285 | 5906 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5907 #else |
9285 | 5908 |
4230 | 5909 if (od->sess->ssi.received_data) { |
9285 | 5910 GList *curb = buddies; |
5911 GList *curg = groups; | |
5912 while ((curb != NULL) && (curg != NULL)) { | |
5913 GaimBuddy *buddy = curb->data; | |
5914 GaimGroup *group = curg->data; | |
5915 oscar_add_buddy(gc, buddy, group); | |
5916 curb = curb->next; | |
5917 curg = curg->next; | |
4230 | 5918 } |
5919 } | |
5920 #endif | |
5921 } | |
5922 | |
9285 | 5923 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5924 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5925 |
4230 | 5926 #ifdef NOSSI |
9285 | 5927 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5928 #else |
5929 if (od->sess->ssi.received_data) { | |
8660 | 5930 gaim_debug_info("oscar", |
9285 | 5931 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5932 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5933 } |
5934 #endif | |
5935 } | |
5936 | |
9285 | 5937 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5938 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5939 |
4230 | 5940 #ifdef NOSSI |
9285 | 5941 for (cur = buddies; cur != NULL; cur = cur->next) { |
5942 GaimBuddy *buddy = cur->data; | |
5943 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5944 } | |
4230 | 5945 #else |
5946 if (od->sess->ssi.received_data) { | |
9285 | 5947 GList *curb = buddies; |
5948 GList *curg = groups; | |
5949 while ((curb != NULL) && (curg != NULL)) { | |
5950 GaimBuddy *buddy = curb->data; | |
5951 GaimGroup *group = curg->data; | |
5952 oscar_remove_buddy(gc, buddy, group); | |
5953 curb = curb->next; | |
5954 curg = curg->next; | |
3092 | 5955 } |
4230 | 5956 } |
5957 #endif | |
5958 } | |
5959 | |
5960 #ifndef NOSSI | |
5575 | 5961 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5962 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5963 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5964 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5965 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5966 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5967 } |
5968 } | |
5969 | |
5575 | 5970 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5971 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5972 if (od->sess->ssi.received_data) { |
5973 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5974 if (gname) { | |
8660 | 5975 gaim_debug_info("oscar", |
9586 | 5976 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5977 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5978 } |
5979 } | |
5980 } | |
5981 | |
9285 | 5982 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5983 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5984 |
5985 if (od->sess->ssi.received_data) { | |
9285 | 5986 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5987 GList *cur, *groups = NULL; | |
5988 | |
5989 /* Make a list of what the groups each buddy is in */ | |
5990 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5991 GaimBlistNode *node = cur->data; | |
5992 groups = g_list_append(groups, node->parent); | |
5993 } | |
5994 | |
5995 oscar_remove_buddies(gc, moved_buddies, groups); | |
5996 oscar_add_buddies(gc, moved_buddies, groups); | |
5997 g_list_free(groups); | |
8660 | 5998 gaim_debug_info("oscar", |
9285 | 5999 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 6000 } else { |
9285 | 6001 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 6002 gaim_debug_info("oscar", |
9285 | 6003 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 6004 } |
6005 } | |
6006 } | |
6007 | |
5968 | 6008 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
6009 aim_session_t *sess = data; | |
6350 | 6010 aim_ssi_reqdata(sess); |
5968 | 6011 return FALSE; |
6012 } | |
6013 | |
4642 | 6014 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6015 GaimConnection *gc = sess->aux_data; |
7283 | 6016 OscarData *od = gc->proto_data; |
4642 | 6017 va_list ap; |
6018 fu16_t reason; | |
6019 | |
6020 va_start(ap, fr); | |
6021 reason = (fu16_t)va_arg(ap, unsigned int); | |
6022 va_end(ap); | |
6023 | |
8660 | 6024 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 6025 |
6026 if (reason == 0x0005) { | |
5892 | 6027 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 6028 _("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
|
6029 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 6030 } |
6031 | |
6032 /* Activate SSI */ | |
6033 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6034 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6035 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 6036 aim_ssi_enable(od->sess); |
6037 | |
6038 return 1; | |
6039 } | |
6040 | |
2991 | 6041 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6042 GaimConnection *gc = sess->aux_data; |
7283 | 6043 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 6044 int i; |
6045 va_list ap; | |
6046 int numtypes; | |
4230 | 6047 fu16_t *maxitems; |
2991 | 6048 |
6049 va_start(ap, fr); | |
4230 | 6050 numtypes = va_arg(ap, int); |
6051 maxitems = va_arg(ap, fu16_t *); | |
2991 | 6052 va_end(ap); |
6053 | |
8660 | 6054 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6055 |
4230 | 6056 for (i=0; i<numtypes; i++) |
8660 | 6057 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6058 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6059 |
8660 | 6060 gaim_debug_misc(NULL, "\n"); |
4230 | 6061 |
6062 if (numtypes >= 0) | |
6063 od->rights.maxbuddies = maxitems[0]; | |
6064 if (numtypes >= 1) | |
6065 od->rights.maxgroups = maxitems[1]; | |
6066 if (numtypes >= 2) | |
6067 od->rights.maxpermits = maxitems[2]; | |
6068 if (numtypes >= 3) | |
6069 od->rights.maxdenies = maxitems[3]; | |
2991 | 6070 |
6071 return 1; | |
6072 } | |
6073 | |
6074 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6075 GaimConnection *gc = sess->aux_data; |
6076 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6077 GaimStatus *status; |
7283 | 6078 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6079 GaimGroup *g; |
6080 GaimBuddy *b; | |
2995 | 6081 struct aim_ssi_item *curitem; |
2991 | 6082 int tmp; |
4230 | 6083 va_list ap; |
8219 | 6084 fu16_t fmtver, numitems; |
6085 struct aim_ssi_item *items; | |
6086 fu32_t timestamp; | |
4230 | 6087 |
6088 va_start(ap, fr); | |
6089 fmtver = (fu16_t)va_arg(ap, int); | |
6090 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6091 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6092 timestamp = va_arg(ap, fu32_t); |
8219 | 6093 va_end(ap); |
2991 | 6094 |
8660 | 6095 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6096 "ssi: syncing local list and server list\n"); |
2991 | 6097 |
8219 | 6098 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 6099 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 | 6100 return 1; |
6101 } | |
6102 | |
2991 | 6103 /* Clean the buddy list */ |
4889 | 6104 aim_ssi_cleanlist(sess); |
2991 | 6105 |
8150 | 6106 { /* If not in server list then prune from local list */ |
6107 GaimBlistNode *gnode, *cnode, *bnode; | |
6108 GaimBuddyList *blist; | |
9539 | 6109 GSList *cur, *next; |
8150 | 6110 |
6111 /* Buddies */ | |
6112 cur = NULL; | |
6113 if ((blist = gaim_get_blist()) != NULL) { | |
6114 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6115 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6116 continue; | |
6117 g = (GaimGroup *)gnode; | |
6118 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6119 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6120 continue; | |
6121 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6122 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6123 continue; | |
6124 b = (GaimBuddy *)bnode; | |
6125 if (b->account == gc->account) { | |
6126 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6127 /* If the buddy is an ICQ user then load his nickname */ | |
6128 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6129 char *alias; |
8150 | 6130 if (servernick) |
6131 serv_got_alias(gc, b->name, servernick); | |
6132 | |
6133 /* Store local alias on server */ | |
8214 | 6134 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6135 if (!alias && b->alias && strlen(b->alias)) |
6136 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6137 free(alias); | |
6138 } else { | |
8660 | 6139 gaim_debug_info("oscar", |
8150 | 6140 "ssi: removing buddy %s from local list\n", b->name); |
6141 /* We can't actually remove now because it will screw up our looping */ | |
6142 cur = g_slist_prepend(cur, b); | |
6143 } | |
6144 } | |
6145 } | |
6146 } | |
6147 } | |
6148 } | |
8175 | 6149 |
8150 | 6150 while (cur != NULL) { |
6151 b = cur->data; | |
6152 cur = g_slist_remove(cur, b); | |
6153 gaim_blist_remove_buddy(b); | |
6154 } | |
6155 | |
6156 /* Permit list */ | |
6157 if (gc->account->permit) { | |
9539 | 6158 next = gc->account->permit; |
6159 while (next != NULL) { | |
6160 cur = next; | |
6161 next = next->next; | |
8150 | 6162 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6163 gaim_debug_info("oscar", |
8150 | 6164 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6165 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6166 } | |
9539 | 6167 } |
8150 | 6168 } |
6169 | |
6170 /* Deny list */ | |
6171 if (gc->account->deny) { | |
9539 | 6172 next = gc->account->deny; |
6173 while (next != NULL) { | |
6174 cur = next; | |
6175 next = next->next; | |
8150 | 6176 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6177 gaim_debug_info("oscar", |
8150 | 6178 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6179 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6180 } | |
9539 | 6181 } |
8150 | 6182 } |
6183 /* Presence settings (idle time visibility) */ | |
6184 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6185 if (!(tmp & 0x400)) | |
6186 aim_ssi_setpresence(sess, tmp | 0x400); | |
6187 } /* end pruning buddies from local list */ | |
6188 | |
2991 | 6189 /* Add from server list to local list */ |
4230 | 6190 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6191 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6192 switch (curitem->type) { |
4230 | 6193 case 0x0000: { /* Buddy */ |
4251 | 6194 if (curitem->name) { |
4292 | 6195 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6196 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6197 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6198 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6199 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6200 /* Should gname be freed here? -- elb */ |
4754 | 6201 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6202 free(alias); |
8150 | 6203 if (b) { |
4292 | 6204 /* Get server stored alias */ |
4705 | 6205 if (alias_utf8) { |
8150 | 6206 g_free(b->alias); |
6207 b->alias = g_strdup(alias_utf8); | |
4705 | 6208 } |
4282 | 6209 } else { |
8150 | 6210 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6211 |
4754 | 6212 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6213 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6214 gaim_blist_add_group(g, NULL); |
6215 } | |
5146 | 6216 |
8660 | 6217 gaim_debug_info("oscar", |
9285 | 6218 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6219 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6220 } |
8341 | 6221 if (!aim_sncmp(curitem->name, account->username)) { |
6222 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6223 gaim_check_comment(od, comment); | |
6224 free(comment); | |
6225 } | |
7162 | 6226 g_free(gname_utf8); |
6227 g_free(alias_utf8); | |
2991 | 6228 } |
4230 | 6229 } break; |
6230 | |
6231 case 0x0001: { /* Group */ | |
4282 | 6232 /* Shouldn't add empty groups */ |
4230 | 6233 } break; |
6234 | |
6235 case 0x0002: { /* Permit buddy */ | |
2991 | 6236 if (curitem->name) { |
4230 | 6237 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6238 GSList *list; |
5575 | 6239 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6240 if (!list) { |
8660 | 6241 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6242 "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
|
6243 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6244 } |
6245 } | |
4230 | 6246 } break; |
6247 | |
6248 case 0x0003: { /* Deny buddy */ | |
2991 | 6249 if (curitem->name) { |
6250 GSList *list; | |
5575 | 6251 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6252 if (!list) { |
8660 | 6253 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6254 "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
|
6255 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6256 } |
6257 } | |
4230 | 6258 } break; |
6259 | |
6260 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6261 if (curitem->data) { |
6262 fu8_t permdeny; | |
5575 | 6263 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6264 gaim_debug_info("oscar", |
5575 | 6265 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6266 account->perm_deny = permdeny; | |
6267 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6268 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6269 } |
2991 | 6270 } |
6271 } | |
4230 | 6272 } break; |
6273 | |
6274 case 0x0005: { /* Presence setting */ | |
3109 | 6275 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6276 } break; |
2991 | 6277 } /* End of switch on curitem->type */ |
6278 } /* End of for loop */ | |
4230 | 6279 |
9991 | 6280 /* |
6281 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6282 * this. We probably want the SSI status setting to override the local | |
6283 * setting. | |
6284 */ | |
9982 | 6285 status = gaim_presence_get_active_status(account->presence); |
6286 if (gaim_status_is_available(status)) | |
4901 | 6287 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6288 | |
4342 | 6289 /* Activate SSI */ |
6290 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6291 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6292 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6293 "ssi: activating server-stored buddy list\n"); |
4642 | 6294 aim_ssi_enable(sess); |
4342 | 6295 |
2991 | 6296 return 1; |
2086 | 6297 } |
4230 | 6298 |
6299 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6300 GaimConnection *gc = sess->aux_data; |
4230 | 6301 va_list ap; |
6302 struct aim_ssi_tmp *retval; | |
6303 | |
6304 va_start(ap, fr); | |
6305 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6306 va_end(ap); | |
6307 | |
6308 while (retval) { | |
8660 | 6309 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6310 "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 | 6311 |
6312 if (retval->ack != 0xffff) | |
6313 switch (retval->ack) { | |
6314 case 0x0000: { /* added successfully */ | |
6315 } break; | |
6316 | |
4829 | 6317 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6318 gchar *buf; | |
6319 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 | 6320 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6321 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6322 g_free(buf); |
6323 } | |
6324 | |
7023 | 6325 case 0x000e: { /* buddy requires authorization */ |
4828 | 6326 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6327 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6328 } break; |
6329 | |
6330 default: { /* La la la */ | |
5197 | 6331 gchar *buf; |
8660 | 6332 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6333 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 | 6334 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6335 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6336 g_free(buf); |
4230 | 6337 } break; |
6338 } | |
6339 | |
6340 retval = retval->next; | |
6341 } | |
6342 | |
6343 return 1; | |
6344 } | |
6345 | |
8227 | 6346 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6347 GaimConnection *gc = sess->aux_data; | |
6348 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6349 GaimBuddy *b; | |
6350 GaimGroup *g; | |
6351 va_list ap; | |
6352 fu16_t type; | |
6353 const char *name; | |
6354 | |
6355 va_start(ap, fr); | |
6356 type = (fu16_t)va_arg(ap, int); | |
6357 name = va_arg(ap, char *); | |
6358 va_end(ap); | |
6359 | |
6360 if ((type != 0x0000) || (name == NULL)) | |
6361 return 1; | |
6362 | |
6363 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6364 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6365 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6366 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6367 b = gaim_find_buddy(gc->account, name); | |
6368 free(alias); | |
6369 | |
6370 if (b) { | |
6371 /* Get server stored alias */ | |
6372 if (alias_utf8) { | |
6373 g_free(b->alias); | |
6374 b->alias = g_strdup(alias_utf8); | |
6375 } | |
6376 } else { | |
6377 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6378 | |
6379 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6380 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6381 gaim_blist_add_group(g, NULL); | |
6382 } | |
6383 | |
8660 | 6384 gaim_debug_info("oscar", |
9285 | 6385 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6386 gaim_blist_add_buddy(b, NULL, g, NULL); |
6387 } | |
6388 g_free(gname_utf8); | |
6389 g_free(alias_utf8); | |
6390 | |
6391 return 1; | |
6392 } | |
6393 | |
4230 | 6394 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6395 GaimConnection *gc = sess->aux_data; |
4230 | 6396 va_list ap; |
6397 char *sn, *msg; | |
4236 | 6398 gchar *dialog_msg, *nombre; |
4230 | 6399 struct name_data *data; |
6695 | 6400 GaimBuddy *buddy; |
4230 | 6401 |
6402 va_start(ap, fr); | |
6403 sn = va_arg(ap, char *); | |
6404 msg = va_arg(ap, char *); | |
6405 va_end(ap); | |
6406 | |
8660 | 6407 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6408 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6409 |
4687 | 6410 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6411 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6412 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6413 else |
6414 nombre = g_strdup(sn); | |
6415 | |
6416 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 | 6417 data = g_new(struct name_data, 1); |
6418 data->gc = gc; | |
6419 data->name = g_strdup(sn); | |
6420 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6421 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6422 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6423 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6424 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6425 G_CALLBACK(oscar_free_name_data)); |
4236 | 6426 |
4230 | 6427 g_free(dialog_msg); |
4236 | 6428 g_free(nombre); |
4230 | 6429 |
6430 return 1; | |
6431 } | |
6432 | |
6433 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6434 GaimConnection *gc = sess->aux_data; |
4230 | 6435 va_list ap; |
6436 char *sn, *msg; | |
4236 | 6437 gchar *dialog_msg, *nombre; |
4230 | 6438 struct name_data *data; |
6695 | 6439 GaimBuddy *buddy; |
4230 | 6440 |
6441 va_start(ap, fr); | |
6442 sn = va_arg(ap, char *); | |
6443 msg = va_arg(ap, char *); | |
6444 va_end(ap); | |
6445 | |
8660 | 6446 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6447 "ssi: received authorization request from %s\n", sn); |
4230 | 6448 |
4687 | 6449 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6450 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6451 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6452 else |
6453 nombre = g_strdup(sn); | |
6454 | |
4337 | 6455 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
4230 | 6456 data = g_new(struct name_data, 1); |
6457 data->gc = gc; | |
6458 data->name = g_strdup(sn); | |
6459 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6460 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6461 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6462 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6463 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6464 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6465 |
4230 | 6466 g_free(dialog_msg); |
4236 | 6467 g_free(nombre); |
4230 | 6468 |
6469 return 1; | |
6470 } | |
6471 | |
6472 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6473 GaimConnection *gc = sess->aux_data; |
4230 | 6474 va_list ap; |
6475 char *sn, *msg; | |
4236 | 6476 gchar *dialog_msg, *nombre; |
4230 | 6477 fu8_t reply; |
6695 | 6478 GaimBuddy *buddy; |
4230 | 6479 |
6480 va_start(ap, fr); | |
6481 sn = va_arg(ap, char *); | |
6482 reply = (fu8_t)va_arg(ap, int); | |
6483 msg = va_arg(ap, char *); | |
6484 va_end(ap); | |
6485 | |
8660 | 6486 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6487 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6488 |
4687 | 6489 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6490 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6491 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6492 else |
6493 nombre = g_strdup(sn); | |
6494 | |
4230 | 6495 if (reply) { |
6496 /* Granted */ | |
7023 | 6497 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
|
6498 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6499 } else { |
6500 /* Denied */ | |
7023 | 6501 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
|
6502 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6503 } |
6504 g_free(dialog_msg); | |
4236 | 6505 g_free(nombre); |
4230 | 6506 |
6507 return 1; | |
6508 } | |
6509 | |
6510 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6511 GaimConnection *gc = sess->aux_data; |
4230 | 6512 va_list ap; |
6513 char *sn; | |
6695 | 6514 GaimBuddy *buddy; |
4230 | 6515 |
6516 va_start(ap, fr); | |
6517 sn = va_arg(ap, char *); | |
6518 va_end(ap); | |
6519 | |
4687 | 6520 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6521 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6522 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6523 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6524 |
6525 return 1; | |
6526 } | |
4269 | 6527 #endif |
2086 | 6528 |
5575 | 6529 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6530 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6531 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6532 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6533 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6534 pce->label = _("_Room:"); |
5234 | 6535 pce->identifier = "room"; |
10475 | 6536 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6537 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6538 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6539 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6540 pce->label = _("_Exchange:"); |
5234 | 6541 pce->identifier = "exchange"; |
10475 | 6542 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6543 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6544 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6545 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6546 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6547 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6548 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6549 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6550 |
9754 | 6551 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6552 { | |
6553 GHashTable *defaults; | |
6554 | |
6555 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6556 | |
6557 if (chat_name != NULL) | |
6558 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6559 | |
6560 return defaults; | |
6561 } | |
6562 | |
9917 | 6563 static char *oscar_get_chat_name(GHashTable *data) { |
6564 return g_strdup(g_hash_table_lookup(data, "room")); | |
6565 } | |
6566 | |
8308 | 6567 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6568 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6569 aim_conn_t *cur; |
5234 | 6570 char *name, *exchange; |
6571 | |
6572 name = g_hash_table_lookup(data, "room"); | |
6573 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6574 |
8660 | 6575 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6576 "Attempting to join chat room %s.\n", name); |
8308 | 6577 |
6578 if ((name == NULL) || (*name == '\0')) { | |
6579 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6580 return; | |
6581 } | |
6582 | |
4617 | 6583 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6584 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6585 "chatnav exists, creating room\n"); |
5234 | 6586 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6587 } else { |
6588 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6589 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6590 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6591 "chatnav does not exist, opening chatnav\n"); |
5234 | 6592 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6593 cr->name = g_strdup(name); |
4617 | 6594 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6595 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6596 } |
6597 } | |
6598 | |
8308 | 6599 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6600 OscarData *od = (OscarData *)gc->proto_data; | |
6601 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6602 |
6603 if (ccon == NULL) | |
2086 | 6604 return; |
10404 | 6605 |
8225 | 6606 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6607 ccon->exchange, ccon->name, 0x0); |
6608 } | |
6609 | |
10458 | 6610 static void |
6611 oscar_chat_leave(GaimConnection *gc, int id) | |
6612 { | |
6613 GaimConversation *conv; | |
6614 struct chat_connection *cc; | |
6615 | |
6616 conv = gaim_find_chat(gc, id); | |
6617 | |
6618 g_return_if_fail(conv != NULL); | |
6619 | |
6620 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6621 | |
6622 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6623 oscar_chat_kill(gc, cc); | |
2086 | 6624 } |
6625 | |
8219 | 6626 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6627 OscarData *od = (OscarData *)gc->proto_data; | |
6628 GaimConversation *conv = NULL; | |
2086 | 6629 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6630 char *buf, *buf2; |
9830 | 6631 fu16_t charset, charsubset; |
9807 | 6632 char *charsetstr = NULL; |
10111 | 6633 int len; |
8219 | 6634 |
6635 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6636 return -EINVAL; |
2086 | 6637 |
8219 | 6638 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6639 return -EINVAL; |
2086 | 6640 |
8219 | 6641 buf = gaim_strdup_withhtml(message); |
6642 len = strlen(buf); | |
6643 | |
8962 | 6644 if (strstr(buf, "<IMG ")) |
6645 gaim_conversation_write(conv, "", | |
6646 _("Your IM Image was not sent. " | |
6647 "You cannot send IM Images in AIM chats."), | |
6648 GAIM_MESSAGE_ERROR, time(NULL)); | |
6649 | |
9830 | 6650 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6651 if ((len > c->maxlen) || (len > c->maxvis)) { |
6652 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6653 return -E2BIG; |
8359 | 6654 } |
6655 | |
9831 | 6656 if (charset == AIM_CHARSET_ASCII) |
6657 charsetstr = "us-ascii"; | |
6658 else if (charset == AIM_CHARSET_UNICODE) | |
6659 charsetstr = "unicode-2-0"; | |
6660 else if (charset == AIM_CHARSET_CUSTOM) | |
6661 charsetstr = "iso-8859-1"; | |
9807 | 6662 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6663 g_free(buf2); |
8359 | 6664 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6665 return 0; |
2086 | 6666 } |
6667 | |
10042 | 6668 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6669 { | |
4766 | 6670 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6671 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6672 return "icq"; |
6673 else | |
6674 return "aim"; | |
6675 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6676 |
9975 | 6677 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6678 return "icq"; |
6679 return "aim"; | |
6680 } | |
6681 | |
9972 | 6682 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6683 { |
7334 | 6684 GaimConnection *gc = NULL; |
6685 OscarData *od = NULL; | |
10042 | 6686 GaimAccount *account = NULL; |
6687 GaimPresence *presence; | |
6688 GaimStatus *status; | |
6689 const char *status_id; | |
4687 | 6690 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6691 int i = 0; | |
7334 | 6692 aim_userinfo_t *userinfo = NULL; |
6693 | |
6694 if (b != NULL) | |
6695 account = b->account; | |
6696 if (account != NULL) | |
6697 gc = account->gc; | |
6698 if (gc != NULL) | |
6699 od = gc->proto_data; | |
7945 | 6700 if (od != NULL) |
6701 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6702 |
10042 | 6703 presence = gaim_buddy_get_presence(b); |
6704 status = gaim_presence_get_active_status(presence); | |
6705 status_id = gaim_status_get_id(status); | |
6706 | |
6707 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6708 char *gname; |
7334 | 6709 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6710 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6711 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6712 emblems[i++] = "notauthorized"; | |
6713 } else { | |
6714 emblems[i++] = "offline"; | |
6715 } | |
6716 } | |
4916 | 6717 |
10042 | 6718 if (b->name && aim_sn_is_icq(b->name)) { |
6719 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6720 emblems[i++] = "invisible"; | |
6721 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6722 emblems[i++] = "freeforchat"; |
10042 | 6723 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6724 emblems[i++] = "dnd"; |
10042 | 6725 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6726 emblems[i++] = "na"; |
10042 | 6727 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6728 emblems[i++] = "occupied"; |
10042 | 6729 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6730 emblems[i++] = "away"; |
10042 | 6731 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6732 emblems[i++] = "away"; | |
6733 } | |
6734 | |
6735 if (userinfo != NULL ) { | |
6736 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6737 emblems[i++] = "unconfirmed"; */ | |
6738 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6739 emblems[i++] = "admin"; | |
6740 if (userinfo->flags & AIM_FLAG_AOL) | |
6741 emblems[i++] = "aol"; | |
6742 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6743 emblems[i++] = "wireless"; | |
6744 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6745 emblems[i++] = "activebuddy"; | |
6746 | |
6747 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6748 emblems[i++] = "hiptop"; |
6749 | |
10042 | 6750 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6751 emblems[i++] = "secure"; |
10042 | 6752 } |
7334 | 6753 |
4687 | 6754 *se = emblems[0]; |
6755 *sw = emblems[1]; | |
6756 *nw = emblems[2]; | |
6757 *ne = emblems[3]; | |
6758 } | |
6759 | |
6695 | 6760 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6761 GaimConnection *gc = b->account->gc; |
7283 | 6762 OscarData *od = gc->proto_data; |
7045 | 6763 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6764 GString *str = g_string_new(""); |
5131 | 6765 |
6766 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6767 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6768 |
6769 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6770 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6771 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6772 g_free(charset); |
7011 | 6773 if (away_utf8 != NULL) { |
7091 | 6774 gchar *tmp1, *tmp2; |
9627 | 6775 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6776 g_free(away_utf8); |
8571 | 6777 tmp1 = gaim_escape_html(tmp2); |
7091 | 6778 g_free(tmp2); |
8700 | 6779 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6780 g_free(tmp1); |
8701 | 6781 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6782 g_free(tmp2); |
5836 | 6783 } |
5131 | 6784 } |
8701 | 6785 } |
6786 | |
6787 return g_string_free(str, FALSE); | |
5131 | 6788 } |
6789 | |
10042 | 6790 static char *oscar_status_text(GaimBuddy *b) |
6791 { | |
6792 GaimConnection *gc; | |
6793 OscarData *od; | |
6794 GaimStatus *status; | |
5167 | 6795 gchar *ret = NULL; |
6796 | |
10042 | 6797 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6798 od = gc->proto_data; | |
6799 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6800 | |
6801 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6802 if (aim_sn_is_icq(b->name)) |
8701 | 6803 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6804 else |
6805 ret = g_strdup(_("Away")); | |
5836 | 6806 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6807 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6808 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6809 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6810 } else { |
5167 | 6811 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6812 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6813 ret = g_strdup(_("Not Authorized")); | |
6814 else | |
6815 ret = g_strdup(_("Offline")); | |
6816 } | |
6817 | |
6818 return ret; | |
6819 } | |
6820 | |
5842 | 6821 |
5844 | 6822 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6823 GaimConnection *gc = sess->aux_data; |
7283 | 6824 OscarData *od = gc->proto_data; |
5892 | 6825 va_list ap; |
5842 | 6826 fu16_t type; |
5892 | 6827 fu8_t flags = 0, length = 0; |
6828 char *md5 = NULL; | |
6829 | |
7334 | 6830 |
5842 | 6831 va_start(ap, fr); |
6832 type = va_arg(ap, int); | |
5892 | 6833 |
6834 switch(type) { | |
6835 case 0x0000: | |
6836 case 0x0001: { | |
6837 flags = va_arg(ap, int); | |
6838 length = va_arg(ap, int); | |
6839 md5 = va_arg(ap, char *); | |
6840 | |
6841 if (flags == 0x41) { | |
6842 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6843 od->iconconnecting = TRUE; | |
6844 od->set_icon = TRUE; | |
6845 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6846 } else { | |
6039 | 6847 struct stat st; |
6848 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6849 if (iconfile == NULL) { | |
8363 | 6850 aim_ssi_delicon(od->sess); |
6039 | 6851 } else if (!stat(iconfile, &st)) { |
6852 char *buf = g_malloc(st.st_size); | |
6853 FILE *file = fopen(iconfile, "rb"); | |
6854 if (file) { | |
9532 | 6855 /* XXX - Use g_file_get_contents()? */ |
6039 | 6856 fread(buf, 1, st.st_size, file); |
6857 fclose(file); | |
8660 | 6858 gaim_debug_info("oscar", |
10042 | 6859 "Uploading icon to icon server\n"); |
6879 | 6860 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6861 } else |
8660 | 6862 gaim_debug_error("oscar", |
10042 | 6863 "Can't open buddy icon file!\n"); |
6039 | 6864 g_free(buf); |
6865 } else { | |
8660 | 6866 gaim_debug_error("oscar", |
10042 | 6867 "Can't stat buddy icon file!\n"); |
5892 | 6868 } |
6869 } | |
8363 | 6870 } else if (flags == 0x81) { |
6871 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6872 if (iconfile == NULL) | |
6873 aim_ssi_delicon(od->sess); | |
6874 else | |
6875 aim_ssi_seticon(od->sess, md5, length); | |
6876 } | |
5892 | 6877 } break; |
6878 | |
6879 case 0x0002: { /* We just set an "available" message? */ | |
6880 } break; | |
6881 } | |
6882 | |
5842 | 6883 va_end(ap); |
5844 | 6884 |
6885 return 0; | |
5842 | 6886 } |
5892 | 6887 |
5575 | 6888 static void oscar_set_permit_deny(GaimConnection *gc) { |
6889 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6890 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6891 #ifdef NOSSI |
8143 | 6892 GSList *list; |
4230 | 6893 char buf[MAXMSGLEN]; |
6894 int at; | |
6895 | |
5575 | 6896 switch(account->perm_deny) { |
8175 | 6897 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6898 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6899 break; |
8175 | 6900 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6901 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6902 break; |
8175 | 6903 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6904 list = account->permit; |
4230 | 6905 at = 0; |
6906 while (list) { | |
6907 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6908 list = list->next; | |
6909 } | |
6910 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6911 break; | |
8175 | 6912 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6913 list = account->deny; |
4230 | 6914 at = 0; |
6915 while (list) { | |
6916 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6917 list = list->next; | |
6918 } | |
6919 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6920 break; | |
6921 default: | |
6922 break; | |
2086 | 6923 } |
4230 | 6924 #else |
8175 | 6925 if (od->sess->ssi.received_data) { |
6926 switch (account->perm_deny) { | |
6927 case GAIM_PRIVACY_ALLOW_ALL: | |
6928 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6929 break; | |
6930 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6931 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6932 break; | |
6933 case GAIM_PRIVACY_ALLOW_USERS: | |
6934 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6935 break; | |
6936 case GAIM_PRIVACY_DENY_ALL: | |
6937 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6938 break; | |
6939 case GAIM_PRIVACY_DENY_USERS: | |
6940 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6941 break; | |
6942 default: | |
6943 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6944 break; | |
6945 } | |
6946 } | |
4230 | 6947 #endif |
2086 | 6948 } |
6949 | |
5575 | 6950 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6951 #ifdef NOSSI |
8143 | 6952 if (gc->account->perm_deny == 3) |
4269 | 6953 oscar_set_permit_deny(gc); |
6954 #else | |
7283 | 6955 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6956 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6957 if (od->sess->ssi.received_data) |
4889 | 6958 aim_ssi_addpermit(od->sess, who); |
4230 | 6959 #endif |
2086 | 6960 } |
6961 | |
5575 | 6962 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6963 #ifdef NOSSI |
8143 | 6964 if (gc->account->perm_deny == 4) |
4269 | 6965 oscar_set_permit_deny(gc); |
6966 #else | |
7283 | 6967 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6968 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6969 if (od->sess->ssi.received_data) |
4889 | 6970 aim_ssi_adddeny(od->sess, who); |
4230 | 6971 #endif |
2086 | 6972 } |
6973 | |
5575 | 6974 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6975 #ifdef NOSSI |
8143 | 6976 if (gc->account->perm_deny == 3) |
4269 | 6977 oscar_set_permit_deny(gc); |
6978 #else | |
7283 | 6979 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6980 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6981 if (od->sess->ssi.received_data) |
4889 | 6982 aim_ssi_delpermit(od->sess, who); |
4230 | 6983 #endif |
2086 | 6984 } |
6985 | |
5575 | 6986 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6987 #ifdef NOSSI |
8143 | 6988 if (gc->account->perm_deny == 4) |
4269 | 6989 oscar_set_permit_deny(gc); |
6990 #else | |
7283 | 6991 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6992 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6993 if (od->sess->ssi.received_data) |
4889 | 6994 aim_ssi_deldeny(od->sess, who); |
4230 | 6995 #endif |
2086 | 6996 } |
6997 | |
9975 | 6998 static GList * |
6999 oscar_status_types(GaimAccount *account) | |
2086 | 7000 { |
9975 | 7001 GList *status_types = NULL; |
7002 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
7003 |
9973 | 7004 g_return_val_if_fail(account != NULL, NULL); |
7005 | |
10042 | 7006 /* Oscar-common status types */ |
9991 | 7007 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
7008 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 7009 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 7010 status_types = g_list_append(status_types, type); |
7011 | |
9991 | 7012 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
7013 OSCAR_STATUS_ID_ONLINE, | |
10400 | 7014 _("Online"), FALSE, TRUE, FALSE); |
9976 | 7015 status_types = g_list_append(status_types, type); |
7016 | |
10198 | 7017 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
7018 OSCAR_STATUS_ID_AVAILABLE, | |
7019 _("Available"), TRUE, TRUE, FALSE, | |
7020 "message", _("Message"), | |
7021 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 7022 status_types = g_list_append(status_types, type); |
7023 | |
10195 | 7024 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
7025 OSCAR_STATUS_ID_AWAY, | |
7026 _("Away"), TRUE, TRUE, FALSE, | |
7027 "message", _("Message"), | |
7028 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 7029 status_types = g_list_append(status_types, type); |
7030 | |
7031 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
7032 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 7033 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 7034 status_types = g_list_append(status_types, type); |
7035 | |
7036 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
7037 return status_types; | |
7038 | |
7039 /* ICQ-specific status types */ | |
7040 | |
9991 | 7041 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
7042 OSCAR_STATUS_ID_FREE4CHAT, | |
7043 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 7044 status_types = g_list_append(status_types, type); |
7045 | |
9991 | 7046 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
7047 OSCAR_STATUS_ID_OCCUPIED, | |
7048 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 7049 status_types = g_list_append(status_types, type); |
7050 | |
9991 | 7051 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7052 OSCAR_STATUS_ID_DND, | |
7053 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 7054 status_types = g_list_append(status_types, type); |
7055 | |
9991 | 7056 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7057 OSCAR_STATUS_ID_NA, | |
7058 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 7059 status_types = g_list_append(status_types, type); |
9975 | 7060 |
7061 return status_types; | |
4333 | 7062 } |
7063 | |
7172 | 7064 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 7065 GaimConnection *gc = data->gc; |
7066 OscarData *od = gc->proto_data; | |
7172 | 7067 GaimBuddy *b; |
7068 GaimGroup *g; | |
7069 | |
7070 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
7071 oscar_free_name_data(data); | |
7072 return; | |
7073 } | |
7074 | |
7075 if (!(g = gaim_find_buddys_group(b))) { | |
7076 oscar_free_name_data(data); | |
7077 return; | |
7078 } | |
7079 | |
7080 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 7081 |
7082 if (!aim_sncmp(data->name, gc->account->username)) | |
7083 gaim_check_comment(od, text); | |
7084 | |
7172 | 7085 oscar_free_name_data(data); |
7086 } | |
7087 | |
9030 | 7088 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
7089 | |
7090 GaimBuddy *buddy; | |
7091 GaimConnection *gc; | |
7092 OscarData *od; | |
7093 struct name_data *data; | |
7172 | 7094 GaimGroup *g; |
7095 char *comment; | |
7096 gchar *comment_utf8; | |
9631 | 7097 gchar *title; |
7172 | 7098 |
9030 | 7099 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
7100 | |
7101 buddy = (GaimBuddy *) node; | |
7102 gc = gaim_account_get_connection(buddy->account); | |
7103 od = gc->proto_data; | |
7104 | |
7105 data = g_new(struct name_data, 1); | |
7106 | |
7107 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 7108 return; |
9030 | 7109 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 7110 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
7111 | |
7112 data->gc = gc; | |
9030 | 7113 data->name = g_strdup(buddy->name); |
7172 | 7114 data->nick = NULL; |
7115 | |
9631 | 7116 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7117 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7118 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7119 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7120 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7121 data); | |
9631 | 7122 g_free(title); |
7172 | 7123 |
7124 free(comment); | |
7125 g_free(comment_utf8); | |
7126 } | |
7127 | |
9030 | 7128 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7129 | |
7130 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7131 OscarData *od = gc->proto_data; |
9030 | 7132 |
4333 | 7133 GList *m = NULL; |
9030 | 7134 GaimBlistNodeAction *act; |
7135 | |
7136 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
7137 oscar_buddycb_edit_comment, NULL); | |
7138 m = g_list_append(m, act); | |
7172 | 7139 |
4333 | 7140 if (od->icq) { |
4624 | 7141 #if 0 |
9030 | 7142 act = gaim_blist_node_action_new(_("Get Status Msg"), |
7143 oscar_get_icqstatusmsg, NULL); | |
7144 m = g_list_append(m, act); | |
4624 | 7145 #endif |
4333 | 7146 } else { |
7011 | 7147 aim_userinfo_t *userinfo; |
9030 | 7148 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7149 | |
7150 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7151 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7152 | |
7011 | 7153 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7154 act = gaim_blist_node_action_new(_("Direct IM"), |
7155 oscar_ask_direct_im, NULL); | |
7156 m = g_list_append(m, act); | |
5917 | 7157 } |
9466 | 7158 #if 0 |
7011 | 7159 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7160 act = gaim_blist_node_action_new(_("Get File"), |
7161 oscar_ask_getfile, NULL); | |
7162 m = g_list_append(m, act); | |
5917 | 7163 } |
4826 | 7164 #endif |
4333 | 7165 } |
5131 | 7166 } |
5197 | 7167 |
5131 | 7168 if (od->sess->ssi.received_data) { |
9030 | 7169 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7170 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7171 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
7172 gaim_auth_sendrequest_menu, NULL); | |
7173 m = g_list_append(m, act); | |
4333 | 7174 } |
4916 | 7175 } |
10157 | 7176 |
4333 | 7177 return m; |
7178 } | |
7179 | |
9030 | 7180 |
7181 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7182 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7183 return oscar_buddy_menu((GaimBuddy *) node); | |
7184 } else { | |
7185 return NULL; | |
7186 } | |
7187 } | |
7188 | |
10570 | 7189 static void |
7190 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
7191 { | |
7192 OscarData *od = gc->proto_data; | |
7193 GaimAccount *account = gaim_connection_get_account(gc); | |
7194 GaimRequestField *f; | |
7195 gboolean auth, hide_ip, web_aware; | |
7196 | |
7197 f = gaim_request_fields_get_field(fields, "authorization"); | |
7198 auth = gaim_request_field_bool_get_value(f); | |
7199 | |
7200 f = gaim_request_fields_get_field(fields, "hide_ip"); | |
7201 hide_ip = gaim_request_field_bool_get_value(f); | |
7202 | |
7203 f = gaim_request_fields_get_field(fields, "web_aware"); | |
7204 web_aware = gaim_request_field_bool_get_value(f); | |
7205 | |
7206 gaim_account_set_bool(account, "authorization", auth); | |
7207 gaim_account_set_bool(account, "hide_ip", hide_ip); | |
7208 gaim_account_set_bool(account, "web_aware", web_aware); | |
7209 | |
7210 aim_icq_setsecurity(od->sess, auth, web_aware, hide_ip); | |
7211 } | |
7212 | |
7213 static void | |
7214 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
7215 { | |
7216 GaimConnection *gc = (GaimConnection *) action->context; | |
7217 GaimAccount *account = gaim_connection_get_account(gc); | |
7218 GaimRequestFields *fields; | |
7219 GaimRequestFieldGroup *g; | |
7220 GaimRequestField *f; | |
7221 gboolean auth, hide_ip, web_aware; | |
7222 | |
7223 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7224 hide_ip = gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7225 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7226 | |
7227 fields = gaim_request_fields_new(); | |
7228 | |
7229 g = gaim_request_field_group_new(NULL); | |
7230 | |
7231 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
7232 gaim_request_field_group_add_field(g, f); | |
7233 | |
7234 f = gaim_request_field_bool_new("hide_ip", _("Hide IP address"), hide_ip); | |
7235 gaim_request_field_group_add_field(g, f); | |
7236 | |
7237 f = gaim_request_field_bool_new("web_aware", _("Web aware"), web_aware); | |
7238 gaim_request_field_group_add_field(g, f); | |
7239 | |
7240 gaim_request_fields_add_group(fields, g); | |
7241 | |
7242 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
7243 NULL, fields, | |
7244 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
7245 _("Cancel"), NULL, gc); | |
7246 } | |
9030 | 7247 |
5575 | 7248 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7249 OscarData *od = gc->proto_data; |
5575 | 7250 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7251 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7252 od->setnick = TRUE; | |
7253 od->newsn = g_strdup(nick); | |
7254 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7255 } else { | |
7256 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7257 } | |
7258 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7259 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7260 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7261 } |
7262 } | |
7263 | |
9015 | 7264 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7265 { |
9015 | 7266 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7267 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7268 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7269 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7270 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7271 gc); |
4333 | 7272 } |
7273 | |
9015 | 7274 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7275 { |
9015 | 7276 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7277 OscarData *od = gc->proto_data; |
4333 | 7278 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7279 | |
7280 if (conn) { | |
7281 aim_admin_reqconfirm(od->sess, conn); | |
7282 } else { | |
7283 od->conf = TRUE; | |
7284 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7285 } | |
7286 } | |
7287 | |
9015 | 7288 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7289 { |
9015 | 7290 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7291 OscarData *od = gc->proto_data; |
4333 | 7292 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7293 | |
7294 if (conn) { | |
7295 aim_admin_getinfo(od->sess, conn, 0x11); | |
7296 } else { | |
7297 od->reqemail = TRUE; | |
7298 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7299 } | |
7300 } | |
7301 | |
5575 | 7302 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7303 { |
7283 | 7304 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7305 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
|
7306 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7307 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7308 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7309 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7310 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7311 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7312 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7313 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7314 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7315 |
9015 | 7316 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7317 { |
9015 | 7318 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7319 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7320 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7321 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7322 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7323 gc); |
4333 | 7324 } |
7325 | |
9015 | 7326 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7327 { |
9015 | 7328 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7329 OscarData *od = gc->proto_data; |
4333 | 7330 gchar *nombre, *text, *tmp; |
6695 | 7331 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7332 int num=0; |
7333 | |
6873 | 7334 text = g_strdup(""); |
4333 | 7335 |
4785 | 7336 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7337 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7338 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7339 continue; | |
6695 | 7340 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7341 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7342 continue; |
6695 | 7343 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7344 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7345 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7346 continue; | |
7347 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7348 if (gaim_buddy_get_alias_only(buddy)) |
7349 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7350 else |
7351 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7352 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7353 g_free(text); |
7354 text = tmp; | |
7355 g_free(nombre); | |
7356 num++; | |
7357 } | |
4333 | 7358 } |
2979 | 7359 } |
4333 | 7360 } |
7361 | |
7362 if (!num) { | |
7363 g_free(text); | |
6873 | 7364 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7365 } | |
7366 | |
7367 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7368 "the following buddies"), _("You can re-request " | |
7369 "authorization from these buddies by " | |
7370 "right-clicking on them and selecting " | |
7371 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7372 g_free(text); |
2979 | 7373 } |
7374 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7375 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7376 { |
8950 | 7377 OscarData *od = (OscarData *)gc->proto_data; |
7378 | |
7379 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7380 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7381 |
9015 | 7382 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7383 { |
9015 | 7384 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7385 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7386 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7387 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7388 "searching for."), |
8697 | 7389 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7390 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7391 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7392 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7393 |
9015 | 7394 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7395 { |
9015 | 7396 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7397 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7398 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7399 |
9015 | 7400 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7401 { |
9015 | 7402 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7403 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7404 } |
7405 | |
9015 | 7406 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7407 { |
9015 | 7408 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7409 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7410 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7411 |
9015 | 7412 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7413 { |
9015 | 7414 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7415 OscarData *od = gc->proto_data; |
5575 | 7416 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
|
7417 gaim_notify_uri(gc, substituted); |
5517 | 7418 g_free(substituted); |
4333 | 7419 } |
7420 | |
9015 | 7421 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7422 { |
9015 | 7423 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7424 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7425 } |
7426 | |
5842 | 7427 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7428 { | |
7283 | 7429 OscarData *od = gc->proto_data; |
5844 | 7430 aim_session_t *sess = od->sess; |
5842 | 7431 FILE *file; |
7432 struct stat st; | |
5844 | 7433 |
6039 | 7434 if (iconfile == NULL) { |
8363 | 7435 aim_ssi_delicon(od->sess); |
6039 | 7436 } else if (!stat(iconfile, &st)) { |
5842 | 7437 char *buf = g_malloc(st.st_size); |
7438 file = fopen(iconfile, "rb"); | |
7439 if (file) { | |
6052 | 7440 md5_state_t *state; |
6039 | 7441 char md5[16]; |
9532 | 7442 /* XXX - Use g_file_get_contents()? */ |
5842 | 7443 int len = fread(buf, 1, st.st_size, file); |
6039 | 7444 fclose(file); |
6052 | 7445 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7446 md5_init(state); |
7447 md5_append(state, buf, len); | |
7448 md5_finish(state, md5); | |
7449 g_free(state); | |
7450 aim_ssi_seticon(sess, md5, 16); | |
7451 } else | |
8660 | 7452 gaim_debug_error("oscar", |
5842 | 7453 "Can't open buddy icon file!\n"); |
7454 g_free(buf); | |
7455 } else | |
8660 | 7456 gaim_debug_error("oscar", |
5842 | 7457 "Can't stat buddy icon file!\n"); |
7458 } | |
7459 | |
7460 | |
9015 | 7461 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7462 { |
9015 | 7463 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7464 OscarData *od = gc->proto_data; |
4333 | 7465 GList *m = NULL; |
9015 | 7466 GaimPluginAction *act; |
7467 | |
7468 act = gaim_plugin_action_new(_("Set User Info..."), | |
7469 oscar_show_set_info); | |
7470 m = g_list_append(m, act); | |
4333 | 7471 |
10570 | 7472 if (od->icq) |
7473 { | |
9015 | 7474 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7475 oscar_show_set_info_icqurl); | |
7476 m = g_list_append(m, act); | |
8576 | 7477 } |
7478 | |
9015 | 7479 act = gaim_plugin_action_new(_("Change Password..."), |
7480 oscar_change_pass); | |
7481 m = g_list_append(m, act); | |
4617 | 7482 |
10570 | 7483 if (od->sess->authinfo->chpassurl != NULL) |
7484 { | |
9015 | 7485 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7486 oscar_show_chpassurl); | |
7487 m = g_list_append(m, act); | |
7488 | |
7489 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7490 oscar_show_imforwardingurl); | |
7491 m = g_list_append(m, act); | |
7026 | 7492 } |
7493 | |
10570 | 7494 m = g_list_append(m, NULL); |
7495 | |
7496 if (od->icq) | |
7497 { | |
7498 /* ICQ actions */ | |
7499 act = gaim_plugin_action_new(_("Show privacy options..."), | |
7500 oscar_show_icq_privacy_opts); | |
7501 m = g_list_append(m, act); | |
7502 } | |
7503 else | |
7504 { | |
4617 | 7505 /* AIM actions */ |
9015 | 7506 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7507 oscar_show_format_screenname); | |
7508 m = g_list_append(m, act); | |
7509 | |
7510 act = gaim_plugin_action_new(_("Confirm Account"), | |
7511 oscar_confirm_account); | |
7512 m = g_list_append(m, act); | |
7513 | |
7514 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7515 oscar_show_email); | |
7516 m = g_list_append(m, act); | |
7517 | |
7518 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7519 oscar_show_change_email); | |
7520 m = g_list_append(m, act); | |
2086 | 7521 } |
4333 | 7522 |
7523 m = g_list_append(m, NULL); | |
7524 | |
9015 | 7525 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7526 oscar_show_awaitingauth); | |
7527 m = g_list_append(m, act); | |
4333 | 7528 |
2086 | 7529 m = g_list_append(m, NULL); |
4333 | 7530 |
9015 | 7531 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7532 oscar_show_find_email); | |
7533 m = g_list_append(m, act); | |
4333 | 7534 |
8591 | 7535 #if 0 |
9015 | 7536 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7537 show_find_info); | |
7538 m = g_list_append(m, act); | |
8591 | 7539 #endif |
2086 | 7540 |
7541 return m; | |
7542 } | |
7543 | |
5575 | 7544 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7545 { |
7283 | 7546 OscarData *od = gc->proto_data; |
4617 | 7547 |
7548 if (od->icq) { | |
7549 aim_icq_changepasswd(od->sess, new); | |
2086 | 7550 } else { |
4617 | 7551 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7552 if (conn) { | |
7553 aim_admin_changepasswd(od->sess, conn, new, old); | |
7554 } else { | |
7555 od->chpass = TRUE; | |
7556 od->oldp = g_strdup(old); | |
7557 od->newp = g_strdup(new); | |
7558 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7559 } | |
2086 | 7560 } |
7561 } | |
7562 | |
6059 | 7563 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7564 { |
7283 | 7565 OscarData *od = gc->proto_data; |
8971 | 7566 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
|
7567 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7568 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7569 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7570 |
8971 | 7571 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7572 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7573 |
9935 | 7574 static void |
7575 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7576 { | |
7577 GaimConnection *gc = data; | |
7578 OscarData *od = gc->proto_data; | |
7579 aim_session_t *sess = od->sess; | |
7580 fu32_t presence; | |
7581 | |
7582 presence = aim_ssi_getpresence(sess->ssi.local); | |
7583 | |
7584 if (value) { | |
9992 | 7585 /* Based on the packet capture I thought it was the first one */ |
7586 /* Stu thinks it's the second one. */ | |
7587 /* presence |= 0x00400000; */ | |
9971 | 7588 presence &= ~0x00020000; |
9935 | 7589 aim_ssi_setpresence(sess, presence); |
7590 } else { | |
9992 | 7591 /* presence &= ~0x00400000; */ |
9971 | 7592 presence |= 0x00020000; |
9935 | 7593 aim_ssi_setpresence(sess, presence); |
7594 } | |
7595 } | |
7596 | |
7597 static GaimPluginPrefFrame * | |
9936 | 7598 get_plugin_pref_frame(GaimPlugin *plugin) |
7599 { | |
9935 | 7600 GaimPluginPrefFrame *frame; |
7601 GaimPluginPref *ppref; | |
7602 | |
7603 frame = gaim_plugin_pref_frame_new(); | |
7604 | |
7605 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7606 gaim_plugin_pref_frame_add(frame, ppref); | |
7607 | |
7608 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7609 gaim_plugin_pref_frame_add(frame, ppref); | |
7610 | |
7611 return frame; | |
7612 } | |
7613 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7614 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7615 { |
9308 | 7616 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7617 NULL, /* user_splits */ |
7618 NULL, /* protocol_options */ | |
7619 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7620 oscar_list_icon, /* list_icon */ | |
7621 oscar_list_emblems, /* list_emblems */ | |
7622 oscar_status_text, /* status_text */ | |
7623 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7624 oscar_status_types, /* status_types */ |
9475 | 7625 oscar_blist_node_menu, /* blist_node_menu */ |
7626 oscar_chat_info, /* chat_info */ | |
9754 | 7627 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7628 oscar_login, /* login */ |
7629 oscar_close, /* close */ | |
7630 oscar_send_im, /* send_im */ | |
7631 oscar_set_info, /* set_info */ | |
7632 oscar_send_typing, /* send_typing */ | |
7633 oscar_get_info, /* get_info */ | |
9973 | 7634 oscar_set_status, /* set_status */ |
9475 | 7635 oscar_set_idle, /* set_idle */ |
7636 oscar_change_passwd, /* change_passwd */ | |
7637 oscar_add_buddy, /* add_buddy */ | |
7638 oscar_add_buddies, /* add_buddies */ | |
7639 oscar_remove_buddy, /* remove_buddy */ | |
7640 oscar_remove_buddies, /* remove_buddies */ | |
7641 oscar_add_permit, /* add_permit */ | |
7642 oscar_add_deny, /* add_deny */ | |
7643 oscar_rem_permit, /* rem_permit */ | |
7644 oscar_rem_deny, /* rem_deny */ | |
7645 oscar_set_permit_deny, /* set_permit_deny */ | |
7646 oscar_warn, /* warn */ | |
7647 oscar_join_chat, /* join_chat */ | |
7648 NULL, /* reject_chat */ | |
9973 | 7649 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7650 oscar_chat_invite, /* chat_invite */ |
7651 oscar_chat_leave, /* chat_leave */ | |
7652 NULL, /* chat_whisper */ | |
7653 oscar_send_chat, /* chat_send */ | |
7654 oscar_keepalive, /* keepalive */ | |
7655 NULL, /* register_user */ | |
7656 NULL, /* get_cb_info */ | |
7657 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7658 #ifndef NOSSI |
9475 | 7659 oscar_alias_buddy, /* alias_buddy */ |
7660 oscar_move_buddy, /* group_buddy */ | |
7661 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7662 #else |
9475 | 7663 NULL, /* alias_buddy */ |
7664 NULL, /* group_buddy */ | |
7665 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7666 #endif |
9475 | 7667 NULL, /* buddy_free */ |
7668 oscar_convo_closed, /* convo_closed */ | |
7669 NULL, /* normalize */ | |
7670 oscar_set_icon, /* set_buddy_icon */ | |
7671 NULL, /* remove_group */ | |
7672 NULL, /* get_cb_real_name */ | |
7673 NULL, /* set_chat_topic */ | |
7674 NULL, /* find_blist_chat */ | |
7675 NULL, /* roomlist_get_list */ | |
7676 NULL, /* roomlist_cancel */ | |
7677 NULL, /* roomlist_expand_category */ | |
7678 oscar_can_receive_file, /* can_receive_file */ | |
7679 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7680 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7681 |
9935 | 7682 static GaimPluginUiInfo prefs_info = { |
7683 get_plugin_pref_frame | |
7684 }; | |
7685 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7686 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7687 { |
9943 | 7688 GAIM_PLUGIN_MAGIC, |
7689 GAIM_MAJOR_VERSION, | |
7690 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7691 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7692 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7693 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7694 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7695 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7696 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7697 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7698 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7699 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7700 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7701 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7702 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7703 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7704 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7705 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7706 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7707 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7708 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7709 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7710 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7711 NULL, /**< ui_info */ |
8993 | 7712 &prpl_info, /**< extra_info */ |
10487 | 7713 NULL, /**< prefs_info */ |
9015 | 7714 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7715 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7716 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7717 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7718 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7719 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7720 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7721 |
9830 | 7722 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7723 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7724 | |
7725 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7726 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7727 | |
7728 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7729 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
|
7730 |
10570 | 7731 /* We don't add these to protocol_options because they're ICQ specific */ |
7732 option = gaim_account_option_bool_new(_("Authorization"), "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7733 option = gaim_account_option_bool_new(_("Hide IP"), "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7734 option = gaim_account_option_bool_new(_("Web presence"), "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7735 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7736 my_protocol = plugin; |
9935 | 7737 |
7738 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7739 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7740 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7741 } |
7742 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7743 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |