Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 13186:7df94dba7ab8
[gaim-migrate @ 15549]
This stuff doesn't belong in here, as this should be building from a make dist'ed tree, right?
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 08 Feb 2006 20:57:17 +0000 |
parents | bdb8d7beb5a7 |
children | 33bef17125c2 |
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" |
11404 | 33 #include "cipher.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
35 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
36 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
37 #include "ft.h" |
6982 | 38 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
39 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
40 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
41 #include "privacy.h" |
2086 | 42 #include "prpl.h" |
4889 | 43 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 #include "util.h" |
9943 | 46 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
47 |
2086 | 48 #include "aim.h" |
49 | |
9976 | 50 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
51 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
9991 | 52 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 53 #define OSCAR_STATUS_ID_AWAY "away" |
54 #define OSCAR_STATUS_ID_DND "dnd" | |
55 #define OSCAR_STATUS_ID_NA "na" | |
56 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
57 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
58 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 59 |
2086 | 60 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
61 | |
7283 | 62 #define OSCAR_CONNECT_STEPS 6 |
11338 | 63 #define OSCAR_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" |
64 #define OSCAR_DEFAULT_LOGIN_PORT 5190 | |
9830 | 65 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
10570 | 66 #define OSCAR_DEFAULT_AUTHORIZATION TRUE |
67 #define OSCAR_DEFAULT_HIDE_IP TRUE | |
68 #define OSCAR_DEFAULT_WEB_AWARE FALSE | |
13071 | 69 #define OSCAR_DEFAULT_USE_RV_PROXY TRUE |
7283 | 70 |
11369 | 71 /* Milliseconds each file transfer ip address will be given to make a connection. */ |
72 #define FT_CLIENTIP_TIMEOUT 1000 /* 5000 */ | |
73 #define FT_VERIFIEDIP_TIMEOUT 5000 /* 15000 */ | |
74 #define FT_REDIR_TIMEOUT 10000 /* 20000 */ /* Time to wait for redirected transfer */ | |
75 #define FT_PROXYIP_TIMEOUT 300000 /* 120000 */ /* Time to create a checksum for VERY large files */ | |
11084 | 76 |
7376 | 77 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
78 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 79 |
4665 | 80 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
81 static fu8_t features_icq[] = {0x01, 0x06}; | |
11172 | 82 static fu8_t features_icq_offline[] = {0x01}; |
8341 | 83 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 84 |
7283 | 85 typedef struct _OscarData OscarData; |
86 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
87 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
88 aim_conn_t *conn; |
2086 | 89 |
90 guint cnpa; | |
91 guint paspa; | |
3694 | 92 guint emlpa; |
4804 | 93 guint icopa; |
2086 | 94 |
4823 | 95 gboolean iconconnecting; |
5842 | 96 gboolean set_icon; |
4823 | 97 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
98 GSList *create_rooms; |
2086 | 99 |
100 gboolean conf; | |
101 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
102 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
103 char *email; |
2979 | 104 gboolean setnick; |
105 char *newsn; | |
2086 | 106 gboolean chpass; |
107 char *oldp; | |
108 char *newp; | |
11651 | 109 |
2086 | 110 GSList *oscar_chats; |
111 GSList *direct_ims; | |
3630 | 112 GSList *file_transfers; |
4738 | 113 GHashTable *buddyinfo; |
4804 | 114 GSList *requesticon; |
2086 | 115 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
116 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
117 gboolean icq; |
4804 | 118 guint icontimer; |
5968 | 119 guint getblisttimer; |
8341 | 120 guint getinfotimer; |
10567 | 121 gint timeoffset; |
2993 | 122 |
123 struct { | |
4230 | 124 guint maxwatchers; /* max users who can watch you */ |
2993 | 125 guint maxbuddies; /* max users you can watch */ |
4230 | 126 guint maxgroups; /* max groups in server list */ |
2993 | 127 guint maxpermits; /* max users on permit list */ |
128 guint maxdenies; /* max users on deny list */ | |
129 guint maxsiglen; /* max size (bytes) of profile */ | |
130 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
131 } rights; | |
2086 | 132 }; |
133 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
134 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
135 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
136 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
137 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
138 |
2086 | 139 struct chat_connection { |
140 char *name; | |
141 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
142 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
143 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
144 aim_conn_t *conn; |
2086 | 145 int inpa; |
146 int id; | |
5575 | 147 GaimConnection *gc; /* i hate this. */ |
8733 | 148 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
149 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
150 int maxvis; |
2086 | 151 }; |
152 | |
8971 | 153 struct oscar_direct_im { |
5575 | 154 GaimConnection *gc; |
2086 | 155 char name[80]; |
156 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
157 aim_conn_t *conn; |
3008 | 158 gboolean connected; |
8978 | 159 gboolean gpc_pend; |
160 gboolean killme; | |
8984 | 161 gboolean donttryagain; |
2086 | 162 }; |
163 | |
164 struct ask_direct { | |
5575 | 165 GaimConnection *gc; |
2086 | 166 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
167 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
168 fu8_t cookie[8]; |
8984 | 169 gboolean donttryagain; |
2086 | 170 }; |
171 | |
7011 | 172 /* |
173 * Various PRPL-specific buddy info that we want to keep track of | |
11651 | 174 * Some other info is maintained by locate.c, and I'd like to move |
7011 | 175 * the rest of this to libfaim, mostly im.c |
11651 | 176 * |
177 * TODO: I think all of this should use the status API. | |
7011 | 178 */ |
4738 | 179 struct buddyinfo { |
180 gboolean typingnot; | |
6857 | 181 fu32_t ipaddr; |
5836 | 182 |
183 unsigned long ico_me_len; | |
184 unsigned long ico_me_csum; | |
185 time_t ico_me_time; | |
186 gboolean ico_informed; | |
4738 | 187 |
188 unsigned long ico_len; | |
189 unsigned long ico_csum; | |
190 time_t ico_time; | |
191 gboolean ico_need; | |
7406 | 192 gboolean ico_sent; |
2086 | 193 }; |
194 | |
4230 | 195 struct name_data { |
5575 | 196 GaimConnection *gc; |
4230 | 197 gchar *name; |
3453 | 198 gchar *nick; |
3141 | 199 }; |
200 | |
5129 | 201 static char *msgerrreason[] = { |
202 N_("Invalid error"), | |
203 N_("Invalid SNAC"), | |
204 N_("Rate to host"), | |
205 N_("Rate to client"), | |
206 N_("Not logged in"), | |
207 N_("Service unavailable"), | |
208 N_("Service not defined"), | |
209 N_("Obsolete SNAC"), | |
210 N_("Not supported by host"), | |
211 N_("Not supported by client"), | |
212 N_("Refused by client"), | |
213 N_("Reply too big"), | |
214 N_("Responses lost"), | |
215 N_("Request denied"), | |
216 N_("Busted SNAC payload"), | |
217 N_("Insufficient rights"), | |
218 N_("In local permit/deny"), | |
219 N_("Too evil (sender)"), | |
220 N_("Too evil (receiver)"), | |
221 N_("User temporarily unavailable"), | |
222 N_("No match"), | |
223 N_("List overflow"), | |
224 N_("Request ambiguous"), | |
225 N_("Queue full"), | |
226 N_("Not while on AOL") | |
227 }; | |
228 static int msgerrreasonlen = 25; | |
229 | |
230 /* All the libfaim->gaim callback functions */ | |
231 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 233 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 234 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
235 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
237 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
238 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
240 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
241 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 242 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 243 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
12189 | 244 static int gaim_got_infoblock (aim_session_t *sess, aim_frame_t *fr, ...); |
5129 | 245 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
246 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
|
247 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
|
248 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
|
249 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
|
250 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 251 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
252 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 254 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 255 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
256 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
262 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
263 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
264 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
265 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
266 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
267 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
280 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
281 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
11369 | 282 |
5129 | 283 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); |
284 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
286 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 287 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 288 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
289 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
290 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
291 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
292 | |
293 /* for DirectIM/image transfer */ | |
294 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
295 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
296 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 297 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 298 |
299 /* for file transfer */ | |
300 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
301 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
302 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
303 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
304 | |
305 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 306 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
11369 | 307 static void oscar_xfer_init_recv(GaimXfer *xfer); |
308 static void oscar_xfer_init_send(GaimXfer *xfer); | |
309 | |
11159 | 310 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie); |
12816 | 311 static void recent_buddies_cb(const char *name, GaimPrefType type, gconstpointer value, gpointer data); |
11347 | 312 static void oscar_set_info(GaimConnection *gc, const char *info); |
11965 | 313 static void oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo, gboolean setstatus, GaimStatus *status); |
12652 | 314 static void oscar_set_extendedstatus(GaimConnection *gc); |
12663 | 315 static gboolean gaim_ssi_rerequestdata(gpointer data); |
9935 | 316 |
5836 | 317 static void oscar_free_name_data(struct name_data *data) { |
4230 | 318 g_free(data->name); |
319 g_free(data->nick); | |
320 g_free(data); | |
321 } | |
322 | |
5836 | 323 static void oscar_free_buddyinfo(void *data) { |
324 struct buddyinfo *bi = data; | |
325 g_free(bi); | |
326 } | |
327 | |
9807 | 328 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 329 { |
330 int i = 0; | |
9826 | 331 int charset = AIM_CHARSET_ASCII; |
5129 | 332 |
11369 | 333 /* Determine how we can send this message. Per the warnings elsewhere |
334 * in this file, these little checks determine the simplest encoding | |
5129 | 335 * we can use for a given message send using it. */ |
336 while (utf8[i]) { | |
337 if ((unsigned char)utf8[i] > 0x7f) { | |
338 /* not ASCII! */ | |
9826 | 339 charset = AIM_CHARSET_CUSTOM; |
5129 | 340 break; |
341 } | |
342 i++; | |
343 } | |
344 while (utf8[i]) { | |
345 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
346 * followed by 0xc0-0xc3 in the second */ | |
347 if ((unsigned char)utf8[i] < 0x80) { | |
348 i++; | |
349 continue; | |
350 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
351 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
352 i += 2; | |
353 continue; | |
354 } | |
9826 | 355 charset = AIM_CHARSET_UNICODE; |
5129 | 356 break; |
357 } | |
358 | |
9807 | 359 return charset; |
5129 | 360 } |
361 | |
8225 | 362 /* |
363 * Take a string of the form charset="bleh" where bleh is | |
11369 | 364 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and |
8225 | 365 * return a newly allocated string containing bleh. |
366 */ | |
367 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 368 { |
8225 | 369 gchar *ret = NULL; |
370 char *begin, *end; | |
371 | |
9933 | 372 g_return_val_if_fail(encoding != NULL, NULL); |
373 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
374 /* Make sure encoding begins with charset= */ |
10540 | 375 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
376 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
377 { | |
8225 | 378 return NULL; |
10540 | 379 } |
8225 | 380 |
381 begin = strchr(encoding, '"'); | |
382 end = strrchr(encoding, '"'); | |
383 | |
384 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
385 return NULL; | |
386 | |
387 ret = g_strndup(begin+1, (end-1) - begin); | |
388 | |
389 return ret; | |
390 } | |
391 | |
9830 | 392 static gchar * |
393 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 394 { |
395 gchar *utf8 = NULL; | |
9595 | 396 |
397 if ((encoding == NULL) || encoding[0] == '\0') { | |
398 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 399 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 400 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 401 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 402 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 403 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 404 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 405 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 406 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 407 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 408 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
409 } | |
410 | |
411 /* | |
412 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
413 * we have been unable to convert the text to utf-8 from the encoding | |
414 * that was specified. So we check if the text is valid utf-8 then | |
415 * just copy it. | |
416 */ | |
417 if (utf8 == NULL) { | |
9638 | 418 if (textlen != 0 && *text != '\0' |
419 && !g_utf8_validate(text, textlen, NULL)) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
420 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 421 else |
9481 | 422 utf8 = g_strndup(text, textlen); |
5129 | 423 } |
424 | |
425 return utf8; | |
426 } | |
427 | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
428 static gchar *oscar_utf8_try_convert(GaimAccount *account, const gchar *msg) |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
429 { |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
430 const char *charset = NULL; |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
431 char *ret = NULL; |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
432 |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
433 if(aim_sn_is_icq(gaim_account_get_username(account))) |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
434 charset = gaim_account_get_string(account, "encoding", NULL); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
435 |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
436 if(charset && *charset) |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
437 ret = g_convert(msg, -1, "UTF-8", charset, NULL, NULL, NULL); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
438 |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
439 if(!ret) |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
440 ret = gaim_utf8_try_convert(msg); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
441 |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
442 return ret; |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
443 } |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
444 |
9830 | 445 static gchar * |
11159 | 446 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback) |
9830 | 447 { |
448 gchar *ret = NULL; | |
449 GError *err = NULL; | |
450 | |
9908 | 451 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
452 return NULL; | |
453 | |
454 if (strcasecmp("UTF-8", charsetstr)) { | |
455 if (fallback) | |
456 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
457 else | |
458 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
459 if (err != NULL) { | |
460 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
461 charsetstr, err->message); | |
462 g_error_free(err); | |
463 } | |
464 } else { | |
465 if (g_utf8_validate(data, datalen, NULL)) | |
466 ret = g_strndup(data, datalen); | |
467 else | |
468 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
469 } | |
470 | |
471 return ret; | |
472 } | |
473 | |
474 /* | |
11081 | 475 * This attemps to decode an incoming IM into a UTF8 string. |
476 * | |
9908 | 477 * We try decoding using two different character sets. The charset |
478 * specified in the IM determines the order in which we attempt to | |
479 * decode. We do this because there are lots of broken ICQ clients | |
480 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
481 * able to deal with that crap, then people complain like banshees. | |
482 * charsetstr1 is always set to what the correct encoding should be. | |
483 */ | |
484 static gchar * | |
11159 | 485 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, const gchar *data, gsize datalen) |
9908 | 486 { |
487 gchar *ret = NULL; | |
488 const gchar *charsetstr1, *charsetstr2; | |
489 | |
490 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 491 |
492 if ((datalen == 0) || (data == NULL)) | |
493 return NULL; | |
494 | |
9908 | 495 if (charset == AIM_CHARSET_UNICODE) { |
496 charsetstr1 = "UCS-2BE"; | |
497 charsetstr2 = "UTF-8"; | |
498 } else if (charset == AIM_CHARSET_CUSTOM) { | |
11369 | 499 if ((sourcesn != NULL) && isdigit(sourcesn[0])) |
9908 | 500 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 501 else |
9908 | 502 charsetstr1 = "ISO-8859-1"; |
503 charsetstr2 = "UTF-8"; | |
504 } else if (charset == AIM_CHARSET_ASCII) { | |
505 /* Should just be "ASCII" */ | |
9914 | 506 charsetstr1 = "ASCII"; |
9908 | 507 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
508 } else if (charset == 0x000d) { | |
9830 | 509 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 510 charsetstr1 = "ISO-8859-1"; |
511 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
512 } else { | |
9830 | 513 /* Unknown, hope for valid UTF-8... */ |
9908 | 514 charsetstr1 = "UTF-8"; |
515 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
516 } | |
517 | |
518 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
519 if (ret == NULL) | |
520 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
521 if (ret == NULL) | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
522 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9830 | 523 |
524 return ret; | |
525 } | |
526 | |
11081 | 527 /* |
528 * Figure out what encoding to use when sending a given outgoing message. | |
529 */ | |
9830 | 530 static void |
531 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 532 gchar **msg, int *msglen_int, |
9830 | 533 fu16_t *charset, fu16_t *charsubset) |
534 { | |
535 OscarData *od = gc->proto_data; | |
536 GaimAccount *account = gaim_connection_get_account(gc); | |
537 GError *err = NULL; | |
538 aim_userinfo_t *userinfo = NULL; | |
539 const gchar *charsetstr; | |
10039 | 540 gsize msglen; |
9830 | 541 |
542 /* Attempt to send as ASCII */ | |
10098 | 543 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 544 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 545 *charset = AIM_CHARSET_ASCII; |
9830 | 546 *charsubset = 0x0000; |
10039 | 547 *msglen_int = msglen; |
9830 | 548 return; |
549 } | |
550 | |
551 /* | |
10565 | 552 * If we're sending to an ICQ user, and they are in our |
553 * buddy list, and they are advertising the Unicode | |
554 * capability, and they are online, then attempt to send | |
555 * as UCS-2BE. | |
9830 | 556 */ |
9975 | 557 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 558 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
559 | |
10565 | 560 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
561 { | |
562 GaimBuddy *b; | |
563 b = gaim_find_buddy(account, destsn); | |
564 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
565 { | |
566 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
567 if (*msg != NULL) | |
568 { | |
569 *charset = AIM_CHARSET_UNICODE; | |
570 *charsubset = 0x0000; | |
571 *msglen_int = msglen; | |
572 return; | |
573 } | |
9830 | 574 } |
575 } | |
576 | |
577 /* | |
578 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
579 * ICQ then attempt to send as the user specified character encoding. | |
580 */ | |
581 charsetstr = "ISO-8859-1"; | |
9975 | 582 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 583 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
584 | |
10097 | 585 /* |
586 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
587 * can be converted to "charsetstr" | |
588 */ | |
10039 | 589 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 590 if (*msg != NULL) { |
591 *charset = AIM_CHARSET_CUSTOM; | |
592 *charsubset = 0x0000; | |
10039 | 593 *msglen_int = msglen; |
9830 | 594 return; |
595 } | |
596 | |
597 /* | |
598 * Nothing else worked, so send as UCS-2BE. | |
599 */ | |
10039 | 600 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 601 if (*msg != NULL) { |
602 *charset = AIM_CHARSET_UNICODE; | |
603 *charsubset = 0x0000; | |
10039 | 604 *msglen_int = msglen; |
9830 | 605 return; |
606 } | |
607 | |
9908 | 608 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 609 g_error_free(err); |
610 | |
611 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
612 *msg = g_strdup(from); | |
10039 | 613 *msglen_int = strlen(*msg); |
9830 | 614 *charset = AIM_CHARSET_ASCII; |
615 *charsubset = 0x0000; | |
616 return; | |
617 } | |
618 | |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
619 static gchar *oscar_caps_to_string(guint caps) |
8701 | 620 { |
9407 | 621 GString *str; |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
622 const gchar *tmp; |
8701 | 623 guint bit = 1; |
624 | |
9407 | 625 str = g_string_new(""); |
626 | |
8701 | 627 if (!caps) { |
628 return NULL; | |
629 } else while (bit <= AIM_CAPS_LAST) { | |
630 if (bit & caps) { | |
631 switch (bit) { | |
632 case AIM_CAPS_BUDDYICON: | |
633 tmp = _("Buddy Icon"); | |
634 break; | |
635 case AIM_CAPS_TALK: | |
636 tmp = _("Voice"); | |
637 break; | |
638 case AIM_CAPS_DIRECTIM: | |
639 tmp = _("AIM Direct IM"); | |
640 break; | |
641 case AIM_CAPS_CHAT: | |
642 tmp = _("Chat"); | |
643 break; | |
644 case AIM_CAPS_GETFILE: | |
645 tmp = _("Get File"); | |
646 break; | |
647 case AIM_CAPS_SENDFILE: | |
648 tmp = _("Send File"); | |
649 break; | |
650 case AIM_CAPS_GAMES: | |
651 case AIM_CAPS_GAMES2: | |
652 tmp = _("Games"); | |
653 break; | |
654 case AIM_CAPS_ADDINS: | |
655 tmp = _("Add-Ins"); | |
656 break; | |
657 case AIM_CAPS_SENDBUDDYLIST: | |
658 tmp = _("Send Buddy List"); | |
659 break; | |
660 case AIM_CAPS_ICQ_DIRECT: | |
661 tmp = _("ICQ Direct Connect"); | |
662 break; | |
663 case AIM_CAPS_APINFO: | |
664 tmp = _("AP User"); | |
665 break; | |
666 case AIM_CAPS_ICQRTF: | |
667 tmp = _("ICQ RTF"); | |
668 break; | |
669 case AIM_CAPS_EMPTY: | |
670 tmp = _("Nihilist"); | |
671 break; | |
672 case AIM_CAPS_ICQSERVERRELAY: | |
673 tmp = _("ICQ Server Relay"); | |
674 break; | |
675 case AIM_CAPS_ICQUTF8OLD: | |
676 tmp = _("Old ICQ UTF8"); | |
677 break; | |
678 case AIM_CAPS_TRILLIANCRYPT: | |
679 tmp = _("Trillian Encryption"); | |
680 break; | |
681 case AIM_CAPS_ICQUTF8: | |
682 tmp = _("ICQ UTF8"); | |
683 break; | |
684 case AIM_CAPS_HIPTOP: | |
685 tmp = _("Hiptop"); | |
686 break; | |
687 case AIM_CAPS_SECUREIM: | |
688 tmp = _("Security Enabled"); | |
689 break; | |
690 case AIM_CAPS_VIDEO: | |
691 tmp = _("Video Chat"); | |
692 break; | |
693 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
694 case AIM_CAPS_ICHATAV: | |
695 tmp = _("iChat AV"); | |
696 break; | |
697 case AIM_CAPS_LIVEVIDEO: | |
698 tmp = _("Live Video"); | |
699 break; | |
700 case AIM_CAPS_CAMERA: | |
701 tmp = _("Camera"); | |
702 break; | |
703 default: | |
704 tmp = NULL; | |
705 break; | |
706 } | |
707 if (tmp) | |
9532 | 708 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 709 } |
710 bit <<= 1; | |
711 } | |
9407 | 712 |
713 return g_string_free(str, FALSE); | |
8701 | 714 } |
715 | |
716 static char *oscar_icqstatus(int state) { | |
717 /* Make a cute little string that shows the status of the dude or dudet */ | |
718 if (state & AIM_ICQ_STATE_CHAT) | |
719 return g_strdup_printf(_("Free For Chat")); | |
720 else if (state & AIM_ICQ_STATE_DND) | |
721 return g_strdup_printf(_("Do Not Disturb")); | |
722 else if (state & AIM_ICQ_STATE_OUT) | |
723 return g_strdup_printf(_("Not Available")); | |
724 else if (state & AIM_ICQ_STATE_BUSY) | |
725 return g_strdup_printf(_("Occupied")); | |
726 else if (state & AIM_ICQ_STATE_AWAY) | |
727 return g_strdup_printf(_("Away")); | |
728 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
729 return g_strdup_printf(_("Web Aware")); | |
730 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
731 return g_strdup_printf(_("Invisible")); | |
732 else | |
733 return g_strdup_printf(_("Online")); | |
734 } | |
735 | |
9973 | 736 static void |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
737 oscar_string_append(GaimAccount *account, GString *str, const char *newline, |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
738 const char *name, const char *value) |
8700 | 739 { |
740 gchar *utf8; | |
741 | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
742 if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) { |
8701 | 743 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 744 g_free(utf8); |
745 } | |
746 } | |
747 | |
9973 | 748 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 749 { |
10042 | 750 OscarData *od; |
751 GaimAccount *account; | |
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
752 GaimPresence *presence = NULL; |
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
753 GaimStatus *status = NULL; |
8701 | 754 GaimGroup *g = NULL; |
755 struct buddyinfo *bi = NULL; | |
756 char *tmp; | |
757 | |
10042 | 758 od = gc->proto_data; |
759 account = gaim_connection_get_account(gc); | |
760 | |
761 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 762 return; |
763 | |
764 if (userinfo == NULL) | |
765 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
766 | |
767 if (b == NULL) | |
10042 | 768 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 769 |
11369 | 770 if (b != NULL) { |
12088 | 771 g = gaim_buddy_get_group(b); |
10498 | 772 presence = gaim_buddy_get_presence(b); |
773 status = gaim_presence_get_active_status(presence); | |
774 } | |
8701 | 775 |
776 if (userinfo != NULL) | |
777 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
778 | |
8733 | 779 if (b != NULL) { |
10498 | 780 if (gaim_presence_is_online(presence)) { |
9975 | 781 if (aim_sn_is_icq(b->name)) { |
11510 | 782 GaimStatus *status = gaim_presence_get_active_status(presence); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
783 oscar_string_append(gc->account, str, newline, _("Status"), |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
784 gaim_status_get_name(status)); |
8733 | 785 } |
786 } else { | |
9625 | 787 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 788 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
789 oscar_string_append(gc->account, str, newline, _("Status"), |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
790 _("Not Authorized")); |
8733 | 791 else |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
792 oscar_string_append(gc->account, str, newline, _("Status"), |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
793 _("Offline")); |
8701 | 794 } |
8733 | 795 } |
8701 | 796 |
797 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 798 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 799 (bi->ipaddr & 0xff000000) >> 24, |
800 (bi->ipaddr & 0x00ff0000) >> 16, | |
801 (bi->ipaddr & 0x0000ff00) >> 8, | |
802 (bi->ipaddr & 0x000000ff)); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
803 oscar_string_append(gc->account, str, newline, _("IP Address"), tmp); |
8701 | 804 g_free(tmp); |
805 } | |
806 | |
11257 | 807 |
808 if ((userinfo != NULL) && (userinfo->warnlevel != 0)) { | |
11285 | 809 tmp = g_strdup_printf("%d", (int)(userinfo->warnlevel/10.0 + .5)); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
810 oscar_string_append(gc->account, str, newline, _("Warning Level"), tmp); |
11257 | 811 g_free(tmp); |
812 } | |
813 | |
8701 | 814 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { |
815 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
816 if (tmp != NULL) { | |
9625 | 817 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 818 g_free(tmp); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
819 oscar_string_append(gc->account, str, newline, _("Buddy Comment"), tmp2); |
9625 | 820 g_free(tmp2); |
8701 | 821 } |
822 } | |
823 } | |
824 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
825 static char *extract_name(const char *name) { |
4121 | 826 char *tmp, *x; |
2086 | 827 int i, j; |
4120 | 828 |
829 if (!name) | |
4121 | 830 return NULL; |
11369 | 831 |
4120 | 832 x = strchr(name, '-'); |
4121 | 833 |
2086 | 834 if (!x) return NULL; |
835 x = strchr(++x, '-'); | |
836 if (!x) return NULL; | |
837 tmp = g_strdup(++x); | |
838 | |
839 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
840 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
841 if (x[i] != '%') { |
2086 | 842 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
843 continue; |
2086 | 844 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
845 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
846 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
847 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 848 } |
849 | |
850 tmp[j] = 0; | |
851 return tmp; | |
852 } | |
853 | |
10458 | 854 static struct chat_connection * |
855 find_oscar_chat(GaimConnection *gc, int id) | |
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->id == id) | |
865 return cc; | |
866 } | |
867 | |
868 return NULL; | |
869 } | |
870 | |
871 static struct chat_connection * | |
872 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
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->conn == conn) | |
882 return cc; | |
883 } | |
884 | |
885 return NULL; | |
886 } | |
887 | |
888 static struct chat_connection * | |
889 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
890 { | |
891 OscarData *od = (OscarData *)gc->proto_data; | |
892 GSList *cur; | |
893 struct chat_connection *cc; | |
894 | |
895 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
896 { | |
897 cc = (struct chat_connection *)cur->data; | |
898 if (cc->conv == conv) | |
899 return cc; | |
900 } | |
901 | |
902 return NULL; | |
903 } | |
904 | |
905 static void | |
906 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
907 { | |
908 OscarData *od = (OscarData *)gc->proto_data; | |
909 | |
910 /* Notify the conversation window that we've left the chat */ | |
911 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
912 | |
913 /* Destroy the chat_connection */ | |
914 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
915 if (cc->inpa > 0) | |
916 gaim_input_remove(cc->inpa); | |
917 aim_conn_kill(od->sess, &cc->conn); | |
918 g_free(cc->name); | |
919 g_free(cc->show); | |
920 g_free(cc); | |
8219 | 921 } |
922 | |
8971 | 923 /***************************************************************************** |
924 * Begin scary direct im stuff | |
925 *****************************************************************************/ | |
926 | |
927 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
928 GSList *d = od->direct_ims; | |
929 struct oscar_direct_im *m = NULL; | |
930 | |
931 while (d) { | |
932 m = (struct oscar_direct_im *)d->data; | |
933 if (!aim_sncmp(who, m->name)) | |
934 return m; | |
935 d = d->next; | |
936 } | |
937 | |
938 return NULL; | |
939 } | |
940 | |
941 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
942 { | |
943 gaim_debug_info("oscar", | |
944 "destroying Direct IM for %s.\n", dim->name); | |
945 | |
946 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 947 if (dim->gpc_pend) { |
948 dim->killme = TRUE; | |
949 return; | |
950 } | |
8971 | 951 if (dim->watcher) |
952 gaim_input_remove(dim->watcher); | |
953 if (dim->conn) { | |
10271 | 954 aim_conn_close(dim->conn); |
8971 | 955 aim_conn_kill(od->sess, &dim->conn); |
956 } | |
957 g_free(dim); | |
958 } | |
959 | |
960 /* the only difference between this and destroy is this writes a conv message */ | |
961 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
962 { | |
963 GaimConversation *conv; | |
964 char buf[256]; | |
965 | |
966 gaim_debug_info("oscar", | |
967 "%s disconnected Direct IM.\n", dim->name); | |
968 | |
969 if (dim->connected) | |
970 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 971 else |
8971 | 972 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
973 | |
11338 | 974 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, dim->name, |
11369 | 975 gaim_connection_get_account(dim->gc)); |
976 | |
8971 | 977 if (conv) { |
978 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
979 } else { | |
980 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
981 } | |
982 | |
983 oscar_direct_im_destroy(od, dim); | |
984 | |
985 return; | |
986 } | |
987 | |
988 /* oops i made two of these. this one just calls the other one. */ | |
989 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
990 { | |
991 GaimConnection *gc = sess->aux_data; | |
992 OscarData *od = (OscarData *)gc->proto_data; | |
993 struct oscar_direct_im *dim; | |
994 char *sn; | |
995 | |
996 sn = g_strdup(aim_odc_getsn(conn)); | |
997 dim = oscar_direct_im_find(od, sn); | |
998 oscar_direct_im_disconnect(od, dim); | |
999 g_free(sn); | |
1000 } | |
1001 | |
1002 static void destroy_direct_im_request(struct ask_direct *d) { | |
1003 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
1004 | |
1005 g_free(d->sn); | |
1006 g_free(d); | |
1007 } | |
1008 | |
1009 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
1010 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
1011 struct oscar_direct_im *dim = data; | |
1012 GaimConnection *gc = dim->gc; | |
1013 OscarData *od = gc->proto_data; | |
1014 GaimConversation *conv; | |
1015 char buf[256]; | |
1016 struct sockaddr name; | |
1017 socklen_t name_len = 1; | |
1018 | |
1019 g_return_if_fail(gc != NULL); | |
1020 | |
8978 | 1021 dim->gpc_pend = FALSE; |
1022 if (dim->killme) { | |
1023 oscar_direct_im_destroy(od, dim); | |
1024 return; | |
1025 } | |
1026 | |
8971 | 1027 if (!g_list_find(gaim_connections_get_all(), gc)) { |
1028 oscar_direct_im_destroy(od, dim); | |
1029 return; | |
1030 } | |
1031 | |
1032 if (source < 0) { | |
8984 | 1033 if (dim->donttryagain) { |
1034 oscar_direct_im_disconnect(od, dim); | |
1035 return; | |
1036 } else { | |
11159 | 1037 guchar cookie[8]; |
8984 | 1038 char *who = g_strdup(dim->name); |
11159 | 1039 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1040 |
1041 memcpy(cookie, tmp, 8); | |
1042 oscar_direct_im_destroy(od, dim); | |
1043 oscar_direct_im_initiate(gc, who, cookie); | |
1044 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1045 g_free(who); | |
1046 return; | |
1047 } | |
8971 | 1048 } |
1049 | |
1050 dim->conn->fd = source; | |
1051 aim_conn_completeconnect(od->sess, dim->conn); | |
11338 | 1052 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); |
8971 | 1053 |
1054 /* This is the best way to see if we're connected or not */ | |
8983 | 1055 /* Is this really needed? */ |
8971 | 1056 if (getpeername(source, &name, &name_len) == 0) { |
1057 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1058 dim->connected = TRUE; | |
1059 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1060 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1061 } else { | |
8984 | 1062 if (dim->donttryagain) { |
1063 oscar_direct_im_disconnect(od, dim); | |
1064 return; | |
1065 } else { | |
11159 | 1066 guchar cookie[8]; |
8984 | 1067 char *who = g_strdup(dim->name); |
11159 | 1068 const guchar *tmp = aim_odc_getcookie(dim->conn); |
8984 | 1069 |
1070 memcpy(cookie, tmp, 8); | |
1071 oscar_direct_im_destroy(od, dim); | |
1072 oscar_direct_im_initiate(gc, who, cookie); | |
1073 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1074 g_free(who); | |
1075 return; | |
1076 } | |
8983 | 1077 } |
1078 | |
1079 | |
8971 | 1080 } |
1081 | |
1082 static void accept_direct_im_request(struct ask_direct *d) { | |
1083 GaimConnection *gc = d->gc; | |
1084 OscarData *od; | |
1085 struct oscar_direct_im *dim; | |
1086 char *host; int port = 5190; | |
1087 int i, rc; | |
8982 | 1088 char *tmp; |
1089 GaimConversation *conv; | |
8971 | 1090 |
1091 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1092 destroy_direct_im_request(d); | |
1093 return; | |
1094 } | |
1095 | |
1096 od = (OscarData *)gc->proto_data; | |
1097 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1098 | |
1099 dim = oscar_direct_im_find(od, d->sn); | |
1100 if (dim && dim->connected) { | |
1101 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1102 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1103 return; | |
1104 } | |
1105 dim = g_new0(struct oscar_direct_im, 1); | |
1106 dim->gc = d->gc; | |
8984 | 1107 dim->donttryagain = d->donttryagain; |
8971 | 1108 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1109 | |
1110 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1111 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1112 if (!dim->conn) { | |
1113 oscar_direct_im_disconnect(od, dim); | |
1114 destroy_direct_im_request(d); | |
1115 return; | |
1116 } | |
1117 | |
1118 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1119 gaim_odc_incoming, 0); | |
1120 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1121 gaim_odc_typing, 0); | |
1122 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1123 gaim_odc_update_ui, 0); | |
1124 | |
1125 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1126 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1127 if (d->ip[i] == ':') { | |
1128 port = atoi(&(d->ip[i+1])); | |
1129 break; | |
1130 } | |
1131 } | |
1132 host = g_strndup(d->ip, i); | |
1133 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1134 dim->gpc_pend = TRUE; |
8971 | 1135 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1136 |
11338 | 1137 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, d->sn); |
8982 | 1138 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, |
1139 port); | |
1140 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1141 g_free(tmp); | |
8983 | 1142 |
8971 | 1143 g_free(host); |
1144 if (rc < 0) { | |
8978 | 1145 dim->gpc_pend = FALSE; |
8971 | 1146 oscar_direct_im_disconnect(od, dim); |
1147 destroy_direct_im_request(d); | |
1148 return; | |
1149 } | |
1150 | |
1151 destroy_direct_im_request(d); | |
1152 | |
1153 return; | |
1154 } | |
1155 | |
1156 /* | |
1157 * We have just established a socket with the other dude, so set up some handlers. | |
1158 */ | |
1159 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1160 GaimConnection *gc = sess->aux_data; |
7283 | 1161 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1162 GaimConversation *conv; |
8971 | 1163 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1164 char buf[256]; |
8971 | 1165 char *sn; |
1166 va_list ap; | |
1167 aim_conn_t *newconn, *listenerconn; | |
1168 | |
1169 va_start(ap, fr); | |
1170 newconn = va_arg(ap, aim_conn_t *); | |
1171 listenerconn = va_arg(ap, aim_conn_t *); | |
1172 va_end(ap); | |
1173 | |
10271 | 1174 aim_conn_close(listenerconn); |
8971 | 1175 aim_conn_kill(sess, &listenerconn); |
1176 | |
1177 sn = g_strdup(aim_odc_getsn(newconn)); | |
1178 | |
1179 gaim_debug_info("oscar", | |
1180 "DirectIM: initiate success to %s\n", sn); | |
1181 dim = oscar_direct_im_find(od, sn); | |
1182 | |
11338 | 1183 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, sn); |
8971 | 1184 gaim_input_remove(dim->watcher); |
1185 dim->conn = newconn; | |
1186 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1187 dim->connected = TRUE; | |
1188 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1189 g_free(sn); | |
1190 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1191 | |
1192 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1193 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1194 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1195 | |
1196 return 1; | |
1197 } | |
1198 | |
1199 /* | |
1200 * This is called when each chunk of an image is received. It can be used to | |
1201 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1202 * nasty, you sicko. | |
1203 */ | |
1204 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1205 va_list ap; | |
1206 char *sn; | |
1207 double percent; | |
1208 GaimConnection *gc = sess->aux_data; | |
1209 OscarData *od = (OscarData *)gc->proto_data; | |
1210 struct oscar_direct_im *dim; | |
1211 | |
1212 va_start(ap, fr); | |
1213 sn = va_arg(ap, char *); | |
1214 percent = va_arg(ap, double); | |
1215 va_end(ap); | |
1216 | |
1217 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1218 return 1; | |
1219 if (dim->watcher) { | |
1220 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1221 /* The callback will callback? I don't get how that would happen here. */ | |
1222 dim->watcher = 0; | |
1223 } | |
1224 | |
1225 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1226 oscar_callback, dim->conn); | |
1227 | |
1228 return 1; | |
1229 } | |
1230 | |
1231 /* | |
1232 * This is called after a direct IM has been received in its entirety. This | |
1233 * function is passed a long chunk of data which contains the IM with any | |
1234 * data chunks (images) appended to it. | |
1235 * | |
1236 * This function rips out all the data chunks and creates an imgstore for | |
1237 * each one. In order to do this, it first goes through the IM and takes | |
1238 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1239 * with one compatible with the imgstore Gaim core code. For each one, we | |
1240 * then read in chunks of data from the end of the message and actually | |
1241 * create the img store using the given data. | |
1242 * | |
1243 * For somewhat easy reference, here's a sample message | |
1244 * (without the whitespace and asterisks): | |
1245 * | |
1246 * <HTML><BODY BGCOLOR="#ffffff"> | |
1247 * <FONT LANG="0"> | |
1248 * This is a really stupid picture:<BR> | |
1249 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1250 * Yeah it is<BR> | |
1251 * Here is another one:<BR> | |
1252 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1253 * </FONT> | |
1254 * </BODY></HTML> | |
1255 * <BINARY> | |
1256 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1257 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1258 * </BINARY> | |
1259 */ | |
1260 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1261 GaimConnection *gc = sess->aux_data; | |
12216 | 1262 GaimMessageFlags imflags = 0; |
8971 | 1263 gchar *utf8; |
1264 GString *newmsg = g_string_new(""); | |
1265 GSList *images = NULL; | |
1266 va_list ap; | |
1267 const char *sn, *msg, *msgend, *binary; | |
1268 size_t len; | |
1269 int encoding, isawaymsg; | |
1270 | |
1271 va_start(ap, fr); | |
1272 sn = va_arg(ap, const char *); | |
1273 msg = va_arg(ap, const char *); | |
1274 len = va_arg(ap, size_t); | |
1275 encoding = va_arg(ap, int); | |
1276 isawaymsg = va_arg(ap, int); | |
1277 va_end(ap); | |
1278 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1279 |
8660 | 1280 gaim_debug_info("oscar", |
8971 | 1281 "Got DirectIM message from %s\n", sn); |
1282 | |
1283 if (isawaymsg) | |
12216 | 1284 imflags |= GAIM_MESSAGE_AUTO_RESP; |
8971 | 1285 |
1286 /* message has a binary trailer */ | |
1287 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1288 GData *attribs; | |
1289 const char *tmp, *start, *end, *last = NULL; | |
1290 | |
1291 tmp = msg; | |
1292 | |
1293 /* for each valid image tag... */ | |
1294 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1295 const char *id, *src, *datasize; | |
10504 | 1296 const char *data = NULL; |
1297 char *tag = NULL; | |
8971 | 1298 size_t size; |
1299 int imgid = 0; | |
1300 | |
1301 /* update the location of the last img tag */ | |
1302 last = end; | |
1303 | |
1304 /* grab attributes */ | |
1305 id = g_datalist_get_data(&attribs, "id"); | |
1306 src = g_datalist_get_data(&attribs, "src"); | |
1307 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1308 | |
1309 /* if we have id & datasize, build the data tag */ | |
1310 if (id && datasize) | |
1311 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1312 | |
1313 /* if we have a tag, find the start of the data */ | |
1314 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1315 data += strlen(tag); | |
1316 | |
10504 | 1317 g_free(tag); |
1318 | |
8971 | 1319 /* check the data is here and store it */ |
1320 if (data + (size = atoi(datasize)) <= msgend) | |
1321 imgid = gaim_imgstore_add(data, size, src); | |
1322 | |
1323 /* | |
1324 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1325 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1326 */ | |
1327 /* if we have a stored image... */ | |
1328 if (imgid) { | |
1329 /* append the message up to the tag */ | |
1330 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1331 if (utf8 != NULL) { | |
1332 newmsg = g_string_append(newmsg, utf8); | |
1333 g_free(utf8); | |
1334 } | |
1335 | |
1336 /* write the new image tag */ | |
1337 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1338 | |
1339 /* and record the image number */ | |
1340 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1341 } else { | |
1342 /* otherwise, copy up to the end of the tag */ | |
1343 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1344 if (utf8 != NULL) { | |
1345 newmsg = g_string_append(newmsg, utf8); | |
1346 g_free(utf8); | |
1347 } | |
1348 } | |
1349 | |
1350 /* clear the attribute list */ | |
1351 g_datalist_clear(&attribs); | |
1352 | |
1353 /* continue from the end of the tag */ | |
1354 tmp = end + 1; | |
1355 } | |
1356 | |
1357 /* append any remaining message data (without the > :-) */ | |
1358 if (last++ && (last < binary)) | |
1359 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1360 | |
1361 /* set the flag if we caught any images */ | |
1362 if (images) | |
12216 | 1363 imflags |= GAIM_MESSAGE_IMAGES; |
8971 | 1364 } else { |
1365 g_string_append_len(newmsg, msg, len); | |
1366 } | |
1367 | |
10318 | 1368 /* Convert to UTF8 */ |
1369 /* (This hasn't been tested very much) */ | |
1370 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1371 if (utf8 != NULL) { | |
1372 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1373 g_free(utf8); | |
1374 } | |
1375 | |
1376 /* free the message */ | |
8971 | 1377 g_string_free(newmsg, TRUE); |
1378 | |
1379 /* unref any images we allocated */ | |
1380 if (images) { | |
1381 GSList *tmp; | |
1382 int id; | |
1383 | |
1384 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1385 id = GPOINTER_TO_INT(tmp->data); | |
1386 gaim_imgstore_unref(id); | |
1387 } | |
1388 | |
1389 g_slist_free(images); | |
1390 } | |
1391 | |
1392 return 1; | |
1393 } | |
1394 | |
1395 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1396 va_list ap; | |
1397 char *sn; | |
1398 int typing; | |
1399 GaimConnection *gc = sess->aux_data; | |
1400 | |
1401 va_start(ap, fr); | |
1402 sn = va_arg(ap, char *); | |
1403 typing = va_arg(ap, int); | |
1404 va_end(ap); | |
1405 | |
1406 if (typing == 0x0002) { | |
1407 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1408 gaim_debug_info("oscar", | |
1409 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1410 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1411 } else if (typing == 0x0001) | |
1412 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1413 else | |
1414 serv_got_typing_stopped(gc, sn); | |
1415 return 1; | |
1416 } | |
1417 | |
12216 | 1418 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimMessageFlags imflags) { |
8971 | 1419 char *buf; |
1420 size_t len; | |
1421 int ret; | |
1422 GString *msg = g_string_new("<HTML><BODY>"); | |
1423 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1424 GData *attribs; | |
1425 const char *start, *end, *last; | |
1426 int oscar_id = 0; | |
1427 | |
1428 last = message; | |
1429 | |
1430 /* for each valid IMG tag... */ | |
1431 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1432 GaimStoredImage *image = NULL; | |
1433 const char *id; | |
1434 | |
1435 if (start - last) { | |
1436 g_string_append_len(msg, last, start - last); | |
1437 } | |
1438 | |
1439 id = g_datalist_get_data(&attribs, "id"); | |
1440 | |
1441 /* ... if it refers to a valid gaim image ... */ | |
1442 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1443 /* ... append the message from start to the tag ... */ | |
9126 | 1444 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1445 const char *filename = gaim_imgstore_get_filename(image); |
1446 gpointer imgdata = gaim_imgstore_get_data(image); | |
1447 | |
1448 oscar_id++; | |
1449 | |
1450 /* ... insert a new img tag with the oscar id ... */ | |
1451 if (filename) | |
1452 g_string_append_printf(msg, | |
9126 | 1453 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1454 filename, oscar_id, size); |
1455 else | |
1456 g_string_append_printf(msg, | |
9126 | 1457 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1458 oscar_id, size); |
1459 | |
1460 /* ... and append the data to the binary section ... */ | |
9126 | 1461 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1462 oscar_id, size); |
1463 data = g_string_append_len(data, imgdata, size); | |
1464 data = g_string_append(data, "</DATA>"); | |
1465 } | |
1466 /* If the tag is invalid, skip it, thus no else here */ | |
1467 | |
1468 g_datalist_clear(&attribs); | |
1469 | |
1470 /* continue from the end of the tag */ | |
1471 last = end + 1; | |
1472 } | |
1473 | |
1474 /* append any remaining message data (without the > :-) */ | |
1475 if (last && *last) | |
1476 msg = g_string_append(msg, last); | |
1477 | |
1478 /* if we inserted any images in the binary section, append it */ | |
1479 if (oscar_id) { | |
1480 msg = g_string_append_len(msg, data->str, data->len); | |
1481 msg = g_string_append(msg, "</BINARY>"); | |
1482 } | |
1483 | |
1484 len = msg->len; | |
1485 buf = msg->str; | |
1486 g_string_free(msg, FALSE); | |
1487 g_string_free(data, TRUE); | |
1488 | |
1489 | |
1490 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
12216 | 1491 if (imflags & GAIM_MESSAGE_AUTO_RESP) |
8971 | 1492 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); |
1493 else | |
1494 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1495 | |
1496 g_free(buf); | |
1497 | |
1498 return ret; | |
1499 } | |
1500 | |
1501 struct ask_do_dir_im { | |
1502 char *who; | |
1503 GaimConnection *gc; | |
1504 }; | |
1505 | |
1506 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1507 g_free(data->who); | |
1508 g_free(data); | |
1509 } | |
1510 | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1511 struct dir_im_listen { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1512 struct oscar_direct_im *dim; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1513 const guchar *cookie; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1514 }; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1515 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1516 static void |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1517 oscar_direct_im_listen_cb(int listenfd, gpointer data) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1518 struct dir_im_listen *dim_l = data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1519 const char *ip; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1520 OscarData *od; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1521 struct oscar_direct_im *dim = dim_l->dim; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1522 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1523 od = (OscarData *)dim->gc->proto_data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1524 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1525 /* XXX: shouldn't this be your public IP or something? */ |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1526 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1527 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1528 if (listenfd >= 0) |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1529 dim->conn = aim_odc_initiate(od->sess, dim->name, listenfd, |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1530 gaim_network_ip_atoi(ip), |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1531 gaim_network_get_port_from_fd(listenfd), dim_l->cookie); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1532 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1533 if (dim->conn != NULL) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1534 char *tmp; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1535 GaimConversation *conv; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1536 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1537 od->direct_ims = g_slist_append(od->direct_ims, dim); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1538 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1539 oscar_callback, dim->conn); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1540 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1541 gaim_odc_initiate, 0); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1542 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1543 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1544 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), dim->name, ip, |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1545 gaim_network_get_port_from_fd(listenfd)); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1546 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1547 g_free(tmp); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1548 } else { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1549 gaim_notify_error(dim->gc, NULL, _("Unable to open Direct IM"), NULL); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1550 oscar_direct_im_destroy(od, dim); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1551 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1552 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1553 g_free(dim_l); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1554 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1555 |
8983 | 1556 /* this function is used to initiate a direct im session with someone. |
1557 * we start listening on a port and send a request. they either connect | |
1558 * or send some kind of reply. If they can't connect, they ask us to | |
1559 * connect to them, and so we do that. | |
1560 * | |
1561 * this function will also get called if the other side initiate's a direct | |
1562 * im and we try to connect and fail. in that case cookie will not be null. | |
1563 * | |
1564 * note that cookie is an 8 byte string that isn't NULL terminated | |
1565 */ | |
11159 | 1566 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie) { |
8971 | 1567 OscarData *od; |
1568 struct oscar_direct_im *dim; | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1569 struct dir_im_listen *dim_l; |
8971 | 1570 |
1571 od = (OscarData *)gc->proto_data; | |
1572 | |
8983 | 1573 dim = oscar_direct_im_find(od, who); |
8971 | 1574 if (dim) { |
12918
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1575 /* TODO: we need to somehow not do this if we're waiting |
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1576 for the gaim_network_listen_range() call to finish */ |
8971 | 1577 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
1578 oscar_direct_im_disconnect(od, dim); | |
1579 gaim_debug_info("oscar", | |
1580 "Gave up on old direct IM, trying again\n"); | |
1581 } else { | |
1582 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1583 return; |
8971 | 1584 } |
1585 } | |
1586 dim = g_new0(struct oscar_direct_im, 1); | |
1587 dim->gc = gc; | |
8983 | 1588 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1589 |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1590 dim_l = g_new0(struct dir_im_listen, 1); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1591 dim_l->dim = dim; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1592 dim_l->cookie = cookie; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1593 |
12918
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1594 if(!gaim_network_listen_range(5190, 5199, SOCK_STREAM, |
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1595 oscar_direct_im_listen_cb, dim_l)) { |
8971 | 1596 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); |
1597 oscar_direct_im_destroy(od, dim); | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1598 g_free(dim_l); |
8971 | 1599 } |
8983 | 1600 } |
1601 | |
1602 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1603 GaimConnection *gc = data->gc; | |
1604 | |
1605 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1606 g_free(data->who); | |
1607 g_free(data); | |
1608 return; | |
1609 } | |
1610 | |
1611 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1612 g_free(data->who); |
1613 g_free(data); | |
1614 } | |
1615 | |
1616 /* this is the right click menu cb thingy */ | |
9030 | 1617 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1618 | |
1619 GaimBuddy *buddy; | |
1620 GaimConnection *gc; | |
8971 | 1621 gchar *buf; |
9030 | 1622 struct ask_do_dir_im *data; |
1623 | |
1624 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1625 | |
1626 buddy = (GaimBuddy *) node; | |
1627 gc = gaim_account_get_connection(buddy->account); | |
1628 | |
1629 data = g_new0(struct ask_do_dir_im, 1); | |
1630 data->who = g_strdup(buddy->name); | |
8971 | 1631 data->gc = gc; |
9030 | 1632 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1633 buddy->name); | |
8971 | 1634 |
1635 gaim_request_action(gc, NULL, buf, | |
9030 | 1636 _("Because this reveals your IP address, it " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1637 "may be considered a privacy risk. Do you " |
9030 | 1638 "wish to continue?"), |
1639 0, data, 2, | |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1640 _("_Connect"), G_CALLBACK(oscar_direct_im), |
9030 | 1641 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); |
8971 | 1642 g_free(buf); |
1643 } | |
1644 | |
1645 /***************************************************************************** | |
1646 * End scary direct im stuff | |
1647 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1648 |
4617 | 1649 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1650 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1651 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1652 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1653 OscarData *od; |
11369 | 1654 |
2086 | 1655 if (!gc) { |
8660 | 1656 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1657 "oscar callback for closed connection (1).\n"); |
2086 | 1658 return; |
1659 } | |
11369 | 1660 |
1661 if( !(od = (OscarData *)gc->proto_data) ) { | |
1662 gaim_debug_warning("oscar","NULL od in oscar_callback; conn closed?\n"); | |
1663 return; | |
1664 } | |
2086 | 1665 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1666 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1667 /* oh boy. this is probably bad. i guess the only thing we |
1668 * can really do is return? */ | |
8660 | 1669 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1670 "oscar callback for closed connection (2).\n"); |
8660 | 1671 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1672 return; |
1673 } | |
1674 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1675 if (condition & GAIM_INPUT_READ) { |
4617 | 1676 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1677 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1678 "got information on rendezvous listener\n"); |
4617 | 1679 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1680 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1681 "connection error (rendezvous listener)\n"); |
4617 | 1682 aim_conn_kill(od->sess, &conn); |
8446 | 1683 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1684 } |
1685 } else { | |
4617 | 1686 if (aim_get_command(od->sess, conn) >= 0) { |
1687 aim_rxdispatch(od->sess); | |
6029 | 1688 if (od->killme) { |
8660 | 1689 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1690 return; |
1691 } | |
2086 | 1692 } else { |
1693 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
11369 | 1694 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
10444 | 1695 { |
12588 | 1696 gaim_debug_error("oscar", "Major connection error " |
1697 "(invalid data was received on the oscar TCP stream).\n"); | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1698 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1699 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1700 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1701 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1702 char *buf; |
10458 | 1703 gaim_debug_info("oscar", "Lost connection " |
1704 "to chat room %s\n", cc->name); | |
1705 | |
1706 buf = g_strdup_printf(_("You have lost your connection " | |
1707 "to chat room %s."), cc->name); | |
1708 if (conv != NULL) | |
9627 | 1709 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1710 else | |
1711 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1712 g_free(buf); |
12617 | 1713 |
10458 | 1714 oscar_chat_kill(gc, cc); |
12617 | 1715 |
2086 | 1716 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1717 if (od->cnpa > 0) |
1718 gaim_input_remove(od->cnpa); | |
1719 od->cnpa = 0; | |
8660 | 1720 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1721 "removing chatnav input watcher\n"); |
4617 | 1722 while (od->create_rooms) { |
1723 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1724 g_free(cr->name); |
4617 | 1725 od->create_rooms = |
1726 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1727 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1728 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1729 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1730 NULL); |
2086 | 1731 } |
11369 | 1732 gaim_debug_info("oscar","killing rendezvous connection\n"); |
4617 | 1733 aim_conn_kill(od->sess, &conn); |
2086 | 1734 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1735 if (od->paspa > 0) |
1736 gaim_input_remove(od->paspa); | |
1737 od->paspa = 0; | |
8660 | 1738 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1739 "removing authconn input watcher\n"); |
4617 | 1740 aim_conn_kill(od->sess, &conn); |
3694 | 1741 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1742 if (od->emlpa > 0) |
1743 gaim_input_remove(od->emlpa); | |
1744 od->emlpa = 0; | |
8660 | 1745 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1746 "removing email input watcher\n"); |
4617 | 1747 aim_conn_kill(od->sess, &conn); |
4804 | 1748 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1749 if (od->icopa > 0) | |
1750 gaim_input_remove(od->icopa); | |
1751 od->icopa = 0; | |
8660 | 1752 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1753 "removing icon input watcher\n"); |
4804 | 1754 aim_conn_kill(od->sess, &conn); |
2086 | 1755 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1756 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1757 gaim_odc_disconnect(od->sess, conn); |
11214 | 1758 gaim_debug_info("oscar","killing rendezvous connection\n"); |
4617 | 1759 aim_conn_kill(od->sess, &conn); |
2086 | 1760 } else { |
8660 | 1761 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1762 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1763 conn->type); |
4617 | 1764 aim_conn_kill(od->sess, &conn); |
2086 | 1765 } |
1766 } | |
1767 } | |
1768 } | |
1769 } | |
1770 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1771 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1772 { |
5575 | 1773 GaimConnection *gc = data; |
7283 | 1774 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1775 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1776 aim_conn_t *conn; |
2086 | 1777 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1778 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1779 close(source); |
1780 return; | |
1781 } | |
1782 | |
4617 | 1783 od = gc->proto_data; |
1784 sess = od->sess; | |
2086 | 1785 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1786 conn->fd = source; |
2086 | 1787 |
1788 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1789 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1790 return; |
1791 } | |
1792 | |
1793 aim_conn_completeconnect(sess, conn); | |
4617 | 1794 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1795 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1796 | |
8660 | 1797 gaim_debug_info("oscar", |
7282 | 1798 "Screen name sent, waiting for response\n"); |
7283 | 1799 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1800 ck[1] = 0x65; |
2086 | 1801 } |
1802 | |
10444 | 1803 static void |
11837 | 1804 oscar_login(GaimAccount *account) |
10444 | 1805 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1806 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1807 aim_conn_t *conn; |
5575 | 1808 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1809 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1810 |
8660 | 1811 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1812 |
8437 | 1813 if (!aim_snvalid(gaim_account_get_username(account))) { |
1814 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1815 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 | 1816 gaim_connection_error(gc, buf); |
1817 g_free(buf); | |
1818 } | |
1819 | |
9975 | 1820 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1821 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1822 } else { |
6622 | 1823 gc->flags |= GAIM_CONNECTION_HTML; |
1824 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1825 } |
5836 | 1826 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1827 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1828 sess = g_new0(aim_session_t, 1); |
11253 | 1829 aim_session_init(sess, TRUE); |
7282 | 1830 /* |
11837 | 1831 * We need an immediate queue because we don't use a while-loop |
7282 | 1832 * to see if things need to be sent. |
1833 */ | |
2086 | 1834 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1835 od->sess = sess; |
2086 | 1836 sess->aux_data = gc; |
1837 | |
9935 | 1838 /* Connect to core Gaim signals */ |
10087 | 1839 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1840 |
11162 | 1841 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
2086 | 1842 if (conn == NULL) { |
10444 | 1843 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1844 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1845 return; |
1846 } | |
1847 | |
4649 | 1848 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1849 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1850 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1851 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1852 |
1853 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
11338 | 1854 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER), |
1855 gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), | |
5575 | 1856 oscar_login_connect, gc) < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1857 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1858 return; |
1859 } | |
7282 | 1860 |
7283 | 1861 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1862 ck[0] = 0x5a; |
5575 | 1863 } |
1864 | |
1865 static void oscar_close(GaimConnection *gc) { | |
7283 | 1866 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1867 |
1868 while (od->oscar_chats) { | |
1869 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1870 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1871 gaim_input_remove(n->inpa); |
2086 | 1872 g_free(n->name); |
1873 g_free(n->show); | |
4617 | 1874 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1875 g_free(n); |
1876 } | |
4617 | 1877 while (od->direct_ims) { |
8971 | 1878 struct oscar_direct_im *n = od->direct_ims->data; |
1879 oscar_direct_im_destroy(od, n); | |
2086 | 1880 } |
4617 | 1881 /* BBB */ |
1882 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1883 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1884 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1885 gaim_xfer_cancel_local(xfer); |
3630 | 1886 } |
4804 | 1887 while (od->requesticon) { |
1888 char *sn = od->requesticon->data; | |
1889 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1890 free(sn); | |
1891 } | |
4738 | 1892 g_hash_table_destroy(od->buddyinfo); |
4617 | 1893 while (od->create_rooms) { |
1894 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1895 g_free(cr->name); |
4617 | 1896 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1897 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1898 } |
4617 | 1899 if (od->email) |
1900 g_free(od->email); | |
1901 if (od->newp) | |
1902 g_free(od->newp); | |
1903 if (od->oldp) | |
1904 g_free(od->oldp); | |
2086 | 1905 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1906 gaim_input_remove(gc->inpa); |
4617 | 1907 if (od->cnpa > 0) |
1908 gaim_input_remove(od->cnpa); | |
1909 if (od->paspa > 0) | |
1910 gaim_input_remove(od->paspa); | |
1911 if (od->emlpa > 0) | |
1912 gaim_input_remove(od->emlpa); | |
4804 | 1913 if (od->icopa > 0) |
1914 gaim_input_remove(od->icopa); | |
6907 | 1915 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1916 gaim_timeout_remove(od->icontimer); |
8341 | 1917 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1918 gaim_timeout_remove(od->getblisttimer); |
8341 | 1919 if (od->getinfotimer > 0) |
1920 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1921 gaim_prefs_disconnect_by_handle(gc); |
12663 | 1922 |
4617 | 1923 aim_session_kill(od->sess); |
1924 g_free(od->sess); | |
1925 od->sess = NULL; | |
2086 | 1926 g_free(gc->proto_data); |
1927 gc->proto_data = NULL; | |
8660 | 1928 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1929 } |
1930 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1931 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1932 GaimConnection *gc = data; |
7283 | 1933 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1934 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1935 aim_conn_t *bosconn; |
2086 | 1936 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1937 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1938 close(source); |
1939 return; | |
1940 } | |
1941 | |
4617 | 1942 od = gc->proto_data; |
1943 sess = od->sess; | |
12653 | 1944 bosconn = od->conn; |
4366 | 1945 bosconn->fd = source; |
2086 | 1946 |
1947 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1948 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1949 return; |
1950 } | |
1951 | |
1952 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1953 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1954 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1955 gaim_connection_update_progress(gc, |
7283 | 1956 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1957 ck[4] = 0x61; |
2086 | 1958 } |
1959 | |
4617 | 1960 /* BBB */ |
4656 | 1961 /* |
12653 | 1962 * This little area in oscar.c is the nexus of file transfer code, |
1963 * so I wrote a little explanation of what happens. I am such a | |
4656 | 1964 * ninja. |
1965 * | |
1966 * The series of events for a file send is: | |
1967 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
12653 | 1968 * -User chooses a file and oscar_xfer_init is called. It establishes a |
1969 * listening socket, then asks the remote user to connect to us (and | |
4656 | 1970 * gives them the file name, port, IP, etc.) |
12653 | 1971 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens |
4656 | 1972 * in oscar_sendfile_estblsh) |
1973 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
12653 | 1974 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the |
4656 | 1975 * connection. |
1976 * -We get drunk because file transfer kicks ass. | |
1977 * | |
1978 * The series of events for a file receive is: | |
1979 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
12653 | 1980 * -Gaim user selects file to name and location to save file to and |
4656 | 1981 * oscar_xfer_init is called |
1982 * -It connects to the remote user using the IP they gave us earlier | |
12653 | 1983 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send |
4656 | 1984 * them an AIM_CB_OFT_ACK. |
1985 * -They begin to send us lots of raw data. | |
12653 | 1986 * -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
|
1987 * the connection. |
11369 | 1988 * |
1989 * Update August 2005: | |
1990 * The series of events for transfers has been seriously complicated by the addition | |
1991 * of transfer redirects and proxied connections. I could throw a whole lot of words | |
1992 * at trying to explain things here, but it probably wouldn't do much good. To get | |
1993 * a better idea of what happens, take a look at the diagrams and documentation | |
1994 * from my Summer of Code project. -- Jonathan Clark | |
4656 | 1995 */ |
1996 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
11369 | 1997 static void oscar_xfer_proxylogin(gpointer data, gint source, GaimInputCondition condition); |
1998 static void oscar_send_file_request(GaimXfer *xfer); | |
4656 | 1999 |
8446 | 2000 /* |
2001 * Miscellaneous xfer functions | |
2002 */ | |
2003 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 2004 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2005 GaimXfer *xfer; |
5146 | 2006 struct aim_oft_info *oft_info; |
4656 | 2007 |
2008 while (fts) { | |
2009 xfer = fts->data; | |
5146 | 2010 oft_info = xfer->data; |
2011 | |
8446 | 2012 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 2013 return xfer; |
2014 | |
2015 fts = g_slist_next(fts); | |
2016 } | |
2017 | |
2018 return NULL; | |
2019 } | |
2020 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2021 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 2022 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2023 GaimXfer *xfer; |
5146 | 2024 struct aim_oft_info *oft_info; |
4656 | 2025 |
2026 while (fts) { | |
2027 xfer = fts->data; | |
5146 | 2028 oft_info = xfer->data; |
2029 | |
2030 if (oft_info && (conn == oft_info->conn)) | |
4656 | 2031 return xfer; |
2032 | |
2033 fts = g_slist_next(fts); | |
2034 } | |
2035 | |
2036 return NULL; | |
2037 } | |
2038 | |
11369 | 2039 /* |
2040 * We're done sending/receiving raw data through the connection. | |
2041 * If we're the receiver, send an OFT header with the bytes received | |
2042 * filled in to indicate this party's over. | |
2043 */ | |
8446 | 2044 static void oscar_xfer_end(GaimXfer *xfer) |
2045 { | |
2046 struct aim_oft_info *oft_info = xfer->data; | |
2047 GaimConnection *gc = oft_info->sess->aux_data; | |
2048 OscarData *od = gc->proto_data; | |
2049 | |
8660 | 2050 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 2051 |
2052 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
2053 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
2054 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
2055 } | |
2056 | |
2057 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2058 aim_oft_destroyinfo(oft_info); | |
2059 xfer->data = NULL; | |
2060 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2061 } | |
2062 | |
2063 /* | |
2064 * xfer functions used when receiving files | |
2065 */ | |
2066 | |
11084 | 2067 /* |
11369 | 2068 * This is a gaim timeout callback called X milliseconds after a connection is attempted |
2069 * By this point, we've lost faith in the connection method we just tried and want to | |
2070 * try something new. Hopefully, that new connection method will be more successful, | |
2071 * otherwise, we'll end up here again and again until the connection is successful | |
2072 * or we've tried every method... if that happens we just throw our hands up | |
2073 * and inform the user of his bad karma. | |
2074 */ | |
2075 static gboolean oscar_xfer_ip_timeout(gpointer data) { | |
11084 | 2076 GaimXfer *xfer; |
13074 | 2077 GaimAccount *account; |
11084 | 2078 struct aim_oft_info *oft_info; |
2079 char *msg = NULL; | |
12653 | 2080 |
11369 | 2081 gaim_debug_info("oscar","AAA - in oscar_xfer_ip_timeout\n"); |
2082 | |
11084 | 2083 xfer = (GaimXfer*) data; |
13074 | 2084 account = gaim_xfer_get_account(xfer); |
11084 | 2085 if(xfer->data) { |
2086 oft_info = (struct aim_oft_info*) xfer->data; | |
12653 | 2087 |
11084 | 2088 /* Check to see if the clientip has produced any results */ |
11214 | 2089 if(!oft_info->success) { |
11369 | 2090 /* This connection has worn out its welcome. Goodbye. */ |
2091 if(oft_info->conn) { | |
2092 close(oft_info->conn->fd); | |
2093 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2094 } | |
12653 | 2095 |
2096 if(oft_info->method == AIM_XFER_DIRECT || oft_info->method == AIM_XFER_REDIR) { | |
11369 | 2097 /* If (we're currently using the verified ip) |
2098 * In case clientip & verifiedip are the same, | |
2099 * we must prevent an infinite loop */ | |
2100 if(xfer->remote_ip && oft_info->verifiedip | |
2101 && g_ascii_strcasecmp(xfer->remote_ip, oft_info->verifiedip) == 0 | |
2102 && g_ascii_strcasecmp(oft_info->clientip, oft_info->verifiedip) != 0 ) | |
2103 { | |
2104 /* The verifiedip timed out */ | |
13071 | 2105 if (oft_info->method == AIM_XFER_DIRECT && !oft_info->redir_attempted) |
2106 { | |
11369 | 2107 /* clientip & verifiedip failed, request a redirect |
13071 | 2108 * that is, we want the sender to connect to us |
2109 * | |
2110 * Above, we checked if we had previously attempted a connection | |
2111 * redirect to prevent a conflict with the joscar library | |
2112 */ | |
12653 | 2113 |
11369 | 2114 /* Let the user not to lose hope quite yet*/ |
2115 msg = g_strdup_printf(_("Attempting connection redirect...")); | |
2116 gaim_xfer_conversation_write(xfer, msg, FALSE); | |
2117 g_free(msg); | |
12653 | 2118 |
11369 | 2119 gaim_timeout_add(FT_REDIR_TIMEOUT, |
2120 oscar_xfer_ip_timeout, xfer); | |
2121 oft_info->method = AIM_XFER_REDIR; | |
13071 | 2122 oft_info->redir_attempted = TRUE; |
11369 | 2123 g_free(oft_info->proxyip); |
2124 oft_info->proxyip = NULL; | |
2125 oft_info->clientip = g_strdup( gaim_network_get_my_ip( | |
2126 oft_info->conn ? oft_info->conn->fd : -1)); | |
2127 oscar_xfer_init_send(xfer); | |
2128 } else { | |
2129 /* clientip, verifiedip, and redirect all failed. */ | |
2130 gaim_debug_info("oscar", | |
2131 "redirect timed out. requesting stg3 proxy\n"); | |
12653 | 2132 |
11369 | 2133 /* Kill our listener */ |
2134 gaim_input_remove(xfer->watcher); | |
2135 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
12653 | 2136 |
11369 | 2137 /* Instead of failing here, request a stage 3 proxy */ |
2138 g_free(oft_info->clientip); | |
2139 g_free(oft_info->verifiedip); | |
2140 oft_info->clientip = NULL; | |
2141 oft_info->verifiedip = NULL; | |
2142 oft_info->port = 0; | |
2143 oft_info->conn->type = AIM_CONN_TYPE_RENDEZVOUS; | |
2144 oft_info->method = AIM_XFER_PROXY; | |
2145 oft_info->stage = AIM_XFER_PROXY_STG3; | |
12653 | 2146 |
11369 | 2147 aim_im_sendch2_sendfile_ask(oft_info->sess, oft_info); |
2148 } | |
2149 } else { | |
2150 /* clientip timed out, now try verifiedip */ | |
2151 g_free(xfer->remote_ip); | |
2152 xfer->remote_ip = g_strdup(oft_info->verifiedip); | |
2153 gaim_debug_info("oscar","attempting connection using verifiedip\n"); | |
2154 oscar_xfer_init_recv(xfer); | |
2155 } | |
2156 } else if(oft_info->method == AIM_XFER_PROXY) { | |
2157 /* proxyip timed out | |
2158 * Yes, it's a bit odd to ask the user to enable proxied file transfers | |
2159 * when it's a proxied transfer that timed out. It is possible that a | |
13071 | 2160 * stage 1 or 2 proxied transfer might work when a stage 3 will not. */ |
13074 | 2161 msg = g_strdup_printf(_("Transfer of file %s timed out.\n Try enabling proxy servers for file transfers in Accounts->%s->Edit Account->Advanced."), |
2162 gaim_xfer_get_filename(xfer), gaim_account_get_username(account)); | |
11369 | 2163 gaim_xfer_conversation_write(xfer, msg, TRUE); |
2164 g_free(msg); | |
2165 gaim_xfer_cancel_local(xfer); | |
2166 if(oft_info->xfer_reffed) { | |
2167 oft_info->xfer_reffed = FALSE; | |
2168 gaim_xfer_unref(xfer); | |
2169 } | |
2170 } else { | |
2171 gaim_debug_warning("oscar","unknown xfer method encountered in timout\n"); | |
2172 } | |
11214 | 2173 } else { |
11369 | 2174 if(oft_info->xfer_reffed) { |
2175 oft_info->xfer_reffed = FALSE; | |
2176 gaim_xfer_unref(xfer); | |
2177 } | |
2178 gaim_debug_info("oscar","connection successful; timeout off\n"); | |
11084 | 2179 } |
11369 | 2180 } else { |
2181 gaim_debug_info("oscar","transfer already done; nothing to do\n"); | |
11084 | 2182 } |
2183 return FALSE; | |
2184 } | |
2185 | |
2186 /* | |
11369 | 2187 * Connect to another client or a file transfer proxy server. |
2188 * Though this function has traditionally only been used during file receives, | |
2189 * it is now called to make any sort of file transfer connection via gaim_proxy_connect. | |
11084 | 2190 */ |
8446 | 2191 static void oscar_xfer_init_recv(GaimXfer *xfer) |
2192 { | |
11369 | 2193 struct aim_oft_info *oft_info; |
2194 struct aim_rv_proxy_info *proxy_info; | |
2195 GaimConnection *gc; | |
2196 OscarData *od; | |
2197 GaimInputFunction nextstop_cb; | |
2198 int rc; | |
2199 | |
2200 g_return_if_fail(xfer != NULL); | |
2201 g_return_if_fail(xfer->data != NULL); | |
2202 | |
2203 oft_info = xfer->data; | |
2204 proxy_info = oft_info->proxy_info; | |
2205 gc = oft_info->sess->aux_data; | |
2206 od = gc->proto_data; | |
2207 | |
2208 gaim_debug_info("oscar", "AAA - in oscar_xfer_init_recv\n"); | |
13074 | 2209 |
11084 | 2210 /* Start a timer for this ip address |
11369 | 2211 * If the clientip fails, try the verifiedip |
2212 * If that fails, wait for the transfer to redirect | |
2213 * This xfer reference will be released in oscar_xfer_ip_timeout */ | |
2214 if(!oft_info->xfer_reffed) { | |
2215 oft_info->xfer_reffed = TRUE; | |
11084 | 2216 gaim_xfer_ref(xfer); |
11369 | 2217 } |
13074 | 2218 |
11369 | 2219 if(oft_info->method != AIM_XFER_PROXY) { |
2220 /* If (we're currently using the verified ip) | |
2221 * In case clientip & verifiedip are the same, we must prevent an infinite loop */ | |
2222 if(xfer->remote_ip && oft_info->verifiedip | |
2223 && g_ascii_strcasecmp(xfer->remote_ip, oft_info->verifiedip) == 0 | |
11084 | 2224 && g_ascii_strcasecmp(oft_info->clientip, oft_info->verifiedip) != 0 ) { |
11369 | 2225 gaim_timeout_add(FT_VERIFIEDIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); |
11084 | 2226 } else { |
11369 | 2227 gaim_timeout_add(FT_CLIENTIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); |
11084 | 2228 } |
11369 | 2229 } else { |
2230 gaim_timeout_add(FT_PROXYIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); | |
2231 } | |
11162 | 2232 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS); |
13074 | 2233 |
11369 | 2234 /* If we're routing this transfer through a AOL proxy server, do the special login |
2235 * before telling the other client we're ready for action. | |
2236 * Note, firststop_cb is the first function called after gaim has made a connection | |
2237 * Also, the connection type is changed until the proxy login is complete */ | |
2238 if(oft_info->method == AIM_XFER_PROXY) { | |
2239 if(proxy_info) | |
2240 proxy_info->conn = oft_info->conn; | |
2241 else { | |
2242 gaim_debug_warning("oscar","NULL proxy_info\n"); | |
2243 gaim_xfer_cancel_local(xfer); | |
2244 } | |
2245 nextstop_cb = oscar_xfer_proxylogin; | |
2246 oft_info->conn->type = AIM_CONN_TYPE_RENDEZVOUS_PROXY; | |
2247 } else { | |
2248 nextstop_cb = oscar_sendfile_connected; | |
2249 } | |
13074 | 2250 |
8446 | 2251 if (oft_info->conn) { |
2252 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
11369 | 2253 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, |
2254 oscar_sendfile_prompt, 0); | |
2255 rc = gaim_proxy_connect(gaim_connection_get_account(gc), | |
2256 xfer->remote_ip, xfer->remote_port, nextstop_cb, xfer); | |
2257 if (rc == -1) { | |
10654 | 2258 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2259 _("Unable to establish file descriptor.")); |
2260 gaim_xfer_cancel_local(xfer); | |
2261 } | |
2262 } else { | |
10654 | 2263 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
8446 | 2264 _("Unable to create new connection.")); |
2265 gaim_xfer_cancel_local(xfer); | |
2266 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2267 } | |
11369 | 2268 } |
2269 | |
2270 /* | |
2271 * "Never mind. This transfer wasn't such a great idea after all." | |
2272 */ | |
8446 | 2273 static void oscar_xfer_cancel_recv(GaimXfer *xfer) |
2274 { | |
11369 | 2275 struct aim_oft_info *oft_info = xfer->data; |
2276 GaimConnection *gc = oft_info->sess->aux_data; | |
2277 OscarData *od = gc->proto_data; | |
8446 | 2278 |
8660 | 2279 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2280 |
9771 | 2281 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2282 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2283 |
2284 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2285 aim_oft_destroyinfo(oft_info); | |
2286 xfer->data = NULL; | |
2287 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2288 } | |
2289 | |
11369 | 2290 /* |
2291 * Called after every data packet we receive | |
2292 */ | |
11159 | 2293 static void oscar_xfer_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2294 { |
2295 struct aim_oft_info *oft_info = xfer->data; | |
2296 | |
2297 /* Update our rolling checksum. Like Walmart, yo. */ | |
2298 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2299 } | |
2300 | |
2301 /* | |
11369 | 2302 * xfer functions used for proxied file transfers |
2303 */ | |
2304 | |
2305 /* | |
2306 * Called by oscar_send_proxylogin_cb when we receive a ready packet | |
2307 * BBB | |
2308 */ | |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
2309 static void oscar_xfer_proxylogin_ready(GaimXfer *xfer, gint fd) { |
11369 | 2310 struct aim_oft_info *oft_info; |
2311 struct aim_rv_proxy_info *proxy_info; | |
12653 | 2312 |
11369 | 2313 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_ready\n"); |
2314 if (!(oft_info = xfer->data)) { | |
2315 gaim_debug_warning("oscar","NULL oft_info; aborting\n"); | |
2316 gaim_xfer_cancel_local(xfer); | |
2317 return; | |
2318 } | |
2319 if (!(proxy_info = oft_info->proxy_info)) { | |
2320 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); | |
2321 gaim_xfer_cancel_local(xfer); | |
2322 return; | |
2323 } | |
12653 | 2324 |
11369 | 2325 /* Remove the rv proxy watcher and put the connection type back the way we found it */ |
2326 gaim_input_remove(xfer->watcher); | |
2327 xfer->watcher = 0; | |
2328 oft_info->conn->type = AIM_CONN_TYPE_RENDEZVOUS; | |
2329 | |
2330 if(oft_info->send_or_recv == AIM_XFER_SEND) { | |
12653 | 2331 |
11369 | 2332 if(oft_info->stage == AIM_XFER_PROXY_STG2) { |
2333 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); | |
12653 | 2334 |
11369 | 2335 /* For stage 2, both file headers are filled in */ |
2336 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
2337 } | |
12653 | 2338 |
11369 | 2339 /* The following is taken from oscar_sendfile_estblsh */ |
2340 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, | |
2341 oscar_sendfile_ack, 0); | |
2342 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, | |
2343 oscar_sendfile_done, 0); | |
2344 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, | |
2345 oft_info->conn); | |
12653 | 2346 |
11369 | 2347 /* Inform the other user that we are connected and ready to transfer */ |
2348 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_PROMPT, oft_info); | |
2349 } else if(oft_info->send_or_recv == AIM_XFER_RECV) { | |
2350 oscar_sendfile_connected(xfer, fd, GAIM_INPUT_READ); | |
2351 } else { | |
2352 gaim_debug_warning("oscar","no value for send_or_recv; aborting transfer\n"); | |
2353 gaim_xfer_cancel_local(xfer); | |
12653 | 2354 } |
11369 | 2355 } |
2356 | |
2357 /* | |
2358 * Called by oscar_sendfile_proxylogin_cb when we receive an ack packet in reply to an init_send | |
2359 * BBB | |
2360 */ | |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
2361 static void oscar_xfer_proxylogin_ack(GaimXfer *xfer) { |
11369 | 2362 struct aim_oft_info *oft_info; |
2363 struct aim_rv_proxy_info *proxy_info; | |
12653 | 2364 |
11369 | 2365 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_ack\n"); |
2366 if (!(oft_info = xfer->data)) { | |
2367 gaim_debug_warning("oscar","NULL oft_info; aborting\n"); | |
2368 gaim_xfer_cancel_local(xfer); | |
2369 return; | |
2370 } | |
2371 if (!(proxy_info = oft_info->proxy_info)) { | |
2372 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); | |
2373 gaim_xfer_cancel_local(xfer); | |
2374 return; | |
2375 } | |
12653 | 2376 |
11369 | 2377 /* Use the proxy "port" we just ACK-quired (hah) so that the proxy will love us */ |
2378 oft_info->port = proxy_info->port; | |
2379 oft_info->proxyip = g_strdup(proxy_info->ip); | |
2380 gaim_debug_info("oscar","received client ip and port: %s:%d\n", | |
2381 oft_info->proxyip, oft_info->port); | |
12653 | 2382 |
11369 | 2383 if(oft_info->send_or_recv == AIM_XFER_SEND) { |
2384 oscar_send_file_request(xfer); | |
2385 } else if(oft_info->send_or_recv == AIM_XFER_RECV) { | |
2386 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2387 oft_info->fh.name[63] = '\0'; | |
2388 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2389 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
12653 | 2390 |
11369 | 2391 /* Calculating the checksum can take a very long time for large files */ |
2392 gaim_debug_info("oscar","calculating file checksum\n"); | |
12653 | 2393 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); |
11369 | 2394 gaim_debug_info("oscar","checksum calculated\n"); |
12653 | 2395 |
11369 | 2396 aim_im_sendch2_sendfile_ask(oft_info->sess, oft_info); |
2397 } else { | |
2398 gaim_debug_warning("oscar","no value for send_or_recv; aborting transfer\n"); | |
2399 gaim_xfer_cancel_local(xfer); | |
2400 } | |
2401 } | |
2402 | |
2403 /* | |
2404 * This is called whenever we receive data while negotiating a rendezvous proxy connection | |
2405 * BBB | |
2406 */ | |
2407 static void oscar_xfer_proxylogin_cb(gpointer data, gint source, GaimInputCondition condition) { | |
2408 GaimXfer *xfer; | |
2409 struct aim_oft_info *oft_info; | |
12653 | 2410 |
11369 | 2411 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_cb\n"); |
2412 if (!(xfer = data)) { | |
2413 gaim_debug_warning("oscar","NULL xfer; aborting\n"); | |
2414 gaim_xfer_cancel_local(xfer); | |
2415 return; | |
12653 | 2416 } |
11369 | 2417 if (!(oft_info = xfer->data)) { |
2418 gaim_debug_warning("oscar","NULL oft_info; aborting\n"); | |
2419 gaim_xfer_cancel_local(xfer); | |
2420 return; | |
2421 } | |
12653 | 2422 |
11369 | 2423 if( (oft_info->proxy_info = aim_rv_proxy_read(oft_info->sess, oft_info->conn)) ) { |
12653 | 2424 |
11369 | 2425 switch(oft_info->proxy_info->cmd_type) { |
2426 case AIM_RV_PROXY_READY: | |
2427 oscar_xfer_proxylogin_ready(xfer, source); | |
2428 free(oft_info->proxy_info); | |
2429 oft_info->proxy_info = NULL; | |
2430 break; | |
2431 case AIM_RV_PROXY_ACK: | |
2432 oscar_xfer_proxylogin_ack(xfer); | |
2433 free(oft_info->proxy_info); | |
2434 oft_info->proxy_info = NULL; | |
2435 break; | |
2436 case AIM_RV_PROXY_ERROR: | |
2437 gaim_debug_info("oscar","error logging into rendezvous proxy; err code is %x\n", | |
2438 oft_info->proxy_info->err_code); | |
2439 gaim_input_remove(xfer->watcher); | |
2440 xfer->watcher = 0; | |
2441 free(oft_info->proxy_info); | |
2442 oft_info->proxy_info = NULL; | |
2443 gaim_xfer_cancel_remote(xfer); | |
2444 break; | |
2445 /* We should never get here */ | |
2446 default: | |
2447 gaim_debug_info("oscar","proxylogin switch defaulted unexpectedly\n"); | |
2448 } | |
2449 } else { | |
2450 gaim_debug_info("oscar","could not read rv proxy packet\n"); | |
2451 } | |
2452 } | |
2453 | |
2454 /* | |
2455 * Called to send necessary login data to a rendezvous proxy server once we're connected | |
2456 * Takes xfer is data and fd as source | |
2457 */ | |
2458 static void oscar_xfer_proxylogin(gpointer data, gint source, GaimInputCondition condition) | |
2459 { | |
2460 GaimXfer *xfer; | |
2461 struct aim_oft_info *oft_info; | |
2462 struct aim_rv_proxy_info *proxy_info; | |
2463 int err; | |
12653 | 2464 |
11369 | 2465 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin\n"); |
2466 if (!(xfer = data)) { | |
2467 gaim_debug_warning("oscar","NULL xfer; aborting\n"); | |
2468 gaim_xfer_cancel_local(xfer); | |
2469 return; | |
12653 | 2470 } |
11369 | 2471 if (!(oft_info = xfer->data)) { |
2472 gaim_debug_warning("oscar","NULL oft_info; aborting\n"); | |
2473 gaim_xfer_cancel_local(xfer); | |
2474 return; | |
2475 } | |
2476 if (!(proxy_info = oft_info->proxy_info)) { | |
2477 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); | |
2478 gaim_xfer_cancel_local(xfer); | |
2479 return; | |
2480 } | |
2481 if(oft_info->success) { | |
2482 gaim_debug_info("oscar","connection already successful, ignoring 2nd conn\n"); | |
2483 return; | |
2484 } | |
2485 | |
2486 xfer->fd = source; | |
2487 oft_info->conn->fd = source; | |
12653 | 2488 |
11369 | 2489 proxy_info->conn = oft_info->conn; |
2490 proxy_info->flags = AIM_RV_PROXY_CLIENT_FLAGS; | |
2491 memcpy(proxy_info->cookie, oft_info->cookie, 8); | |
12653 | 2492 |
11369 | 2493 if(oft_info->send_or_recv == AIM_XFER_SEND) { |
2494 if(oft_info->stage == AIM_XFER_PROXY_STG1 || oft_info->stage == AIM_XFER_PROXY_STG3) { | |
2495 gaim_debug_info("oscar","sending INIT SEND for stage 1/3 rv proxied send\n"); | |
2496 if( (err = aim_rv_proxy_init_send(proxy_info)) ) { | |
2497 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2498 _("Unable to log into file transfer proxy.")); | |
2499 gaim_debug_info("oscar", "error while sending INIT SEND rv proxy packet: %s\n", | |
2500 strerror(err)); | |
2501 gaim_xfer_cancel_local(xfer); | |
2502 } | |
2503 } else if(oft_info->stage == AIM_XFER_PROXY_STG2) { | |
2504 gaim_debug_info("oscar","sending INIT RECV for stage 2 rv proxied send\n"); | |
2505 if( (err = aim_rv_proxy_init_recv(proxy_info)) ) { | |
2506 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2507 _("Unable to log into file transfer proxy.")); | |
2508 gaim_debug_info("oscar", "error while sending INIT RECV rv proxy packet: %s\n", | |
2509 strerror(err)); | |
2510 gaim_xfer_cancel_local(xfer); | |
2511 } | |
2512 } else { | |
2513 gaim_debug_warning("oscar","no proxy type specified; aborting transfer\n"); | |
2514 gaim_xfer_cancel_local(xfer); | |
2515 } | |
2516 } else if(oft_info->send_or_recv == AIM_XFER_RECV) { | |
2517 if(oft_info->stage == AIM_XFER_PROXY_STG2) { | |
2518 gaim_debug_info("oscar","sending INIT SEND for stage 2 rv proxied receive\n"); | |
2519 if( (err = aim_rv_proxy_init_send(proxy_info)) ) { | |
2520 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2521 _("Unable to log into file transfer proxy.")); | |
2522 gaim_debug_info("oscar", "error while sending INIT SEND rv proxy packet: %s\n", | |
2523 strerror(err)); | |
2524 gaim_xfer_cancel_local(xfer); | |
2525 } | |
2526 } else if(oft_info->stage == AIM_XFER_PROXY_STG1 | |
2527 || oft_info->stage == AIM_XFER_PROXY_STG3) { | |
2528 gaim_debug_info("oscar","sending INIT RECV for stage 1/3 rv proxied receive\n"); | |
2529 if( (err = aim_rv_proxy_init_recv(proxy_info)) ) { | |
2530 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2531 _("Unable to log into file transfer proxy.")); | |
2532 gaim_debug_info("oscar", "error while sending INIT RECV rv proxy packet: %s\n", | |
2533 strerror(err)); | |
2534 gaim_xfer_cancel_local(xfer); | |
2535 } | |
2536 } else { | |
2537 gaim_debug_warning("oscar","no proxy type specified; aborting transfer\n"); | |
2538 gaim_xfer_cancel_local(xfer); | |
2539 } | |
2540 } else { | |
2541 gaim_debug_warning("oscar","no send_or_recv value specified; aborting\n"); | |
2542 gaim_xfer_cancel_local(xfer); | |
2543 } | |
2544 free(proxy_info); | |
2545 oft_info->proxy_info = NULL; | |
12653 | 2546 |
11369 | 2547 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_xfer_proxylogin_cb, xfer); |
2548 } | |
2549 | |
12653 | 2550 |
11369 | 2551 /* |
8446 | 2552 * xfer functions used when sending files |
2553 */ | |
2554 | |
11369 | 2555 /* |
2556 * Send a request to another client notifying them we want to sent a file | |
2557 */ | |
2558 static void oscar_send_file_request(GaimXfer *xfer) | |
2559 { | |
12653 | 2560 struct aim_oft_info *oft_info = xfer->data; |
11369 | 2561 GaimConnection *gc = oft_info->sess->aux_data; |
12653 | 2562 OscarData *od = gc->proto_data; |
2563 | |
11369 | 2564 gaim_debug_info("oscar", "AAA - in oscar_send_file_request\n"); |
12653 | 2565 |
11369 | 2566 if (oft_info->conn) { |
2567 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2568 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2569 oft_info->fh.name[63] = '\0'; | |
2570 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2571 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
12653 | 2572 |
11369 | 2573 /* Calculating the checksum can take a very long time for large files */ |
2574 gaim_debug_info("oscar","calculating file checksum\n"); | |
2575 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2576 gaim_debug_info("oscar","checksum calculated\n"); | |
2577 | |
2578 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
2579 | |
2580 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2581 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, | |
2582 AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2583 } else { | |
2584 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
2585 _("Unable to establish listener socket or no AOL proxy connection present.")); | |
2586 gaim_xfer_cancel_local(xfer); | |
2587 } | |
2588 } | |
2589 | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2590 static void |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2591 oscar_xfer_init_listen_cb(int listenfd, gpointer data) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2592 GaimXfer *xfer = data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2593 struct aim_oft_info *oft_info; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2594 GaimConnection *gc; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2595 OscarData *od; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2596 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2597 /* If the ft was canceled before we get here, don't continue */ |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2598 if(gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2599 gaim_xfer_unref(xfer); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2600 return; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2601 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2602 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2603 oft_info = xfer->data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2604 gc = oft_info->sess->aux_data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2605 od = gc->proto_data; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2606 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2607 if (listenfd < 0) { |
8446 | 2608 gaim_xfer_cancel_local(xfer); |
2609 return; | |
2610 } | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2611 |
8446 | 2612 xfer->local_port = gaim_network_get_port_from_fd(listenfd); |
2613 oft_info->port = xfer->local_port; | |
2614 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2615 gaim_xfer_cancel_local(xfer); | |
2616 return; | |
2617 } | |
8660 | 2618 gaim_debug_misc("oscar", |
8446 | 2619 "port is %hu, ip is %s\n", |
2620 xfer->local_port, oft_info->clientip); | |
12653 | 2621 |
11369 | 2622 if(oft_info->conn) |
2623 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, | |
2624 oft_info->conn); | |
2625 else | |
2626 gaim_debug_info("oscar","NULL oft_info->conn; not adding watcher\n"); | |
12653 | 2627 |
11369 | 2628 oscar_send_file_request(xfer); |
2629 } | |
2630 | |
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2631 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2632 /* |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2633 * Opens a listener socket in preparation for sending a file |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2634 * This is not called if we are using a rendezvous proxy server |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2635 */ |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2636 static void oscar_xfer_init_send(GaimXfer *xfer) |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2637 { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2638 gaim_debug_info("oscar", "AAA - in oscar_xfer_init_send\n"); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2639 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2640 gaim_xfer_ref(xfer); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2641 |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2642 /* Create a listening socket and an associated libfaim conn */ |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2643 if (!gaim_network_listen_range(5190, 5199, SOCK_STREAM, |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2644 oscar_xfer_init_listen_cb, xfer)) { |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2645 gaim_xfer_unref(xfer); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2646 gaim_xfer_cancel_local(xfer); |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2647 return; |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2648 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2649 } |
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2650 |
11369 | 2651 /* |
2652 * "On second thought, you don't deserve this file." | |
2653 */ | |
8446 | 2654 static void oscar_xfer_cancel_send(GaimXfer *xfer) |
2655 { | |
2656 struct aim_oft_info *oft_info = xfer->data; | |
2657 GaimConnection *gc = oft_info->sess->aux_data; | |
2658 OscarData *od = gc->proto_data; | |
2659 | |
8660 | 2660 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2661 |
9771 | 2662 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2663 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2664 |
11369 | 2665 /* Added a few sanity checks to prevent segfaulting */ |
2666 if(oft_info) { | |
2667 if(oft_info->sess && oft_info->conn) | |
2668 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2669 aim_oft_destroyinfo(oft_info); | |
2670 } | |
8446 | 2671 xfer->data = NULL; |
2672 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2673 } | |
2674 | |
11369 | 2675 /* |
2676 * Called when we send some data to the other client | |
2677 */ | |
11159 | 2678 static void oscar_xfer_ack_send(GaimXfer *xfer, const guchar *buffer, size_t size) |
8446 | 2679 { |
2680 struct aim_oft_info *oft_info = xfer->data; | |
2681 | |
2682 /* I'm not sure I like how we do this. --marv | |
2683 * I do. AIM file transfers aren't really meant to be thought | |
2684 * of as a transferring just a single file. The rendezvous | |
2685 * establishes a connection between two computers, and then | |
2686 * those computers can use the same connection for transferring | |
2687 * multiple files. So we don't want the Gaim core up and closing | |
2688 * the socket all willy-nilly. We want to do that in the oscar | |
2689 * prpl, whenever one side or the other says they're finished | |
2690 * using the connection. There might be a better way to intercept | |
2691 * the socket from the core, however... --KingAnt | |
2692 */ | |
2693 | |
2694 /* | |
2695 * If we're done sending, intercept the socket from the core ft code | |
2696 * and wait for the other guy to send the "done" OFT packet. | |
2697 */ | |
2698 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2699 gaim_input_remove(xfer->watcher); | |
2700 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2701 xfer->fd = 0; | |
2702 gaim_xfer_set_completed(xfer, TRUE); | |
2703 } | |
2704 } | |
2705 | |
11369 | 2706 /* |
2707 * Called by the Gaim core to determine whether or not we're allowed to send a file | |
2708 * to this user. | |
2709 */ | |
9466 | 2710 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2711 OscarData *od = gc->proto_data; | |
2712 | |
11049 | 2713 if (od != NULL) { |
9466 | 2714 aim_userinfo_t *userinfo; |
2715 userinfo = aim_locate_finduserinfo(od->sess, who); | |
12714 | 2716 |
2717 /* | |
2718 * Don't allowing sending a file to a user that does not support | |
2719 * file transfer, and don't allow sending to ourselves. | |
2720 */ | |
2721 if (userinfo && (userinfo->capabilities & AIM_CAPS_SENDFILE) && | |
12723 | 2722 aim_sncmp(who, gaim_account_get_username(gaim_connection_get_account(gc)))) |
12714 | 2723 { |
2724 return TRUE; | |
2725 } | |
13071 | 2726 |
12714 | 2727 } |
2728 | |
2729 return FALSE; | |
9466 | 2730 } |
2731 | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2732 static GaimXfer* |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2733 oscar_new_xfer(GaimConnection *gc, const char *who) { |
9030 | 2734 OscarData *od; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2735 GaimXfer *xfer; |
5146 | 2736 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2737 const char *ip; |
11369 | 2738 gboolean use_rv_proxy; |
2739 | |
2740 use_rv_proxy = gaim_prefs_get_bool("/plugins/prpl/oscar/use_rv_proxy"); | |
11401 | 2741 if(use_rv_proxy) |
11369 | 2742 gaim_debug_info("oscar","using stage 1 proxied transfer\n"); |
11401 | 2743 |
9030 | 2744 od = (OscarData *)gc->proto_data; |
2745 | |
4617 | 2746 /* You want to send a file to someone else, you're so generous */ |
2747 | |
2748 /* Build the file transfer handle */ | |
9466 | 2749 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2750 |
5146 | 2751 /* Create the oscar-specific data */ |
11369 | 2752 if (use_rv_proxy) { |
2753 /* This hostname will be resolved by gaim_proxy_connect */ | |
2754 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
2755 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
2756 oft_info = aim_oft_createinfo(od->sess, NULL /*cookie*/, who, 0 /*ip*/, 0, 0, 0, NULL, | |
2757 AIM_XFER_SEND, AIM_XFER_PROXY, AIM_XFER_PROXY_STG1); | |
2758 oft_info->proxy_info = aim_rv_proxy_createinfo(oft_info->sess, NULL, 0); | |
2759 /* We must create a cookie before the request is sent | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2760 * so that it can be sent to the proxy */ |
11401 | 2761 aim_icbm_makecookie(oft_info->cookie); |
11369 | 2762 } else { |
2763 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); | |
2764 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL, | |
2765 AIM_XFER_SEND, AIM_XFER_DIRECT, AIM_XFER_PROXY_NONE); | |
2766 } | |
5146 | 2767 xfer->data = oft_info; |
2768 | |
11369 | 2769 /* Setup our I/O op functions */ |
2770 if (use_rv_proxy) | |
11399 | 2771 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
11369 | 2772 else |
2773 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); | |
4617 | 2774 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2775 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2776 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2777 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2778 |
2779 /* Keep track of this transfer for later */ | |
2780 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2781 | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2782 return xfer; |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2783 } |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2784 |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2785 /* |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2786 * Called by the Gaim core when the user indicates that a file is to be sent to |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2787 * a special someone. |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2788 */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2789 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2790 GaimXfer *xfer = oscar_new_xfer(gc, who); |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2791 |
4617 | 2792 /* Now perform the request */ |
9466 | 2793 if (file) |
2794 gaim_xfer_request_accepted(xfer, file); | |
2795 else | |
2796 gaim_xfer_request(xfer); | |
3630 | 2797 } |
2798 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2799 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2800 GaimConnection *gc = sess->aux_data; |
7283 | 2801 OscarData *od = gc->proto_data; |
6029 | 2802 GaimAccount *account = gc->account; |
2803 aim_conn_t *bosconn; | |
2804 char *host; int port; | |
2805 int i, rc; | |
2086 | 2806 va_list ap; |
2704 | 2807 struct aim_authresp_info *info; |
6029 | 2808 |
11338 | 2809 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); |
2086 | 2810 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2811 va_start(ap, fr); |
2704 | 2812 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2813 va_end(ap); |
2814 | |
8660 | 2815 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2816 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2817 |
4293 | 2818 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2819 char buf[256]; |
2704 | 2820 switch (info->errorcode) { |
2086 | 2821 case 0x05: |
2822 /* Incorrect nick/password */ | |
6498 | 2823 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2824 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2825 break; |
2826 case 0x11: | |
2827 /* Suspended account */ | |
6498 | 2828 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2829 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2830 break; |
3498 | 2831 case 0x14: |
2832 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2833 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2834 break; |
2086 | 2835 case 0x18: |
2836 /* connecting too frequently */ | |
6498 | 2837 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2838 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 | 2839 break; |
2840 case 0x1c: | |
2841 /* client too old */ | |
6498 | 2842 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2843 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
|
2844 gaim_connection_error(gc, buf); |
2086 | 2845 break; |
2846 default: | |
6623 | 2847 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2848 break; |
2849 } | |
8660 | 2850 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2851 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2852 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2853 "Error URL: %s\n", info->errorurl); |
2086 | 2854 od->killme = TRUE; |
2855 return 1; | |
2856 } | |
2857 | |
2858 | |
9992 | 2859 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2860 |
2704 | 2861 if (info->email) { |
8660 | 2862 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2863 } else { |
8660 | 2864 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2865 } |
11369 | 2866 |
8660 | 2867 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2868 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2869 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2870 aim_conn_kill(sess, &fr->conn); |
2086 | 2871 |
11162 | 2872 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS); |
2086 | 2873 if (bosconn == NULL) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2874 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2875 od->killme = TRUE; |
2876 return 0; | |
2877 } | |
2878 | |
4649 | 2879 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2880 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2881 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2882 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2883 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2884 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2885 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2886 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2887 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2888 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2889 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2890 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2891 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2892 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2893 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2894 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2895 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2896 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2897 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2898 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2899 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
12189 | 2900 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_GOTINFOBLOCK, gaim_got_infoblock, 0); |
2086 | 2901 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2902 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
|
2903 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2904 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2905 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2906 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2907 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2908 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2909 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
|
2910 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
|
2911 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
|
2912 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2913 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2914 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4642 | 2915 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2916 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2917 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2918 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2919 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2920 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2921 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2922 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2923 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2924 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
|
2925 |
7283 | 2926 od->conn = bosconn; |
2704 | 2927 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2928 if (info->bosip[i] == ':') { | |
2929 port = atoi(&(info->bosip[i+1])); | |
2086 | 2930 break; |
2931 } | |
2932 } | |
2704 | 2933 host = g_strndup(info->bosip, i); |
2086 | 2934 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2935 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2936 g_free(host); |
4366 | 2937 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2938 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2939 od->killme = TRUE; |
2940 return 0; | |
2941 } | |
4293 | 2942 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2943 gaim_input_remove(gc->inpa); |
2704 | 2944 |
7283 | 2945 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2946 ck[3] = 0x64; |
7282 | 2947 |
2086 | 2948 return 1; |
2949 } | |
2950 | |
10464 | 2951 static void |
2952 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2953 { | |
2954 GaimConnection *gc = user_data; | |
2955 OscarData *od = gc->proto_data; | |
2956 aim_session_t *sess = od->sess; | |
2957 | |
2958 aim_auth_securid_send(sess, msg); | |
2959 } | |
2960 | |
2961 static void | |
2962 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2963 { | |
2964 GaimConnection *gc = user_data; | |
2965 OscarData *od = gc->proto_data; | |
2966 | |
2967 /* Disconnect */ | |
2968 gc->wants_to_die = TRUE; | |
2969 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2970 od->killme = TRUE; | |
2971 } | |
2972 | |
2973 static int | |
2974 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2975 { | |
2976 GaimConnection *gc = sess->aux_data; | |
2977 GaimAccount *account = gaim_connection_get_account(gc); | |
2978 gchar *primary; | |
2979 | |
2980 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2981 | |
2982 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2983 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2984 _("Enter the 6 digit number from the digital display."), | |
2985 FALSE, FALSE, NULL, | |
2986 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2987 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2988 gc); | |
2989 g_free(primary); | |
2990 | |
2991 return 1; | |
2992 } | |
2993 | |
7285 | 2994 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2995 struct pieceofcrap { |
5575 | 2996 GaimConnection *gc; |
2086 | 2997 unsigned long offset; |
2998 unsigned long len; | |
2999 char *modname; | |
3000 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3001 aim_conn_t *conn; |
2086 | 3002 unsigned int inpa; |
3003 }; | |
3004 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3005 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 3006 { |
3007 struct pieceofcrap *pos = data; | |
7283 | 3008 OscarData *od = pos->gc->proto_data; |
2086 | 3009 char in = '\0'; |
3010 int x = 0; | |
3011 unsigned char m[17]; | |
3012 | |
3013 while (read(pos->fd, &in, 1) == 1) { | |
3014 if (in == '\n') | |
3015 x++; | |
3016 else if (in != '\r') | |
3017 x = 0; | |
3018 if (x == 2) | |
3019 break; | |
3020 in = '\0'; | |
3021 } | |
3022 if (in != '\n') { | |
4056 | 3023 char buf[256]; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3024 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
|
3025 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3026 gaim_notify_warning(pos->gc, NULL, |
7422 | 3027 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3028 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3029 gaim_input_remove(pos->inpa); |
2086 | 3030 close(pos->fd); |
3031 g_free(pos); | |
3032 return; | |
3033 } | |
3034 read(pos->fd, m, 16); | |
3035 m[16] = '\0'; | |
8660 | 3036 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 3037 for (x = 0; x < 16; x++) |
8660 | 3038 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
3039 | |
3040 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3041 gaim_input_remove(pos->inpa); |
2086 | 3042 close(pos->fd); |
3043 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
3044 g_free(pos); | |
3045 } | |
3046 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3047 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 3048 struct pieceofcrap *pos = data; |
5420 | 3049 gchar *buf; |
2086 | 3050 |
4366 | 3051 pos->fd = source; |
3052 | |
2086 | 3053 if (source < 0) { |
5420 | 3054 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
|
3055 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3056 gaim_notify_warning(pos->gc, NULL, |
7422 | 3057 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3058 buf); |
5420 | 3059 g_free(buf); |
2086 | 3060 if (pos->modname) |
3061 g_free(pos->modname); | |
3062 g_free(pos); | |
3063 return; | |
3064 } | |
3065 | |
5420 | 3066 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 3067 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
3068 write(pos->fd, buf, strlen(buf)); | |
5420 | 3069 g_free(buf); |
2086 | 3070 if (pos->modname) |
3071 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3072 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 3073 return; |
3074 } | |
3075 | |
3076 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
3077 #define AIM_MAX_FILE_SIZE 98304 | |
3078 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3079 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3080 va_list ap; |
3081 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3082 fu32_t offset, len; |
2086 | 3083 char *modname; |
3084 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3085 va_start(ap, fr); |
4200 | 3086 offset = va_arg(ap, fu32_t); |
3087 len = va_arg(ap, fu32_t); | |
2086 | 3088 modname = va_arg(ap, char *); |
3089 va_end(ap); | |
3090 | |
8660 | 3091 gaim_debug_misc("oscar", |
5556 | 3092 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3093 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3094 |
2086 | 3095 if (len == 0) { |
8660 | 3096 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3097 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 3098 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
3099 return 1; | |
3100 } | |
9625 | 3101 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
3102 #if 0 | |
2086 | 3103 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
3104 char *buf; | |
3105 int i = 8; | |
3106 if (modname) | |
3107 i += strlen(modname); | |
3108 buf = g_malloc(i); | |
3109 i = 0; | |
3110 if (modname) { | |
3111 memcpy(buf, modname, strlen(modname)); | |
3112 i += strlen(modname); | |
3113 } | |
3114 buf[i++] = offset & 0xff; | |
3115 buf[i++] = (offset >> 8) & 0xff; | |
3116 buf[i++] = (offset >> 16) & 0xff; | |
3117 buf[i++] = (offset >> 24) & 0xff; | |
3118 buf[i++] = len & 0xff; | |
3119 buf[i++] = (len >> 8) & 0xff; | |
3120 buf[i++] = (len >> 16) & 0xff; | |
3121 buf[i++] = (len >> 24) & 0xff; | |
8660 | 3122 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3123 "hashing request\n"); |
2086 | 3124 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
3125 g_free(buf); | |
3126 return 1; | |
3127 } | |
9625 | 3128 #endif |
2086 | 3129 |
3130 pos = g_new0(struct pieceofcrap, 1); | |
3131 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3132 pos->conn = fr->conn; |
2086 | 3133 |
3134 pos->offset = offset; | |
3135 pos->len = len; | |
3136 pos->modname = modname ? g_strdup(modname) : NULL; | |
3137 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3138 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 3139 char buf[256]; |
2086 | 3140 if (pos->modname) |
3141 g_free(pos->modname); | |
3142 g_free(pos); | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3143 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
|
3144 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3145 gaim_notify_warning(pos->gc, NULL, |
7422 | 3146 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3147 buf); |
2086 | 3148 } |
3149 | |
3150 return 1; | |
3151 } | |
3152 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3153 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3154 GaimConnection *gc = sess->aux_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
3155 GaimAccount *account = gaim_connection_get_account(gc); |
12049 | 3156 struct client_info_s info = CLIENTINFO_GAIM; |
7011 | 3157 va_list ap; |
3158 char *key; | |
2086 | 3159 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3160 va_start(ap, fr); |
2086 | 3161 key = va_arg(ap, char *); |
3162 va_end(ap); | |
3163 | |
12049 | 3164 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
3165 gaim_connection_get_password(gc), &info, key); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3166 |
7283 | 3167 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 3168 ck[2] = 0x6c; |
7282 | 3169 |
2086 | 3170 return 1; |
3171 } | |
3172 | |
2675 | 3173 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3174 GaimConnection *gc = sess->aux_data; |
2647 | 3175 struct chat_connection *chatcon; |
3176 static int id = 1; | |
3177 | |
6905 | 3178 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
|
3179 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
|
3180 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
|
3181 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
|
3182 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 3183 |
2672 | 3184 aim_clientready(sess, fr->conn); |
2675 | 3185 |
2647 | 3186 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
3187 chatcon->id = id; | |
8733 | 3188 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 3189 |
3190 return 1; | |
3191 } | |
3192 | |
2675 | 3193 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
3194 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3195 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 3196 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 3197 |
3198 aim_clientready(sess, fr->conn); | |
3199 | |
3200 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3201 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3202 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3203 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3204 |
3694 | 3205 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
3206 | |
3207 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
3208 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
3209 | |
7282 | 3210 aim_email_sendcookies(sess); |
3211 aim_email_activate(sess); | |
3694 | 3212 aim_clientready(sess, fr->conn); |
3213 | |
3214 return 1; | |
3215 } | |
3216 | |
4804 | 3217 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3218 GaimConnection *gc = sess->aux_data; |
7283 | 3219 OscarData *od = gc->proto_data; |
4804 | 3220 |
3221 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
3222 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
3223 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
3224 | |
3225 aim_clientready(sess, fr->conn); | |
3226 | |
4823 | 3227 od->iconconnecting = FALSE; |
3228 | |
4804 | 3229 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3230 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3231 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 3232 |
3233 return 1; | |
3234 } | |
3235 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3236 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 3237 GaimConnection *gc = data; |
7283 | 3238 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3239 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3240 aim_conn_t *tstconn; |
2086 | 3241 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3242 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 3243 close(source); |
3244 return; | |
3245 } | |
3246 | |
4617 | 3247 od = gc->proto_data; |
3248 sess = od->sess; | |
2086 | 3249 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 3250 tstconn->fd = source; |
2086 | 3251 |
3252 if (source < 0) { | |
3253 aim_conn_kill(sess, &tstconn); | |
8660 | 3254 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3255 "unable to connect to chatnav server\n"); |
2086 | 3256 return; |
3257 } | |
3258 | |
3259 aim_conn_completeconnect(sess, tstconn); | |
4617 | 3260 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 3261 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 3262 } |
3263 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3264 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 3265 { |
5575 | 3266 GaimConnection *gc = data; |
7283 | 3267 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3268 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3269 aim_conn_t *tstconn; |
2086 | 3270 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3271 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 3272 close(source); |
3273 return; | |
3274 } | |
3275 | |
4617 | 3276 od = gc->proto_data; |
3277 sess = od->sess; | |
2086 | 3278 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 3279 tstconn->fd = source; |
2086 | 3280 |
3281 if (source < 0) { | |
3282 aim_conn_kill(sess, &tstconn); | |
8660 | 3283 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3284 "unable to connect to authorizer\n"); |
2086 | 3285 return; |
3286 } | |
3287 | |
3288 aim_conn_completeconnect(sess, tstconn); | |
4617 | 3289 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 3290 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 3291 } |
3292 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3293 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 3294 { |
3295 struct chat_connection *ccon = data; | |
5575 | 3296 GaimConnection *gc = ccon->gc; |
7283 | 3297 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3298 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3299 aim_conn_t *tstconn; |
2086 | 3300 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3301 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 3302 close(source); |
3303 g_free(ccon->show); | |
3304 g_free(ccon->name); | |
3305 g_free(ccon); | |
3306 return; | |
3307 } | |
3308 | |
4617 | 3309 od = gc->proto_data; |
3310 sess = od->sess; | |
2086 | 3311 tstconn = ccon->conn; |
4366 | 3312 tstconn->fd = source; |
2086 | 3313 |
3314 if (source < 0) { | |
3315 aim_conn_kill(sess, &tstconn); | |
3316 g_free(ccon->show); | |
3317 g_free(ccon->name); | |
3318 g_free(ccon); | |
3319 return; | |
3320 } | |
3321 | |
3322 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 3323 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
3324 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 3325 } |
3326 | |
3694 | 3327 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 3328 GaimConnection *gc = data; |
7283 | 3329 OscarData *od; |
3694 | 3330 aim_session_t *sess; |
3331 aim_conn_t *tstconn; | |
3332 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3333 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 3334 close(source); |
3335 return; | |
3336 } | |
3337 | |
4617 | 3338 od = gc->proto_data; |
3339 sess = od->sess; | |
3694 | 3340 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 3341 tstconn->fd = source; |
3694 | 3342 |
3343 if (source < 0) { | |
3344 aim_conn_kill(sess, &tstconn); | |
8660 | 3345 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3346 "unable to connect to email server\n"); |
3694 | 3347 return; |
3348 } | |
3349 | |
3350 aim_conn_completeconnect(sess, tstconn); | |
4617 | 3351 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 3352 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3353 "email: connected\n"); |
3694 | 3354 } |
3355 | |
4804 | 3356 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 3357 GaimConnection *gc = data; |
7283 | 3358 OscarData *od; |
4804 | 3359 aim_session_t *sess; |
3360 aim_conn_t *tstconn; | |
3361 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3362 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 3363 close(source); |
3364 return; | |
3365 } | |
3366 | |
3367 od = gc->proto_data; | |
3368 sess = od->sess; | |
3369 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
3370 tstconn->fd = source; | |
3371 | |
3372 if (source < 0) { | |
3373 aim_conn_kill(sess, &tstconn); | |
8660 | 3374 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3375 "unable to connect to icon server\n"); |
4804 | 3376 return; |
3377 } | |
3378 | |
3379 aim_conn_completeconnect(sess, tstconn); | |
3380 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 3381 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 3382 } |
3383 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3384 /* 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
|
3385 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3386 GaimConnection *gc = sess->aux_data; |
3387 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3388 aim_conn_t *tstconn; |
4452 | 3389 int i; |
2086 | 3390 char *host; |
3391 int port; | |
4821 | 3392 va_list ap; |
3393 struct aim_redirect_data *redir; | |
2086 | 3394 |
11338 | 3395 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); |
2086 | 3396 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3397 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3398 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3399 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3400 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3401 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3402 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3403 port = atoi(&(redir->ip[i+1])); |
2086 | 3404 break; |
3405 } | |
3406 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3407 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3408 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3409 switch(redir->group) { |
2086 | 3410 case 0x7: /* Authorizer */ |
8660 | 3411 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3412 "Reconnecting with authorizor...\n"); |
11162 | 3413 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
2086 | 3414 if (tstconn == NULL) { |
8660 | 3415 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3416 "unable to reconnect with authorizer\n"); |
2086 | 3417 g_free(host); |
3418 return 1; | |
3419 } | |
4649 | 3420 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 3421 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 3422 |
3423 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3424 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 3425 aim_conn_kill(sess, &tstconn); |
8660 | 3426 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3427 "unable to reconnect with authorizer\n"); |
2086 | 3428 g_free(host); |
3429 return 1; | |
3430 } | |
4293 | 3431 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 3432 break; |
3433 | |
2086 | 3434 case 0xd: /* ChatNav */ |
11162 | 3435 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV); |
2086 | 3436 if (tstconn == NULL) { |
8660 | 3437 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3438 "unable to connect to chatnav server\n"); |
2086 | 3439 g_free(host); |
3440 return 1; | |
3441 } | |
4649 | 3442 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 3443 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 3444 |
3445 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3446 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 3447 aim_conn_kill(sess, &tstconn); |
8660 | 3448 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3449 "unable to connect to chatnav server\n"); |
2086 | 3450 g_free(host); |
3451 return 1; | |
3452 } | |
4293 | 3453 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 3454 break; |
3455 | |
3456 case 0xe: { /* Chat */ | |
2086 | 3457 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3458 |
11162 | 3459 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT); |
2086 | 3460 if (tstconn == NULL) { |
8660 | 3461 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3462 "unable to connect to chat server\n"); |
2086 | 3463 g_free(host); |
3464 return 1; | |
3465 } | |
3466 | |
4649 | 3467 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 3468 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
3469 | |
2086 | 3470 ccon = g_new0(struct chat_connection, 1); |
3471 ccon->conn = tstconn; | |
3472 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3473 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3474 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3475 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3476 ccon->show = extract_name(redir->chat.room); |
4634 | 3477 |
2086 | 3478 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3479 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 3480 aim_conn_kill(sess, &tstconn); |
8660 | 3481 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3482 "unable to connect to chat server\n"); |
2086 | 3483 g_free(host); |
3484 g_free(ccon->show); | |
3485 g_free(ccon->name); | |
3486 g_free(ccon); | |
3487 return 1; | |
3488 } | |
4293 | 3489 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 3490 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3491 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3492 ccon->name, ccon->exchange); |
4194 | 3493 } break; |
3694 | 3494 |
4804 | 3495 case 0x0010: { /* icon */ |
11162 | 3496 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON))) { |
8660 | 3497 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3498 "unable to connect to icon server\n"); |
4804 | 3499 g_free(host); |
3500 return 1; | |
3501 } | |
3502 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
3503 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
3504 | |
3505 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3506 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 3507 aim_conn_kill(sess, &tstconn); |
8660 | 3508 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3509 "unable to connect to icon server\n"); |
4804 | 3510 g_free(host); |
3511 return 1; | |
3512 } | |
3513 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
3514 } break; | |
3515 | |
3694 | 3516 case 0x0018: { /* email */ |
11162 | 3517 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL))) { |
8660 | 3518 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3519 "unable to connect to email server\n"); |
3694 | 3520 g_free(host); |
3521 return 1; | |
3522 } | |
4649 | 3523 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 3524 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
3525 | |
3526 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3527 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 3528 aim_conn_kill(sess, &tstconn); |
8660 | 3529 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3530 "unable to connect to email server\n"); |
3694 | 3531 g_free(host); |
3532 return 1; | |
3533 } | |
4293 | 3534 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 3535 } break; |
3536 | |
2086 | 3537 default: /* huh? */ |
8660 | 3538 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3539 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3540 redir->group); |
2086 | 3541 break; |
3542 } | |
3543 | |
3544 g_free(host); | |
3545 return 1; | |
3546 } | |
3547 | |
10042 | 3548 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
3549 { | |
3550 GaimConnection *gc; | |
3551 GaimAccount *account; | |
11973 | 3552 GaimPresence *presence; |
10042 | 3553 OscarData *od; |
4738 | 3554 struct buddyinfo *bi; |
2993 | 3555 time_t time_idle = 0, signon = 0; |
3556 int type = 0; | |
12349 | 3557 gboolean buddy_is_away = FALSE; |
3558 const char *status_id; | |
3559 gboolean have_status_message = FALSE; | |
3560 char *message = NULL; | |
2086 | 3561 va_list ap; |
4738 | 3562 aim_userinfo_t *info; |
10042 | 3563 |
3564 gc = sess->aux_data; | |
3565 account = gaim_connection_get_account(gc); | |
11973 | 3566 presence = gaim_account_get_presence(account); |
10042 | 3567 od = gc->proto_data; |
4194 | 3568 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3569 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3570 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3571 va_end(ap); |
11973 | 3572 |
10130 | 3573 g_return_val_if_fail(info != NULL, 1); |
3574 g_return_val_if_fail(info->sn != NULL, 1); | |
3575 | |
4766 | 3576 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
3577 if (info->flags & AIM_FLAG_AWAY) | |
11369 | 3578 buddy_is_away = TRUE; |
3579 } | |
2993 | 3580 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
11510 | 3581 type = info->icqinfo.status; |
3013 | 3582 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
3583 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 3584 buddy_is_away = TRUE; |
3013 | 3585 } |
2993 | 3586 } |
3587 | |
12349 | 3588 if (aim_sn_is_icq(info->sn)) { |
3589 if (type & AIM_ICQ_STATE_CHAT) | |
3590 status_id = OSCAR_STATUS_ID_FREE4CHAT; | |
3591 else if (type & AIM_ICQ_STATE_DND) | |
3592 status_id = OSCAR_STATUS_ID_DND; | |
3593 else if (type & AIM_ICQ_STATE_OUT) | |
3594 status_id = OSCAR_STATUS_ID_NA; | |
3595 else if (type & AIM_ICQ_STATE_BUSY) | |
3596 status_id = OSCAR_STATUS_ID_OCCUPIED; | |
3597 else if (type & AIM_ICQ_STATE_AWAY) | |
3598 status_id = OSCAR_STATUS_ID_AWAY; | |
3599 else if (type & AIM_ICQ_STATE_INVISIBLE) | |
3600 status_id = OSCAR_STATUS_ID_INVISIBLE; | |
3601 else | |
3602 status_id = OSCAR_STATUS_ID_AVAILABLE; | |
3603 } else { | |
12653 | 3604 if (buddy_is_away) |
12349 | 3605 status_id = OSCAR_STATUS_ID_AWAY; |
3606 else | |
3607 status_id = OSCAR_STATUS_ID_AVAILABLE; | |
3608 } | |
3609 | |
3610 /* | |
3611 * Handle the available message. If info->status is NULL then the user | |
3612 * may or may not have an available message, so don't do anything. If | |
3613 * info->status is set to the empty string, then the user's client DOES | |
3614 * support available messages and the user DOES NOT have one set. | |
3615 * Otherwise info->status contains the available message. | |
3616 */ | |
3617 if (info->status != NULL) | |
3618 { | |
3619 have_status_message = TRUE; | |
3620 if (info->status[0] != '\0') | |
3621 message = oscar_encoding_to_utf8(info->status_encoding, | |
3622 info->status, info->status_len); | |
3623 } | |
3624 | |
3625 if (have_status_message) | |
3626 { | |
3627 gaim_prpl_got_user_status(account, info->sn, status_id, | |
3628 "message", message, NULL); | |
3629 g_free(message); | |
3630 } | |
3631 else | |
3632 gaim_prpl_got_user_status(account, info->sn, status_id, NULL); | |
3633 | |
12350 | 3634 /* Login time stuff */ |
5836 | 3635 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3636 signon = info->onlinesince; | |
3637 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3638 signon = time(NULL) - info->sessionlen; |
10567 | 3639 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
5575 | 3640 gaim_connection_set_display_name(gc, info->sn); |
11973 | 3641 od->timeoffset = signon - gaim_presence_get_login_time(presence); |
10567 | 3642 } |
12350 | 3643 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
3644 | |
3645 /* Idle time stuff */ | |
3646 /* info->idletime is the number of minutes that this user has been idle */ | |
3647 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
3648 time_idle = time(NULL) - info->idletime * 60; | |
3649 | |
3650 if (time_idle > 0) | |
3651 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
3652 else | |
3653 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
3654 | |
3655 /* Server stored icon stuff */ | |
9982 | 3656 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3657 if (!bi) { |
3658 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3659 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3660 } |
4739 | 3661 bi->typingnot = FALSE; |
3662 bi->ico_informed = FALSE; | |
6857 | 3663 bi->ipaddr = info->icqinfo.ipaddr; |
3664 | |
4853 | 3665 if (info->iconcsumlen) { |
7125 | 3666 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3667 char *b16 = NULL, *filepath = NULL; |
7093 | 3668 GaimBuddy *b = NULL; |
4853 | 3669 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3670 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3671 b = gaim_find_buddy(account, info->sn); |
7093 | 3672 /* |
3673 * If for some reason the checksum is valid, but cached file is not.. | |
3674 * we want to know. | |
3675 */ | |
7693 | 3676 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3677 if (filename != NULL) { |
3678 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3679 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3680 "icon_checksum"); | |
9801 | 3681 else { |
3682 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3683 filename, NULL); | |
3684 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3685 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3686 "icon_checksum"); | |
3687 g_free(filepath); | |
3688 } | |
7093 | 3689 } else |
3690 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3691 |
4853 | 3692 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3693 GSList *cur = od->requesticon; | |
3694 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3695 cur = cur->next; | |
3696 if (!cur) { | |
9982 | 3697 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3698 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3699 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3700 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3701 } |
3702 } | |
6053 | 3703 g_free(b16); |
4853 | 3704 } |
3705 | |
2086 | 3706 return 1; |
3707 } | |
3708 | |
8341 | 3709 static void gaim_check_comment(OscarData *od, const char *str) { |
11159 | 3710 if ((str == NULL) || strcmp(str, (const char *)ck)) |
8341 | 3711 aim_locate_setcaps(od->sess, caps_aim); |
3712 else | |
3713 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3714 } | |
3715 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3716 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3717 GaimConnection *gc = sess->aux_data; |
7283 | 3718 OscarData *od = gc->proto_data; |
9982 | 3719 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3720 va_list ap; |
4739 | 3721 aim_userinfo_t *info; |
2086 | 3722 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3723 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3724 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3725 va_end(ap); |
3726 | |
12349 | 3727 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3728 |
7261 | 3729 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3730 |
2086 | 3731 return 1; |
3732 } | |
3733 | |
4617 | 3734 /* BBB */ |
3952 | 3735 /* |
11369 | 3736 * This is called after a remote AIM user has connected to us. |
3737 * If not using a rendezvous proxy, then we want to do some | |
3738 * voodoo with the socket file descriptors. Then we always | |
3739 * add a callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3740 */ |
4656 | 3741 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3742 GaimConnection *gc = sess->aux_data; |
7283 | 3743 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3744 GaimXfer *xfer; |
5146 | 3745 struct aim_oft_info *oft_info; |
3630 | 3746 va_list ap; |
3747 aim_conn_t *conn, *listenerconn; | |
4656 | 3748 |
11369 | 3749 gaim_debug_info("oscar", "AAA - in oscar_sendfile_estblsh\n"); |
3750 | |
3630 | 3751 va_start(ap, fr); |
3752 conn = va_arg(ap, aim_conn_t *); | |
3753 listenerconn = va_arg(ap, aim_conn_t *); | |
3754 va_end(ap); | |
3755 | |
11369 | 3756 /* Finding by conn will work for proxied connections only |
3757 * Finding by listenerconn will work for direct connections only */ | |
3758 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) { | |
3759 if(!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) { | |
3760 gaim_debug_warning("oscar","xfer not found via connection\n"); | |
3761 return 1; | |
3762 } | |
3763 } | |
3764 if (!(oft_info = xfer->data)) { | |
3765 gaim_debug_warning("oscar","NULL data\n"); | |
4617 | 3766 return 1; |
11369 | 3767 } |
3768 | |
3769 /* Mark connection as success so further connections aren't attempted | |
3770 * This is important here since some receive file code paths pass through here */ | |
3771 oft_info->success = TRUE; | |
3772 | |
3773 if(oft_info->method != AIM_XFER_PROXY) { | |
3774 /* Stop watching listener conn; watch transfer conn instead */ | |
3775 gaim_input_remove(xfer->watcher); | |
3776 | |
3777 aim_conn_kill(sess, &listenerconn); | |
3778 | |
3779 oft_info->conn = conn; | |
3780 xfer->fd = oft_info->conn->fd; | |
3781 } | |
3782 | |
5146 | 3783 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); |
11369 | 3784 |
3785 if(oft_info->send_or_recv == AIM_XFER_SEND) { | |
3786 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, | |
3787 oscar_sendfile_ack, 0); | |
3788 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, | |
3789 oscar_sendfile_done, 0); | |
3790 | |
3791 /* Inform the other user that we are connected and ready to transfer */ | |
3792 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); | |
3793 } | |
3794 | |
3795 /* For a file send, we'll hopefully end up in oscar_sendfile_ack next | |
3796 * For a file receive, oscar_sendfile_prompt */ | |
3797 | |
3630 | 3798 return 0; |
3799 } | |
3800 | |
3952 | 3801 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3802 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
11369 | 3803 * user in order to transfer a file |
3804 * Takes xfer as data and fd as source | |
3805 * BBB | |
3952 | 3806 */ |
4617 | 3807 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
|
3808 GaimXfer *xfer; |
5146 | 3809 struct aim_oft_info *oft_info; |
4656 | 3810 |
8660 | 3811 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3812 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3813 if (!(xfer = data)) |
3814 return; | |
5146 | 3815 if (!(oft_info = xfer->data)) |
3630 | 3816 return; |
11369 | 3817 if(oft_info->success) { |
3818 gaim_debug_info("oscar","connection already successful; ignoring 2nd conn\n"); | |
3819 return; | |
3820 } | |
8446 | 3821 if (source < 0) { |
11369 | 3822 gaim_debug_info("oscar","received fd of %d; aborting transfer\n", source); |
3823 gaim_xfer_cancel_remote(xfer); | |
3824 return; | |
3825 } | |
3826 oft_info->success = TRUE; /* Mark this connection as successful before it times out */ | |
11214 | 3827 |
11369 | 3828 /* We might have already set these in oscar_sendfile_proxylogin, but it won't |
3829 * hurt to do it again since it is rather necessary */ | |
4617 | 3830 xfer->fd = source; |
5146 | 3831 oft_info->conn->fd = source; |
11369 | 3832 |
5146 | 3833 aim_conn_completeconnect(oft_info->sess, oft_info->conn); |
11369 | 3834 |
5146 | 3835 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); |
4617 | 3836 |
11369 | 3837 /* Inform the other user that we are connected and accept the transfer |
3838 * Except for a stage 2 receive, then we'll be the ones receiving this accept message */ | |
3839 if(oft_info->stage != AIM_XFER_PROXY_STG2) | |
3840 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); | |
3841 | |
3842 /* Don't wait around if this is a redirected send */ | |
3843 if(oft_info->send_or_recv == AIM_XFER_SEND) { | |
3844 /* We should only get here if this is a redirected file send */ | |
3845 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, | |
3846 oscar_sendfile_ack, 0); | |
3847 aim_conn_addhandler(oft_info->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, | |
3848 oscar_sendfile_done, 0); | |
3849 | |
3850 /* Inform the other user that we are ready to transfer */ | |
3851 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_PROMPT, oft_info); | |
3852 } | |
3630 | 3853 } |
3854 | |
3952 | 3855 /* |
4617 | 3856 * This is called when a buddy sends us some file info. This happens when they |
3857 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3858 * You should send them the exact same info except use the real cookie. We also |
4617 | 3859 * get like totally ready to like, receive the file, kay? |
3952 | 3860 */ |
4617 | 3861 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3862 GaimConnection *gc = sess->aux_data; |
7283 | 3863 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3864 GaimXfer *xfer; |
5146 | 3865 struct aim_oft_info *oft_info; |
4617 | 3866 va_list ap; |
3867 aim_conn_t *conn; | |
3868 fu8_t *cookie; | |
3869 struct aim_fileheader_t *fh; | |
11369 | 3870 |
8660 | 3871 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3872 "AAA - in oscar_sendfile_prompt\n"); |
11369 | 3873 |
4617 | 3874 va_start(ap, fr); |
3875 conn = va_arg(ap, aim_conn_t *); | |
3876 cookie = va_arg(ap, fu8_t *); | |
3877 fh = va_arg(ap, struct aim_fileheader_t *); | |
3878 va_end(ap); | |
3879 | |
3880 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3881 return 1; | |
3882 | |
5146 | 3883 if (!(oft_info = xfer->data)) |
4617 | 3884 return 1; |
3885 | |
3886 /* We want to stop listening with a normal thingy */ | |
3887 gaim_input_remove(xfer->watcher); | |
3888 xfer->watcher = 0; | |
3889 | |
5146 | 3890 /* They sent us some information about the file they're sending */ |
3891 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3892 | |
3893 /* Fill in the cookie */ | |
3894 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3895 | |
4617 | 3896 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3897 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3898 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3899 | |
3900 return 0; | |
3630 | 3901 } |
3902 | |
3952 | 3903 /* |
4657 | 3904 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3905 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3906 */ |
4617 | 3907 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3908 GaimConnection *gc = sess->aux_data; |
7283 | 3909 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3910 GaimXfer *xfer; |
4617 | 3911 va_list ap; |
3912 aim_conn_t *conn; | |
3913 fu8_t *cookie; | |
3914 struct aim_fileheader_t *fh; | |
4656 | 3915 |
8660 | 3916 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3917 va_start(ap, fr); |
3918 conn = va_arg(ap, aim_conn_t *); | |
3919 cookie = va_arg(ap, fu8_t *); | |
3920 fh = va_arg(ap, struct aim_fileheader_t *); | |
3921 va_end(ap); | |
3922 | |
3923 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3924 return 1; | |
3925 | |
4656 | 3926 /* We want to stop listening with a normal thingy */ |
3927 gaim_input_remove(xfer->watcher); | |
3928 xfer->watcher = 0; | |
3929 | |
4617 | 3930 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3931 | |
3932 return 0; | |
3630 | 3933 } |
4617 | 3934 |
3935 /* | |
3936 * We just sent a file to someone. They said they got it and everything, | |
3937 * so we can close our direct connection and what not. | |
3938 */ | |
3939 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3940 GaimConnection *gc = sess->aux_data; |
7283 | 3941 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3942 GaimXfer *xfer; |
4617 | 3943 va_list ap; |
3944 aim_conn_t *conn; | |
3945 fu8_t *cookie; | |
3946 struct aim_fileheader_t *fh; | |
11369 | 3947 struct aim_oft_info *oft_info; |
4656 | 3948 |
8660 | 3949 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3950 va_start(ap, fr); |
3951 conn = va_arg(ap, aim_conn_t *); | |
3952 cookie = va_arg(ap, fu8_t *); | |
3953 fh = va_arg(ap, struct aim_fileheader_t *); | |
3954 va_end(ap); | |
3955 | |
11369 | 3956 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) { |
3957 gaim_debug_warning("oscar","xfer not found\n"); | |
4617 | 3958 return 1; |
11369 | 3959 } |
3960 if(!(oft_info = xfer->data)) { | |
3961 gaim_debug_warning("oscar","NULL oft_info\n"); | |
3962 return 1; | |
3963 } | |
3964 if(fh->nrecvd == fh->size) | |
3965 gaim_xfer_set_completed(xfer, TRUE); | |
4617 | 3966 |
4656 | 3967 xfer->fd = conn->fd; |
4617 | 3968 gaim_xfer_end(xfer); |
3969 | |
3970 return 0; | |
3971 } | |
3630 | 3972 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3973 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3974 GaimConnection *gc = sess->aux_data; |
7283 | 3975 OscarData *od = gc->proto_data; |
8708 | 3976 GaimAccount *account = gaim_connection_get_account(gc); |
12216 | 3977 GaimMessageFlags flags = 0; |
4738 | 3978 struct buddyinfo *bi; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
3979 char *iconfile; |
9806 | 3980 GString *message; |
3981 gchar *tmp; | |
3982 aim_mpmsg_section_t *curpart; | |
12675 | 3983 const char *start; |
3984 const char *end; | |
3985 GData *attribs; | |
9806 | 3986 |
11537 | 3987 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3988 userinfo->sn, args->mpmsg.numparts); |
4738 | 3989 |
10595 | 3990 if (args->mpmsg.numparts == 0) |
3991 return 1; | |
3992 | |
8708 | 3993 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3994 if (!bi) { |
3995 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3996 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3997 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3998 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3999 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
12216 | 4000 flags |= GAIM_MESSAGE_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4001 |
4738 | 4002 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
4003 bi->typingnot = TRUE; | |
4004 else | |
4005 bi->typingnot = FALSE; | |
4006 | |
4380 | 4007 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 4008 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4009 "%s has an icon\n", userinfo->sn); |
4738 | 4010 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
4011 bi->ico_need = TRUE; | |
4012 bi->ico_len = args->iconlen; | |
4013 bi->ico_csum = args->iconsum; | |
4014 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4015 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4016 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4017 |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4018 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
|
4019 if ((iconfile != NULL) && |
7406 | 4020 (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
|
4021 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4022 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4023 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4024 if (!g_stat(iconfile, &st)) { |
11159 | 4025 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4026 file = g_fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4027 if (file) { |
9532 | 4028 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
4029 int len = fread(buf, 1, st.st_size, file); |
8660 | 4030 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4031 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4032 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4033 userinfo->sn, len, st.st_size); |
4617 | 4034 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
4035 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4036 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
4037 } else |
8660 | 4038 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4039 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4040 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
4041 } else |
8660 | 4042 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4043 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4044 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4045 g_free(iconfile); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4046 |
9806 | 4047 message = g_string_new(""); |
4048 curpart = args->mpmsg.parts; | |
4049 while (curpart != NULL) { | |
11159 | 4050 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, |
12675 | 4051 curpart->charsubset, curpart->data, curpart->datalen); |
9806 | 4052 if (tmp != NULL) { |
4053 g_string_append(message, tmp); | |
4054 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4055 } |
9806 | 4056 |
4057 curpart = curpart->next; | |
4058 } | |
4059 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4060 |
8666 | 4061 /* |
10781 | 4062 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
9016 | 4063 * because HTML is not sent over ICQ as a means to format a message. |
10781 | 4064 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
4065 * replaced with <br> | |
8995 | 4066 * |
4067 * Note: There *may* be some clients which send messages as HTML formatted - | |
4068 * they need to be special-cased somehow. | |
8666 | 4069 */ |
9982 | 4070 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 4071 /* 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
|
4072 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
8493 | 4073 g_free(tmp); |
4074 tmp = tmp2; | |
10783 | 4075 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
10781 | 4076 g_free(tmp); |
4077 tmp = tmp2; | |
8493 | 4078 } |
4079 | |
12675 | 4080 /* |
4081 * Convert iChat color tags to normal font tags. | |
4082 */ | |
4083 if (gaim_markup_find_tag("body", tmp, &start, &end, &attribs)) | |
4084 { | |
4085 const char *ichattextcolor, *ichatballooncolor; | |
4086 | |
4087 ichattextcolor = g_datalist_get_data(&attribs, "ichattextcolor"); | |
4088 if (ichattextcolor != NULL) | |
4089 { | |
4090 gchar *tmp2; | |
4091 tmp2 = g_strdup_printf("<font color=\"%s\">%s</font>", ichattextcolor, tmp); | |
4092 g_free(tmp); | |
4093 tmp = tmp2; | |
4094 } | |
4095 | |
4096 ichatballooncolor = g_datalist_get_data(&attribs, "ichatballooncolor"); | |
4097 if (ichatballooncolor != NULL) | |
4098 { | |
4099 gchar *tmp2; | |
4100 tmp2 = g_strdup_printf("<font back=\"%s\">%s</font>", ichatballooncolor, tmp); | |
4101 g_free(tmp); | |
4102 tmp = tmp2; | |
4103 } | |
4104 | |
4105 g_datalist_clear(&attribs); | |
4106 } | |
4107 | |
6982 | 4108 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4109 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4110 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4111 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4112 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4113 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4114 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 4115 GaimConnection *gc; |
9933 | 4116 GaimAccount *account; |
9070 | 4117 OscarData *od; |
9933 | 4118 const char *username = NULL; |
4119 char *message = NULL; | |
9070 | 4120 |
4121 g_return_val_if_fail(sess != NULL, 0); | |
4122 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
4123 | |
4124 gc = sess->aux_data; | |
9933 | 4125 account = gaim_connection_get_account(gc); |
9070 | 4126 od = gc->proto_data; |
9933 | 4127 username = gaim_account_get_username(account); |
4128 | |
4129 if (args == NULL) | |
4121 | 4130 return 0; |
4194 | 4131 |
9933 | 4132 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
4133 userinfo->sn, args->status); | |
4134 | |
4135 if (args->msg != NULL) | |
4136 { | |
4137 if (args->encoding != NULL) | |
4138 { | |
4139 char *encoding = NULL; | |
4140 encoding = oscar_encoding_extract(args->encoding); | |
4141 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
4142 g_free(encoding); | |
4143 } else { | |
4144 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
4145 message = g_strdup(args->msg); | |
4146 } | |
4147 } | |
2869 | 4148 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4149 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 4150 char *name; |
5234 | 4151 GHashTable *components; |
4152 | |
9933 | 4153 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
4154 g_free(message); | |
4121 | 4155 return 1; |
9933 | 4156 } |
5234 | 4157 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
4158 g_free); | |
4121 | 4159 name = extract_name(args->info.chat.roominfo.name); |
5234 | 4160 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
4161 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
|
4162 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4163 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4164 userinfo->sn, |
9933 | 4165 message, |
5234 | 4166 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4167 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4168 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4169 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 4170 /* BBB */ |
11369 | 4171 /* This is the first sendfile request where we need to notify the user that someone |
4172 * wants to send a file */ | |
4173 if (args->status == AIM_RENDEZVOUS_PROPOSE | |
4174 && (args->info.sendfile.reqnum == 0x0001)) { | |
4617 | 4175 /* Someone wants to send a file (or files) to us */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4176 GaimXfer *xfer; |
5146 | 4177 struct aim_oft_info *oft_info; |
11369 | 4178 struct aim_rv_proxy_info *proxy_info = NULL; |
4179 gboolean use_rv_proxy; | |
4180 int proxy_stage; | |
4181 int xfer_method; | |
4182 const char *proxy_ip = NULL; | |
13073 | 4183 |
11369 | 4184 if (!args->cookie || !args->port || |
13073 | 4185 !args->info.sendfile.filename || !args->info.sendfile.totsize || |
4656 | 4186 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 4187 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4188 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4189 "information.\n", userinfo->sn); |
9933 | 4190 g_free(message); |
4617 | 4191 return 1; |
4656 | 4192 } |
4617 | 4193 |
4194 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
4195 /* 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
|
4196 * directory -- remove the star and trailing slash so we don't save |
4617 | 4197 * directories that look like 'dirname\*' -- arl */ |
4198 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
4199 if (tmp && (tmp[1] == '*')) { | |
4200 tmp[0] = '\0'; | |
4201 } | |
8660 | 4202 gaim_debug_warning("oscar", |
8446 | 4203 "We're receiving a whole directory! What fun! " |
4204 "Especially since we don't support that!\n"); | |
4617 | 4205 } |
4206 | |
4207 /* Build the file transfer handle */ | |
4208 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
13073 | 4209 |
11369 | 4210 use_rv_proxy = gaim_prefs_get_bool("/plugins/prpl/oscar/use_rv_proxy"); |
13073 | 4211 |
11369 | 4212 if(args->info.sendfile.use_proxy) { |
4213 /* The sender requested (stage 1) that we use a rendezvous proxy */ | |
4214 xfer_method = AIM_XFER_PROXY; | |
4215 proxy_stage = AIM_XFER_PROXY_STG1; | |
4216 gaim_debug_info("oscar","using stage 1 proxy with ip: %s\n", | |
4217 args->proxyip, args->port); | |
4218 xfer->remote_ip = g_strdup(args->proxyip); | |
4219 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4220 proxy_info = aim_rv_proxy_createinfo(od->sess, args->cookie, args->port); | |
4221 } else if(use_rv_proxy) { | |
4222 /* If the local user indicated that a rendezvous proxy is necessary | |
4223 * start a stage 2 proxied transfer */ | |
4224 gaim_debug_info("oscar","using stage 2 proxied transfer\n"); | |
4225 xfer_method = AIM_XFER_PROXY; | |
4226 proxy_stage = AIM_XFER_PROXY_STG2; | |
4227 /* This hostname will be resolved by gaim_proxy_connect */ | |
4228 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
4229 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4230 proxy_info = aim_rv_proxy_createinfo(od->sess, args->cookie, 0); | |
4231 } else { | |
4232 /* We are receiving a file directly with no rendezvous proxy */ | |
4233 xfer_method = AIM_XFER_DIRECT; | |
4234 proxy_stage = AIM_XFER_PROXY_NONE; | |
4235 xfer->remote_ip = g_strdup(args->clientip); | |
4236 xfer->remote_port = args->port; | |
4237 } | |
4238 | |
4239 /* Use UTF8 so that the world will be a happier place */ | |
11238 | 4240 if (g_utf8_validate(args->info.sendfile.filename, -1, |
4241 NULL)) { | |
4242 gaim_xfer_set_filename(xfer, | |
4243 args->info.sendfile.filename); | |
4244 } else { | |
4245 gchar * utf8_filename = gaim_utf8_salvage( | |
4246 args->info.sendfile.filename); | |
4247 gaim_xfer_set_filename(xfer, utf8_filename); | |
4248 g_free(utf8_filename); | |
4249 } | |
4250 | |
4617 | 4251 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); |
11084 | 4252 |
11369 | 4253 /* Ignore messages that start with <ICQ_COOL_FT> (XML that is sent along |
4254 * with ICQ sendfile requests) & <HTML> message that is sent with AOL file | |
4255 * transfers (Note: this latter message is ignored only if whole message | |
4256 * is <HTML>, but not if it starts with <HTML> */ | |
4257 if(message && ( g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13) < 0 | |
4258 || g_ascii_strcasecmp(message,"<HTML>") == 0) ) { | |
4259 gaim_debug_info("oscar","Ignoring file transfer message: %s\n", message); | |
11084 | 4260 g_free(message); |
4261 message = NULL; | |
4262 } | |
9933 | 4263 gaim_xfer_set_message(xfer, message); |
5146 | 4264 |
4265 /* Create the oscar-specific data */ | |
11369 | 4266 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, |
4267 xfer->remote_port, 0, 0, NULL, AIM_XFER_RECV, xfer_method, proxy_stage); | |
4268 if(proxy_stage == AIM_XFER_PROXY_STG2 && proxy_ip) { | |
4269 oft_info->proxyip = g_strdup(proxy_ip); | |
4270 } else { | |
4271 if (args->proxyip) | |
4272 oft_info->proxyip = g_strdup(args->proxyip); | |
4273 if (args->verifiedip) | |
4274 oft_info->verifiedip = g_strdup(args->verifiedip); | |
4275 } | |
4276 oft_info->proxy_info = proxy_info; | |
5146 | 4277 xfer->data = oft_info; |
4617 | 4278 |
4279 /* Setup our I/O op functions */ | |
8446 | 4280 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 4281 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 4282 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
|
4283 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 4284 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 4285 |
4286 /* Keep track of this transfer for later */ | |
4287 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
11369 | 4288 |
4617 | 4289 /* Now perform the request */ |
4290 gaim_xfer_request(xfer); | |
11369 | 4291 /* A secondary request has been sent to negotiate the connection method */ |
4292 } else if (args->status == AIM_RENDEZVOUS_PROPOSE && args->info.sendfile.reqnum == 0x0002) { | |
4293 /* We have asked to send a file to someone else, but they sent us a reply request | |
4294 * asking us to use an alternative method of connecting */ | |
4295 GaimXfer *xfer; | |
4296 struct aim_oft_info *oft_info; | |
4297 | |
4298 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { | |
4299 oft_info = xfer->data; | |
4300 | |
4301 /* Stop the listener connection */ | |
4302 gaim_input_remove(xfer->watcher); | |
4303 aim_conn_kill(sess, &oft_info->conn); /* This is currently the listener */ | |
4304 | |
4305 if(args->info.sendfile.use_proxy) { | |
4306 gaim_debug_info("oscar", | |
4307 "received request for stage 2 rv proxy with ip: %s\n", | |
4308 args->proxyip); | |
4309 oft_info->method = AIM_XFER_PROXY; | |
4310 oft_info->stage = AIM_XFER_PROXY_STG2; | |
4311 | |
4312 oft_info->proxy_info = aim_rv_proxy_createinfo(oft_info->sess, | |
4313 args->cookie, args->port); | |
4314 if(args->proxyip) { | |
4315 if(xfer->remote_ip) | |
4316 g_free(xfer->remote_ip); | |
4317 xfer->remote_ip = g_strdup(args->proxyip); | |
4318 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4319 oscar_xfer_init_recv(xfer); | |
4320 } else { | |
4321 gaim_debug_warning("oscar", | |
4322 "stage 2 rv proxy file send: no proxy ip specified\n"); | |
4323 } | |
4324 } else if(args->clientip | |
4325 && g_ascii_strcasecmp(args->clientip,"0.0.0.0") == 0) | |
4326 { | |
4327 gaim_debug_warning("oscar", | |
4328 "other client wants us to send stage 3 proxy info\n"); | |
4329 oft_info->method = AIM_XFER_PROXY; | |
4330 oft_info->stage = AIM_XFER_PROXY_STG3; | |
4331 | |
4332 /* Clean useless data from oft_info */ | |
4333 oft_info->clientip = NULL; | |
4334 oft_info->verifiedip = NULL; | |
4335 | |
4336 /* This hostname will be resolved in gaim_proxy_connect */ | |
4337 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
4338 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4339 | |
4340 oft_info->proxy_info | |
4341 = aim_rv_proxy_createinfo(od->sess, args->cookie, 0); | |
4342 oscar_xfer_init_recv(xfer); | |
4343 } else { | |
4344 gaim_debug_info("oscar","received request to redirect transfer; clientip/verifiedip: %s / %s\n", | |
4345 args->clientip, args->verifiedip); | |
4346 oft_info->method = AIM_XFER_REDIR; | |
4347 if (args->verifiedip) | |
4348 oft_info->verifiedip = g_strdup(args->verifiedip); | |
4349 if (args->clientip) { | |
4350 oft_info->clientip = g_strdup(args->clientip); | |
4351 xfer->remote_ip = g_strdup(args->clientip); | |
4352 } | |
4353 xfer->remote_port = args->port; | |
4354 | |
4355 /* This file send will briefly follow file receive codepaths */ | |
4356 oscar_xfer_init_recv(xfer); | |
4357 } | |
4358 } else { | |
4359 gaim_debug_warning("oscar","received file tranfer reply request: xfer not found\n"); | |
4360 } | |
4361 /* A THIRD request has been sent trying to figure out what connection method will be used | |
4362 * to transfer this file */ | |
4363 } else if (args->status == AIM_RENDEZVOUS_PROPOSE && args->info.sendfile.reqnum == 0x0003) { | |
4364 /* We are receiving a file from someone. We sent a request to use a stage 3 | |
4365 * proxy. They did the initial proxy login and have sent us the info in a | |
4366 * third file transfer request. */ | |
4367 GaimXfer *xfer; | |
4368 struct aim_oft_info *oft_info; | |
4369 | |
4370 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { | |
4371 oft_info = xfer->data; | |
4372 | |
4373 /* We are receiving a file */ | |
4374 gaim_debug_info("oscar", | |
4375 "other client sent us stage 3 proxy info\n"); | |
4376 | |
4377 /* The following pieces of information should already have | |
4378 * been set in oscar_xfer_ip_timeout, but we'll list them | |
4379 * again just for clarity. */ | |
4380 oft_info->method = AIM_XFER_PROXY; | |
4381 oft_info->stage = AIM_XFER_PROXY_STG3; | |
4382 | |
4383 oft_info->proxy_info = aim_rv_proxy_createinfo(oft_info->sess, | |
4384 args->cookie, args->port); | |
4385 if(args->proxyip) { | |
4386 if(xfer->remote_ip) | |
4387 g_free(xfer->remote_ip); | |
4388 xfer->remote_ip = g_strdup(args->proxyip); | |
4389 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
4390 oscar_xfer_init_recv(xfer); | |
4391 } else { | |
4392 gaim_debug_warning("oscar", | |
4393 "stage 3 rv proxy file receive: no proxy ip specified\n"); | |
4394 } | |
4395 } else { | |
4396 gaim_debug_warning("oscar","received file tranfer reply request: xfer not found\n"); | |
4397 } | |
4617 | 4398 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { |
4399 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4400 GaimXfer *xfer; |
8660 | 4401 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4402 "AAA - File transfer canceled by remote user\n"); |
4617 | 4403 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
|
4404 gaim_xfer_cancel_remote(xfer); |
4617 | 4405 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
4406 /* | |
4407 * This gets sent by the receiver of a file | |
4408 * as they connect directly to us. If we don't | |
4409 * get this, then maybe a third party connected | |
4410 * to us, and we shouldn't send them anything. | |
4411 */ | |
11214 | 4412 gaim_debug_info("oscar", |
4413 "AAA - received chan 2 AIM_RENDEZVOUS_ACCEPT; ignoring\n"); | |
4617 | 4414 } else { |
8660 | 4415 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4416 "unknown rendezvous status!\n"); |
3630 | 4417 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4418 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 4419 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4420 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 4421 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
4422 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4423 args->info.icon.length); |
6871 | 4424 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 4425 /* 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
|
4426 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 4427 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
|
4428 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4429 |
4212 | 4430 if (!args->verifiedip) { |
8983 | 4431 /* TODO: do something about this, after figuring out what it means */ |
8660 | 4432 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4433 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 4434 g_free(message); |
4650 | 4435 return 1; |
4212 | 4436 } |
4437 | |
8660 | 4438 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4439 "%s received direct im request from %s (%s)\n", |
10594 | 4440 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4441 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4442 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4443 d->sn = g_strdup(userinfo->sn); |
8983 | 4444 /* Let's use the clientip here, because I think that's what AIM does. |
4445 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
4446 * and then ask them to connect to us. */ | |
10594 | 4447 /* |
4448 * I disagree, let's use the verifiedip. I think AIM tries the | |
4449 * verified IP first, then tries the client IP if that fails. In | |
4450 * any case, there's a better chance the verified IP will be correct. | |
4451 * The client IP is what the other person _thinks_ their IP address | |
4452 * is. The verified IP is the address that the AIM server sees the | |
4453 * other person using. | |
4454 */ | |
4455 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
|
4456 memcpy(d->cookie, args->cookie, 8); |
9070 | 4457 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
4458 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
4459 | |
8971 | 4460 oscar_direct_im_destroy(od, dim); |
8984 | 4461 d->donttryagain = TRUE; |
8971 | 4462 accept_direct_im_request(d); |
4463 } else { | |
8983 | 4464 if (dim && !dim->connected) |
8971 | 4465 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
4466 "already connected to that buddy!"); | |
5575 | 4467 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
|
4468 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4469 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4470 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4471 "the two computers and is necessary for IM " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4472 "Images. Because your IP address will be " |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4473 "revealed, this may be considered a privacy " |
11369 | 4474 "risk."), |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4475 GAIM_DEFAULT_ACTION_NONE, d, 2, |
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4476 _("_Connect"), G_CALLBACK(accept_direct_im_request), |
8971 | 4477 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); |
4478 /* FIXME: we should actually send a packet on cancel */ | |
4479 } | |
8708 | 4480 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
4481 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
|
4482 } else { |
8660 | 4483 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4484 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4485 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4486 |
9933 | 4487 g_free(message); |
4488 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4489 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4490 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4491 |
3453 | 4492 /* |
4230 | 4493 * Authorization Functions |
4494 * Most of these are callbacks from dialogs. They're used by both | |
4495 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 4496 */ |
4269 | 4497 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4498 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 4499 GaimConnection *gc = data->gc; |
4244 | 4500 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4501 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 4502 OscarData *od = gc->proto_data; |
6695 | 4503 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
12088 | 4504 GaimGroup *group = gaim_buddy_get_group(buddy); |
4244 | 4505 if (buddy && group) { |
8660 | 4506 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4507 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4508 buddy->name, group->name); |
4889 | 4509 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 4510 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 4511 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 4512 } |
4230 | 4513 } |
4337 | 4514 } |
4515 | |
4516 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4517 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 4518 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4519 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 4520 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4521 data); |
4230 | 4522 } |
4523 | |
4524 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 4525 GaimConnection *gc = data->gc; |
4244 | 4526 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4527 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 4528 /* Remove from local list */ |
4529 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
4530 gaim_blist_remove_buddy(b); | |
4244 | 4531 } |
4532 | |
5836 | 4533 oscar_free_name_data(data); |
4230 | 4534 } |
4535 | |
9030 | 4536 |
4537 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 4538 struct name_data *data = g_new(struct name_data, 1); |
6695 | 4539 GaimBuddy *buddy; |
4269 | 4540 gchar *dialog_msg, *nombre; |
4541 | |
4687 | 4542 buddy = gaim_find_buddy(gc->account, name); |
9620 | 4543 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
4544 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 4545 else |
4830 | 4546 nombre = NULL; |
4547 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4548 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 | 4549 data->gc = gc; |
4550 data->name = g_strdup(name); | |
4551 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4552 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4553 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4554 0, data, 2, |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4555 _("_Request Authorization"), |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4556 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4557 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 4558 |
4559 g_free(dialog_msg); | |
4560 g_free(nombre); | |
4561 } | |
4562 | |
9030 | 4563 |
4564 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
4565 GaimBuddy *buddy; | |
4566 GaimConnection *gc; | |
4567 | |
4568 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
4569 | |
4570 buddy = (GaimBuddy *) node; | |
4571 gc = gaim_account_get_connection(buddy->account); | |
4572 gaim_auth_sendrequest(gc, buddy->name); | |
4573 } | |
4574 | |
4230 | 4575 /* When other people ask you for authorization */ |
4576 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 4577 GaimConnection *gc = data->gc; |
4244 | 4578 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4579 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 4580 OscarData *od = gc->proto_data; |
4889 | 4581 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4244 | 4582 } |
4583 | |
5836 | 4584 oscar_free_name_data(data); |
3141 | 4585 } |
4586 | |
4230 | 4587 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4588 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 4589 GaimConnection *gc = data->gc; |
4244 | 4590 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4591 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 4592 OscarData *od = gc->proto_data; |
4889 | 4593 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4244 | 4594 } |
4337 | 4595 } |
4596 | |
4597 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4598 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 4599 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4600 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 4601 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4602 data); |
3141 | 4603 } |
4604 | |
7023 | 4605 /* When someone sends you buddies */ |
4606 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 4607 GaimConnection *gc = data->gc; |
4244 | 4608 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4609 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
4610 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 4611 } |
4612 | |
5836 | 4613 oscar_free_name_data(data); |
3453 | 4614 } |
4615 | |
4075 | 4616 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 | 4617 GaimConnection *gc = sess->aux_data; |
9908 | 4618 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 4619 gchar **msg1, **msg2; |
6051 | 4620 int i, numtoks; |
4076 | 4621 |
4121 | 4622 if (!args->type || !args->msg || !args->uin) |
4623 return 1; | |
4194 | 4624 |
8660 | 4625 gaim_debug_info("oscar", |
9908 | 4626 "Received a channel 4 message of type 0x%02hhx.\n", |
4627 args->type); | |
4076 | 4628 |
9919 | 4629 /* |
4630 * Split up the message at the delimeter character, then convert each | |
4631 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
4632 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
4633 * character in whatever encoding the message was sent in. Type 1 | |
4634 * messages are always made up of only one part, so we can easily account | |
4635 * for this suck-ass part of the protocol by splitting the string into at | |
4636 * most 1 baby string. | |
4637 */ | |
4638 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 4639 for (numtoks=0; msg1[numtoks]; numtoks++); |
4640 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 4641 for (i=0; msg1[i]; i++) { |
11920 | 4642 gaim_str_strip_char(msg1[i], '\r'); |
9908 | 4643 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 4644 } |
4645 msg2[i] = NULL; | |
4646 | |
3952 | 4647 switch (args->type) { |
4173 | 4648 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 4649 if (i >= 1) { |
5556 | 4650 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 4651 gchar *tmp; |
4652 | |
4653 /* 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
|
4654 tmp = g_markup_escape_text(msg2[0], -1); |
8493 | 4655 |
4076 | 4656 if (t) { /* This is an offline message */ |
9680 | 4657 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 4658 #ifdef HAVE_TM_GMTOFF |
9724 | 4659 time_t now; |
4660 struct tm *tm; | |
4661 now = time(NULL); | |
4662 tm = localtime(&now); | |
4663 t += tm->tm_gmtoff; | |
9698 | 4664 #else |
4665 # ifdef HAVE_TIMEZONE | |
9680 | 4666 tzset(); |
4667 t -= timezone; | |
9698 | 4668 # endif |
4669 #endif | |
8514 | 4670 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 4671 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 4672 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 4673 } |
4674 g_free(uin); | |
8493 | 4675 g_free(tmp); |
4075 | 4676 } |
3316 | 4677 } break; |
4678 | |
4173 | 4679 case 0x04: { /* Someone sent you a URL */ |
4076 | 4680 if (i >= 2) { |
7385 | 4681 if (msg2[1] != NULL) { |
4682 gchar *uin = g_strdup_printf("%u", args->uin); | |
4683 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
4684 msg2[1], | |
4685 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
4686 serv_got_im(gc, uin, message, 0, time(NULL)); | |
4687 g_free(uin); | |
4688 g_free(message); | |
4689 } | |
3453 | 4690 } |
4691 } break; | |
4692 | |
4173 | 4693 case 0x06: { /* Someone requested authorization */ |
4076 | 4694 if (i >= 6) { |
4230 | 4695 struct name_data *data = g_new(struct name_data, 1); |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4696 gchar *sn = g_strdup_printf("%u", args->uin); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4697 gchar *reason; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4698 gchar *dialog_msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4699 |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4700 if (msg2[5] != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4701 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
|
4702 else |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4703 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4704 |
11369 | 4705 dialog_msg = g_strdup_printf(_("The user %u wants to add %s to their buddy list for the following reason:\n%s"), |
4706 args->uin, gaim_account_get_username(gc->account), reason); | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4707 g_free(reason); |
8660 | 4708 gaim_debug_info("oscar", |
5556 | 4709 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4710 args->uin); |
4076 | 4711 data->gc = gc; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4712 data->name = sn; |
4230 | 4713 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4714 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4715 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 4716 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4717 2, _("_Authorize"), |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4718 G_CALLBACK(gaim_auth_grant), |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4719 _("_Deny"), |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4720 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 4721 g_free(dialog_msg); |
4722 } | |
3141 | 4723 } break; |
4724 | |
4173 | 4725 case 0x07: { /* Someone has denied you authorization */ |
4076 | 4726 if (i >= 1) { |
7023 | 4727 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
|
4728 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4729 dialog_msg); |
4076 | 4730 g_free(dialog_msg); |
4731 } | |
3141 | 4732 } break; |
4733 | |
4173 | 4734 case 0x08: { /* Someone has granted you authorization */ |
7023 | 4735 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
|
4736 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4737 dialog_msg); |
3141 | 4738 g_free(dialog_msg); |
4739 } break; | |
4740 | |
4333 | 4741 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
4742 if (i >= 5) { | |
4743 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
|
4744 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 4745 g_free(dialog_msg); |
4746 } | |
4747 } break; | |
4748 | |
4173 | 4749 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 4750 if (i >= 6) { |
4194 | 4751 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
|
4752 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 4753 g_free(dialog_msg); |
4754 } | |
4075 | 4755 } break; |
4756 | |
4173 | 4757 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 4758 if (i >= 6) { |
4308 | 4759 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
|
4760 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 4761 g_free(dialog_msg); |
4762 } | |
4075 | 4763 } break; |
4764 | |
4173 | 4765 case 0x12: { |
3141 | 4766 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 4767 /* Someone added you to their buddy list? */ |
3141 | 4768 } break; |
4769 | |
7023 | 4770 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 4771 guint i, num; |
3453 | 4772 gchar **text; |
4173 | 4773 text = g_strsplit(args->msg, "\376", 0); |
3453 | 4774 if (text) { |
4775 num = 0; | |
4776 for (i=0; i<strlen(text[0]); i++) | |
4777 num = num*10 + text[0][i]-48; | |
4778 for (i=0; i<num; i++) { | |
4230 | 4779 struct name_data *data = g_new(struct name_data, 1); |
7023 | 4780 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 | 4781 data->gc = gc; |
4790 | 4782 data->name = g_strdup(text[i*2+1]); |
4783 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4784 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4785 gaim_request_action(gc, NULL, message, |
7023 | 4786 _("Do you want to add this buddy " |
4787 "to your buddy list?"), | |
9972 | 4788 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 4789 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4790 _("_Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 4791 g_free(message); |
4792 } | |
4793 g_strfreev(text); | |
4794 } | |
4795 } break; | |
4796 | |
7023 | 4797 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 4798 /* This is boring and silly. */ |
4799 } break; | |
4800 | |
3141 | 4801 default: { |
8660 | 4802 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4803 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4804 "(type 0x%02hhx).\n", args->type); |
3141 | 4805 } break; |
4806 } | |
4807 | |
4076 | 4808 g_strfreev(msg1); |
4809 g_strfreev(msg2); | |
4810 | |
3141 | 4811 return 1; |
4812 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4813 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4814 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 4815 fu16_t channel; |
4816 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4817 aim_userinfo_t *userinfo; |
2086 | 4818 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4819 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4820 va_start(ap, fr); |
4200 | 4821 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4822 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4823 |
3141 | 4824 switch (channel) { |
4825 case 1: { /* standard message */ | |
4826 struct aim_incomingim_ch1_args *args; | |
4827 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
4828 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
4829 } break; | |
4830 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
4831 case 2: { /* rendezvous */ |
3141 | 4832 struct aim_incomingim_ch2_args *args; |
4833 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
4834 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
4835 } break; | |
4836 | |
4837 case 4: { /* ICQ */ | |
4838 struct aim_incomingim_ch4_args *args; | |
4839 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 4840 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 4841 } break; |
4842 | |
4843 default: { | |
8660 | 4844 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4845 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4846 "0x%04hx).", channel); |
3141 | 4847 } break; |
2086 | 4848 } |
4849 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4850 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4851 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4852 return ret; |
2086 | 4853 } |
4854 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4855 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 4856 GaimConnection *gc = sess->aux_data; |
4857 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 4858 char *buf; |
2086 | 4859 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4860 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4861 aim_userinfo_t *userinfo; |
2086 | 4862 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4863 va_start(ap, fr); |
4200 | 4864 chan = (fu16_t)va_arg(ap, unsigned int); |
4865 userinfo = va_arg(ap, aim_userinfo_t *); | |
4866 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
4867 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 4868 va_end(ap); |
4869 | |
4870 switch(reason) { | |
5420 | 4871 case 0: /* Invalid (0) */ |
4872 buf = g_strdup_printf( | |
4873 ngettext( | |
4276 | 4874 "You missed %hu message from %s because it was invalid.", |
4875 "You missed %hu messages from %s because they were invalid.", | |
4876 nummissed), | |
4282 | 4877 nummissed, |
4878 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4879 break; |
5420 | 4880 case 1: /* Message too large */ |
4881 buf = g_strdup_printf( | |
4882 ngettext( | |
4276 | 4883 "You missed %hu message from %s because it was too large.", |
4884 "You missed %hu messages from %s because they were too large.", | |
4885 nummissed), | |
4282 | 4886 nummissed, |
4887 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4888 break; |
5420 | 4889 case 2: /* Rate exceeded */ |
4890 buf = g_strdup_printf( | |
4891 ngettext( | |
4276 | 4892 "You missed %hu message from %s because the rate limit has been exceeded.", |
4893 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
4894 nummissed), | |
4282 | 4895 nummissed, |
4896 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4897 break; |
5420 | 4898 case 3: /* Evil Sender */ |
4899 buf = g_strdup_printf( | |
4900 ngettext( | |
4276 | 4901 "You missed %hu message from %s because he/she was too evil.", |
4902 "You missed %hu messages from %s because he/she was too evil.", | |
4903 nummissed), | |
4282 | 4904 nummissed, |
4905 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4906 break; |
5420 | 4907 case 4: /* Evil Receiver */ |
4908 buf = g_strdup_printf( | |
4909 ngettext( | |
4276 | 4910 "You missed %hu message from %s because you are too evil.", |
4911 "You missed %hu messages from %s because you are too evil.", | |
4912 nummissed), | |
4282 | 4913 nummissed, |
4914 userinfo->sn); | |
2086 | 4915 break; |
4916 default: | |
5420 | 4917 buf = g_strdup_printf( |
4918 ngettext( | |
4276 | 4919 "You missed %hu message from %s for an unknown reason.", |
4920 "You missed %hu messages from %s for an unknown reason.", | |
4921 nummissed), | |
4282 | 4922 nummissed, |
4923 userinfo->sn); | |
2086 | 4924 break; |
4925 } | |
8733 | 4926 |
9627 | 4927 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4928 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4929 g_free(buf); |
2086 | 4930 |
4931 return 1; | |
4932 } | |
4933 | |
11159 | 4934 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const guchar *cookie) { |
5575 | 4935 GaimConnection *gc = sess->aux_data; |
7283 | 4936 OscarData *od = gc->proto_data; |
4617 | 4937 |
4938 /* BBB */ | |
3630 | 4939 switch (reason) { |
4151 | 4940 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4941 GaimXfer *xfer; |
8971 | 4942 struct oscar_direct_im *dim; |
4943 | |
8660 | 4944 gaim_debug_info("oscar", |
9070 | 4945 "AAA - Other user declined some sort of direct " |
8971 | 4946 "connect attempt (automaticly?)\n"); |
4617 | 4947 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
|
4948 gaim_xfer_cancel_remote(xfer); |
8971 | 4949 else if ((dim = oscar_direct_im_find(od, who))) { |
4950 /* AAA should use find by cookie or something here */ | |
4951 oscar_direct_im_disconnect(od, dim); | |
4952 } | |
4151 | 4953 } break; |
4954 | |
4955 default: { | |
8660 | 4956 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4957 "Received an unknown rendezvous client auto-response " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4958 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4959 } |
3630 | 4960 |
4961 } | |
4962 | |
4963 return 0; | |
4964 } | |
4965 | |
4194 | 4966 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4967 GaimConnection *gc = sess->aux_data; |
4151 | 4968 |
4969 switch(reason) { | |
4970 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4971 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4972 | |
4973 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4974 |
4975 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4976 statusmsg = oscar_icqstatus(state); |
4151 | 4977 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4978 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4979 g_free(statusmsg); | |
4151 | 4980 g_strfreev(splitmsg); |
9244 | 4981 |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
4982 gaim_notify_userinfo(gc, who, dialogmsg, NULL, NULL); |
9244 | 4983 |
4984 g_free(title); | |
4985 g_free(dialogmsg); | |
4151 | 4986 } break; |
4987 | |
4988 default: { | |
8660 | 4989 gaim_debug_warning("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4990 "Received an unknown client auto-response from %s. " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4991 "Type 0x%04hx\n", who, reason); |
4151 | 4992 } break; |
4993 } /* end of switch */ | |
4994 | |
4995 return 0; | |
4996 } | |
4997 | |
3212 | 4998 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4999 va_list ap; | |
5000 fu16_t chan, reason; | |
5001 char *who; | |
5002 | |
5003 va_start(ap, fr); | |
4200 | 5004 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 5005 who = va_arg(ap, char *); |
4200 | 5006 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 5007 |
3952 | 5008 if (chan == 0x0002) { /* File transfer declined */ |
11159 | 5009 guchar *cookie = va_arg(ap, guchar *); |
4151 | 5010 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 5011 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 5012 fu32_t state = 0; |
4151 | 5013 char *msg = NULL; |
5014 if (reason == 0x0003) { | |
4200 | 5015 state = va_arg(ap, fu32_t); |
4151 | 5016 msg = va_arg(ap, char *); |
5017 } | |
5018 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
5019 } | |
3952 | 5020 |
3212 | 5021 va_end(ap); |
5022 | |
5023 return 1; | |
5024 } | |
5025 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5026 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5027 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5028 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5029 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5030 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5031 va_start(ap, fr); |
4199 | 5032 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 5033 va_end(ap); |
5034 | |
8660 | 5035 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5036 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5037 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 5038 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5039 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 5040 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5041 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5042 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5043 |
2086 | 5044 return 1; |
5045 } | |
5046 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5047 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 5048 GaimConnection *gc = sess->aux_data; |
4617 | 5049 #if 0 |
7283 | 5050 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
5051 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5052 #endif |
4617 | 5053 va_list ap; |
5054 fu16_t reason; | |
5055 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5056 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5057 va_start(ap, fr); |
4617 | 5058 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 5059 data = va_arg(ap, char *); |
2086 | 5060 va_end(ap); |
5061 | |
8660 | 5062 gaim_debug_error("oscar", |
10130 | 5063 "Message error with data %s and reason %hu\n", |
5064 (data != NULL ? data : ""), reason); | |
4617 | 5065 |
5066 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5067 #if 0 |
4617 | 5068 /* If this was a file transfer request, data is a cookie */ |
5069 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
|
5070 gaim_xfer_cancel_remote(xfer); |
3630 | 5071 return 1; |
5072 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5073 #endif |
3630 | 5074 |
4617 | 5075 /* Data is assumed to be the destination sn */ |
9826 | 5076 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
5077 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
5078 g_free(buf); | |
5079 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 5080 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 5081 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
5082 } | |
5083 g_free(buf); | |
5084 | |
2086 | 5085 return 1; |
5086 } | |
5087 | |
3595 | 5088 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5089 GaimConnection *gc = sess->aux_data; |
3595 | 5090 va_list ap; |
5091 fu16_t type1, type2; | |
5092 char *sn; | |
5093 | |
5094 va_start(ap, fr); | |
4199 | 5095 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 5096 sn = va_arg(ap, char *); |
4199 | 5097 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 5098 va_end(ap); |
5099 | |
5100 switch (type2) { | |
5101 case 0x0000: { /* Text has been cleared */ | |
5102 serv_got_typing_stopped(gc, sn); | |
5103 } break; | |
5104 | |
5105 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5106 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 5107 } break; |
5108 | |
5109 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5110 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 5111 } break; |
5112 | |
5113 default: { | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5114 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 | 5115 } break; |
5116 } | |
5117 | |
5118 return 1; | |
5119 } | |
5120 | |
7141 | 5121 /* |
5122 * We get this error when there was an error in the locate family. This | |
7259 | 5123 * happens when you request info of someone who is offline. |
7141 | 5124 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5125 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 5126 gchar *buf; |
2086 | 5127 va_list ap; |
5420 | 5128 fu16_t reason; |
2086 | 5129 char *destn; |
5130 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5131 va_start(ap, fr); |
4199 | 5132 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 5133 destn = va_arg(ap, char *); |
5134 va_end(ap); | |
5135 | |
7781 | 5136 if (destn == NULL) |
7793 | 5137 return 1; |
12653 | 5138 |
9826 | 5139 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
5140 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
5141 g_free(buf); | |
9627 | 5142 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 5143 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
5144 } | |
5145 g_free(buf); | |
2086 | 5146 |
5147 return 1; | |
5148 } | |
5149 | |
7011 | 5150 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5151 GaimConnection *gc = sess->aux_data; |
8700 | 5152 GaimAccount *account = gaim_connection_get_account(gc); |
10567 | 5153 OscarData *od = gc->proto_data; |
8700 | 5154 GString *str; |
11532
57439a383f4f
[gaim-migrate @ 13781]
Luke Schierer <lschiere@pidgin.im>
parents:
11531
diff
changeset
|
5155 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; |
4791 | 5156 va_list ap; |
7011 | 5157 aim_userinfo_t *userinfo; |
2086 | 5158 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5159 va_start(ap, fr); |
7011 | 5160 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 5161 va_end(ap); |
5162 | |
8700 | 5163 str = g_string_new(""); |
5164 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
5165 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 5166 |
10116 | 5167 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
10567 | 5168 time_t t = userinfo->onlinesince - od->timeoffset; |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
5169 oscar_string_append(gc->account, str, "\n<br>", _("Online Since"), gaim_date_format_full(localtime(&t))); |
10116 | 5170 } |
5171 | |
5172 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
10567 | 5173 time_t t = userinfo->membersince - od->timeoffset; |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
5174 oscar_string_append(gc->account, str, "\n<br>", _("Member Since"), gaim_date_format_full(localtime(&t))); |
10116 | 5175 } |
7011 | 5176 |
12430 | 5177 if (userinfo->capabilities != 0) { |
5178 tmp = oscar_caps_to_string(userinfo->capabilities); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
5179 oscar_string_append(gc->account, str, "\n<br>", _("Capabilities"), tmp); |
12430 | 5180 g_free(tmp); |
5181 } | |
5182 | |
7011 | 5183 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
8700 | 5184 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
5185 oscar_string_append(gc->account, str, "\n<br>", _("Idle"), tmp); |
8700 | 5186 g_free(tmp); |
5187 } | |
5188 | |
8701 | 5189 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 5190 |
13007 | 5191 /* Available message */ |
5192 if ((userinfo->status != NULL) && !(userinfo->flags & AIM_FLAG_AWAY)) | |
5193 { | |
5194 if (userinfo->status[0] != '\0') | |
5195 tmp = oscar_encoding_to_utf8(userinfo->status_encoding, | |
5196 userinfo->status, userinfo->status_len); | |
5197 oscar_string_append(gc->account, str, "\n<br>", _("Available Message"), tmp); | |
5198 g_free(tmp); | |
5199 } | |
5200 | |
5201 /* Away message */ | |
7011 | 5202 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { |
8700 | 5203 tmp = oscar_encoding_extract(userinfo->away_encoding); |
5204 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
5205 g_free(tmp); | |
7011 | 5206 if (away_utf8 != NULL) { |
12661 | 5207 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 5208 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5209 } |
7011 | 5210 } |
5211 | |
13007 | 5212 /* Info */ |
7011 | 5213 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { |
8700 | 5214 tmp = oscar_encoding_extract(userinfo->info_encoding); |
5215 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
5216 g_free(tmp); | |
7011 | 5217 if (info_utf8 != NULL) { |
12661 | 5218 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 5219 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5220 } |
7011 | 5221 } |
5222 | |
8701 | 5223 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 5224 g_string_free(str, TRUE); |
11920 | 5225 gaim_str_strip_char(tmp, '\r'); |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
5226 gaim_notify_userinfo(gc, userinfo->sn, tmp, NULL, NULL); |
8700 | 5227 g_free(tmp); |
4151 | 5228 |
2086 | 5229 return 1; |
5230 } | |
5231 | |
12189 | 5232 static int gaim_got_infoblock(aim_session_t *sess, aim_frame_t *fr, ...) |
5233 { | |
5234 GaimConnection *gc = sess->aux_data; | |
5235 GaimBuddy *b; | |
5236 GaimPresence *presence; | |
12349 | 5237 GaimStatus *status; |
12189 | 5238 gchar *message = NULL; |
5239 | |
5240 va_list ap; | |
5241 aim_userinfo_t *userinfo; | |
5242 | |
5243 va_start(ap, fr); | |
5244 userinfo = va_arg(ap, aim_userinfo_t *); | |
5245 va_end(ap); | |
5246 | |
5247 b = gaim_find_buddy(gaim_connection_get_account(gc), userinfo->sn); | |
5248 if (b == NULL) | |
5249 return 1; | |
5250 | |
5251 presence = gaim_buddy_get_presence(b); | |
12349 | 5252 status = gaim_presence_get_active_status(presence); |
5253 | |
12426 | 5254 if (!gaim_status_is_available(status) && gaim_status_is_online(status)) |
12271 | 5255 { |
12189 | 5256 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && |
5257 (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
5258 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); | |
5259 message = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); | |
5260 g_free(charset); | |
12393 | 5261 gaim_status_set_attr_string(status, "message", message); |
5262 g_free(message); | |
12189 | 5263 } |
12349 | 5264 |
5265 gaim_blist_update_buddy_status(b, status); | |
5266 } | |
12189 | 5267 |
5268 return 1; | |
5269 } | |
5270 | |
8341 | 5271 static gboolean gaim_reqinfo_timeout_cb(void *data) |
5272 { | |
5273 aim_session_t *sess = data; | |
5274 GaimConnection *gc = sess->aux_data; | |
5275 OscarData *od = (OscarData *)gc->proto_data; | |
5276 | |
5277 aim_locate_dorequest(data); | |
5278 od->getinfotimer = 0; | |
5279 | |
5280 return FALSE; | |
5281 } | |
5282 | |
5283 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
5284 { | |
5285 GaimConnection *gc = sess->aux_data; | |
5286 OscarData *od = (OscarData *)gc->proto_data; | |
5287 | |
5288 /* | |
5289 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
5290 * us from hitting the rate limit due to request away messages and info | |
5291 * too quickly. | |
5292 */ | |
5293 if (od->getinfotimer == 0) | |
11670 | 5294 od->getinfotimer = gaim_timeout_add(10000, gaim_reqinfo_timeout_cb, sess); |
8341 | 5295 |
5296 return 1; | |
5297 } | |
5298 | |
5299 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
5300 { | |
2086 | 5301 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5302 fu16_t id; |
2086 | 5303 va_list ap; |
5304 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5305 va_start(ap, fr); |
4199 | 5306 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 5307 msg = va_arg(ap, char *); |
5308 va_end(ap); | |
5309 | |
8660 | 5310 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5311 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
5312 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5313 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5314 _("Your AIM connection may be lost."), NULL); |
2086 | 5315 |
5316 return 1; | |
5317 } | |
5318 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5319 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5320 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5321 fu16_t type; |
5575 | 5322 GaimConnection *gc = sess->aux_data; |
7283 | 5323 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 5324 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5325 va_start(ap, fr); |
4199 | 5326 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 5327 |
5328 switch(type) { | |
5329 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5330 fu8_t maxrooms; |
2086 | 5331 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5332 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5333 |
4199 | 5334 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 5335 exchangecount = va_arg(ap, int); |
5336 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
5337 | |
8660 | 5338 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5339 "chat info: Chat Rights:\n"); |
8660 | 5340 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5341 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 5342 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5343 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5344 for (i = 0; i < exchangecount; i++) |
8660 | 5345 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5346 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5347 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 5348 while (od->create_rooms) { |
5349 struct create_room *cr = od->create_rooms->data; | |
8660 | 5350 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5351 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5352 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5353 g_free(cr->name); |
4617 | 5354 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5355 g_free(cr); |
2086 | 5356 } |
5357 } | |
5358 break; | |
5359 case 0x0008: { | |
5360 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5361 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5362 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5363 fu32_t createtime; |
2086 | 5364 |
5365 fqcn = va_arg(ap, char *); | |
4200 | 5366 instance = (fu16_t)va_arg(ap, unsigned int); |
5367 exchange = (fu16_t)va_arg(ap, unsigned int); | |
5368 flags = (fu16_t)va_arg(ap, unsigned int); | |
5369 createtime = va_arg(ap, fu32_t); | |
5370 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
5371 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
5372 createperms = (fu8_t)va_arg(ap, unsigned int); | |
5373 unknown = (fu16_t)va_arg(ap, unsigned int); | |
5374 name = va_arg(ap, char *); | |
5375 ck = va_arg(ap, char *); | |
4194 | 5376 |
8660 | 5377 gaim_debug_misc("oscar", |
5556 | 5378 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 5379 fqcn, |
5380 exchange, instance, flags, | |
5381 createtime, | |
5382 maxmsglen, maxoccupancy, createperms, unknown, | |
5383 name, ck); | |
4617 | 5384 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 5385 } |
5386 break; | |
5387 default: | |
8660 | 5388 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5389 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 5390 break; |
5391 } | |
4194 | 5392 |
5393 va_end(ap); | |
5394 | |
2086 | 5395 return 1; |
5396 } | |
5397 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5398 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5399 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5400 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5401 aim_userinfo_t *info; |
5575 | 5402 GaimConnection *g = sess->aux_data; |
2086 | 5403 |
5404 struct chat_connection *c = NULL; | |
5405 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5406 va_start(ap, fr); |
2086 | 5407 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5408 info = va_arg(ap, aim_userinfo_t *); |
2086 | 5409 va_end(ap); |
5410 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5411 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 5412 if (!c) |
5413 return 1; | |
5414 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5415 for (i = 0; i < count; i++) |
9846 | 5416 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 5417 |
5418 return 1; | |
5419 } | |
5420 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5421 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5422 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5423 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5424 aim_userinfo_t *info; |
5575 | 5425 GaimConnection *g = sess->aux_data; |
2086 | 5426 |
5427 struct chat_connection *c = NULL; | |
5428 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5429 va_start(ap, fr); |
2086 | 5430 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5431 info = va_arg(ap, aim_userinfo_t *); |
2086 | 5432 va_end(ap); |
5433 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5434 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 5435 if (!c) |
5436 return 1; | |
5437 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5438 for (i = 0; i < count; i++) |
8733 | 5439 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 5440 |
5441 return 1; | |
5442 } | |
5443 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5444 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
|
5445 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5446 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5447 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5448 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5449 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5450 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5451 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5452 fu32_t creationtime; |
5575 | 5453 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5454 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
|
5455 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5456 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5457 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5458 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5459 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5460 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5461 roomdesc = va_arg(ap, char *); |
4200 | 5462 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
5463 creationtime = va_arg(ap, fu32_t); | |
5464 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
5465 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
5466 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
5467 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5468 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5469 |
8660 | 5470 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5471 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5472 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5473 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5474 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5475 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5476 |
2086 | 5477 return 1; |
5478 } | |
5479 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5480 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5481 GaimConnection *gc = sess->aux_data; |
8225 | 5482 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
5483 gchar *utf8; | |
2086 | 5484 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5485 aim_userinfo_t *info; |
8225 | 5486 int len; |
2086 | 5487 char *msg; |
8219 | 5488 char *charset; |
2086 | 5489 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5490 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5491 info = va_arg(ap, aim_userinfo_t *); |
8219 | 5492 len = va_arg(ap, int); |
4194 | 5493 msg = va_arg(ap, char *); |
8219 | 5494 charset = va_arg(ap, char *); |
4194 | 5495 va_end(ap); |
2086 | 5496 |
8225 | 5497 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 5498 if (utf8 == NULL) |
5499 /* The conversion failed! */ | |
8668 | 5500 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 5501 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
5502 g_free(utf8); | |
2086 | 5503 |
5504 return 1; | |
5505 } | |
5506 | |
3694 | 5507 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
5508 va_list ap; | |
5575 | 5509 GaimConnection *gc = sess->aux_data; |
3694 | 5510 struct aim_emailinfo *emailinfo; |
3725 | 5511 int havenewmail; |
7297 | 5512 char *alertitle, *alerturl; |
3694 | 5513 |
5514 va_start(ap, fr); | |
5515 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 5516 havenewmail = va_arg(ap, int); |
7301 | 5517 alertitle = va_arg(ap, char *); |
5518 alerturl = va_arg(ap, char *); | |
3694 | 5519 va_end(ap); |
5520 | |
9661 | 5521 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
5522 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
5523 emailinfo->domain ? "@" : "", | |
5524 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 5525 if (emailinfo->unread && havenewmail) |
5526 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 5527 g_free(to); |
3694 | 5528 } |
11369 | 5529 |
7301 | 5530 if (alertitle) |
8660 | 5531 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 5532 |
5533 return 1; | |
5534 } | |
5535 | |
4804 | 5536 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5537 GaimConnection *gc = sess->aux_data; |
7283 | 5538 OscarData *od = gc->proto_data; |
4804 | 5539 char *sn; |
5540 | |
5541 sn = od->requesticon->data; | |
8660 | 5542 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5543 "removing %s from hash table\n", sn); |
4804 | 5544 od->requesticon = g_slist_remove(od->requesticon, sn); |
5545 free(sn); | |
5546 | |
5547 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
5548 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5549 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 5550 |
5551 return 1; | |
5552 } | |
5553 | |
5554 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5555 GaimConnection *gc = sess->aux_data; |
7283 | 5556 OscarData *od = gc->proto_data; |
4804 | 5557 GSList *cur; |
5558 va_list ap; | |
5559 char *sn; | |
11024 | 5560 fu8_t iconcsumtype, *iconcsum, *icon; |
4853 | 5561 fu16_t iconcsumlen, iconlen; |
4804 | 5562 |
5563 va_start(ap, fr); | |
5564 sn = va_arg(ap, char *); | |
11024 | 5565 iconcsumtype = va_arg(ap, int); |
4853 | 5566 iconcsum = va_arg(ap, fu8_t *); |
5567 iconcsumlen = va_arg(ap, int); | |
4804 | 5568 icon = va_arg(ap, fu8_t *); |
5569 iconlen = va_arg(ap, int); | |
5570 va_end(ap); | |
5571 | |
11024 | 5572 /* |
5573 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
5574 * no icon is set. Ignore these. | |
5575 */ | |
5576 if ((iconlen > 0) && (iconlen != 90)) { | |
4853 | 5577 char *b16; |
6695 | 5578 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
5579 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
5580 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
5581 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 5582 if (b16) { |
7693 | 5583 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 5584 g_free(b16); |
5129 | 5585 } |
4853 | 5586 } |
4804 | 5587 |
5588 cur = od->requesticon; | |
5589 while (cur) { | |
5590 char *cursn = cur->data; | |
5591 if (!aim_sncmp(cursn, sn)) { | |
5592 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
5593 free(cursn); | |
5594 cur = od->requesticon; | |
5595 } else | |
5596 cur = cur->next; | |
5597 } | |
5598 | |
5599 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
5600 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5601 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 5602 |
5603 return 1; | |
5604 } | |
5605 | |
5606 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 5607 GaimConnection *gc = data; |
7283 | 5608 OscarData *od = gc->proto_data; |
7011 | 5609 aim_userinfo_t *userinfo; |
4804 | 5610 aim_conn_t *conn; |
5611 | |
5612 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 5613 if (!conn) { |
5614 if (!od->iconconnecting) { | |
5615 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
5616 od->iconconnecting = TRUE; | |
5617 } | |
4804 | 5618 return FALSE; |
5619 } | |
5620 | |
5842 | 5621 if (od->set_icon) { |
6039 | 5622 struct stat st; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5623 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
6039 | 5624 if (iconfile == NULL) { |
8363 | 5625 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5626 } else if (!g_stat(iconfile, &st)) { |
11159 | 5627 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5628 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 5629 if (file) { |
9532 | 5630 /* XXX - Use g_file_get_contents()? */ |
6039 | 5631 fread(buf, 1, st.st_size, file); |
5632 fclose(file); | |
8660 | 5633 gaim_debug_info("oscar", |
6039 | 5634 "Uploading icon to icon server\n"); |
6879 | 5635 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 5636 } else |
8660 | 5637 gaim_debug_error("oscar", |
6039 | 5638 "Can't open buddy icon file!\n"); |
5639 g_free(buf); | |
5640 } else { | |
8660 | 5641 gaim_debug_error("oscar", |
6039 | 5642 "Can't stat buddy icon file!\n"); |
5842 | 5643 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5644 g_free(iconfile); |
5842 | 5645 od->set_icon = FALSE; |
5646 } | |
5647 | |
5648 if (!od->requesticon) { | |
8660 | 5649 gaim_debug_misc("oscar", |
5842 | 5650 "no more icons to request\n"); |
5651 return FALSE; | |
5652 } | |
5653 | |
7045 | 5654 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 5655 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
11024 | 5656 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
4804 | 5657 return FALSE; |
5658 } else { | |
5659 char *sn = od->requesticon->data; | |
5660 od->requesticon = g_slist_remove(od->requesticon, sn); | |
5661 free(sn); | |
5662 } | |
5663 | |
5664 return TRUE; | |
5665 } | |
5666 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5667 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5668 * 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
|
5669 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5670 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5671 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5672 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5673 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5674 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5675 va_start(ap, fr); |
4199 | 5676 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 5677 sn = va_arg(ap, char *); |
5678 va_end(ap); | |
5679 | |
8660 | 5680 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 5681 |
5682 return 1; | |
5683 } | |
5684 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5685 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
|
5686 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5687 "invalid", |
4194 | 5688 "change", |
5689 "warning", | |
5690 "limit", | |
5691 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5692 }; |
2086 | 5693 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5694 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5695 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5696 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5697 va_start(ap, fr); |
4200 | 5698 code = (fu16_t)va_arg(ap, unsigned int); |
5699 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
5700 windowsize = va_arg(ap, fu32_t); | |
5701 clear = va_arg(ap, fu32_t); | |
5702 alert = va_arg(ap, fu32_t); | |
5703 limit = va_arg(ap, fu32_t); | |
5704 disconnect = va_arg(ap, fu32_t); | |
5705 currentavg = va_arg(ap, fu32_t); | |
5706 maxavg = va_arg(ap, fu32_t); | |
2086 | 5707 va_end(ap); |
5708 | |
8660 | 5709 gaim_debug_misc("oscar", |
5556 | 5710 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
5711 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 5712 (code < 5) ? codes[code] : codes[0], |
5713 rateclass, | |
5714 currentavg, maxavg, | |
5715 alert, clear, | |
5716 limit, disconnect, | |
5717 windowsize); | |
5718 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5719 /* XXX fix these values */ |
2086 | 5720 if (code == AIM_RATE_CODE_CHANGE) { |
5721 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5722 aim_conn_setlatency(fr->conn, 0); |
2086 | 5723 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5724 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
5725 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5726 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 5727 _("The last action you attempted could not be " |
5728 "performed because you are over the rate limit. " | |
5729 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5730 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 5731 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5732 aim_conn_setlatency(fr->conn, 0); |
2086 | 5733 } |
5734 | |
5735 return 1; | |
5736 } | |
5737 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5738 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5739 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5740 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5741 aim_userinfo_t *userinfo; |
2086 | 5742 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5743 va_start(ap, fr); |
4199 | 5744 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5745 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 5746 va_end(ap); |
5747 | |
11285 | 5748 #ifdef CRAZY_WARNING |
5749 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
5750 #endif | |
2086 | 5751 |
5752 return 1; | |
5753 } | |
5754 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5755 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 5756 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5757 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5758 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5759 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5760 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5761 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5762 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5763 |
11285 | 5764 /* |
5765 * What's with the + 0.5? | |
5766 * The 0.5 is basically poor-man's rounding. Normally | |
5767 * casting "13.7" to an int will truncate to "13," but | |
5768 * with 13.7 + 0.5 = 14.2, which becomes "14" when | |
5769 * truncated. | |
5770 */ | |
9982 | 5771 warning_level = info->warnlevel/10.0 + 0.5; |
5772 | |
11285 | 5773 #ifdef CRAZY_WARNING |
5774 gaim_presence_set_warning_level(presence, warning_level); | |
5775 #endif | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5776 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5777 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5778 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5779 |
4649 | 5780 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5781 GaimConnection *gc = sess->aux_data; |
7283 | 5782 OscarData *od = gc->proto_data; |
4649 | 5783 va_list ap; |
5784 fu16_t code; | |
5785 char *msg; | |
5786 | |
5787 va_start(ap, fr); | |
5788 code = (fu16_t)va_arg(ap, int); | |
5789 msg = va_arg(ap, char *); | |
5790 va_end(ap); | |
5791 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5792 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
10458 | 5793 code, (msg != NULL ? msg : "")); |
5794 | |
5795 g_return_val_if_fail(fr != NULL, 1); | |
5796 g_return_val_if_fail(fr->conn != NULL, 1); | |
5797 | |
5798 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 5799 if (code == 0x0001) { |
6113 | 5800 gc->wants_to_die = TRUE; |
10715 | 5801 gaim_connection_error(gc, _("You have signed on from another location.")); |
4651 | 5802 } else { |
5579 | 5803 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 5804 } |
4666 | 5805 od->killme = TRUE; |
10458 | 5806 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
5807 struct chat_connection *cc; | |
5808 GaimConversation *conv; | |
5809 | |
5810 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
5811 conv = gaim_find_chat(gc, cc->id); | |
5812 | |
5813 if (conv != NULL) | |
5814 { | |
5815 gchar *buf; | |
5816 buf = g_strdup_printf(_("You have been disconnected from chat " | |
5817 "room %s."), cc->name); | |
5818 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
5819 g_free(buf); | |
5820 } | |
5821 oscar_chat_kill(gc, cc); | |
4649 | 5822 } |
5823 | |
5824 return 1; | |
5825 } | |
5826 | |
2675 | 5827 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 5828 GaimConnection *gc = sess->aux_data; |
12663 | 5829 OscarData *od = gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5830 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5831 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 5832 |
8660 | 5833 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 5834 aim_ssi_reqrights(sess); |
6350 | 5835 aim_ssi_reqdata(sess); |
12663 | 5836 if (od->getblisttimer > 0) |
5837 gaim_timeout_remove(od->getblisttimer); | |
5838 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od->sess); | |
4230 | 5839 |
7011 | 5840 aim_locate_reqrights(sess); |
7285 | 5841 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 5842 aim_im_reqparams(sess); |
7334 | 5843 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 5844 |
7283 | 5845 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
5846 | |
2086 | 5847 return 1; |
5848 } | |
5849 | |
2675 | 5850 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5851 GaimConnection *gc = sess->aux_data; |
7283 | 5852 OscarData *od = gc->proto_data; |
2647 | 5853 |
6905 | 5854 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
5855 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
5856 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
5857 | |
2672 | 5858 aim_clientready(sess, fr->conn); |
8660 | 5859 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5860 |
2647 | 5861 if (od->chpass) { |
8660 | 5862 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5863 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 5864 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5865 od->oldp = NULL; |
2647 | 5866 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5867 od->newp = NULL; |
2647 | 5868 od->chpass = FALSE; |
5869 } | |
2979 | 5870 if (od->setnick) { |
8660 | 5871 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 5872 aim_admin_setnick(sess, fr->conn, od->newsn); |
5873 g_free(od->newsn); | |
5874 od->newsn = NULL; | |
5875 od->setnick = FALSE; | |
5876 } | |
2647 | 5877 if (od->conf) { |
8660 | 5878 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5879 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 5880 od->conf = FALSE; |
5881 } | |
5882 if (od->reqemail) { | |
8660 | 5883 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5884 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 5885 od->reqemail = FALSE; |
5886 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5887 if (od->setemail) { |
8660 | 5888 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5889 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5890 g_free(od->email); |
5497 | 5891 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5892 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5893 } |
2647 | 5894 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5895 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5896 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5897 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5898 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
|
5899 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5900 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5901 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5902 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5903 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5904 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5905 |
4194 | 5906 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 5907 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 5908 "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
|
5909 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5910 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5911 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
5912 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5913 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5914 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 5915 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5916 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5917 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5918 |
4617 | 5919 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5920 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5921 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5922 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5923 |
2993 | 5924 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
5925 { | |
5575 | 5926 GaimConnection *gc = sess->aux_data; |
11338 | 5927 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 5928 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 5929 va_list ap; |
5930 fu16_t maxsiglen; | |
2993 | 5931 |
5932 va_start(ap, fr); | |
4199 | 5933 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 5934 va_end(ap); |
5935 | |
8660 | 5936 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5937 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 5938 |
4617 | 5939 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
5940 | |
5941 if (od->icq) | |
7334 | 5942 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 5943 else |
7334 | 5944 aim_locate_setcaps(od->sess, caps_aim); |
11965 | 5945 oscar_set_info_and_status(account, TRUE, account->user_info, TRUE, |
5946 gaim_account_get_active_status(account)); | |
2993 | 5947 |
5948 return 1; | |
5949 } | |
5950 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5951 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
|
5952 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5953 fu16_t maxbuddies, maxwatchers; |
5575 | 5954 GaimConnection *gc = sess->aux_data; |
7283 | 5955 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5956 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5957 va_start(ap, fr); |
4199 | 5958 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
5959 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5960 va_end(ap); |
5961 | |
8660 | 5962 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5963 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5964 |
4617 | 5965 od->rights.maxbuddies = (guint)maxbuddies; |
5966 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5967 |
2086 | 5968 return 1; |
5969 } | |
5970 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5971 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
11808 | 5972 GaimConnection *gc; |
5973 OscarData *od; | |
5974 GaimAccount *account; | |
5975 GaimStatus *status; | |
5976 const char *message; | |
12344 | 5977 char *tmp; |
7334 | 5978 va_list ap; |
5979 fu16_t maxpermits, maxdenies; | |
2086 | 5980 |
11808 | 5981 gc = sess->aux_data; |
5982 od = (OscarData *)gc->proto_data; | |
11809 | 5983 account = gaim_connection_get_account(gc); |
11808 | 5984 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5985 va_start(ap, fr); |
4199 | 5986 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5987 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5988 va_end(ap); |
5989 | |
8660 | 5990 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5991 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5992 |
4617 | 5993 od->rights.maxpermits = (guint)maxpermits; |
5994 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5995 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5996 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5997 |
8660 | 5998 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5999 |
2672 | 6000 aim_clientready(sess, fr->conn); |
11808 | 6001 |
6002 /* Set our available message based on the current status */ | |
6003 status = gaim_account_get_active_status(account); | |
6004 if (gaim_status_is_available(status)) | |
6005 message = gaim_status_get_attr_string(status, "message"); | |
11810 | 6006 else |
6007 message = NULL; | |
12344 | 6008 tmp = gaim_markup_strip_html(message); |
12349 | 6009 aim_srv_setstatusmsg(sess, tmp); |
12344 | 6010 free(tmp); |
11808 | 6011 |
7474 | 6012 aim_srv_setidle(sess, 0); |
4617 | 6013 |
4664 | 6014 if (od->icq) { |
6015 aim_icq_reqofflinemsgs(sess); | |
12652 | 6016 oscar_set_extendedstatus(gc); |
10570 | 6017 aim_icq_setsecurity(sess, |
6018 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
12652 | 6019 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE)); |
4664 | 6020 } |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6021 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
6022 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 6023 if (sess->authinfo->email) |
6024 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 6025 |
6026 return 1; | |
6027 } | |
6028 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6029 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
|
6030 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6031 struct aim_icq_offlinemsg *msg; |
4075 | 6032 struct aim_incomingim_ch4_args args; |
6033 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6034 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6035 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6036 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6037 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6038 |
8660 | 6039 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6040 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 6041 args.uin = msg->sender; |
6042 args.type = msg->type; | |
4173 | 6043 args.flags = msg->flags; |
4076 | 6044 args.msglen = msg->msglen; |
4075 | 6045 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
6046 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 6047 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6048 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6049 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6050 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6051 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6052 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
|
6053 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6054 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6055 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6056 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6057 |
4624 | 6058 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
|
6059 { |
5575 | 6060 GaimConnection *gc = sess->aux_data; |
8670 | 6061 OscarData *od = (OscarData *)gc->proto_data; |
6062 GaimBuddy *buddy; | |
8853 | 6063 struct buddyinfo *bi = NULL; |
4624 | 6064 gchar who[16]; |
8670 | 6065 GString *str; |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
6066 gchar *utf8; |
9634 | 6067 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6068 va_list ap; |
4151 | 6069 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6070 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6071 va_start(ap, fr); |
4151 | 6072 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6073 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6074 |
4664 | 6075 if (!info->uin) |
6076 return 0; | |
6077 | |
8670 | 6078 str = g_string_sized_new(100); |
5556 | 6079 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 6080 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
6081 if (buddy != NULL) | |
6082 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
6083 | |
6084 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6085 oscar_string_append(gc->account, str, "\n<br>", _("Nick"), info->nick); |
8670 | 6086 if ((bi != NULL) && (bi->ipaddr != 0)) { |
6087 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
6088 (bi->ipaddr & 0xff000000) >> 24, | |
6089 (bi->ipaddr & 0x00ff0000) >> 16, | |
6090 (bi->ipaddr & 0x0000ff00) >> 8, | |
6091 (bi->ipaddr & 0x000000ff)); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6092 oscar_string_append(gc->account, str, "\n<br>", _("IP Address"), tstr); |
8670 | 6093 g_free(tstr); |
6094 } | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6095 oscar_string_append(gc->account, str, "\n<br>", _("First Name"), info->first); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6096 oscar_string_append(gc->account, str, "\n<br>", _("Last Name"), info->last); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6097 if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) { |
8670 | 6098 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
6099 g_free(utf8); | |
4625 | 6100 } |
6101 if (info->numaddresses && info->email2) { | |
6102 int i; | |
6103 for (i = 0; i < info->numaddresses; i++) { | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6104 if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) { |
10683 | 6105 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
8670 | 6106 g_free(utf8); |
4643 | 6107 } |
4625 | 6108 } |
4624 | 6109 } |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6110 oscar_string_append(gc->account, str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 6111 if (info->gender != 0) |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6112 oscar_string_append(gc->account, str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); |
12491 | 6113 if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) { |
4627 | 6114 struct tm tm; |
6115 tm.tm_mday = (int)info->birthday; | |
6116 tm.tm_mon = (int)info->birthmonth-1; | |
6117 tm.tm_year = (int)info->birthyear-1900; | |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
6118 oscar_string_append(gc->account, str, "\n<br>", _("Birthday"), |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
6119 gaim_date_format_short(&tm)); |
4151 | 6120 } |
12491 | 6121 if ((info->age > 0) && (info->age < 255)) { |
4624 | 6122 char age[5]; |
6123 snprintf(age, sizeof(age), "%hhd", info->age); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6124 oscar_string_append(gc->account, str, "\n<br>", _("Age"), age); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6125 } |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6126 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) { |
8670 | 6127 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
6128 g_free(utf8); | |
4819 | 6129 } |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6130 if (info->info && info->info[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->info))) { |
8670 | 6131 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
6132 g_free(utf8); | |
6133 } | |
10683 | 6134 g_string_append_printf(str, "<hr>"); |
4641 | 6135 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 6136 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6137 oscar_string_append(gc->account, str, "\n<br>", _("Address"), info->homeaddr); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6138 oscar_string_append(gc->account, str, "\n<br>", _("City"), info->homecity); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6139 oscar_string_append(gc->account, str, "\n<br>", _("State"), info->homestate); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6140 oscar_string_append(gc->account, str, "\n<br>", _("Zip Code"), info->homezip); |
10683 | 6141 g_string_append_printf(str, "\n<hr>"); |
4151 | 6142 } |
4641 | 6143 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 6144 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6145 oscar_string_append(gc->account, str, "\n<br>", _("Address"), info->workaddr); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6146 oscar_string_append(gc->account, str, "\n<br>", _("City"), info->workcity); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6147 oscar_string_append(gc->account, str, "\n<br>", _("State"), info->workstate); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6148 oscar_string_append(gc->account, str, "\n<br>", _("Zip Code"), info->workzip); |
10683 | 6149 g_string_append_printf(str, "\n<hr>"); |
4624 | 6150 } |
4641 | 6151 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 6152 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6153 oscar_string_append(gc->account, str, "\n<br>", _("Company"), info->workcompany); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6154 oscar_string_append(gc->account, str, "\n<br>", _("Division"), info->workdivision); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6155 oscar_string_append(gc->account, str, "\n<br>", _("Position"), info->workposition); |
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6156 if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) { |
8670 | 6157 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
6158 g_free(utf8); | |
4624 | 6159 } |
10683 | 6160 g_string_append_printf(str, "\n<hr>"); |
8670 | 6161 } |
6162 | |
9634 | 6163 if (buddy != NULL) |
6164 alias = gaim_buddy_get_alias(buddy); | |
6165 else | |
6166 alias = who; | |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
6167 gaim_notify_userinfo(gc, who, str->str, NULL, NULL); |
8670 | 6168 g_string_free(str, TRUE); |
4151 | 6169 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6170 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6171 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6172 |
4759 | 6173 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
6174 { | |
5575 | 6175 GaimConnection *gc = sess->aux_data; |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6176 GaimAccount *account = gaim_connection_get_account(gc); |
4820 | 6177 gchar who[16], *utf8; |
6695 | 6178 GaimBuddy *b; |
4759 | 6179 va_list ap; |
6180 struct aim_icq_info *info; | |
6181 | |
6182 va_start(ap, fr); | |
6183 info = va_arg(ap, struct aim_icq_info *); | |
6184 va_end(ap); | |
6185 | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6186 if (info->uin && info->nick && info->nick[0] && (utf8 = oscar_utf8_try_convert(account, info->nick))) { |
5556 | 6187 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 6188 serv_got_alias(gc, who, utf8); |
4759 | 6189 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 6190 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 6191 } |
4820 | 6192 g_free(utf8); |
4759 | 6193 } |
6194 | |
6195 return 1; | |
6196 } | |
6197 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6198 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
|
6199 { |
7032 | 6200 GaimConnection *gc = sess->aux_data; |
6201 gchar *text; | |
6202 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6203 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6204 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6205 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6206 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6207 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6208 url = va_arg(ap, char *); |
4199 | 6209 wid = (fu16_t) va_arg(ap, int); |
6210 hei = (fu16_t) va_arg(ap, int); | |
6211 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6212 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6213 |
7032 | 6214 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
6215 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
6216 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6217 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6218 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6219 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6220 |
11359 | 6221 static void oscar_searchresults_add_buddy_cb(GaimConnection *gc, GList *row) |
6222 { | |
6223 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), | |
6224 g_list_nth_data(row, 0), NULL, NULL); | |
6225 } | |
6226 | |
7032 | 6227 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
6228 { | |
6873 | 6229 GaimConnection *gc = sess->aux_data; |
11359 | 6230 GaimNotifySearchResults *results; |
6231 GaimNotifySearchColumn *column; | |
6873 | 6232 gchar *secondary; |
6233 int i, num; | |
2086 | 6234 va_list ap; |
6873 | 6235 char *email, *SNs; |
2086 | 6236 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6237 va_start(ap, fr); |
6873 | 6238 email = va_arg(ap, char *); |
2086 | 6239 num = va_arg(ap, int); |
6240 SNs = va_arg(ap, char *); | |
6241 va_end(ap); | |
6242 | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6243 results = gaim_notify_searchresults_new(); |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6244 |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6245 if (results == NULL) { |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6246 gaim_debug_error("oscar", "gaim_parse_searchreply: " |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6247 "Unable to display the search results.\n"); |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6248 gaim_notify_error(gc, NULL, |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6249 _("Unable to display the search results."), |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6250 NULL); |
12260 | 6251 return 1; |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6252 } |
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6253 |
12254
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6254 secondary = g_strdup_printf( |
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6255 ngettext("The following screen name is associated with %s", |
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6256 "The following screen names are associated with %s", |
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6257 num), |
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6258 email); |
10439 | 6259 |
11359 | 6260 column = gaim_notify_searchresults_column_new("Screen name"); |
6261 gaim_notify_searchresults_column_add(results, column); | |
6262 | |
6263 for (i = 0; i < num; i++) { | |
6264 GList *row = NULL; | |
6265 row = g_list_append(row, g_strdup(&SNs[i * (MAXSNLEN + 1)])); | |
6266 gaim_notify_searchresults_row_add(results, row); | |
6267 } | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12617
diff
changeset
|
6268 gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD, |
11359 | 6269 oscar_searchresults_add_buddy_cb); |
6270 gaim_notify_searchresults(gc, NULL, NULL, secondary, results, NULL, NULL); | |
6873 | 6271 |
6272 g_free(secondary); | |
2086 | 6273 |
6274 return 1; | |
6275 } | |
6276 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6277 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 6278 va_list ap; |
6873 | 6279 char *email; |
5420 | 6280 char *buf; |
2086 | 6281 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6282 va_start(ap, fr); |
6873 | 6283 email = va_arg(ap, char *); |
2086 | 6284 va_end(ap); |
6285 | |
6873 | 6286 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
|
6287 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 6288 g_free(buf); |
2086 | 6289 |
6290 return 1; | |
6291 } | |
6292 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6293 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 6294 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6295 fu16_t status; |
2086 | 6296 va_list ap; |
6297 char msg[256]; | |
6298 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6299 va_start(ap, fr); |
4199 | 6300 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 6301 va_end(ap); |
6302 | |
8660 | 6303 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6304 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 6305 status ? "unknown" : "email sent"); |
6306 if (!status) { | |
5302 | 6307 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 6308 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6309 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 6310 } |
6311 | |
6312 return 1; | |
6313 } | |
6314 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6315 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6316 GaimConnection *gc = sess->aux_data; |
2086 | 6317 va_list ap; |
3912 | 6318 fu16_t perms, err; |
6319 char *url, *sn, *email; | |
6320 int change; | |
2086 | 6321 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6322 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6323 change = va_arg(ap, int); |
4199 | 6324 perms = (fu16_t) va_arg(ap, unsigned int); |
6325 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 6326 url = va_arg(ap, char *); |
6327 sn = va_arg(ap, char *); | |
6328 email = va_arg(ap, char *); | |
2086 | 6329 va_end(ap); |
6330 | |
8660 | 6331 gaim_debug_misc("oscar", |
9626 | 6332 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
6333 change ? "change" : "request", perms, err, | |
6334 (url != NULL) ? url : "(null)", | |
6335 (sn != NULL) ? sn : "(null)", | |
6336 (email != NULL) ? email : "(null)"); | |
6337 | |
6338 if ((err > 0) && (url != NULL)) { | |
3912 | 6339 char *dialog_msg; |
6340 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
6341 switch (err) { | |
6342 case 0x0001: { | |
6343 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
6344 } break; | |
6345 case 0x0006: { | |
11399 | 6346 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because it is invalid."), err); |
3912 | 6347 } break; |
6348 case 0x000b: { | |
6349 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
6350 } break; | |
6351 case 0x001d: { | |
6352 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); | |
6353 } break; | |
6354 case 0x0021: { | |
6355 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); | |
6356 } break; | |
6357 case 0x0023: { | |
6358 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
6359 } break; | |
6360 default: { | |
6361 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
6362 } break; | |
6363 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6364 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 6365 g_free(dialog_top); |
6366 g_free(dialog_msg); | |
6367 return 1; | |
6368 } | |
6369 | |
9626 | 6370 if (sn != NULL) { |
4585 | 6371 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
|
6372 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 6373 g_free(dialog_msg); |
6374 } | |
6375 | |
9626 | 6376 if (email != NULL) { |
5575 | 6377 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
6378 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6379 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 6380 g_free(dialog_msg); |
2086 | 6381 } |
6382 | |
6383 return 1; | |
6384 } | |
6385 | |
5575 | 6386 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 6387 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 6388 aim_flap_nop(od->sess, od->conn); |
2086 | 6389 } |
6390 | |
6059 | 6391 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 6392 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 6393 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
6394 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6395 if (typing == GAIM_TYPING) |
4870 | 6396 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6397 else if (typing == GAIM_TYPED) |
4870 | 6398 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
6399 else | |
6400 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 6401 else { |
5300 | 6402 /* Don't send if this turkey is in our deny list */ |
6403 GSList *list; | |
6404 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
6405 if (!list) { | |
7261 | 6406 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 6407 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6408 if (typing == GAIM_TYPING) |
5300 | 6409 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6410 else if (typing == GAIM_TYPED) |
5300 | 6411 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
6412 else | |
6413 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
6414 } | |
3595 | 6415 } |
6416 } | |
2993 | 6417 return 0; |
6418 } | |
9030 | 6419 |
12216 | 6420 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimMessageFlags); |
6421 | |
6422 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimMessageFlags imflags) { | |
7283 | 6423 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 6424 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 6425 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
|
6426 int ret = 0; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6427 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); |
12677 | 6428 char *tmp1, *tmp2; |
6429 | |
6430 if (imflags & GAIM_MESSAGE_AUTO_RESP) | |
6431 tmp1 = gaim_str_sub_away_formatters(message, name); | |
6432 else | |
6433 tmp1 = g_strdup(message); | |
3458 | 6434 |
4838 | 6435 if (dim && dim->connected) { |
6436 /* If we're directly connected, send a direct IM */ | |
12677 | 6437 ret = gaim_odc_send_im(od->sess, dim->conn, tmp1, imflags); |
2086 | 6438 } else { |
4738 | 6439 struct buddyinfo *bi; |
3008 | 6440 struct aim_sendimext_args args; |
6441 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
6442 gsize len; |
10246 | 6443 GaimConversation *conv; |
6444 | |
11338 | 6445 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account); |
8962 | 6446 |
12677 | 6447 if (strstr(tmp1, "<IMG ")) |
8962 | 6448 gaim_conversation_write(conv, "", |
6449 _("Your IM Image was not sent. " | |
6450 "You must be Direct Connected to send IM Images."), | |
6451 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 6452 |
10246 | 6453 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 6454 if (!bi) { |
6455 bi = g_new0(struct buddyinfo, 1); | |
10246 | 6456 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 6457 } |
6458 | |
3008 | 6459 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 6460 if (od->icq) { |
11185 | 6461 /* We have to present different "features" (whose meaning |
11172 | 6462 is unclear and are merely a result of protocol inspection) |
6463 to offline ICQ buddies. Otherwise, the official | |
6464 ICQ client doesn't treat those messages as being "ANSI- | |
6465 encoded" (and instead, assumes them to be UTF-8). | |
6466 For more details, see SF issue 1179452. | |
6467 */ | |
6468 GaimBuddy *buddy = gaim_find_buddy(gc->account, name); | |
11910 | 6469 if (buddy && GAIM_BUDDY_IS_ONLINE(buddy)) { |
11172 | 6470 args.features = features_icq; |
6471 args.featureslen = sizeof(features_icq); | |
6472 } else { | |
6473 args.features = features_icq_offline; | |
6474 args.featureslen = sizeof(features_icq_offline); | |
6475 } | |
3008 | 6476 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 6477 } else { |
6478 args.features = features_aim; | |
6479 args.featureslen = sizeof(features_aim); | |
4972 | 6480 |
12216 | 6481 if (imflags & GAIM_MESSAGE_AUTO_RESP) |
4972 | 6482 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 6483 } |
4269 | 6484 |
4738 | 6485 if (bi->ico_need) { |
8660 | 6486 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6487 "Sending buddy icon request with message\n"); |
3008 | 6488 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 6489 bi->ico_need = FALSE; |
3008 | 6490 } |
4269 | 6491 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6492 if (iconfile && !g_stat(iconfile, &st)) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6493 FILE *file = g_fopen(iconfile, "rb"); |
3008 | 6494 if (file) { |
11159 | 6495 guchar *buf = g_malloc(st.st_size); |
9532 | 6496 /* XXX - Use g_file_get_contents()? */ |
3008 | 6497 fread(buf, 1, st.st_size, file); |
6039 | 6498 fclose(file); |
4269 | 6499 |
3008 | 6500 args.iconlen = st.st_size; |
4617 | 6501 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 6502 args.iconstamp = st.st_mtime; |
6503 | |
7406 | 6504 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 6505 bi->ico_informed = FALSE; |
7406 | 6506 bi->ico_sent = FALSE; |
6507 } | |
4738 | 6508 |
6509 if (!bi->ico_informed) { | |
8660 | 6510 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6511 "Claiming to have a buddy icon\n"); |
4738 | 6512 args.flags |= AIM_IMFLAGS_HASICON; |
6513 bi->ico_me_len = args.iconlen; | |
6514 bi->ico_me_csum = args.iconsum; | |
6515 bi->ico_me_time = args.iconstamp; | |
6516 bi->ico_informed = TRUE; | |
6517 } | |
6518 | |
3008 | 6519 g_free(buf); |
2086 | 6520 } |
6521 } | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6522 g_free(iconfile); |
4269 | 6523 |
3008 | 6524 args.destsn = name; |
4269 | 6525 |
8985 | 6526 /* |
13165
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6527 * If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML. |
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6528 */ |
13168
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13165
diff
changeset
|
6529 if (aim_sn_is_sms(name)) { |
13165
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6530 /* Messaging an SMS (mobile) user */ |
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6531 tmp2 = gaim_unescape_html(tmp1); |
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6532 } else if (aim_sn_is_icq(gaim_account_get_username(account))) { |
10781 | 6533 if (aim_sn_is_icq(name)) |
6534 /* From ICQ to ICQ */ | |
12677 | 6535 tmp2 = gaim_unescape_html(tmp1); |
10781 | 6536 else |
6537 /* From ICQ to AIM */ | |
12677 | 6538 tmp2 = g_strdup(tmp1); |
8995 | 6539 } else { |
10785 | 6540 /* From AIM to AIM and AIM to ICQ */ |
12677 | 6541 tmp2 = g_strdup(tmp1); |
8995 | 6542 } |
12677 | 6543 g_free(tmp1); |
6544 tmp1 = tmp2; | |
6545 len = strlen(tmp1); | |
6546 | |
6547 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmp1, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); | |
9830 | 6548 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", |
6549 args.charset, args.charsubset, args.msglen); | |
4617 | 6550 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 6551 g_free((char *)args.msg); |
2086 | 6552 } |
4838 | 6553 |
12677 | 6554 g_free(tmp1); |
6310 | 6555 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6556 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6557 return 1; |
6310 | 6558 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6559 return ret; |
2086 | 6560 } |
6561 | |
7011 | 6562 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 6563 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 6564 |
9975 | 6565 if (od->icq && aim_sn_is_icq(name)) |
4624 | 6566 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6567 else |
7235 | 6568 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 6569 } |
6570 | |
8950 | 6571 #if 0 |
7011 | 6572 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 6573 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 6574 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 6575 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 6576 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 6577 maiden, NULL, NULL, city, state, NULL, 0, web); |
6578 } | |
8950 | 6579 #endif |
2086 | 6580 |
5575 | 6581 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 6582 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 6583 aim_srv_setidle(od->sess, time); |
2086 | 6584 } |
6585 | |
11347 | 6586 static |
6587 gchar *gaim_prpl_oscar_convert_to_infotext(const gchar *str, gsize *ret_len, char **encoding) | |
6588 { | |
9807 | 6589 int charset = 0; |
11347 | 6590 char *encoded = NULL; |
6591 | |
6592 charset = oscar_charset_check(str); | |
6593 if (charset == AIM_CHARSET_UNICODE) { | |
6594 encoded = g_convert(str, strlen(str), "UCS-2BE", "UTF-8", NULL, ret_len, NULL); | |
6595 *encoding = "unicode-2-0"; | |
6596 } else if (charset == AIM_CHARSET_CUSTOM) { | |
6597 encoded = g_convert(str, strlen(str), "ISO-8859-1", "UTF-8", NULL, ret_len, NULL); | |
6598 *encoding = "iso-8859-1"; | |
6599 } else { | |
6600 encoded = g_strdup(str); | |
6601 *ret_len = strlen(str); | |
6602 *encoding = "us-ascii"; | |
6603 } | |
6604 | |
6605 return encoded; | |
6606 } | |
6607 | |
6608 static void | |
6609 oscar_set_info(GaimConnection *gc, const char *rawinfo) | |
6610 { | |
11965 | 6611 GaimAccount *account; |
11347 | 6612 GaimStatus *status; |
11965 | 6613 |
6614 account = gaim_connection_get_account(gc); | |
6615 status = gaim_account_get_active_status(account); | |
6616 oscar_set_info_and_status(account, TRUE, rawinfo, FALSE, status); | |
6617 } | |
6618 | |
6619 static void | |
6620 oscar_set_extendedstatus(GaimConnection *gc) | |
6621 { | |
6622 OscarData *od; | |
6623 GaimAccount *account; | |
12653 | 6624 GaimStatus *status; |
6625 const gchar *status_id; | |
12652 | 6626 fu32_t data = 0x00000000; |
11965 | 6627 |
6628 od = gc->proto_data; | |
6629 account = gaim_connection_get_account(gc); | |
12653 | 6630 status = gaim_account_get_active_status(account); |
6631 status_id = gaim_status_get_id(status); | |
11965 | 6632 |
12652 | 6633 data |= AIM_ICQ_STATE_HIDEIP; |
6634 if (gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE)) | |
6635 data |= AIM_ICQ_STATE_WEBAWARE; | |
6636 | |
12653 | 6637 if (!strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE) || !strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE)) |
6638 data |= AIM_ICQ_STATE_NORMAL; | |
6639 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
6640 data |= AIM_ICQ_STATE_AWAY; | |
6641 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
6642 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY; | |
6643 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
6644 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY; | |
6645 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
6646 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY; | |
6647 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
6648 data |= AIM_ICQ_STATE_CHAT; | |
6649 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
12652 | 6650 data |= AIM_ICQ_STATE_INVISIBLE; |
12653 | 6651 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) |
6652 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY; | |
12652 | 6653 |
6654 aim_setextstatus(od->sess, data); | |
11965 | 6655 } |
6656 | |
6657 static void | |
6658 oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo, | |
6659 gboolean setstatus, GaimStatus *status) | |
6660 { | |
6661 GaimConnection *gc = gaim_account_get_connection(account); | |
6662 OscarData *od = gc->proto_data; | |
6663 GaimPresence *presence; | |
11347 | 6664 GaimStatusType *status_type; |
6665 GaimStatusPrimitive primitive; | |
11965 | 6666 gboolean invisible; |
11347 | 6667 |
6668 char *htmlinfo; | |
6669 char *info_encoding = NULL; | |
6670 char *info = NULL; | |
6671 gsize infolen = 0; | |
6672 | |
6673 const char *htmlaway; | |
6674 char *away_encoding = NULL; | |
6675 char *away = NULL; | |
6676 gsize awaylen = 0; | |
6677 | |
6678 status_type = gaim_status_get_type(status); | |
6679 primitive = gaim_status_type_get_primitive(status_type); | |
11965 | 6680 presence = gaim_account_get_presence(account); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
6681 invisible = gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE); |
11965 | 6682 |
6683 if (!setinfo) | |
6684 { | |
6685 /* Do nothing! */ | |
6686 } | |
6687 else if (od->rights.maxsiglen == 0) | |
6688 { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6689 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6690 _("You have probably requested to set your " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6691 "profile before the login procedure completed. " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6692 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6693 "again when you are fully connected.")); |
11965 | 6694 } |
6695 else if (rawinfo != NULL) | |
11347 | 6696 { |
6697 htmlinfo = gaim_strdup_withhtml(rawinfo); | |
6698 info = gaim_prpl_oscar_convert_to_infotext(htmlinfo, &infolen, &info_encoding); | |
6699 g_free(htmlinfo); | |
6700 | |
6701 if (infolen > od->rights.maxsiglen) | |
6702 { | |
6703 gchar *errstr; | |
6704 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
6705 "has been exceeded. Gaim has truncated it for you.", | |
6706 "The maximum profile length of %d bytes " | |
6707 "has been exceeded. Gaim has truncated it for you.", | |
6708 od->rights.maxsiglen), od->rights.maxsiglen); | |
6709 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
6710 g_free(errstr); | |
6711 } | |
6712 } | |
6713 | |
11965 | 6714 if (!setstatus) |
6715 { | |
6716 /* Do nothing! */ | |
6717 } | |
6718 else if (primitive == GAIM_STATUS_AVAILABLE) | |
11347 | 6719 { |
12349 | 6720 const char *status_html; |
6721 char *status_text; | |
6722 | |
6723 status_html = gaim_status_get_attr_string(status, "message"); | |
6724 if (status_html != NULL) | |
11965 | 6725 { |
12349 | 6726 status_text = gaim_markup_strip_html(status_html); |
12617 | 6727 /* If the status_text is longer than 60 character then truncate it */ |
6728 if (strlen(status_text) > 60) | |
6729 { | |
6730 char *tmp = g_utf8_find_prev_char(status_text, &status_text[58]); | |
6731 strcpy(tmp, "..."); | |
6732 } | |
12349 | 6733 aim_srv_setstatusmsg(od->sess, status_text); |
6734 g_free(status_text); | |
11965 | 6735 } |
6736 | |
6737 /* This is needed for us to un-set any previous away message. */ | |
6738 away = g_strdup(""); | |
6739 } | |
6740 else if (primitive == GAIM_STATUS_AWAY) | |
6741 { | |
11347 | 6742 htmlaway = gaim_status_get_attr_string(status, "message"); |
11965 | 6743 if ((htmlaway == NULL) || (*htmlaway == '\0')) |
11347 | 6744 htmlaway = _("Away"); |
6745 away = gaim_prpl_oscar_convert_to_infotext(htmlaway, &awaylen, &away_encoding); | |
6746 | |
6747 if (awaylen > od->rights.maxawaymsglen) | |
6748 { | |
6749 gchar *errstr; | |
6750 | |
6751 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
6752 "has been exceeded. Gaim has truncated it for you.", | |
6753 "The maximum away message length of %d bytes " | |
6754 "has been exceeded. Gaim has truncated it for you.", | |
6755 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
6756 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
6757 g_free(errstr); | |
6758 } | |
6759 } | |
6760 | |
11965 | 6761 if (setstatus) |
6762 oscar_set_extendedstatus(gc); | |
6763 | |
11347 | 6764 aim_locate_setprofile(od->sess, info_encoding, info, MIN(infolen, od->rights.maxsiglen), |
6765 away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen)); | |
6766 g_free(info); | |
6767 g_free(away); | |
2086 | 6768 } |
6769 | |
9991 | 6770 static void |
6771 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 6772 { |
9991 | 6773 GaimConnection *gc = gaim_account_get_connection(account); |
10646 | 6774 OscarData *od = NULL; |
9991 | 6775 |
10646 | 6776 if (gc) |
6777 od = (OscarData *)gc->proto_data; | |
6778 if (!od) | |
6779 return; | |
6780 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
6781 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_INVISIBLE) |
11766 | 6782 account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; |
8265 | 6783 else |
11766 | 6784 account->perm_deny = GAIM_PRIVACY_DENY_USERS; |
9991 | 6785 |
8265 | 6786 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
6787 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 6788 |
12653 | 6789 oscar_set_extendedstatus(gc); |
2993 | 6790 } |
6791 | |
9991 | 6792 static void |
6793 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 6794 { |
10747 | 6795 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
6796 | |
10498 | 6797 if (!gaim_status_is_active(status)) |
10485 | 6798 return; |
6799 | |
11718 | 6800 if (!gaim_account_is_connected(account)) |
6801 return; | |
6802 | |
12653 | 6803 /* Set the AIM-style away message for both AIM and ICQ accounts */ |
6804 oscar_set_info_and_status(account, FALSE, NULL, TRUE, status); | |
6805 | |
6806 /* Set the ICQ status for ICQ accounts only */ | |
11718 | 6807 if (aim_sn_is_icq(gaim_account_get_username(account))) |
6808 oscar_set_status_icq(account, status); | |
2086 | 6809 } |
6810 | |
11285 | 6811 #ifdef CRAZY_WARN |
9991 | 6812 static void |
6813 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 6814 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 6815 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 6816 } |
11285 | 6817 #endif |
2086 | 6818 |
10747 | 6819 static void |
6820 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6821 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6822 |
6823 if (!aim_snvalid(buddy->name)) { | |
8092 | 6824 gchar *buf; |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6825 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 | 6826 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
6827 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 6828 g_free(buf); |
8150 | 6829 |
6830 /* Remove from local list */ | |
9285 | 6831 gaim_blist_remove_buddy(buddy); |
8150 | 6832 |
8092 | 6833 return; |
6834 } | |
6835 | |
9285 | 6836 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
6837 if (buddy && group) { | |
8660 | 6838 gaim_debug_info("oscar", |
9285 | 6839 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 6840 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 6841 } |
6842 } | |
8150 | 6843 |
10157 | 6844 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 6845 if (od->icq) |
9285 | 6846 aim_icq_getalias(od->sess, buddy->name); |
6847 } | |
6848 | |
6849 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
7283 | 6850 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 6851 |
4230 | 6852 if (od->sess->ssi.received_data) { |
8660 | 6853 gaim_debug_info("oscar", |
9285 | 6854 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
6855 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 6856 } |
10866 | 6857 } |
6858 | |
5575 | 6859 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 6860 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 6861 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 6862 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6863 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 6864 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 6865 } |
6866 } | |
6867 | |
5575 | 6868 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 6869 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 6870 if (od->sess->ssi.received_data) { |
6871 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
6872 if (gname) { | |
8660 | 6873 gaim_debug_info("oscar", |
9586 | 6874 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 6875 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 6876 } |
6877 } | |
6878 } | |
6879 | |
11005 | 6880 /* |
6881 * FYI, the OSCAR SSI code removes empty groups automatically. | |
6882 */ | |
9285 | 6883 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 6884 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6885 |
6886 if (od->sess->ssi.received_data) { | |
9285 | 6887 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
6888 GList *cur, *groups = NULL; | |
11643 | 6889 GaimAccount *account = gaim_connection_get_account(gc); |
9285 | 6890 |
6891 /* Make a list of what the groups each buddy is in */ | |
6892 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
6893 GaimBlistNode *node = cur->data; | |
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6894 /* node is GaimBuddy, parent is a GaimContact. |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6895 * We must go two levels up to get the Group */ |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6896 groups = g_list_append(groups, |
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6897 node->parent->parent); |
9285 | 6898 } |
6899 | |
11643 | 6900 gaim_account_remove_buddies(account, moved_buddies, groups); |
6901 gaim_account_add_buddies(account, moved_buddies); | |
9285 | 6902 g_list_free(groups); |
8660 | 6903 gaim_debug_info("oscar", |
9285 | 6904 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 6905 } else { |
9285 | 6906 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 6907 gaim_debug_info("oscar", |
9285 | 6908 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 6909 } |
6910 } | |
6911 } | |
6912 | |
5968 | 6913 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
6914 aim_session_t *sess = data; | |
12663 | 6915 |
6350 | 6916 aim_ssi_reqdata(sess); |
12663 | 6917 |
13060 | 6918 return TRUE; |
5968 | 6919 } |
6920 | |
4642 | 6921 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6922 GaimConnection *gc = sess->aux_data; |
7283 | 6923 OscarData *od = gc->proto_data; |
4642 | 6924 va_list ap; |
6925 fu16_t reason; | |
6926 | |
6927 va_start(ap, fr); | |
6928 reason = (fu16_t)va_arg(ap, unsigned int); | |
6929 va_end(ap); | |
6930 | |
8660 | 6931 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 6932 |
6933 if (reason == 0x0005) { | |
5892 | 6934 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6935 _("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.")); |
12663 | 6936 if (od->getblisttimer > 0) |
6937 gaim_timeout_remove(od->getblisttimer); | |
6938 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od->sess); | |
4642 | 6939 } |
6940 | |
11965 | 6941 oscar_set_extendedstatus(gc); |
6942 | |
4642 | 6943 /* Activate SSI */ |
6944 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6945 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6946 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 6947 aim_ssi_enable(od->sess); |
6948 | |
6949 return 1; | |
6950 } | |
6951 | |
2991 | 6952 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6953 GaimConnection *gc = sess->aux_data; |
7283 | 6954 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 6955 int i; |
6956 va_list ap; | |
6957 int numtypes; | |
4230 | 6958 fu16_t *maxitems; |
2991 | 6959 |
6960 va_start(ap, fr); | |
4230 | 6961 numtypes = va_arg(ap, int); |
6962 maxitems = va_arg(ap, fu16_t *); | |
2991 | 6963 va_end(ap); |
6964 | |
8660 | 6965 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6966 |
4230 | 6967 for (i=0; i<numtypes; i++) |
8660 | 6968 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6969 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6970 |
8660 | 6971 gaim_debug_misc(NULL, "\n"); |
4230 | 6972 |
6973 if (numtypes >= 0) | |
6974 od->rights.maxbuddies = maxitems[0]; | |
6975 if (numtypes >= 1) | |
6976 od->rights.maxgroups = maxitems[1]; | |
6977 if (numtypes >= 2) | |
6978 od->rights.maxpermits = maxitems[2]; | |
6979 if (numtypes >= 3) | |
6980 od->rights.maxdenies = maxitems[3]; | |
2991 | 6981 |
6982 return 1; | |
6983 } | |
6984 | |
11965 | 6985 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) |
6986 { | |
6987 GaimConnection *gc; | |
6988 OscarData *od; | |
6989 GaimAccount *account; | |
8150 | 6990 GaimGroup *g; |
6991 GaimBuddy *b; | |
2995 | 6992 struct aim_ssi_item *curitem; |
12317
1baf4cbcf84d
[gaim-migrate @ 14621]
Richard Laager <rlaager@wiktel.com>
parents:
12271
diff
changeset
|
6993 fu32_t tmp; |
4230 | 6994 va_list ap; |
8219 | 6995 fu16_t fmtver, numitems; |
6996 struct aim_ssi_item *items; | |
6997 fu32_t timestamp; | |
4230 | 6998 |
11965 | 6999 gc = sess->aux_data; |
7000 od = gc->proto_data; | |
7001 account = gaim_connection_get_account(gc); | |
7002 | |
4230 | 7003 va_start(ap, fr); |
7004 fmtver = (fu16_t)va_arg(ap, int); | |
7005 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 7006 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 7007 timestamp = va_arg(ap, fu32_t); |
8219 | 7008 va_end(ap); |
2991 | 7009 |
12663 | 7010 /* Don't attempt to re-request our buddy list later */ |
7011 if (od->getblisttimer != 0) | |
7012 gaim_timeout_remove(od->getblisttimer); | |
7013 od->getblisttimer = 0; | |
7014 | |
8660 | 7015 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7016 "ssi: syncing local list and server list\n"); |
2991 | 7017 |
8219 | 7018 if ((timestamp == 0) || (numitems == 0)) { |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7019 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 | 7020 return 1; |
7021 } | |
7022 | |
2991 | 7023 /* Clean the buddy list */ |
4889 | 7024 aim_ssi_cleanlist(sess); |
2991 | 7025 |
8150 | 7026 { /* If not in server list then prune from local list */ |
7027 GaimBlistNode *gnode, *cnode, *bnode; | |
7028 GaimBuddyList *blist; | |
9539 | 7029 GSList *cur, *next; |
8150 | 7030 |
7031 /* Buddies */ | |
7032 cur = NULL; | |
7033 if ((blist = gaim_get_blist()) != NULL) { | |
7034 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
7035 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
7036 continue; | |
7037 g = (GaimGroup *)gnode; | |
7038 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
7039 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
7040 continue; | |
7041 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
7042 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7043 continue; | |
7044 b = (GaimBuddy *)bnode; | |
7045 if (b->account == gc->account) { | |
7046 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
7047 /* If the buddy is an ICQ user then load his nickname */ | |
7048 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 7049 char *alias; |
8150 | 7050 if (servernick) |
7051 serv_got_alias(gc, b->name, servernick); | |
7052 | |
7053 /* Store local alias on server */ | |
8214 | 7054 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 7055 if (!alias && b->alias && strlen(b->alias)) |
7056 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
7057 free(alias); | |
7058 } else { | |
8660 | 7059 gaim_debug_info("oscar", |
8150 | 7060 "ssi: removing buddy %s from local list\n", b->name); |
7061 /* We can't actually remove now because it will screw up our looping */ | |
7062 cur = g_slist_prepend(cur, b); | |
7063 } | |
7064 } | |
7065 } | |
7066 } | |
7067 } | |
7068 } | |
8175 | 7069 |
8150 | 7070 while (cur != NULL) { |
7071 b = cur->data; | |
7072 cur = g_slist_remove(cur, b); | |
7073 gaim_blist_remove_buddy(b); | |
7074 } | |
7075 | |
7076 /* Permit list */ | |
7077 if (gc->account->permit) { | |
9539 | 7078 next = gc->account->permit; |
7079 while (next != NULL) { | |
7080 cur = next; | |
7081 next = next->next; | |
8150 | 7082 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 7083 gaim_debug_info("oscar", |
8150 | 7084 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
7085 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
7086 } | |
9539 | 7087 } |
8150 | 7088 } |
7089 | |
7090 /* Deny list */ | |
7091 if (gc->account->deny) { | |
9539 | 7092 next = gc->account->deny; |
7093 while (next != NULL) { | |
7094 cur = next; | |
7095 next = next->next; | |
8150 | 7096 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 7097 gaim_debug_info("oscar", |
8150 | 7098 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
7099 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
7100 } | |
9539 | 7101 } |
8150 | 7102 } |
7103 /* Presence settings (idle time visibility) */ | |
7104 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
7105 if (!(tmp & 0x400)) | |
7106 aim_ssi_setpresence(sess, tmp | 0x400); | |
7107 } /* end pruning buddies from local list */ | |
7108 | |
2991 | 7109 /* Add from server list to local list */ |
4230 | 7110 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 7111 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 7112 switch (curitem->type) { |
4230 | 7113 case 0x0000: { /* Buddy */ |
4251 | 7114 if (curitem->name) { |
4292 | 7115 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7116 char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL; |
4282 | 7117 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7118 char *alias_utf8 = alias ? oscar_utf8_try_convert(gc->account, alias) : NULL; |
8150 | 7119 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 7120 /* Should gname be freed here? -- elb */ |
4754 | 7121 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 7122 free(alias); |
8150 | 7123 if (b) { |
4292 | 7124 /* Get server stored alias */ |
4705 | 7125 if (alias_utf8) { |
8150 | 7126 g_free(b->alias); |
7127 b->alias = g_strdup(alias_utf8); | |
4705 | 7128 } |
4282 | 7129 } else { |
8150 | 7130 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 7131 |
4754 | 7132 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 7133 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 7134 gaim_blist_add_group(g, NULL); |
7135 } | |
5146 | 7136 |
8660 | 7137 gaim_debug_info("oscar", |
9285 | 7138 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 7139 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 7140 } |
8341 | 7141 if (!aim_sncmp(curitem->name, account->username)) { |
7142 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
7143 gaim_check_comment(od, comment); | |
7144 free(comment); | |
7145 } | |
7162 | 7146 g_free(gname_utf8); |
7147 g_free(alias_utf8); | |
2991 | 7148 } |
4230 | 7149 } break; |
7150 | |
7151 case 0x0001: { /* Group */ | |
4282 | 7152 /* Shouldn't add empty groups */ |
4230 | 7153 } break; |
7154 | |
7155 case 0x0002: { /* Permit buddy */ | |
2991 | 7156 if (curitem->name) { |
4230 | 7157 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 7158 GSList *list; |
5575 | 7159 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 7160 if (!list) { |
8660 | 7161 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7162 "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
|
7163 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 7164 } |
7165 } | |
4230 | 7166 } break; |
7167 | |
7168 case 0x0003: { /* Deny buddy */ | |
2991 | 7169 if (curitem->name) { |
7170 GSList *list; | |
5575 | 7171 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 7172 if (!list) { |
8660 | 7173 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7174 "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
|
7175 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 7176 } |
7177 } | |
4230 | 7178 } break; |
7179 | |
7180 case 0x0004: { /* Permit/deny setting */ | |
2991 | 7181 if (curitem->data) { |
7182 fu8_t permdeny; | |
5575 | 7183 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 7184 gaim_debug_info("oscar", |
5575 | 7185 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
7186 account->perm_deny = permdeny; | |
11766 | 7187 if (od->icq && account->perm_deny == GAIM_PRIVACY_ALLOW_USERS) { |
7188 gaim_presence_set_status_active(account->presence, OSCAR_STATUS_ID_INVISIBLE, TRUE); | |
4342 | 7189 } |
2991 | 7190 } |
7191 } | |
4230 | 7192 } break; |
7193 | |
7194 case 0x0005: { /* Presence setting */ | |
3109 | 7195 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 7196 } break; |
2991 | 7197 } /* End of switch on curitem->type */ |
7198 } /* End of for loop */ | |
4230 | 7199 |
11965 | 7200 oscar_set_extendedstatus(gc); |
4901 | 7201 |
4342 | 7202 /* Activate SSI */ |
7203 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
7204 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 7205 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7206 "ssi: activating server-stored buddy list\n"); |
4642 | 7207 aim_ssi_enable(sess); |
4342 | 7208 |
2991 | 7209 return 1; |
2086 | 7210 } |
4230 | 7211 |
7212 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 7213 GaimConnection *gc = sess->aux_data; |
4230 | 7214 va_list ap; |
7215 struct aim_ssi_tmp *retval; | |
7216 | |
7217 va_start(ap, fr); | |
7218 retval = va_arg(ap, struct aim_ssi_tmp *); | |
7219 va_end(ap); | |
7220 | |
7221 while (retval) { | |
8660 | 7222 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7223 "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 | 7224 |
7225 if (retval->ack != 0xffff) | |
7226 switch (retval->ack) { | |
7227 case 0x0000: { /* added successfully */ | |
7228 } break; | |
7229 | |
4829 | 7230 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
7231 gchar *buf; | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7232 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 | 7233 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 7234 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 7235 g_free(buf); |
7236 } | |
7237 | |
7023 | 7238 case 0x000e: { /* buddy requires authorization */ |
4828 | 7239 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 7240 gaim_auth_sendrequest(gc, retval->name); |
4230 | 7241 } break; |
7242 | |
7243 default: { /* La la la */ | |
5197 | 7244 gchar *buf; |
8660 | 7245 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
|
7246 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 | 7247 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 7248 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 7249 g_free(buf); |
4230 | 7250 } break; |
7251 } | |
7252 | |
7253 retval = retval->next; | |
7254 } | |
7255 | |
7256 return 1; | |
7257 } | |
7258 | |
8227 | 7259 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
7260 GaimConnection *gc = sess->aux_data; | |
7261 char *gname, *gname_utf8, *alias, *alias_utf8; | |
7262 GaimBuddy *b; | |
7263 GaimGroup *g; | |
7264 va_list ap; | |
7265 fu16_t type; | |
7266 const char *name; | |
7267 | |
7268 va_start(ap, fr); | |
7269 type = (fu16_t)va_arg(ap, int); | |
7270 name = va_arg(ap, char *); | |
7271 va_end(ap); | |
7272 | |
7273 if ((type != 0x0000) || (name == NULL)) | |
7274 return 1; | |
7275 | |
7276 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7277 gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL; |
8227 | 7278 alias = aim_ssi_getalias(sess->ssi.local, gname, name); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7279 alias_utf8 = alias ? oscar_utf8_try_convert(gc->account, alias) : NULL; |
8227 | 7280 b = gaim_find_buddy(gc->account, name); |
7281 free(alias); | |
7282 | |
7283 if (b) { | |
7284 /* Get server stored alias */ | |
7285 if (alias_utf8) { | |
7286 g_free(b->alias); | |
7287 b->alias = g_strdup(alias_utf8); | |
7288 } | |
7289 } else { | |
7290 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
7291 | |
7292 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
7293 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
7294 gaim_blist_add_group(g, NULL); | |
7295 } | |
7296 | |
8660 | 7297 gaim_debug_info("oscar", |
9285 | 7298 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 7299 gaim_blist_add_buddy(b, NULL, g, NULL); |
7300 } | |
7301 g_free(gname_utf8); | |
7302 g_free(alias_utf8); | |
7303 | |
7304 return 1; | |
7305 } | |
7306 | |
4230 | 7307 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 7308 GaimConnection *gc = sess->aux_data; |
4230 | 7309 va_list ap; |
7310 char *sn, *msg; | |
4236 | 7311 gchar *dialog_msg, *nombre; |
4230 | 7312 struct name_data *data; |
6695 | 7313 GaimBuddy *buddy; |
4230 | 7314 |
7315 va_start(ap, fr); | |
7316 sn = va_arg(ap, char *); | |
7317 msg = va_arg(ap, char *); | |
7318 va_end(ap); | |
7319 | |
8660 | 7320 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7321 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 7322 |
4687 | 7323 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 7324 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
7325 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 7326 else |
7327 nombre = g_strdup(sn); | |
7328 | |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7329 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 | 7330 data = g_new(struct name_data, 1); |
7331 data->gc = gc; | |
7332 data->name = g_strdup(sn); | |
7333 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7334 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7335 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 7336 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 7337 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 7338 G_CALLBACK(oscar_free_name_data)); |
4236 | 7339 |
4230 | 7340 g_free(dialog_msg); |
4236 | 7341 g_free(nombre); |
4230 | 7342 |
7343 return 1; | |
7344 } | |
7345 | |
7346 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 7347 GaimConnection *gc = sess->aux_data; |
4230 | 7348 va_list ap; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7349 char *sn; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7350 char *msg; |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7351 GaimAccount *account = gaim_connection_get_account(gc); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7352 gchar *nombre; |
11567
603a0e626332
[gaim-migrate @ 13834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11537
diff
changeset
|
7353 gchar *reason = NULL; |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7354 gchar *dialog_msg; |
4230 | 7355 struct name_data *data; |
6695 | 7356 GaimBuddy *buddy; |
4230 | 7357 |
7358 va_start(ap, fr); | |
7359 sn = va_arg(ap, char *); | |
7360 msg = va_arg(ap, char *); | |
7361 va_end(ap); | |
7362 | |
8660 | 7363 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7364 "ssi: received authorization request from %s\n", sn); |
4230 | 7365 |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7366 buddy = gaim_find_buddy(account, sn); |
9620 | 7367 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
7368 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 7369 else |
7370 nombre = g_strdup(sn); | |
7371 | |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7372 if (msg != NULL) |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7373 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg, strlen(msg)); |
11567
603a0e626332
[gaim-migrate @ 13834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11537
diff
changeset
|
7374 |
603a0e626332
[gaim-migrate @ 13834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11537
diff
changeset
|
7375 if (reason == NULL) |
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7376 reason = g_strdup(_("No reason given.")); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7377 |
10949 | 7378 dialog_msg = g_strdup_printf( |
7379 _("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
|
7380 nombre, gaim_account_get_username(account), reason); |
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7381 g_free(reason); |
10949 | 7382 |
4230 | 7383 data = g_new(struct name_data, 1); |
7384 data->gc = gc; | |
7385 data->name = g_strdup(sn); | |
7386 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7387 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7388 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 7389 GAIM_DEFAULT_ACTION_NONE, data, 2, |
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
7390 _("_Authorize"), G_CALLBACK(gaim_auth_grant), |
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
7391 _("_Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 7392 |
4230 | 7393 g_free(dialog_msg); |
4236 | 7394 g_free(nombre); |
4230 | 7395 |
7396 return 1; | |
7397 } | |
7398 | |
7399 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 7400 GaimConnection *gc = sess->aux_data; |
4230 | 7401 va_list ap; |
7402 char *sn, *msg; | |
4236 | 7403 gchar *dialog_msg, *nombre; |
4230 | 7404 fu8_t reply; |
6695 | 7405 GaimBuddy *buddy; |
4230 | 7406 |
7407 va_start(ap, fr); | |
7408 sn = va_arg(ap, char *); | |
7409 reply = (fu8_t)va_arg(ap, int); | |
7410 msg = va_arg(ap, char *); | |
7411 va_end(ap); | |
7412 | |
8660 | 7413 gaim_debug_info("oscar", |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7414 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 7415 |
4687 | 7416 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 7417 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
7418 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 7419 else |
7420 nombre = g_strdup(sn); | |
7421 | |
4230 | 7422 if (reply) { |
7423 /* Granted */ | |
7023 | 7424 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
|
7425 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 7426 } else { |
7427 /* Denied */ | |
7023 | 7428 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
|
7429 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 7430 } |
7431 g_free(dialog_msg); | |
4236 | 7432 g_free(nombre); |
4230 | 7433 |
7434 return 1; | |
7435 } | |
7436 | |
7437 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 7438 GaimConnection *gc = sess->aux_data; |
4230 | 7439 va_list ap; |
7440 char *sn; | |
6695 | 7441 GaimBuddy *buddy; |
4230 | 7442 |
7443 va_start(ap, fr); | |
7444 sn = va_arg(ap, char *); | |
7445 va_end(ap); | |
7446 | |
4687 | 7447 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 7448 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7449 "ssi: %s added you to their buddy list\n", sn); |
9620 | 7450 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 7451 |
7452 return 1; | |
7453 } | |
2086 | 7454 |
5575 | 7455 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7456 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7457 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7458 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7459 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 7460 pce->label = _("_Room:"); |
5234 | 7461 pce->identifier = "room"; |
10475 | 7462 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7463 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7464 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7465 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 7466 pce->label = _("_Exchange:"); |
5234 | 7467 pce->identifier = "exchange"; |
10475 | 7468 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7469 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7470 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7471 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7472 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7473 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7474 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7475 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7476 |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
7477 static GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
9754 | 7478 { |
7479 GHashTable *defaults; | |
7480 | |
7481 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
7482 | |
7483 if (chat_name != NULL) | |
7484 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
7485 | |
7486 return defaults; | |
7487 } | |
7488 | |
9917 | 7489 static char *oscar_get_chat_name(GHashTable *data) { |
7490 return g_strdup(g_hash_table_lookup(data, "room")); | |
7491 } | |
7492 | |
8308 | 7493 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
7494 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7495 aim_conn_t *cur; |
5234 | 7496 char *name, *exchange; |
7497 | |
7498 name = g_hash_table_lookup(data, "room"); | |
7499 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7500 |
8308 | 7501 if ((name == NULL) || (*name == '\0')) { |
7502 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
7503 return; | |
7504 } | |
7505 | |
11461
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7506 gaim_debug_info("oscar", |
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7507 "Attempting to join chat room %s.\n", name); |
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7508 |
4617 | 7509 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 7510 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7511 "chatnav exists, creating room\n"); |
5234 | 7512 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 7513 } else { |
7514 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
7515 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 7516 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7517 "chatnav does not exist, opening chatnav\n"); |
5234 | 7518 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
7519 cr->name = g_strdup(name); |
4617 | 7520 od->create_rooms = g_slist_append(od->create_rooms, cr); |
7521 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 7522 } |
7523 } | |
7524 | |
8308 | 7525 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
7526 OscarData *od = (OscarData *)gc->proto_data; | |
7527 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 7528 |
7529 if (ccon == NULL) | |
2086 | 7530 return; |
10404 | 7531 |
8225 | 7532 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 7533 ccon->exchange, ccon->name, 0x0); |
7534 } | |
7535 | |
10458 | 7536 static void |
7537 oscar_chat_leave(GaimConnection *gc, int id) | |
7538 { | |
7539 GaimConversation *conv; | |
7540 struct chat_connection *cc; | |
7541 | |
7542 conv = gaim_find_chat(gc, id); | |
7543 | |
7544 g_return_if_fail(conv != NULL); | |
7545 | |
7546 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
7547 | |
7548 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
7549 oscar_chat_kill(gc, cc); | |
2086 | 7550 } |
7551 | |
12216 | 7552 static int oscar_send_chat(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) { |
8219 | 7553 OscarData *od = (OscarData *)gc->proto_data; |
7554 GaimConversation *conv = NULL; | |
2086 | 7555 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7556 char *buf, *buf2; |
9830 | 7557 fu16_t charset, charsubset; |
9807 | 7558 char *charsetstr = NULL; |
10111 | 7559 int len; |
8219 | 7560 |
7561 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7562 return -EINVAL; |
2086 | 7563 |
8219 | 7564 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7565 return -EINVAL; |
2086 | 7566 |
8219 | 7567 buf = gaim_strdup_withhtml(message); |
7568 len = strlen(buf); | |
7569 | |
8962 | 7570 if (strstr(buf, "<IMG ")) |
7571 gaim_conversation_write(conv, "", | |
7572 _("Your IM Image was not sent. " | |
7573 "You cannot send IM Images in AIM chats."), | |
7574 GAIM_MESSAGE_ERROR, time(NULL)); | |
7575 | |
9830 | 7576 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 7577 if ((len > c->maxlen) || (len > c->maxvis)) { |
7578 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7579 return -E2BIG; |
8359 | 7580 } |
7581 | |
9831 | 7582 if (charset == AIM_CHARSET_ASCII) |
7583 charsetstr = "us-ascii"; | |
7584 else if (charset == AIM_CHARSET_UNICODE) | |
7585 charsetstr = "unicode-2-0"; | |
7586 else if (charset == AIM_CHARSET_CUSTOM) | |
7587 charsetstr = "iso-8859-1"; | |
9807 | 7588 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 7589 g_free(buf2); |
8359 | 7590 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7591 return 0; |
2086 | 7592 } |
7593 | |
10042 | 7594 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
7595 { | |
4766 | 7596 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 7597 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 7598 return "icq"; |
7599 else | |
7600 return "aim"; | |
7601 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
7602 |
9975 | 7603 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 7604 return "icq"; |
7605 return "aim"; | |
7606 } | |
7607 | |
9972 | 7608 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 7609 { |
7334 | 7610 GaimConnection *gc = NULL; |
7611 OscarData *od = NULL; | |
10042 | 7612 GaimAccount *account = NULL; |
7613 GaimPresence *presence; | |
7614 GaimStatus *status; | |
7615 const char *status_id; | |
4687 | 7616 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
7617 int i = 0; | |
7334 | 7618 aim_userinfo_t *userinfo = NULL; |
7619 | |
7620 if (b != NULL) | |
7621 account = b->account; | |
7622 if (account != NULL) | |
7623 gc = account->gc; | |
7624 if (gc != NULL) | |
7625 od = gc->proto_data; | |
7945 | 7626 if (od != NULL) |
7627 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 7628 |
10042 | 7629 presence = gaim_buddy_get_presence(b); |
7630 status = gaim_presence_get_active_status(presence); | |
7631 status_id = gaim_status_get_id(status); | |
7632 | |
7633 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 7634 char *gname; |
7334 | 7635 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 7636 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
7637 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
7638 emblems[i++] = "notauthorized"; | |
7639 } else { | |
7640 emblems[i++] = "offline"; | |
7641 } | |
7642 } | |
4916 | 7643 |
10042 | 7644 if (b->name && aim_sn_is_icq(b->name)) { |
7645 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
7646 emblems[i++] = "invisible"; | |
7647 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 7648 emblems[i++] = "freeforchat"; |
10042 | 7649 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 7650 emblems[i++] = "dnd"; |
10042 | 7651 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7652 emblems[i++] = "unavailable"; |
10042 | 7653 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 7654 emblems[i++] = "occupied"; |
10042 | 7655 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 7656 emblems[i++] = "away"; |
10042 | 7657 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
7658 emblems[i++] = "away"; | |
7659 } | |
7660 | |
7661 if (userinfo != NULL ) { | |
7662 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
7663 emblems[i++] = "unconfirmed"; */ | |
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7664 if ((i < 4) && userinfo->flags & AIM_FLAG_ADMINISTRATOR) |
10042 | 7665 emblems[i++] = "admin"; |
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7666 if ((i < 4) && userinfo->flags & AIM_FLAG_AOL) |
10042 | 7667 emblems[i++] = "aol"; |
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7668 if ((i < 4) && userinfo->flags & AIM_FLAG_WIRELESS) |
10042 | 7669 emblems[i++] = "wireless"; |
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7670 if ((i < 4) && userinfo->flags & AIM_FLAG_ACTIVEBUDDY) |
10042 | 7671 emblems[i++] = "activebuddy"; |
7672 | |
7673 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 7674 emblems[i++] = "hiptop"; |
7675 | |
10042 | 7676 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 7677 emblems[i++] = "secure"; |
10042 | 7678 } |
7334 | 7679 |
4687 | 7680 *se = emblems[0]; |
7681 *sw = emblems[1]; | |
7682 *nw = emblems[2]; | |
7683 *ne = emblems[3]; | |
7684 } | |
7685 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
7686 static void oscar_tooltip_text(GaimBuddy *b, GString *str, gboolean full) { |
5575 | 7687 GaimConnection *gc = b->account->gc; |
7283 | 7688 OscarData *od = gc->proto_data; |
7045 | 7689 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
5131 | 7690 |
7691 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
12189 | 7692 GaimPresence *presence; |
7693 GaimStatus *status; | |
7694 const char *message; | |
7695 | |
12948
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12946
diff
changeset
|
7696 if (full) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12946
diff
changeset
|
7697 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 7698 |
12189 | 7699 presence = gaim_buddy_get_presence(b); |
7700 status = gaim_presence_get_active_status(presence); | |
7701 message = gaim_status_get_attr_string(status, "message"); | |
7702 | |
12433 | 7703 if (gaim_status_is_available(status)) |
7704 { | |
7705 if (message != NULL) | |
7706 { | |
12189 | 7707 /* Available status messages are plain text */ |
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7708 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), message); |
12433 | 7709 } |
7710 } | |
7711 else | |
7712 { | |
7713 if (message != NULL) | |
7714 { | |
12189 | 7715 /* Away messages are HTML */ |
7091 | 7716 gchar *tmp1, *tmp2; |
12189 | 7717 tmp2 = gaim_markup_strip_html(message); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
7718 tmp1 = g_markup_escape_text(tmp2, -1); |
7091 | 7719 g_free(tmp2); |
8700 | 7720 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 7721 g_free(tmp1); |
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7722 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp2); |
8700 | 7723 g_free(tmp2); |
5836 | 7724 } |
12433 | 7725 else |
7726 { | |
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7727 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), _("<i>(retrieving)</i>")); |
12433 | 7728 } |
5131 | 7729 } |
8701 | 7730 } |
5131 | 7731 } |
7732 | |
10042 | 7733 static char *oscar_status_text(GaimBuddy *b) |
7734 { | |
7735 GaimConnection *gc; | |
12347 | 7736 GaimAccount *account; |
10042 | 7737 OscarData *od; |
12347 | 7738 const GaimPresence *presence; |
7739 const GaimStatus *status; | |
7740 const char *id; | |
7741 const char *message; | |
5167 | 7742 gchar *ret = NULL; |
7743 | |
10042 | 7744 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
12347 | 7745 account = gaim_connection_get_account(gc); |
10042 | 7746 od = gc->proto_data; |
11248 | 7747 presence = gaim_buddy_get_presence(b); |
12347 | 7748 status = gaim_presence_get_active_status(presence); |
7749 id = gaim_status_get_id(status); | |
11248 | 7750 |
7751 if (!gaim_presence_is_online(presence)) | |
7752 { | |
5167 | 7753 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
7754 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
7755 ret = g_strdup(_("Not Authorized")); | |
7756 else | |
7757 ret = g_strdup(_("Offline")); | |
7758 } | |
12365 | 7759 else if (gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AVAILABLE)) |
12347 | 7760 { |
12365 | 7761 /* Available */ |
12347 | 7762 message = gaim_status_get_attr_string(status, "message"); |
7763 if (message != NULL) | |
7764 { | |
7765 ret = g_markup_escape_text(message, -1); | |
7766 gaim_util_chrreplace(ret, '\n', ' '); | |
7767 } | |
7768 } | |
12365 | 7769 else if (!gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AWAY)) |
11248 | 7770 { |
12365 | 7771 /* Away */ |
12347 | 7772 message = gaim_status_get_attr_string(status, "message"); |
7773 if (message != NULL) | |
7774 { | |
7775 gchar *tmp1, *tmp2; | |
7776 tmp1 = gaim_markup_strip_html(message); | |
12361 | 7777 gaim_util_chrreplace(tmp1, '\n', ' '); |
12347 | 7778 tmp2 = g_markup_escape_text(tmp1, -1); |
7779 ret = gaim_str_sub_away_formatters(tmp2, gaim_account_get_username(account)); | |
7780 g_free(tmp1); | |
7781 g_free(tmp2); | |
7782 } | |
7783 else | |
7784 { | |
7785 ret = g_strdup(_("Away")); | |
11510 | 7786 } |
11248 | 7787 } |
7788 else | |
12347 | 7789 ret = g_strdup(gaim_status_get_name(status)); |
5167 | 7790 |
7791 return ret; | |
7792 } | |
7793 | |
5842 | 7794 |
5844 | 7795 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 7796 GaimConnection *gc = sess->aux_data; |
7283 | 7797 OscarData *od = gc->proto_data; |
5892 | 7798 va_list ap; |
5842 | 7799 fu16_t type; |
5892 | 7800 fu8_t flags = 0, length = 0; |
11159 | 7801 guchar *md5 = NULL; |
5892 | 7802 |
5842 | 7803 va_start(ap, fr); |
7804 type = va_arg(ap, int); | |
5892 | 7805 |
7806 switch(type) { | |
7807 case 0x0000: | |
7808 case 0x0001: { | |
7809 flags = va_arg(ap, int); | |
7810 length = va_arg(ap, int); | |
11159 | 7811 md5 = va_arg(ap, guchar *); |
5892 | 7812 |
7813 if (flags == 0x41) { | |
7814 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
7815 od->iconconnecting = TRUE; | |
7816 od->set_icon = TRUE; | |
7817 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
7818 } else { | |
6039 | 7819 struct stat st; |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7820 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
6039 | 7821 if (iconfile == NULL) { |
8363 | 7822 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7823 } else if (!g_stat(iconfile, &st)) { |
11159 | 7824 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7825 FILE *file = g_fopen(iconfile, "rb"); |
6039 | 7826 if (file) { |
9532 | 7827 /* XXX - Use g_file_get_contents()? */ |
6039 | 7828 fread(buf, 1, st.st_size, file); |
7829 fclose(file); | |
8660 | 7830 gaim_debug_info("oscar", |
10042 | 7831 "Uploading icon to icon server\n"); |
6879 | 7832 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 7833 } else |
8660 | 7834 gaim_debug_error("oscar", |
10042 | 7835 "Can't open buddy icon file!\n"); |
6039 | 7836 g_free(buf); |
7837 } else { | |
8660 | 7838 gaim_debug_error("oscar", |
10042 | 7839 "Can't stat buddy icon file!\n"); |
5892 | 7840 } |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7841 g_free(iconfile); |
5892 | 7842 } |
8363 | 7843 } else if (flags == 0x81) { |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7844 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
8363 | 7845 if (iconfile == NULL) |
7846 aim_ssi_delicon(od->sess); | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7847 else { |
8363 | 7848 aim_ssi_seticon(od->sess, md5, length); |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7849 g_free(iconfile); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7850 } |
8363 | 7851 } |
5892 | 7852 } break; |
7853 | |
7854 case 0x0002: { /* We just set an "available" message? */ | |
7855 } break; | |
7856 } | |
7857 | |
5842 | 7858 va_end(ap); |
5844 | 7859 |
7860 return 0; | |
5842 | 7861 } |
5892 | 7862 |
5575 | 7863 static void oscar_set_permit_deny(GaimConnection *gc) { |
7864 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 7865 OscarData *od = (OscarData *)gc->proto_data; |
10866 | 7866 |
8175 | 7867 if (od->sess->ssi.received_data) { |
7868 switch (account->perm_deny) { | |
7869 case GAIM_PRIVACY_ALLOW_ALL: | |
7870 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
7871 break; | |
7872 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
7873 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
7874 break; | |
7875 case GAIM_PRIVACY_ALLOW_USERS: | |
7876 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
7877 break; | |
7878 case GAIM_PRIVACY_DENY_ALL: | |
7879 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
7880 break; | |
7881 case GAIM_PRIVACY_DENY_USERS: | |
7882 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
7883 break; | |
7884 default: | |
7885 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
7886 break; | |
7887 } | |
7888 } | |
2086 | 7889 } |
7890 | |
5575 | 7891 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
7283 | 7892 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7893 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 7894 if (od->sess->ssi.received_data) |
4889 | 7895 aim_ssi_addpermit(od->sess, who); |
2086 | 7896 } |
7897 | |
5575 | 7898 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
7283 | 7899 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7900 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 7901 if (od->sess->ssi.received_data) |
4889 | 7902 aim_ssi_adddeny(od->sess, who); |
2086 | 7903 } |
7904 | |
5575 | 7905 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
7283 | 7906 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7907 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 7908 if (od->sess->ssi.received_data) |
4889 | 7909 aim_ssi_delpermit(od->sess, who); |
2086 | 7910 } |
7911 | |
5575 | 7912 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
7283 | 7913 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 7914 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 7915 if (od->sess->ssi.received_data) |
4889 | 7916 aim_ssi_deldeny(od->sess, who); |
2086 | 7917 } |
7918 | |
9975 | 7919 static GList * |
7920 oscar_status_types(GaimAccount *account) | |
2086 | 7921 { |
12662 | 7922 gboolean is_icq; |
9975 | 7923 GList *status_types = NULL; |
7924 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
7925 |
9973 | 7926 g_return_val_if_fail(account != NULL, NULL); |
7927 | |
13007 | 7928 /* Used to flag some statuses as "user settable" or not */ |
12662 | 7929 is_icq = aim_sn_is_icq(gaim_account_get_username(account)); |
7930 | |
13007 | 7931 /* Common status types */ |
7932 /* Really the available message should only be settable for AIM accounts */ | |
7933 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, | |
7934 OSCAR_STATUS_ID_AVAILABLE, | |
7935 NULL, TRUE, TRUE, FALSE, | |
7936 "message", _("Message"), | |
7937 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
7938 status_types = g_list_append(status_types, type); | |
7939 | |
7940 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, | |
7941 OSCAR_STATUS_ID_FREE4CHAT, | |
7942 _("Free For Chat"), TRUE, is_icq, FALSE); | |
7943 status_types = g_list_append(status_types, type); | |
9976 | 7944 |
10195 | 7945 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
7946 OSCAR_STATUS_ID_AWAY, | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7947 NULL, TRUE, TRUE, FALSE, |
10195 | 7948 "message", _("Message"), |
7949 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 7950 status_types = g_list_append(status_types, type); |
7951 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7952 type = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, |
10042 | 7953 OSCAR_STATUS_ID_INVISIBLE, |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7954 NULL, TRUE, TRUE, FALSE); |
10042 | 7955 status_types = g_list_append(status_types, type); |
7956 | |
7957 /* ICQ-specific status types */ | |
13007 | 7958 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
7959 OSCAR_STATUS_ID_OCCUPIED, | |
7960 _("Occupied"), TRUE, is_icq, FALSE); | |
7961 status_types = g_list_append(status_types, type); | |
7962 | |
7963 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, | |
7964 OSCAR_STATUS_ID_DND, | |
7965 _("Do Not Disturb"), TRUE, is_icq, FALSE); | |
7966 status_types = g_list_append(status_types, type); | |
7967 | |
7968 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, | |
7969 OSCAR_STATUS_ID_NA, | |
7970 _("Not Available"), TRUE, is_icq, FALSE); | |
7971 status_types = g_list_append(status_types, type); | |
12658 | 7972 |
7973 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, | |
7974 OSCAR_STATUS_ID_OFFLINE, | |
7975 NULL, TRUE, TRUE, FALSE); | |
9976 | 7976 status_types = g_list_append(status_types, type); |
9975 | 7977 |
7978 return status_types; | |
4333 | 7979 } |
7980 | |
7172 | 7981 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 7982 GaimConnection *gc = data->gc; |
7983 OscarData *od = gc->proto_data; | |
7172 | 7984 GaimBuddy *b; |
7985 GaimGroup *g; | |
7986 | |
7987 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
7988 oscar_free_name_data(data); | |
7989 return; | |
7990 } | |
7991 | |
12088 | 7992 if (!(g = gaim_buddy_get_group(b))) { |
7172 | 7993 oscar_free_name_data(data); |
7994 return; | |
7995 } | |
7996 | |
7997 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 7998 |
7999 if (!aim_sncmp(data->name, gc->account->username)) | |
8000 gaim_check_comment(od, text); | |
8001 | |
7172 | 8002 oscar_free_name_data(data); |
8003 } | |
8004 | |
9030 | 8005 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
8006 | |
8007 GaimBuddy *buddy; | |
8008 GaimConnection *gc; | |
8009 OscarData *od; | |
8010 struct name_data *data; | |
7172 | 8011 GaimGroup *g; |
8012 char *comment; | |
8013 gchar *comment_utf8; | |
9631 | 8014 gchar *title; |
7172 | 8015 |
9030 | 8016 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
8017 | |
8018 buddy = (GaimBuddy *) node; | |
8019 gc = gaim_account_get_connection(buddy->account); | |
8020 od = gc->proto_data; | |
8021 | |
8022 data = g_new(struct name_data, 1); | |
8023 | |
12088 | 8024 if (!(g = gaim_buddy_get_group(buddy))) |
7172 | 8025 return; |
9030 | 8026 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
8027 comment_utf8 = comment ? oscar_utf8_try_convert(gc->account, comment) : NULL; |
7172 | 8028 |
8029 data->gc = gc; | |
9030 | 8030 data->name = g_strdup(buddy->name); |
7172 | 8031 data->nick = NULL; |
8032 | |
9631 | 8033 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
8034 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 8035 comment_utf8, TRUE, FALSE, NULL, |
7172 | 8036 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
8037 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
8038 data); | |
9631 | 8039 g_free(title); |
7172 | 8040 |
8041 free(comment); | |
8042 g_free(comment_utf8); | |
8043 } | |
8044 | |
9030 | 8045 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
8046 | |
8047 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 8048 OscarData *od = gc->proto_data; |
9030 | 8049 |
4333 | 8050 GList *m = NULL; |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8051 GaimMenuAction *act; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8052 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8053 act = gaim_menu_action_new(_("Edit Buddy Comment"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8054 GAIM_CALLBACK(oscar_buddycb_edit_comment), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8055 NULL, NULL); |
9030 | 8056 m = g_list_append(m, act); |
7172 | 8057 |
4333 | 8058 if (od->icq) { |
4624 | 8059 #if 0 |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8060 act = gaim_menu_action_new(_("Get Status Msg"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8061 GAIM_CALLBACK(oscar_get_icqstatusmsg), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8062 NULL, NULL); |
9030 | 8063 m = g_list_append(m, act); |
4624 | 8064 #endif |
4333 | 8065 } else { |
7011 | 8066 aim_userinfo_t *userinfo; |
9030 | 8067 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
8068 | |
8069 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
8070 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
8071 | |
7011 | 8072 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8073 act = gaim_menu_action_new(_("Direct IM"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8074 GAIM_CALLBACK(oscar_ask_direct_im), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8075 NULL, NULL); |
9030 | 8076 m = g_list_append(m, act); |
5917 | 8077 } |
9466 | 8078 #if 0 |
7011 | 8079 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8080 act = gaim_menu_action_new(_("Get File"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8081 GAIM_CALLBACK(oscar_ask_getfile), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8082 NULL, NULL); |
9030 | 8083 m = g_list_append(m, act); |
5917 | 8084 } |
4826 | 8085 #endif |
4333 | 8086 } |
5131 | 8087 } |
5197 | 8088 |
5131 | 8089 if (od->sess->ssi.received_data) { |
9030 | 8090 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
8091 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8092 act = gaim_menu_action_new(_("Re-request Authorization"), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8093 GAIM_CALLBACK(gaim_auth_sendrequest_menu), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8094 NULL, NULL); |
9030 | 8095 m = g_list_append(m, act); |
4333 | 8096 } |
4916 | 8097 } |
10157 | 8098 |
4333 | 8099 return m; |
8100 } | |
8101 | |
9030 | 8102 |
8103 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
8104 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
8105 return oscar_buddy_menu((GaimBuddy *) node); | |
8106 } else { | |
8107 return NULL; | |
8108 } | |
8109 } | |
8110 | |
10570 | 8111 static void |
8112 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
8113 { | |
8114 OscarData *od = gc->proto_data; | |
8115 GaimAccount *account = gaim_connection_get_account(gc); | |
8116 GaimRequestField *f; | |
12652 | 8117 gboolean auth, web_aware; |
10570 | 8118 |
8119 f = gaim_request_fields_get_field(fields, "authorization"); | |
8120 auth = gaim_request_field_bool_get_value(f); | |
8121 | |
8122 f = gaim_request_fields_get_field(fields, "web_aware"); | |
8123 web_aware = gaim_request_field_bool_get_value(f); | |
8124 | |
8125 gaim_account_set_bool(account, "authorization", auth); | |
8126 gaim_account_set_bool(account, "web_aware", web_aware); | |
8127 | |
12652 | 8128 oscar_set_extendedstatus(gc); |
8129 aim_icq_setsecurity(od->sess, auth, web_aware); | |
10570 | 8130 } |
8131 | |
8132 static void | |
8133 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
8134 { | |
8135 GaimConnection *gc = (GaimConnection *) action->context; | |
8136 GaimAccount *account = gaim_connection_get_account(gc); | |
8137 GaimRequestFields *fields; | |
8138 GaimRequestFieldGroup *g; | |
8139 GaimRequestField *f; | |
12652 | 8140 gboolean auth, web_aware; |
10570 | 8141 |
8142 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
8143 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
8144 | |
8145 fields = gaim_request_fields_new(); | |
8146 | |
8147 g = gaim_request_field_group_new(NULL); | |
8148 | |
8149 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
8150 gaim_request_field_group_add_field(g, f); | |
8151 | |
12617 | 8152 f = gaim_request_field_bool_new("web_aware", _("Web aware (enabling this will cause you to receive SPAM!)"), web_aware); |
10570 | 8153 gaim_request_field_group_add_field(g, f); |
8154 | |
8155 gaim_request_fields_add_group(fields, g); | |
8156 | |
8157 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
8158 NULL, fields, | |
8159 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
8160 _("Cancel"), NULL, gc); | |
8161 } | |
9030 | 8162 |
5575 | 8163 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 8164 OscarData *od = gc->proto_data; |
5575 | 8165 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 8166 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
8167 od->setnick = TRUE; | |
8168 od->newsn = g_strdup(nick); | |
8169 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
8170 } else { | |
8171 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
8172 } | |
8173 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
8174 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 8175 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 8176 } |
8177 } | |
8178 | |
9015 | 8179 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 8180 { |
9015 | 8181 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 8182 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 8183 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8184 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8185 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8186 gc); |
4333 | 8187 } |
8188 | |
9015 | 8189 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 8190 { |
9015 | 8191 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 8192 OscarData *od = gc->proto_data; |
4333 | 8193 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
8194 | |
8195 if (conn) { | |
8196 aim_admin_reqconfirm(od->sess, conn); | |
8197 } else { | |
8198 od->conf = TRUE; | |
8199 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
8200 } | |
8201 } | |
8202 | |
9015 | 8203 static void oscar_show_email(GaimPluginAction *action) |
4333 | 8204 { |
9015 | 8205 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 8206 OscarData *od = gc->proto_data; |
4333 | 8207 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
8208 | |
8209 if (conn) { | |
8210 aim_admin_getinfo(od->sess, conn, 0x11); | |
8211 } else { | |
8212 od->reqemail = TRUE; | |
8213 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
8214 } | |
8215 } | |
8216 | |
5575 | 8217 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8218 { |
7283 | 8219 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8220 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
|
8221 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8222 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8223 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8224 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8225 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8226 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8227 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8228 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8229 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8230 |
9015 | 8231 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 8232 { |
9015 | 8233 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
8234 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 8235 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8236 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8237 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8238 gc); |
4333 | 8239 } |
8240 | |
9015 | 8241 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 8242 { |
9015 | 8243 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 8244 OscarData *od = gc->proto_data; |
4333 | 8245 gchar *nombre, *text, *tmp; |
6695 | 8246 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 8247 int num=0; |
8248 | |
6873 | 8249 text = g_strdup(""); |
4333 | 8250 |
4785 | 8251 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 8252 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 8253 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
8254 continue; | |
6695 | 8255 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
8256 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 8257 continue; |
6695 | 8258 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
8259 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
8260 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
8261 continue; | |
8262 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 8263 if (gaim_buddy_get_alias_only(buddy)) |
8264 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 8265 else |
8266 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 8267 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 8268 g_free(text); |
8269 text = tmp; | |
8270 g_free(nombre); | |
8271 num++; | |
8272 } | |
4333 | 8273 } |
2979 | 8274 } |
4333 | 8275 } |
8276 | |
8277 if (!num) { | |
8278 g_free(text); | |
6873 | 8279 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
8280 } | |
8281 | |
8282 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
8283 "the following buddies"), _("You can re-request " | |
8284 "authorization from these buddies by " | |
8285 "right-clicking on them and selecting " | |
8286 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 8287 g_free(text); |
2979 | 8288 } |
8289 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8290 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8291 { |
8950 | 8292 OscarData *od = (OscarData *)gc->proto_data; |
8293 | |
8294 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8295 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8296 |
9015 | 8297 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8298 { |
9015 | 8299 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8300 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8301 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8302 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8303 "searching for."), |
8697 | 8304 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8305 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8306 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8307 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8308 |
9015 | 8309 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8310 { |
9015 | 8311 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8312 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8313 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8314 |
9015 | 8315 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 8316 { |
9015 | 8317 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
8318 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 8319 } |
8320 | |
9015 | 8321 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8322 { |
9015 | 8323 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8324 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8325 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8326 |
9015 | 8327 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 8328 { |
9015 | 8329 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 8330 OscarData *od = gc->proto_data; |
5575 | 8331 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
|
8332 gaim_notify_uri(gc, substituted); |
5517 | 8333 g_free(substituted); |
4333 | 8334 } |
8335 | |
9015 | 8336 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 8337 { |
9015 | 8338 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
8339 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 8340 } |
8341 | |
5842 | 8342 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
8343 { | |
7283 | 8344 OscarData *od = gc->proto_data; |
5844 | 8345 aim_session_t *sess = od->sess; |
5842 | 8346 FILE *file; |
8347 struct stat st; | |
5844 | 8348 |
6039 | 8349 if (iconfile == NULL) { |
8363 | 8350 aim_ssi_delicon(od->sess); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
8351 } else if (!g_stat(iconfile, &st)) { |
11159 | 8352 guchar *buf = g_malloc(st.st_size); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
8353 file = g_fopen(iconfile, "rb"); |
11404 | 8354 if (file) |
8355 { | |
8356 GaimCipher *cipher; | |
8357 GaimCipherContext *context; | |
11159 | 8358 guchar md5[16]; |
11404 | 8359 int len; |
8360 | |
9532 | 8361 /* XXX - Use g_file_get_contents()? */ |
11404 | 8362 len = fread(buf, 1, st.st_size, file); |
6039 | 8363 fclose(file); |
11404 | 8364 |
8365 cipher = gaim_ciphers_find_cipher("md5"); | |
8366 context = gaim_cipher_context_new(cipher, NULL); | |
8367 gaim_cipher_context_append(context, buf, len); | |
8368 gaim_cipher_context_digest(context, 16, md5, NULL); | |
8369 gaim_cipher_context_destroy(context); | |
8370 | |
5842 | 8371 aim_ssi_seticon(sess, md5, 16); |
8372 } else | |
8660 | 8373 gaim_debug_error("oscar", |
5842 | 8374 "Can't open buddy icon file!\n"); |
8375 g_free(buf); | |
8376 } else | |
8660 | 8377 gaim_debug_error("oscar", |
5842 | 8378 "Can't stat buddy icon file!\n"); |
8379 } | |
8380 | |
8381 | |
9015 | 8382 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 8383 { |
9015 | 8384 GaimConnection *gc = (GaimConnection *) context; |
7283 | 8385 OscarData *od = gc->proto_data; |
4333 | 8386 GList *m = NULL; |
9015 | 8387 GaimPluginAction *act; |
8388 | |
8389 act = gaim_plugin_action_new(_("Set User Info..."), | |
8390 oscar_show_set_info); | |
8391 m = g_list_append(m, act); | |
4333 | 8392 |
10570 | 8393 if (od->icq) |
8394 { | |
9015 | 8395 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
8396 oscar_show_set_info_icqurl); | |
8397 m = g_list_append(m, act); | |
8576 | 8398 } |
8399 | |
9015 | 8400 act = gaim_plugin_action_new(_("Change Password..."), |
8401 oscar_change_pass); | |
8402 m = g_list_append(m, act); | |
4617 | 8403 |
10570 | 8404 if (od->sess->authinfo->chpassurl != NULL) |
8405 { | |
9015 | 8406 act = gaim_plugin_action_new(_("Change Password (URL)"), |
8407 oscar_show_chpassurl); | |
8408 m = g_list_append(m, act); | |
8409 | |
8410 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
8411 oscar_show_imforwardingurl); | |
8412 m = g_list_append(m, act); | |
7026 | 8413 } |
8414 | |
10570 | 8415 m = g_list_append(m, NULL); |
8416 | |
8417 if (od->icq) | |
8418 { | |
8419 /* ICQ actions */ | |
12652 | 8420 act = gaim_plugin_action_new(_("Set Privacy Options..."), |
10570 | 8421 oscar_show_icq_privacy_opts); |
8422 m = g_list_append(m, act); | |
8423 } | |
8424 else | |
8425 { | |
4617 | 8426 /* AIM actions */ |
9015 | 8427 act = gaim_plugin_action_new(_("Format Screen Name..."), |
8428 oscar_show_format_screenname); | |
8429 m = g_list_append(m, act); | |
8430 | |
8431 act = gaim_plugin_action_new(_("Confirm Account"), | |
8432 oscar_confirm_account); | |
8433 m = g_list_append(m, act); | |
8434 | |
8435 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
8436 oscar_show_email); | |
8437 m = g_list_append(m, act); | |
8438 | |
8439 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
8440 oscar_show_change_email); | |
8441 m = g_list_append(m, act); | |
2086 | 8442 } |
4333 | 8443 |
8444 m = g_list_append(m, NULL); | |
8445 | |
9015 | 8446 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
8447 oscar_show_awaitingauth); | |
8448 m = g_list_append(m, act); | |
4333 | 8449 |
2086 | 8450 m = g_list_append(m, NULL); |
4333 | 8451 |
9015 | 8452 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
8453 oscar_show_find_email); | |
8454 m = g_list_append(m, act); | |
4333 | 8455 |
8591 | 8456 #if 0 |
9015 | 8457 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
8458 show_find_info); | |
8459 m = g_list_append(m, act); | |
8591 | 8460 #endif |
2086 | 8461 |
8462 return m; | |
8463 } | |
8464 | |
5575 | 8465 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 8466 { |
7283 | 8467 OscarData *od = gc->proto_data; |
4617 | 8468 |
8469 if (od->icq) { | |
8470 aim_icq_changepasswd(od->sess, new); | |
2086 | 8471 } else { |
4617 | 8472 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
8473 if (conn) { | |
8474 aim_admin_changepasswd(od->sess, conn, new, old); | |
8475 } else { | |
8476 od->chpass = TRUE; | |
8477 od->oldp = g_strdup(old); | |
8478 od->newp = g_strdup(new); | |
8479 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
8480 } | |
2086 | 8481 } |
8482 } | |
8483 | |
6059 | 8484 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8485 { |
7283 | 8486 OscarData *od = gc->proto_data; |
8971 | 8487 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
|
8488 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8489 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8490 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8491 |
8971 | 8492 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8493 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8494 |
9935 | 8495 static void |
12816 | 8496 recent_buddies_cb(const char *name, GaimPrefType type, |
8497 gconstpointer value, gpointer data) | |
9935 | 8498 { |
8499 GaimConnection *gc = data; | |
8500 OscarData *od = gc->proto_data; | |
8501 aim_session_t *sess = od->sess; | |
8502 fu32_t presence; | |
8503 | |
8504 presence = aim_ssi_getpresence(sess->ssi.local); | |
8505 | |
8506 if (value) { | |
12486 | 8507 presence &= ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES; |
9935 | 8508 aim_ssi_setpresence(sess, presence); |
8509 } else { | |
12486 | 8510 presence |= AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES; |
9935 | 8511 aim_ssi_setpresence(sess, presence); |
8512 } | |
8513 } | |
8514 | |
8515 static GaimPluginPrefFrame * | |
9936 | 8516 get_plugin_pref_frame(GaimPlugin *plugin) |
8517 { | |
9935 | 8518 GaimPluginPrefFrame *frame; |
8519 GaimPluginPref *ppref; | |
8520 | |
8521 frame = gaim_plugin_pref_frame_new(); | |
8522 | |
12317
1baf4cbcf84d
[gaim-migrate @ 14621]
Richard Laager <rlaager@wiktel.com>
parents:
12271
diff
changeset
|
8523 #ifdef USE_PRPL_PREFERENCES |
9935 | 8524 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); |
8525 gaim_plugin_pref_frame_add(frame, ppref); | |
8526 | |
8527 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
8528 gaim_plugin_pref_frame_add(frame, ppref); | |
11369 | 8529 #endif |
13071 | 8530 |
11369 | 8531 ppref = gaim_plugin_pref_new_with_label(_("File Transfers")); |
8532 gaim_plugin_pref_frame_add(frame, ppref); | |
8533 | |
8534 ppref = gaim_plugin_pref_new_with_name_and_label( | |
8535 "/plugins/prpl/oscar/use_rv_proxy", | |
13071 | 8536 _("Use AIM/ICQ proxy server (slower, but usually works)")); |
11369 | 8537 gaim_plugin_pref_frame_add(frame, ppref); |
9935 | 8538 |
8539 return frame; | |
8540 } | |
8541 | |
11153 | 8542 static const char * |
8543 oscar_normalize(const GaimAccount *account, const char *str) | |
8544 { | |
8545 static char buf[BUF_LEN]; | |
8546 char *tmp1, *tmp2; | |
8547 int i, j; | |
8548 | |
8549 g_return_val_if_fail(str != NULL, NULL); | |
8550 | |
8551 strncpy(buf, str, BUF_LEN); | |
8552 for (i=0, j=0; buf[j]; i++, j++) | |
8553 { | |
8554 while (buf[j] == ' ') | |
8555 j++; | |
8556 buf[i] = buf[j]; | |
8557 } | |
8558 buf[i] = '\0'; | |
8559 | |
8560 tmp1 = g_utf8_strdown(buf, -1); | |
8561 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
8562 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
8563 g_free(tmp2); | |
8564 g_free(tmp1); | |
8565 | |
8566 return buf; | |
8567 } | |
8568 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8569 static gboolean oscar_offline_message(const GaimBuddy *buddy) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8570 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8571 OscarData *od; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8572 GaimAccount *account; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8573 GaimConnection *gc; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8574 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8575 account = gaim_buddy_get_account(buddy); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8576 gc = gaim_account_get_connection(account); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8577 od = (OscarData *)gc->proto_data; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8578 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8579 return (od->icq && aim_sn_is_icq(gaim_account_get_username(account))); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8580 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8581 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8582 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8583 { |
9308 | 8584 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 8585 NULL, /* user_splits */ |
8586 NULL, /* protocol_options */ | |
10674 | 8587 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
8588 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
9475 | 8589 oscar_list_icon, /* list_icon */ |
8590 oscar_list_emblems, /* list_emblems */ | |
8591 oscar_status_text, /* status_text */ | |
8592 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 8593 oscar_status_types, /* status_types */ |
9475 | 8594 oscar_blist_node_menu, /* blist_node_menu */ |
8595 oscar_chat_info, /* chat_info */ | |
9754 | 8596 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 8597 oscar_login, /* login */ |
8598 oscar_close, /* close */ | |
8599 oscar_send_im, /* send_im */ | |
8600 oscar_set_info, /* set_info */ | |
8601 oscar_send_typing, /* send_typing */ | |
8602 oscar_get_info, /* get_info */ | |
9973 | 8603 oscar_set_status, /* set_status */ |
9475 | 8604 oscar_set_idle, /* set_idle */ |
8605 oscar_change_passwd, /* change_passwd */ | |
8606 oscar_add_buddy, /* add_buddy */ | |
10866 | 8607 NULL, /* add_buddies */ |
9475 | 8608 oscar_remove_buddy, /* remove_buddy */ |
10866 | 8609 NULL, /* remove_buddies */ |
9475 | 8610 oscar_add_permit, /* add_permit */ |
8611 oscar_add_deny, /* add_deny */ | |
8612 oscar_rem_permit, /* rem_permit */ | |
8613 oscar_rem_deny, /* rem_deny */ | |
8614 oscar_set_permit_deny, /* set_permit_deny */ | |
8615 oscar_join_chat, /* join_chat */ | |
8616 NULL, /* reject_chat */ | |
9973 | 8617 oscar_get_chat_name, /* get_chat_name */ |
9475 | 8618 oscar_chat_invite, /* chat_invite */ |
8619 oscar_chat_leave, /* chat_leave */ | |
8620 NULL, /* chat_whisper */ | |
8621 oscar_send_chat, /* chat_send */ | |
8622 oscar_keepalive, /* keepalive */ | |
8623 NULL, /* register_user */ | |
8624 NULL, /* get_cb_info */ | |
8625 NULL, /* get_cb_away */ | |
8626 oscar_alias_buddy, /* alias_buddy */ | |
8627 oscar_move_buddy, /* group_buddy */ | |
8628 oscar_rename_group, /* rename_group */ | |
8629 NULL, /* buddy_free */ | |
8630 oscar_convo_closed, /* convo_closed */ | |
11153 | 8631 oscar_normalize, /* normalize */ |
9475 | 8632 oscar_set_icon, /* set_buddy_icon */ |
8633 NULL, /* remove_group */ | |
8634 NULL, /* get_cb_real_name */ | |
8635 NULL, /* set_chat_topic */ | |
8636 NULL, /* find_blist_chat */ | |
8637 NULL, /* roomlist_get_list */ | |
8638 NULL, /* roomlist_cancel */ | |
8639 NULL, /* roomlist_expand_category */ | |
8640 oscar_can_receive_file, /* can_receive_file */ | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
8641 oscar_send_file, /* send_file */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
8642 oscar_new_xfer, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8643 oscar_offline_message, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8644 NULL, /* whiteboard_prpl_ops */ |
12617 | 8645 NULL, /* media_prpl_ops */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8646 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8647 |
9935 | 8648 static GaimPluginUiInfo prefs_info = { |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8649 get_plugin_pref_frame, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8650 0, /* page_num (Reserved) */ |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8651 NULL /* frame (Reserved) */ |
9935 | 8652 }; |
8653 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8654 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8655 { |
9943 | 8656 GAIM_PLUGIN_MAGIC, |
8657 GAIM_MAJOR_VERSION, | |
8658 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8659 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8660 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8661 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8662 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8663 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8664 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8665 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8666 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8667 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8668 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8669 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8670 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8671 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8672 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
8673 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8674 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8675 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8676 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8677 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8678 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8679 NULL, /**< ui_info */ |
8993 | 8680 &prpl_info, /**< extra_info */ |
11369 | 8681 &prefs_info, |
9015 | 8682 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8683 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8684 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8685 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
8686 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8687 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
8688 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
8689 |
11338 | 8690 option = gaim_account_option_string_new(_("Auth host"), "server", OSCAR_DEFAULT_LOGIN_SERVER); |
9830 | 8691 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
8692 | |
11338 | 8693 option = gaim_account_option_int_new(_("Auth port"), "port", OSCAR_DEFAULT_LOGIN_PORT); |
9830 | 8694 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
8695 | |
8696 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
8697 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
13073 | 8698 |
13071 | 8699 option = gaim_account_option_bool_new( |
13073 | 8700 _("Use AIM/ICQ proxy server\n(slower, but usually works)"), "use_rv_proxy", |
13071 | 8701 OSCAR_DEFAULT_USE_RV_PROXY); |
8702 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
11338 | 8703 |
11369 | 8704 /* Preferences */ |
9935 | 8705 gaim_prefs_add_none("/plugins/prpl/oscar"); |
8706 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 8707 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
11369 | 8708 gaim_prefs_add_bool("/plugins/prpl/oscar/use_rv_proxy", FALSE); |
2086 | 8709 } |
8710 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
8711 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |