Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 11353:0f03b5492130
[gaim-migrate @ 13572]
ntlm support for sip
committer: Tailor Script <tailor@pidgin.im>
author | Thomas Butter <tbutter> |
---|---|
date | Sat, 27 Aug 2005 09:25:15 +0000 |
parents | 6c1ad49fcb4b |
children | 9480e0d0f563 |
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); |
11347 | 302 static void oscar_set_info(GaimConnection *gc, const char *info); |
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); |
2993 | 5146 |
5147 return 1; | |
5148 } | |
5149 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5150 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
|
5151 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5152 fu16_t maxbuddies, maxwatchers; |
5575 | 5153 GaimConnection *gc = sess->aux_data; |
7283 | 5154 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5155 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5156 va_start(ap, fr); |
4199 | 5157 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5158 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5159 va_end(ap); |
5160 | |
8660 | 5161 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5162 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5163 |
4617 | 5164 od->rights.maxbuddies = (guint)maxbuddies; |
5165 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5166 |
2086 | 5167 return 1; |
5168 } | |
5169 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5170 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5171 GaimConnection *gc = sess->aux_data; |
7283 | 5172 OscarData *od = (OscarData *)gc->proto_data; |
10570 | 5173 GaimAccount *account = gaim_connection_get_account(gc); |
7334 | 5174 va_list ap; |
5175 fu16_t maxpermits, maxdenies; | |
2086 | 5176 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5177 va_start(ap, fr); |
4199 | 5178 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5179 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5180 va_end(ap); |
5181 | |
8660 | 5182 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5183 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5184 |
4617 | 5185 od->rights.maxpermits = (guint)maxpermits; |
5186 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5187 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5188 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5189 |
8660 | 5190 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5191 |
2672 | 5192 aim_clientready(sess, fr->conn); |
5948 | 5193 aim_srv_setavailmsg(sess, NULL); |
7474 | 5194 aim_srv_setidle(sess, 0); |
4617 | 5195 |
4664 | 5196 if (od->icq) { |
5197 aim_icq_reqofflinemsgs(sess); | |
10570 | 5198 aim_icq_setsecurity(sess, |
5199 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
5200 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE), | |
5201 gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP)); | |
4664 | 5202 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5203 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5204 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5205 if (sess->authinfo->email) |
5206 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5207 |
5208 return 1; | |
5209 } | |
5210 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5211 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
|
5212 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5213 struct aim_icq_offlinemsg *msg; |
4075 | 5214 struct aim_incomingim_ch4_args args; |
5215 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5216 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5217 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5218 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5219 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5220 |
8660 | 5221 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5222 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5223 args.uin = msg->sender; |
5224 args.type = msg->type; | |
4173 | 5225 args.flags = msg->flags; |
4076 | 5226 args.msglen = msg->msglen; |
4075 | 5227 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5228 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5229 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5230 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5231 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5232 } |
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 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
|
5235 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5236 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5237 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5238 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5239 |
7388 | 5240 #if 0 |
5241 /* | |
7465 | 5242 * Update, 2003-11-09: |
5243 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5244 * | |
7388 | 5245 * It may not be my place to do this, but... |
5246 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5247 * stupid, and should not exist for % switches (%x in our case) that request | |
5248 * a year in the preferred representation for the current locale. For that | |
5249 * reason I've chosen to not use this workaround (n., see kluge). | |
5250 * | |
5251 * I have a date. I want to show it to the user in the "preferred" way. | |
5252 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5253 * what the locale wanted. | |
5254 * | |
5255 * If I have a necessity for a full representation of the year in the current | |
5256 * locale, then I'll use a switch that returns a full representation of the | |
5257 * year. | |
5258 * | |
5259 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5260 * (because you're anal, or whatever), then change the f***ing locale. | |
5261 * | |
5262 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5263 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5264 * |
5265 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5266 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5267 */ |
5268 | |
5269 /* | |
5270 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5271 * "last 2 digits" warning. |
5272 */ | |
10157 | 5273 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5274 const struct tm *tm) |
5275 { | |
5276 return strftime(s, max, fmt, tm); | |
5277 } | |
10636 | 5278 |
5279 /* | |
5280 * Before even realizing this was here, I went and did the same thing in util.c. | |
5281 * | |
5282 * Use gaim_strftime() | |
5283 */ | |
5284 | |
7388 | 5285 #endif |
7386 | 5286 |
4624 | 5287 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
|
5288 { |
5575 | 5289 GaimConnection *gc = sess->aux_data; |
8670 | 5290 OscarData *od = (OscarData *)gc->proto_data; |
5291 GaimBuddy *buddy; | |
8853 | 5292 struct buddyinfo *bi = NULL; |
4624 | 5293 gchar who[16]; |
8670 | 5294 GString *str; |
5295 gchar *primary, *utf8; | |
9634 | 5296 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5297 va_list ap; |
4151 | 5298 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5299 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5300 va_start(ap, fr); |
4151 | 5301 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5302 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5303 |
4664 | 5304 if (!info->uin) |
5305 return 0; | |
5306 | |
8670 | 5307 str = g_string_sized_new(100); |
5556 | 5308 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5309 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5310 if (buddy != NULL) | |
5311 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5312 | |
5313 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5314 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5315 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5316 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5317 (bi->ipaddr & 0xff000000) >> 24, | |
5318 (bi->ipaddr & 0x00ff0000) >> 16, | |
5319 (bi->ipaddr & 0x0000ff00) >> 8, | |
5320 (bi->ipaddr & 0x000000ff)); | |
8701 | 5321 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5322 g_free(tstr); |
5323 } | |
8701 | 5324 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5325 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5326 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5327 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5328 g_free(utf8); | |
4625 | 5329 } |
5330 if (info->numaddresses && info->email2) { | |
5331 int i; | |
5332 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5333 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
10683 | 5334 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 5335 g_free(utf8); |
4643 | 5336 } |
4625 | 5337 } |
4624 | 5338 } |
8701 | 5339 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5340 if (info->gender != 0) |
5341 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5342 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5343 char date[30]; |
5344 struct tm tm; | |
5345 tm.tm_mday = (int)info->birthday; | |
5346 tm.tm_mon = (int)info->birthmonth-1; | |
5347 tm.tm_year = (int)info->birthyear-1900; | |
10636 | 5348 gaim_strftime(date, sizeof(date), "%x", &tm); |
8701 | 5349 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5350 } |
4624 | 5351 if (info->age) { |
5352 char age[5]; | |
5353 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5354 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5355 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5356 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5357 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5358 g_free(utf8); | |
4819 | 5359 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5360 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5361 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5362 g_free(utf8); | |
5363 } | |
10683 | 5364 g_string_append_printf(str, "<hr>"); |
4641 | 5365 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5366 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5367 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5368 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5369 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5370 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
10683 | 5371 g_string_append_printf(str, "\n<hr>"); |
4151 | 5372 } |
4641 | 5373 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5374 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5375 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5376 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5377 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5378 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
10683 | 5379 g_string_append_printf(str, "\n<hr>"); |
4624 | 5380 } |
4641 | 5381 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5382 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5383 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5384 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5385 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5386 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5387 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5388 g_free(utf8); | |
4624 | 5389 } |
10683 | 5390 g_string_append_printf(str, "\n<hr>"); |
8670 | 5391 } |
5392 | |
9634 | 5393 if (buddy != NULL) |
5394 alias = gaim_buddy_get_alias(buddy); | |
5395 else | |
5396 alias = who; | |
5397 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5398 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5399 g_free(primary); |
8670 | 5400 g_string_free(str, TRUE); |
4151 | 5401 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5402 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5403 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5404 |
4759 | 5405 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5406 { | |
5575 | 5407 GaimConnection *gc = sess->aux_data; |
4820 | 5408 gchar who[16], *utf8; |
6695 | 5409 GaimBuddy *b; |
4759 | 5410 va_list ap; |
5411 struct aim_icq_info *info; | |
5412 | |
5413 va_start(ap, fr); | |
5414 info = va_arg(ap, struct aim_icq_info *); | |
5415 va_end(ap); | |
5416 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5417 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5418 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5419 serv_got_alias(gc, who, utf8); |
4759 | 5420 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5421 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5422 } |
4820 | 5423 g_free(utf8); |
4759 | 5424 } |
5425 | |
5426 return 1; | |
5427 } | |
5428 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5429 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
|
5430 { |
7032 | 5431 GaimConnection *gc = sess->aux_data; |
5432 gchar *text; | |
5433 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5434 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5435 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5436 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5437 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5438 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5439 url = va_arg(ap, char *); |
4199 | 5440 wid = (fu16_t) va_arg(ap, int); |
5441 hei = (fu16_t) va_arg(ap, int); | |
5442 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5443 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5444 |
7032 | 5445 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5446 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5447 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5448 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5449 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5450 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5451 |
7032 | 5452 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5453 { | |
6873 | 5454 GaimConnection *gc = sess->aux_data; |
5455 gchar *secondary; | |
10439 | 5456 gchar **screennames; |
6873 | 5457 int i, num; |
2086 | 5458 va_list ap; |
6873 | 5459 char *email, *SNs; |
2086 | 5460 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5461 va_start(ap, fr); |
6873 | 5462 email = va_arg(ap, char *); |
2086 | 5463 num = va_arg(ap, int); |
5464 SNs = va_arg(ap, char *); | |
5465 va_end(ap); | |
5466 | |
10439 | 5467 /* TODO: Need to use ngettext() here */ |
8152 | 5468 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5469 |
5470 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5471 for (i = 0; i < num; i++) |
10439 | 5472 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5473 screennames[num] = NULL; | |
5474 | |
5475 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5476 (const char **)screennames, NULL, NULL); | |
6873 | 5477 |
5478 g_free(secondary); | |
10439 | 5479 g_strfreev(screennames); |
2086 | 5480 |
5481 return 1; | |
5482 } | |
5483 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5484 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5485 va_list ap; |
6873 | 5486 char *email; |
5420 | 5487 char *buf; |
2086 | 5488 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5489 va_start(ap, fr); |
6873 | 5490 email = va_arg(ap, char *); |
2086 | 5491 va_end(ap); |
5492 | |
6873 | 5493 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
|
5494 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5495 g_free(buf); |
2086 | 5496 |
5497 return 1; | |
5498 } | |
5499 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5500 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5501 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5502 fu16_t status; |
2086 | 5503 va_list ap; |
5504 char msg[256]; | |
5505 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5506 va_start(ap, fr); |
4199 | 5507 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5508 va_end(ap); |
5509 | |
8660 | 5510 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5511 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5512 status ? "unknown" : "email sent"); |
5513 if (!status) { | |
5302 | 5514 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5515 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5516 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5517 } |
5518 | |
5519 return 1; | |
5520 } | |
5521 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5522 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5523 GaimConnection *gc = sess->aux_data; |
2086 | 5524 va_list ap; |
3912 | 5525 fu16_t perms, err; |
5526 char *url, *sn, *email; | |
5527 int change; | |
2086 | 5528 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5529 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5530 change = va_arg(ap, int); |
4199 | 5531 perms = (fu16_t) va_arg(ap, unsigned int); |
5532 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5533 url = va_arg(ap, char *); |
5534 sn = va_arg(ap, char *); | |
5535 email = va_arg(ap, char *); | |
2086 | 5536 va_end(ap); |
5537 | |
8660 | 5538 gaim_debug_misc("oscar", |
9626 | 5539 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5540 change ? "change" : "request", perms, err, | |
5541 (url != NULL) ? url : "(null)", | |
5542 (sn != NULL) ? sn : "(null)", | |
5543 (email != NULL) ? email : "(null)"); | |
5544 | |
5545 if ((err > 0) && (url != NULL)) { | |
3912 | 5546 char *dialog_msg; |
5547 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5548 switch (err) { | |
5549 case 0x0001: { | |
5550 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5551 } break; | |
5552 case 0x0006: { | |
5553 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5554 } break; | |
5555 case 0x000b: { | |
5556 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5557 } break; | |
5558 case 0x001d: { | |
5559 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); | |
5560 } break; | |
5561 case 0x0021: { | |
5562 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); | |
5563 } break; | |
5564 case 0x0023: { | |
5565 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5566 } break; | |
5567 default: { | |
5568 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5569 } break; | |
5570 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5571 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5572 g_free(dialog_top); |
5573 g_free(dialog_msg); | |
5574 return 1; | |
5575 } | |
5576 | |
9626 | 5577 if (sn != NULL) { |
4585 | 5578 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
|
5579 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5580 g_free(dialog_msg); |
5581 } | |
5582 | |
9626 | 5583 if (email != NULL) { |
5575 | 5584 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5585 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5586 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5587 g_free(dialog_msg); |
2086 | 5588 } |
5589 | |
5590 return 1; | |
5591 } | |
5592 | |
5575 | 5593 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5594 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5595 aim_flap_nop(od->sess, od->conn); |
2086 | 5596 } |
5597 | |
6059 | 5598 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5599 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5600 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5601 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5602 if (typing == GAIM_TYPING) |
4870 | 5603 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5604 else if (typing == GAIM_TYPED) |
4870 | 5605 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5606 else | |
5607 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5608 else { |
5300 | 5609 /* Don't send if this turkey is in our deny list */ |
5610 GSList *list; | |
5611 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5612 if (!list) { | |
7261 | 5613 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5614 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5615 if (typing == GAIM_TYPING) |
5300 | 5616 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5617 else if (typing == GAIM_TYPED) |
5300 | 5618 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5619 else | |
5620 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5621 } | |
3595 | 5622 } |
5623 } | |
2993 | 5624 return 0; |
5625 } | |
9030 | 5626 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5627 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
|
5628 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5629 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5630 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5631 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5632 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
|
5633 int ret = 0; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5634 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); |
10781 | 5635 char *tmpmsg = NULL; |
3458 | 5636 |
4838 | 5637 if (dim && dim->connected) { |
5638 /* If we're directly connected, send a direct IM */ | |
6982 | 5639 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5640 } else { |
4738 | 5641 struct buddyinfo *bi; |
3008 | 5642 struct aim_sendimext_args args; |
5643 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5644 gsize len; |
10246 | 5645 GaimConversation *conv; |
5646 | |
11338 | 5647 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account); |
8962 | 5648 |
5649 if (strstr(message, "<IMG ")) | |
5650 gaim_conversation_write(conv, "", | |
5651 _("Your IM Image was not sent. " | |
5652 "You must be Direct Connected to send IM Images."), | |
5653 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5654 |
10246 | 5655 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5656 if (!bi) { |
5657 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5658 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5659 } |
5660 | |
3008 | 5661 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5662 if (od->icq) { |
11185 | 5663 /* We have to present different "features" (whose meaning |
11172 | 5664 is unclear and are merely a result of protocol inspection) |
5665 to offline ICQ buddies. Otherwise, the official | |
5666 ICQ client doesn't treat those messages as being "ANSI- | |
5667 encoded" (and instead, assumes them to be UTF-8). | |
5668 For more details, see SF issue 1179452. | |
5669 */ | |
5670 GaimBuddy *buddy = gaim_find_buddy(gc->account, name); | |
5671 if (buddy && buddy->present != 0) { | |
5672 args.features = features_icq; | |
5673 args.featureslen = sizeof(features_icq); | |
5674 } else { | |
5675 args.features = features_icq_offline; | |
5676 args.featureslen = sizeof(features_icq_offline); | |
5677 } | |
3008 | 5678 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5679 } else { |
5680 args.features = features_aim; | |
5681 args.featureslen = sizeof(features_aim); | |
4972 | 5682 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5683 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5684 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5685 } |
4269 | 5686 |
4738 | 5687 if (bi->ico_need) { |
8660 | 5688 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5689 "Sending buddy icon request with message\n"); |
3008 | 5690 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5691 bi->ico_need = FALSE; |
3008 | 5692 } |
4269 | 5693 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5694 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5695 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 5696 if (file) { |
11159 | 5697 guchar *buf = g_malloc(st.st_size); |
9532 | 5698 /* XXX - Use g_file_get_contents()? */ |
3008 | 5699 fread(buf, 1, st.st_size, file); |
6039 | 5700 fclose(file); |
4269 | 5701 |
3008 | 5702 args.iconlen = st.st_size; |
4617 | 5703 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5704 args.iconstamp = st.st_mtime; |
5705 | |
7406 | 5706 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5707 bi->ico_informed = FALSE; |
7406 | 5708 bi->ico_sent = FALSE; |
5709 } | |
4738 | 5710 |
5711 if (!bi->ico_informed) { | |
8660 | 5712 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5713 "Claiming to have a buddy icon\n"); |
4738 | 5714 args.flags |= AIM_IMFLAGS_HASICON; |
5715 bi->ico_me_len = args.iconlen; | |
5716 bi->ico_me_csum = args.iconsum; | |
5717 bi->ico_me_time = args.iconstamp; | |
5718 bi->ico_informed = TRUE; | |
5719 } | |
5720 | |
3008 | 5721 g_free(buf); |
2086 | 5722 } |
5723 } | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5724 g_free(iconfile); |
4269 | 5725 |
3008 | 5726 args.destsn = name; |
4269 | 5727 |
8985 | 5728 /* |
10781 | 5729 * If we're IMing an ICQ user from an ICQ account, then strip HTML |
5730 * and use \r\n as the newline character. | |
8985 | 5731 */ |
10781 | 5732 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
5733 if (aim_sn_is_icq(name)) | |
5734 /* From ICQ to ICQ */ | |
8995 | 5735 tmpmsg = g_strdup(message); |
10781 | 5736 else |
5737 /* From ICQ to AIM */ | |
5738 tmpmsg = g_markup_escape_text(message, -1); | |
8995 | 5739 } else { |
10785 | 5740 /* From AIM to AIM and AIM to ICQ */ |
5741 tmpmsg = g_strdup(message); | |
8995 | 5742 } |
6310 | 5743 len = strlen(tmpmsg); |
5744 | |
9830 | 5745 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5746 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5747 args.charset, args.charsubset, args.msglen); | |
4617 | 5748 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5749 g_free((char *)args.msg); |
2086 | 5750 } |
4838 | 5751 |
6310 | 5752 g_free(tmpmsg); |
5753 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5754 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5755 return 1; |
6310 | 5756 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5757 return ret; |
2086 | 5758 } |
5759 | |
7011 | 5760 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5761 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5762 |
9975 | 5763 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5764 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5765 else |
7235 | 5766 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5767 } |
5768 | |
8950 | 5769 #if 0 |
7011 | 5770 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5771 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5772 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5773 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5774 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5775 maiden, NULL, NULL, city, state, NULL, 0, web); |
5776 } | |
8950 | 5777 #endif |
2086 | 5778 |
5575 | 5779 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5780 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5781 aim_srv_setidle(od->sess, time); |
2086 | 5782 } |
5783 | |
11347 | 5784 static |
5785 gchar *gaim_prpl_oscar_convert_to_infotext(const gchar *str, gsize *ret_len, char **encoding) | |
5786 { | |
9807 | 5787 int charset = 0; |
11347 | 5788 char *encoded = NULL; |
5789 | |
5790 charset = oscar_charset_check(str); | |
5791 if (charset == AIM_CHARSET_UNICODE) { | |
5792 encoded = g_convert(str, strlen(str), "UCS-2BE", "UTF-8", NULL, ret_len, NULL); | |
5793 *encoding = "unicode-2-0"; | |
5794 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5795 encoded = g_convert(str, strlen(str), "ISO-8859-1", "UTF-8", NULL, ret_len, NULL); | |
5796 *encoding = "iso-8859-1"; | |
5797 } else { | |
5798 encoded = g_strdup(str); | |
5799 *ret_len = strlen(str); | |
5800 *encoding = "us-ascii"; | |
5801 } | |
5802 | |
5803 return encoded; | |
5804 } | |
5805 | |
5806 /* | |
5807 * If we're away, this will also send the away message to the server. | |
5808 */ | |
5809 static void | |
5810 oscar_set_info(GaimConnection *gc, const char *rawinfo) | |
5811 { | |
5812 GaimAccount *account = gaim_connection_get_account(gc); | |
5813 OscarData *od = (OscarData *)gc->proto_data; | |
5814 GaimPresence *presence; | |
5815 GaimStatus *status; | |
5816 GaimStatusType *status_type; | |
5817 GaimStatusPrimitive primitive; | |
5818 | |
5819 char *htmlinfo; | |
5820 char *info_encoding = NULL; | |
5821 char *info = NULL; | |
5822 gsize infolen = 0; | |
5823 | |
5824 const char *htmlaway; | |
5825 char *away_encoding = NULL; | |
5826 char *away = NULL; | |
5827 gsize awaylen = 0; | |
5828 | |
5829 presence = gaim_account_get_presence(account); | |
5830 status = gaim_presence_get_active_status(presence); | |
5831 status_type = gaim_status_get_type(status); | |
5832 primitive = gaim_status_type_get_primitive(status_type); | |
2993 | 5833 |
4617 | 5834 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5835 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5836 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5837 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5838 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5839 "again when you are fully connected.")); |
4617 | 5840 |
11347 | 5841 if (rawinfo != NULL) |
5842 { | |
5843 htmlinfo = gaim_strdup_withhtml(rawinfo); | |
5844 info = gaim_prpl_oscar_convert_to_infotext(htmlinfo, &infolen, &info_encoding); | |
5845 g_free(htmlinfo); | |
5846 | |
5847 if (infolen > od->rights.maxsiglen) | |
5848 { | |
5849 gchar *errstr; | |
5850 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5851 "has been exceeded. Gaim has truncated it for you.", | |
5852 "The maximum profile length of %d bytes " | |
5853 "has been exceeded. Gaim has truncated it for you.", | |
5854 od->rights.maxsiglen), od->rights.maxsiglen); | |
5855 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5856 g_free(errstr); | |
5857 } | |
5858 } | |
5859 else | |
5860 { | |
5861 /* TODO: It's very possible that this isn't necessary */ | |
5862 info = g_strdup(""); | |
5863 } | |
5864 | |
5865 if (primitive == GAIM_STATUS_AWAY) | |
5866 { | |
5867 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5868 | |
5869 htmlaway = gaim_status_get_attr_string(status, "message"); | |
5870 if (htmlaway == NULL) | |
5871 htmlaway = _("Away"); | |
5872 away = gaim_prpl_oscar_convert_to_infotext(htmlaway, &awaylen, &away_encoding); | |
5873 | |
5874 if (awaylen > od->rights.maxawaymsglen) | |
5875 { | |
5876 gchar *errstr; | |
5877 | |
5878 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
5879 "has been exceeded. Gaim has truncated it for you.", | |
5880 "The maximum away message length of %d bytes " | |
5881 "has been exceeded. Gaim has truncated it for you.", | |
5882 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5883 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5884 g_free(errstr); | |
5885 } | |
5886 } | |
5887 | |
5888 aim_locate_setprofile(od->sess, info_encoding, info, MIN(infolen, od->rights.maxsiglen), | |
5889 away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen)); | |
5890 g_free(info); | |
5891 g_free(away); | |
2086 | 5892 } |
5893 | |
9991 | 5894 static void |
5895 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5896 { |
9991 | 5897 GaimConnection *gc = gaim_account_get_connection(account); |
11347 | 5898 OscarData *od = (OscarData *)gc->proto_data; |
5899 GaimPresence *presence; | |
9992 | 5900 GaimStatusType *status_type; |
9991 | 5901 GaimStatusPrimitive primitive; |
5902 const gchar *status_id; | |
11347 | 5903 |
10196 | 5904 const gchar *text_html = NULL; |
11347 | 5905 char *away_encoding = NULL; |
5906 char *away = NULL; | |
5907 gsize awaylen = 0; | |
2993 | 5908 |
9992 | 5909 status_type = gaim_status_get_type(status); |
5910 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5911 status_id = gaim_status_get_id(status); |
5912 presence = gaim_account_get_presence(account); | |
5913 | |
10401 | 5914 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { |
9991 | 5915 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5916 _("You have probably requested to set your " |
5917 "away message before the login procedure " | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5918 "completed. You remain in a \"present\" " |
10400 | 5919 "state; try setting it again when you are " |
5920 "fully connected.")); | |
10401 | 5921 return; |
5922 } | |
5129 | 5923 |
9992 | 5924 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5925 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5926 | |
7334 | 5927 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5928 |
5929 text_html = gaim_status_get_attr_string(status, "message"); | |
5930 if (text_html != NULL) { | |
5931 aim_srv_setavailmsg(od->sess, text_html); | |
5932 } | |
10196 | 5933 |
5934 } else if (primitive == GAIM_STATUS_AWAY) { | |
11347 | 5935 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
10197 | 5936 |
10196 | 5937 text_html = gaim_status_get_attr_string(status, "message"); |
5938 | |
11347 | 5939 if ((text_html == NULL) || (*text_html == '\0')) { |
10196 | 5940 text_html = _("Away"); |
5941 } | |
5942 | |
11347 | 5943 away = gaim_prpl_oscar_convert_to_infotext(text_html, &awaylen, &away_encoding); |
5944 aim_locate_setprofile(od->sess, NULL, NULL, 0, away_encoding, away, | |
5945 MIN(awaylen, od->rights.maxawaymsglen)); | |
5946 g_free(away); | |
5947 | |
5948 if (awaylen > od->rights.maxawaymsglen) { | |
10196 | 5949 gchar *errstr; |
5950 | |
5951 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
|
5952 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5953 "The maximum away message length of %d bytes " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5954 "has been exceeded. Gaim has truncated it for you.", |
10196 | 5955 od->rights.maxawaymsglen), od->rights.maxawaymsglen); |
5956 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5957 g_free(errstr); | |
5958 } | |
5959 | |
10197 | 5960 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5961 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5962 | |
5129 | 5963 } else { |
10196 | 5964 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5965 | |
5966 } | |
2993 | 5967 } |
5968 | |
9991 | 5969 static void |
5970 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5971 { |
9991 | 5972 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 5973 OscarData *od = NULL; |
9991 | 5974 const gchar *status_id = gaim_status_get_id(status); |
5975 | |
10646 | 5976 if (gc) |
5977 od = (OscarData *)gc->proto_data; | |
5978 if (!od) | |
5979 return; | |
5980 | |
9991 | 5981 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) |
5575 | 5982 account->perm_deny = 4; |
8265 | 5983 else |
5575 | 5984 account->perm_deny = 3; |
9991 | 5985 |
8265 | 5986 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5987 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5988 |
9991 | 5989 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5990 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5991 |
5992 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5993 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5994 |
5995 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5996 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5997 |
5998 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5999 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 6000 |
6001 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 6002 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 6003 |
6004 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 6005 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 6006 |
6007 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 6008 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 6009 |
6010 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
6011 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 6012 } |
6013 | |
9991 | 6014 static void |
6015 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 6016 { |
11251 | 6017 gboolean disconnected = gaim_account_is_disconnected(account); |
10400 | 6018 GaimStatusType *type = gaim_status_get_type(status); |
6019 int primitive = gaim_status_type_get_primitive(type); | |
6020 | |
10747 | 6021 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
6022 | |
10498 | 6023 if (!gaim_status_is_active(status)) |
10485 | 6024 return; |
6025 | |
11251 | 6026 if (primitive != GAIM_STATUS_OFFLINE && disconnected) { |
10738 | 6027 gaim_account_connect(account); |
11251 | 6028 } else if (primitive == GAIM_STATUS_OFFLINE && !disconnected) { |
10400 | 6029 gaim_account_disconnect(account); |
6030 } else { | |
11251 | 6031 if (!gaim_account_is_connected(account)) |
10747 | 6032 return; |
10400 | 6033 |
6034 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
6035 oscar_set_status_icq(account, status); | |
6036 else | |
10560 | 6037 /* QQQ - Should probably also set this for ICQ */ |
10400 | 6038 oscar_set_status_aim(account, status); |
6039 } | |
2086 | 6040 } |
6041 | |
11285 | 6042 #ifdef CRAZY_WARN |
9991 | 6043 static void |
6044 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 6045 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 6046 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 6047 } |
11285 | 6048 #endif |
2086 | 6049 |
10747 | 6050 static void |
6051 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6052 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6053 |
6054 if (!aim_snvalid(buddy->name)) { | |
8092 | 6055 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6056 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 | 6057 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
6058 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 6059 g_free(buf); |
8150 | 6060 |
6061 /* Remove from local list */ | |
9285 | 6062 gaim_blist_remove_buddy(buddy); |
8150 | 6063 |
8092 | 6064 return; |
6065 } | |
6066 | |
9285 | 6067 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
6068 if (buddy && group) { | |
8660 | 6069 gaim_debug_info("oscar", |
9285 | 6070 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 6071 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 6072 } |
6073 } | |
8150 | 6074 |
10157 | 6075 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 6076 if (od->icq) |
9285 | 6077 aim_icq_getalias(od->sess, buddy->name); |
6078 } | |
6079 | |
6080 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6081 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6082 |
4230 | 6083 if (od->sess->ssi.received_data) { |
8660 | 6084 gaim_debug_info("oscar", |
9285 | 6085 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
6086 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 6087 } |
10866 | 6088 } |
6089 | |
5575 | 6090 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 6091 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 6092 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 6093 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6094 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 6095 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 6096 } |
6097 } | |
6098 | |
5575 | 6099 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 6100 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 6101 if (od->sess->ssi.received_data) { |
6102 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
6103 if (gname) { | |
8660 | 6104 gaim_debug_info("oscar", |
9586 | 6105 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 6106 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 6107 } |
6108 } | |
6109 } | |
6110 | |
11005 | 6111 /* |
6112 * FYI, the OSCAR SSI code removes empty groups automatically. | |
6113 */ | |
9285 | 6114 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 6115 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6116 |
6117 if (od->sess->ssi.received_data) { | |
9285 | 6118 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
6119 GList *cur, *groups = NULL; | |
6120 | |
6121 /* Make a list of what the groups each buddy is in */ | |
6122 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
6123 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6124 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6125 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6126 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6127 node->parent->parent); |
9285 | 6128 } |
6129 | |
10866 | 6130 serv_remove_buddies(gc, moved_buddies, groups); |
6131 serv_add_buddies(gc, moved_buddies); | |
9285 | 6132 g_list_free(groups); |
8660 | 6133 gaim_debug_info("oscar", |
9285 | 6134 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 6135 } else { |
9285 | 6136 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 6137 gaim_debug_info("oscar", |
9285 | 6138 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 6139 } |
6140 } | |
6141 } | |
6142 | |
5968 | 6143 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
6144 aim_session_t *sess = data; | |
6350 | 6145 aim_ssi_reqdata(sess); |
5968 | 6146 return FALSE; |
6147 } | |
6148 | |
4642 | 6149 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6150 GaimConnection *gc = sess->aux_data; |
7283 | 6151 OscarData *od = gc->proto_data; |
4642 | 6152 va_list ap; |
6153 fu16_t reason; | |
6154 | |
6155 va_start(ap, fr); | |
6156 reason = (fu16_t)va_arg(ap, unsigned int); | |
6157 va_end(ap); | |
6158 | |
8660 | 6159 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 6160 |
6161 if (reason == 0x0005) { | |
5892 | 6162 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6163 _("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
|
6164 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 6165 } |
6166 | |
6167 /* Activate SSI */ | |
6168 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6169 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6170 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 6171 aim_ssi_enable(od->sess); |
6172 | |
6173 return 1; | |
6174 } | |
6175 | |
2991 | 6176 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6177 GaimConnection *gc = sess->aux_data; |
7283 | 6178 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 6179 int i; |
6180 va_list ap; | |
6181 int numtypes; | |
4230 | 6182 fu16_t *maxitems; |
2991 | 6183 |
6184 va_start(ap, fr); | |
4230 | 6185 numtypes = va_arg(ap, int); |
6186 maxitems = va_arg(ap, fu16_t *); | |
2991 | 6187 va_end(ap); |
6188 | |
8660 | 6189 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6190 |
4230 | 6191 for (i=0; i<numtypes; i++) |
8660 | 6192 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6193 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6194 |
8660 | 6195 gaim_debug_misc(NULL, "\n"); |
4230 | 6196 |
6197 if (numtypes >= 0) | |
6198 od->rights.maxbuddies = maxitems[0]; | |
6199 if (numtypes >= 1) | |
6200 od->rights.maxgroups = maxitems[1]; | |
6201 if (numtypes >= 2) | |
6202 od->rights.maxpermits = maxitems[2]; | |
6203 if (numtypes >= 3) | |
6204 od->rights.maxdenies = maxitems[3]; | |
2991 | 6205 |
6206 return 1; | |
6207 } | |
6208 | |
6209 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6210 GaimConnection *gc = sess->aux_data; |
6211 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6212 GaimStatus *status; |
7283 | 6213 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6214 GaimGroup *g; |
6215 GaimBuddy *b; | |
2995 | 6216 struct aim_ssi_item *curitem; |
2991 | 6217 int tmp; |
4230 | 6218 va_list ap; |
8219 | 6219 fu16_t fmtver, numitems; |
6220 struct aim_ssi_item *items; | |
6221 fu32_t timestamp; | |
4230 | 6222 |
6223 va_start(ap, fr); | |
6224 fmtver = (fu16_t)va_arg(ap, int); | |
6225 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6226 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6227 timestamp = va_arg(ap, fu32_t); |
8219 | 6228 va_end(ap); |
2991 | 6229 |
8660 | 6230 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6231 "ssi: syncing local list and server list\n"); |
2991 | 6232 |
8219 | 6233 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6234 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 | 6235 return 1; |
6236 } | |
6237 | |
2991 | 6238 /* Clean the buddy list */ |
4889 | 6239 aim_ssi_cleanlist(sess); |
2991 | 6240 |
8150 | 6241 { /* If not in server list then prune from local list */ |
6242 GaimBlistNode *gnode, *cnode, *bnode; | |
6243 GaimBuddyList *blist; | |
9539 | 6244 GSList *cur, *next; |
8150 | 6245 |
6246 /* Buddies */ | |
6247 cur = NULL; | |
6248 if ((blist = gaim_get_blist()) != NULL) { | |
6249 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6250 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6251 continue; | |
6252 g = (GaimGroup *)gnode; | |
6253 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6254 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6255 continue; | |
6256 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6257 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6258 continue; | |
6259 b = (GaimBuddy *)bnode; | |
6260 if (b->account == gc->account) { | |
6261 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6262 /* If the buddy is an ICQ user then load his nickname */ | |
6263 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6264 char *alias; |
8150 | 6265 if (servernick) |
6266 serv_got_alias(gc, b->name, servernick); | |
6267 | |
6268 /* Store local alias on server */ | |
8214 | 6269 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6270 if (!alias && b->alias && strlen(b->alias)) |
6271 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6272 free(alias); | |
6273 } else { | |
8660 | 6274 gaim_debug_info("oscar", |
8150 | 6275 "ssi: removing buddy %s from local list\n", b->name); |
6276 /* We can't actually remove now because it will screw up our looping */ | |
6277 cur = g_slist_prepend(cur, b); | |
6278 } | |
6279 } | |
6280 } | |
6281 } | |
6282 } | |
6283 } | |
8175 | 6284 |
8150 | 6285 while (cur != NULL) { |
6286 b = cur->data; | |
6287 cur = g_slist_remove(cur, b); | |
6288 gaim_blist_remove_buddy(b); | |
6289 } | |
6290 | |
6291 /* Permit list */ | |
6292 if (gc->account->permit) { | |
9539 | 6293 next = gc->account->permit; |
6294 while (next != NULL) { | |
6295 cur = next; | |
6296 next = next->next; | |
8150 | 6297 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6298 gaim_debug_info("oscar", |
8150 | 6299 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6300 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6301 } | |
9539 | 6302 } |
8150 | 6303 } |
6304 | |
6305 /* Deny list */ | |
6306 if (gc->account->deny) { | |
9539 | 6307 next = gc->account->deny; |
6308 while (next != NULL) { | |
6309 cur = next; | |
6310 next = next->next; | |
8150 | 6311 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6312 gaim_debug_info("oscar", |
8150 | 6313 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6314 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6315 } | |
9539 | 6316 } |
8150 | 6317 } |
6318 /* Presence settings (idle time visibility) */ | |
6319 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6320 if (!(tmp & 0x400)) | |
6321 aim_ssi_setpresence(sess, tmp | 0x400); | |
6322 } /* end pruning buddies from local list */ | |
6323 | |
2991 | 6324 /* Add from server list to local list */ |
4230 | 6325 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6326 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6327 switch (curitem->type) { |
4230 | 6328 case 0x0000: { /* Buddy */ |
4251 | 6329 if (curitem->name) { |
4292 | 6330 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6331 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6332 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6333 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6334 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6335 /* Should gname be freed here? -- elb */ |
4754 | 6336 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6337 free(alias); |
8150 | 6338 if (b) { |
4292 | 6339 /* Get server stored alias */ |
4705 | 6340 if (alias_utf8) { |
8150 | 6341 g_free(b->alias); |
6342 b->alias = g_strdup(alias_utf8); | |
4705 | 6343 } |
4282 | 6344 } else { |
8150 | 6345 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6346 |
4754 | 6347 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6348 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6349 gaim_blist_add_group(g, NULL); |
6350 } | |
5146 | 6351 |
8660 | 6352 gaim_debug_info("oscar", |
9285 | 6353 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6354 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6355 } |
8341 | 6356 if (!aim_sncmp(curitem->name, account->username)) { |
6357 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6358 gaim_check_comment(od, comment); | |
6359 free(comment); | |
6360 } | |
7162 | 6361 g_free(gname_utf8); |
6362 g_free(alias_utf8); | |
2991 | 6363 } |
4230 | 6364 } break; |
6365 | |
6366 case 0x0001: { /* Group */ | |
4282 | 6367 /* Shouldn't add empty groups */ |
4230 | 6368 } break; |
6369 | |
6370 case 0x0002: { /* Permit buddy */ | |
2991 | 6371 if (curitem->name) { |
4230 | 6372 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6373 GSList *list; |
5575 | 6374 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6375 if (!list) { |
8660 | 6376 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6377 "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
|
6378 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6379 } |
6380 } | |
4230 | 6381 } break; |
6382 | |
6383 case 0x0003: { /* Deny buddy */ | |
2991 | 6384 if (curitem->name) { |
6385 GSList *list; | |
5575 | 6386 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6387 if (!list) { |
8660 | 6388 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6389 "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
|
6390 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6391 } |
6392 } | |
4230 | 6393 } break; |
6394 | |
6395 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6396 if (curitem->data) { |
6397 fu8_t permdeny; | |
5575 | 6398 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6399 gaim_debug_info("oscar", |
5575 | 6400 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6401 account->perm_deny = permdeny; | |
6402 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6403 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6404 } |
2991 | 6405 } |
6406 } | |
4230 | 6407 } break; |
6408 | |
6409 case 0x0005: { /* Presence setting */ | |
3109 | 6410 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6411 } break; |
2991 | 6412 } /* End of switch on curitem->type */ |
6413 } /* End of for loop */ | |
4230 | 6414 |
9991 | 6415 /* |
6416 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6417 * this. We probably want the SSI status setting to override the local | |
6418 * setting. | |
6419 */ | |
9982 | 6420 status = gaim_presence_get_active_status(account->presence); |
6421 if (gaim_status_is_available(status)) | |
4901 | 6422 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6423 | |
4342 | 6424 /* Activate SSI */ |
6425 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6426 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6427 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6428 "ssi: activating server-stored buddy list\n"); |
4642 | 6429 aim_ssi_enable(sess); |
4342 | 6430 |
2991 | 6431 return 1; |
2086 | 6432 } |
4230 | 6433 |
6434 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6435 GaimConnection *gc = sess->aux_data; |
4230 | 6436 va_list ap; |
6437 struct aim_ssi_tmp *retval; | |
6438 | |
6439 va_start(ap, fr); | |
6440 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6441 va_end(ap); | |
6442 | |
6443 while (retval) { | |
8660 | 6444 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6445 "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 | 6446 |
6447 if (retval->ack != 0xffff) | |
6448 switch (retval->ack) { | |
6449 case 0x0000: { /* added successfully */ | |
6450 } break; | |
6451 | |
4829 | 6452 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6453 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6454 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 | 6455 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6456 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6457 g_free(buf); |
6458 } | |
6459 | |
7023 | 6460 case 0x000e: { /* buddy requires authorization */ |
4828 | 6461 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6462 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6463 } break; |
6464 | |
6465 default: { /* La la la */ | |
5197 | 6466 gchar *buf; |
8660 | 6467 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
|
6468 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 | 6469 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6470 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6471 g_free(buf); |
4230 | 6472 } break; |
6473 } | |
6474 | |
6475 retval = retval->next; | |
6476 } | |
6477 | |
6478 return 1; | |
6479 } | |
6480 | |
8227 | 6481 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6482 GaimConnection *gc = sess->aux_data; | |
6483 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6484 GaimBuddy *b; | |
6485 GaimGroup *g; | |
6486 va_list ap; | |
6487 fu16_t type; | |
6488 const char *name; | |
6489 | |
6490 va_start(ap, fr); | |
6491 type = (fu16_t)va_arg(ap, int); | |
6492 name = va_arg(ap, char *); | |
6493 va_end(ap); | |
6494 | |
6495 if ((type != 0x0000) || (name == NULL)) | |
6496 return 1; | |
6497 | |
6498 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6499 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6500 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6501 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6502 b = gaim_find_buddy(gc->account, name); | |
6503 free(alias); | |
6504 | |
6505 if (b) { | |
6506 /* Get server stored alias */ | |
6507 if (alias_utf8) { | |
6508 g_free(b->alias); | |
6509 b->alias = g_strdup(alias_utf8); | |
6510 } | |
6511 } else { | |
6512 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6513 | |
6514 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6515 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6516 gaim_blist_add_group(g, NULL); | |
6517 } | |
6518 | |
8660 | 6519 gaim_debug_info("oscar", |
9285 | 6520 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6521 gaim_blist_add_buddy(b, NULL, g, NULL); |
6522 } | |
6523 g_free(gname_utf8); | |
6524 g_free(alias_utf8); | |
6525 | |
6526 return 1; | |
6527 } | |
6528 | |
4230 | 6529 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6530 GaimConnection *gc = sess->aux_data; |
4230 | 6531 va_list ap; |
6532 char *sn, *msg; | |
4236 | 6533 gchar *dialog_msg, *nombre; |
4230 | 6534 struct name_data *data; |
6695 | 6535 GaimBuddy *buddy; |
4230 | 6536 |
6537 va_start(ap, fr); | |
6538 sn = va_arg(ap, char *); | |
6539 msg = va_arg(ap, char *); | |
6540 va_end(ap); | |
6541 | |
8660 | 6542 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6543 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6544 |
4687 | 6545 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6546 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6547 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6548 else |
6549 nombre = g_strdup(sn); | |
6550 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6551 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 | 6552 data = g_new(struct name_data, 1); |
6553 data->gc = gc; | |
6554 data->name = g_strdup(sn); | |
6555 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6556 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6557 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6558 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6559 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6560 G_CALLBACK(oscar_free_name_data)); |
4236 | 6561 |
4230 | 6562 g_free(dialog_msg); |
4236 | 6563 g_free(nombre); |
4230 | 6564 |
6565 return 1; | |
6566 } | |
6567 | |
6568 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6569 GaimConnection *gc = sess->aux_data; |
4230 | 6570 va_list ap; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6571 char *sn; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6572 char *msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6573 GaimAccount *account = gaim_connection_get_account(gc); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6574 gchar *nombre; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6575 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6576 gchar *dialog_msg; |
4230 | 6577 struct name_data *data; |
6695 | 6578 GaimBuddy *buddy; |
4230 | 6579 |
6580 va_start(ap, fr); | |
6581 sn = va_arg(ap, char *); | |
6582 msg = va_arg(ap, char *); | |
6583 va_end(ap); | |
6584 | |
8660 | 6585 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6586 "ssi: received authorization request from %s\n", sn); |
4230 | 6587 |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6588 buddy = gaim_find_buddy(account, sn); |
9620 | 6589 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6590 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6591 else |
6592 nombre = g_strdup(sn); | |
6593 | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6594 if (msg != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6595 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
|
6596 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6597 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6598 |
10949 | 6599 dialog_msg = g_strdup_printf( |
6600 _("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
|
6601 nombre, gaim_account_get_username(account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
6602 g_free(reason); |
10949 | 6603 |
4230 | 6604 data = g_new(struct name_data, 1); |
6605 data->gc = gc; | |
6606 data->name = g_strdup(sn); | |
6607 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6608 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6609 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6610 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6611 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6612 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6613 |
4230 | 6614 g_free(dialog_msg); |
4236 | 6615 g_free(nombre); |
4230 | 6616 |
6617 return 1; | |
6618 } | |
6619 | |
6620 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6621 GaimConnection *gc = sess->aux_data; |
4230 | 6622 va_list ap; |
6623 char *sn, *msg; | |
4236 | 6624 gchar *dialog_msg, *nombre; |
4230 | 6625 fu8_t reply; |
6695 | 6626 GaimBuddy *buddy; |
4230 | 6627 |
6628 va_start(ap, fr); | |
6629 sn = va_arg(ap, char *); | |
6630 reply = (fu8_t)va_arg(ap, int); | |
6631 msg = va_arg(ap, char *); | |
6632 va_end(ap); | |
6633 | |
8660 | 6634 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6635 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6636 |
4687 | 6637 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6638 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6639 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6640 else |
6641 nombre = g_strdup(sn); | |
6642 | |
4230 | 6643 if (reply) { |
6644 /* Granted */ | |
7023 | 6645 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
|
6646 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6647 } else { |
6648 /* Denied */ | |
7023 | 6649 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
|
6650 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6651 } |
6652 g_free(dialog_msg); | |
4236 | 6653 g_free(nombre); |
4230 | 6654 |
6655 return 1; | |
6656 } | |
6657 | |
6658 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6659 GaimConnection *gc = sess->aux_data; |
4230 | 6660 va_list ap; |
6661 char *sn; | |
6695 | 6662 GaimBuddy *buddy; |
4230 | 6663 |
6664 va_start(ap, fr); | |
6665 sn = va_arg(ap, char *); | |
6666 va_end(ap); | |
6667 | |
4687 | 6668 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6669 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6670 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6671 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6672 |
6673 return 1; | |
6674 } | |
2086 | 6675 |
5575 | 6676 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6677 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6678 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6679 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6680 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6681 pce->label = _("_Room:"); |
5234 | 6682 pce->identifier = "room"; |
10475 | 6683 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6684 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6685 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6686 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6687 pce->label = _("_Exchange:"); |
5234 | 6688 pce->identifier = "exchange"; |
10475 | 6689 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6690 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6691 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6692 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6693 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6694 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6695 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6696 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6697 |
9754 | 6698 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6699 { | |
6700 GHashTable *defaults; | |
6701 | |
6702 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6703 | |
6704 if (chat_name != NULL) | |
6705 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6706 | |
6707 return defaults; | |
6708 } | |
6709 | |
9917 | 6710 static char *oscar_get_chat_name(GHashTable *data) { |
6711 return g_strdup(g_hash_table_lookup(data, "room")); | |
6712 } | |
6713 | |
8308 | 6714 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6715 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6716 aim_conn_t *cur; |
5234 | 6717 char *name, *exchange; |
6718 | |
6719 name = g_hash_table_lookup(data, "room"); | |
6720 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6721 |
8660 | 6722 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6723 "Attempting to join chat room %s.\n", name); |
8308 | 6724 |
6725 if ((name == NULL) || (*name == '\0')) { | |
6726 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6727 return; | |
6728 } | |
6729 | |
4617 | 6730 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6731 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6732 "chatnav exists, creating room\n"); |
5234 | 6733 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6734 } else { |
6735 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6736 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6737 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6738 "chatnav does not exist, opening chatnav\n"); |
5234 | 6739 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6740 cr->name = g_strdup(name); |
4617 | 6741 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6742 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6743 } |
6744 } | |
6745 | |
8308 | 6746 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6747 OscarData *od = (OscarData *)gc->proto_data; | |
6748 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6749 |
6750 if (ccon == NULL) | |
2086 | 6751 return; |
10404 | 6752 |
8225 | 6753 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6754 ccon->exchange, ccon->name, 0x0); |
6755 } | |
6756 | |
10458 | 6757 static void |
6758 oscar_chat_leave(GaimConnection *gc, int id) | |
6759 { | |
6760 GaimConversation *conv; | |
6761 struct chat_connection *cc; | |
6762 | |
6763 conv = gaim_find_chat(gc, id); | |
6764 | |
6765 g_return_if_fail(conv != NULL); | |
6766 | |
6767 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6768 | |
6769 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6770 oscar_chat_kill(gc, cc); | |
2086 | 6771 } |
6772 | |
8219 | 6773 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6774 OscarData *od = (OscarData *)gc->proto_data; | |
6775 GaimConversation *conv = NULL; | |
2086 | 6776 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6777 char *buf, *buf2; |
9830 | 6778 fu16_t charset, charsubset; |
9807 | 6779 char *charsetstr = NULL; |
10111 | 6780 int len; |
8219 | 6781 |
6782 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6783 return -EINVAL; |
2086 | 6784 |
8219 | 6785 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6786 return -EINVAL; |
2086 | 6787 |
8219 | 6788 buf = gaim_strdup_withhtml(message); |
6789 len = strlen(buf); | |
6790 | |
8962 | 6791 if (strstr(buf, "<IMG ")) |
6792 gaim_conversation_write(conv, "", | |
6793 _("Your IM Image was not sent. " | |
6794 "You cannot send IM Images in AIM chats."), | |
6795 GAIM_MESSAGE_ERROR, time(NULL)); | |
6796 | |
9830 | 6797 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6798 if ((len > c->maxlen) || (len > c->maxvis)) { |
6799 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6800 return -E2BIG; |
8359 | 6801 } |
6802 | |
9831 | 6803 if (charset == AIM_CHARSET_ASCII) |
6804 charsetstr = "us-ascii"; | |
6805 else if (charset == AIM_CHARSET_UNICODE) | |
6806 charsetstr = "unicode-2-0"; | |
6807 else if (charset == AIM_CHARSET_CUSTOM) | |
6808 charsetstr = "iso-8859-1"; | |
9807 | 6809 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6810 g_free(buf2); |
8359 | 6811 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6812 return 0; |
2086 | 6813 } |
6814 | |
10042 | 6815 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6816 { | |
4766 | 6817 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6818 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6819 return "icq"; |
6820 else | |
6821 return "aim"; | |
6822 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6823 |
9975 | 6824 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6825 return "icq"; |
6826 return "aim"; | |
6827 } | |
6828 | |
9972 | 6829 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6830 { |
7334 | 6831 GaimConnection *gc = NULL; |
6832 OscarData *od = NULL; | |
10042 | 6833 GaimAccount *account = NULL; |
6834 GaimPresence *presence; | |
6835 GaimStatus *status; | |
6836 const char *status_id; | |
4687 | 6837 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6838 int i = 0; | |
7334 | 6839 aim_userinfo_t *userinfo = NULL; |
6840 | |
6841 if (b != NULL) | |
6842 account = b->account; | |
6843 if (account != NULL) | |
6844 gc = account->gc; | |
6845 if (gc != NULL) | |
6846 od = gc->proto_data; | |
7945 | 6847 if (od != NULL) |
6848 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6849 |
10042 | 6850 presence = gaim_buddy_get_presence(b); |
6851 status = gaim_presence_get_active_status(presence); | |
6852 status_id = gaim_status_get_id(status); | |
6853 | |
6854 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6855 char *gname; |
7334 | 6856 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6857 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6858 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6859 emblems[i++] = "notauthorized"; | |
6860 } else { | |
6861 emblems[i++] = "offline"; | |
6862 } | |
6863 } | |
4916 | 6864 |
10042 | 6865 if (b->name && aim_sn_is_icq(b->name)) { |
6866 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6867 emblems[i++] = "invisible"; | |
6868 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6869 emblems[i++] = "freeforchat"; |
10042 | 6870 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6871 emblems[i++] = "dnd"; |
10042 | 6872 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6873 emblems[i++] = "na"; |
10042 | 6874 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6875 emblems[i++] = "occupied"; |
10042 | 6876 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6877 emblems[i++] = "away"; |
10042 | 6878 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6879 emblems[i++] = "away"; | |
6880 } | |
6881 | |
6882 if (userinfo != NULL ) { | |
6883 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6884 emblems[i++] = "unconfirmed"; */ | |
6885 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6886 emblems[i++] = "admin"; | |
6887 if (userinfo->flags & AIM_FLAG_AOL) | |
6888 emblems[i++] = "aol"; | |
6889 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6890 emblems[i++] = "wireless"; | |
6891 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6892 emblems[i++] = "activebuddy"; | |
6893 | |
6894 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6895 emblems[i++] = "hiptop"; |
6896 | |
10042 | 6897 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6898 emblems[i++] = "secure"; |
10042 | 6899 } |
7334 | 6900 |
4687 | 6901 *se = emblems[0]; |
6902 *sw = emblems[1]; | |
6903 *nw = emblems[2]; | |
6904 *ne = emblems[3]; | |
6905 } | |
6906 | |
6695 | 6907 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6908 GaimConnection *gc = b->account->gc; |
7283 | 6909 OscarData *od = gc->proto_data; |
7045 | 6910 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6911 GString *str = g_string_new(""); |
5131 | 6912 |
6913 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6914 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6915 |
6916 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6917 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6918 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6919 g_free(charset); |
7011 | 6920 if (away_utf8 != NULL) { |
7091 | 6921 gchar *tmp1, *tmp2; |
9627 | 6922 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6923 g_free(away_utf8); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
6924 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 6925 g_free(tmp2); |
8700 | 6926 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6927 g_free(tmp1); |
8701 | 6928 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6929 g_free(tmp2); |
5836 | 6930 } |
5131 | 6931 } |
8701 | 6932 } |
6933 | |
6934 return g_string_free(str, FALSE); | |
5131 | 6935 } |
6936 | |
10042 | 6937 static char *oscar_status_text(GaimBuddy *b) |
6938 { | |
6939 GaimConnection *gc; | |
6940 OscarData *od; | |
11248 | 6941 GaimPresence *presence; |
5167 | 6942 gchar *ret = NULL; |
6943 | |
10042 | 6944 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6945 od = gc->proto_data; | |
11248 | 6946 presence = gaim_buddy_get_presence(b); |
6947 | |
6948 if (!gaim_presence_is_online(presence)) | |
6949 { | |
5167 | 6950 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6951 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6952 ret = g_strdup(_("Not Authorized")); | |
6953 else | |
6954 ret = g_strdup(_("Offline")); | |
6955 } | |
11248 | 6956 else if (gaim_presence_is_available(presence)) |
6957 { | |
6958 struct buddyinfo *bi; | |
6959 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); | |
6960 if ((bi != NULL) && (bi->availmsg != NULL)) | |
6961 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
6962 } | |
6963 else | |
6964 { | |
6965 if (aim_sn_is_icq(b->name)) | |
6966 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
6967 else | |
6968 ret = g_strdup(_("Away")); | |
6969 } | |
5167 | 6970 |
6971 return ret; | |
6972 } | |
6973 | |
5842 | 6974 |
5844 | 6975 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6976 GaimConnection *gc = sess->aux_data; |
7283 | 6977 OscarData *od = gc->proto_data; |
5892 | 6978 va_list ap; |
5842 | 6979 fu16_t type; |
5892 | 6980 fu8_t flags = 0, length = 0; |
11159 | 6981 guchar *md5 = NULL; |
5892 | 6982 |
7334 | 6983 |
5842 | 6984 va_start(ap, fr); |
6985 type = va_arg(ap, int); | |
5892 | 6986 |
6987 switch(type) { | |
6988 case 0x0000: | |
6989 case 0x0001: { | |
6990 flags = va_arg(ap, int); | |
6991 length = va_arg(ap, int); | |
11159 | 6992 md5 = va_arg(ap, guchar *); |
5892 | 6993 |
6994 if (flags == 0x41) { | |
6995 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6996 od->iconconnecting = TRUE; | |
6997 od->set_icon = TRUE; | |
6998 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6999 } else { | |
6039 | 7000 struct stat st; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7001 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
6039 | 7002 if (iconfile == NULL) { |
8363 | 7003 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7004 } else if (!g_stat(iconfile, &st)) { |
11159 | 7005 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7006 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 7007 if (file) { |
9532 | 7008 /* XXX - Use g_file_get_contents()? */ |
6039 | 7009 fread(buf, 1, st.st_size, file); |
7010 fclose(file); | |
8660 | 7011 gaim_debug_info("oscar", |
10042 | 7012 "Uploading icon to icon server\n"); |
6879 | 7013 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 7014 } else |
8660 | 7015 gaim_debug_error("oscar", |
10042 | 7016 "Can't open buddy icon file!\n"); |
6039 | 7017 g_free(buf); |
7018 } else { | |
8660 | 7019 gaim_debug_error("oscar", |
10042 | 7020 "Can't stat buddy icon file!\n"); |
5892 | 7021 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7022 g_free(iconfile); |
5892 | 7023 } |
8363 | 7024 } else if (flags == 0x81) { |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7025 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
8363 | 7026 if (iconfile == NULL) |
7027 aim_ssi_delicon(od->sess); | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7028 else { |
8363 | 7029 aim_ssi_seticon(od->sess, md5, length); |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7030 g_free(iconfile); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7031 } |
8363 | 7032 } |
5892 | 7033 } break; |
7034 | |
7035 case 0x0002: { /* We just set an "available" message? */ | |
7036 } break; | |
7037 } | |
7038 | |
5842 | 7039 va_end(ap); |
5844 | 7040 |
7041 return 0; | |
5842 | 7042 } |
5892 | 7043 |
5575 | 7044 static void oscar_set_permit_deny(GaimConnection *gc) { |
7045 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 7046 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 7047 |
8175 | 7048 if (od->sess->ssi.received_data) { |
7049 switch (account->perm_deny) { | |
7050 case GAIM_PRIVACY_ALLOW_ALL: | |
7051 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
7052 break; | |
7053 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
7054 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
7055 break; | |
7056 case GAIM_PRIVACY_ALLOW_USERS: | |
7057 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
7058 break; | |
7059 case GAIM_PRIVACY_DENY_ALL: | |
7060 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
7061 break; | |
7062 case GAIM_PRIVACY_DENY_USERS: | |
7063 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
7064 break; | |
7065 default: | |
7066 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
7067 break; | |
7068 } | |
7069 } | |
2086 | 7070 } |
7071 | |
5575 | 7072 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 7073 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7074 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 7075 if (od->sess->ssi.received_data) |
4889 | 7076 aim_ssi_addpermit(od->sess, who); |
2086 | 7077 } |
7078 | |
5575 | 7079 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 7080 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7081 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 7082 if (od->sess->ssi.received_data) |
4889 | 7083 aim_ssi_adddeny(od->sess, who); |
2086 | 7084 } |
7085 | |
5575 | 7086 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 7087 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7088 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 7089 if (od->sess->ssi.received_data) |
4889 | 7090 aim_ssi_delpermit(od->sess, who); |
2086 | 7091 } |
7092 | |
5575 | 7093 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 7094 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7095 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 7096 if (od->sess->ssi.received_data) |
4889 | 7097 aim_ssi_deldeny(od->sess, who); |
2086 | 7098 } |
7099 | |
9975 | 7100 static GList * |
7101 oscar_status_types(GaimAccount *account) | |
2086 | 7102 { |
9975 | 7103 GList *status_types = NULL; |
7104 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
7105 |
9973 | 7106 g_return_val_if_fail(account != NULL, NULL); |
7107 | |
10042 | 7108 /* Oscar-common status types */ |
9991 | 7109 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
7110 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 7111 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 7112 status_types = g_list_append(status_types, type); |
7113 | |
9991 | 7114 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
7115 OSCAR_STATUS_ID_ONLINE, | |
10400 | 7116 _("Online"), FALSE, TRUE, FALSE); |
9976 | 7117 status_types = g_list_append(status_types, type); |
7118 | |
10198 | 7119 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
7120 OSCAR_STATUS_ID_AVAILABLE, | |
7121 _("Available"), TRUE, TRUE, FALSE, | |
7122 "message", _("Message"), | |
7123 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 7124 status_types = g_list_append(status_types, type); |
7125 | |
10195 | 7126 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
7127 OSCAR_STATUS_ID_AWAY, | |
7128 _("Away"), TRUE, TRUE, FALSE, | |
7129 "message", _("Message"), | |
7130 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 7131 status_types = g_list_append(status_types, type); |
7132 | |
7133 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
7134 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 7135 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 7136 status_types = g_list_append(status_types, type); |
7137 | |
7138 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
7139 return status_types; | |
7140 | |
7141 /* ICQ-specific status types */ | |
7142 | |
9991 | 7143 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
7144 OSCAR_STATUS_ID_FREE4CHAT, | |
7145 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 7146 status_types = g_list_append(status_types, type); |
7147 | |
9991 | 7148 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
7149 OSCAR_STATUS_ID_OCCUPIED, | |
7150 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 7151 status_types = g_list_append(status_types, type); |
7152 | |
9991 | 7153 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7154 OSCAR_STATUS_ID_DND, | |
7155 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 7156 status_types = g_list_append(status_types, type); |
7157 | |
9991 | 7158 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7159 OSCAR_STATUS_ID_NA, | |
7160 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 7161 status_types = g_list_append(status_types, type); |
9975 | 7162 |
7163 return status_types; | |
4333 | 7164 } |
7165 | |
7172 | 7166 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 7167 GaimConnection *gc = data->gc; |
7168 OscarData *od = gc->proto_data; | |
7172 | 7169 GaimBuddy *b; |
7170 GaimGroup *g; | |
7171 | |
7172 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
7173 oscar_free_name_data(data); | |
7174 return; | |
7175 } | |
7176 | |
7177 if (!(g = gaim_find_buddys_group(b))) { | |
7178 oscar_free_name_data(data); | |
7179 return; | |
7180 } | |
7181 | |
7182 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 7183 |
7184 if (!aim_sncmp(data->name, gc->account->username)) | |
7185 gaim_check_comment(od, text); | |
7186 | |
7172 | 7187 oscar_free_name_data(data); |
7188 } | |
7189 | |
9030 | 7190 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
7191 | |
7192 GaimBuddy *buddy; | |
7193 GaimConnection *gc; | |
7194 OscarData *od; | |
7195 struct name_data *data; | |
7172 | 7196 GaimGroup *g; |
7197 char *comment; | |
7198 gchar *comment_utf8; | |
9631 | 7199 gchar *title; |
7172 | 7200 |
9030 | 7201 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
7202 | |
7203 buddy = (GaimBuddy *) node; | |
7204 gc = gaim_account_get_connection(buddy->account); | |
7205 od = gc->proto_data; | |
7206 | |
7207 data = g_new(struct name_data, 1); | |
7208 | |
7209 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 7210 return; |
9030 | 7211 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 7212 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
7213 | |
7214 data->gc = gc; | |
9030 | 7215 data->name = g_strdup(buddy->name); |
7172 | 7216 data->nick = NULL; |
7217 | |
9631 | 7218 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7219 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7220 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7221 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7222 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7223 data); | |
9631 | 7224 g_free(title); |
7172 | 7225 |
7226 free(comment); | |
7227 g_free(comment_utf8); | |
7228 } | |
7229 | |
9030 | 7230 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7231 | |
7232 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7233 OscarData *od = gc->proto_data; |
9030 | 7234 |
4333 | 7235 GList *m = NULL; |
9030 | 7236 GaimBlistNodeAction *act; |
7237 | |
7238 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7239 oscar_buddycb_edit_comment, NULL, NULL); |
9030 | 7240 m = g_list_append(m, act); |
7172 | 7241 |
4333 | 7242 if (od->icq) { |
4624 | 7243 #if 0 |
9030 | 7244 act = gaim_blist_node_action_new(_("Get Status Msg"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7245 oscar_get_icqstatusmsg, NULL, NULL); |
9030 | 7246 m = g_list_append(m, act); |
4624 | 7247 #endif |
4333 | 7248 } else { |
7011 | 7249 aim_userinfo_t *userinfo; |
9030 | 7250 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7251 | |
7252 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7253 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7254 | |
7011 | 7255 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7256 act = gaim_blist_node_action_new(_("Direct IM"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7257 oscar_ask_direct_im, NULL, NULL); |
9030 | 7258 m = g_list_append(m, act); |
5917 | 7259 } |
9466 | 7260 #if 0 |
7011 | 7261 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7262 act = gaim_blist_node_action_new(_("Get File"), |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7263 oscar_ask_getfile, NULL, NULL); |
9030 | 7264 m = g_list_append(m, act); |
5917 | 7265 } |
4826 | 7266 #endif |
4333 | 7267 } |
5131 | 7268 } |
5197 | 7269 |
5131 | 7270 if (od->sess->ssi.received_data) { |
9030 | 7271 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7272 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7273 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10654
diff
changeset
|
7274 gaim_auth_sendrequest_menu, NULL, NULL); |
9030 | 7275 m = g_list_append(m, act); |
4333 | 7276 } |
4916 | 7277 } |
10157 | 7278 |
4333 | 7279 return m; |
7280 } | |
7281 | |
9030 | 7282 |
7283 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7284 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7285 return oscar_buddy_menu((GaimBuddy *) node); | |
7286 } else { | |
7287 return NULL; | |
7288 } | |
7289 } | |
7290 | |
10570 | 7291 static void |
7292 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
7293 { | |
7294 OscarData *od = gc->proto_data; | |
7295 GaimAccount *account = gaim_connection_get_account(gc); | |
7296 GaimRequestField *f; | |
7297 gboolean auth, hide_ip, web_aware; | |
7298 | |
7299 f = gaim_request_fields_get_field(fields, "authorization"); | |
7300 auth = gaim_request_field_bool_get_value(f); | |
7301 | |
7302 f = gaim_request_fields_get_field(fields, "hide_ip"); | |
7303 hide_ip = gaim_request_field_bool_get_value(f); | |
7304 | |
7305 f = gaim_request_fields_get_field(fields, "web_aware"); | |
7306 web_aware = gaim_request_field_bool_get_value(f); | |
7307 | |
7308 gaim_account_set_bool(account, "authorization", auth); | |
7309 gaim_account_set_bool(account, "hide_ip", hide_ip); | |
7310 gaim_account_set_bool(account, "web_aware", web_aware); | |
7311 | |
7312 aim_icq_setsecurity(od->sess, auth, web_aware, hide_ip); | |
7313 } | |
7314 | |
7315 static void | |
7316 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
7317 { | |
7318 GaimConnection *gc = (GaimConnection *) action->context; | |
7319 GaimAccount *account = gaim_connection_get_account(gc); | |
7320 GaimRequestFields *fields; | |
7321 GaimRequestFieldGroup *g; | |
7322 GaimRequestField *f; | |
7323 gboolean auth, hide_ip, web_aware; | |
7324 | |
7325 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
7326 hide_ip = gaim_account_get_bool(account, "hide_ip", OSCAR_DEFAULT_HIDE_IP); | |
7327 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
7328 | |
7329 fields = gaim_request_fields_new(); | |
7330 | |
7331 g = gaim_request_field_group_new(NULL); | |
7332 | |
7333 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
7334 gaim_request_field_group_add_field(g, f); | |
7335 | |
7336 f = gaim_request_field_bool_new("hide_ip", _("Hide IP address"), hide_ip); | |
7337 gaim_request_field_group_add_field(g, f); | |
7338 | |
7339 f = gaim_request_field_bool_new("web_aware", _("Web aware"), web_aware); | |
7340 gaim_request_field_group_add_field(g, f); | |
7341 | |
7342 gaim_request_fields_add_group(fields, g); | |
7343 | |
7344 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
7345 NULL, fields, | |
7346 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
7347 _("Cancel"), NULL, gc); | |
7348 } | |
9030 | 7349 |
5575 | 7350 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7351 OscarData *od = gc->proto_data; |
5575 | 7352 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7353 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7354 od->setnick = TRUE; | |
7355 od->newsn = g_strdup(nick); | |
7356 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7357 } else { | |
7358 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7359 } | |
7360 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7361 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7362 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7363 } |
7364 } | |
7365 | |
9015 | 7366 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7367 { |
9015 | 7368 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7369 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7370 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7371 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7372 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7373 gc); |
4333 | 7374 } |
7375 | |
9015 | 7376 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7377 { |
9015 | 7378 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7379 OscarData *od = gc->proto_data; |
4333 | 7380 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7381 | |
7382 if (conn) { | |
7383 aim_admin_reqconfirm(od->sess, conn); | |
7384 } else { | |
7385 od->conf = TRUE; | |
7386 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7387 } | |
7388 } | |
7389 | |
9015 | 7390 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7391 { |
9015 | 7392 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7393 OscarData *od = gc->proto_data; |
4333 | 7394 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7395 | |
7396 if (conn) { | |
7397 aim_admin_getinfo(od->sess, conn, 0x11); | |
7398 } else { | |
7399 od->reqemail = TRUE; | |
7400 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7401 } | |
7402 } | |
7403 | |
5575 | 7404 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7405 { |
7283 | 7406 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7407 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
|
7408 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7409 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7410 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7411 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7412 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7413 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7414 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7415 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7416 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7417 |
9015 | 7418 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7419 { |
9015 | 7420 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7421 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7422 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7423 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7424 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7425 gc); |
4333 | 7426 } |
7427 | |
9015 | 7428 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7429 { |
9015 | 7430 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7431 OscarData *od = gc->proto_data; |
4333 | 7432 gchar *nombre, *text, *tmp; |
6695 | 7433 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7434 int num=0; |
7435 | |
6873 | 7436 text = g_strdup(""); |
4333 | 7437 |
4785 | 7438 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7439 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7440 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7441 continue; | |
6695 | 7442 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7443 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7444 continue; |
6695 | 7445 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7446 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7447 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7448 continue; | |
7449 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7450 if (gaim_buddy_get_alias_only(buddy)) |
7451 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7452 else |
7453 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7454 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7455 g_free(text); |
7456 text = tmp; | |
7457 g_free(nombre); | |
7458 num++; | |
7459 } | |
4333 | 7460 } |
2979 | 7461 } |
4333 | 7462 } |
7463 | |
7464 if (!num) { | |
7465 g_free(text); | |
6873 | 7466 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7467 } | |
7468 | |
7469 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7470 "the following buddies"), _("You can re-request " | |
7471 "authorization from these buddies by " | |
7472 "right-clicking on them and selecting " | |
7473 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7474 g_free(text); |
2979 | 7475 } |
7476 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7477 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7478 { |
8950 | 7479 OscarData *od = (OscarData *)gc->proto_data; |
7480 | |
7481 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7482 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7483 |
9015 | 7484 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7485 { |
9015 | 7486 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7487 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7488 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7489 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7490 "searching for."), |
8697 | 7491 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7492 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7493 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7494 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7495 |
9015 | 7496 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7497 { |
9015 | 7498 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7499 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7500 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7501 |
9015 | 7502 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7503 { |
9015 | 7504 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7505 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7506 } |
7507 | |
9015 | 7508 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7509 { |
9015 | 7510 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7511 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7512 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7513 |
9015 | 7514 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7515 { |
9015 | 7516 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7517 OscarData *od = gc->proto_data; |
5575 | 7518 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
|
7519 gaim_notify_uri(gc, substituted); |
5517 | 7520 g_free(substituted); |
4333 | 7521 } |
7522 | |
9015 | 7523 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7524 { |
9015 | 7525 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7526 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7527 } |
7528 | |
5842 | 7529 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7530 { | |
7283 | 7531 OscarData *od = gc->proto_data; |
5844 | 7532 aim_session_t *sess = od->sess; |
5842 | 7533 FILE *file; |
7534 struct stat st; | |
5844 | 7535 |
6039 | 7536 if (iconfile == NULL) { |
8363 | 7537 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7538 } else if (!g_stat(iconfile, &st)) { |
11159 | 7539 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7540 file = g_fopen(iconfile, "rb"); |
5842 | 7541 if (file) { |
6052 | 7542 md5_state_t *state; |
11159 | 7543 guchar md5[16]; |
9532 | 7544 /* XXX - Use g_file_get_contents()? */ |
5842 | 7545 int len = fread(buf, 1, st.st_size, file); |
6039 | 7546 fclose(file); |
6052 | 7547 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7548 md5_init(state); |
7549 md5_append(state, buf, len); | |
7550 md5_finish(state, md5); | |
7551 g_free(state); | |
7552 aim_ssi_seticon(sess, md5, 16); | |
7553 } else | |
8660 | 7554 gaim_debug_error("oscar", |
5842 | 7555 "Can't open buddy icon file!\n"); |
7556 g_free(buf); | |
7557 } else | |
8660 | 7558 gaim_debug_error("oscar", |
5842 | 7559 "Can't stat buddy icon file!\n"); |
7560 } | |
7561 | |
7562 | |
9015 | 7563 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7564 { |
9015 | 7565 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7566 OscarData *od = gc->proto_data; |
4333 | 7567 GList *m = NULL; |
9015 | 7568 GaimPluginAction *act; |
7569 | |
7570 act = gaim_plugin_action_new(_("Set User Info..."), | |
7571 oscar_show_set_info); | |
7572 m = g_list_append(m, act); | |
4333 | 7573 |
10570 | 7574 if (od->icq) |
7575 { | |
9015 | 7576 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7577 oscar_show_set_info_icqurl); | |
7578 m = g_list_append(m, act); | |
8576 | 7579 } |
7580 | |
9015 | 7581 act = gaim_plugin_action_new(_("Change Password..."), |
7582 oscar_change_pass); | |
7583 m = g_list_append(m, act); | |
4617 | 7584 |
10570 | 7585 if (od->sess->authinfo->chpassurl != NULL) |
7586 { | |
9015 | 7587 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7588 oscar_show_chpassurl); | |
7589 m = g_list_append(m, act); | |
7590 | |
7591 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7592 oscar_show_imforwardingurl); | |
7593 m = g_list_append(m, act); | |
7026 | 7594 } |
7595 | |
10570 | 7596 m = g_list_append(m, NULL); |
7597 | |
7598 if (od->icq) | |
7599 { | |
7600 /* ICQ actions */ | |
7601 act = gaim_plugin_action_new(_("Show privacy options..."), | |
7602 oscar_show_icq_privacy_opts); | |
7603 m = g_list_append(m, act); | |
7604 } | |
7605 else | |
7606 { | |
4617 | 7607 /* AIM actions */ |
9015 | 7608 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7609 oscar_show_format_screenname); | |
7610 m = g_list_append(m, act); | |
7611 | |
7612 act = gaim_plugin_action_new(_("Confirm Account"), | |
7613 oscar_confirm_account); | |
7614 m = g_list_append(m, act); | |
7615 | |
7616 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7617 oscar_show_email); | |
7618 m = g_list_append(m, act); | |
7619 | |
7620 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7621 oscar_show_change_email); | |
7622 m = g_list_append(m, act); | |
2086 | 7623 } |
4333 | 7624 |
7625 m = g_list_append(m, NULL); | |
7626 | |
9015 | 7627 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7628 oscar_show_awaitingauth); | |
7629 m = g_list_append(m, act); | |
4333 | 7630 |
2086 | 7631 m = g_list_append(m, NULL); |
4333 | 7632 |
9015 | 7633 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7634 oscar_show_find_email); | |
7635 m = g_list_append(m, act); | |
4333 | 7636 |
8591 | 7637 #if 0 |
9015 | 7638 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7639 show_find_info); | |
7640 m = g_list_append(m, act); | |
8591 | 7641 #endif |
2086 | 7642 |
7643 return m; | |
7644 } | |
7645 | |
5575 | 7646 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7647 { |
7283 | 7648 OscarData *od = gc->proto_data; |
4617 | 7649 |
7650 if (od->icq) { | |
7651 aim_icq_changepasswd(od->sess, new); | |
2086 | 7652 } else { |
4617 | 7653 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7654 if (conn) { | |
7655 aim_admin_changepasswd(od->sess, conn, new, old); | |
7656 } else { | |
7657 od->chpass = TRUE; | |
7658 od->oldp = g_strdup(old); | |
7659 od->newp = g_strdup(new); | |
7660 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7661 } | |
2086 | 7662 } |
7663 } | |
7664 | |
6059 | 7665 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7666 { |
7283 | 7667 OscarData *od = gc->proto_data; |
8971 | 7668 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
|
7669 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7670 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7671 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7672 |
8971 | 7673 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7674 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7675 |
9935 | 7676 static void |
7677 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7678 { | |
7679 GaimConnection *gc = data; | |
7680 OscarData *od = gc->proto_data; | |
7681 aim_session_t *sess = od->sess; | |
7682 fu32_t presence; | |
7683 | |
7684 presence = aim_ssi_getpresence(sess->ssi.local); | |
7685 | |
7686 if (value) { | |
9992 | 7687 /* Based on the packet capture I thought it was the first one */ |
7688 /* Stu thinks it's the second one. */ | |
7689 /* presence |= 0x00400000; */ | |
9971 | 7690 presence &= ~0x00020000; |
9935 | 7691 aim_ssi_setpresence(sess, presence); |
7692 } else { | |
9992 | 7693 /* presence &= ~0x00400000; */ |
9971 | 7694 presence |= 0x00020000; |
9935 | 7695 aim_ssi_setpresence(sess, presence); |
7696 } | |
7697 } | |
7698 | |
10653 | 7699 #if USE_PRPL_PREFERENCES |
9935 | 7700 static GaimPluginPrefFrame * |
9936 | 7701 get_plugin_pref_frame(GaimPlugin *plugin) |
7702 { | |
9935 | 7703 GaimPluginPrefFrame *frame; |
7704 GaimPluginPref *ppref; | |
7705 | |
7706 frame = gaim_plugin_pref_frame_new(); | |
7707 | |
7708 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7709 gaim_plugin_pref_frame_add(frame, ppref); | |
7710 | |
7711 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7712 gaim_plugin_pref_frame_add(frame, ppref); | |
7713 | |
7714 return frame; | |
7715 } | |
10653 | 7716 #endif |
9935 | 7717 |
11153 | 7718 static const char * |
7719 oscar_normalize(const GaimAccount *account, const char *str) | |
7720 { | |
7721 static char buf[BUF_LEN]; | |
7722 char *tmp1, *tmp2; | |
7723 int i, j; | |
7724 | |
7725 g_return_val_if_fail(str != NULL, NULL); | |
7726 | |
7727 strncpy(buf, str, BUF_LEN); | |
7728 for (i=0, j=0; buf[j]; i++, j++) | |
7729 { | |
7730 while (buf[j] == ' ') | |
7731 j++; | |
7732 buf[i] = buf[j]; | |
7733 } | |
7734 buf[i] = '\0'; | |
7735 | |
7736 tmp1 = g_utf8_strdown(buf, -1); | |
7737 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
7738 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
7739 g_free(tmp2); | |
7740 g_free(tmp1); | |
7741 | |
7742 return buf; | |
7743 } | |
7744 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7745 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7746 { |
9308 | 7747 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7748 NULL, /* user_splits */ |
7749 NULL, /* protocol_options */ | |
10674 | 7750 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
7751 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 7752 oscar_list_icon, /* list_icon */ |
7753 oscar_list_emblems, /* list_emblems */ | |
7754 oscar_status_text, /* status_text */ | |
7755 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7756 oscar_status_types, /* status_types */ |
9475 | 7757 oscar_blist_node_menu, /* blist_node_menu */ |
7758 oscar_chat_info, /* chat_info */ | |
9754 | 7759 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7760 oscar_login, /* login */ |
7761 oscar_close, /* close */ | |
7762 oscar_send_im, /* send_im */ | |
7763 oscar_set_info, /* set_info */ | |
7764 oscar_send_typing, /* send_typing */ | |
7765 oscar_get_info, /* get_info */ | |
9973 | 7766 oscar_set_status, /* set_status */ |
9475 | 7767 oscar_set_idle, /* set_idle */ |
7768 oscar_change_passwd, /* change_passwd */ | |
7769 oscar_add_buddy, /* add_buddy */ | |
10866 | 7770 NULL, /* add_buddies */ |
9475 | 7771 oscar_remove_buddy, /* remove_buddy */ |
10866 | 7772 NULL, /* remove_buddies */ |
9475 | 7773 oscar_add_permit, /* add_permit */ |
7774 oscar_add_deny, /* add_deny */ | |
7775 oscar_rem_permit, /* rem_permit */ | |
7776 oscar_rem_deny, /* rem_deny */ | |
7777 oscar_set_permit_deny, /* set_permit_deny */ | |
7778 oscar_join_chat, /* join_chat */ | |
7779 NULL, /* reject_chat */ | |
9973 | 7780 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7781 oscar_chat_invite, /* chat_invite */ |
7782 oscar_chat_leave, /* chat_leave */ | |
7783 NULL, /* chat_whisper */ | |
7784 oscar_send_chat, /* chat_send */ | |
7785 oscar_keepalive, /* keepalive */ | |
7786 NULL, /* register_user */ | |
7787 NULL, /* get_cb_info */ | |
7788 NULL, /* get_cb_away */ | |
7789 oscar_alias_buddy, /* alias_buddy */ | |
7790 oscar_move_buddy, /* group_buddy */ | |
7791 oscar_rename_group, /* rename_group */ | |
7792 NULL, /* buddy_free */ | |
7793 oscar_convo_closed, /* convo_closed */ | |
11153 | 7794 oscar_normalize, /* normalize */ |
9475 | 7795 oscar_set_icon, /* set_buddy_icon */ |
7796 NULL, /* remove_group */ | |
7797 NULL, /* get_cb_real_name */ | |
7798 NULL, /* set_chat_topic */ | |
7799 NULL, /* find_blist_chat */ | |
7800 NULL, /* roomlist_get_list */ | |
7801 NULL, /* roomlist_cancel */ | |
7802 NULL, /* roomlist_expand_category */ | |
7803 oscar_can_receive_file, /* can_receive_file */ | |
7804 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7805 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7806 |
10653 | 7807 #if USE_PRPL_PREFERENCES |
9935 | 7808 static GaimPluginUiInfo prefs_info = { |
7809 get_plugin_pref_frame | |
7810 }; | |
10653 | 7811 #endif |
9935 | 7812 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7813 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7814 { |
9943 | 7815 GAIM_PLUGIN_MAGIC, |
7816 GAIM_MAJOR_VERSION, | |
7817 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7818 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7819 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7820 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7821 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7822 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7823 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7824 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7825 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7826 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7827 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7828 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7829 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7830 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7831 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7832 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7833 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7834 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7835 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7836 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7837 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7838 NULL, /**< ui_info */ |
8993 | 7839 &prpl_info, /**< extra_info */ |
10653 | 7840 #if USE_PRPL_PREFERENCES |
10487 | 7841 NULL, /**< prefs_info */ |
10653 | 7842 #else |
7843 NULL, /**< prefs_info */ | |
7844 #endif | |
9015 | 7845 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7846 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7847 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7848 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7849 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7850 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7851 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7852 |
11338 | 7853 option = gaim_account_option_string_new(_("Auth host"), "server", OSCAR_DEFAULT_LOGIN_SERVER); |
9830 | 7854 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
7855 | |
11338 | 7856 option = gaim_account_option_int_new(_("Auth port"), "port", OSCAR_DEFAULT_LOGIN_PORT); |
9830 | 7857 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
7858 | |
7859 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7860 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
11338 | 7861 |
9935 | 7862 gaim_prefs_add_none("/plugins/prpl/oscar"); |
7863 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7864 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7865 } |
7866 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7867 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |