Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 11338:17142948653e
[gaim-migrate @ 13551]
Change the GAIM_CONV_IM and GAIM_CONV_CHAT enums to GAIM_CONV_TYPE_IM
and GAIM_CONV_TYPE_CHAT. This touched A LOT of files. Also combined
two oscar header files (one of them was small and dorky).
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 25 Aug 2005 02:33:44 +0000 |
parents | 10066662176a |
children | 6c1ad49fcb4b |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
6 * Some code copyright (C) 2001-2003, Sean Egan | |
11155 | 7 * Some code copyright (C) 2001-2005, Mark Doliner <thekingant@users.sourceforge.net> |
11049 | 8 * Some code copyright (C) 2005, Jonathan Clark <ardentlygnarly@users.sourceforge.net> |
6302 | 9 * |
10 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 11 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 12 * |
13 * This program is free software; you can redistribute it and/or modify | |
14 * it under the terms of the GNU General Public License as published by | |
15 * the Free Software Foundation; either version 2 of the License, or | |
16 * (at your option) any later version. | |
17 * | |
18 * This program is distributed in the hope that it will be useful, | |
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10485 | 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2086 | 21 * GNU General Public License for more details. |
22 * | |
23 * You should have received a copy of the GNU General Public License | |
24 * along with this program; if not, write to the Free Software | |
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
26 * | |
27 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
30 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
31 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
32 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
33 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
34 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
36 #include "ft.h" |
6982 | 37 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
38 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
40 #include "privacy.h" |
2086 | 41 #include "prpl.h" |
4889 | 42 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 #include "util.h" |
9943 | 45 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
46 |
2086 | 47 #include "aim.h" |
5842 | 48 #include "md5.h" |
2086 | 49 |
9976 | 50 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
51 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
52 #define OSCAR_STATUS_ID_ONLINE "online" | |
9991 | 53 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 54 #define OSCAR_STATUS_ID_AWAY "away" |
55 #define OSCAR_STATUS_ID_DND "dnd" | |
56 #define OSCAR_STATUS_ID_NA "na" | |
57 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
58 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
59 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 60 |
2086 | 61 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
62 | |
7283 | 63 #define OSCAR_CONNECT_STEPS 6 |
11338 | 64 #define OSCAR_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" |
65 #define OSCAR_DEFAULT_LOGIN_PORT 5190 | |
9830 | 66 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
10570 | 67 #define OSCAR_DEFAULT_AUTHORIZATION TRUE |
68 #define OSCAR_DEFAULT_HIDE_IP TRUE | |
69 #define OSCAR_DEFAULT_WEB_AWARE FALSE | |
7283 | 70 |
11084 | 71 /* Seconds each file transfer ip address will be given to make a connection */ |
72 #define FT_IP_TIMEOUT 15 | |
73 | |
7376 | 74 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
75 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 76 |
4665 | 77 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
78 static fu8_t features_icq[] = {0x01, 0x06}; | |
11172 | 79 static fu8_t features_icq_offline[] = {0x01}; |
8341 | 80 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 81 |
7283 | 82 typedef struct _OscarData OscarData; |
83 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
84 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
85 aim_conn_t *conn; |
2086 | 86 |
87 guint cnpa; | |
88 guint paspa; | |
3694 | 89 guint emlpa; |
4804 | 90 guint icopa; |
2086 | 91 |
4823 | 92 gboolean iconconnecting; |
5842 | 93 gboolean set_icon; |
4823 | 94 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
95 GSList *create_rooms; |
2086 | 96 |
97 gboolean conf; | |
98 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
99 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
100 char *email; |
2979 | 101 gboolean setnick; |
102 char *newsn; | |
2086 | 103 gboolean chpass; |
104 char *oldp; | |
105 char *newp; | |
9971 | 106 |
2086 | 107 GSList *oscar_chats; |
108 GSList *direct_ims; | |
3630 | 109 GSList *file_transfers; |
4738 | 110 GHashTable *buddyinfo; |
4804 | 111 GSList *requesticon; |
2086 | 112 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
113 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
114 gboolean icq; |
4804 | 115 guint icontimer; |
5968 | 116 guint getblisttimer; |
8341 | 117 guint getinfotimer; |
10567 | 118 gint timeoffset; |
2993 | 119 |
120 struct { | |
4230 | 121 guint maxwatchers; /* max users who can watch you */ |
2993 | 122 guint maxbuddies; /* max users you can watch */ |
4230 | 123 guint maxgroups; /* max groups in server list */ |
2993 | 124 guint maxpermits; /* max users on permit list */ |
125 guint maxdenies; /* max users on deny list */ | |
126 guint maxsiglen; /* max size (bytes) of profile */ | |
127 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
128 } rights; | |
2086 | 129 }; |
130 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
133 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
134 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
135 |
2086 | 136 struct chat_connection { |
137 char *name; | |
138 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
139 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
140 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
141 aim_conn_t *conn; |
2086 | 142 int inpa; |
143 int id; | |
5575 | 144 GaimConnection *gc; /* i hate this. */ |
8733 | 145 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
146 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
147 int maxvis; |
2086 | 148 }; |
149 | |
8971 | 150 struct oscar_direct_im { |
5575 | 151 GaimConnection *gc; |
2086 | 152 char name[80]; |
153 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
154 aim_conn_t *conn; |
3008 | 155 gboolean connected; |
8978 | 156 gboolean gpc_pend; |
157 gboolean killme; | |
8984 | 158 gboolean donttryagain; |
2086 | 159 }; |
160 | |
161 struct ask_direct { | |
5575 | 162 GaimConnection *gc; |
2086 | 163 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
164 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
165 fu8_t cookie[8]; |
8984 | 166 gboolean donttryagain; |
2086 | 167 }; |
168 | |
7011 | 169 /* |
170 * Various PRPL-specific buddy info that we want to keep track of | |
171 * Some other info is maintained by locate.c, and I'd like to move | |
172 * the rest of this to libfaim, mostly im.c | |
173 */ | |
4738 | 174 struct buddyinfo { |
175 gboolean typingnot; | |
6292 | 176 gchar *availmsg; |
6857 | 177 fu32_t ipaddr; |
5836 | 178 |
179 unsigned long ico_me_len; | |
180 unsigned long ico_me_csum; | |
181 time_t ico_me_time; | |
182 gboolean ico_informed; | |
4738 | 183 |
184 unsigned long ico_len; | |
185 unsigned long ico_csum; | |
186 time_t ico_time; | |
187 gboolean ico_need; | |
7406 | 188 gboolean ico_sent; |
2086 | 189 }; |
190 | |
4230 | 191 struct name_data { |
5575 | 192 GaimConnection *gc; |
4230 | 193 gchar *name; |
3453 | 194 gchar *nick; |
3141 | 195 }; |
196 | |
5129 | 197 static char *msgerrreason[] = { |
198 N_("Invalid error"), | |
199 N_("Invalid SNAC"), | |
200 N_("Rate to host"), | |
201 N_("Rate to client"), | |
202 N_("Not logged in"), | |
203 N_("Service unavailable"), | |
204 N_("Service not defined"), | |
205 N_("Obsolete SNAC"), | |
206 N_("Not supported by host"), | |
207 N_("Not supported by client"), | |
208 N_("Refused by client"), | |
209 N_("Reply too big"), | |
210 N_("Responses lost"), | |
211 N_("Request denied"), | |
212 N_("Busted SNAC payload"), | |
213 N_("Insufficient rights"), | |
214 N_("In local permit/deny"), | |
215 N_("Too evil (sender)"), | |
216 N_("Too evil (receiver)"), | |
217 N_("User temporarily unavailable"), | |
218 N_("No match"), | |
219 N_("List overflow"), | |
220 N_("Request ambiguous"), | |
221 N_("Queue full"), | |
222 N_("Not while on AOL") | |
223 }; | |
224 static int msgerrreasonlen = 25; | |
225 | |
226 /* All the libfaim->gaim callback functions */ | |
227 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 229 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 230 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
231 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
237 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 238 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 239 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 240 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
241 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
|
242 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
|
243 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
|
244 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
|
245 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 246 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
247 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 249 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 250 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
251 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
259 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
260 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
261 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
262 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
280 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 281 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 282 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
283 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
284 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
286 | |
287 /* for DirectIM/image transfer */ | |
288 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
289 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
290 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 291 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 292 |
293 /* for file transfer */ | |
294 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
295 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
296 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
297 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
298 | |
299 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 300 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
11159 | 301 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie); |
5954 | 302 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 303 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
11084 | 304 static void oscar_xfer_init_recv(GaimXfer *xfer); |
9935 | 305 |
5836 | 306 static void oscar_free_name_data(struct name_data *data) { |
4230 | 307 g_free(data->name); |
308 g_free(data->nick); | |
309 g_free(data); | |
310 } | |
311 | |
5836 | 312 static void oscar_free_buddyinfo(void *data) { |
313 struct buddyinfo *bi = data; | |
6292 | 314 g_free(bi->availmsg); |
5836 | 315 g_free(bi); |
316 } | |
317 | |
9807 | 318 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 319 { |
320 int i = 0; | |
9826 | 321 int charset = AIM_CHARSET_ASCII; |
5129 | 322 |
11081 | 323 /* Determine how we can send this message. Per the warnings elsewhere |
324 * in this file, these little checks determine the simplest encoding | |
5129 | 325 * we can use for a given message send using it. */ |
326 while (utf8[i]) { | |
327 if ((unsigned char)utf8[i] > 0x7f) { | |
328 /* not ASCII! */ | |
9826 | 329 charset = AIM_CHARSET_CUSTOM; |
5129 | 330 break; |
331 } | |
332 i++; | |
333 } | |
334 while (utf8[i]) { | |
335 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
336 * followed by 0xc0-0xc3 in the second */ | |
337 if ((unsigned char)utf8[i] < 0x80) { | |
338 i++; | |
339 continue; | |
340 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
341 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
342 i += 2; | |
343 continue; | |
344 } | |
9826 | 345 charset = AIM_CHARSET_UNICODE; |
5129 | 346 break; |
347 } | |
348 | |
9807 | 349 return charset; |
5129 | 350 } |
351 | |
8225 | 352 /* |
353 * Take a string of the form charset="bleh" where bleh is | |
11081 | 354 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and |
8225 | 355 * return a newly allocated string containing bleh. |
356 */ | |
357 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 358 { |
8225 | 359 gchar *ret = NULL; |
360 char *begin, *end; | |
361 | |
9933 | 362 g_return_val_if_fail(encoding != NULL, NULL); |
363 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
364 /* Make sure encoding begins with charset= */ |
10540 | 365 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
366 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
367 { | |
8225 | 368 return NULL; |
10540 | 369 } |
8225 | 370 |
371 begin = strchr(encoding, '"'); | |
372 end = strrchr(encoding, '"'); | |
373 | |
374 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
375 return NULL; | |
376 | |
377 ret = g_strndup(begin+1, (end-1) - begin); | |
378 | |
379 return ret; | |
380 } | |
381 | |
9830 | 382 static gchar * |
383 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 384 { |
385 gchar *utf8 = NULL; | |
9595 | 386 |
387 if ((encoding == NULL) || encoding[0] == '\0') { | |
388 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 389 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 390 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 391 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 392 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 393 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 394 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 395 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 396 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 397 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 398 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
399 } | |
400 | |
401 /* | |
402 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
403 * we have been unable to convert the text to utf-8 from the encoding | |
404 * that was specified. So we check if the text is valid utf-8 then | |
405 * just copy it. | |
406 */ | |
407 if (utf8 == NULL) { | |
9638 | 408 if (textlen != 0 && *text != '\0' |
409 && !g_utf8_validate(text, textlen, NULL)) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
410 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 411 else |
9481 | 412 utf8 = g_strndup(text, textlen); |
5129 | 413 } |
414 | |
415 return utf8; | |
416 } | |
417 | |
9830 | 418 static gchar * |
11159 | 419 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback) |
9830 | 420 { |
421 gchar *ret = NULL; | |
422 GError *err = NULL; | |
423 | |
9908 | 424 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
425 return NULL; | |
426 | |
427 if (strcasecmp("UTF-8", charsetstr)) { | |
428 if (fallback) | |
429 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
430 else | |
431 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
432 if (err != NULL) { | |
433 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
434 charsetstr, err->message); | |
435 g_error_free(err); | |
436 } | |
437 } else { | |
438 if (g_utf8_validate(data, datalen, NULL)) | |
439 ret = g_strndup(data, datalen); | |
440 else | |
441 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
442 } | |
443 | |
444 return ret; | |
445 } | |
446 | |
447 /* | |
11081 | 448 * This attemps to decode an incoming IM into a UTF8 string. |
449 * | |
9908 | 450 * We try decoding using two different character sets. The charset |
451 * specified in the IM determines the order in which we attempt to | |
452 * decode. We do this because there are lots of broken ICQ clients | |
453 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
454 * able to deal with that crap, then people complain like banshees. | |
455 * charsetstr1 is always set to what the correct encoding should be. | |
456 */ | |
457 static gchar * | |
11159 | 458 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, const gchar *data, gsize datalen) |
9908 | 459 { |
460 gchar *ret = NULL; | |
461 const gchar *charsetstr1, *charsetstr2; | |
462 | |
463 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 464 |
465 if ((datalen == 0) || (data == NULL)) | |
466 return NULL; | |
467 | |
9908 | 468 if (charset == AIM_CHARSET_UNICODE) { |
469 charsetstr1 = "UCS-2BE"; | |
470 charsetstr2 = "UTF-8"; | |
471 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 472 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 473 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 474 else |
9908 | 475 charsetstr1 = "ISO-8859-1"; |
476 charsetstr2 = "UTF-8"; | |
477 } else if (charset == AIM_CHARSET_ASCII) { | |
478 /* Should just be "ASCII" */ | |
9914 | 479 charsetstr1 = "ASCII"; |
9908 | 480 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
481 } else if (charset == 0x000d) { | |
9830 | 482 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 483 charsetstr1 = "ISO-8859-1"; |
484 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
485 } else { | |
9830 | 486 /* Unknown, hope for valid UTF-8... */ |
9908 | 487 charsetstr1 = "UTF-8"; |
488 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
489 } | |
490 | |
491 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
492 if (ret == NULL) | |
493 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
494 if (ret == NULL) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
495 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9830 | 496 |
497 return ret; | |
498 } | |
499 | |
11081 | 500 /* |
501 * Figure out what encoding to use when sending a given outgoing message. | |
502 */ | |
9830 | 503 static void |
504 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 505 gchar **msg, int *msglen_int, |
9830 | 506 fu16_t *charset, fu16_t *charsubset) |
507 { | |
508 OscarData *od = gc->proto_data; | |
509 GaimAccount *account = gaim_connection_get_account(gc); | |
510 GError *err = NULL; | |
511 aim_userinfo_t *userinfo = NULL; | |
512 const gchar *charsetstr; | |
10039 | 513 gsize msglen; |
9830 | 514 |
515 /* Attempt to send as ASCII */ | |
10098 | 516 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 517 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 518 *charset = AIM_CHARSET_ASCII; |
9830 | 519 *charsubset = 0x0000; |
10039 | 520 *msglen_int = msglen; |
9830 | 521 return; |
522 } | |
523 | |
524 /* | |
10565 | 525 * If we're sending to an ICQ user, and they are in our |
526 * buddy list, and they are advertising the Unicode | |
527 * capability, and they are online, then attempt to send | |
528 * as UCS-2BE. | |
9830 | 529 */ |
9975 | 530 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 531 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
532 | |
10565 | 533 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
534 { | |
535 GaimBuddy *b; | |
536 b = gaim_find_buddy(account, destsn); | |
537 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
538 { | |
539 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
540 if (*msg != NULL) | |
541 { | |
542 *charset = AIM_CHARSET_UNICODE; | |
543 *charsubset = 0x0000; | |
544 *msglen_int = msglen; | |
545 return; | |
546 } | |
9830 | 547 } |
548 } | |
549 | |
550 /* | |
551 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
552 * ICQ then attempt to send as the user specified character encoding. | |
553 */ | |
554 charsetstr = "ISO-8859-1"; | |
9975 | 555 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 556 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
557 | |
10097 | 558 /* |
559 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
560 * can be converted to "charsetstr" | |
561 */ | |
10039 | 562 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 563 if (*msg != NULL) { |
564 *charset = AIM_CHARSET_CUSTOM; | |
565 *charsubset = 0x0000; | |
10039 | 566 *msglen_int = msglen; |
9830 | 567 return; |
568 } | |
569 | |
570 /* | |
571 * Nothing else worked, so send as UCS-2BE. | |
572 */ | |
10039 | 573 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 574 if (*msg != NULL) { |
575 *charset = AIM_CHARSET_UNICODE; | |
576 *charsubset = 0x0000; | |
10039 | 577 *msglen_int = msglen; |
9830 | 578 return; |
579 } | |
580 | |
9908 | 581 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 582 g_error_free(err); |
583 | |
584 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
585 *msg = g_strdup(from); | |
10039 | 586 *msglen_int = strlen(*msg); |
9830 | 587 *charset = AIM_CHARSET_ASCII; |
588 *charsubset = 0x0000; | |
589 return; | |
590 } | |
591 | |
9407 | 592 gchar *oscar_caps_to_string(guint caps) |
8701 | 593 { |
9407 | 594 GString *str; |
595 gchar *tmp; | |
8701 | 596 guint bit = 1; |
597 | |
9407 | 598 str = g_string_new(""); |
599 | |
8701 | 600 if (!caps) { |
601 return NULL; | |
602 } else while (bit <= AIM_CAPS_LAST) { | |
603 if (bit & caps) { | |
604 switch (bit) { | |
605 case AIM_CAPS_BUDDYICON: | |
606 tmp = _("Buddy Icon"); | |
607 break; | |
608 case AIM_CAPS_TALK: | |
609 tmp = _("Voice"); | |
610 break; | |
611 case AIM_CAPS_DIRECTIM: | |
612 tmp = _("AIM Direct IM"); | |
613 break; | |
614 case AIM_CAPS_CHAT: | |
615 tmp = _("Chat"); | |
616 break; | |
617 case AIM_CAPS_GETFILE: | |
618 tmp = _("Get File"); | |
619 break; | |
620 case AIM_CAPS_SENDFILE: | |
621 tmp = _("Send File"); | |
622 break; | |
623 case AIM_CAPS_GAMES: | |
624 case AIM_CAPS_GAMES2: | |
625 tmp = _("Games"); | |
626 break; | |
627 case AIM_CAPS_ADDINS: | |
628 tmp = _("Add-Ins"); | |
629 break; | |
630 case AIM_CAPS_SENDBUDDYLIST: | |
631 tmp = _("Send Buddy List"); | |
632 break; | |
633 case AIM_CAPS_ICQ_DIRECT: | |
634 tmp = _("ICQ Direct Connect"); | |
635 break; | |
636 case AIM_CAPS_APINFO: | |
637 tmp = _("AP User"); | |
638 break; | |
639 case AIM_CAPS_ICQRTF: | |
640 tmp = _("ICQ RTF"); | |
641 break; | |
642 case AIM_CAPS_EMPTY: | |
643 tmp = _("Nihilist"); | |
644 break; | |
645 case AIM_CAPS_ICQSERVERRELAY: | |
646 tmp = _("ICQ Server Relay"); | |
647 break; | |
648 case AIM_CAPS_ICQUTF8OLD: | |
649 tmp = _("Old ICQ UTF8"); | |
650 break; | |
651 case AIM_CAPS_TRILLIANCRYPT: | |
652 tmp = _("Trillian Encryption"); | |
653 break; | |
654 case AIM_CAPS_ICQUTF8: | |
655 tmp = _("ICQ UTF8"); | |
656 break; | |
657 case AIM_CAPS_HIPTOP: | |
658 tmp = _("Hiptop"); | |
659 break; | |
660 case AIM_CAPS_SECUREIM: | |
661 tmp = _("Security Enabled"); | |
662 break; | |
663 case AIM_CAPS_VIDEO: | |
664 tmp = _("Video Chat"); | |
665 break; | |
666 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
667 case AIM_CAPS_ICHATAV: | |
668 tmp = _("iChat AV"); | |
669 break; | |
670 case AIM_CAPS_LIVEVIDEO: | |
671 tmp = _("Live Video"); | |
672 break; | |
673 case AIM_CAPS_CAMERA: | |
674 tmp = _("Camera"); | |
675 break; | |
676 default: | |
677 tmp = NULL; | |
678 break; | |
679 } | |
680 if (tmp) | |
9532 | 681 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 682 } |
683 bit <<= 1; | |
684 } | |
9407 | 685 |
686 return g_string_free(str, FALSE); | |
8701 | 687 } |
688 | |
689 static char *oscar_icqstatus(int state) { | |
690 /* Make a cute little string that shows the status of the dude or dudet */ | |
691 if (state & AIM_ICQ_STATE_CHAT) | |
692 return g_strdup_printf(_("Free For Chat")); | |
693 else if (state & AIM_ICQ_STATE_DND) | |
694 return g_strdup_printf(_("Do Not Disturb")); | |
695 else if (state & AIM_ICQ_STATE_OUT) | |
696 return g_strdup_printf(_("Not Available")); | |
697 else if (state & AIM_ICQ_STATE_BUSY) | |
698 return g_strdup_printf(_("Occupied")); | |
699 else if (state & AIM_ICQ_STATE_AWAY) | |
700 return g_strdup_printf(_("Away")); | |
701 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
702 return g_strdup_printf(_("Web Aware")); | |
703 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
704 return g_strdup_printf(_("Invisible")); | |
705 else | |
706 return g_strdup_printf(_("Online")); | |
707 } | |
708 | |
9973 | 709 static void |
710 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 711 { |
712 gchar *utf8; | |
713 | |
714 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 715 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 716 g_free(utf8); |
717 } | |
718 } | |
719 | |
9973 | 720 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 721 { |
10042 | 722 OscarData *od; |
723 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
724 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
725 GaimStatus *status = NULL; |
8701 | 726 GaimGroup *g = NULL; |
727 struct buddyinfo *bi = NULL; | |
728 char *tmp; | |
729 | |
10042 | 730 od = gc->proto_data; |
731 account = gaim_connection_get_account(gc); | |
732 | |
733 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 734 return; |
735 | |
736 if (userinfo == NULL) | |
737 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
738 | |
739 if (b == NULL) | |
10042 | 740 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 741 |
742 if (b != NULL) | |
10498 | 743 { |
8701 | 744 g = gaim_find_buddys_group(b); |
10498 | 745 presence = gaim_buddy_get_presence(b); |
746 status = gaim_presence_get_active_status(presence); | |
747 } | |
8701 | 748 |
749 if (userinfo != NULL) | |
750 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
751 | |
8733 | 752 if (b != NULL) { |
10498 | 753 if (gaim_presence_is_online(presence)) { |
9975 | 754 if (aim_sn_is_icq(b->name)) { |
8733 | 755 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
756 oscar_string_append(str, newline, _("Status"), tmp); | |
757 g_free(tmp); | |
758 } | |
759 } else { | |
9625 | 760 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 761 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
762 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
763 else | |
764 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 765 } |
8733 | 766 } |
8701 | 767 |
768 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 769 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 770 (bi->ipaddr & 0xff000000) >> 24, |
771 (bi->ipaddr & 0x00ff0000) >> 16, | |
772 (bi->ipaddr & 0x0000ff00) >> 8, | |
773 (bi->ipaddr & 0x000000ff)); | |
774 oscar_string_append(str, newline, _("IP Address"), tmp); | |
775 g_free(tmp); | |
776 } | |
777 | |
11257 | 778 |
779 if ((userinfo != NULL) && (userinfo->warnlevel != 0)) { | |
11285 | 780 tmp = g_strdup_printf("%d", (int)(userinfo->warnlevel/10.0 + .5)); |
11257 | 781 oscar_string_append(str, newline, _("Warning Level"), tmp); |
782 g_free(tmp); | |
783 } | |
784 | |
8701 | 785 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { |
786 tmp = oscar_caps_to_string(userinfo->capabilities); | |
787 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 788 g_free(tmp); |
8701 | 789 } |
790 | |
791 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
792 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
793 if (tmp != NULL) { | |
9625 | 794 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 795 g_free(tmp); |
9625 | 796 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
797 g_free(tmp2); | |
8701 | 798 } |
799 } | |
800 | |
10498 | 801 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_status_is_available(status)) { |
8701 | 802 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
803 oscar_string_append(str, newline, _("Available"), tmp); | |
804 g_free(tmp); | |
805 } | |
806 } | |
807 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
808 static char *extract_name(const char *name) { |
4121 | 809 char *tmp, *x; |
2086 | 810 int i, j; |
4120 | 811 |
812 if (!name) | |
4121 | 813 return NULL; |
10042 | 814 |
4120 | 815 x = strchr(name, '-'); |
4121 | 816 |
2086 | 817 if (!x) return NULL; |
818 x = strchr(++x, '-'); | |
819 if (!x) return NULL; | |
820 tmp = g_strdup(++x); | |
821 | |
822 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
823 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
824 if (x[i] != '%') { |
2086 | 825 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
826 continue; |
2086 | 827 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
828 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
829 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
830 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 831 } |
832 | |
833 tmp[j] = 0; | |
834 return tmp; | |
835 } | |
836 | |
10458 | 837 static struct chat_connection * |
838 find_oscar_chat(GaimConnection *gc, int id) | |
839 { | |
840 OscarData *od = (OscarData *)gc->proto_data; | |
841 GSList *cur; | |
842 struct chat_connection *cc; | |
843 | |
844 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
845 { | |
846 cc = (struct chat_connection *)cur->data; | |
847 if (cc->id == id) | |
848 return cc; | |
849 } | |
850 | |
851 return NULL; | |
852 } | |
853 | |
854 static struct chat_connection * | |
855 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
856 { | |
857 OscarData *od = (OscarData *)gc->proto_data; | |
858 GSList *cur; | |
859 struct chat_connection *cc; | |
860 | |
861 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
862 { | |
863 cc = (struct chat_connection *)cur->data; | |
864 if (cc->conn == conn) | |
865 return cc; | |
866 } | |
867 | |
868 return NULL; | |
869 } | |
870 | |
871 static struct chat_connection * | |
872 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
873 { | |
874 OscarData *od = (OscarData *)gc->proto_data; | |
875 GSList *cur; | |
876 struct chat_connection *cc; | |
877 | |
878 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
879 { | |
880 cc = (struct chat_connection *)cur->data; | |
881 if (cc->conv == conv) | |
882 return cc; | |
883 } | |
884 | |
885 return NULL; | |
886 } | |
887 | |
888 static void | |
889 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
890 { | |
891 OscarData *od = (OscarData *)gc->proto_data; | |
892 | |
893 /* Notify the conversation window that we've left the chat */ | |
894 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
895 | |
896 /* Destroy the chat_connection */ | |
897 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
898 if (cc->inpa > 0) | |
899 gaim_input_remove(cc->inpa); | |
900 aim_conn_kill(od->sess, &cc->conn); | |
901 g_free(cc->name); | |
902 g_free(cc->show); | |
903 g_free(cc); | |
8219 | 904 } |
905 | |
8971 | 906 /***************************************************************************** |
907 * Begin scary direct im stuff | |
908 *****************************************************************************/ | |
909 | |
910 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
911 GSList *d = od->direct_ims; | |
912 struct oscar_direct_im *m = NULL; | |
913 | |
914 while (d) { | |
915 m = (struct oscar_direct_im *)d->data; | |
916 if (!aim_sncmp(who, m->name)) | |
917 return m; | |
918 d = d->next; | |
919 } | |
920 | |
921 return NULL; | |
922 } | |
923 | |
924 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
925 { | |
926 gaim_debug_info("oscar", | |
927 "destroying Direct IM for %s.\n", dim->name); | |
928 | |
929 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 930 if (dim->gpc_pend) { |
931 dim->killme = TRUE; | |
932 return; | |
933 } | |
8971 | 934 if (dim->watcher) |
935 gaim_input_remove(dim->watcher); | |
936 if (dim->conn) { | |
10271 | 937 aim_conn_close(dim->conn); |
8971 | 938 aim_conn_kill(od->sess, &dim->conn); |
939 } | |
940 g_free(dim); | |
941 } | |
942 | |
943 /* the only difference between this and destroy is this writes a conv message */ | |
944 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
945 { | |
946 GaimConversation *conv; | |
947 char buf[256]; | |
948 | |
949 gaim_debug_info("oscar", | |
950 "%s disconnected Direct IM.\n", dim->name); | |
951 | |
952 if (dim->connected) | |
953 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 954 else |
8971 | 955 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
956 | |
11338 | 957 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, dim->name, |
10246 | 958 gaim_connection_get_account(dim->gc)); |
8971 | 959 if (conv) { |
960 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 961 gaim_conversation_update_progress(conv, 0); |
8971 | 962 } else { |
963 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
964 } | |
965 | |
966 oscar_direct_im_destroy(od, dim); | |
967 | |
968 return; | |
969 } | |
970 | |
971 /* oops i made two of these. this one just calls the other one. */ | |
972 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
973 { | |
974 GaimConnection *gc = sess->aux_data; | |
975 OscarData *od = (OscarData *)gc->proto_data; | |
976 struct oscar_direct_im *dim; | |
977 char *sn; | |
978 | |
979 sn = g_strdup(aim_odc_getsn(conn)); | |
980 dim = oscar_direct_im_find(od, sn); | |
981 oscar_direct_im_disconnect(od, dim); | |
982 g_free(sn); | |
983 } | |
984 | |
985 static void destroy_direct_im_request(struct ask_direct *d) { | |
986 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
987 | |
988 g_free(d->sn); | |
989 g_free(d); | |
990 } | |
991 | |
992 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
993 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
994 struct oscar_direct_im *dim = data; | |
995 GaimConnection *gc = dim->gc; | |
996 OscarData *od = gc->proto_data; | |
997 GaimConversation *conv; | |
998 char buf[256]; | |
999 struct sockaddr name; | |
1000 socklen_t name_len = 1; | |
1001 | |
1002 g_return_if_fail(gc != NULL); | |
1003 | |
8978 | 1004 dim->gpc_pend = FALSE; |
1005 if (dim->killme) { | |
1006 oscar_direct_im_destroy(od, dim); | |
1007 return; | |
1008 } | |
1009 | |
8971 | 1010 if (!g_list_find(gaim_connections_get_all(), gc)) { |
1011 oscar_direct_im_destroy(od, dim); | |
1012 return; | |
1013 } | |
1014 | |
1015 if (source < 0) { | |
8984 | 1016 if (dim->donttryagain) { |
1017 oscar_direct_im_disconnect(od, dim); | |
1018 return; | |
1019 } else { | |
11159 | 1020 guchar cookie[8]; |
8984 | 1021 char *who = g_strdup(dim->name); |
11159 | 1022 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1023 |
1024 memcpy(cookie, tmp, 8); | |
1025 oscar_direct_im_destroy(od, dim); | |
1026 oscar_direct_im_initiate(gc, who, cookie); | |
1027 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1028 g_free(who); | |
1029 return; | |
1030 } | |
8971 | 1031 } |
1032 | |
1033 dim->conn->fd = source; | |
1034 aim_conn_completeconnect(od->sess, dim->conn); | |
11338 | 1035 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); |
8971 | 1036 |
1037 /* This is the best way to see if we're connected or not */ | |
8983 | 1038 /* Is this really needed? */ |
8971 | 1039 if (getpeername(source, &name, &name_len) == 0) { |
1040 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1041 dim->connected = TRUE; | |
1042 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1043 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1044 } else { | |
8984 | 1045 if (dim->donttryagain) { |
1046 oscar_direct_im_disconnect(od, dim); | |
1047 return; | |
1048 } else { | |
11159 | 1049 guchar cookie[8]; |
8984 | 1050 char *who = g_strdup(dim->name); |
11159 | 1051 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1052 |
1053 memcpy(cookie, tmp, 8); | |
1054 oscar_direct_im_destroy(od, dim); | |
1055 oscar_direct_im_initiate(gc, who, cookie); | |
1056 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1057 g_free(who); | |
1058 return; | |
1059 } | |
8983 | 1060 } |
1061 | |
1062 | |
8971 | 1063 } |
1064 | |
1065 static void accept_direct_im_request(struct ask_direct *d) { | |
1066 GaimConnection *gc = d->gc; | |
1067 OscarData *od; | |
1068 struct oscar_direct_im *dim; | |
1069 char *host; int port = 5190; | |
1070 int i, rc; | |
8982 | 1071 char *tmp; |
1072 GaimConversation *conv; | |
8971 | 1073 |
1074 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1075 destroy_direct_im_request(d); | |
1076 return; | |
1077 } | |
1078 | |
1079 od = (OscarData *)gc->proto_data; | |
1080 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1081 | |
1082 dim = oscar_direct_im_find(od, d->sn); | |
1083 if (dim && dim->connected) { | |
1084 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1085 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1086 return; | |
1087 } | |
1088 dim = g_new0(struct oscar_direct_im, 1); | |
1089 dim->gc = d->gc; | |
8984 | 1090 dim->donttryagain = d->donttryagain; |
8971 | 1091 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1092 | |
1093 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1094 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1095 if (!dim->conn) { | |
1096 oscar_direct_im_disconnect(od, dim); | |
1097 destroy_direct_im_request(d); | |
1098 return; | |
1099 } | |
1100 | |
1101 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1102 gaim_odc_incoming, 0); | |
1103 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1104 gaim_odc_typing, 0); | |
1105 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1106 gaim_odc_update_ui, 0); | |
1107 | |
1108 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1109 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1110 if (d->ip[i] == ':') { | |
1111 port = atoi(&(d->ip[i+1])); | |
1112 break; | |
1113 } | |
1114 } | |
1115 host = g_strndup(d->ip, i); | |
1116 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1117 dim->gpc_pend = TRUE; |
8971 | 1118 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1119 |
11338 | 1120 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, d->sn); |
8982 | 1121 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, |
1122 port); | |
1123 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1124 g_free(tmp); | |
8983 | 1125 |
8971 | 1126 g_free(host); |
1127 if (rc < 0) { | |
8978 | 1128 dim->gpc_pend = FALSE; |
8971 | 1129 oscar_direct_im_disconnect(od, dim); |
1130 destroy_direct_im_request(d); | |
1131 return; | |
1132 } | |
1133 | |
1134 destroy_direct_im_request(d); | |
1135 | |
1136 return; | |
1137 } | |
1138 | |
1139 /* | |
1140 * We have just established a socket with the other dude, so set up some handlers. | |
1141 */ | |
1142 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1143 GaimConnection *gc = sess->aux_data; |
7283 | 1144 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1145 GaimConversation *conv; |
8971 | 1146 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1147 char buf[256]; |
8971 | 1148 char *sn; |
1149 va_list ap; | |
1150 aim_conn_t *newconn, *listenerconn; | |
1151 | |
1152 va_start(ap, fr); | |
1153 newconn = va_arg(ap, aim_conn_t *); | |
1154 listenerconn = va_arg(ap, aim_conn_t *); | |
1155 va_end(ap); | |
1156 | |
10271 | 1157 aim_conn_close(listenerconn); |
8971 | 1158 aim_conn_kill(sess, &listenerconn); |
1159 | |
1160 sn = g_strdup(aim_odc_getsn(newconn)); | |
1161 | |
1162 gaim_debug_info("oscar", | |
1163 "DirectIM: initiate success to %s\n", sn); | |
1164 dim = oscar_direct_im_find(od, sn); | |
1165 | |
11338 | 1166 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, sn); |
8971 | 1167 gaim_input_remove(dim->watcher); |
1168 dim->conn = newconn; | |
1169 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1170 dim->connected = TRUE; | |
1171 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1172 g_free(sn); | |
1173 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1174 | |
1175 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1176 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1177 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1178 | |
1179 return 1; | |
1180 } | |
1181 | |
1182 /* | |
1183 * This is called when each chunk of an image is received. It can be used to | |
1184 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1185 * nasty, you sicko. | |
1186 */ | |
1187 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1188 va_list ap; | |
1189 char *sn; | |
1190 double percent; | |
1191 GaimConnection *gc = sess->aux_data; | |
1192 OscarData *od = (OscarData *)gc->proto_data; | |
1193 GaimConversation *c; | |
1194 struct oscar_direct_im *dim; | |
1195 | |
1196 va_start(ap, fr); | |
1197 sn = va_arg(ap, char *); | |
1198 percent = va_arg(ap, double); | |
1199 va_end(ap); | |
1200 | |
1201 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1202 return 1; | |
1203 if (dim->watcher) { | |
1204 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1205 /* The callback will callback? I don't get how that would happen here. */ | |
1206 dim->watcher = 0; | |
1207 } | |
1208 | |
11338 | 1209 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, sn, |
10246 | 1210 gaim_connection_get_account(gc)); |
8971 | 1211 if (c != NULL) |
1212 gaim_conversation_update_progress(c, percent); | |
1213 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1214 oscar_callback, dim->conn); | |
1215 | |
1216 return 1; | |
1217 } | |
1218 | |
1219 /* | |
1220 * This is called after a direct IM has been received in its entirety. This | |
1221 * function is passed a long chunk of data which contains the IM with any | |
1222 * data chunks (images) appended to it. | |
1223 * | |
1224 * This function rips out all the data chunks and creates an imgstore for | |
1225 * each one. In order to do this, it first goes through the IM and takes | |
1226 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1227 * with one compatible with the imgstore Gaim core code. For each one, we | |
1228 * then read in chunks of data from the end of the message and actually | |
1229 * create the img store using the given data. | |
1230 * | |
1231 * For somewhat easy reference, here's a sample message | |
1232 * (without the whitespace and asterisks): | |
1233 * | |
1234 * <HTML><BODY BGCOLOR="#ffffff"> | |
1235 * <FONT LANG="0"> | |
1236 * This is a really stupid picture:<BR> | |
1237 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1238 * Yeah it is<BR> | |
1239 * Here is another one:<BR> | |
1240 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1241 * </FONT> | |
1242 * </BODY></HTML> | |
1243 * <BINARY> | |
1244 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1245 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1246 * </BINARY> | |
1247 */ | |
1248 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1249 GaimConnection *gc = sess->aux_data; | |
1250 GaimConvImFlags imflags = 0; | |
1251 gchar *utf8; | |
1252 GString *newmsg = g_string_new(""); | |
1253 GSList *images = NULL; | |
1254 va_list ap; | |
1255 const char *sn, *msg, *msgend, *binary; | |
1256 size_t len; | |
1257 int encoding, isawaymsg; | |
1258 | |
1259 va_start(ap, fr); | |
1260 sn = va_arg(ap, const char *); | |
1261 msg = va_arg(ap, const char *); | |
1262 len = va_arg(ap, size_t); | |
1263 encoding = va_arg(ap, int); | |
1264 isawaymsg = va_arg(ap, int); | |
1265 va_end(ap); | |
1266 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1267 |
8660 | 1268 gaim_debug_info("oscar", |
8971 | 1269 "Got DirectIM message from %s\n", sn); |
1270 | |
1271 if (isawaymsg) | |
1272 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1273 | |
1274 /* message has a binary trailer */ | |
1275 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1276 GData *attribs; | |
1277 const char *tmp, *start, *end, *last = NULL; | |
1278 | |
1279 tmp = msg; | |
1280 | |
1281 /* for each valid image tag... */ | |
1282 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1283 const char *id, *src, *datasize; | |
10504 | 1284 const char *data = NULL; |
1285 char *tag = NULL; | |
8971 | 1286 size_t size; |
1287 int imgid = 0; | |
1288 | |
1289 /* update the location of the last img tag */ | |
1290 last = end; | |
1291 | |
1292 /* grab attributes */ | |
1293 id = g_datalist_get_data(&attribs, "id"); | |
1294 src = g_datalist_get_data(&attribs, "src"); | |
1295 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1296 | |
1297 /* if we have id & datasize, build the data tag */ | |
1298 if (id && datasize) | |
1299 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1300 | |
1301 /* if we have a tag, find the start of the data */ | |
1302 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1303 data += strlen(tag); | |
1304 | |
10504 | 1305 g_free(tag); |
1306 | |
8971 | 1307 /* check the data is here and store it */ |
1308 if (data + (size = atoi(datasize)) <= msgend) | |
1309 imgid = gaim_imgstore_add(data, size, src); | |
1310 | |
1311 /* | |
1312 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1313 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1314 */ | |
1315 /* if we have a stored image... */ | |
1316 if (imgid) { | |
1317 /* append the message up to the tag */ | |
1318 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1319 if (utf8 != NULL) { | |
1320 newmsg = g_string_append(newmsg, utf8); | |
1321 g_free(utf8); | |
1322 } | |
1323 | |
1324 /* write the new image tag */ | |
1325 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1326 | |
1327 /* and record the image number */ | |
1328 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1329 } else { | |
1330 /* otherwise, copy up to the end of the tag */ | |
1331 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1332 if (utf8 != NULL) { | |
1333 newmsg = g_string_append(newmsg, utf8); | |
1334 g_free(utf8); | |
1335 } | |
1336 } | |
1337 | |
1338 /* clear the attribute list */ | |
1339 g_datalist_clear(&attribs); | |
1340 | |
1341 /* continue from the end of the tag */ | |
1342 tmp = end + 1; | |
1343 } | |
1344 | |
1345 /* append any remaining message data (without the > :-) */ | |
1346 if (last++ && (last < binary)) | |
1347 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1348 | |
1349 /* set the flag if we caught any images */ | |
1350 if (images) | |
1351 imflags |= GAIM_CONV_IM_IMAGES; | |
1352 } else { | |
1353 g_string_append_len(newmsg, msg, len); | |
1354 } | |
1355 | |
10318 | 1356 /* Convert to UTF8 */ |
1357 /* (This hasn't been tested very much) */ | |
1358 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1359 if (utf8 != NULL) { | |
1360 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1361 g_free(utf8); | |
1362 } | |
1363 | |
1364 /* free the message */ | |
8971 | 1365 g_string_free(newmsg, TRUE); |
1366 | |
1367 /* unref any images we allocated */ | |
1368 if (images) { | |
1369 GSList *tmp; | |
1370 int id; | |
1371 | |
1372 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1373 id = GPOINTER_TO_INT(tmp->data); | |
1374 gaim_imgstore_unref(id); | |
1375 } | |
1376 | |
1377 g_slist_free(images); | |
1378 } | |
1379 | |
1380 return 1; | |
1381 } | |
1382 | |
1383 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1384 va_list ap; | |
1385 char *sn; | |
1386 int typing; | |
1387 GaimConnection *gc = sess->aux_data; | |
1388 | |
1389 va_start(ap, fr); | |
1390 sn = va_arg(ap, char *); | |
1391 typing = va_arg(ap, int); | |
1392 va_end(ap); | |
1393 | |
1394 if (typing == 0x0002) { | |
1395 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1396 gaim_debug_info("oscar", | |
1397 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1398 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1399 } else if (typing == 0x0001) | |
1400 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1401 else | |
1402 serv_got_typing_stopped(gc, sn); | |
1403 return 1; | |
1404 } | |
1405 | |
1406 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1407 char *buf; | |
1408 size_t len; | |
1409 int ret; | |
1410 GString *msg = g_string_new("<HTML><BODY>"); | |
1411 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1412 GData *attribs; | |
1413 const char *start, *end, *last; | |
1414 int oscar_id = 0; | |
1415 | |
1416 last = message; | |
1417 | |
1418 /* for each valid IMG tag... */ | |
1419 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1420 GaimStoredImage *image = NULL; | |
1421 const char *id; | |
1422 | |
1423 if (start - last) { | |
1424 g_string_append_len(msg, last, start - last); | |
1425 } | |
1426 | |
1427 id = g_datalist_get_data(&attribs, "id"); | |
1428 | |
1429 /* ... if it refers to a valid gaim image ... */ | |
1430 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1431 /* ... append the message from start to the tag ... */ | |
9126 | 1432 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1433 const char *filename = gaim_imgstore_get_filename(image); |
1434 gpointer imgdata = gaim_imgstore_get_data(image); | |
1435 | |
1436 oscar_id++; | |
1437 | |
1438 /* ... insert a new img tag with the oscar id ... */ | |
1439 if (filename) | |
1440 g_string_append_printf(msg, | |
9126 | 1441 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1442 filename, oscar_id, size); |
1443 else | |
1444 g_string_append_printf(msg, | |
9126 | 1445 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1446 oscar_id, size); |
1447 | |
1448 /* ... and append the data to the binary section ... */ | |
9126 | 1449 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1450 oscar_id, size); |
1451 data = g_string_append_len(data, imgdata, size); | |
1452 data = g_string_append(data, "</DATA>"); | |
1453 } | |
1454 /* If the tag is invalid, skip it, thus no else here */ | |
1455 | |
1456 g_datalist_clear(&attribs); | |
1457 | |
1458 /* continue from the end of the tag */ | |
1459 last = end + 1; | |
1460 } | |
1461 | |
1462 /* append any remaining message data (without the > :-) */ | |
1463 if (last && *last) | |
1464 msg = g_string_append(msg, last); | |
1465 | |
1466 /* if we inserted any images in the binary section, append it */ | |
1467 if (oscar_id) { | |
1468 msg = g_string_append_len(msg, data->str, data->len); | |
1469 msg = g_string_append(msg, "</BINARY>"); | |
1470 } | |
1471 | |
1472 len = msg->len; | |
1473 buf = msg->str; | |
1474 g_string_free(msg, FALSE); | |
1475 g_string_free(data, TRUE); | |
1476 | |
1477 | |
1478 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1479 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1480 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1481 else | |
1482 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1483 | |
1484 g_free(buf); | |
1485 | |
1486 return ret; | |
1487 } | |
1488 | |
1489 struct ask_do_dir_im { | |
1490 char *who; | |
1491 GaimConnection *gc; | |
1492 }; | |
1493 | |
1494 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1495 g_free(data->who); | |
1496 g_free(data); | |
1497 } | |
1498 | |
8983 | 1499 /* this function is used to initiate a direct im session with someone. |
1500 * we start listening on a port and send a request. they either connect | |
1501 * or send some kind of reply. If they can't connect, they ask us to | |
1502 * connect to them, and so we do that. | |
1503 * | |
1504 * this function will also get called if the other side initiate's a direct | |
1505 * im and we try to connect and fail. in that case cookie will not be null. | |
1506 * | |
1507 * note that cookie is an 8 byte string that isn't NULL terminated | |
1508 */ | |
11159 | 1509 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie) { |
8971 | 1510 OscarData *od; |
1511 struct oscar_direct_im *dim; | |
1512 int listenfd; | |
8982 | 1513 const char *ip; |
8971 | 1514 |
1515 od = (OscarData *)gc->proto_data; | |
1516 | |
8983 | 1517 dim = oscar_direct_im_find(od, who); |
8971 | 1518 if (dim) { |
1519 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1520 oscar_direct_im_disconnect(od, dim); | |
1521 gaim_debug_info("oscar", | |
1522 "Gave up on old direct IM, trying again\n"); | |
1523 } else { | |
1524 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1525 return; |
8971 | 1526 } |
1527 } | |
1528 dim = g_new0(struct oscar_direct_im, 1); | |
1529 dim->gc = gc; | |
8983 | 1530 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1531 |
1532 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1533 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1534 if (listenfd >= 0) |
1535 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1536 if (dim->conn != NULL) { |
8982 | 1537 char *tmp; |
1538 GaimConversation *conv; | |
1539 | |
8971 | 1540 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1541 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1542 oscar_callback, dim->conn); | |
1543 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1544 gaim_odc_initiate, 0); | |
8982 | 1545 |
11338 | 1546 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, who); |
8983 | 1547 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, |
8982 | 1548 gaim_network_get_port_from_fd(listenfd)); |
1549 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1550 g_free(tmp); | |
8971 | 1551 } else { |
1552 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1553 oscar_direct_im_destroy(od, dim); | |
1554 } | |
8983 | 1555 } |
1556 | |
1557 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1558 GaimConnection *gc = data->gc; | |
1559 | |
1560 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1561 g_free(data->who); | |
1562 g_free(data); | |
1563 return; | |
1564 } | |
1565 | |
1566 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1567 g_free(data->who); |
1568 g_free(data); | |
1569 } | |
1570 | |
1571 /* this is the right click menu cb thingy */ | |
9030 | 1572 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1573 | |
1574 GaimBuddy *buddy; | |
1575 GaimConnection *gc; | |
8971 | 1576 gchar *buf; |
9030 | 1577 struct ask_do_dir_im *data; |
1578 | |
1579 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1580 | |
1581 buddy = (GaimBuddy *) node; | |
1582 gc = gaim_account_get_connection(buddy->account); | |
1583 | |
1584 data = g_new0(struct ask_do_dir_im, 1); | |
1585 data->who = g_strdup(buddy->name); | |
8971 | 1586 data->gc = gc; |
9030 | 1587 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1588 buddy->name); | |
8971 | 1589 |
1590 gaim_request_action(gc, NULL, buf, | |
9030 | 1591 _("Because this reveals your IP address, it " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1592 "may be considered a privacy risk. Do you " |
9030 | 1593 "wish to continue?"), |
1594 0, data, 2, | |
1595 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1596 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1597 g_free(buf); |
1598 } | |
1599 | |
1600 /***************************************************************************** | |
1601 * End scary direct im stuff | |
1602 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1603 |
4617 | 1604 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1605 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1606 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1607 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1608 OscarData *od; |
11214 | 1609 |
2086 | 1610 if (!gc) { |
8660 | 1611 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1612 "oscar callback for closed connection (1).\n"); |
2086 | 1613 return; |
1614 } | |
10458 | 1615 |
7283 | 1616 od = (OscarData *)gc->proto_data; |
2086 | 1617 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1618 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1619 /* oh boy. this is probably bad. i guess the only thing we |
1620 * can really do is return? */ | |
8660 | 1621 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1622 "oscar callback for closed connection (2).\n"); |
8660 | 1623 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1624 return; |
1625 } | |
1626 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1627 if (condition & GAIM_INPUT_READ) { |
4617 | 1628 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1629 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1630 "got information on rendezvous listener\n"); |
4617 | 1631 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1632 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1633 "connection error (rendezvous listener)\n"); |
4617 | 1634 aim_conn_kill(od->sess, &conn); |
8446 | 1635 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1636 } |
1637 } else { | |
4617 | 1638 if (aim_get_command(od->sess, conn) >= 0) { |
1639 aim_rxdispatch(od->sess); | |
6029 | 1640 if (od->killme) { |
8660 | 1641 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1642 return; |
1643 } | |
2086 | 1644 } else { |
1645 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
10444 | 1646 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1647 { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1648 gaim_debug_error("oscar", "Major connection error. i.e. " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1649 "invalid data was received on the oscar TCP stream\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1650 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1651 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1652 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1653 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1654 char *buf; |
10458 | 1655 |
1656 gaim_debug_info("oscar", "Lost connection " | |
1657 "to chat room %s\n", cc->name); | |
1658 | |
1659 buf = g_strdup_printf(_("You have lost your connection " | |
1660 "to chat room %s."), cc->name); | |
1661 if (conv != NULL) | |
9627 | 1662 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1663 else | |
1664 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1665 g_free(buf); |
10458 | 1666 |
1667 oscar_chat_kill(gc, cc); | |
1668 | |
2086 | 1669 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1670 if (od->cnpa > 0) |
1671 gaim_input_remove(od->cnpa); | |
1672 od->cnpa = 0; | |
8660 | 1673 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1674 "removing chatnav input watcher\n"); |
4617 | 1675 while (od->create_rooms) { |
1676 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1677 g_free(cr->name); |
4617 | 1678 od->create_rooms = |
1679 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1680 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1681 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1682 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1683 NULL); |
2086 | 1684 } |
4617 | 1685 aim_conn_kill(od->sess, &conn); |
2086 | 1686 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1687 if (od->paspa > 0) |
1688 gaim_input_remove(od->paspa); | |
1689 od->paspa = 0; | |
8660 | 1690 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1691 "removing authconn input watcher\n"); |
4617 | 1692 aim_conn_kill(od->sess, &conn); |
3694 | 1693 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1694 if (od->emlpa > 0) |
1695 gaim_input_remove(od->emlpa); | |
1696 od->emlpa = 0; | |
8660 | 1697 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1698 "removing email input watcher\n"); |
4617 | 1699 aim_conn_kill(od->sess, &conn); |
4804 | 1700 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1701 if (od->icopa > 0) | |
1702 gaim_input_remove(od->icopa); | |
1703 od->icopa = 0; | |
8660 | 1704 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1705 "removing icon input watcher\n"); |
4804 | 1706 aim_conn_kill(od->sess, &conn); |
2086 | 1707 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1708 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1709 gaim_odc_disconnect(od->sess, conn); |
11214 | 1710 gaim_debug_info("oscar","killing rendezvous connection\n"); |
4617 | 1711 aim_conn_kill(od->sess, &conn); |
2086 | 1712 } else { |
8660 | 1713 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1714 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1715 conn->type); |
4617 | 1716 aim_conn_kill(od->sess, &conn); |
2086 | 1717 } |
1718 } | |
1719 } | |
1720 } | |
1721 } | |
1722 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1723 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1724 { |
5575 | 1725 GaimConnection *gc = data; |
7283 | 1726 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1727 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1728 aim_conn_t *conn; |
2086 | 1729 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1730 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1731 close(source); |
1732 return; | |
1733 } | |
1734 | |
4617 | 1735 od = gc->proto_data; |
1736 sess = od->sess; | |
2086 | 1737 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1738 conn->fd = source; |
2086 | 1739 |
1740 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1741 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1742 return; |
1743 } | |
1744 | |
1745 aim_conn_completeconnect(sess, conn); | |
4617 | 1746 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1747 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1748 | |
8660 | 1749 gaim_debug_info("oscar", |
7282 | 1750 "Screen name sent, waiting for response\n"); |
7283 | 1751 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1752 ck[1] = 0x65; |
2086 | 1753 } |
1754 | |
10444 | 1755 static void |
1756 oscar_login(GaimAccount *account, GaimStatus *status) | |
1757 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1758 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1759 aim_conn_t *conn; |
5575 | 1760 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1761 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
10400 | 1762 GaimStatusType *status_type; |
1763 GaimStatusPrimitive primitive; | |
1764 | |
1765 status_type = gaim_status_get_type(status); | |
1766 primitive = gaim_status_type_get_primitive(status_type); | |
2086 | 1767 |
8660 | 1768 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
10444 | 1769 |
10400 | 1770 if (primitive == GAIM_STATUS_OFFLINE) |
1771 return; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1772 |
8437 | 1773 if (!aim_snvalid(gaim_account_get_username(account))) { |
1774 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1775 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 | 1776 gaim_connection_error(gc, buf); |
1777 g_free(buf); | |
1778 } | |
1779 | |
9975 | 1780 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1781 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1782 } else { |
6622 | 1783 gc->flags |= GAIM_CONNECTION_HTML; |
1784 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1785 } |
5836 | 1786 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1787 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1788 sess = g_new0(aim_session_t, 1); |
11253 | 1789 aim_session_init(sess, TRUE); |
7282 | 1790 /* |
11162 | 1791 * We need an immediate queue because we don't use a while-loop |
7282 | 1792 * to see if things need to be sent. |
1793 */ | |
2086 | 1794 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1795 od->sess = sess; |
2086 | 1796 sess->aux_data = gc; |
1797 | |
9935 | 1798 /* Connect to core Gaim signals */ |
10087 | 1799 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1800 |
11162 | 1801 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
2086 | 1802 if (conn == NULL) { |
10444 | 1803 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1804 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1805 return; |
1806 } | |
1807 | |
4649 | 1808 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1809 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1810 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1811 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1812 |
1813 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
11338 | 1814 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER), |
1815 gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), | |
5575 | 1816 oscar_login_connect, gc) < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1817 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1818 return; |
1819 } | |
7282 | 1820 |
7283 | 1821 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1822 ck[0] = 0x5a; |
5575 | 1823 } |
1824 | |
1825 static void oscar_close(GaimConnection *gc) { | |
7283 | 1826 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1827 |
1828 while (od->oscar_chats) { | |
1829 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1830 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1831 gaim_input_remove(n->inpa); |
2086 | 1832 g_free(n->name); |
1833 g_free(n->show); | |
4617 | 1834 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1835 g_free(n); |
1836 } | |
4617 | 1837 while (od->direct_ims) { |
8971 | 1838 struct oscar_direct_im *n = od->direct_ims->data; |
1839 oscar_direct_im_destroy(od, n); | |
2086 | 1840 } |
4617 | 1841 /* BBB */ |
1842 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1843 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1844 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1845 gaim_xfer_cancel_local(xfer); |
3630 | 1846 } |
4804 | 1847 while (od->requesticon) { |
1848 char *sn = od->requesticon->data; | |
1849 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1850 free(sn); | |
1851 } | |
4738 | 1852 g_hash_table_destroy(od->buddyinfo); |
4617 | 1853 while (od->create_rooms) { |
1854 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1855 g_free(cr->name); |
4617 | 1856 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1857 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1858 } |
4617 | 1859 if (od->email) |
1860 g_free(od->email); | |
1861 if (od->newp) | |
1862 g_free(od->newp); | |
1863 if (od->oldp) | |
1864 g_free(od->oldp); | |
2086 | 1865 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1866 gaim_input_remove(gc->inpa); |
4617 | 1867 if (od->cnpa > 0) |
1868 gaim_input_remove(od->cnpa); | |
1869 if (od->paspa > 0) | |
1870 gaim_input_remove(od->paspa); | |
1871 if (od->emlpa > 0) | |
1872 gaim_input_remove(od->emlpa); | |
4804 | 1873 if (od->icopa > 0) |
1874 gaim_input_remove(od->icopa); | |
6907 | 1875 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1876 gaim_timeout_remove(od->icontimer); |
8341 | 1877 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1878 gaim_timeout_remove(od->getblisttimer); |
8341 | 1879 if (od->getinfotimer > 0) |
1880 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1881 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1882 |
4617 | 1883 aim_session_kill(od->sess); |
1884 g_free(od->sess); | |
1885 od->sess = NULL; | |
2086 | 1886 g_free(gc->proto_data); |
1887 gc->proto_data = NULL; | |
8660 | 1888 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1889 } |
1890 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1891 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1892 GaimConnection *gc = data; |
7283 | 1893 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1894 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1895 aim_conn_t *bosconn; |
2086 | 1896 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1897 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1898 close(source); |
1899 return; | |
1900 } | |
1901 | |
4617 | 1902 od = gc->proto_data; |
1903 sess = od->sess; | |
1904 bosconn = od->conn; | |
4366 | 1905 bosconn->fd = source; |
2086 | 1906 |
1907 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1908 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1909 return; |
1910 } | |
1911 | |
1912 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1913 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1914 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1915 gaim_connection_update_progress(gc, |
7283 | 1916 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1917 ck[4] = 0x61; |
2086 | 1918 } |
1919 | |
4617 | 1920 /* BBB */ |
4656 | 1921 /* |
1922 * This little area in oscar.c is the nexus of file transfer code, | |
1923 * so I wrote a little explanation of what happens. I am such a | |
1924 * ninja. | |
1925 * | |
1926 * The series of events for a file send is: | |
1927 * -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
|
1928 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1929 * listening socket, then asks the remote user to connect to us (and |
1930 * gives them the file name, port, IP, etc.) | |
1931 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1932 * in oscar_sendfile_estblsh) | |
1933 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1934 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1935 * connection. | |
1936 * -We get drunk because file transfer kicks ass. | |
1937 * | |
1938 * The series of events for a file receive is: | |
1939 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1940 * -Gaim user selects file to name and location to save file to and | |
1941 * oscar_xfer_init is called | |
1942 * -It connects to the remote user using the IP they gave us earlier | |
1943 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1944 * them an AIM_CB_OFT_ACK. | |
1945 * -They begin to send us lots of raw data. | |
1946 * -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
|
1947 * the connection. |
4656 | 1948 */ |
1949 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1950 | |
8446 | 1951 /* |
1952 * Miscellaneous xfer functions | |
1953 */ | |
1954 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1955 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1956 GaimXfer *xfer; |
5146 | 1957 struct aim_oft_info *oft_info; |
4656 | 1958 |
1959 while (fts) { | |
1960 xfer = fts->data; | |
5146 | 1961 oft_info = xfer->data; |
1962 | |
8446 | 1963 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1964 return xfer; |
1965 | |
1966 fts = g_slist_next(fts); | |
1967 } | |
1968 | |
1969 return NULL; | |
1970 } | |
1971 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1972 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1973 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1974 GaimXfer *xfer; |
5146 | 1975 struct aim_oft_info *oft_info; |
4656 | 1976 |
1977 while (fts) { | |
1978 xfer = fts->data; | |
5146 | 1979 oft_info = xfer->data; |
1980 | |
1981 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1982 return xfer; |
1983 | |
1984 fts = g_slist_next(fts); | |
1985 } | |
1986 | |
1987 return NULL; | |
1988 } | |
1989 | |
8446 | 1990 static void oscar_xfer_end(GaimXfer *xfer) |
1991 { | |
1992 struct aim_oft_info *oft_info = xfer->data; | |
1993 GaimConnection *gc = oft_info->sess->aux_data; | |
1994 OscarData *od = gc->proto_data; | |
1995 | |
8660 | 1996 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1997 |
1998 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1999 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
2000 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
2001 } | |
2002 | |
2003 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2004 aim_oft_destroyinfo(oft_info); | |
2005 xfer->data = NULL; | |
2006 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2007 } | |
2008 | |
2009 /* | |
2010 * xfer functions used when receiving files | |
2011 */ | |
2012 | |
11084 | 2013 /* |
2014 * This is a gaim timeout callback for when the clientip looks to be useless (after verifiedip has been tried) | |
2015 * It gives up on the file transfer completely if it doesn't approve of the file transfer status | |
2016 */ | |
2017 static gboolean oscar_clientip_timeout(gpointer data) { | |
2018 GaimXfer *xfer; | |
2019 struct aim_oft_info *oft_info; | |
2020 char *msg = NULL; | |
11214 | 2021 |
11084 | 2022 gaim_debug_info("oscar","AAA - in oscar_clientip_timeout\n"); |
2023 xfer = (GaimXfer*) data; | |
2024 if(xfer->data) { | |
2025 oft_info = (struct aim_oft_info*) xfer->data; | |
11214 | 2026 |
11084 | 2027 /* Check to see if the clientip has produced any results */ |
11214 | 2028 if(!oft_info->success) { |
11084 | 2029 msg = g_strdup_printf(_("Transfer of file %s timed out."),gaim_xfer_get_filename(xfer)); |
2030 gaim_xfer_conversation_write(xfer, msg, TRUE); | |
2031 g_free(msg); | |
2032 gaim_xfer_unref(xfer); | |
2033 gaim_xfer_cancel_local(xfer); | |
11214 | 2034 } else { |
2035 gaim_debug_info("oscar","connection successful; no action taken\n"); | |
11084 | 2036 } |
2037 } | |
2038 return FALSE; | |
2039 } | |
2040 | |
2041 /* | |
2042 * This is a gaim timeout callback for when the verifiedip looks to be useless | |
2043 * It tries the file transfer again using the clientip | |
2044 * | |
2045 * BBB | |
2046 */ | |
2047 static gboolean oscar_verifiedip_timeout(gpointer data) { | |
2048 GaimXfer *xfer; | |
2049 struct aim_oft_info *oft_info; | |
2050 | |
2051 gaim_debug_info("oscar","AAA - in oscar_verifiedip_timeout\n"); | |
2052 xfer = (GaimXfer*) data; | |
2053 if(xfer->data) { | |
2054 oft_info = (struct aim_oft_info*) xfer->data; | |
2055 | |
2056 /* Check to see if the verifiedip has produced any results */ | |
11214 | 2057 if(!oft_info->success) { |
11084 | 2058 /* gaim_xfer_conversation_write(xfer, |
2059 "Attempting file transfer via secondary IP address...", FALSE); */ | |
2060 | |
2061 /* The verifiedip connection has worn out its welcome. Goodbye. */ | |
11214 | 2062 close(oft_info->conn->fd); |
11084 | 2063 aim_conn_kill(oft_info->sess, &oft_info->conn); |
2064 | |
2065 /* Try the file transfer again with the clientip */ | |
2066 g_free(xfer->remote_ip); | |
2067 xfer->remote_ip = g_strdup(oft_info->clientip); | |
11214 | 2068 gaim_debug_info("oscar","attempting connection using clientip: %s\n", xfer->remote_ip); |
11084 | 2069 oscar_xfer_init_recv(xfer); |
11214 | 2070 } else { |
2071 gaim_debug_info("oscar","connection successful; no action taken\n"); | |
11084 | 2072 } |
2073 } | |
2074 return FALSE; | |
2075 } | |
11162 | 2076 |
8446 | 2077 static void oscar_xfer_init_recv(GaimXfer *xfer) |
2078 { | |
2079 struct aim_oft_info *oft_info = xfer->data; | |
2080 GaimConnection *gc = oft_info->sess->aux_data; | |
2081 OscarData *od = gc->proto_data; | |
2082 | |
8660 | 2083 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
11214 | 2084 |
11084 | 2085 /* Start a timer for this ip address |
2086 * If the verifiedip fails, try the clientip | |
2087 * If clientip fails, declare the whole file transfer dead | |
2088 * This xfer reference will be released in oscar_clientip_timeout */ | |
2089 if(xfer->data) { | |
2090 gaim_xfer_ref(xfer); | |
2091 /* If clientip & verifiedip are the same, we must prevent an infinite loop */ | |
2092 if(g_ascii_strcasecmp(xfer->remote_ip, oft_info->verifiedip) == 0 | |
2093 && g_ascii_strcasecmp(oft_info->clientip, oft_info->verifiedip) != 0 ) { | |
2094 gaim_timeout_add(FT_IP_TIMEOUT * 1000, oscar_verifiedip_timeout, xfer); | |
2095 } else { | |
2096 gaim_timeout_add(FT_IP_TIMEOUT * 1000, oscar_clientip_timeout, xfer); | |
2097 } | |
2098 } | |
8446 | 2099 |
11162 | 2100 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS); |
8446 | 2101 if (oft_info->conn) { |
2102 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2103 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
2104 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
11214 | 2105 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); |
8446 | 2106 if (xfer->fd == -1) { |
10654 | 2107 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2108 _("Unable to establish file descriptor.")); |
2109 gaim_xfer_cancel_local(xfer); | |
2110 } | |
2111 } else { | |
10654 | 2112 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2113 _("Unable to create new connection.")); |
2114 gaim_xfer_cancel_local(xfer); | |
2115 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2116 } | |
2117 | |
2118 } | |
2119 | |
2120 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
2121 { | |
10405 | 2122 struct aim_oft_info *oft_info; |
2123 GaimConnection *gc; | |
2124 OscarData *od; | |
2125 | |
2126 g_return_if_fail(xfer != NULL); | |
2127 g_return_if_fail(xfer->data != NULL); | |
2128 | |
2129 oft_info = xfer->data; | |
2130 gc = oft_info->sess->aux_data; | |
2131 od = gc->proto_data; | |
8446 | 2132 |
8660 | 2133 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2134 |
9771 | 2135 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2136 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2137 |
2138 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2139 aim_oft_destroyinfo(oft_info); | |
2140 xfer->data = NULL; | |
2141 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2142 } | |
2143 | |
11159 | 2144 static void oscar_xfer_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2145 { |
2146 struct aim_oft_info *oft_info = xfer->data; | |
2147 | |
2148 /* Update our rolling checksum. Like Walmart, yo. */ | |
2149 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2150 } | |
2151 | |
2152 /* | |
2153 * xfer functions used when sending files | |
2154 */ | |
2155 | |
2156 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2157 { | |
2158 struct aim_oft_info *oft_info = xfer->data; | |
2159 GaimConnection *gc = oft_info->sess->aux_data; | |
2160 OscarData *od = gc->proto_data; | |
2161 int listenfd; | |
2162 | |
8660 | 2163 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2164 |
2165 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2166 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2167 oft_info->fh.name[63] = '\0'; | |
2168 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2169 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2170 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2171 | |
2172 /* Create a listening socket and an associated libfaim conn */ | |
2173 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2174 gaim_xfer_cancel_local(xfer); | |
2175 return; | |
2176 } | |
2177 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2178 oft_info->port = xfer->local_port; | |
2179 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2180 gaim_xfer_cancel_local(xfer); | |
2181 return; | |
2182 } | |
8660 | 2183 gaim_debug_misc("oscar", |
8446 | 2184 "port is %hu, ip is %s\n", |
2185 xfer->local_port, oft_info->clientip); | |
2186 if (oft_info->conn) { | |
2187 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2188 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2189 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2190 } else { | |
10654 | 2191 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2192 _("Unable to establish listener socket.")); |
2193 gaim_xfer_cancel_local(xfer); | |
2194 } | |
2195 } | |
2196 | |
2197 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2198 { | |
2199 struct aim_oft_info *oft_info = xfer->data; | |
2200 GaimConnection *gc = oft_info->sess->aux_data; | |
2201 OscarData *od = gc->proto_data; | |
2202 | |
8660 | 2203 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2204 |
9771 | 2205 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2206 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2207 |
2208 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2209 aim_oft_destroyinfo(oft_info); | |
2210 xfer->data = NULL; | |
2211 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2212 } | |
2213 | |
11159 | 2214 static void oscar_xfer_ack_send(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2215 { |
2216 struct aim_oft_info *oft_info = xfer->data; | |
2217 | |
2218 /* I'm not sure I like how we do this. --marv | |
2219 * I do. AIM file transfers aren't really meant to be thought | |
2220 * of as a transferring just a single file. The rendezvous | |
2221 * establishes a connection between two computers, and then | |
2222 * those computers can use the same connection for transferring | |
2223 * multiple files. So we don't want the Gaim core up and closing | |
2224 * the socket all willy-nilly. We want to do that in the oscar | |
2225 * prpl, whenever one side or the other says they're finished | |
2226 * using the connection. There might be a better way to intercept | |
2227 * the socket from the core, however... --KingAnt | |
2228 */ | |
2229 | |
2230 /* | |
2231 * If we're done sending, intercept the socket from the core ft code | |
2232 * and wait for the other guy to send the "done" OFT packet. | |
2233 */ | |
2234 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2235 gaim_input_remove(xfer->watcher); | |
2236 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2237 xfer->fd = 0; | |
2238 gaim_xfer_set_completed(xfer, TRUE); | |
2239 } | |
2240 } | |
2241 | |
9466 | 2242 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2243 gboolean can_receive = FALSE; | |
2244 OscarData *od = gc->proto_data; | |
2245 | |
11049 | 2246 if (od != NULL) { |
9466 | 2247 aim_userinfo_t *userinfo; |
2248 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2249 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2250 can_receive = TRUE; | |
2251 } | |
2252 | |
2253 return can_receive; | |
2254 } | |
2255 | |
2256 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2257 |
2258 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2259 GaimXfer *xfer; |
5146 | 2260 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2261 const char *ip; |
3752 | 2262 |
9030 | 2263 od = (OscarData *)gc->proto_data; |
2264 | |
4617 | 2265 /* You want to send a file to someone else, you're so generous */ |
2266 | |
2267 /* Build the file transfer handle */ | |
9466 | 2268 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2269 |
5146 | 2270 /* Create the oscar-specific data */ |
8838 | 2271 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2272 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2273 xfer->data = oft_info; |
2274 | |
4617 | 2275 /* Setup our I/O op functions */ |
8446 | 2276 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2277 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2278 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2279 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2280 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2281 |
2282 /* Keep track of this transfer for later */ | |
2283 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2284 | |
2285 /* Now perform the request */ | |
9466 | 2286 if (file) |
2287 gaim_xfer_request_accepted(xfer, file); | |
2288 else | |
2289 gaim_xfer_request(xfer); | |
3630 | 2290 } |
2291 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2292 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2293 GaimConnection *gc = sess->aux_data; |
7283 | 2294 OscarData *od = gc->proto_data; |
6029 | 2295 GaimAccount *account = gc->account; |
2296 aim_conn_t *bosconn; | |
2297 char *host; int port; | |
2298 int i, rc; | |
2086 | 2299 va_list ap; |
2704 | 2300 struct aim_authresp_info *info; |
6029 | 2301 |
11338 | 2302 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); |
2086 | 2303 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2304 va_start(ap, fr); |
2704 | 2305 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2306 va_end(ap); |
2307 | |
8660 | 2308 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2309 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2310 |
4293 | 2311 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2312 char buf[256]; |
2704 | 2313 switch (info->errorcode) { |
2086 | 2314 case 0x05: |
2315 /* Incorrect nick/password */ | |
6498 | 2316 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2317 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2318 break; |
2319 case 0x11: | |
2320 /* Suspended account */ | |
6498 | 2321 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2322 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2323 break; |
3498 | 2324 case 0x14: |
2325 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2326 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2327 break; |
2086 | 2328 case 0x18: |
2329 /* connecting too frequently */ | |
6498 | 2330 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2331 gaim_connection_error(gc, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); |
2086 | 2332 break; |
2333 case 0x1c: | |
2334 /* client too old */ | |
6498 | 2335 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2336 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), GAIM_WEBSITE); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2337 gaim_connection_error(gc, buf); |
2086 | 2338 break; |
2339 default: | |
6623 | 2340 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2341 break; |
2342 } | |
8660 | 2343 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2344 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2345 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2346 "Error URL: %s\n", info->errorurl); |
2086 | 2347 od->killme = TRUE; |
2348 return 1; | |
2349 } | |
2350 | |
2351 | |
9992 | 2352 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2353 |
2704 | 2354 if (info->email) { |
8660 | 2355 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2356 } else { |
8660 | 2357 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2358 } |
10042 | 2359 |
8660 | 2360 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2361 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2362 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2363 aim_conn_kill(sess, &fr->conn); |
2086 | 2364 |
11162 | 2365 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS); |
2086 | 2366 if (bosconn == NULL) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2367 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2368 od->killme = TRUE; |
2369 return 0; | |
2370 } | |
2371 | |
4649 | 2372 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2373 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2374 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2375 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2376 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2377 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2378 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2379 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2380 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2381 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2382 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2383 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2384 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2385 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2386 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2387 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2388 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2389 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2390 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2391 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2392 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2393 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2394 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2395 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2396 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2397 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2398 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2399 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2400 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2401 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0021, oscar_icon_req,0); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
2402 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
2403 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
2404 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2405 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2406 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4642 | 2407 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2408 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2409 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2410 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2411 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2412 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2413 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2414 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2415 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2416 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2417 |
7283 | 2418 od->conn = bosconn; |
2704 | 2419 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2420 if (info->bosip[i] == ':') { | |
2421 port = atoi(&(info->bosip[i+1])); | |
2086 | 2422 break; |
2423 } | |
2424 } | |
2704 | 2425 host = g_strndup(info->bosip, i); |
2086 | 2426 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2427 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2428 g_free(host); |
4366 | 2429 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2430 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2431 od->killme = TRUE; |
2432 return 0; | |
2433 } | |
4293 | 2434 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2435 gaim_input_remove(gc->inpa); |
2704 | 2436 |
7283 | 2437 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2438 ck[3] = 0x64; |
7282 | 2439 |
2086 | 2440 return 1; |
2441 } | |
2442 | |
10464 | 2443 static void |
2444 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2445 { | |
2446 GaimConnection *gc = user_data; | |
2447 OscarData *od = gc->proto_data; | |
2448 aim_session_t *sess = od->sess; | |
2449 | |
2450 aim_auth_securid_send(sess, msg); | |
2451 } | |
2452 | |
2453 static void | |
2454 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2455 { | |
2456 GaimConnection *gc = user_data; | |
2457 OscarData *od = gc->proto_data; | |
2458 | |
2459 /* Disconnect */ | |
2460 gc->wants_to_die = TRUE; | |
2461 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2462 od->killme = TRUE; | |
2463 } | |
2464 | |
2465 static int | |
2466 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2467 { | |
2468 GaimConnection *gc = sess->aux_data; | |
2469 GaimAccount *account = gaim_connection_get_account(gc); | |
2470 gchar *primary; | |
2471 | |
2472 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2473 | |
2474 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2475 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2476 _("Enter the 6 digit number from the digital display."), | |
2477 FALSE, FALSE, NULL, | |
2478 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2479 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2480 gc); | |
2481 g_free(primary); | |
2482 | |
2483 return 1; | |
2484 } | |
2485 | |
7285 | 2486 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2487 struct pieceofcrap { |
5575 | 2488 GaimConnection *gc; |
2086 | 2489 unsigned long offset; |
2490 unsigned long len; | |
2491 char *modname; | |
2492 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2493 aim_conn_t *conn; |
2086 | 2494 unsigned int inpa; |
2495 }; | |
2496 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2497 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2498 { |
2499 struct pieceofcrap *pos = data; | |
7283 | 2500 OscarData *od = pos->gc->proto_data; |
2086 | 2501 char in = '\0'; |
2502 int x = 0; | |
2503 unsigned char m[17]; | |
2504 | |
2505 while (read(pos->fd, &in, 1) == 1) { | |
2506 if (in == '\n') | |
2507 x++; | |
2508 else if (in != '\r') | |
2509 x = 0; | |
2510 if (x == 2) | |
2511 break; | |
2512 in = '\0'; | |
2513 } | |
2514 if (in != '\n') { | |
4056 | 2515 char buf[256]; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2516 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2517 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2518 gaim_notify_warning(pos->gc, NULL, |
7422 | 2519 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2520 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2521 gaim_input_remove(pos->inpa); |
2086 | 2522 close(pos->fd); |
2523 g_free(pos); | |
2524 return; | |
2525 } | |
2526 read(pos->fd, m, 16); | |
2527 m[16] = '\0'; | |
8660 | 2528 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2529 for (x = 0; x < 16; x++) |
8660 | 2530 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2531 | |
2532 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2533 gaim_input_remove(pos->inpa); |
2086 | 2534 close(pos->fd); |
2535 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2536 g_free(pos); | |
2537 } | |
2538 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2539 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2540 struct pieceofcrap *pos = data; |
5420 | 2541 gchar *buf; |
2086 | 2542 |
4366 | 2543 pos->fd = source; |
2544 | |
2086 | 2545 if (source < 0) { |
5420 | 2546 buf = g_strdup_printf(_("You may be disconnected shortly. You may want to use TOC until " |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2547 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2548 gaim_notify_warning(pos->gc, NULL, |
7422 | 2549 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2550 buf); |
5420 | 2551 g_free(buf); |
2086 | 2552 if (pos->modname) |
2553 g_free(pos->modname); | |
2554 g_free(pos); | |
2555 return; | |
2556 } | |
2557 | |
5420 | 2558 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2559 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2560 write(pos->fd, buf, strlen(buf)); | |
5420 | 2561 g_free(buf); |
2086 | 2562 if (pos->modname) |
2563 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2564 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2565 return; |
2566 } | |
2567 | |
2568 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2569 #define AIM_MAX_FILE_SIZE 98304 | |
2570 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2571 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2572 va_list ap; |
2573 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2574 fu32_t offset, len; |
2086 | 2575 char *modname; |
2576 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2577 va_start(ap, fr); |
4200 | 2578 offset = va_arg(ap, fu32_t); |
2579 len = va_arg(ap, fu32_t); | |
2086 | 2580 modname = va_arg(ap, char *); |
2581 va_end(ap); | |
2582 | |
8660 | 2583 gaim_debug_misc("oscar", |
5556 | 2584 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2585 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2586 |
2086 | 2587 if (len == 0) { |
8660 | 2588 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2589 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2590 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2591 return 1; | |
2592 } | |
9625 | 2593 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2594 #if 0 | |
2086 | 2595 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2596 char *buf; | |
2597 int i = 8; | |
2598 if (modname) | |
2599 i += strlen(modname); | |
2600 buf = g_malloc(i); | |
2601 i = 0; | |
2602 if (modname) { | |
2603 memcpy(buf, modname, strlen(modname)); | |
2604 i += strlen(modname); | |
2605 } | |
2606 buf[i++] = offset & 0xff; | |
2607 buf[i++] = (offset >> 8) & 0xff; | |
2608 buf[i++] = (offset >> 16) & 0xff; | |
2609 buf[i++] = (offset >> 24) & 0xff; | |
2610 buf[i++] = len & 0xff; | |
2611 buf[i++] = (len >> 8) & 0xff; | |
2612 buf[i++] = (len >> 16) & 0xff; | |
2613 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2614 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2615 "hashing request\n"); |
2086 | 2616 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2617 g_free(buf); | |
2618 return 1; | |
2619 } | |
9625 | 2620 #endif |
2086 | 2621 |
2622 pos = g_new0(struct pieceofcrap, 1); | |
2623 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2624 pos->conn = fr->conn; |
2086 | 2625 |
2626 pos->offset = offset; | |
2627 pos->len = len; | |
2628 pos->modname = modname ? g_strdup(modname) : NULL; | |
2629 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2630 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2631 char buf[256]; |
2086 | 2632 if (pos->modname) |
2633 g_free(pos->modname); | |
2634 g_free(pos); | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2635 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2636 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2637 gaim_notify_warning(pos->gc, NULL, |
7422 | 2638 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2639 buf); |
2086 | 2640 } |
2641 | |
2642 return 1; | |
2643 } | |
2644 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2645 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2646 GaimConnection *gc = sess->aux_data; |
7283 | 2647 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2648 GaimAccount *account = gaim_connection_get_account(gc); |
7282 | 2649 #if 0 |
2650 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2651 #endif | |
7011 | 2652 va_list ap; |
2653 char *key; | |
2086 | 2654 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2655 va_start(ap, fr); |
2086 | 2656 key = va_arg(ap, char *); |
2657 va_end(ap); | |
2658 | |
4617 | 2659 if (od->icq) { |
3458 | 2660 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
10740 | 2661 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2662 gaim_connection_get_password(gc), &info, key); | |
3458 | 2663 } else { |
2664 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
10740 | 2665 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
2666 gaim_connection_get_password(gc), &info, key); | |
3458 | 2667 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2668 |
7283 | 2669 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2670 ck[2] = 0x6c; |
7282 | 2671 |
2086 | 2672 return 1; |
2673 } | |
2674 | |
2675 | 2675 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2676 GaimConnection *gc = sess->aux_data; |
2647 | 2677 struct chat_connection *chatcon; |
2678 static int id = 1; | |
2679 | |
6905 | 2680 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, 0x0001, gaim_parse_genericerr, 0); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2681 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_conv_chat_join, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2682 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_conv_chat_leave, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2683 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_conv_chat_info_update, 0); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2684 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2685 |
2672 | 2686 aim_clientready(sess, fr->conn); |
2675 | 2687 |
2647 | 2688 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2689 chatcon->id = id; | |
8733 | 2690 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2691 |
2692 return 1; | |
2693 } | |
2694 | |
2675 | 2695 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2696 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2697 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2698 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2699 |
2700 aim_clientready(sess, fr->conn); | |
2701 | |
2702 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2703 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2704 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2705 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2706 |
3694 | 2707 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2708 | |
2709 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2710 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2711 | |
7282 | 2712 aim_email_sendcookies(sess); |
2713 aim_email_activate(sess); | |
3694 | 2714 aim_clientready(sess, fr->conn); |
2715 | |
2716 return 1; | |
2717 } | |
2718 | |
4804 | 2719 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2720 GaimConnection *gc = sess->aux_data; |
7283 | 2721 OscarData *od = gc->proto_data; |
4804 | 2722 |
2723 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2724 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2725 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2726 | |
2727 aim_clientready(sess, fr->conn); | |
2728 | |
4823 | 2729 od->iconconnecting = FALSE; |
2730 | |
4804 | 2731 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2732 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2733 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2734 |
2735 return 1; | |
2736 } | |
2737 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2738 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2739 GaimConnection *gc = data; |
7283 | 2740 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2741 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2742 aim_conn_t *tstconn; |
2086 | 2743 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2744 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2745 close(source); |
2746 return; | |
2747 } | |
2748 | |
4617 | 2749 od = gc->proto_data; |
2750 sess = od->sess; | |
2086 | 2751 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2752 tstconn->fd = source; |
2086 | 2753 |
2754 if (source < 0) { | |
2755 aim_conn_kill(sess, &tstconn); | |
8660 | 2756 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2757 "unable to connect to chatnav server\n"); |
2086 | 2758 return; |
2759 } | |
2760 | |
2761 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2762 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2763 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2764 } |
2765 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2766 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2767 { |
5575 | 2768 GaimConnection *gc = data; |
7283 | 2769 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2770 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2771 aim_conn_t *tstconn; |
2086 | 2772 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2773 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2774 close(source); |
2775 return; | |
2776 } | |
2777 | |
4617 | 2778 od = gc->proto_data; |
2779 sess = od->sess; | |
2086 | 2780 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2781 tstconn->fd = source; |
2086 | 2782 |
2783 if (source < 0) { | |
2784 aim_conn_kill(sess, &tstconn); | |
8660 | 2785 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2786 "unable to connect to authorizer\n"); |
2086 | 2787 return; |
2788 } | |
2789 | |
2790 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2791 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2792 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2793 } |
2794 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2795 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2796 { |
2797 struct chat_connection *ccon = data; | |
5575 | 2798 GaimConnection *gc = ccon->gc; |
7283 | 2799 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2800 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2801 aim_conn_t *tstconn; |
2086 | 2802 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2803 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2804 close(source); |
2805 g_free(ccon->show); | |
2806 g_free(ccon->name); | |
2807 g_free(ccon); | |
2808 return; | |
2809 } | |
2810 | |
4617 | 2811 od = gc->proto_data; |
2812 sess = od->sess; | |
2086 | 2813 tstconn = ccon->conn; |
4366 | 2814 tstconn->fd = source; |
2086 | 2815 |
2816 if (source < 0) { | |
2817 aim_conn_kill(sess, &tstconn); | |
2818 g_free(ccon->show); | |
2819 g_free(ccon->name); | |
2820 g_free(ccon); | |
2821 return; | |
2822 } | |
2823 | |
2824 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2825 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2826 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2827 } |
2828 | |
3694 | 2829 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2830 GaimConnection *gc = data; |
7283 | 2831 OscarData *od; |
3694 | 2832 aim_session_t *sess; |
2833 aim_conn_t *tstconn; | |
2834 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2835 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2836 close(source); |
2837 return; | |
2838 } | |
2839 | |
4617 | 2840 od = gc->proto_data; |
2841 sess = od->sess; | |
3694 | 2842 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2843 tstconn->fd = source; |
3694 | 2844 |
2845 if (source < 0) { | |
2846 aim_conn_kill(sess, &tstconn); | |
8660 | 2847 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2848 "unable to connect to email server\n"); |
3694 | 2849 return; |
2850 } | |
2851 | |
2852 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2853 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2854 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2855 "email: connected\n"); |
3694 | 2856 } |
2857 | |
4804 | 2858 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2859 GaimConnection *gc = data; |
7283 | 2860 OscarData *od; |
4804 | 2861 aim_session_t *sess; |
2862 aim_conn_t *tstconn; | |
2863 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2864 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2865 close(source); |
2866 return; | |
2867 } | |
2868 | |
2869 od = gc->proto_data; | |
2870 sess = od->sess; | |
2871 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2872 tstconn->fd = source; | |
2873 | |
2874 if (source < 0) { | |
2875 aim_conn_kill(sess, &tstconn); | |
8660 | 2876 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2877 "unable to connect to icon server\n"); |
4804 | 2878 return; |
2879 } | |
2880 | |
2881 aim_conn_completeconnect(sess, tstconn); | |
2882 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2883 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2884 } |
2885 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2886 /* Hrmph. I don't know how to make this look better. --mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2887 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2888 GaimConnection *gc = sess->aux_data; |
2889 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2890 aim_conn_t *tstconn; |
4452 | 2891 int i; |
2086 | 2892 char *host; |
2893 int port; | |
4821 | 2894 va_list ap; |
2895 struct aim_redirect_data *redir; | |
2086 | 2896 |
11338 | 2897 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); |
2086 | 2898 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2899 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2900 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2901 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2902 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2903 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2904 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2905 port = atoi(&(redir->ip[i+1])); |
2086 | 2906 break; |
2907 } | |
2908 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2909 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2910 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2911 switch(redir->group) { |
2086 | 2912 case 0x7: /* Authorizer */ |
8660 | 2913 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2914 "Reconnecting with authorizor...\n"); |
11162 | 2915 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
2086 | 2916 if (tstconn == NULL) { |
8660 | 2917 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2918 "unable to reconnect with authorizer\n"); |
2086 | 2919 g_free(host); |
2920 return 1; | |
2921 } | |
4649 | 2922 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2923 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2924 |
2925 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2926 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2927 aim_conn_kill(sess, &tstconn); |
8660 | 2928 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2929 "unable to reconnect with authorizer\n"); |
2086 | 2930 g_free(host); |
2931 return 1; | |
2932 } | |
4293 | 2933 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2934 break; |
2935 | |
2086 | 2936 case 0xd: /* ChatNav */ |
11162 | 2937 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV); |
2086 | 2938 if (tstconn == NULL) { |
8660 | 2939 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2940 "unable to connect to chatnav server\n"); |
2086 | 2941 g_free(host); |
2942 return 1; | |
2943 } | |
4649 | 2944 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2945 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2946 |
2947 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2948 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2949 aim_conn_kill(sess, &tstconn); |
8660 | 2950 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2951 "unable to connect to chatnav server\n"); |
2086 | 2952 g_free(host); |
2953 return 1; | |
2954 } | |
4293 | 2955 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2956 break; |
2957 | |
2958 case 0xe: { /* Chat */ | |
2086 | 2959 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2960 |
11162 | 2961 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT); |
2086 | 2962 if (tstconn == NULL) { |
8660 | 2963 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2964 "unable to connect to chat server\n"); |
2086 | 2965 g_free(host); |
2966 return 1; | |
2967 } | |
2968 | |
4649 | 2969 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2970 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2971 | |
2086 | 2972 ccon = g_new0(struct chat_connection, 1); |
2973 ccon->conn = tstconn; | |
2974 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2975 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2976 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2977 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2978 ccon->show = extract_name(redir->chat.room); |
4634 | 2979 |
2086 | 2980 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2981 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2982 aim_conn_kill(sess, &tstconn); |
8660 | 2983 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2984 "unable to connect to chat server\n"); |
2086 | 2985 g_free(host); |
2986 g_free(ccon->show); | |
2987 g_free(ccon->name); | |
2988 g_free(ccon); | |
2989 return 1; | |
2990 } | |
4293 | 2991 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2992 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2993 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2994 ccon->name, ccon->exchange); |
4194 | 2995 } break; |
3694 | 2996 |
4804 | 2997 case 0x0010: { /* icon */ |
11162 | 2998 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON))) { |
8660 | 2999 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3000 "unable to connect to icon server\n"); |
4804 | 3001 g_free(host); |
3002 return 1; | |
3003 } | |
3004 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
3005 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
3006 | |
3007 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3008 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 3009 aim_conn_kill(sess, &tstconn); |
8660 | 3010 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3011 "unable to connect to icon server\n"); |
4804 | 3012 g_free(host); |
3013 return 1; | |
3014 } | |
3015 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
3016 } break; | |
3017 | |
3694 | 3018 case 0x0018: { /* email */ |
11162 | 3019 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL))) { |
8660 | 3020 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3021 "unable to connect to email server\n"); |
3694 | 3022 g_free(host); |
3023 return 1; | |
3024 } | |
4649 | 3025 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 3026 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
3027 | |
3028 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3029 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 3030 aim_conn_kill(sess, &tstconn); |
8660 | 3031 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3032 "unable to connect to email server\n"); |
3694 | 3033 g_free(host); |
3034 return 1; | |
3035 } | |
4293 | 3036 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 3037 } break; |
3038 | |
2086 | 3039 default: /* huh? */ |
8660 | 3040 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3041 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3042 redir->group); |
2086 | 3043 break; |
3044 } | |
3045 | |
3046 g_free(host); | |
3047 return 1; | |
3048 } | |
3049 | |
10042 | 3050 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
3051 { | |
3052 GaimConnection *gc; | |
3053 GaimAccount *account; | |
3054 OscarData *od; | |
4738 | 3055 struct buddyinfo *bi; |
2993 | 3056 time_t time_idle = 0, signon = 0; |
3057 int type = 0; | |
3058 int caps = 0; | |
2086 | 3059 va_list ap; |
4738 | 3060 aim_userinfo_t *info; |
10042 | 3061 gboolean buddy_is_away = FALSE; |
3062 | |
3063 gc = sess->aux_data; | |
3064 account = gaim_connection_get_account(gc); | |
3065 od = gc->proto_data; | |
4194 | 3066 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3067 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3068 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3069 va_end(ap); |
3070 | |
10130 | 3071 g_return_val_if_fail(info != NULL, 1); |
3072 g_return_val_if_fail(info->sn != NULL, 1); | |
3073 | |
2993 | 3074 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
3075 caps = info->capabilities; | |
3267 | 3076 |
4766 | 3077 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
3078 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 3079 buddy_is_away = TRUE; |
3080 } | |
3081 | |
2993 | 3082 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 3083 type = (info->icqinfo.status << 16); |
3013 | 3084 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3085 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3086 buddy_is_away = TRUE; |
3013 | 3087 } |
2993 | 3088 } |
3089 | |
7141 | 3090 if (caps & AIM_CAPS_ICQ_DIRECT) |
3091 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 3092 |
10860 | 3093 /* info->idletime is the number of minutes that this user has been idle */ |
3094 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
3095 time_idle = time(NULL) - info->idletime * 60; | |
2993 | 3096 |
5836 | 3097 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3098 signon = info->onlinesince; | |
3099 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3100 signon = time(NULL) - info->sessionlen; |
2086 | 3101 |
10567 | 3102 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3103 gaim_connection_set_display_name(gc, info->sn); |
10567 | 3104 od->timeoffset = signon - gc->login_time; |
3105 } | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
3106 |
9982 | 3107 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3108 if (!bi) { |
3109 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3110 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3111 } |
4739 | 3112 bi->typingnot = FALSE; |
3113 bi->ico_informed = FALSE; | |
6857 | 3114 bi->ipaddr = info->icqinfo.ipaddr; |
3115 | |
10563 | 3116 /* |
3117 * Handle the available message. If info->avail is NULL then the user | |
3118 * may or may not have an available message, so don't do anything. If | |
3119 * info->avail is set to the empty string, then the user's client DOES | |
3120 * support available messages and the user DOES NOT have one set. | |
3121 * Otherwise info->avail contains the available message. | |
3122 */ | |
7011 | 3123 if (info->avail != NULL) |
10563 | 3124 { |
3125 free(bi->availmsg); | |
3126 if (info->avail[0] != '\0') | |
3127 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); | |
3128 else | |
3129 bi->availmsg = NULL; | |
3130 } | |
4732 | 3131 |
4804 | 3132 /* Server stored icon stuff */ |
4853 | 3133 if (info->iconcsumlen) { |
7125 | 3134 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3135 char *b16 = NULL, *filepath = NULL; |
7093 | 3136 GaimBuddy *b = NULL; |
4853 | 3137 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3138 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3139 b = gaim_find_buddy(account, info->sn); |
7093 | 3140 /* |
3141 * If for some reason the checksum is valid, but cached file is not.. | |
3142 * we want to know. | |
3143 */ | |
7693 | 3144 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3145 if (filename != NULL) { |
3146 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3147 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3148 "icon_checksum"); | |
9801 | 3149 else { |
3150 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3151 filename, NULL); | |
3152 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3153 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3154 "icon_checksum"); | |
3155 g_free(filepath); | |
3156 } | |
7093 | 3157 } else |
3158 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3159 |
4853 | 3160 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3161 GSList *cur = od->requesticon; | |
3162 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3163 cur = cur->next; | |
3164 if (!cur) { | |
9982 | 3165 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3166 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3167 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3168 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3169 } |
3170 } | |
6053 | 3171 g_free(b16); |
4853 | 3172 } |
3173 | |
10042 | 3174 /* XXX - Represent other ICQ statuses */ |
3175 if (buddy_is_away == TRUE) | |
3176 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
3177 else | |
3178 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
10567 | 3179 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
11257 | 3180 // gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); |
9982 | 3181 |
3182 if (time_idle > 0) | |
3183 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 3184 else |
3185 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 3186 |
3187 return 1; | |
3188 } | |
3189 | |
8341 | 3190 static void gaim_check_comment(OscarData *od, const char *str) { |
11159 | 3191 if ((str == NULL) || strcmp(str, (const char *)ck)) |
8341 | 3192 aim_locate_setcaps(od->sess, caps_aim); |
3193 else | |
3194 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3195 } | |
3196 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3197 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3198 GaimConnection *gc = sess->aux_data; |
7283 | 3199 OscarData *od = gc->proto_data; |
9982 | 3200 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3201 va_list ap; |
4739 | 3202 aim_userinfo_t *info; |
2086 | 3203 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3204 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3205 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3206 va_end(ap); |
3207 | |
9982 | 3208 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3209 |
7261 | 3210 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3211 |
2086 | 3212 return 1; |
3213 } | |
3214 | |
4617 | 3215 /* BBB */ |
3952 | 3216 /* |
4617 | 3217 * This is called after a remote AIM user has connected to us. We |
3218 * want to do some voodoo with the socket file descriptors, add a | |
3219 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3220 */ |
4656 | 3221 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3222 GaimConnection *gc = sess->aux_data; |
7283 | 3223 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3224 GaimXfer *xfer; |
5146 | 3225 struct aim_oft_info *oft_info; |
3630 | 3226 va_list ap; |
3227 aim_conn_t *conn, *listenerconn; | |
4656 | 3228 |
8660 | 3229 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3230 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3231 va_start(ap, fr); |
3232 conn = va_arg(ap, aim_conn_t *); | |
3233 listenerconn = va_arg(ap, aim_conn_t *); | |
3234 va_end(ap); | |
3235 | |
4617 | 3236 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3237 return 1; | |
3238 | |
5146 | 3239 if (!(oft_info = xfer->data)) |
4617 | 3240 return 1; |
3241 | |
3630 | 3242 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3243 gaim_input_remove(xfer->watcher); |
3630 | 3244 aim_conn_kill(sess, &listenerconn); |
3245 | |
5146 | 3246 oft_info->conn = conn; |
3247 xfer->fd = oft_info->conn->fd; | |
3248 | |
3249 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3250 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3251 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3252 |
3253 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3254 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3255 |
3256 return 0; | |
3257 } | |
3258 | |
3952 | 3259 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3260 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3261 * user in order to transfer a file. |
3952 | 3262 */ |
4617 | 3263 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3264 GaimXfer *xfer; |
5146 | 3265 struct aim_oft_info *oft_info; |
4656 | 3266 |
8660 | 3267 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3268 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3269 if (!(xfer = data)) |
3270 return; | |
5146 | 3271 if (!(oft_info = xfer->data)) |
3630 | 3272 return; |
8446 | 3273 if (source < 0) { |
11214 | 3274 /* This will also be called 3 minutes after the verifiedip times out. |
3275 * However, we might have made a successful connection with the clientip | |
3276 * so we need to make sure the verifiedip's failures aren't taken out | |
3277 * on the poor little clientip, which might actually have been a success. */ | |
3278 if(oft_info->success) { | |
3279 gaim_debug_info("oscar","fd of %d for verifiedip, but clientip succeeded; ignoring\n", | |
3280 source); | |
3281 return; | |
3282 } else { | |
3283 gaim_debug_info("oscar","received fd of %d; aborting transfer\n", source); | |
3284 gaim_xfer_cancel_remote(xfer); | |
3285 return; | |
3286 } | |
3287 } | |
3288 | |
3289 gaim_debug_info("oscar","marking connection as success; fd is %d\n", source); | |
3290 oft_info->success = TRUE; /* Mark this connection as successful before it times out */ | |
4617 | 3291 |
3292 xfer->fd = source; | |
5146 | 3293 oft_info->conn->fd = source; |
3294 | |
3295 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3296 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3297 |
3298 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3299 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3300 |
3301 return; | |
3630 | 3302 } |
3303 | |
3952 | 3304 /* |
4617 | 3305 * This is called when a buddy sends us some file info. This happens when they |
3306 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3307 * You should send them the exact same info except use the real cookie. We also |
4617 | 3308 * get like totally ready to like, receive the file, kay? |
3952 | 3309 */ |
4617 | 3310 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3311 GaimConnection *gc = sess->aux_data; |
7283 | 3312 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3313 GaimXfer *xfer; |
5146 | 3314 struct aim_oft_info *oft_info; |
4617 | 3315 va_list ap; |
3316 aim_conn_t *conn; | |
3317 fu8_t *cookie; | |
3318 struct aim_fileheader_t *fh; | |
4656 | 3319 |
8660 | 3320 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3321 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3322 va_start(ap, fr); |
3323 conn = va_arg(ap, aim_conn_t *); | |
3324 cookie = va_arg(ap, fu8_t *); | |
3325 fh = va_arg(ap, struct aim_fileheader_t *); | |
3326 va_end(ap); | |
3327 | |
3328 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3329 return 1; | |
3330 | |
5146 | 3331 if (!(oft_info = xfer->data)) |
4617 | 3332 return 1; |
3333 | |
3334 /* We want to stop listening with a normal thingy */ | |
3335 gaim_input_remove(xfer->watcher); | |
3336 xfer->watcher = 0; | |
3337 | |
5146 | 3338 /* They sent us some information about the file they're sending */ |
3339 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3340 | |
3341 /* Fill in the cookie */ | |
3342 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3343 | |
4617 | 3344 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3345 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3346 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3347 | |
3348 return 0; | |
3630 | 3349 } |
3350 | |
3952 | 3351 /* |
4657 | 3352 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3353 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3354 */ |
4617 | 3355 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3356 GaimConnection *gc = sess->aux_data; |
7283 | 3357 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3358 GaimXfer *xfer; |
4617 | 3359 va_list ap; |
3360 aim_conn_t *conn; | |
3361 fu8_t *cookie; | |
3362 struct aim_fileheader_t *fh; | |
4656 | 3363 |
8660 | 3364 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3365 va_start(ap, fr); |
3366 conn = va_arg(ap, aim_conn_t *); | |
3367 cookie = va_arg(ap, fu8_t *); | |
3368 fh = va_arg(ap, struct aim_fileheader_t *); | |
3369 va_end(ap); | |
3370 | |
3371 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3372 return 1; | |
3373 | |
4656 | 3374 /* We want to stop listening with a normal thingy */ |
3375 gaim_input_remove(xfer->watcher); | |
3376 xfer->watcher = 0; | |
3377 | |
4617 | 3378 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3379 | |
3380 return 0; | |
3630 | 3381 } |
4617 | 3382 |
3383 /* | |
3384 * We just sent a file to someone. They said they got it and everything, | |
3385 * so we can close our direct connection and what not. | |
3386 */ | |
3387 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3388 GaimConnection *gc = sess->aux_data; |
7283 | 3389 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3390 GaimXfer *xfer; |
4617 | 3391 va_list ap; |
3392 aim_conn_t *conn; | |
3393 fu8_t *cookie; | |
3394 struct aim_fileheader_t *fh; | |
4656 | 3395 |
8660 | 3396 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3397 va_start(ap, fr); |
3398 conn = va_arg(ap, aim_conn_t *); | |
3399 cookie = va_arg(ap, fu8_t *); | |
3400 fh = va_arg(ap, struct aim_fileheader_t *); | |
3401 va_end(ap); | |
3402 | |
3403 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3404 return 1; | |
3405 | |
4656 | 3406 xfer->fd = conn->fd; |
4617 | 3407 gaim_xfer_end(xfer); |
3408 | |
3409 return 0; | |
3410 } | |
3630 | 3411 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3412 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3413 GaimConnection *gc = sess->aux_data; |
7283 | 3414 OscarData *od = gc->proto_data; |
8708 | 3415 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3416 GaimConvImFlags flags = 0; |
4738 | 3417 struct buddyinfo *bi; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
3418 char *iconfile; |
9806 | 3419 GString *message; |
3420 gchar *tmp; | |
3421 aim_mpmsg_section_t *curpart; | |
3422 | |
10472 | 3423 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3424 userinfo->sn, args->mpmsg.numparts); |
4738 | 3425 |
10595 | 3426 if (args->mpmsg.numparts == 0) |
3427 return 1; | |
3428 | |
8708 | 3429 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3430 if (!bi) { |
3431 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3432 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3433 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3434 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3435 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3436 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3437 |
4738 | 3438 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3439 bi->typingnot = TRUE; | |
3440 else | |
3441 bi->typingnot = FALSE; | |
3442 | |
4380 | 3443 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3444 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3445 "%s has an icon\n", userinfo->sn); |
4738 | 3446 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3447 bi->ico_need = TRUE; | |
3448 bi->ico_len = args->iconlen; | |
3449 bi->ico_csum = args->iconsum; | |
3450 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3451 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3452 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3453 |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
3454 iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
3455 if ((iconfile != NULL) && |
7406 | 3456 (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
|
3457 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3458 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3459 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3460 if (!g_stat(iconfile, &st)) { |
11159 | 3461 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
3462 file = g_fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3463 if (file) { |
9532 | 3464 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3465 int len = fread(buf, 1, st.st_size, file); |
8660 | 3466 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3467 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3468 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3469 userinfo->sn, len, st.st_size); |
4617 | 3470 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3471 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3472 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3473 } else |
8660 | 3474 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3475 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3476 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3477 } else |
8660 | 3478 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3479 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3480 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
3481 g_free(iconfile); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3482 |
9806 | 3483 message = g_string_new(""); |
3484 curpart = args->mpmsg.parts; | |
3485 while (curpart != NULL) { | |
11159 | 3486 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, |
3487 curpart->charsubset, curpart->data, curpart->datalen); | |
9806 | 3488 if (tmp != NULL) { |
3489 g_string_append(message, tmp); | |
3490 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3491 } |
9806 | 3492 |
3493 curpart = curpart->next; | |
3494 } | |
3495 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3496 |
8666 | 3497 /* |
10781 | 3498 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
9016 | 3499 * because HTML is not sent over ICQ as a means to format a message. |
10781 | 3500 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
3501 * replaced with <br> | |
8995 | 3502 * |
3503 * Note: There *may* be some clients which send messages as HTML formatted - | |
3504 * they need to be special-cased somehow. | |
8666 | 3505 */ |
9982 | 3506 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3507 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
3508 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
8493 | 3509 g_free(tmp); |
3510 tmp = tmp2; | |
10783 | 3511 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
10781 | 3512 g_free(tmp); |
3513 tmp = tmp2; | |
8493 | 3514 } |
3515 | |
6982 | 3516 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3517 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3518 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3519 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3520 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3521 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3522 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3523 GaimConnection *gc; |
9933 | 3524 GaimAccount *account; |
9070 | 3525 OscarData *od; |
9933 | 3526 const char *username = NULL; |
3527 char *message = NULL; | |
9070 | 3528 |
3529 g_return_val_if_fail(sess != NULL, 0); | |
3530 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3531 | |
3532 gc = sess->aux_data; | |
9933 | 3533 account = gaim_connection_get_account(gc); |
9070 | 3534 od = gc->proto_data; |
9933 | 3535 username = gaim_account_get_username(account); |
3536 | |
3537 if (args == NULL) | |
4121 | 3538 return 0; |
4194 | 3539 |
9933 | 3540 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3541 userinfo->sn, args->status); | |
3542 | |
3543 if (args->msg != NULL) | |
3544 { | |
3545 if (args->encoding != NULL) | |
3546 { | |
3547 char *encoding = NULL; | |
3548 encoding = oscar_encoding_extract(args->encoding); | |
3549 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3550 g_free(encoding); | |
3551 } else { | |
3552 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3553 message = g_strdup(args->msg); | |
3554 } | |
3555 } | |
2869 | 3556 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3557 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3558 char *name; |
5234 | 3559 GHashTable *components; |
3560 | |
9933 | 3561 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3562 g_free(message); | |
4121 | 3563 return 1; |
9933 | 3564 } |
5234 | 3565 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3566 g_free); | |
4121 | 3567 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3568 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3569 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
|
3570 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3571 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3572 userinfo->sn, |
9933 | 3573 message, |
5234 | 3574 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3575 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3576 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3577 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3578 /* BBB */ |
3579 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3580 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3581 GaimXfer *xfer; |
5146 | 3582 struct aim_oft_info *oft_info; |
3583 | |
3584 if (!args->cookie || !args->port || !args->verifiedip || | |
3585 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3586 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3587 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3588 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3589 "information.\n", userinfo->sn); |
5146 | 3590 if (args->proxyip) |
8660 | 3591 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3592 "IP for a proxy server was given. Gaim " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3593 "does not support this yet.\n"); |
9933 | 3594 g_free(message); |
4617 | 3595 return 1; |
4656 | 3596 } |
4617 | 3597 |
3598 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3599 /* 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
|
3600 * directory -- remove the star and trailing slash so we don't save |
4617 | 3601 * directories that look like 'dirname\*' -- arl */ |
3602 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3603 if (tmp && (tmp[1] == '*')) { | |
3604 tmp[0] = '\0'; | |
3605 } | |
8660 | 3606 gaim_debug_warning("oscar", |
8446 | 3607 "We're receiving a whole directory! What fun! " |
3608 "Especially since we don't support that!\n"); | |
4617 | 3609 } |
3610 | |
3611 /* Build the file transfer handle */ | |
3612 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3613 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3614 xfer->remote_port = args->port; |
11238 | 3615 |
3616 if (g_utf8_validate(args->info.sendfile.filename, -1, | |
3617 NULL)) { | |
3618 gaim_xfer_set_filename(xfer, | |
3619 args->info.sendfile.filename); | |
3620 } else { | |
3621 gchar * utf8_filename = gaim_utf8_salvage( | |
3622 args->info.sendfile.filename); | |
3623 gaim_xfer_set_filename(xfer, utf8_filename); | |
3624 g_free(utf8_filename); | |
3625 } | |
3626 | |
4617 | 3627 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); |
11084 | 3628 |
3629 /* Ignore <ICQ_COOL_FT> XML that is sent along with ICQ sendfile requests */ | |
3630 if(g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13)) { | |
3631 gaim_debug_info("oscar","Ignoring ICQ file transfer message: %s\n", message); | |
3632 g_free(message); | |
3633 message = NULL; | |
3634 } | |
9933 | 3635 gaim_xfer_set_message(xfer, message); |
5146 | 3636 |
3637 /* Create the oscar-specific data */ | |
5163 | 3638 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3639 if (args->proxyip) |
5146 | 3640 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3641 if (args->verifiedip) |
5146 | 3642 oft_info->verifiedip = g_strdup(args->verifiedip); |
3643 xfer->data = oft_info; | |
4617 | 3644 |
3645 /* Setup our I/O op functions */ | |
8446 | 3646 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3647 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3648 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
|
3649 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3650 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3651 |
3652 /* Keep track of this transfer for later */ | |
3653 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3654 | |
3655 /* Now perform the request */ | |
3656 gaim_xfer_request(xfer); | |
3657 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3658 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3659 GaimXfer *xfer; |
8660 | 3660 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3661 "AAA - File transfer canceled by remote user\n"); |
4617 | 3662 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
|
3663 gaim_xfer_cancel_remote(xfer); |
4617 | 3664 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3665 /* | |
3666 * This gets sent by the receiver of a file | |
3667 * as they connect directly to us. If we don't | |
3668 * get this, then maybe a third party connected | |
3669 * to us, and we shouldn't send them anything. | |
3670 */ | |
11214 | 3671 gaim_debug_info("oscar", |
3672 "AAA - received chan 2 AIM_RENDEZVOUS_ACCEPT; ignoring\n"); | |
4617 | 3673 } else { |
8660 | 3674 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3675 "unknown rendezvous status!\n"); |
3630 | 3676 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3677 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3678 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3679 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3680 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3681 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3682 args->info.icon.length); |
6871 | 3683 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3684 /* 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
|
3685 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3686 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
|
3687 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3688 |
4212 | 3689 if (!args->verifiedip) { |
8983 | 3690 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3691 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3692 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3693 g_free(message); |
4650 | 3694 return 1; |
4212 | 3695 } |
3696 | |
8660 | 3697 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3698 "%s received direct im request from %s (%s)\n", |
10594 | 3699 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3700 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3701 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3702 d->sn = g_strdup(userinfo->sn); |
8983 | 3703 /* Let's use the clientip here, because I think that's what AIM does. |
3704 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3705 * and then ask them to connect to us. */ | |
10594 | 3706 /* |
3707 * I disagree, let's use the verifiedip. I think AIM tries the | |
3708 * verified IP first, then tries the client IP if that fails. In | |
3709 * any case, there's a better chance the verified IP will be correct. | |
3710 * The client IP is what the other person _thinks_ their IP address | |
3711 * is. The verified IP is the address that the AIM server sees the | |
3712 * other person using. | |
3713 */ | |
3714 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->verifiedip, args->port?args->port:5190); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3715 memcpy(d->cookie, args->cookie, 8); |
9070 | 3716 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3717 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3718 | |
8971 | 3719 oscar_direct_im_destroy(od, dim); |
8984 | 3720 d->donttryagain = TRUE; |
8971 | 3721 accept_direct_im_request(d); |
3722 } else { | |
8983 | 3723 if (dim && !dim->connected) |
8971 | 3724 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3725 "already connected to that buddy!"); | |
5575 | 3726 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
|
3727 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3728 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3729 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3730 "the two computers and is necessary for IM " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3731 "Images. Because your IP address will be " |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3732 "revealed, this may be considered a privacy " |
9972 | 3733 "risk."), |
3734 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3735 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3736 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3737 /* FIXME: we should actually send a packet on cancel */ | |
3738 } | |
8708 | 3739 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3740 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
|
3741 } else { |
8660 | 3742 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3743 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3744 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3745 |
9933 | 3746 g_free(message); |
3747 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3748 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3749 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3750 |
3453 | 3751 /* |
4230 | 3752 * Authorization Functions |
3753 * Most of these are callbacks from dialogs. They're used by both | |
3754 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3755 */ |
4269 | 3756 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3757 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3758 GaimConnection *gc = data->gc; |
4244 | 3759 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3760 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3761 OscarData *od = gc->proto_data; |
6695 | 3762 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3763 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3764 if (buddy && group) { |
8660 | 3765 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3766 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3767 buddy->name, group->name); |
4889 | 3768 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3769 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3770 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3771 } |
4230 | 3772 } |
4337 | 3773 } |
3774 | |
3775 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3776 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3777 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3778 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3779 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3780 data); |
4230 | 3781 } |
3782 | |
3783 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3784 GaimConnection *gc = data->gc; |
4244 | 3785 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3786 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3787 /* Remove from local list */ |
3788 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3789 gaim_blist_remove_buddy(b); | |
4244 | 3790 } |
3791 | |
5836 | 3792 oscar_free_name_data(data); |
4230 | 3793 } |
3794 | |
9030 | 3795 |
3796 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3797 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3798 GaimBuddy *buddy; |
4269 | 3799 gchar *dialog_msg, *nombre; |
3800 | |
4687 | 3801 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3802 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3803 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3804 else |
4830 | 3805 nombre = NULL; |
3806 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3807 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 | 3808 data->gc = gc; |
3809 data->name = g_strdup(name); | |
3810 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3811 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3812 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3813 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3814 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3815 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3816 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3817 |
3818 g_free(dialog_msg); | |
3819 g_free(nombre); | |
3820 } | |
3821 | |
9030 | 3822 |
3823 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3824 GaimBuddy *buddy; | |
3825 GaimConnection *gc; | |
3826 | |
3827 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3828 | |
3829 buddy = (GaimBuddy *) node; | |
3830 gc = gaim_account_get_connection(buddy->account); | |
3831 gaim_auth_sendrequest(gc, buddy->name); | |
3832 } | |
3833 | |
4230 | 3834 /* When other people ask you for authorization */ |
3835 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3836 GaimConnection *gc = data->gc; |
4244 | 3837 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3838 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3839 OscarData *od = gc->proto_data; |
4889 | 3840 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4244 | 3841 } |
3842 | |
5836 | 3843 oscar_free_name_data(data); |
3141 | 3844 } |
3845 | |
4230 | 3846 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3847 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3848 GaimConnection *gc = data->gc; |
4244 | 3849 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3850 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3851 OscarData *od = gc->proto_data; |
4889 | 3852 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4244 | 3853 } |
4337 | 3854 } |
3855 | |
3856 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3857 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3858 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3859 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3860 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3861 data); |
3141 | 3862 } |
3863 | |
7023 | 3864 /* When someone sends you buddies */ |
3865 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3866 GaimConnection *gc = data->gc; |
4244 | 3867 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3868 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3869 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3870 } |
3871 | |
5836 | 3872 oscar_free_name_data(data); |
3453 | 3873 } |
3874 | |
4075 | 3875 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 | 3876 GaimConnection *gc = sess->aux_data; |
9908 | 3877 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3878 gchar **msg1, **msg2; |
6051 | 3879 int i, numtoks; |
4076 | 3880 |
4121 | 3881 if (!args->type || !args->msg || !args->uin) |
3882 return 1; | |
4194 | 3883 |
8660 | 3884 gaim_debug_info("oscar", |
9908 | 3885 "Received a channel 4 message of type 0x%02hhx.\n", |
3886 args->type); | |
4076 | 3887 |
9919 | 3888 /* |
3889 * Split up the message at the delimeter character, then convert each | |
3890 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3891 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3892 * character in whatever encoding the message was sent in. Type 1 | |
3893 * messages are always made up of only one part, so we can easily account | |
3894 * for this suck-ass part of the protocol by splitting the string into at | |
3895 * most 1 baby string. | |
3896 */ | |
3897 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3898 for (numtoks=0; msg1[numtoks]; numtoks++); |
3899 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3900 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3901 gaim_str_strip_cr(msg1[i]); |
9908 | 3902 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3903 } |
3904 msg2[i] = NULL; | |
3905 | |
3952 | 3906 switch (args->type) { |
4173 | 3907 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3908 if (i >= 1) { |
5556 | 3909 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3910 gchar *tmp; |
3911 | |
3912 /* If the message came from an ICQ user then escape any HTML */ | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
3913 tmp = g_markup_escape_text(msg2[0], -1); |
8493 | 3914 |
4076 | 3915 if (t) { /* This is an offline message */ |
9680 | 3916 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3917 #ifdef HAVE_TM_GMTOFF |
9724 | 3918 time_t now; |
3919 struct tm *tm; | |
3920 now = time(NULL); | |
3921 tm = localtime(&now); | |
3922 t += tm->tm_gmtoff; | |
9698 | 3923 #else |
3924 # ifdef HAVE_TIMEZONE | |
9680 | 3925 tzset(); |
3926 t -= timezone; | |
9698 | 3927 # endif |
3928 #endif | |
8514 | 3929 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3930 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3931 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3932 } |
3933 g_free(uin); | |
8493 | 3934 g_free(tmp); |
4075 | 3935 } |
3316 | 3936 } break; |
3937 | |
4173 | 3938 case 0x04: { /* Someone sent you a URL */ |
4076 | 3939 if (i >= 2) { |
7385 | 3940 if (msg2[1] != NULL) { |
3941 gchar *uin = g_strdup_printf("%u", args->uin); | |
3942 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3943 msg2[1], | |
3944 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3945 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3946 g_free(uin); | |
3947 g_free(message); | |
3948 } | |
3453 | 3949 } |
3950 } break; | |
3951 | |
4173 | 3952 case 0x06: { /* Someone requested authorization */ |
4076 | 3953 if (i >= 6) { |
4230 | 3954 struct name_data *data = g_new(struct name_data, 1); |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3955 gchar *sn = g_strdup_printf("%u", args->uin); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3956 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3957 gchar *dialog_msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3958 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3959 if (msg2[5] != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3960 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5])); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3961 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3962 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3963 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3964 dialog_msg = g_strdup_printf( |
10949 | 3965 _("The user %u wants to add %s to their buddy list for the following reason:\n%s"), |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3966 args->uin, gaim_account_get_username(gc->account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3967 g_free(reason); |
8660 | 3968 gaim_debug_info("oscar", |
5556 | 3969 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3970 args->uin); |
4076 | 3971 data->gc = gc; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
3972 data->name = sn; |
4230 | 3973 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3974 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3975 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3976 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3977 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3978 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3979 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3980 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3981 g_free(dialog_msg); |
3982 } | |
3141 | 3983 } break; |
3984 | |
4173 | 3985 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3986 if (i >= 1) { |
7023 | 3987 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
|
3988 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3989 dialog_msg); |
4076 | 3990 g_free(dialog_msg); |
3991 } | |
3141 | 3992 } break; |
3993 | |
4173 | 3994 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3995 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
|
3996 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3997 dialog_msg); |
3141 | 3998 g_free(dialog_msg); |
3999 } break; | |
4000 | |
4333 | 4001 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
4002 if (i >= 5) { | |
4003 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
|
4004 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 4005 g_free(dialog_msg); |
4006 } | |
4007 } break; | |
4008 | |
4173 | 4009 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 4010 if (i >= 6) { |
4194 | 4011 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
|
4012 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 4013 g_free(dialog_msg); |
4014 } | |
4075 | 4015 } break; |
4016 | |
4173 | 4017 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 4018 if (i >= 6) { |
4308 | 4019 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
|
4020 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 4021 g_free(dialog_msg); |
4022 } | |
4075 | 4023 } break; |
4024 | |
4173 | 4025 case 0x12: { |
3141 | 4026 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 4027 /* Someone added you to their buddy list? */ |
3141 | 4028 } break; |
4029 | |
7023 | 4030 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 4031 guint i, num; |
3453 | 4032 gchar **text; |
4173 | 4033 text = g_strsplit(args->msg, "\376", 0); |
3453 | 4034 if (text) { |
4035 num = 0; | |
4036 for (i=0; i<strlen(text[0]); i++) | |
4037 num = num*10 + text[0][i]-48; | |
4038 for (i=0; i<num; i++) { | |
4230 | 4039 struct name_data *data = g_new(struct name_data, 1); |
7023 | 4040 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 | 4041 data->gc = gc; |
4790 | 4042 data->name = g_strdup(text[i*2+1]); |
4043 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4044 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4045 gaim_request_action(gc, NULL, message, |
7023 | 4046 _("Do you want to add this buddy " |
4047 "to your buddy list?"), | |
9972 | 4048 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 4049 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 4050 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 4051 g_free(message); |
4052 } | |
4053 g_strfreev(text); | |
4054 } | |
4055 } break; | |
4056 | |
7023 | 4057 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 4058 /* This is boring and silly. */ |
4059 } break; | |
4060 | |
3141 | 4061 default: { |
8660 | 4062 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4063 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4064 "(type 0x%02hhx).\n", args->type); |
3141 | 4065 } break; |
4066 } | |
4067 | |
4076 | 4068 g_strfreev(msg1); |
4069 g_strfreev(msg2); | |
4070 | |
3141 | 4071 return 1; |
4072 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4073 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4074 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 4075 fu16_t channel; |
4076 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4077 aim_userinfo_t *userinfo; |
2086 | 4078 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4079 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4080 va_start(ap, fr); |
4200 | 4081 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4082 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4083 |
3141 | 4084 switch (channel) { |
4085 case 1: { /* standard message */ | |
4086 struct aim_incomingim_ch1_args *args; | |
4087 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
4088 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
4089 } break; | |
4090 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
4091 case 2: { /* rendezvous */ |
3141 | 4092 struct aim_incomingim_ch2_args *args; |
4093 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
4094 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
4095 } break; | |
4096 | |
4097 case 4: { /* ICQ */ | |
4098 struct aim_incomingim_ch4_args *args; | |
4099 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 4100 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 4101 } break; |
4102 | |
4103 default: { | |
8660 | 4104 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4105 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4106 "0x%04hx).", channel); |
3141 | 4107 } break; |
2086 | 4108 } |
4109 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4110 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4111 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4112 return ret; |
2086 | 4113 } |
4114 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4115 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 4116 GaimConnection *gc = sess->aux_data; |
4117 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 4118 char *buf; |
2086 | 4119 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4120 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4121 aim_userinfo_t *userinfo; |
2086 | 4122 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4123 va_start(ap, fr); |
4200 | 4124 chan = (fu16_t)va_arg(ap, unsigned int); |
4125 userinfo = va_arg(ap, aim_userinfo_t *); | |
4126 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
4127 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 4128 va_end(ap); |
4129 | |
4130 switch(reason) { | |
5420 | 4131 case 0: /* Invalid (0) */ |
4132 buf = g_strdup_printf( | |
4133 ngettext( | |
4276 | 4134 "You missed %hu message from %s because it was invalid.", |
4135 "You missed %hu messages from %s because they were invalid.", | |
4136 nummissed), | |
4282 | 4137 nummissed, |
4138 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4139 break; |
5420 | 4140 case 1: /* Message too large */ |
4141 buf = g_strdup_printf( | |
4142 ngettext( | |
4276 | 4143 "You missed %hu message from %s because it was too large.", |
4144 "You missed %hu messages from %s because they were too large.", | |
4145 nummissed), | |
4282 | 4146 nummissed, |
4147 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4148 break; |
5420 | 4149 case 2: /* Rate exceeded */ |
4150 buf = g_strdup_printf( | |
4151 ngettext( | |
4276 | 4152 "You missed %hu message from %s because the rate limit has been exceeded.", |
4153 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
4154 nummissed), | |
4282 | 4155 nummissed, |
4156 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4157 break; |
5420 | 4158 case 3: /* Evil Sender */ |
4159 buf = g_strdup_printf( | |
4160 ngettext( | |
4276 | 4161 "You missed %hu message from %s because he/she was too evil.", |
4162 "You missed %hu messages from %s because he/she was too evil.", | |
4163 nummissed), | |
4282 | 4164 nummissed, |
4165 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4166 break; |
5420 | 4167 case 4: /* Evil Receiver */ |
4168 buf = g_strdup_printf( | |
4169 ngettext( | |
4276 | 4170 "You missed %hu message from %s because you are too evil.", |
4171 "You missed %hu messages from %s because you are too evil.", | |
4172 nummissed), | |
4282 | 4173 nummissed, |
4174 userinfo->sn); | |
2086 | 4175 break; |
4176 default: | |
5420 | 4177 buf = g_strdup_printf( |
4178 ngettext( | |
4276 | 4179 "You missed %hu message from %s for an unknown reason.", |
4180 "You missed %hu messages from %s for an unknown reason.", | |
4181 nummissed), | |
4282 | 4182 nummissed, |
4183 userinfo->sn); | |
2086 | 4184 break; |
4185 } | |
8733 | 4186 |
9627 | 4187 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4188 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4189 g_free(buf); |
2086 | 4190 |
4191 return 1; | |
4192 } | |
4193 | |
11159 | 4194 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const guchar *cookie) { |
5575 | 4195 GaimConnection *gc = sess->aux_data; |
7283 | 4196 OscarData *od = gc->proto_data; |
4617 | 4197 |
4198 /* BBB */ | |
3630 | 4199 switch (reason) { |
4151 | 4200 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4201 GaimXfer *xfer; |
8971 | 4202 struct oscar_direct_im *dim; |
4203 | |
8660 | 4204 gaim_debug_info("oscar", |
9070 | 4205 "AAA - Other user declined some sort of direct " |
8971 | 4206 "connect attempt (automaticly?)\n"); |
4617 | 4207 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
|
4208 gaim_xfer_cancel_remote(xfer); |
8971 | 4209 else if ((dim = oscar_direct_im_find(od, who))) { |
4210 /* AAA should use find by cookie or something here */ | |
4211 oscar_direct_im_disconnect(od, dim); | |
4212 } | |
4151 | 4213 } break; |
4214 | |
4215 default: { | |
8660 | 4216 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4217 "Received an unknown rendezvous client auto-response " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4218 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4219 } |
3630 | 4220 |
4221 } | |
4222 | |
4223 return 0; | |
4224 } | |
4225 | |
4194 | 4226 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4227 GaimConnection *gc = sess->aux_data; |
4151 | 4228 |
4229 switch(reason) { | |
4230 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4231 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4232 | |
4233 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4234 |
4235 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4236 statusmsg = oscar_icqstatus(state); |
4151 | 4237 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4238 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4239 g_free(statusmsg); | |
4151 | 4240 g_strfreev(splitmsg); |
9244 | 4241 |
9797 | 4242 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4243 |
4244 g_free(title); | |
4245 g_free(dialogmsg); | |
4151 | 4246 } break; |
4247 | |
4248 default: { | |
8660 | 4249 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4250 "Received an unknown client auto-response from %s. " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4251 "Type 0x%04hx\n", who, reason); |
4151 | 4252 } break; |
4253 } /* end of switch */ | |
4254 | |
4255 return 0; | |
4256 } | |
4257 | |
3212 | 4258 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4259 va_list ap; | |
4260 fu16_t chan, reason; | |
4261 char *who; | |
4262 | |
4263 va_start(ap, fr); | |
4200 | 4264 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4265 who = va_arg(ap, char *); |
4200 | 4266 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4267 |
3952 | 4268 if (chan == 0x0002) { /* File transfer declined */ |
11159 | 4269 guchar *cookie = va_arg(ap, guchar *); |
4151 | 4270 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4271 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4272 fu32_t state = 0; |
4151 | 4273 char *msg = NULL; |
4274 if (reason == 0x0003) { | |
4200 | 4275 state = va_arg(ap, fu32_t); |
4151 | 4276 msg = va_arg(ap, char *); |
4277 } | |
4278 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4279 } | |
3952 | 4280 |
3212 | 4281 va_end(ap); |
4282 | |
4283 return 1; | |
4284 } | |
4285 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4286 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4287 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4288 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4289 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4290 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4291 va_start(ap, fr); |
4199 | 4292 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4293 va_end(ap); |
4294 | |
8660 | 4295 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4296 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4297 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4298 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4299 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4300 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4301 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4302 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4303 |
2086 | 4304 return 1; |
4305 } | |
4306 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4307 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4308 GaimConnection *gc = sess->aux_data; |
4617 | 4309 #if 0 |
7283 | 4310 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4311 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4312 #endif |
4617 | 4313 va_list ap; |
4314 fu16_t reason; | |
4315 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4316 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4317 va_start(ap, fr); |
4617 | 4318 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4319 data = va_arg(ap, char *); |
2086 | 4320 va_end(ap); |
4321 | |
8660 | 4322 gaim_debug_error("oscar", |
10130 | 4323 "Message error with data %s and reason %hu\n", |
4324 (data != NULL ? data : ""), reason); | |
4617 | 4325 |
4326 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4327 #if 0 |
4617 | 4328 /* If this was a file transfer request, data is a cookie */ |
4329 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
|
4330 gaim_xfer_cancel_remote(xfer); |
3630 | 4331 return 1; |
4332 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4333 #endif |
3630 | 4334 |
4617 | 4335 /* Data is assumed to be the destination sn */ |
9826 | 4336 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4337 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4338 g_free(buf); | |
4339 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4340 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4341 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4342 } | |
4343 g_free(buf); | |
4344 | |
2086 | 4345 return 1; |
4346 } | |
4347 | |
3595 | 4348 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4349 GaimConnection *gc = sess->aux_data; |
3595 | 4350 va_list ap; |
4351 fu16_t type1, type2; | |
4352 char *sn; | |
4353 | |
4354 va_start(ap, fr); | |
4199 | 4355 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4356 sn = va_arg(ap, char *); |
4199 | 4357 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4358 va_end(ap); |
4359 | |
4360 switch (type2) { | |
4361 case 0x0000: { /* Text has been cleared */ | |
4362 serv_got_typing_stopped(gc, sn); | |
4363 } break; | |
4364 | |
4365 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4366 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4367 } break; |
4368 | |
4369 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4370 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4371 } break; |
4372 | |
4373 default: { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4374 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 | 4375 } break; |
4376 } | |
4377 | |
4378 return 1; | |
4379 } | |
4380 | |
7141 | 4381 /* |
4382 * We get this error when there was an error in the locate family. This | |
7259 | 4383 * happens when you request info of someone who is offline. |
7141 | 4384 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4385 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4386 gchar *buf; |
2086 | 4387 va_list ap; |
5420 | 4388 fu16_t reason; |
2086 | 4389 char *destn; |
4390 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4391 va_start(ap, fr); |
4199 | 4392 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4393 destn = va_arg(ap, char *); |
4394 va_end(ap); | |
4395 | |
7781 | 4396 if (destn == NULL) |
7793 | 4397 return 1; |
10560 | 4398 |
9826 | 4399 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4400 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4401 g_free(buf); | |
9627 | 4402 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4403 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4404 } | |
4405 g_free(buf); | |
2086 | 4406 |
4407 return 1; | |
4408 } | |
4409 | |
7011 | 4410 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4411 GaimConnection *gc = sess->aux_data; |
8700 | 4412 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 4413 OscarData *od = gc->proto_data; |
8700 | 4414 GString *str; |
9244 | 4415 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4416 va_list ap; |
7011 | 4417 aim_userinfo_t *userinfo; |
2086 | 4418 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4419 va_start(ap, fr); |
7011 | 4420 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4421 va_end(ap); |
4422 | |
8700 | 4423 str = g_string_new(""); |
4424 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4425 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4426 |
10116 | 4427 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 4428 time_t t = userinfo->onlinesince - od->timeoffset; |
10116 | 4429 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); |
4430 } | |
4431 | |
4432 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 4433 time_t t = userinfo->membersince - od->timeoffset; |
10116 | 4434 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); |
4435 } | |
7011 | 4436 |
4437 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4438 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4439 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4440 g_free(tmp); |
4441 } | |
4442 | |
8701 | 4443 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4444 |
4445 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4446 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4447 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4448 g_free(tmp); | |
7011 | 4449 if (away_utf8 != NULL) { |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4450 g_string_append_printf(str, "\n<hr>%s<br>", away_utf8); |
7011 | 4451 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4452 } |
7011 | 4453 } |
4454 | |
4455 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4456 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4457 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4458 g_free(tmp); | |
7011 | 4459 if (info_utf8 != NULL) { |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4460 g_string_append_printf(str, "\n<hr>%s<br>", info_utf8); |
7011 | 4461 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4462 } |
7011 | 4463 } |
4464 | |
8701 | 4465 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4466 g_string_free(str, TRUE); |
9244 | 4467 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4468 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4469 g_free(title); |
8700 | 4470 g_free(tmp); |
4151 | 4471 |
2086 | 4472 return 1; |
4473 } | |
4474 | |
8341 | 4475 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4476 { | |
4477 aim_session_t *sess = data; | |
4478 GaimConnection *gc = sess->aux_data; | |
4479 OscarData *od = (OscarData *)gc->proto_data; | |
4480 | |
4481 aim_locate_dorequest(data); | |
4482 od->getinfotimer = 0; | |
4483 | |
4484 return FALSE; | |
4485 } | |
4486 | |
4487 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4488 { | |
4489 GaimConnection *gc = sess->aux_data; | |
4490 OscarData *od = (OscarData *)gc->proto_data; | |
4491 | |
4492 /* | |
4493 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4494 * us from hitting the rate limit due to request away messages and info | |
4495 * too quickly. | |
4496 */ | |
4497 if (od->getinfotimer == 0) | |
10198 | 4498 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4499 |
4500 return 1; | |
4501 } | |
4502 | |
4503 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4504 { | |
2086 | 4505 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4506 fu16_t id; |
2086 | 4507 va_list ap; |
4508 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4509 va_start(ap, fr); |
4199 | 4510 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4511 msg = va_arg(ap, char *); |
4512 va_end(ap); | |
4513 | |
8660 | 4514 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4515 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4516 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4517 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4518 _("Your AIM connection may be lost."), NULL); |
2086 | 4519 |
4520 return 1; | |
4521 } | |
4522 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4523 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4524 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4525 fu16_t type; |
5575 | 4526 GaimConnection *gc = sess->aux_data; |
7283 | 4527 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4528 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4529 va_start(ap, fr); |
4199 | 4530 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4531 |
4532 switch(type) { | |
4533 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4534 fu8_t maxrooms; |
2086 | 4535 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4536 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4537 |
4199 | 4538 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4539 exchangecount = va_arg(ap, int); |
4540 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4541 | |
8660 | 4542 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4543 "chat info: Chat Rights:\n"); |
8660 | 4544 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4545 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4546 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4547 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4548 for (i = 0; i < exchangecount; i++) |
8660 | 4549 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4550 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4551 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4552 while (od->create_rooms) { |
4553 struct create_room *cr = od->create_rooms->data; | |
8660 | 4554 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4555 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4556 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4557 g_free(cr->name); |
4617 | 4558 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4559 g_free(cr); |
2086 | 4560 } |
4561 } | |
4562 break; | |
4563 case 0x0008: { | |
4564 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4565 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4566 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4567 fu32_t createtime; |
2086 | 4568 |
4569 fqcn = va_arg(ap, char *); | |
4200 | 4570 instance = (fu16_t)va_arg(ap, unsigned int); |
4571 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4572 flags = (fu16_t)va_arg(ap, unsigned int); | |
4573 createtime = va_arg(ap, fu32_t); | |
4574 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4575 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4576 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4577 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4578 name = va_arg(ap, char *); | |
4579 ck = va_arg(ap, char *); | |
4194 | 4580 |
8660 | 4581 gaim_debug_misc("oscar", |
5556 | 4582 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4583 fqcn, |
4584 exchange, instance, flags, | |
4585 createtime, | |
4586 maxmsglen, maxoccupancy, createperms, unknown, | |
4587 name, ck); | |
4617 | 4588 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4589 } |
4590 break; | |
4591 default: | |
8660 | 4592 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4593 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4594 break; |
4595 } | |
4194 | 4596 |
4597 va_end(ap); | |
4598 | |
2086 | 4599 return 1; |
4600 } | |
4601 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4602 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4603 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4604 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4605 aim_userinfo_t *info; |
5575 | 4606 GaimConnection *g = sess->aux_data; |
2086 | 4607 |
4608 struct chat_connection *c = NULL; | |
4609 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4610 va_start(ap, fr); |
2086 | 4611 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4612 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4613 va_end(ap); |
4614 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4615 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4616 if (!c) |
4617 return 1; | |
4618 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4619 for (i = 0; i < count; i++) |
9846 | 4620 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4621 |
4622 return 1; | |
4623 } | |
4624 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4625 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4626 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4627 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4628 aim_userinfo_t *info; |
5575 | 4629 GaimConnection *g = sess->aux_data; |
2086 | 4630 |
4631 struct chat_connection *c = NULL; | |
4632 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4633 va_start(ap, fr); |
2086 | 4634 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4635 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4636 va_end(ap); |
4637 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4638 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4639 if (!c) |
4640 return 1; | |
4641 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4642 for (i = 0; i < count; i++) |
8733 | 4643 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4644 |
4645 return 1; | |
4646 } | |
4647 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4648 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
|
4649 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4650 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4651 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4652 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4653 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4654 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4655 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4656 fu32_t creationtime; |
5575 | 4657 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4658 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
|
4659 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4660 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4661 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4662 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4663 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4664 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4665 roomdesc = va_arg(ap, char *); |
4200 | 4666 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4667 creationtime = va_arg(ap, fu32_t); | |
4668 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4669 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4670 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4671 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4672 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4673 |
8660 | 4674 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4675 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4676 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4677 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4678 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4679 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4680 |
2086 | 4681 return 1; |
4682 } | |
4683 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4684 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4685 GaimConnection *gc = sess->aux_data; |
8225 | 4686 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4687 gchar *utf8; | |
2086 | 4688 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4689 aim_userinfo_t *info; |
8225 | 4690 int len; |
2086 | 4691 char *msg; |
8219 | 4692 char *charset; |
2086 | 4693 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4694 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4695 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4696 len = va_arg(ap, int); |
4194 | 4697 msg = va_arg(ap, char *); |
8219 | 4698 charset = va_arg(ap, char *); |
4194 | 4699 va_end(ap); |
2086 | 4700 |
8225 | 4701 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4702 if (utf8 == NULL) |
4703 /* The conversion failed! */ | |
8668 | 4704 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4705 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4706 g_free(utf8); | |
2086 | 4707 |
4708 return 1; | |
4709 } | |
4710 | |
3694 | 4711 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4712 va_list ap; | |
5575 | 4713 GaimConnection *gc = sess->aux_data; |
3694 | 4714 struct aim_emailinfo *emailinfo; |
3725 | 4715 int havenewmail; |
7297 | 4716 char *alertitle, *alerturl; |
3694 | 4717 |
4718 va_start(ap, fr); | |
4719 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4720 havenewmail = va_arg(ap, int); |
7301 | 4721 alertitle = va_arg(ap, char *); |
4722 alerturl = va_arg(ap, char *); | |
3694 | 4723 va_end(ap); |
4724 | |
9661 | 4725 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4726 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4727 emailinfo->domain ? "@" : "", | |
4728 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4729 if (emailinfo->unread && havenewmail) |
4730 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4731 g_free(to); |
3694 | 4732 } |
10157 | 4733 |
7301 | 4734 if (alertitle) |
8660 | 4735 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4736 |
4737 return 1; | |
4738 } | |
4739 | |
4804 | 4740 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4741 GaimConnection *gc = sess->aux_data; |
7283 | 4742 OscarData *od = gc->proto_data; |
4804 | 4743 char *sn; |
4744 | |
4745 sn = od->requesticon->data; | |
8660 | 4746 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4747 "removing %s from hash table\n", sn); |
4804 | 4748 od->requesticon = g_slist_remove(od->requesticon, sn); |
4749 free(sn); | |
4750 | |
4751 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4752 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4753 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4754 |
4755 return 1; | |
4756 } | |
4757 | |
4758 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4759 GaimConnection *gc = sess->aux_data; |
7283 | 4760 OscarData *od = gc->proto_data; |
4804 | 4761 GSList *cur; |
4762 va_list ap; | |
4763 char *sn; | |
11024 | 4764 fu8_t iconcsumtype, *iconcsum, *icon; |
4853 | 4765 fu16_t iconcsumlen, iconlen; |
4804 | 4766 |
4767 va_start(ap, fr); | |
4768 sn = va_arg(ap, char *); | |
11024 | 4769 iconcsumtype = va_arg(ap, int); |
4853 | 4770 iconcsum = va_arg(ap, fu8_t *); |
4771 iconcsumlen = va_arg(ap, int); | |
4804 | 4772 icon = va_arg(ap, fu8_t *); |
4773 iconlen = va_arg(ap, int); | |
4774 va_end(ap); | |
4775 | |
11024 | 4776 /* |
4777 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
4778 * no icon is set. Ignore these. | |
4779 */ | |
4780 if ((iconlen > 0) && (iconlen != 90)) { | |
4853 | 4781 char *b16; |
6695 | 4782 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4783 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4784 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4785 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4786 if (b16) { |
7693 | 4787 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4788 g_free(b16); |
5129 | 4789 } |
4853 | 4790 } |
4804 | 4791 |
4792 cur = od->requesticon; | |
4793 while (cur) { | |
4794 char *cursn = cur->data; | |
4795 if (!aim_sncmp(cursn, sn)) { | |
4796 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4797 free(cursn); | |
4798 cur = od->requesticon; | |
4799 } else | |
4800 cur = cur->next; | |
4801 } | |
4802 | |
4803 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4804 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4805 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4806 |
4807 return 1; | |
4808 } | |
4809 | |
4810 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4811 GaimConnection *gc = data; |
7283 | 4812 OscarData *od = gc->proto_data; |
7011 | 4813 aim_userinfo_t *userinfo; |
4804 | 4814 aim_conn_t *conn; |
4815 | |
4816 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4817 if (!conn) { |
4818 if (!od->iconconnecting) { | |
4819 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4820 od->iconconnecting = TRUE; | |
4821 } | |
4804 | 4822 return FALSE; |
4823 } | |
4824 | |
5842 | 4825 if (od->set_icon) { |
6039 | 4826 struct stat st; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4827 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
6039 | 4828 if (iconfile == NULL) { |
8363 | 4829 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4830 } else if (!g_stat(iconfile, &st)) { |
11159 | 4831 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4832 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 4833 if (file) { |
9532 | 4834 /* XXX - Use g_file_get_contents()? */ |
6039 | 4835 fread(buf, 1, st.st_size, file); |
4836 fclose(file); | |
8660 | 4837 gaim_debug_info("oscar", |
6039 | 4838 "Uploading icon to icon server\n"); |
6879 | 4839 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4840 } else |
8660 | 4841 gaim_debug_error("oscar", |
6039 | 4842 "Can't open buddy icon file!\n"); |
4843 g_free(buf); | |
4844 } else { | |
8660 | 4845 gaim_debug_error("oscar", |
6039 | 4846 "Can't stat buddy icon file!\n"); |
5842 | 4847 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4848 g_free(iconfile); |
5842 | 4849 od->set_icon = FALSE; |
4850 } | |
4851 | |
4852 if (!od->requesticon) { | |
8660 | 4853 gaim_debug_misc("oscar", |
5842 | 4854 "no more icons to request\n"); |
4855 return FALSE; | |
4856 } | |
4857 | |
7045 | 4858 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4859 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
11024 | 4860 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
4804 | 4861 return FALSE; |
4862 } else { | |
4863 char *sn = od->requesticon->data; | |
4864 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4865 free(sn); | |
4866 } | |
4867 | |
4868 return TRUE; | |
4869 } | |
4870 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4871 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4872 * 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
|
4873 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4874 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4875 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4876 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4877 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4878 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4879 va_start(ap, fr); |
4199 | 4880 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4881 sn = va_arg(ap, char *); |
4882 va_end(ap); | |
4883 | |
8660 | 4884 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4885 |
4886 return 1; | |
4887 } | |
4888 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4889 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
|
4890 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4891 "invalid", |
4194 | 4892 "change", |
4893 "warning", | |
4894 "limit", | |
4895 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4896 }; |
2086 | 4897 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4898 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4899 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4900 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4901 va_start(ap, fr); |
4200 | 4902 code = (fu16_t)va_arg(ap, unsigned int); |
4903 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4904 windowsize = va_arg(ap, fu32_t); | |
4905 clear = va_arg(ap, fu32_t); | |
4906 alert = va_arg(ap, fu32_t); | |
4907 limit = va_arg(ap, fu32_t); | |
4908 disconnect = va_arg(ap, fu32_t); | |
4909 currentavg = va_arg(ap, fu32_t); | |
4910 maxavg = va_arg(ap, fu32_t); | |
2086 | 4911 va_end(ap); |
4912 | |
8660 | 4913 gaim_debug_misc("oscar", |
5556 | 4914 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4915 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4916 (code < 5) ? codes[code] : codes[0], |
4917 rateclass, | |
4918 currentavg, maxavg, | |
4919 alert, clear, | |
4920 limit, disconnect, | |
4921 windowsize); | |
4922 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4923 /* XXX fix these values */ |
2086 | 4924 if (code == AIM_RATE_CODE_CHANGE) { |
4925 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4926 aim_conn_setlatency(fr->conn, 0); |
2086 | 4927 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4928 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4929 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4930 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4931 _("The last action you attempted could not be " |
4932 "performed because you are over the rate limit. " | |
4933 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4934 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4935 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4936 aim_conn_setlatency(fr->conn, 0); |
2086 | 4937 } |
4938 | |
4939 return 1; | |
4940 } | |
4941 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4942 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4943 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4944 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4945 aim_userinfo_t *userinfo; |
2086 | 4946 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4947 va_start(ap, fr); |
4199 | 4948 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4949 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4950 va_end(ap); |
4951 | |
11285 | 4952 #ifdef CRAZY_WARNING |
4953 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
4954 #endif | |
2086 | 4955 |
4956 return 1; | |
4957 } | |
4958 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4959 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4960 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4961 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4962 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4963 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4964 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4965 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4966 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4967 |
11285 | 4968 /* |
4969 * What's with the + 0.5? | |
4970 * The 0.5 is basically poor-man's rounding. Normally | |
4971 * casting "13.7" to an int will truncate to "13," but | |
4972 * with 13.7 + 0.5 = 14.2, which becomes "14" when | |
4973 * truncated. | |
4974 */ | |
9982 | 4975 warning_level = info->warnlevel/10.0 + 0.5; |
4976 | |
11285 | 4977 #ifdef CRAZY_WARNING |
4978 gaim_presence_set_warning_level(presence, warning_level); | |
4979 #endif | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4980 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4981 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4982 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4983 |
4649 | 4984 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4985 GaimConnection *gc = sess->aux_data; |
7283 | 4986 OscarData *od = gc->proto_data; |
4649 | 4987 va_list ap; |
4988 fu16_t code; | |
4989 char *msg; | |
4990 | |
4991 va_start(ap, fr); | |
4992 code = (fu16_t)va_arg(ap, int); | |
4993 msg = va_arg(ap, char *); | |
4994 va_end(ap); | |
4995 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4996 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
10458 | 4997 code, (msg != NULL ? msg : "")); |
4998 | |
4999 g_return_val_if_fail(fr != NULL, 1); | |
5000 g_return_val_if_fail(fr->conn != NULL, 1); | |
5001 | |
5002 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 5003 if (code == 0x0001) { |
6113 | 5004 gc->wants_to_die = TRUE; |
10715 | 5005 gaim_connection_error(gc, _("You have signed on from another location.")); |
4651 | 5006 } else { |
5579 | 5007 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 5008 } |
4666 | 5009 od->killme = TRUE; |
10458 | 5010 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
5011 struct chat_connection *cc; | |
5012 GaimConversation *conv; | |
5013 | |
5014 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
5015 conv = gaim_find_chat(gc, cc->id); | |
5016 | |
5017 if (conv != NULL) | |
5018 { | |
5019 gchar *buf; | |
5020 buf = g_strdup_printf(_("You have been disconnected from chat " | |
5021 "room %s."), cc->name); | |
5022 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
5023 g_free(buf); | |
5024 } | |
5025 oscar_chat_kill(gc, cc); | |
4649 | 5026 } |
5027 | |
5028 return 1; | |
5029 } | |
5030 | |
2675 | 5031 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 5032 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5033 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5034 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 5035 |
8660 | 5036 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 5037 aim_ssi_reqrights(sess); |
6350 | 5038 aim_ssi_reqdata(sess); |
4230 | 5039 |
7011 | 5040 aim_locate_reqrights(sess); |
7285 | 5041 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 5042 aim_im_reqparams(sess); |
7334 | 5043 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 5044 |
7283 | 5045 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
5046 | |
2086 | 5047 return 1; |
5048 } | |
5049 | |
2675 | 5050 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5051 GaimConnection *gc = sess->aux_data; |
7283 | 5052 OscarData *od = gc->proto_data; |
2647 | 5053 |
6905 | 5054 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
5055 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
5056 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
5057 | |
2672 | 5058 aim_clientready(sess, fr->conn); |
8660 | 5059 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5060 |
2647 | 5061 if (od->chpass) { |
8660 | 5062 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5063 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 5064 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5065 od->oldp = NULL; |
2647 | 5066 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5067 od->newp = NULL; |
2647 | 5068 od->chpass = FALSE; |
5069 } | |
2979 | 5070 if (od->setnick) { |
8660 | 5071 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 5072 aim_admin_setnick(sess, fr->conn, od->newsn); |
5073 g_free(od->newsn); | |
5074 od->newsn = NULL; | |
5075 od->setnick = FALSE; | |
5076 } | |
2647 | 5077 if (od->conf) { |
8660 | 5078 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5079 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 5080 od->conf = FALSE; |
5081 } | |
5082 if (od->reqemail) { | |
8660 | 5083 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5084 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 5085 od->reqemail = FALSE; |
5086 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5087 if (od->setemail) { |
8660 | 5088 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5089 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5090 g_free(od->email); |
5497 | 5091 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5092 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5093 } |
2647 | 5094 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5095 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5096 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5097 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5098 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
|
5099 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5100 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5101 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5102 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5103 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5104 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5105 |
4194 | 5106 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 5107 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 5108 "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
|
5109 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5110 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5111 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
5112 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5113 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5114 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 5115 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5116 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5117 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5118 |
4617 | 5119 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5120 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5121 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5122 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5123 |
2993 | 5124 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
5125 { | |
5575 | 5126 GaimConnection *gc = sess->aux_data; |
11338 | 5127 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 5128 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 5129 va_list ap; |
5130 fu16_t maxsiglen; | |
2993 | 5131 |
5132 va_start(ap, fr); | |
4199 | 5133 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 5134 va_end(ap); |
5135 | |
8660 | 5136 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5137 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 5138 |
4617 | 5139 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
5140 | |
5141 if (od->icq) | |
7334 | 5142 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 5143 else |
7334 | 5144 aim_locate_setcaps(od->sess, caps_aim); |
11338 | 5145 oscar_set_info(gc, account->user_info); |
5146 /* TODO: Should set the status here, as well. */ | |
2993 | 5147 |
5148 return 1; | |
5149 } | |
5150 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5151 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
|
5152 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5153 fu16_t maxbuddies, maxwatchers; |
5575 | 5154 GaimConnection *gc = sess->aux_data; |
7283 | 5155 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5156 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5157 va_start(ap, fr); |
4199 | 5158 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5159 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5160 va_end(ap); |
5161 | |
8660 | 5162 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5163 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5164 |
4617 | 5165 od->rights.maxbuddies = (guint)maxbuddies; |
5166 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5167 |
2086 | 5168 return 1; |
5169 } | |
5170 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5171 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5172 GaimConnection *gc = sess->aux_data; |
7283 | 5173 OscarData *od = (OscarData *)gc->proto_data; |
10570 | 5174 GaimAccount *account = gaim_connection_get_account(gc); |
7334 | 5175 va_list ap; |
5176 fu16_t maxpermits, maxdenies; | |
2086 | 5177 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5178 va_start(ap, fr); |
4199 | 5179 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5180 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5181 va_end(ap); |
5182 | |
8660 | 5183 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5184 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5185 |
4617 | 5186 od->rights.maxpermits = (guint)maxpermits; |
5187 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5188 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5189 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5190 |
8660 | 5191 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5192 |
2672 | 5193 aim_clientready(sess, fr->conn); |
5948 | 5194 aim_srv_setavailmsg(sess, NULL); |
7474 | 5195 aim_srv_setidle(sess, 0); |
4617 | 5196 |
4664 | 5197 if (od->icq) { |
5198 aim_icq_reqofflinemsgs(sess); | |
10570 | 5199 aim_icq_setsecurity(sess, |
5200 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
5201 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE), | |
5202 gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP)); | |
4664 | 5203 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5204 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5205 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5206 if (sess->authinfo->email) |
5207 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5208 |
5209 return 1; | |
5210 } | |
5211 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5212 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
|
5213 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5214 struct aim_icq_offlinemsg *msg; |
4075 | 5215 struct aim_incomingim_ch4_args args; |
5216 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5217 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5218 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5219 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5220 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5221 |
8660 | 5222 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5223 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5224 args.uin = msg->sender; |
5225 args.type = msg->type; | |
4173 | 5226 args.flags = msg->flags; |
4076 | 5227 args.msglen = msg->msglen; |
4075 | 5228 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5229 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5230 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5231 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5232 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5233 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5234 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5235 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
|
5236 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5237 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5238 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5239 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5240 |
7388 | 5241 #if 0 |
5242 /* | |
7465 | 5243 * Update, 2003-11-09: |
5244 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5245 * | |
7388 | 5246 * It may not be my place to do this, but... |
5247 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5248 * stupid, and should not exist for % switches (%x in our case) that request | |
5249 * a year in the preferred representation for the current locale. For that | |
5250 * reason I've chosen to not use this workaround (n., see kluge). | |
5251 * | |
5252 * I have a date. I want to show it to the user in the "preferred" way. | |
5253 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5254 * what the locale wanted. | |
5255 * | |
5256 * If I have a necessity for a full representation of the year in the current | |
5257 * locale, then I'll use a switch that returns a full representation of the | |
5258 * year. | |
5259 * | |
5260 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5261 * (because you're anal, or whatever), then change the f***ing locale. | |
5262 * | |
5263 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5264 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5265 * |
5266 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5267 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5268 */ |
5269 | |
5270 /* | |
5271 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5272 * "last 2 digits" warning. |
5273 */ | |
10157 | 5274 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5275 const struct tm *tm) |
5276 { | |
5277 return strftime(s, max, fmt, tm); | |
5278 } | |
10636 | 5279 |
5280 /* | |
5281 * Before even realizing this was here, I went and did the same thing in util.c. | |
5282 * | |
5283 * Use gaim_strftime() | |
5284 */ | |
5285 | |
7388 | 5286 #endif |
7386 | 5287 |
4624 | 5288 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
|
5289 { |
5575 | 5290 GaimConnection *gc = sess->aux_data; |
8670 | 5291 OscarData *od = (OscarData *)gc->proto_data; |
5292 GaimBuddy *buddy; | |
8853 | 5293 struct buddyinfo *bi = NULL; |
4624 | 5294 gchar who[16]; |
8670 | 5295 GString *str; |
5296 gchar *primary, *utf8; | |
9634 | 5297 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5298 va_list ap; |
4151 | 5299 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5300 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5301 va_start(ap, fr); |
4151 | 5302 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5303 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5304 |
4664 | 5305 if (!info->uin) |
5306 return 0; | |
5307 | |
8670 | 5308 str = g_string_sized_new(100); |
5556 | 5309 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5310 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5311 if (buddy != NULL) | |
5312 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5313 | |
5314 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5315 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5316 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5317 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5318 (bi->ipaddr & 0xff000000) >> 24, | |
5319 (bi->ipaddr & 0x00ff0000) >> 16, | |
5320 (bi->ipaddr & 0x0000ff00) >> 8, | |
5321 (bi->ipaddr & 0x000000ff)); | |
8701 | 5322 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5323 g_free(tstr); |
5324 } | |
8701 | 5325 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5326 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5327 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5328 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5329 g_free(utf8); | |
4625 | 5330 } |
5331 if (info->numaddresses && info->email2) { | |
5332 int i; | |
5333 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5334 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
10683 | 5335 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 5336 g_free(utf8); |
4643 | 5337 } |
4625 | 5338 } |
4624 | 5339 } |
8701 | 5340 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5341 if (info->gender != 0) |
5342 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5343 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5344 char date[30]; |
5345 struct tm tm; | |
5346 tm.tm_mday = (int)info->birthday; | |
5347 tm.tm_mon = (int)info->birthmonth-1; | |
5348 tm.tm_year = (int)info->birthyear-1900; | |
10636 | 5349 gaim_strftime(date, sizeof(date), "%x", &tm); |
8701 | 5350 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5351 } |
4624 | 5352 if (info->age) { |
5353 char age[5]; | |
5354 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5355 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5356 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5357 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5358 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5359 g_free(utf8); | |
4819 | 5360 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5361 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5362 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5363 g_free(utf8); | |
5364 } | |
10683 | 5365 g_string_append_printf(str, "<hr>"); |
4641 | 5366 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5367 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5368 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5369 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5370 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5371 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
10683 | 5372 g_string_append_printf(str, "\n<hr>"); |
4151 | 5373 } |
4641 | 5374 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5375 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5376 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5377 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5378 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5379 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
10683 | 5380 g_string_append_printf(str, "\n<hr>"); |
4624 | 5381 } |
4641 | 5382 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5383 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5384 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5385 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5386 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5387 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5388 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5389 g_free(utf8); | |
4624 | 5390 } |
10683 | 5391 g_string_append_printf(str, "\n<hr>"); |
8670 | 5392 } |
5393 | |
9634 | 5394 if (buddy != NULL) |
5395 alias = gaim_buddy_get_alias(buddy); | |
5396 else | |
5397 alias = who; | |
5398 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5399 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5400 g_free(primary); |
8670 | 5401 g_string_free(str, TRUE); |
4151 | 5402 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5403 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5404 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5405 |
4759 | 5406 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5407 { | |
5575 | 5408 GaimConnection *gc = sess->aux_data; |
4820 | 5409 gchar who[16], *utf8; |
6695 | 5410 GaimBuddy *b; |
4759 | 5411 va_list ap; |
5412 struct aim_icq_info *info; | |
5413 | |
5414 va_start(ap, fr); | |
5415 info = va_arg(ap, struct aim_icq_info *); | |
5416 va_end(ap); | |
5417 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5418 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5419 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5420 serv_got_alias(gc, who, utf8); |
4759 | 5421 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5422 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5423 } |
4820 | 5424 g_free(utf8); |
4759 | 5425 } |
5426 | |
5427 return 1; | |
5428 } | |
5429 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5430 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
|
5431 { |
7032 | 5432 GaimConnection *gc = sess->aux_data; |
5433 gchar *text; | |
5434 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5435 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5436 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5437 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5438 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5439 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5440 url = va_arg(ap, char *); |
4199 | 5441 wid = (fu16_t) va_arg(ap, int); |
5442 hei = (fu16_t) va_arg(ap, int); | |
5443 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5444 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5445 |
7032 | 5446 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5447 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5448 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5449 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5450 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5451 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5452 |
7032 | 5453 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5454 { | |
6873 | 5455 GaimConnection *gc = sess->aux_data; |
5456 gchar *secondary; | |
10439 | 5457 gchar **screennames; |
6873 | 5458 int i, num; |
2086 | 5459 va_list ap; |
6873 | 5460 char *email, *SNs; |
2086 | 5461 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5462 va_start(ap, fr); |
6873 | 5463 email = va_arg(ap, char *); |
2086 | 5464 num = va_arg(ap, int); |
5465 SNs = va_arg(ap, char *); | |
5466 va_end(ap); | |
5467 | |
10439 | 5468 /* TODO: Need to use ngettext() here */ |
8152 | 5469 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5470 |
5471 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5472 for (i = 0; i < num; i++) |
10439 | 5473 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5474 screennames[num] = NULL; | |
5475 | |
5476 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5477 (const char **)screennames, NULL, NULL); | |
6873 | 5478 |
5479 g_free(secondary); | |
10439 | 5480 g_strfreev(screennames); |
2086 | 5481 |
5482 return 1; | |
5483 } | |
5484 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5485 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5486 va_list ap; |
6873 | 5487 char *email; |
5420 | 5488 char *buf; |
2086 | 5489 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5490 va_start(ap, fr); |
6873 | 5491 email = va_arg(ap, char *); |
2086 | 5492 va_end(ap); |
5493 | |
6873 | 5494 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
|
5495 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5496 g_free(buf); |
2086 | 5497 |
5498 return 1; | |
5499 } | |
5500 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5501 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5502 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5503 fu16_t status; |
2086 | 5504 va_list ap; |
5505 char msg[256]; | |
5506 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5507 va_start(ap, fr); |
4199 | 5508 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5509 va_end(ap); |
5510 | |
8660 | 5511 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5512 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5513 status ? "unknown" : "email sent"); |
5514 if (!status) { | |
5302 | 5515 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5516 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5517 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5518 } |
5519 | |
5520 return 1; | |
5521 } | |
5522 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5523 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5524 GaimConnection *gc = sess->aux_data; |
2086 | 5525 va_list ap; |
3912 | 5526 fu16_t perms, err; |
5527 char *url, *sn, *email; | |
5528 int change; | |
2086 | 5529 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5530 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5531 change = va_arg(ap, int); |
4199 | 5532 perms = (fu16_t) va_arg(ap, unsigned int); |
5533 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5534 url = va_arg(ap, char *); |
5535 sn = va_arg(ap, char *); | |
5536 email = va_arg(ap, char *); | |
2086 | 5537 va_end(ap); |
5538 | |
8660 | 5539 gaim_debug_misc("oscar", |
9626 | 5540 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5541 change ? "change" : "request", perms, err, | |
5542 (url != NULL) ? url : "(null)", | |
5543 (sn != NULL) ? sn : "(null)", | |
5544 (email != NULL) ? email : "(null)"); | |
5545 | |
5546 if ((err > 0) && (url != NULL)) { | |
3912 | 5547 char *dialog_msg; |
5548 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5549 switch (err) { | |
5550 case 0x0001: { | |
5551 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5552 } break; | |
5553 case 0x0006: { | |
5554 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5555 } break; | |
5556 case 0x000b: { | |
5557 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5558 } break; | |
5559 case 0x001d: { | |
5560 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); | |
5561 } break; | |
5562 case 0x0021: { | |
5563 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); | |
5564 } break; | |
5565 case 0x0023: { | |
5566 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5567 } break; | |
5568 default: { | |
5569 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5570 } break; | |
5571 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5572 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5573 g_free(dialog_top); |
5574 g_free(dialog_msg); | |
5575 return 1; | |
5576 } | |
5577 | |
9626 | 5578 if (sn != NULL) { |
4585 | 5579 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
|
5580 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5581 g_free(dialog_msg); |
5582 } | |
5583 | |
9626 | 5584 if (email != NULL) { |
5575 | 5585 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5586 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5587 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5588 g_free(dialog_msg); |
2086 | 5589 } |
5590 | |
5591 return 1; | |
5592 } | |
5593 | |
5575 | 5594 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5595 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5596 aim_flap_nop(od->sess, od->conn); |
2086 | 5597 } |
5598 | |
6059 | 5599 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5600 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5601 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5602 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5603 if (typing == GAIM_TYPING) |
4870 | 5604 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5605 else if (typing == GAIM_TYPED) |
4870 | 5606 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5607 else | |
5608 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5609 else { |
5300 | 5610 /* Don't send if this turkey is in our deny list */ |
5611 GSList *list; | |
5612 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5613 if (!list) { | |
7261 | 5614 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5615 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5616 if (typing == GAIM_TYPING) |
5300 | 5617 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5618 else if (typing == GAIM_TYPED) |
5300 | 5619 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5620 else | |
5621 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5622 } | |
3595 | 5623 } |
5624 } | |
2993 | 5625 return 0; |
5626 } | |
9030 | 5627 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5628 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
|
5629 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5630 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5631 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5632 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5633 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
|
5634 int ret = 0; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5635 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); |
10781 | 5636 char *tmpmsg = NULL; |
3458 | 5637 |
4838 | 5638 if (dim && dim->connected) { |
5639 /* If we're directly connected, send a direct IM */ | |
6982 | 5640 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5641 } else { |
4738 | 5642 struct buddyinfo *bi; |
3008 | 5643 struct aim_sendimext_args args; |
5644 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5645 gsize len; |
10246 | 5646 GaimConversation *conv; |
5647 | |
11338 | 5648 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account); |
8962 | 5649 |
5650 if (strstr(message, "<IMG ")) | |
5651 gaim_conversation_write(conv, "", | |
5652 _("Your IM Image was not sent. " | |
5653 "You must be Direct Connected to send IM Images."), | |
5654 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5655 |
10246 | 5656 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5657 if (!bi) { |
5658 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5659 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5660 } |
5661 | |
3008 | 5662 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5663 if (od->icq) { |
11185 | 5664 /* We have to present different "features" (whose meaning |
11172 | 5665 is unclear and are merely a result of protocol inspection) |
5666 to offline ICQ buddies. Otherwise, the official | |
5667 ICQ client doesn't treat those messages as being "ANSI- | |
5668 encoded" (and instead, assumes them to be UTF-8). | |
5669 For more details, see SF issue 1179452. | |
5670 */ | |
5671 GaimBuddy *buddy = gaim_find_buddy(gc->account, name); | |
5672 if (buddy && buddy->present != 0) { | |
5673 args.features = features_icq; | |
5674 args.featureslen = sizeof(features_icq); | |
5675 } else { | |
5676 args.features = features_icq_offline; | |
5677 args.featureslen = sizeof(features_icq_offline); | |
5678 } | |
3008 | 5679 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5680 } else { |
5681 args.features = features_aim; | |
5682 args.featureslen = sizeof(features_aim); | |
4972 | 5683 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5684 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5685 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5686 } |
4269 | 5687 |
4738 | 5688 if (bi->ico_need) { |
8660 | 5689 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5690 "Sending buddy icon request with message\n"); |
3008 | 5691 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5692 bi->ico_need = FALSE; |
3008 | 5693 } |
4269 | 5694 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5695 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5696 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 5697 if (file) { |
11159 | 5698 guchar *buf = g_malloc(st.st_size); |
9532 | 5699 /* XXX - Use g_file_get_contents()? */ |
3008 | 5700 fread(buf, 1, st.st_size, file); |
6039 | 5701 fclose(file); |
4269 | 5702 |
3008 | 5703 args.iconlen = st.st_size; |
4617 | 5704 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5705 args.iconstamp = st.st_mtime; |
5706 | |
7406 | 5707 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5708 bi->ico_informed = FALSE; |
7406 | 5709 bi->ico_sent = FALSE; |
5710 } | |
4738 | 5711 |
5712 if (!bi->ico_informed) { | |
8660 | 5713 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5714 "Claiming to have a buddy icon\n"); |
4738 | 5715 args.flags |= AIM_IMFLAGS_HASICON; |
5716 bi->ico_me_len = args.iconlen; | |
5717 bi->ico_me_csum = args.iconsum; | |
5718 bi->ico_me_time = args.iconstamp; | |
5719 bi->ico_informed = TRUE; | |
5720 } | |
5721 | |
3008 | 5722 g_free(buf); |
2086 | 5723 } |
5724 } | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5725 g_free(iconfile); |
4269 | 5726 |
3008 | 5727 args.destsn = name; |
4269 | 5728 |
8985 | 5729 /* |
10781 | 5730 * If we're IMing an ICQ user from an ICQ account, then strip HTML |
5731 * and use \r\n as the newline character. | |
8985 | 5732 */ |
10781 | 5733 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
5734 if (aim_sn_is_icq(name)) | |
5735 /* From ICQ to ICQ */ | |
8995 | 5736 tmpmsg = g_strdup(message); |
10781 | 5737 else |
5738 /* From ICQ to AIM */ | |
5739 tmpmsg = g_markup_escape_text(message, -1); | |
8995 | 5740 } else { |
10785 | 5741 /* From AIM to AIM and AIM to ICQ */ |
5742 tmpmsg = g_strdup(message); | |
8995 | 5743 } |
6310 | 5744 len = strlen(tmpmsg); |
5745 | |
9830 | 5746 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5747 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5748 args.charset, args.charsubset, args.msglen); | |
4617 | 5749 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5750 g_free((char *)args.msg); |
2086 | 5751 } |
4838 | 5752 |
6310 | 5753 g_free(tmpmsg); |
5754 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5755 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5756 return 1; |
6310 | 5757 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5758 return ret; |
2086 | 5759 } |
5760 | |
7011 | 5761 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5762 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5763 |
9975 | 5764 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5765 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5766 else |
7235 | 5767 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5768 } |
5769 | |
8950 | 5770 #if 0 |
7011 | 5771 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5772 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5773 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5774 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5775 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5776 maiden, NULL, NULL, city, state, NULL, 0, web); |
5777 } | |
8950 | 5778 #endif |
2086 | 5779 |
5575 | 5780 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5781 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5782 aim_srv_setidle(od->sess, time); |
2086 | 5783 } |
5784 | |
5954 | 5785 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5786 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5787 int charset = 0; |
6019 | 5788 char *text_html = NULL; |
5129 | 5789 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5790 gsize msglen = 0; |
2993 | 5791 |
4617 | 5792 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5793 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5794 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5795 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5796 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5797 "again when you are fully connected.")); |
4617 | 5798 |
7334 | 5799 if (!text) { |
5800 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5801 return; | |
5802 } | |
10097 | 5803 |
7334 | 5804 text_html = gaim_strdup_withhtml(text); |
9807 | 5805 charset = oscar_charset_check(text_html); |
9826 | 5806 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5807 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5808 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5809 g_free(msg); | |
9826 | 5810 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5811 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5812 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5813 g_free(msg); | |
5814 } else { | |
5815 msglen = strlen(text_html); | |
5816 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5817 } | |
5818 | |
5819 if (msglen > od->rights.maxsiglen) { | |
5820 gchar *errstr; | |
5821 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5822 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5823 "The maximum profile length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5824 "has been exceeded. Gaim has truncated it for you.", |
7334 | 5825 od->rights.maxsiglen), od->rights.maxsiglen); |
5826 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5827 g_free(errstr); | |
5828 } | |
5829 | |
5830 g_free(text_html); | |
2086 | 5831 } |
5832 | |
9991 | 5833 static void |
5834 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5835 { |
9991 | 5836 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5837 OscarData *od = NULL; |
9992 | 5838 GaimStatusType *status_type; |
9991 | 5839 GaimStatusPrimitive primitive; |
5840 GaimPresence *presence; | |
5841 const gchar *status_id; | |
9807 | 5842 int charset = 0; |
10196 | 5843 const gchar *text_html = NULL; |
5129 | 5844 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5845 gsize msglen = 0; |
2993 | 5846 |
9992 | 5847 status_type = gaim_status_get_type(status); |
5848 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5849 status_id = gaim_status_get_id(status); |
5850 presence = gaim_account_get_presence(account); | |
5851 | |
10400 | 5852 if (gc) |
5853 od = (OscarData *)gc->proto_data; | |
10401 | 5854 |
5855 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { | |
9991 | 5856 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5857 _("You have probably requested to set your " |
5858 "away message before the login procedure " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5859 "completed. You remain in a \"present\" " |
10400 | 5860 "state; try setting it again when you are " |
5861 "fully connected.")); | |
10401 | 5862 return; |
5863 } | |
5129 | 5864 |
9992 | 5865 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5866 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5867 | |
7334 | 5868 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5869 |
5870 text_html = gaim_status_get_attr_string(status, "message"); | |
5871 if (text_html != NULL) { | |
5872 aim_srv_setavailmsg(od->sess, text_html); | |
5873 } | |
10196 | 5874 |
5875 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5876 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5877 | |
10196 | 5878 text_html = gaim_status_get_attr_string(status, "message"); |
5879 | |
5880 if (text_html == NULL) { | |
5881 text_html = _("Away"); | |
5882 } | |
5883 | |
5884 charset = oscar_charset_check(text_html); | |
5885 if (charset == AIM_CHARSET_UNICODE) { | |
5886 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5887 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5888 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5889 g_free(msg); | |
5890 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5891 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5892 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5893 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5894 g_free(msg); | |
5895 } else { | |
5896 msglen = strlen(text_html); | |
5897 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5898 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5899 } | |
5900 | |
5901 if (msglen > od->rights.maxawaymsglen) { | |
5902 gchar *errstr; | |
5903 | |
5904 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5905 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5906 "The maximum away message length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5907 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5908 od->rights.maxawaymsglen), od->rights.maxawaymsglen); |
5909 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5910 g_free(errstr); | |
5911 } | |
5912 | |
10197 | 5913 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5914 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5915 | |
5129 | 5916 } else { |
10196 | 5917 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5918 | |
5919 } | |
2993 | 5920 } |
5921 | |
9991 | 5922 static void |
5923 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5924 { |
9991 | 5925 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 5926 OscarData *od = NULL; |
9991 | 5927 const gchar *status_id = gaim_status_get_id(status); |
5928 | |
10646 | 5929 if (gc) |
5930 od = (OscarData *)gc->proto_data; | |
5931 if (!od) | |
5932 return; | |
5933 | |
9991 | 5934 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) |
5575 | 5935 account->perm_deny = 4; |
8265 | 5936 else |
5575 | 5937 account->perm_deny = 3; |
9991 | 5938 |
8265 | 5939 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5940 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5941 |
9991 | 5942 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5943 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5944 |
5945 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5946 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5947 |
5948 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5949 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5950 |
5951 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5952 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5953 |
5954 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5955 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5956 |
5957 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5958 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5959 |
5960 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5961 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5962 |
5963 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5964 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5965 } |
5966 | |
9991 | 5967 static void |
5968 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5969 { |
11251 | 5970 gboolean disconnected = gaim_account_is_disconnected(account); |
10400 | 5971 GaimStatusType *type = gaim_status_get_type(status); |
5972 int primitive = gaim_status_type_get_primitive(type); | |
5973 | |
10747 | 5974 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
5975 | |
10498 | 5976 if (!gaim_status_is_active(status)) |
10485 | 5977 return; |
5978 | |
11251 | 5979 if (primitive != GAIM_STATUS_OFFLINE && disconnected) { |
10738 | 5980 gaim_account_connect(account); |
11251 | 5981 } else if (primitive == GAIM_STATUS_OFFLINE && !disconnected) { |
10400 | 5982 gaim_account_disconnect(account); |
5983 } else { | |
11251 | 5984 if (!gaim_account_is_connected(account)) |
10747 | 5985 return; |
10400 | 5986 |
5987 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
5988 oscar_set_status_icq(account, status); | |
5989 else | |
10560 | 5990 /* QQQ - Should probably also set this for ICQ */ |
10400 | 5991 oscar_set_status_aim(account, status); |
5992 } | |
2086 | 5993 } |
5994 | |
11285 | 5995 #ifdef CRAZY_WARN |
9991 | 5996 static void |
5997 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5998 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5999 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 6000 } |
11285 | 6001 #endif |
2086 | 6002 |
10747 | 6003 static void |
6004 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6005 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6006 |
6007 if (!aim_snvalid(buddy->name)) { | |
8092 | 6008 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6009 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 | 6010 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
6011 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 6012 g_free(buf); |
8150 | 6013 |
6014 /* Remove from local list */ | |
9285 | 6015 gaim_blist_remove_buddy(buddy); |
8150 | 6016 |
8092 | 6017 return; |
6018 } | |
6019 | |
9285 | 6020 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
6021 if (buddy && group) { | |
8660 | 6022 gaim_debug_info("oscar", |
9285 | 6023 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 6024 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 6025 } |
6026 } | |
8150 | 6027 |
10157 | 6028 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 6029 if (od->icq) |
9285 | 6030 aim_icq_getalias(od->sess, buddy->name); |
6031 } | |
6032 | |
6033 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6034 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6035 |
4230 | 6036 if (od->sess->ssi.received_data) { |
8660 | 6037 gaim_debug_info("oscar", |
9285 | 6038 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
6039 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 6040 } |
10866 | 6041 } |
6042 | |
5575 | 6043 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 6044 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 6045 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 6046 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6047 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 6048 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 6049 } |
6050 } | |
6051 | |
5575 | 6052 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 6053 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 6054 if (od->sess->ssi.received_data) { |
6055 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
6056 if (gname) { | |
8660 | 6057 gaim_debug_info("oscar", |
9586 | 6058 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 6059 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 6060 } |
6061 } | |
6062 } | |
6063 | |
11005 | 6064 /* |
6065 * FYI, the OSCAR SSI code removes empty groups automatically. | |
6066 */ | |
9285 | 6067 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 6068 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6069 |
6070 if (od->sess->ssi.received_data) { | |
9285 | 6071 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
6072 GList *cur, *groups = NULL; | |
6073 | |
6074 /* Make a list of what the groups each buddy is in */ | |
6075 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
6076 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6077 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6078 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6079 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6080 node->parent->parent); |
9285 | 6081 } |
6082 | |
10866 | 6083 serv_remove_buddies(gc, moved_buddies, groups); |
6084 serv_add_buddies(gc, moved_buddies); | |
9285 | 6085 g_list_free(groups); |
8660 | 6086 gaim_debug_info("oscar", |
9285 | 6087 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 6088 } else { |
9285 | 6089 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 6090 gaim_debug_info("oscar", |
9285 | 6091 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 6092 } |
6093 } | |
6094 } | |
6095 | |
5968 | 6096 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
6097 aim_session_t *sess = data; | |
6350 | 6098 aim_ssi_reqdata(sess); |
5968 | 6099 return FALSE; |
6100 } | |
6101 | |
4642 | 6102 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6103 GaimConnection *gc = sess->aux_data; |
7283 | 6104 OscarData *od = gc->proto_data; |
4642 | 6105 va_list ap; |
6106 fu16_t reason; | |
6107 | |
6108 va_start(ap, fr); | |
6109 reason = (fu16_t)va_arg(ap, unsigned int); | |
6110 va_end(ap); | |
6111 | |
8660 | 6112 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 6113 |
6114 if (reason == 0x0005) { | |
5892 | 6115 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6116 _("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
|
6117 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 6118 } |
6119 | |
6120 /* Activate SSI */ | |
6121 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6122 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6123 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 6124 aim_ssi_enable(od->sess); |
6125 | |
6126 return 1; | |
6127 } | |
6128 | |
2991 | 6129 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6130 GaimConnection *gc = sess->aux_data; |
7283 | 6131 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 6132 int i; |
6133 va_list ap; | |
6134 int numtypes; | |
4230 | 6135 fu16_t *maxitems; |
2991 | 6136 |
6137 va_start(ap, fr); | |
4230 | 6138 numtypes = va_arg(ap, int); |
6139 maxitems = va_arg(ap, fu16_t *); | |
2991 | 6140 va_end(ap); |
6141 | |
8660 | 6142 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6143 |
4230 | 6144 for (i=0; i<numtypes; i++) |
8660 | 6145 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6146 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6147 |
8660 | 6148 gaim_debug_misc(NULL, "\n"); |
4230 | 6149 |
6150 if (numtypes >= 0) | |
6151 od->rights.maxbuddies = maxitems[0]; | |
6152 if (numtypes >= 1) | |
6153 od->rights.maxgroups = maxitems[1]; | |
6154 if (numtypes >= 2) | |
6155 od->rights.maxpermits = maxitems[2]; | |
6156 if (numtypes >= 3) | |
6157 od->rights.maxdenies = maxitems[3]; | |
2991 | 6158 |
6159 return 1; | |
6160 } | |
6161 | |
6162 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6163 GaimConnection *gc = sess->aux_data; |
6164 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6165 GaimStatus *status; |
7283 | 6166 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6167 GaimGroup *g; |
6168 GaimBuddy *b; | |
2995 | 6169 struct aim_ssi_item *curitem; |
2991 | 6170 int tmp; |
4230 | 6171 va_list ap; |
8219 | 6172 fu16_t fmtver, numitems; |
6173 struct aim_ssi_item *items; | |
6174 fu32_t timestamp; | |
4230 | 6175 |
6176 va_start(ap, fr); | |
6177 fmtver = (fu16_t)va_arg(ap, int); | |
6178 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6179 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6180 timestamp = va_arg(ap, fu32_t); |
8219 | 6181 va_end(ap); |
2991 | 6182 |
8660 | 6183 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6184 "ssi: syncing local list and server list\n"); |
2991 | 6185 |
8219 | 6186 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6187 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 | 6188 return 1; |
6189 } | |
6190 | |
2991 | 6191 /* Clean the buddy list */ |
4889 | 6192 aim_ssi_cleanlist(sess); |
2991 | 6193 |
8150 | 6194 { /* If not in server list then prune from local list */ |
6195 GaimBlistNode *gnode, *cnode, *bnode; | |
6196 GaimBuddyList *blist; | |
9539 | 6197 GSList *cur, *next; |
8150 | 6198 |
6199 /* Buddies */ | |
6200 cur = NULL; | |
6201 if ((blist = gaim_get_blist()) != NULL) { | |
6202 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6203 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6204 continue; | |
6205 g = (GaimGroup *)gnode; | |
6206 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6207 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6208 continue; | |
6209 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6210 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6211 continue; | |
6212 b = (GaimBuddy *)bnode; | |
6213 if (b->account == gc->account) { | |
6214 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6215 /* If the buddy is an ICQ user then load his nickname */ | |
6216 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6217 char *alias; |
8150 | 6218 if (servernick) |
6219 serv_got_alias(gc, b->name, servernick); | |
6220 | |
6221 /* Store local alias on server */ | |
8214 | 6222 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6223 if (!alias && b->alias && strlen(b->alias)) |
6224 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6225 free(alias); | |
6226 } else { | |
8660 | 6227 gaim_debug_info("oscar", |
8150 | 6228 "ssi: removing buddy %s from local list\n", b->name); |
6229 /* We can't actually remove now because it will screw up our looping */ | |
6230 cur = g_slist_prepend(cur, b); | |
6231 } | |
6232 } | |
6233 } | |
6234 } | |
6235 } | |
6236 } | |
8175 | 6237 |
8150 | 6238 while (cur != NULL) { |
6239 b = cur->data; | |
6240 cur = g_slist_remove(cur, b); | |
6241 gaim_blist_remove_buddy(b); | |
6242 } | |
6243 | |
6244 /* Permit list */ | |
6245 if (gc->account->permit) { | |
9539 | 6246 next = gc->account->permit; |
6247 while (next != NULL) { | |
6248 cur = next; | |
6249 next = next->next; | |
8150 | 6250 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6251 gaim_debug_info("oscar", |
8150 | 6252 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6253 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6254 } | |
9539 | 6255 } |
8150 | 6256 } |
6257 | |
6258 /* Deny list */ | |
6259 if (gc->account->deny) { | |
9539 | 6260 next = gc->account->deny; |
6261 while (next != NULL) { | |
6262 cur = next; | |
6263 next = next->next; | |
8150 | 6264 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6265 gaim_debug_info("oscar", |
8150 | 6266 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6267 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6268 } | |
9539 | 6269 } |
8150 | 6270 } |
6271 /* Presence settings (idle time visibility) */ | |
6272 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6273 if (!(tmp & 0x400)) | |
6274 aim_ssi_setpresence(sess, tmp | 0x400); | |
6275 } /* end pruning buddies from local list */ | |
6276 | |
2991 | 6277 /* Add from server list to local list */ |
4230 | 6278 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6279 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6280 switch (curitem->type) { |
4230 | 6281 case 0x0000: { /* Buddy */ |
4251 | 6282 if (curitem->name) { |
4292 | 6283 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6284 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6285 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6286 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6287 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6288 /* Should gname be freed here? -- elb */ |
4754 | 6289 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6290 free(alias); |
8150 | 6291 if (b) { |
4292 | 6292 /* Get server stored alias */ |
4705 | 6293 if (alias_utf8) { |
8150 | 6294 g_free(b->alias); |
6295 b->alias = g_strdup(alias_utf8); | |
4705 | 6296 } |
4282 | 6297 } else { |
8150 | 6298 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6299 |
4754 | 6300 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6301 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6302 gaim_blist_add_group(g, NULL); |
6303 } | |
5146 | 6304 |
8660 | 6305 gaim_debug_info("oscar", |
9285 | 6306 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6307 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6308 } |
8341 | 6309 if (!aim_sncmp(curitem->name, account->username)) { |
6310 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6311 gaim_check_comment(od, comment); | |
6312 free(comment); | |
6313 } | |
7162 | 6314 g_free(gname_utf8); |
6315 g_free(alias_utf8); | |
2991 | 6316 } |
4230 | 6317 } break; |
6318 | |
6319 case 0x0001: { /* Group */ | |
4282 | 6320 /* Shouldn't add empty groups */ |
4230 | 6321 } break; |
6322 | |
6323 case 0x0002: { /* Permit buddy */ | |
2991 | 6324 if (curitem->name) { |
4230 | 6325 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6326 GSList *list; |
5575 | 6327 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6328 if (!list) { |
8660 | 6329 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6330 "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
|
6331 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6332 } |
6333 } | |
4230 | 6334 } break; |
6335 | |
6336 case 0x0003: { /* Deny buddy */ | |
2991 | 6337 if (curitem->name) { |
6338 GSList *list; | |
5575 | 6339 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6340 if (!list) { |
8660 | 6341 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6342 "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
|
6343 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6344 } |
6345 } | |
4230 | 6346 } break; |
6347 | |
6348 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6349 if (curitem->data) { |
6350 fu8_t permdeny; | |
5575 | 6351 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6352 gaim_debug_info("oscar", |
5575 | 6353 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6354 account->perm_deny = permdeny; | |
6355 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6356 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6357 } |
2991 | 6358 } |
6359 } | |
4230 | 6360 } break; |
6361 | |
6362 case 0x0005: { /* Presence setting */ | |
3109 | 6363 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6364 } break; |
2991 | 6365 } /* End of switch on curitem->type */ |
6366 } /* End of for loop */ | |
4230 | 6367 |
9991 | 6368 /* |
6369 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6370 * this. We probably want the SSI status setting to override the local | |
6371 * setting. | |
6372 */ | |
9982 | 6373 status = gaim_presence_get_active_status(account->presence); |
6374 if (gaim_status_is_available(status)) | |
4901 | 6375 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6376 | |
4342 | 6377 /* Activate SSI */ |
6378 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6379 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6380 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6381 "ssi: activating server-stored buddy list\n"); |
4642 | 6382 aim_ssi_enable(sess); |
4342 | 6383 |
2991 | 6384 return 1; |
2086 | 6385 } |
4230 | 6386 |
6387 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6388 GaimConnection *gc = sess->aux_data; |
4230 | 6389 va_list ap; |
6390 struct aim_ssi_tmp *retval; | |
6391 | |
6392 va_start(ap, fr); | |
6393 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6394 va_end(ap); | |
6395 | |
6396 while (retval) { | |
8660 | 6397 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6398 "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 | 6399 |
6400 if (retval->ack != 0xffff) | |
6401 switch (retval->ack) { | |
6402 case 0x0000: { /* added successfully */ | |
6403 } break; | |
6404 | |
4829 | 6405 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6406 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6407 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 | 6408 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6409 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6410 g_free(buf); |
6411 } | |
6412 | |
7023 | 6413 case 0x000e: { /* buddy requires authorization */ |
4828 | 6414 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6415 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6416 } break; |
6417 | |
6418 default: { /* La la la */ | |
5197 | 6419 gchar *buf; |
8660 | 6420 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6421 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 | 6422 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6423 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6424 g_free(buf); |
4230 | 6425 } break; |
6426 } | |
6427 | |
6428 retval = retval->next; | |
6429 } | |
6430 | |
6431 return 1; | |
6432 } | |
6433 | |
8227 | 6434 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6435 GaimConnection *gc = sess->aux_data; | |
6436 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6437 GaimBuddy *b; | |
6438 GaimGroup *g; | |
6439 va_list ap; | |
6440 fu16_t type; | |
6441 const char *name; | |
6442 | |
6443 va_start(ap, fr); | |
6444 type = (fu16_t)va_arg(ap, int); | |
6445 name = va_arg(ap, char *); | |
6446 va_end(ap); | |
6447 | |
6448 if ((type != 0x0000) || (name == NULL)) | |
6449 return 1; | |
6450 | |
6451 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6452 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6453 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6454 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6455 b = gaim_find_buddy(gc->account, name); | |
6456 free(alias); | |
6457 | |
6458 if (b) { | |
6459 /* Get server stored alias */ | |
6460 if (alias_utf8) { | |
6461 g_free(b->alias); | |
6462 b->alias = g_strdup(alias_utf8); | |
6463 } | |
6464 } else { | |
6465 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6466 | |
6467 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6468 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6469 gaim_blist_add_group(g, NULL); | |
6470 } | |
6471 | |
8660 | 6472 gaim_debug_info("oscar", |
9285 | 6473 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6474 gaim_blist_add_buddy(b, NULL, g, NULL); |
6475 } | |
6476 g_free(gname_utf8); | |
6477 g_free(alias_utf8); | |
6478 | |
6479 return 1; | |
6480 } | |
6481 | |
4230 | 6482 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6483 GaimConnection *gc = sess->aux_data; |
4230 | 6484 va_list ap; |
6485 char *sn, *msg; | |
4236 | 6486 gchar *dialog_msg, *nombre; |
4230 | 6487 struct name_data *data; |
6695 | 6488 GaimBuddy *buddy; |
4230 | 6489 |
6490 va_start(ap, fr); | |
6491 sn = va_arg(ap, char *); | |
6492 msg = va_arg(ap, char *); | |
6493 va_end(ap); | |
6494 | |
8660 | 6495 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6496 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6497 |
4687 | 6498 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6499 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6500 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6501 else |
6502 nombre = g_strdup(sn); | |
6503 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6504 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 | 6505 data = g_new(struct name_data, 1); |
6506 data->gc = gc; | |
6507 data->name = g_strdup(sn); | |
6508 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6509 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6510 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6511 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6512 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6513 G_CALLBACK(oscar_free_name_data)); |
4236 | 6514 |
4230 | 6515 g_free(dialog_msg); |
4236 | 6516 g_free(nombre); |
4230 | 6517 |
6518 return 1; | |
6519 } | |
6520 | |
6521 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6522 GaimConnection *gc = sess->aux_data; |
4230 | 6523 va_list ap; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6524 char *sn; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6525 char *msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6526 GaimAccount *account = gaim_connection_get_account(gc); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6527 gchar *nombre; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6528 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6529 gchar *dialog_msg; |
4230 | 6530 struct name_data *data; |
6695 | 6531 GaimBuddy *buddy; |
4230 | 6532 |
6533 va_start(ap, fr); | |
6534 sn = va_arg(ap, char *); | |
6535 msg = va_arg(ap, char *); | |
6536 va_end(ap); | |
6537 | |
8660 | 6538 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6539 "ssi: received authorization request from %s\n", sn); |
4230 | 6540 |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6541 buddy = gaim_find_buddy(account, sn); |
9620 | 6542 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6543 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6544 else |
6545 nombre = g_strdup(sn); | |
6546 | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6547 if (msg != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6548 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg, strlen(msg)); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6549 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6550 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6551 |
10949 | 6552 dialog_msg = g_strdup_printf( |
6553 _("The user %s wants to add %s to their buddy list for the following reason:\n%s"), | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6554 nombre, gaim_account_get_username(account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6555 g_free(reason); |
10949 | 6556 |
4230 | 6557 data = g_new(struct name_data, 1); |
6558 data->gc = gc; | |
6559 data->name = g_strdup(sn); | |
6560 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6561 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6562 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6563 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6564 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6565 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6566 |
4230 | 6567 g_free(dialog_msg); |
4236 | 6568 g_free(nombre); |
4230 | 6569 |
6570 return 1; | |
6571 } | |
6572 | |
6573 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6574 GaimConnection *gc = sess->aux_data; |
4230 | 6575 va_list ap; |
6576 char *sn, *msg; | |
4236 | 6577 gchar *dialog_msg, *nombre; |
4230 | 6578 fu8_t reply; |
6695 | 6579 GaimBuddy *buddy; |
4230 | 6580 |
6581 va_start(ap, fr); | |
6582 sn = va_arg(ap, char *); | |
6583 reply = (fu8_t)va_arg(ap, int); | |
6584 msg = va_arg(ap, char *); | |
6585 va_end(ap); | |
6586 | |
8660 | 6587 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6588 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6589 |
4687 | 6590 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6591 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6592 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6593 else |
6594 nombre = g_strdup(sn); | |
6595 | |
4230 | 6596 if (reply) { |
6597 /* Granted */ | |
7023 | 6598 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
|
6599 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6600 } else { |
6601 /* Denied */ | |
7023 | 6602 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
|
6603 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6604 } |
6605 g_free(dialog_msg); | |
4236 | 6606 g_free(nombre); |
4230 | 6607 |
6608 return 1; | |
6609 } | |
6610 | |
6611 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6612 GaimConnection *gc = sess->aux_data; |
4230 | 6613 va_list ap; |
6614 char *sn; | |
6695 | 6615 GaimBuddy *buddy; |
4230 | 6616 |
6617 va_start(ap, fr); | |
6618 sn = va_arg(ap, char *); | |
6619 va_end(ap); | |
6620 | |
4687 | 6621 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6622 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6623 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6624 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6625 |
6626 return 1; | |
6627 } | |
2086 | 6628 |
5575 | 6629 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6630 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6631 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6632 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6633 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6634 pce->label = _("_Room:"); |
5234 | 6635 pce->identifier = "room"; |
10475 | 6636 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6637 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6638 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6639 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6640 pce->label = _("_Exchange:"); |
5234 | 6641 pce->identifier = "exchange"; |
10475 | 6642 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6643 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6644 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6645 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6646 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6647 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6648 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6649 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6650 |
9754 | 6651 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6652 { | |
6653 GHashTable *defaults; | |
6654 | |
6655 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6656 | |
6657 if (chat_name != NULL) | |
6658 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6659 | |
6660 return defaults; | |
6661 } | |
6662 | |
9917 | 6663 static char *oscar_get_chat_name(GHashTable *data) { |
6664 return g_strdup(g_hash_table_lookup(data, "room")); | |
6665 } | |
6666 | |
8308 | 6667 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6668 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6669 aim_conn_t *cur; |
5234 | 6670 char *name, *exchange; |
6671 | |
6672 name = g_hash_table_lookup(data, "room"); | |
6673 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6674 |
8660 | 6675 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6676 "Attempting to join chat room %s.\n", name); |
8308 | 6677 |
6678 if ((name == NULL) || (*name == '\0')) { | |
6679 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6680 return; | |
6681 } | |
6682 | |
4617 | 6683 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6684 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6685 "chatnav exists, creating room\n"); |
5234 | 6686 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6687 } else { |
6688 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6689 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6690 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6691 "chatnav does not exist, opening chatnav\n"); |
5234 | 6692 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6693 cr->name = g_strdup(name); |
4617 | 6694 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6695 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6696 } |
6697 } | |
6698 | |
8308 | 6699 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6700 OscarData *od = (OscarData *)gc->proto_data; | |
6701 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6702 |
6703 if (ccon == NULL) | |
2086 | 6704 return; |
10404 | 6705 |
8225 | 6706 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6707 ccon->exchange, ccon->name, 0x0); |
6708 } | |
6709 | |
10458 | 6710 static void |
6711 oscar_chat_leave(GaimConnection *gc, int id) | |
6712 { | |
6713 GaimConversation *conv; | |
6714 struct chat_connection *cc; | |
6715 | |
6716 conv = gaim_find_chat(gc, id); | |
6717 | |
6718 g_return_if_fail(conv != NULL); | |
6719 | |
6720 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6721 | |
6722 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6723 oscar_chat_kill(gc, cc); | |
2086 | 6724 } |
6725 | |
8219 | 6726 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6727 OscarData *od = (OscarData *)gc->proto_data; | |
6728 GaimConversation *conv = NULL; | |
2086 | 6729 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6730 char *buf, *buf2; |
9830 | 6731 fu16_t charset, charsubset; |
9807 | 6732 char *charsetstr = NULL; |
10111 | 6733 int len; |
8219 | 6734 |
6735 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6736 return -EINVAL; |
2086 | 6737 |
8219 | 6738 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6739 return -EINVAL; |
2086 | 6740 |
8219 | 6741 buf = gaim_strdup_withhtml(message); |
6742 len = strlen(buf); | |
6743 | |
8962 | 6744 if (strstr(buf, "<IMG ")) |
6745 gaim_conversation_write(conv, "", | |
6746 _("Your IM Image was not sent. " | |
6747 "You cannot send IM Images in AIM chats."), | |
6748 GAIM_MESSAGE_ERROR, time(NULL)); | |
6749 | |
9830 | 6750 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6751 if ((len > c->maxlen) || (len > c->maxvis)) { |
6752 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6753 return -E2BIG; |
8359 | 6754 } |
6755 | |
9831 | 6756 if (charset == AIM_CHARSET_ASCII) |
6757 charsetstr = "us-ascii"; | |
6758 else if (charset == AIM_CHARSET_UNICODE) | |
6759 charsetstr = "unicode-2-0"; | |
6760 else if (charset == AIM_CHARSET_CUSTOM) | |
6761 charsetstr = "iso-8859-1"; | |
9807 | 6762 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6763 g_free(buf2); |
8359 | 6764 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6765 return 0; |
2086 | 6766 } |
6767 | |
10042 | 6768 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6769 { | |
4766 | 6770 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6771 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6772 return "icq"; |
6773 else | |
6774 return "aim"; | |
6775 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6776 |
9975 | 6777 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6778 return "icq"; |
6779 return "aim"; | |
6780 } | |
6781 | |
9972 | 6782 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6783 { |
7334 | 6784 GaimConnection *gc = NULL; |
6785 OscarData *od = NULL; | |
10042 | 6786 GaimAccount *account = NULL; |
6787 GaimPresence *presence; | |
6788 GaimStatus *status; | |
6789 const char *status_id; | |
4687 | 6790 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6791 int i = 0; | |
7334 | 6792 aim_userinfo_t *userinfo = NULL; |
6793 | |
6794 if (b != NULL) | |
6795 account = b->account; | |
6796 if (account != NULL) | |
6797 gc = account->gc; | |
6798 if (gc != NULL) | |
6799 od = gc->proto_data; | |
7945 | 6800 if (od != NULL) |
6801 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6802 |
10042 | 6803 presence = gaim_buddy_get_presence(b); |
6804 status = gaim_presence_get_active_status(presence); | |
6805 status_id = gaim_status_get_id(status); | |
6806 | |
6807 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6808 char *gname; |
7334 | 6809 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6810 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6811 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6812 emblems[i++] = "notauthorized"; | |
6813 } else { | |
6814 emblems[i++] = "offline"; | |
6815 } | |
6816 } | |
4916 | 6817 |
10042 | 6818 if (b->name && aim_sn_is_icq(b->name)) { |
6819 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6820 emblems[i++] = "invisible"; | |
6821 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6822 emblems[i++] = "freeforchat"; |
10042 | 6823 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6824 emblems[i++] = "dnd"; |
10042 | 6825 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6826 emblems[i++] = "na"; |
10042 | 6827 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6828 emblems[i++] = "occupied"; |
10042 | 6829 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6830 emblems[i++] = "away"; |
10042 | 6831 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6832 emblems[i++] = "away"; | |
6833 } | |
6834 | |
6835 if (userinfo != NULL ) { | |
6836 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6837 emblems[i++] = "unconfirmed"; */ | |
6838 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6839 emblems[i++] = "admin"; | |
6840 if (userinfo->flags & AIM_FLAG_AOL) | |
6841 emblems[i++] = "aol"; | |
6842 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6843 emblems[i++] = "wireless"; | |
6844 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6845 emblems[i++] = "activebuddy"; | |
6846 | |
6847 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6848 emblems[i++] = "hiptop"; |
6849 | |
10042 | 6850 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6851 emblems[i++] = "secure"; |
10042 | 6852 } |
7334 | 6853 |
4687 | 6854 *se = emblems[0]; |
6855 *sw = emblems[1]; | |
6856 *nw = emblems[2]; | |
6857 *ne = emblems[3]; | |
6858 } | |
6859 | |
6695 | 6860 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6861 GaimConnection *gc = b->account->gc; |
7283 | 6862 OscarData *od = gc->proto_data; |
7045 | 6863 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6864 GString *str = g_string_new(""); |
5131 | 6865 |
6866 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6867 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6868 |
6869 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6870 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6871 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6872 g_free(charset); |
7011 | 6873 if (away_utf8 != NULL) { |
7091 | 6874 gchar *tmp1, *tmp2; |
9627 | 6875 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6876 g_free(away_utf8); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
6877 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 6878 g_free(tmp2); |
8700 | 6879 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6880 g_free(tmp1); |
8701 | 6881 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6882 g_free(tmp2); |
5836 | 6883 } |
5131 | 6884 } |
8701 | 6885 } |
6886 | |
6887 return g_string_free(str, FALSE); | |
5131 | 6888 } |
6889 | |
10042 | 6890 static char *oscar_status_text(GaimBuddy *b) |
6891 { | |
6892 GaimConnection *gc; | |
6893 OscarData *od; | |
11248 | 6894 GaimPresence *presence; |
5167 | 6895 gchar *ret = NULL; |
6896 | |
10042 | 6897 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6898 od = gc->proto_data; | |
11248 | 6899 presence = gaim_buddy_get_presence(b); |
6900 | |
6901 if (!gaim_presence_is_online(presence)) | |
6902 { | |
5167 | 6903 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6904 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6905 ret = g_strdup(_("Not Authorized")); | |
6906 else | |
6907 ret = g_strdup(_("Offline")); | |
6908 } | |
11248 | 6909 else if (gaim_presence_is_available(presence)) |
6910 { | |
6911 struct buddyinfo *bi; | |
6912 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); | |
6913 if ((bi != NULL) && (bi->availmsg != NULL)) | |
6914 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
6915 } | |
6916 else | |
6917 { | |
6918 if (aim_sn_is_icq(b->name)) | |
6919 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
6920 else | |
6921 ret = g_strdup(_("Away")); | |
6922 } | |
5167 | 6923 |
6924 return ret; | |
6925 } | |
6926 | |
5842 | 6927 |
5844 | 6928 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6929 GaimConnection *gc = sess->aux_data; |
7283 | 6930 OscarData *od = gc->proto_data; |
5892 | 6931 va_list ap; |
5842 | 6932 fu16_t type; |
5892 | 6933 fu8_t flags = 0, length = 0; |
11159 | 6934 guchar *md5 = NULL; |
5892 | 6935 |
7334 | 6936 |
5842 | 6937 va_start(ap, fr); |
6938 type = va_arg(ap, int); | |
5892 | 6939 |
6940 switch(type) { | |
6941 case 0x0000: | |
6942 case 0x0001: { | |
6943 flags = va_arg(ap, int); | |
6944 length = va_arg(ap, int); | |
11159 | 6945 md5 = va_arg(ap, guchar *); |
5892 | 6946 |
6947 if (flags == 0x41) { | |
6948 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6949 od->iconconnecting = TRUE; | |
6950 od->set_icon = TRUE; | |
6951 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6952 } else { | |
6039 | 6953 struct stat st; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6954 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
6039 | 6955 if (iconfile == NULL) { |
8363 | 6956 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6957 } else if (!g_stat(iconfile, &st)) { |
11159 | 6958 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6959 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 6960 if (file) { |
9532 | 6961 /* XXX - Use g_file_get_contents()? */ |
6039 | 6962 fread(buf, 1, st.st_size, file); |
6963 fclose(file); | |
8660 | 6964 gaim_debug_info("oscar", |
10042 | 6965 "Uploading icon to icon server\n"); |
6879 | 6966 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6967 } else |
8660 | 6968 gaim_debug_error("oscar", |
10042 | 6969 "Can't open buddy icon file!\n"); |
6039 | 6970 g_free(buf); |
6971 } else { | |
8660 | 6972 gaim_debug_error("oscar", |
10042 | 6973 "Can't stat buddy icon file!\n"); |
5892 | 6974 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6975 g_free(iconfile); |
5892 | 6976 } |
8363 | 6977 } else if (flags == 0x81) { |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6978 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
8363 | 6979 if (iconfile == NULL) |
6980 aim_ssi_delicon(od->sess); | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6981 else { |
8363 | 6982 aim_ssi_seticon(od->sess, md5, length); |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6983 g_free(iconfile); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6984 } |
8363 | 6985 } |
5892 | 6986 } break; |
6987 | |
6988 case 0x0002: { /* We just set an "available" message? */ | |
6989 } break; | |
6990 } | |
6991 | |
5842 | 6992 va_end(ap); |
5844 | 6993 |
6994 return 0; | |
5842 | 6995 } |
5892 | 6996 |
5575 | 6997 static void oscar_set_permit_deny(GaimConnection *gc) { |
6998 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6999 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 7000 |
8175 | 7001 if (od->sess->ssi.received_data) { |
7002 switch (account->perm_deny) { | |
7003 case GAIM_PRIVACY_ALLOW_ALL: | |
7004 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
7005 break; | |
7006 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
7007 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
7008 break; | |
7009 case GAIM_PRIVACY_ALLOW_USERS: | |
7010 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
7011 break; | |
7012 case GAIM_PRIVACY_DENY_ALL: | |
7013 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
7014 break; | |
7015 case GAIM_PRIVACY_DENY_USERS: | |
7016 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
7017 break; | |
7018 default: | |
7019 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
7020 break; | |
7021 } | |
7022 } | |
2086 | 7023 } |
7024 | |
5575 | 7025 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 7026 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7027 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 7028 if (od->sess->ssi.received_data) |
4889 | 7029 aim_ssi_addpermit(od->sess, who); |
2086 | 7030 } |
7031 | |
5575 | 7032 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 7033 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7034 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 7035 if (od->sess->ssi.received_data) |
4889 | 7036 aim_ssi_adddeny(od->sess, who); |
2086 | 7037 } |
7038 | |
5575 | 7039 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 7040 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7041 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 7042 if (od->sess->ssi.received_data) |
4889 | 7043 aim_ssi_delpermit(od->sess, who); |
2086 | 7044 } |
7045 | |
5575 | 7046 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 7047 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7048 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 7049 if (od->sess->ssi.received_data) |
4889 | 7050 aim_ssi_deldeny(od->sess, who); |
2086 | 7051 } |
7052 | |
9975 | 7053 static GList * |
7054 oscar_status_types(GaimAccount *account) | |
2086 | 7055 { |
9975 | 7056 GList *status_types = NULL; |
7057 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
7058 |
9973 | 7059 g_return_val_if_fail(account != NULL, NULL); |
7060 | |
10042 | 7061 /* Oscar-common status types */ |
9991 | 7062 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
7063 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 7064 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 7065 status_types = g_list_append(status_types, type); |
7066 | |
9991 | 7067 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
7068 OSCAR_STATUS_ID_ONLINE, | |
10400 | 7069 _("Online"), FALSE, TRUE, FALSE); |
9976 | 7070 status_types = g_list_append(status_types, type); |
7071 | |
10198 | 7072 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
7073 OSCAR_STATUS_ID_AVAILABLE, | |
7074 _("Available"), TRUE, TRUE, FALSE, | |
7075 "message", _("Message"), | |
7076 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 7077 status_types = g_list_append(status_types, type); |
7078 | |
10195 | 7079 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
7080 OSCAR_STATUS_ID_AWAY, | |
7081 _("Away"), TRUE, TRUE, FALSE, | |
7082 "message", _("Message"), | |
7083 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 7084 status_types = g_list_append(status_types, type); |
7085 | |
7086 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
7087 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 7088 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 7089 status_types = g_list_append(status_types, type); |
7090 | |
7091 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
7092 return status_types; | |
7093 | |
7094 /* ICQ-specific status types */ | |
7095 | |
9991 | 7096 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
7097 OSCAR_STATUS_ID_FREE4CHAT, | |
7098 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 7099 status_types = g_list_append(status_types, type); |
7100 | |
9991 | 7101 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
7102 OSCAR_STATUS_ID_OCCUPIED, | |
7103 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 7104 status_types = g_list_append(status_types, type); |
7105 | |
9991 | 7106 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7107 OSCAR_STATUS_ID_DND, | |
7108 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 7109 status_types = g_list_append(status_types, type); |
7110 | |
9991 | 7111 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7112 OSCAR_STATUS_ID_NA, | |
7113 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 7114 status_types = g_list_append(status_types, type); |
9975 | 7115 |
7116 return status_types; | |
4333 | 7117 } |
7118 | |
7172 | 7119 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 7120 GaimConnection *gc = data->gc; |
7121 OscarData *od = gc->proto_data; | |
7172 | 7122 GaimBuddy *b; |
7123 GaimGroup *g; | |
7124 | |
7125 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
7126 oscar_free_name_data(data); | |
7127 return; | |
7128 } | |
7129 | |
7130 if (!(g = gaim_find_buddys_group(b))) { | |
7131 oscar_free_name_data(data); | |
7132 return; | |
7133 } | |
7134 | |
7135 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 7136 |
7137 if (!aim_sncmp(data->name, gc->account->username)) | |
7138 gaim_check_comment(od, text); | |
7139 | |
7172 | 7140 oscar_free_name_data(data); |
7141 } | |
7142 | |
9030 | 7143 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
7144 | |
7145 GaimBuddy *buddy; | |
7146 GaimConnection *gc; | |
7147 OscarData *od; | |
7148 struct name_data *data; | |
7172 | 7149 GaimGroup *g; |
7150 char *comment; | |
7151 gchar *comment_utf8; | |
9631 | 7152 gchar *title; |
7172 | 7153 |
9030 | 7154 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
7155 | |
7156 buddy = (GaimBuddy *) node; | |
7157 gc = gaim_account_get_connection(buddy->account); | |
7158 od = gc->proto_data; | |
7159 | |
7160 data = g_new(struct name_data, 1); | |
7161 | |
7162 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 7163 return; |
9030 | 7164 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 7165 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
7166 | |
7167 data->gc = gc; | |
9030 | 7168 data->name = g_strdup(buddy->name); |
7172 | 7169 data->nick = NULL; |
7170 | |
9631 | 7171 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7172 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7173 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7174 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7175 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7176 data); | |
9631 | 7177 g_free(title); |
7172 | 7178 |
7179 free(comment); | |
7180 g_free(comment_utf8); | |
7181 } | |
7182 | |
9030 | 7183 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7184 | |
7185 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7186 OscarData *od = gc->proto_data; |
9030 | 7187 |
4333 | 7188 GList *m = NULL; |
9030 | 7189 GaimBlistNodeAction *act; |
7190 | |
7191 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7192 oscar_buddycb_edit_comment, NULL, NULL); |
9030 | 7193 m = g_list_append(m, act); |
7172 | 7194 |
4333 | 7195 if (od->icq) { |
4624 | 7196 #if 0 |
9030 | 7197 act = gaim_blist_node_action_new(_("Get Status Msg"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7198 oscar_get_icqstatusmsg, NULL, NULL); |
9030 | 7199 m = g_list_append(m, act); |
4624 | 7200 #endif |
4333 | 7201 } else { |
7011 | 7202 aim_userinfo_t *userinfo; |
9030 | 7203 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7204 | |
7205 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7206 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7207 | |
7011 | 7208 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7209 act = gaim_blist_node_action_new(_("Direct IM"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7210 oscar_ask_direct_im, NULL, NULL); |
9030 | 7211 m = g_list_append(m, act); |
5917 | 7212 } |
9466 | 7213 #if 0 |
7011 | 7214 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7215 act = gaim_blist_node_action_new(_("Get File"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7216 oscar_ask_getfile, NULL, NULL); |
9030 | 7217 m = g_list_append(m, act); |
5917 | 7218 } |
4826 | 7219 #endif |
4333 | 7220 } |
5131 | 7221 } |
5197 | 7222 |
5131 | 7223 if (od->sess->ssi.received_data) { |
9030 | 7224 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7225 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7226 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7227 gaim_auth_sendrequest_menu, NULL, NULL); |
9030 | 7228 m = g_list_append(m, act); |
4333 | 7229 } |
4916 | 7230 } |
10157 | 7231 |
4333 | 7232 return m; |
7233 } | |
7234 | |
9030 | 7235 |
7236 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7237 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7238 return oscar_buddy_menu((GaimBuddy *) node); | |
7239 } else { | |
7240 return NULL; | |
7241 } | |
7242 } | |
7243 | |
10570 | 7244 static void |
7245 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
7246 { | |
7247 OscarData *od = gc->proto_data; | |
7248 GaimAccount *account = gaim_connection_get_account(gc); | |
7249 GaimRequestField *f; | |
7250 gboolean auth, hide_ip, web_aware; | |
7251 | |
7252 f = gaim_request_fields_get_field(fields, "authorization"); | |
7253 auth = gaim_request_field_bool_get_value(f); | |
7254 | |
7255 f = gaim_request_fields_get_field(fields, "hide_ip"); | |
7256 hide_ip = gaim_request_field_bool_get_value(f); | |
7257 | |
7258 f = gaim_request_fields_get_field(fields, "web_aware"); | |
7259 web_aware = gaim_request_field_bool_get_value(f); | |
7260 | |
7261 gaim_account_set_bool(account, "authorization", auth); | |
7262 gaim_account_set_bool(account, "hide_ip", hide_ip); | |
7263 gaim_account_set_bool(account, "web_aware", web_aware); | |
7264 | |
7265 aim_icq_setsecurity(od->sess, auth, web_aware, hide_ip); | |
7266 } | |
7267 | |
7268 static void | |
7269 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
7270 { | |
7271 GaimConnection *gc = (GaimConnection *) action->context; | |
7272 GaimAccount *account = gaim_connection_get_account(gc); | |
7273 GaimRequestFields *fields; | |
7274 GaimRequestFieldGroup *g; | |
7275 GaimRequestField *f; | |
7276 gboolean auth, hide_ip, web_aware; | |
7277 | |
7278 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7279 hide_ip = gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7280 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7281 | |
7282 fields = gaim_request_fields_new(); | |
7283 | |
7284 g = gaim_request_field_group_new(NULL); | |
7285 | |
7286 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
7287 gaim_request_field_group_add_field(g, f); | |
7288 | |
7289 f = gaim_request_field_bool_new("hide_ip", _("Hide IP address"), hide_ip); | |
7290 gaim_request_field_group_add_field(g, f); | |
7291 | |
7292 f = gaim_request_field_bool_new("web_aware", _("Web aware"), web_aware); | |
7293 gaim_request_field_group_add_field(g, f); | |
7294 | |
7295 gaim_request_fields_add_group(fields, g); | |
7296 | |
7297 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
7298 NULL, fields, | |
7299 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
7300 _("Cancel"), NULL, gc); | |
7301 } | |
9030 | 7302 |
5575 | 7303 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7304 OscarData *od = gc->proto_data; |
5575 | 7305 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7306 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7307 od->setnick = TRUE; | |
7308 od->newsn = g_strdup(nick); | |
7309 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7310 } else { | |
7311 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7312 } | |
7313 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7314 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7315 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7316 } |
7317 } | |
7318 | |
9015 | 7319 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7320 { |
9015 | 7321 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7322 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7323 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7324 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7325 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7326 gc); |
4333 | 7327 } |
7328 | |
9015 | 7329 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7330 { |
9015 | 7331 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7332 OscarData *od = gc->proto_data; |
4333 | 7333 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7334 | |
7335 if (conn) { | |
7336 aim_admin_reqconfirm(od->sess, conn); | |
7337 } else { | |
7338 od->conf = TRUE; | |
7339 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7340 } | |
7341 } | |
7342 | |
9015 | 7343 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7344 { |
9015 | 7345 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7346 OscarData *od = gc->proto_data; |
4333 | 7347 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7348 | |
7349 if (conn) { | |
7350 aim_admin_getinfo(od->sess, conn, 0x11); | |
7351 } else { | |
7352 od->reqemail = TRUE; | |
7353 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7354 } | |
7355 } | |
7356 | |
5575 | 7357 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7358 { |
7283 | 7359 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7360 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
|
7361 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7362 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7363 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7364 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7365 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7366 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7367 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7368 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7369 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7370 |
9015 | 7371 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7372 { |
9015 | 7373 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7374 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7375 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7376 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7377 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7378 gc); |
4333 | 7379 } |
7380 | |
9015 | 7381 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7382 { |
9015 | 7383 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7384 OscarData *od = gc->proto_data; |
4333 | 7385 gchar *nombre, *text, *tmp; |
6695 | 7386 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7387 int num=0; |
7388 | |
6873 | 7389 text = g_strdup(""); |
4333 | 7390 |
4785 | 7391 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7392 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7393 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7394 continue; | |
6695 | 7395 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7396 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7397 continue; |
6695 | 7398 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7399 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7400 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7401 continue; | |
7402 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7403 if (gaim_buddy_get_alias_only(buddy)) |
7404 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7405 else |
7406 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7407 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7408 g_free(text); |
7409 text = tmp; | |
7410 g_free(nombre); | |
7411 num++; | |
7412 } | |
4333 | 7413 } |
2979 | 7414 } |
4333 | 7415 } |
7416 | |
7417 if (!num) { | |
7418 g_free(text); | |
6873 | 7419 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7420 } | |
7421 | |
7422 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7423 "the following buddies"), _("You can re-request " | |
7424 "authorization from these buddies by " | |
7425 "right-clicking on them and selecting " | |
7426 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7427 g_free(text); |
2979 | 7428 } |
7429 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7430 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7431 { |
8950 | 7432 OscarData *od = (OscarData *)gc->proto_data; |
7433 | |
7434 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7435 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7436 |
9015 | 7437 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7438 { |
9015 | 7439 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7440 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7441 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7442 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7443 "searching for."), |
8697 | 7444 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7445 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7446 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7447 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7448 |
9015 | 7449 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7450 { |
9015 | 7451 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7452 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7453 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7454 |
9015 | 7455 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7456 { |
9015 | 7457 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7458 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7459 } |
7460 | |
9015 | 7461 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7462 { |
9015 | 7463 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7464 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7465 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7466 |
9015 | 7467 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7468 { |
9015 | 7469 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7470 OscarData *od = gc->proto_data; |
5575 | 7471 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
|
7472 gaim_notify_uri(gc, substituted); |
5517 | 7473 g_free(substituted); |
4333 | 7474 } |
7475 | |
9015 | 7476 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7477 { |
9015 | 7478 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7479 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7480 } |
7481 | |
5842 | 7482 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7483 { | |
7283 | 7484 OscarData *od = gc->proto_data; |
5844 | 7485 aim_session_t *sess = od->sess; |
5842 | 7486 FILE *file; |
7487 struct stat st; | |
5844 | 7488 |
6039 | 7489 if (iconfile == NULL) { |
8363 | 7490 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7491 } else if (!g_stat(iconfile, &st)) { |
11159 | 7492 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7493 file = g_fopen(iconfile, "rb"); |
5842 | 7494 if (file) { |
6052 | 7495 md5_state_t *state; |
11159 | 7496 guchar md5[16]; |
9532 | 7497 /* XXX - Use g_file_get_contents()? */ |
5842 | 7498 int len = fread(buf, 1, st.st_size, file); |
6039 | 7499 fclose(file); |
6052 | 7500 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7501 md5_init(state); |
7502 md5_append(state, buf, len); | |
7503 md5_finish(state, md5); | |
7504 g_free(state); | |
7505 aim_ssi_seticon(sess, md5, 16); | |
7506 } else | |
8660 | 7507 gaim_debug_error("oscar", |
5842 | 7508 "Can't open buddy icon file!\n"); |
7509 g_free(buf); | |
7510 } else | |
8660 | 7511 gaim_debug_error("oscar", |
5842 | 7512 "Can't stat buddy icon file!\n"); |
7513 } | |
7514 | |
7515 | |
9015 | 7516 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7517 { |
9015 | 7518 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7519 OscarData *od = gc->proto_data; |
4333 | 7520 GList *m = NULL; |
9015 | 7521 GaimPluginAction *act; |
7522 | |
7523 act = gaim_plugin_action_new(_("Set User Info..."), | |
7524 oscar_show_set_info); | |
7525 m = g_list_append(m, act); | |
4333 | 7526 |
10570 | 7527 if (od->icq) |
7528 { | |
9015 | 7529 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7530 oscar_show_set_info_icqurl); | |
7531 m = g_list_append(m, act); | |
8576 | 7532 } |
7533 | |
9015 | 7534 act = gaim_plugin_action_new(_("Change Password..."), |
7535 oscar_change_pass); | |
7536 m = g_list_append(m, act); | |
4617 | 7537 |
10570 | 7538 if (od->sess->authinfo->chpassurl != NULL) |
7539 { | |
9015 | 7540 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7541 oscar_show_chpassurl); | |
7542 m = g_list_append(m, act); | |
7543 | |
7544 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7545 oscar_show_imforwardingurl); | |
7546 m = g_list_append(m, act); | |
7026 | 7547 } |
7548 | |
10570 | 7549 m = g_list_append(m, NULL); |
7550 | |
7551 if (od->icq) | |
7552 { | |
7553 /* ICQ actions */ | |
7554 act = gaim_plugin_action_new(_("Show privacy options..."), | |
7555 oscar_show_icq_privacy_opts); | |
7556 m = g_list_append(m, act); | |
7557 } | |
7558 else | |
7559 { | |
4617 | 7560 /* AIM actions */ |
9015 | 7561 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7562 oscar_show_format_screenname); | |
7563 m = g_list_append(m, act); | |
7564 | |
7565 act = gaim_plugin_action_new(_("Confirm Account"), | |
7566 oscar_confirm_account); | |
7567 m = g_list_append(m, act); | |
7568 | |
7569 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7570 oscar_show_email); | |
7571 m = g_list_append(m, act); | |
7572 | |
7573 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7574 oscar_show_change_email); | |
7575 m = g_list_append(m, act); | |
2086 | 7576 } |
4333 | 7577 |
7578 m = g_list_append(m, NULL); | |
7579 | |
9015 | 7580 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7581 oscar_show_awaitingauth); | |
7582 m = g_list_append(m, act); | |
4333 | 7583 |
2086 | 7584 m = g_list_append(m, NULL); |
4333 | 7585 |
9015 | 7586 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7587 oscar_show_find_email); | |
7588 m = g_list_append(m, act); | |
4333 | 7589 |
8591 | 7590 #if 0 |
9015 | 7591 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7592 show_find_info); | |
7593 m = g_list_append(m, act); | |
8591 | 7594 #endif |
2086 | 7595 |
7596 return m; | |
7597 } | |
7598 | |
5575 | 7599 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7600 { |
7283 | 7601 OscarData *od = gc->proto_data; |
4617 | 7602 |
7603 if (od->icq) { | |
7604 aim_icq_changepasswd(od->sess, new); | |
2086 | 7605 } else { |
4617 | 7606 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7607 if (conn) { | |
7608 aim_admin_changepasswd(od->sess, conn, new, old); | |
7609 } else { | |
7610 od->chpass = TRUE; | |
7611 od->oldp = g_strdup(old); | |
7612 od->newp = g_strdup(new); | |
7613 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7614 } | |
2086 | 7615 } |
7616 } | |
7617 | |
6059 | 7618 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7619 { |
7283 | 7620 OscarData *od = gc->proto_data; |
8971 | 7621 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
|
7622 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7623 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7624 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7625 |
8971 | 7626 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7627 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7628 |
9935 | 7629 static void |
7630 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7631 { | |
7632 GaimConnection *gc = data; | |
7633 OscarData *od = gc->proto_data; | |
7634 aim_session_t *sess = od->sess; | |
7635 fu32_t presence; | |
7636 | |
7637 presence = aim_ssi_getpresence(sess->ssi.local); | |
7638 | |
7639 if (value) { | |
9992 | 7640 /* Based on the packet capture I thought it was the first one */ |
7641 /* Stu thinks it's the second one. */ | |
7642 /* presence |= 0x00400000; */ | |
9971 | 7643 presence &= ~0x00020000; |
9935 | 7644 aim_ssi_setpresence(sess, presence); |
7645 } else { | |
9992 | 7646 /* presence &= ~0x00400000; */ |
9971 | 7647 presence |= 0x00020000; |
9935 | 7648 aim_ssi_setpresence(sess, presence); |
7649 } | |
7650 } | |
7651 | |
10653 | 7652 #if USE_PRPL_PREFERENCES |
9935 | 7653 static GaimPluginPrefFrame * |
9936 | 7654 get_plugin_pref_frame(GaimPlugin *plugin) |
7655 { | |
9935 | 7656 GaimPluginPrefFrame *frame; |
7657 GaimPluginPref *ppref; | |
7658 | |
7659 frame = gaim_plugin_pref_frame_new(); | |
7660 | |
7661 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7662 gaim_plugin_pref_frame_add(frame, ppref); | |
7663 | |
7664 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7665 gaim_plugin_pref_frame_add(frame, ppref); | |
7666 | |
7667 return frame; | |
7668 } | |
10653 | 7669 #endif |
9935 | 7670 |
11153 | 7671 static const char * |
7672 oscar_normalize(const GaimAccount *account, const char *str) | |
7673 { | |
7674 static char buf[BUF_LEN]; | |
7675 char *tmp1, *tmp2; | |
7676 int i, j; | |
7677 | |
7678 g_return_val_if_fail(str != NULL, NULL); | |
7679 | |
7680 strncpy(buf, str, BUF_LEN); | |
7681 for (i=0, j=0; buf[j]; i++, j++) | |
7682 { | |
7683 while (buf[j] == ' ') | |
7684 j++; | |
7685 buf[i] = buf[j]; | |
7686 } | |
7687 buf[i] = '\0'; | |
7688 | |
7689 tmp1 = g_utf8_strdown(buf, -1); | |
7690 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
7691 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
7692 g_free(tmp2); | |
7693 g_free(tmp1); | |
7694 | |
7695 return buf; | |
7696 } | |
7697 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7698 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7699 { |
9308 | 7700 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7701 NULL, /* user_splits */ |
7702 NULL, /* protocol_options */ | |
10674 | 7703 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
7704 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 7705 oscar_list_icon, /* list_icon */ |
7706 oscar_list_emblems, /* list_emblems */ | |
7707 oscar_status_text, /* status_text */ | |
7708 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7709 oscar_status_types, /* status_types */ |
9475 | 7710 oscar_blist_node_menu, /* blist_node_menu */ |
7711 oscar_chat_info, /* chat_info */ | |
9754 | 7712 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7713 oscar_login, /* login */ |
7714 oscar_close, /* close */ | |
7715 oscar_send_im, /* send_im */ | |
7716 oscar_set_info, /* set_info */ | |
7717 oscar_send_typing, /* send_typing */ | |
7718 oscar_get_info, /* get_info */ | |
9973 | 7719 oscar_set_status, /* set_status */ |
9475 | 7720 oscar_set_idle, /* set_idle */ |
7721 oscar_change_passwd, /* change_passwd */ | |
7722 oscar_add_buddy, /* add_buddy */ | |
10866 | 7723 NULL, /* add_buddies */ |
9475 | 7724 oscar_remove_buddy, /* remove_buddy */ |
10866 | 7725 NULL, /* remove_buddies */ |
9475 | 7726 oscar_add_permit, /* add_permit */ |
7727 oscar_add_deny, /* add_deny */ | |
7728 oscar_rem_permit, /* rem_permit */ | |
7729 oscar_rem_deny, /* rem_deny */ | |
7730 oscar_set_permit_deny, /* set_permit_deny */ | |
7731 oscar_join_chat, /* join_chat */ | |
7732 NULL, /* reject_chat */ | |
9973 | 7733 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7734 oscar_chat_invite, /* chat_invite */ |
7735 oscar_chat_leave, /* chat_leave */ | |
7736 NULL, /* chat_whisper */ | |
7737 oscar_send_chat, /* chat_send */ | |
7738 oscar_keepalive, /* keepalive */ | |
7739 NULL, /* register_user */ | |
7740 NULL, /* get_cb_info */ | |
7741 NULL, /* get_cb_away */ | |
7742 oscar_alias_buddy, /* alias_buddy */ | |
7743 oscar_move_buddy, /* group_buddy */ | |
7744 oscar_rename_group, /* rename_group */ | |
7745 NULL, /* buddy_free */ | |
7746 oscar_convo_closed, /* convo_closed */ | |
11153 | 7747 oscar_normalize, /* normalize */ |
9475 | 7748 oscar_set_icon, /* set_buddy_icon */ |
7749 NULL, /* remove_group */ | |
7750 NULL, /* get_cb_real_name */ | |
7751 NULL, /* set_chat_topic */ | |
7752 NULL, /* find_blist_chat */ | |
7753 NULL, /* roomlist_get_list */ | |
7754 NULL, /* roomlist_cancel */ | |
7755 NULL, /* roomlist_expand_category */ | |
7756 oscar_can_receive_file, /* can_receive_file */ | |
7757 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7758 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7759 |
10653 | 7760 #if USE_PRPL_PREFERENCES |
9935 | 7761 static GaimPluginUiInfo prefs_info = { |
7762 get_plugin_pref_frame | |
7763 }; | |
10653 | 7764 #endif |
9935 | 7765 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7766 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7767 { |
9943 | 7768 GAIM_PLUGIN_MAGIC, |
7769 GAIM_MAJOR_VERSION, | |
7770 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7771 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7772 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7773 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7774 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7775 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7776 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7777 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7778 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7779 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7780 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7781 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7782 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7783 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7784 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7785 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7786 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7787 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7788 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7789 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7790 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7791 NULL, /**< ui_info */ |
8993 | 7792 &prpl_info, /**< extra_info */ |
10653 | 7793 #if USE_PRPL_PREFERENCES |
10487 | 7794 NULL, /**< prefs_info */ |
10653 | 7795 #else |
7796 NULL, /**< prefs_info */ | |
7797 #endif | |
9015 | 7798 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7799 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7800 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7801 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7802 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7803 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7804 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7805 |
11338 | 7806 option = gaim_account_option_string_new(_("Auth host"), "server", OSCAR_DEFAULT_LOGIN_SERVER); |
9830 | 7807 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
7808 | |
11338 | 7809 option = gaim_account_option_int_new(_("Auth port"), "port", OSCAR_DEFAULT_LOGIN_PORT); |
9830 | 7810 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
7811 | |
7812 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7813 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
11338 | 7814 |
9935 | 7815 gaim_prefs_add_none("/plugins/prpl/oscar"); |
7816 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7817 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7818 } |
7819 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7820 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |