Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 10125:ee50e4797352
[gaim-migrate @ 11162]
I fixed the problem described in patch 1038166 in a slightly different way.
While I was at it I got carried away and made it not show size and stuff
in the dialog. The way I did it is probably very evil, and someone will
probably revert it. Just delete the realize_ function.
But this is HEAD, so we can try it anyway.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Tue, 19 Oct 2004 04:39:55 +0000 |
parents | 9f358a718f38 |
children | 096197a628bf |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
6 * Some code copyright (C) 2001-2003, Sean Egan | |
8151 | 7 * Some code copyright (C) 2001-2004, Mark Doliner <thekingant@users.sourceforge.net> |
6302 | 8 * |
9 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 10 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 11 * |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10042 | 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2086 | 20 * GNU General Public License for more details. |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 * | |
26 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
31 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
32 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
33 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "ft.h" |
6982 | 36 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
37 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
38 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "privacy.h" |
2086 | 40 #include "prpl.h" |
4889 | 41 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
42 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "util.h" |
9943 | 44 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 |
2086 | 46 #include "aim.h" |
5842 | 47 #include "md5.h" |
2086 | 48 |
9976 | 49 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
50 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
51 #define OSCAR_STATUS_ID_ONLINE "online" | |
9991 | 52 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 53 #define OSCAR_STATUS_ID_AWAY "away" |
54 #define OSCAR_STATUS_ID_DND "dnd" | |
55 #define OSCAR_STATUS_ID_NA "na" | |
56 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
57 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
58 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 59 |
2086 | 60 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
61 | |
7283 | 62 #define OSCAR_CONNECT_STEPS 6 |
9830 | 63 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 64 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
65 static GaimPlugin *my_protocol = NULL; |
4249 | 66 |
7376 | 67 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
68 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 69 |
4665 | 70 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
71 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 72 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 73 |
7283 | 74 typedef struct _OscarData OscarData; |
75 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
76 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
77 aim_conn_t *conn; |
2086 | 78 |
79 guint cnpa; | |
80 guint paspa; | |
3694 | 81 guint emlpa; |
4804 | 82 guint icopa; |
2086 | 83 |
4823 | 84 gboolean iconconnecting; |
5842 | 85 gboolean set_icon; |
4823 | 86 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
87 GSList *create_rooms; |
2086 | 88 |
89 gboolean conf; | |
90 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
91 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
92 char *email; |
2979 | 93 gboolean setnick; |
94 char *newsn; | |
2086 | 95 gboolean chpass; |
96 char *oldp; | |
97 char *newp; | |
9971 | 98 |
2086 | 99 GSList *oscar_chats; |
100 GSList *direct_ims; | |
3630 | 101 GSList *file_transfers; |
4738 | 102 GHashTable *buddyinfo; |
4804 | 103 GSList *requesticon; |
2086 | 104 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
105 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
106 gboolean icq; |
4804 | 107 guint icontimer; |
5968 | 108 guint getblisttimer; |
8341 | 109 guint getinfotimer; |
2993 | 110 |
111 struct { | |
4230 | 112 guint maxwatchers; /* max users who can watch you */ |
2993 | 113 guint maxbuddies; /* max users you can watch */ |
4230 | 114 guint maxgroups; /* max groups in server list */ |
2993 | 115 guint maxpermits; /* max users on permit list */ |
116 guint maxdenies; /* max users on deny list */ | |
117 guint maxsiglen; /* max size (bytes) of profile */ | |
118 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
119 } rights; | |
2086 | 120 }; |
121 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
122 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
123 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
124 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
125 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
126 |
2086 | 127 struct chat_connection { |
128 char *name; | |
129 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
130 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
131 fu16_t instance; |
2086 | 132 int fd; /* this is redundant since we have the conn below */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
133 aim_conn_t *conn; |
2086 | 134 int inpa; |
135 int id; | |
5575 | 136 GaimConnection *gc; /* i hate this. */ |
8733 | 137 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
138 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
139 int maxvis; |
2086 | 140 }; |
141 | |
8971 | 142 struct oscar_direct_im { |
5575 | 143 GaimConnection *gc; |
2086 | 144 char name[80]; |
145 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
146 aim_conn_t *conn; |
3008 | 147 gboolean connected; |
8978 | 148 gboolean gpc_pend; |
149 gboolean killme; | |
8984 | 150 gboolean donttryagain; |
2086 | 151 }; |
152 | |
153 struct ask_direct { | |
5575 | 154 GaimConnection *gc; |
2086 | 155 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
156 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
157 fu8_t cookie[8]; |
8984 | 158 gboolean donttryagain; |
2086 | 159 }; |
160 | |
7011 | 161 /* |
162 * Various PRPL-specific buddy info that we want to keep track of | |
163 * Some other info is maintained by locate.c, and I'd like to move | |
164 * the rest of this to libfaim, mostly im.c | |
165 */ | |
4738 | 166 struct buddyinfo { |
167 gboolean typingnot; | |
6292 | 168 gchar *availmsg; |
6857 | 169 fu32_t ipaddr; |
5836 | 170 |
171 unsigned long ico_me_len; | |
172 unsigned long ico_me_csum; | |
173 time_t ico_me_time; | |
174 gboolean ico_informed; | |
4738 | 175 |
176 unsigned long ico_len; | |
177 unsigned long ico_csum; | |
178 time_t ico_time; | |
179 gboolean ico_need; | |
7406 | 180 gboolean ico_sent; |
2086 | 181 }; |
182 | |
4230 | 183 struct name_data { |
5575 | 184 GaimConnection *gc; |
4230 | 185 gchar *name; |
3453 | 186 gchar *nick; |
3141 | 187 }; |
188 | |
5129 | 189 static char *msgerrreason[] = { |
190 N_("Invalid error"), | |
191 N_("Invalid SNAC"), | |
192 N_("Rate to host"), | |
193 N_("Rate to client"), | |
194 N_("Not logged in"), | |
195 N_("Service unavailable"), | |
196 N_("Service not defined"), | |
197 N_("Obsolete SNAC"), | |
198 N_("Not supported by host"), | |
199 N_("Not supported by client"), | |
200 N_("Refused by client"), | |
201 N_("Reply too big"), | |
202 N_("Responses lost"), | |
203 N_("Request denied"), | |
204 N_("Busted SNAC payload"), | |
205 N_("Insufficient rights"), | |
206 N_("In local permit/deny"), | |
207 N_("Too evil (sender)"), | |
208 N_("Too evil (receiver)"), | |
209 N_("User temporarily unavailable"), | |
210 N_("No match"), | |
211 N_("List overflow"), | |
212 N_("Request ambiguous"), | |
213 N_("Queue full"), | |
214 N_("Not while on AOL") | |
215 }; | |
216 static int msgerrreasonlen = 25; | |
217 | |
218 /* All the libfaim->gaim callback functions */ | |
219 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
220 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
221 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
224 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
225 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
226 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 229 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 230 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 231 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
232 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
|
233 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
|
234 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
|
235 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
|
236 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 237 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
238 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 240 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 241 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
242 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
243 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
244 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
245 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
248 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
249 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
250 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
251 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
252 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
253 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
268 #ifndef NOSSI | |
269 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 273 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 274 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
275 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
277 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
278 #endif | |
279 | |
280 /* for DirectIM/image transfer */ | |
281 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
282 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
283 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 284 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 285 |
286 /* for file transfer */ | |
287 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
288 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
289 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
290 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
291 | |
292 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 293 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 294 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 295 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 296 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
297 | |
5836 | 298 static void oscar_free_name_data(struct name_data *data) { |
4230 | 299 g_free(data->name); |
300 g_free(data->nick); | |
301 g_free(data); | |
302 } | |
303 | |
5836 | 304 static void oscar_free_buddyinfo(void *data) { |
305 struct buddyinfo *bi = data; | |
6292 | 306 g_free(bi->availmsg); |
5836 | 307 g_free(bi); |
308 } | |
309 | |
9807 | 310 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 311 { |
312 int i = 0; | |
9826 | 313 int charset = AIM_CHARSET_ASCII; |
5129 | 314 |
315 /* Determine how we can send this message. Per the warnings elsewhere | |
316 * in this file, these little checks determine the simplest encoding | |
317 * we can use for a given message send using it. */ | |
318 while (utf8[i]) { | |
319 if ((unsigned char)utf8[i] > 0x7f) { | |
320 /* not ASCII! */ | |
9826 | 321 charset = AIM_CHARSET_CUSTOM; |
5129 | 322 break; |
323 } | |
324 i++; | |
325 } | |
326 while (utf8[i]) { | |
327 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
328 * followed by 0xc0-0xc3 in the second */ | |
329 if ((unsigned char)utf8[i] < 0x80) { | |
330 i++; | |
331 continue; | |
332 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
333 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
334 i += 2; | |
335 continue; | |
336 } | |
9826 | 337 charset = AIM_CHARSET_UNICODE; |
5129 | 338 break; |
339 } | |
340 | |
9807 | 341 return charset; |
5129 | 342 } |
343 | |
8225 | 344 /* |
345 * Take a string of the form charset="bleh" where bleh is | |
346 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
347 * return a newly allocated string containing bleh. | |
348 */ | |
349 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 350 { |
8225 | 351 gchar *ret = NULL; |
352 char *begin, *end; | |
353 | |
9933 | 354 g_return_val_if_fail(encoding != NULL, NULL); |
355 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
356 /* Make sure encoding begins with charset= */ |
8225 | 357 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
358 return NULL; | |
359 | |
360 begin = strchr(encoding, '"'); | |
361 end = strrchr(encoding, '"'); | |
362 | |
363 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
364 return NULL; | |
365 | |
366 ret = g_strndup(begin+1, (end-1) - begin); | |
367 | |
368 return ret; | |
369 } | |
370 | |
9830 | 371 static gchar * |
372 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 373 { |
374 gchar *utf8 = NULL; | |
9595 | 375 |
376 if ((encoding == NULL) || encoding[0] == '\0') { | |
377 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
378 | |
9639 | 379 } else if (!strcmp(encoding, "iso-8859-1") |
380 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 381 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
382 | |
383 } else if (!strcmp(encoding, "unicode-2-0")) { | |
384 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
385 | |
386 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
387 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
10096 | 388 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 389 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
390 } | |
391 | |
392 /* | |
393 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
394 * we have been unable to convert the text to utf-8 from the encoding | |
395 * that was specified. So we check if the text is valid utf-8 then | |
396 * just copy it. | |
397 */ | |
398 if (utf8 == NULL) { | |
9638 | 399 if (textlen != 0 && *text != '\0' |
400 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 401 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 402 else |
9481 | 403 utf8 = g_strndup(text, textlen); |
5129 | 404 } |
405 | |
406 return utf8; | |
407 } | |
408 | |
9830 | 409 static gchar * |
9908 | 410 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 411 { |
412 gchar *ret = NULL; | |
413 GError *err = NULL; | |
414 | |
9908 | 415 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
416 return NULL; | |
417 | |
418 if (strcasecmp("UTF-8", charsetstr)) { | |
419 if (fallback) | |
420 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
421 else | |
422 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
423 if (err != NULL) { | |
424 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
425 charsetstr, err->message); | |
426 g_error_free(err); | |
427 } | |
428 } else { | |
429 if (g_utf8_validate(data, datalen, NULL)) | |
430 ret = g_strndup(data, datalen); | |
431 else | |
432 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
433 } | |
434 | |
435 return ret; | |
436 } | |
437 | |
438 /* | |
439 * We try decoding using two different character sets. The charset | |
440 * specified in the IM determines the order in which we attempt to | |
441 * decode. We do this because there are lots of broken ICQ clients | |
442 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
443 * able to deal with that crap, then people complain like banshees. | |
444 * charsetstr1 is always set to what the correct encoding should be. | |
445 */ | |
446 static gchar * | |
447 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
448 { | |
449 gchar *ret = NULL; | |
450 const gchar *charsetstr1, *charsetstr2; | |
451 | |
452 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 453 |
454 if ((datalen == 0) || (data == NULL)) | |
455 return NULL; | |
456 | |
9908 | 457 if (charset == AIM_CHARSET_UNICODE) { |
458 charsetstr1 = "UCS-2BE"; | |
459 charsetstr2 = "UTF-8"; | |
460 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 461 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 462 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 463 else |
9908 | 464 charsetstr1 = "ISO-8859-1"; |
465 charsetstr2 = "UTF-8"; | |
466 } else if (charset == AIM_CHARSET_ASCII) { | |
467 /* Should just be "ASCII" */ | |
9914 | 468 charsetstr1 = "ASCII"; |
9908 | 469 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
470 } else if (charset == 0x000d) { | |
9830 | 471 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 472 charsetstr1 = "ISO-8859-1"; |
473 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
474 } else { | |
9830 | 475 /* Unknown, hope for valid UTF-8... */ |
9908 | 476 charsetstr1 = "UTF-8"; |
477 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
478 } | |
479 | |
480 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
481 if (ret == NULL) | |
482 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
483 if (ret == NULL) | |
484 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 485 |
486 return ret; | |
487 } | |
488 | |
489 static void | |
490 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 491 gchar **msg, int *msglen_int, |
9830 | 492 fu16_t *charset, fu16_t *charsubset) |
493 { | |
494 OscarData *od = gc->proto_data; | |
495 GaimAccount *account = gaim_connection_get_account(gc); | |
496 GError *err = NULL; | |
497 aim_userinfo_t *userinfo = NULL; | |
498 const gchar *charsetstr; | |
10039 | 499 gsize msglen; |
9830 | 500 |
501 /* Attempt to send as ASCII */ | |
10098 | 502 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 503 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 504 *charset = AIM_CHARSET_ASCII; |
9830 | 505 *charsubset = 0x0000; |
10039 | 506 *msglen_int = msglen; |
9830 | 507 return; |
508 } | |
509 | |
510 /* | |
9908 | 511 * If we're sending to an ICQ user, and they are advertising the |
512 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 513 */ |
9975 | 514 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 515 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
516 | |
517 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
10039 | 518 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
9830 | 519 if (*msg != NULL) { |
520 *charset = AIM_CHARSET_UNICODE; | |
521 *charsubset = 0x0000; | |
10039 | 522 *msglen_int = msglen; |
9830 | 523 return; |
524 } | |
525 } | |
526 | |
527 /* | |
528 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
529 * ICQ then attempt to send as the user specified character encoding. | |
530 */ | |
531 charsetstr = "ISO-8859-1"; | |
9975 | 532 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 533 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
534 | |
10097 | 535 /* |
536 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
537 * can be converted to "charsetstr" | |
538 */ | |
10039 | 539 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 540 if (*msg != NULL) { |
541 *charset = AIM_CHARSET_CUSTOM; | |
542 *charsubset = 0x0000; | |
10039 | 543 *msglen_int = msglen; |
9830 | 544 return; |
545 } | |
546 | |
547 /* | |
548 * Nothing else worked, so send as UCS-2BE. | |
549 */ | |
10039 | 550 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 551 if (*msg != NULL) { |
552 *charset = AIM_CHARSET_UNICODE; | |
553 *charsubset = 0x0000; | |
10039 | 554 *msglen_int = msglen; |
9830 | 555 return; |
556 } | |
557 | |
9908 | 558 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 559 g_error_free(err); |
560 | |
561 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
562 *msg = g_strdup(from); | |
10039 | 563 *msglen_int = strlen(*msg); |
9830 | 564 *charset = AIM_CHARSET_ASCII; |
565 *charsubset = 0x0000; | |
566 return; | |
567 } | |
568 | |
9407 | 569 gchar *oscar_caps_to_string(guint caps) |
8701 | 570 { |
9407 | 571 GString *str; |
572 gchar *tmp; | |
8701 | 573 guint bit = 1; |
574 | |
9407 | 575 str = g_string_new(""); |
576 | |
8701 | 577 if (!caps) { |
578 return NULL; | |
579 } else while (bit <= AIM_CAPS_LAST) { | |
580 if (bit & caps) { | |
581 switch (bit) { | |
582 case AIM_CAPS_BUDDYICON: | |
583 tmp = _("Buddy Icon"); | |
584 break; | |
585 case AIM_CAPS_TALK: | |
586 tmp = _("Voice"); | |
587 break; | |
588 case AIM_CAPS_DIRECTIM: | |
589 tmp = _("AIM Direct IM"); | |
590 break; | |
591 case AIM_CAPS_CHAT: | |
592 tmp = _("Chat"); | |
593 break; | |
594 case AIM_CAPS_GETFILE: | |
595 tmp = _("Get File"); | |
596 break; | |
597 case AIM_CAPS_SENDFILE: | |
598 tmp = _("Send File"); | |
599 break; | |
600 case AIM_CAPS_GAMES: | |
601 case AIM_CAPS_GAMES2: | |
602 tmp = _("Games"); | |
603 break; | |
604 case AIM_CAPS_ADDINS: | |
605 tmp = _("Add-Ins"); | |
606 break; | |
607 case AIM_CAPS_SENDBUDDYLIST: | |
608 tmp = _("Send Buddy List"); | |
609 break; | |
610 case AIM_CAPS_ICQ_DIRECT: | |
611 tmp = _("ICQ Direct Connect"); | |
612 break; | |
613 case AIM_CAPS_APINFO: | |
614 tmp = _("AP User"); | |
615 break; | |
616 case AIM_CAPS_ICQRTF: | |
617 tmp = _("ICQ RTF"); | |
618 break; | |
619 case AIM_CAPS_EMPTY: | |
620 tmp = _("Nihilist"); | |
621 break; | |
622 case AIM_CAPS_ICQSERVERRELAY: | |
623 tmp = _("ICQ Server Relay"); | |
624 break; | |
625 case AIM_CAPS_ICQUTF8OLD: | |
626 tmp = _("Old ICQ UTF8"); | |
627 break; | |
628 case AIM_CAPS_TRILLIANCRYPT: | |
629 tmp = _("Trillian Encryption"); | |
630 break; | |
631 case AIM_CAPS_ICQUTF8: | |
632 tmp = _("ICQ UTF8"); | |
633 break; | |
634 case AIM_CAPS_HIPTOP: | |
635 tmp = _("Hiptop"); | |
636 break; | |
637 case AIM_CAPS_SECUREIM: | |
638 tmp = _("Security Enabled"); | |
639 break; | |
640 case AIM_CAPS_VIDEO: | |
641 tmp = _("Video Chat"); | |
642 break; | |
643 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
644 case AIM_CAPS_ICHATAV: | |
645 tmp = _("iChat AV"); | |
646 break; | |
647 case AIM_CAPS_LIVEVIDEO: | |
648 tmp = _("Live Video"); | |
649 break; | |
650 case AIM_CAPS_CAMERA: | |
651 tmp = _("Camera"); | |
652 break; | |
653 default: | |
654 tmp = NULL; | |
655 break; | |
656 } | |
657 if (tmp) | |
9532 | 658 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 659 } |
660 bit <<= 1; | |
661 } | |
9407 | 662 |
663 return g_string_free(str, FALSE); | |
8701 | 664 } |
665 | |
666 static char *oscar_icqstatus(int state) { | |
667 /* Make a cute little string that shows the status of the dude or dudet */ | |
668 if (state & AIM_ICQ_STATE_CHAT) | |
669 return g_strdup_printf(_("Free For Chat")); | |
670 else if (state & AIM_ICQ_STATE_DND) | |
671 return g_strdup_printf(_("Do Not Disturb")); | |
672 else if (state & AIM_ICQ_STATE_OUT) | |
673 return g_strdup_printf(_("Not Available")); | |
674 else if (state & AIM_ICQ_STATE_BUSY) | |
675 return g_strdup_printf(_("Occupied")); | |
676 else if (state & AIM_ICQ_STATE_AWAY) | |
677 return g_strdup_printf(_("Away")); | |
678 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
679 return g_strdup_printf(_("Web Aware")); | |
680 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
681 return g_strdup_printf(_("Invisible")); | |
682 else | |
683 return g_strdup_printf(_("Online")); | |
684 } | |
685 | |
9973 | 686 static void |
687 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 688 { |
689 gchar *utf8; | |
690 | |
691 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 692 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 693 g_free(utf8); |
694 } | |
695 } | |
696 | |
9973 | 697 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 698 { |
10042 | 699 OscarData *od; |
700 GaimAccount *account; | |
701 GaimPresence *presence; | |
702 GaimPresence *buddy_presence; | |
8701 | 703 GaimGroup *g = NULL; |
704 struct buddyinfo *bi = NULL; | |
705 char *tmp; | |
706 | |
10042 | 707 od = gc->proto_data; |
708 account = gaim_connection_get_account(gc); | |
709 presence = gaim_account_get_presence(account); | |
710 buddy_presence = gaim_buddy_get_presence(b); | |
711 | |
712 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 713 return; |
714 | |
715 if (userinfo == NULL) | |
716 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
717 | |
718 if (b == NULL) | |
10042 | 719 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 720 |
721 if (b != NULL) | |
722 g = gaim_find_buddys_group(b); | |
723 | |
724 if (userinfo != NULL) | |
725 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
726 | |
8733 | 727 if (b != NULL) { |
10042 | 728 if (gaim_presence_is_online(buddy_presence)) { |
9975 | 729 if (aim_sn_is_icq(b->name)) { |
8733 | 730 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
731 oscar_string_append(str, newline, _("Status"), tmp); | |
732 g_free(tmp); | |
733 } | |
734 } else { | |
9625 | 735 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 736 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
737 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
738 else | |
739 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 740 } |
8733 | 741 } |
8701 | 742 |
743 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 744 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 745 (bi->ipaddr & 0xff000000) >> 24, |
746 (bi->ipaddr & 0x00ff0000) >> 16, | |
747 (bi->ipaddr & 0x0000ff00) >> 8, | |
748 (bi->ipaddr & 0x000000ff)); | |
749 oscar_string_append(str, newline, _("IP Address"), tmp); | |
750 g_free(tmp); | |
751 } | |
752 | |
753 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
754 tmp = oscar_caps_to_string(userinfo->capabilities); | |
755 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 756 g_free(tmp); |
8701 | 757 } |
758 | |
759 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
760 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
761 if (tmp != NULL) { | |
9625 | 762 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 763 g_free(tmp); |
9625 | 764 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
765 g_free(tmp2); | |
8701 | 766 } |
767 } | |
768 | |
10042 | 769 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_presence_is_available(presence)) { |
8701 | 770 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
771 oscar_string_append(str, newline, _("Available"), tmp); | |
772 g_free(tmp); | |
773 } | |
774 } | |
775 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
776 static char *extract_name(const char *name) { |
4121 | 777 char *tmp, *x; |
2086 | 778 int i, j; |
4120 | 779 |
780 if (!name) | |
4121 | 781 return NULL; |
10042 | 782 |
4120 | 783 x = strchr(name, '-'); |
4121 | 784 |
2086 | 785 if (!x) return NULL; |
786 x = strchr(++x, '-'); | |
787 if (!x) return NULL; | |
788 tmp = g_strdup(++x); | |
789 | |
790 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
791 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
792 if (x[i] != '%') { |
2086 | 793 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
794 continue; |
2086 | 795 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
796 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
797 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
798 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 799 } |
800 | |
801 tmp[j] = 0; | |
802 return tmp; | |
803 } | |
804 | |
5575 | 805 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 806 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 807 struct chat_connection *c = NULL; |
808 | |
809 while (g) { | |
810 c = (struct chat_connection *)g->data; | |
811 if (c->id == id) | |
812 break; | |
813 g = g->next; | |
814 c = NULL; | |
815 } | |
816 | |
817 return c; | |
818 } | |
819 | |
5575 | 820 static struct chat_connection *find_oscar_chat_by_conn(GaimConnection *gc, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
821 aim_conn_t *conn) { |
7283 | 822 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 823 struct chat_connection *c = NULL; |
824 | |
825 while (g) { | |
826 c = (struct chat_connection *)g->data; | |
827 if (c->conn == conn) | |
828 break; | |
829 g = g->next; | |
830 c = NULL; | |
831 } | |
832 | |
833 return c; | |
834 } | |
835 | |
8219 | 836 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
837 GaimConversation *conv) { | |
838 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
839 struct chat_connection *c = NULL; | |
840 | |
841 while (g) { | |
842 c = (struct chat_connection *)g->data; | |
8733 | 843 if (c->conv == conv) |
8219 | 844 break; |
845 g = g->next; | |
846 c = NULL; | |
847 } | |
848 | |
849 return c; | |
850 } | |
851 | |
8971 | 852 /***************************************************************************** |
853 * Begin scary direct im stuff | |
854 *****************************************************************************/ | |
855 | |
856 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
857 GSList *d = od->direct_ims; | |
858 struct oscar_direct_im *m = NULL; | |
859 | |
860 while (d) { | |
861 m = (struct oscar_direct_im *)d->data; | |
862 if (!aim_sncmp(who, m->name)) | |
863 return m; | |
864 d = d->next; | |
865 } | |
866 | |
867 return NULL; | |
868 } | |
869 | |
870 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
871 { | |
872 gaim_debug_info("oscar", | |
873 "destroying Direct IM for %s.\n", dim->name); | |
874 | |
875 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 876 if (dim->gpc_pend) { |
877 dim->killme = TRUE; | |
878 return; | |
879 } | |
8971 | 880 if (dim->watcher) |
881 gaim_input_remove(dim->watcher); | |
882 if (dim->conn) { | |
883 aim_conn_close(dim->conn); | |
884 aim_conn_kill(od->sess, &dim->conn); | |
885 } | |
886 g_free(dim); | |
887 } | |
888 | |
889 /* the only difference between this and destroy is this writes a conv message */ | |
890 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
891 { | |
892 GaimConversation *conv; | |
893 char buf[256]; | |
894 | |
895 gaim_debug_info("oscar", | |
896 "%s disconnected Direct IM.\n", dim->name); | |
897 | |
898 if (dim->connected) | |
899 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 900 else |
8971 | 901 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
902 | |
903 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
904 if (conv) { | |
905 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 906 gaim_conversation_update_progress(conv, 0); |
8971 | 907 } else { |
908 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
909 } | |
910 | |
911 oscar_direct_im_destroy(od, dim); | |
912 | |
913 return; | |
914 } | |
915 | |
916 /* oops i made two of these. this one just calls the other one. */ | |
917 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
918 { | |
919 GaimConnection *gc = sess->aux_data; | |
920 OscarData *od = (OscarData *)gc->proto_data; | |
921 struct oscar_direct_im *dim; | |
922 char *sn; | |
923 | |
924 sn = g_strdup(aim_odc_getsn(conn)); | |
925 dim = oscar_direct_im_find(od, sn); | |
926 oscar_direct_im_disconnect(od, dim); | |
927 g_free(sn); | |
928 } | |
929 | |
930 static void destroy_direct_im_request(struct ask_direct *d) { | |
931 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
932 | |
933 g_free(d->sn); | |
934 g_free(d); | |
935 } | |
936 | |
937 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
938 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
939 struct oscar_direct_im *dim = data; | |
940 GaimConnection *gc = dim->gc; | |
941 OscarData *od = gc->proto_data; | |
942 GaimConversation *conv; | |
943 char buf[256]; | |
944 struct sockaddr name; | |
945 socklen_t name_len = 1; | |
946 | |
947 g_return_if_fail(gc != NULL); | |
948 | |
8978 | 949 dim->gpc_pend = FALSE; |
950 if (dim->killme) { | |
951 oscar_direct_im_destroy(od, dim); | |
952 return; | |
953 } | |
954 | |
8971 | 955 if (!g_list_find(gaim_connections_get_all(), gc)) { |
956 oscar_direct_im_destroy(od, dim); | |
957 return; | |
958 } | |
959 | |
960 if (source < 0) { | |
8984 | 961 if (dim->donttryagain) { |
962 oscar_direct_im_disconnect(od, dim); | |
963 return; | |
964 } else { | |
965 fu8_t cookie[8]; | |
966 char *who = g_strdup(dim->name); | |
967 const char *tmp = aim_odc_getcookie(dim->conn); | |
968 | |
969 memcpy(cookie, tmp, 8); | |
970 oscar_direct_im_destroy(od, dim); | |
971 oscar_direct_im_initiate(gc, who, cookie); | |
972 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
973 g_free(who); | |
974 return; | |
975 } | |
8971 | 976 } |
977 | |
978 dim->conn->fd = source; | |
979 aim_conn_completeconnect(od->sess, dim->conn); | |
980 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
981 | |
982 /* This is the best way to see if we're connected or not */ | |
8983 | 983 /* Is this really needed? */ |
8971 | 984 if (getpeername(source, &name, &name_len) == 0) { |
985 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
986 dim->connected = TRUE; | |
987 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 988 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
989 } else { | |
8984 | 990 if (dim->donttryagain) { |
991 oscar_direct_im_disconnect(od, dim); | |
992 return; | |
993 } else { | |
994 fu8_t cookie[8]; | |
995 char *who = g_strdup(dim->name); | |
996 const char *tmp = aim_odc_getcookie(dim->conn); | |
997 | |
998 memcpy(cookie, tmp, 8); | |
999 oscar_direct_im_destroy(od, dim); | |
1000 oscar_direct_im_initiate(gc, who, cookie); | |
1001 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1002 g_free(who); | |
1003 return; | |
1004 } | |
8983 | 1005 } |
1006 | |
1007 | |
8971 | 1008 } |
1009 | |
1010 static void accept_direct_im_request(struct ask_direct *d) { | |
1011 GaimConnection *gc = d->gc; | |
1012 OscarData *od; | |
1013 struct oscar_direct_im *dim; | |
1014 char *host; int port = 5190; | |
1015 int i, rc; | |
8982 | 1016 char *tmp; |
1017 GaimConversation *conv; | |
8971 | 1018 |
1019 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1020 destroy_direct_im_request(d); | |
1021 return; | |
1022 } | |
1023 | |
1024 od = (OscarData *)gc->proto_data; | |
1025 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1026 | |
1027 dim = oscar_direct_im_find(od, d->sn); | |
1028 if (dim && dim->connected) { | |
1029 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1030 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1031 return; | |
1032 } | |
1033 dim = g_new0(struct oscar_direct_im, 1); | |
1034 dim->gc = d->gc; | |
8984 | 1035 dim->donttryagain = d->donttryagain; |
8971 | 1036 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1037 | |
1038 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1039 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1040 if (!dim->conn) { | |
1041 oscar_direct_im_disconnect(od, dim); | |
1042 destroy_direct_im_request(d); | |
1043 return; | |
1044 } | |
1045 | |
1046 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1047 gaim_odc_incoming, 0); | |
1048 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1049 gaim_odc_typing, 0); | |
1050 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1051 gaim_odc_update_ui, 0); | |
1052 | |
1053 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1054 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1055 if (d->ip[i] == ':') { | |
1056 port = atoi(&(d->ip[i+1])); | |
1057 break; | |
1058 } | |
1059 } | |
1060 host = g_strndup(d->ip, i); | |
1061 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1062 dim->gpc_pend = TRUE; |
8971 | 1063 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1064 |
1065 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1066 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1067 port); | |
1068 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1069 g_free(tmp); | |
8983 | 1070 |
8971 | 1071 g_free(host); |
1072 if (rc < 0) { | |
8978 | 1073 dim->gpc_pend = FALSE; |
8971 | 1074 oscar_direct_im_disconnect(od, dim); |
1075 destroy_direct_im_request(d); | |
1076 return; | |
1077 } | |
1078 | |
1079 destroy_direct_im_request(d); | |
1080 | |
1081 return; | |
1082 } | |
1083 | |
1084 /* | |
1085 * We have just established a socket with the other dude, so set up some handlers. | |
1086 */ | |
1087 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1088 GaimConnection *gc = sess->aux_data; |
7283 | 1089 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1090 GaimConversation *conv; |
8971 | 1091 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1092 char buf[256]; |
8971 | 1093 char *sn; |
1094 va_list ap; | |
1095 aim_conn_t *newconn, *listenerconn; | |
1096 | |
1097 va_start(ap, fr); | |
1098 newconn = va_arg(ap, aim_conn_t *); | |
1099 listenerconn = va_arg(ap, aim_conn_t *); | |
1100 va_end(ap); | |
1101 | |
1102 aim_conn_close(listenerconn); | |
1103 aim_conn_kill(sess, &listenerconn); | |
1104 | |
1105 sn = g_strdup(aim_odc_getsn(newconn)); | |
1106 | |
1107 gaim_debug_info("oscar", | |
1108 "DirectIM: initiate success to %s\n", sn); | |
1109 dim = oscar_direct_im_find(od, sn); | |
1110 | |
1111 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1112 gaim_input_remove(dim->watcher); | |
1113 dim->conn = newconn; | |
1114 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1115 dim->connected = TRUE; | |
1116 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1117 g_free(sn); | |
1118 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1119 | |
1120 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1121 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1122 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1123 | |
1124 return 1; | |
1125 } | |
1126 | |
1127 /* | |
1128 * This is called when each chunk of an image is received. It can be used to | |
1129 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1130 * nasty, you sicko. | |
1131 */ | |
1132 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1133 va_list ap; | |
1134 char *sn; | |
1135 double percent; | |
1136 GaimConnection *gc = sess->aux_data; | |
1137 OscarData *od = (OscarData *)gc->proto_data; | |
1138 GaimConversation *c; | |
1139 struct oscar_direct_im *dim; | |
1140 | |
1141 va_start(ap, fr); | |
1142 sn = va_arg(ap, char *); | |
1143 percent = va_arg(ap, double); | |
1144 va_end(ap); | |
1145 | |
1146 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1147 return 1; | |
1148 if (dim->watcher) { | |
1149 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1150 /* The callback will callback? I don't get how that would happen here. */ | |
1151 dim->watcher = 0; | |
1152 } | |
1153 | |
1154 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
1155 if (c != NULL) | |
1156 gaim_conversation_update_progress(c, percent); | |
1157 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1158 oscar_callback, dim->conn); | |
1159 | |
1160 return 1; | |
1161 } | |
1162 | |
1163 /* | |
1164 * This is called after a direct IM has been received in its entirety. This | |
1165 * function is passed a long chunk of data which contains the IM with any | |
1166 * data chunks (images) appended to it. | |
1167 * | |
1168 * This function rips out all the data chunks and creates an imgstore for | |
1169 * each one. In order to do this, it first goes through the IM and takes | |
1170 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1171 * with one compatible with the imgstore Gaim core code. For each one, we | |
1172 * then read in chunks of data from the end of the message and actually | |
1173 * create the img store using the given data. | |
1174 * | |
1175 * For somewhat easy reference, here's a sample message | |
1176 * (without the whitespace and asterisks): | |
1177 * | |
1178 * <HTML><BODY BGCOLOR="#ffffff"> | |
1179 * <FONT LANG="0"> | |
1180 * This is a really stupid picture:<BR> | |
1181 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1182 * Yeah it is<BR> | |
1183 * Here is another one:<BR> | |
1184 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1185 * </FONT> | |
1186 * </BODY></HTML> | |
1187 * <BINARY> | |
1188 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1189 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1190 * </BINARY> | |
1191 */ | |
1192 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1193 GaimConnection *gc = sess->aux_data; | |
1194 GaimConvImFlags imflags = 0; | |
1195 gchar *utf8; | |
1196 GString *newmsg = g_string_new(""); | |
1197 GSList *images = NULL; | |
1198 va_list ap; | |
1199 const char *sn, *msg, *msgend, *binary; | |
1200 size_t len; | |
1201 int encoding, isawaymsg; | |
1202 | |
1203 va_start(ap, fr); | |
1204 sn = va_arg(ap, const char *); | |
1205 msg = va_arg(ap, const char *); | |
1206 len = va_arg(ap, size_t); | |
1207 encoding = va_arg(ap, int); | |
1208 isawaymsg = va_arg(ap, int); | |
1209 va_end(ap); | |
1210 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1211 |
8660 | 1212 gaim_debug_info("oscar", |
8971 | 1213 "Got DirectIM message from %s\n", sn); |
1214 | |
1215 if (isawaymsg) | |
1216 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1217 | |
1218 /* message has a binary trailer */ | |
1219 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1220 GData *attribs; | |
1221 const char *tmp, *start, *end, *last = NULL; | |
1222 | |
1223 tmp = msg; | |
1224 | |
1225 /* for each valid image tag... */ | |
1226 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1227 const char *id, *src, *datasize; | |
1228 const char *tag = NULL, *data = NULL; | |
1229 size_t size; | |
1230 int imgid = 0; | |
1231 | |
1232 /* update the location of the last img tag */ | |
1233 last = end; | |
1234 | |
1235 /* grab attributes */ | |
1236 id = g_datalist_get_data(&attribs, "id"); | |
1237 src = g_datalist_get_data(&attribs, "src"); | |
1238 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1239 | |
1240 /* if we have id & datasize, build the data tag */ | |
1241 if (id && datasize) | |
1242 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1243 | |
1244 /* if we have a tag, find the start of the data */ | |
1245 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1246 data += strlen(tag); | |
1247 | |
1248 /* check the data is here and store it */ | |
1249 if (data + (size = atoi(datasize)) <= msgend) | |
1250 imgid = gaim_imgstore_add(data, size, src); | |
1251 | |
1252 /* | |
1253 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1254 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1255 */ | |
1256 /* if we have a stored image... */ | |
1257 if (imgid) { | |
1258 /* append the message up to the tag */ | |
1259 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1260 if (utf8 != NULL) { | |
1261 newmsg = g_string_append(newmsg, utf8); | |
1262 g_free(utf8); | |
1263 } | |
1264 | |
1265 /* write the new image tag */ | |
1266 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1267 | |
1268 /* and record the image number */ | |
1269 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1270 } else { | |
1271 /* otherwise, copy up to the end of the tag */ | |
1272 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1273 if (utf8 != NULL) { | |
1274 newmsg = g_string_append(newmsg, utf8); | |
1275 g_free(utf8); | |
1276 } | |
1277 } | |
1278 | |
1279 /* clear the attribute list */ | |
1280 g_datalist_clear(&attribs); | |
1281 | |
1282 /* continue from the end of the tag */ | |
1283 tmp = end + 1; | |
1284 } | |
1285 | |
1286 /* append any remaining message data (without the > :-) */ | |
1287 if (last++ && (last < binary)) | |
1288 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1289 | |
1290 /* set the flag if we caught any images */ | |
1291 if (images) | |
1292 imflags |= GAIM_CONV_IM_IMAGES; | |
1293 } else { | |
1294 g_string_append_len(newmsg, msg, len); | |
1295 } | |
1296 | |
1297 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1298 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1299 | |
1300 /* free up the message */ | |
1301 g_string_free(newmsg, TRUE); | |
1302 | |
1303 /* unref any images we allocated */ | |
1304 if (images) { | |
1305 GSList *tmp; | |
1306 int id; | |
1307 | |
1308 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1309 id = GPOINTER_TO_INT(tmp->data); | |
1310 gaim_imgstore_unref(id); | |
1311 } | |
1312 | |
1313 g_slist_free(images); | |
1314 } | |
1315 | |
1316 return 1; | |
1317 } | |
1318 | |
1319 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1320 va_list ap; | |
1321 char *sn; | |
1322 int typing; | |
1323 GaimConnection *gc = sess->aux_data; | |
1324 | |
1325 va_start(ap, fr); | |
1326 sn = va_arg(ap, char *); | |
1327 typing = va_arg(ap, int); | |
1328 va_end(ap); | |
1329 | |
1330 if (typing == 0x0002) { | |
1331 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1332 gaim_debug_info("oscar", | |
1333 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1334 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1335 } else if (typing == 0x0001) | |
1336 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1337 else | |
1338 serv_got_typing_stopped(gc, sn); | |
1339 return 1; | |
1340 } | |
1341 | |
1342 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1343 char *buf; | |
1344 size_t len; | |
1345 int ret; | |
1346 GString *msg = g_string_new("<HTML><BODY>"); | |
1347 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1348 GData *attribs; | |
1349 const char *start, *end, *last; | |
1350 int oscar_id = 0; | |
1351 | |
1352 last = message; | |
1353 | |
1354 /* for each valid IMG tag... */ | |
1355 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1356 GaimStoredImage *image = NULL; | |
1357 const char *id; | |
1358 | |
1359 if (start - last) { | |
1360 g_string_append_len(msg, last, start - last); | |
1361 } | |
1362 | |
1363 id = g_datalist_get_data(&attribs, "id"); | |
1364 | |
1365 /* ... if it refers to a valid gaim image ... */ | |
1366 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1367 /* ... append the message from start to the tag ... */ | |
9126 | 1368 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1369 const char *filename = gaim_imgstore_get_filename(image); |
1370 gpointer imgdata = gaim_imgstore_get_data(image); | |
1371 | |
1372 oscar_id++; | |
1373 | |
1374 /* ... insert a new img tag with the oscar id ... */ | |
1375 if (filename) | |
1376 g_string_append_printf(msg, | |
9126 | 1377 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1378 filename, oscar_id, size); |
1379 else | |
1380 g_string_append_printf(msg, | |
9126 | 1381 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1382 oscar_id, size); |
1383 | |
1384 /* ... and append the data to the binary section ... */ | |
9126 | 1385 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1386 oscar_id, size); |
1387 data = g_string_append_len(data, imgdata, size); | |
1388 data = g_string_append(data, "</DATA>"); | |
1389 } | |
1390 /* If the tag is invalid, skip it, thus no else here */ | |
1391 | |
1392 g_datalist_clear(&attribs); | |
1393 | |
1394 /* continue from the end of the tag */ | |
1395 last = end + 1; | |
1396 } | |
1397 | |
1398 /* append any remaining message data (without the > :-) */ | |
1399 if (last && *last) | |
1400 msg = g_string_append(msg, last); | |
1401 | |
1402 /* if we inserted any images in the binary section, append it */ | |
1403 if (oscar_id) { | |
1404 msg = g_string_append_len(msg, data->str, data->len); | |
1405 msg = g_string_append(msg, "</BINARY>"); | |
1406 } | |
1407 | |
1408 len = msg->len; | |
1409 buf = msg->str; | |
1410 g_string_free(msg, FALSE); | |
1411 g_string_free(data, TRUE); | |
1412 | |
1413 | |
1414 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1415 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1416 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1417 else | |
1418 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1419 | |
1420 g_free(buf); | |
1421 | |
1422 return ret; | |
1423 } | |
1424 | |
1425 struct ask_do_dir_im { | |
1426 char *who; | |
1427 GaimConnection *gc; | |
1428 }; | |
1429 | |
1430 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1431 g_free(data->who); | |
1432 g_free(data); | |
1433 } | |
1434 | |
8983 | 1435 /* this function is used to initiate a direct im session with someone. |
1436 * we start listening on a port and send a request. they either connect | |
1437 * or send some kind of reply. If they can't connect, they ask us to | |
1438 * connect to them, and so we do that. | |
1439 * | |
1440 * this function will also get called if the other side initiate's a direct | |
1441 * im and we try to connect and fail. in that case cookie will not be null. | |
1442 * | |
1443 * note that cookie is an 8 byte string that isn't NULL terminated | |
1444 */ | |
1445 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1446 OscarData *od; |
1447 struct oscar_direct_im *dim; | |
1448 int listenfd; | |
8982 | 1449 const char *ip; |
8971 | 1450 |
1451 od = (OscarData *)gc->proto_data; | |
1452 | |
8983 | 1453 dim = oscar_direct_im_find(od, who); |
8971 | 1454 if (dim) { |
1455 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1456 oscar_direct_im_disconnect(od, dim); | |
1457 gaim_debug_info("oscar", | |
1458 "Gave up on old direct IM, trying again\n"); | |
1459 } else { | |
1460 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1461 return; |
8971 | 1462 } |
1463 } | |
1464 dim = g_new0(struct oscar_direct_im, 1); | |
1465 dim->gc = gc; | |
8983 | 1466 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1467 |
1468 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1469 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1470 if (listenfd >= 0) |
1471 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1472 if (dim->conn != NULL) { |
8982 | 1473 char *tmp; |
1474 GaimConversation *conv; | |
1475 | |
8971 | 1476 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1477 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1478 oscar_callback, dim->conn); | |
1479 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1480 gaim_odc_initiate, 0); | |
8982 | 1481 |
8983 | 1482 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1483 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1484 gaim_network_get_port_from_fd(listenfd)); |
1485 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1486 g_free(tmp); | |
8971 | 1487 } else { |
1488 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1489 oscar_direct_im_destroy(od, dim); | |
1490 } | |
8983 | 1491 } |
1492 | |
1493 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1494 GaimConnection *gc = data->gc; | |
1495 | |
1496 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1497 g_free(data->who); | |
1498 g_free(data); | |
1499 return; | |
1500 } | |
1501 | |
1502 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1503 g_free(data->who); |
1504 g_free(data); | |
1505 } | |
1506 | |
1507 /* this is the right click menu cb thingy */ | |
9030 | 1508 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1509 | |
1510 GaimBuddy *buddy; | |
1511 GaimConnection *gc; | |
8971 | 1512 gchar *buf; |
9030 | 1513 struct ask_do_dir_im *data; |
1514 | |
1515 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1516 | |
1517 buddy = (GaimBuddy *) node; | |
1518 gc = gaim_account_get_connection(buddy->account); | |
1519 | |
1520 data = g_new0(struct ask_do_dir_im, 1); | |
1521 data->who = g_strdup(buddy->name); | |
8971 | 1522 data->gc = gc; |
9030 | 1523 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1524 buddy->name); | |
8971 | 1525 |
1526 gaim_request_action(gc, NULL, buf, | |
9030 | 1527 _("Because this reveals your IP address, it " |
1528 "may be considered a privacy risk. Do you " | |
1529 "wish to continue?"), | |
1530 0, data, 2, | |
1531 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1532 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1533 g_free(buf); |
1534 } | |
1535 | |
1536 /***************************************************************************** | |
1537 * End scary direct im stuff | |
1538 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1539 |
4617 | 1540 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1541 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1542 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1543 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1544 OscarData *od; |
2086 | 1545 |
1546 if (!gc) { | |
8660 | 1547 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1548 "oscar callback for closed connection (1).\n"); |
2086 | 1549 return; |
1550 } | |
1551 | |
7283 | 1552 od = (OscarData *)gc->proto_data; |
2086 | 1553 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1554 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1555 /* oh boy. this is probably bad. i guess the only thing we |
1556 * can really do is return? */ | |
8660 | 1557 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1558 "oscar callback for closed connection (2).\n"); |
8660 | 1559 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1560 return; |
1561 } | |
1562 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1563 if (condition & GAIM_INPUT_READ) { |
4617 | 1564 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1565 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1566 "got information on rendezvous listener\n"); |
4617 | 1567 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1568 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1569 "connection error (rendezvous listener)\n"); |
4617 | 1570 aim_conn_kill(od->sess, &conn); |
8446 | 1571 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1572 } |
1573 } else { | |
4617 | 1574 if (aim_get_command(od->sess, conn) >= 0) { |
1575 aim_rxdispatch(od->sess); | |
6029 | 1576 if (od->killme) { |
8660 | 1577 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1578 return; |
1579 } | |
2086 | 1580 } else { |
1581 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1582 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1583 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1584 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1585 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1586 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1587 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1588 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1589 char *buf; |
8660 | 1590 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1591 "disconnected from chat room %s\n", c->name); |
2086 | 1592 c->conn = NULL; |
1593 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1594 gaim_input_remove(c->inpa); |
2086 | 1595 c->inpa = 0; |
1596 c->fd = -1; | |
4617 | 1597 aim_conn_kill(od->sess, &conn); |
5420 | 1598 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1599 if (conv) |
1600 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1601 else | |
1602 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1603 g_free(buf); |
2086 | 1604 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1605 if (od->cnpa > 0) |
1606 gaim_input_remove(od->cnpa); | |
1607 od->cnpa = 0; | |
8660 | 1608 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1609 "removing chatnav input watcher\n"); |
4617 | 1610 while (od->create_rooms) { |
1611 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1612 g_free(cr->name); |
4617 | 1613 od->create_rooms = |
1614 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1615 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1616 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1617 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1618 NULL); |
2086 | 1619 } |
4617 | 1620 aim_conn_kill(od->sess, &conn); |
2086 | 1621 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1622 if (od->paspa > 0) |
1623 gaim_input_remove(od->paspa); | |
1624 od->paspa = 0; | |
8660 | 1625 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1626 "removing authconn input watcher\n"); |
4617 | 1627 aim_conn_kill(od->sess, &conn); |
3694 | 1628 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1629 if (od->emlpa > 0) |
1630 gaim_input_remove(od->emlpa); | |
1631 od->emlpa = 0; | |
8660 | 1632 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1633 "removing email input watcher\n"); |
4617 | 1634 aim_conn_kill(od->sess, &conn); |
4804 | 1635 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1636 if (od->icopa > 0) | |
1637 gaim_input_remove(od->icopa); | |
1638 od->icopa = 0; | |
8660 | 1639 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1640 "removing icon input watcher\n"); |
4804 | 1641 aim_conn_kill(od->sess, &conn); |
2086 | 1642 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1643 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1644 gaim_odc_disconnect(od->sess, conn); |
1645 aim_conn_kill(od->sess, &conn); | |
2086 | 1646 } else { |
8660 | 1647 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1648 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1649 conn->type); |
4617 | 1650 aim_conn_kill(od->sess, &conn); |
2086 | 1651 } |
1652 } | |
1653 } | |
1654 } | |
1655 } | |
1656 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1657 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1658 GaimConnection *gc = sess->aux_data; |
7285 | 1659 gchar *s = g_strdup_vprintf(format, va); |
1660 gchar *buf; | |
1661 | |
1662 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1663 gaim_debug_info("oscar", buf); |
7285 | 1664 if (buf[strlen(buf)-1] != '\n') |
8660 | 1665 gaim_debug_info(NULL, "\n"); |
7285 | 1666 g_free(buf); |
2086 | 1667 g_free(s); |
1668 } | |
1669 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1670 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1671 { |
5575 | 1672 GaimConnection *gc = data; |
7283 | 1673 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1674 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1675 aim_conn_t *conn; |
2086 | 1676 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1677 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1678 close(source); |
1679 return; | |
1680 } | |
1681 | |
4617 | 1682 od = gc->proto_data; |
1683 sess = od->sess; | |
2086 | 1684 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1685 conn->fd = source; |
2086 | 1686 |
1687 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1688 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1689 return; |
1690 } | |
1691 | |
1692 aim_conn_completeconnect(sess, conn); | |
4617 | 1693 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1694 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1695 | |
8660 | 1696 gaim_debug_info("oscar", |
7282 | 1697 "Screen name sent, waiting for response\n"); |
7283 | 1698 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1699 ck[1] = 0x65; |
2086 | 1700 } |
1701 | |
5575 | 1702 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1703 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1704 aim_conn_t *conn; |
5575 | 1705 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1706 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1707 |
8660 | 1708 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1709 |
8437 | 1710 if (!aim_snvalid(gaim_account_get_username(account))) { |
1711 gchar *buf; | |
8590 | 1712 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 | 1713 gaim_connection_error(gc, buf); |
1714 g_free(buf); | |
1715 } | |
1716 | |
9975 | 1717 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1718 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1719 } else { |
6622 | 1720 gc->flags |= GAIM_CONNECTION_HTML; |
1721 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1722 } |
5836 | 1723 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1724 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1725 sess = g_new0(aim_session_t, 1); |
7285 | 1726 aim_session_init(sess, TRUE, 0); |
2086 | 1727 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1728 /* |
1729 * We need an immediate queue because we don't use a while-loop | |
1730 * to see if things need to be sent. | |
1731 */ | |
2086 | 1732 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1733 od->sess = sess; |
2086 | 1734 sess->aux_data = gc; |
1735 | |
9935 | 1736 /* Connect to core Gaim signals */ |
10087 | 1737 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1738 |
2086 | 1739 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1740 if (conn == NULL) { | |
8660 | 1741 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1742 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1743 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1744 return; |
1745 } | |
1746 | |
4649 | 1747 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1748 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1749 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1750 | |
1751 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1752 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1753 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1754 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1755 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1756 return; |
1757 } | |
7282 | 1758 |
7283 | 1759 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1760 ck[0] = 0x5a; |
5575 | 1761 } |
1762 | |
1763 static void oscar_close(GaimConnection *gc) { | |
7283 | 1764 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1765 |
1766 while (od->oscar_chats) { | |
1767 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1768 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1769 gaim_input_remove(n->inpa); |
2086 | 1770 g_free(n->name); |
1771 g_free(n->show); | |
4617 | 1772 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1773 g_free(n); |
1774 } | |
4617 | 1775 while (od->direct_ims) { |
8971 | 1776 struct oscar_direct_im *n = od->direct_ims->data; |
1777 oscar_direct_im_destroy(od, n); | |
2086 | 1778 } |
4617 | 1779 /* BBB */ |
1780 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1781 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1782 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1783 gaim_xfer_cancel_local(xfer); |
3630 | 1784 } |
4804 | 1785 while (od->requesticon) { |
1786 char *sn = od->requesticon->data; | |
1787 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1788 free(sn); | |
1789 } | |
4738 | 1790 g_hash_table_destroy(od->buddyinfo); |
4617 | 1791 while (od->create_rooms) { |
1792 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1793 g_free(cr->name); |
4617 | 1794 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1795 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1796 } |
4617 | 1797 if (od->email) |
1798 g_free(od->email); | |
1799 if (od->newp) | |
1800 g_free(od->newp); | |
1801 if (od->oldp) | |
1802 g_free(od->oldp); | |
2086 | 1803 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1804 gaim_input_remove(gc->inpa); |
4617 | 1805 if (od->cnpa > 0) |
1806 gaim_input_remove(od->cnpa); | |
1807 if (od->paspa > 0) | |
1808 gaim_input_remove(od->paspa); | |
1809 if (od->emlpa > 0) | |
1810 gaim_input_remove(od->emlpa); | |
4804 | 1811 if (od->icopa > 0) |
1812 gaim_input_remove(od->icopa); | |
6907 | 1813 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1814 gaim_timeout_remove(od->icontimer); |
8341 | 1815 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1816 gaim_timeout_remove(od->getblisttimer); |
8341 | 1817 if (od->getinfotimer > 0) |
1818 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1819 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1820 |
4617 | 1821 aim_session_kill(od->sess); |
1822 g_free(od->sess); | |
1823 od->sess = NULL; | |
2086 | 1824 g_free(gc->proto_data); |
1825 gc->proto_data = NULL; | |
8660 | 1826 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1827 } |
1828 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1829 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1830 GaimConnection *gc = data; |
7283 | 1831 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1832 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1833 aim_conn_t *bosconn; |
2086 | 1834 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1835 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1836 close(source); |
1837 return; | |
1838 } | |
1839 | |
4617 | 1840 od = gc->proto_data; |
1841 sess = od->sess; | |
1842 bosconn = od->conn; | |
4366 | 1843 bosconn->fd = source; |
2086 | 1844 |
1845 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1846 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1847 return; |
1848 } | |
1849 | |
1850 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1851 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1852 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1853 gaim_connection_update_progress(gc, |
7283 | 1854 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1855 ck[4] = 0x61; |
2086 | 1856 } |
1857 | |
4617 | 1858 /* BBB */ |
4656 | 1859 /* |
1860 * This little area in oscar.c is the nexus of file transfer code, | |
1861 * so I wrote a little explanation of what happens. I am such a | |
1862 * ninja. | |
1863 * | |
1864 * The series of events for a file send is: | |
1865 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
1866 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1867 * listening socket, then asks the remote user to connect to us (and |
1868 * gives them the file name, port, IP, etc.) | |
1869 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1870 * in oscar_sendfile_estblsh) | |
1871 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1872 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1873 * connection. | |
1874 * -We get drunk because file transfer kicks ass. | |
1875 * | |
1876 * The series of events for a file receive is: | |
1877 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1878 * -Gaim user selects file to name and location to save file to and | |
1879 * oscar_xfer_init is called | |
1880 * -It connects to the remote user using the IP they gave us earlier | |
1881 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1882 * them an AIM_CB_OFT_ACK. | |
1883 * -They begin to send us lots of raw data. | |
1884 * -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
|
1885 * the connection. |
4656 | 1886 */ |
1887 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1888 | |
8446 | 1889 /* |
1890 * Miscellaneous xfer functions | |
1891 */ | |
1892 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1893 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1894 GaimXfer *xfer; |
5146 | 1895 struct aim_oft_info *oft_info; |
4656 | 1896 |
1897 while (fts) { | |
1898 xfer = fts->data; | |
5146 | 1899 oft_info = xfer->data; |
1900 | |
8446 | 1901 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1902 return xfer; |
1903 | |
1904 fts = g_slist_next(fts); | |
1905 } | |
1906 | |
1907 return NULL; | |
1908 } | |
1909 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1910 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1911 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1912 GaimXfer *xfer; |
5146 | 1913 struct aim_oft_info *oft_info; |
4656 | 1914 |
1915 while (fts) { | |
1916 xfer = fts->data; | |
5146 | 1917 oft_info = xfer->data; |
1918 | |
1919 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1920 return xfer; |
1921 | |
1922 fts = g_slist_next(fts); | |
1923 } | |
1924 | |
1925 return NULL; | |
1926 } | |
1927 | |
8446 | 1928 static void oscar_xfer_end(GaimXfer *xfer) |
1929 { | |
1930 struct aim_oft_info *oft_info = xfer->data; | |
1931 GaimConnection *gc = oft_info->sess->aux_data; | |
1932 OscarData *od = gc->proto_data; | |
1933 | |
8660 | 1934 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1935 |
1936 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1937 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1938 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1939 } | |
1940 | |
1941 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1942 aim_oft_destroyinfo(oft_info); | |
1943 xfer->data = NULL; | |
1944 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1945 } | |
1946 | |
1947 /* | |
1948 * xfer functions used when receiving files | |
1949 */ | |
1950 | |
1951 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1952 { | |
1953 struct aim_oft_info *oft_info = xfer->data; | |
1954 GaimConnection *gc = oft_info->sess->aux_data; | |
1955 OscarData *od = gc->proto_data; | |
1956 | |
8660 | 1957 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1958 |
1959 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1960 if (oft_info->conn) { | |
1961 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1962 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1963 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1964 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1965 if (xfer->fd == -1) { | |
1966 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1967 _("Unable to establish file descriptor.")); | |
1968 gaim_xfer_cancel_local(xfer); | |
1969 } | |
1970 } else { | |
1971 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1972 _("Unable to create new connection.")); | |
1973 gaim_xfer_cancel_local(xfer); | |
1974 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1975 } | |
1976 | |
1977 } | |
1978 | |
1979 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1980 { | |
1981 struct aim_oft_info *oft_info = xfer->data; | |
1982 GaimConnection *gc = oft_info->sess->aux_data; | |
1983 OscarData *od = gc->proto_data; | |
1984 | |
8660 | 1985 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1986 |
9771 | 1987 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1988 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1989 |
1990 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1991 aim_oft_destroyinfo(oft_info); | |
1992 xfer->data = NULL; | |
1993 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1994 } | |
1995 | |
1996 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1997 { | |
1998 struct aim_oft_info *oft_info = xfer->data; | |
1999 | |
2000 /* Update our rolling checksum. Like Walmart, yo. */ | |
2001 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2002 } | |
2003 | |
2004 /* | |
2005 * xfer functions used when sending files | |
2006 */ | |
2007 | |
2008 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2009 { | |
2010 struct aim_oft_info *oft_info = xfer->data; | |
2011 GaimConnection *gc = oft_info->sess->aux_data; | |
2012 OscarData *od = gc->proto_data; | |
2013 int listenfd; | |
2014 | |
8660 | 2015 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2016 |
2017 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2018 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2019 oft_info->fh.name[63] = '\0'; | |
2020 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2021 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2022 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2023 | |
2024 /* Create a listening socket and an associated libfaim conn */ | |
2025 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2026 gaim_xfer_cancel_local(xfer); | |
2027 return; | |
2028 } | |
2029 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2030 oft_info->port = xfer->local_port; | |
2031 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2032 gaim_xfer_cancel_local(xfer); | |
2033 return; | |
2034 } | |
8660 | 2035 gaim_debug_misc("oscar", |
8446 | 2036 "port is %hu, ip is %s\n", |
2037 xfer->local_port, oft_info->clientip); | |
2038 if (oft_info->conn) { | |
2039 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2040 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2041 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2042 } else { | |
2043 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2044 _("Unable to establish listener socket.")); | |
2045 gaim_xfer_cancel_local(xfer); | |
2046 } | |
2047 } | |
2048 | |
2049 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2050 { | |
2051 struct aim_oft_info *oft_info = xfer->data; | |
2052 GaimConnection *gc = oft_info->sess->aux_data; | |
2053 OscarData *od = gc->proto_data; | |
2054 | |
8660 | 2055 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2056 |
9771 | 2057 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2058 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2059 |
2060 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2061 aim_oft_destroyinfo(oft_info); | |
2062 xfer->data = NULL; | |
2063 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2064 } | |
2065 | |
2066 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2067 { | |
2068 struct aim_oft_info *oft_info = xfer->data; | |
2069 | |
2070 /* I'm not sure I like how we do this. --marv | |
2071 * I do. AIM file transfers aren't really meant to be thought | |
2072 * of as a transferring just a single file. The rendezvous | |
2073 * establishes a connection between two computers, and then | |
2074 * those computers can use the same connection for transferring | |
2075 * multiple files. So we don't want the Gaim core up and closing | |
2076 * the socket all willy-nilly. We want to do that in the oscar | |
2077 * prpl, whenever one side or the other says they're finished | |
2078 * using the connection. There might be a better way to intercept | |
2079 * the socket from the core, however... --KingAnt | |
2080 */ | |
2081 | |
2082 /* | |
2083 * If we're done sending, intercept the socket from the core ft code | |
2084 * and wait for the other guy to send the "done" OFT packet. | |
2085 */ | |
2086 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2087 gaim_input_remove(xfer->watcher); | |
2088 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2089 xfer->fd = 0; | |
2090 gaim_xfer_set_completed(xfer, TRUE); | |
2091 } | |
2092 } | |
2093 | |
9466 | 2094 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2095 gboolean can_receive = FALSE; | |
2096 OscarData *od = gc->proto_data; | |
2097 | |
2098 if (!od->icq) { | |
2099 aim_userinfo_t *userinfo; | |
2100 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2101 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2102 can_receive = TRUE; | |
2103 } | |
2104 | |
2105 return can_receive; | |
2106 } | |
2107 | |
2108 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2109 |
2110 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2111 GaimXfer *xfer; |
5146 | 2112 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2113 const char *ip; |
3752 | 2114 |
9030 | 2115 od = (OscarData *)gc->proto_data; |
2116 | |
4617 | 2117 /* You want to send a file to someone else, you're so generous */ |
2118 | |
2119 /* Build the file transfer handle */ | |
9466 | 2120 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2121 |
5146 | 2122 /* Create the oscar-specific data */ |
8838 | 2123 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2124 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2125 xfer->data = oft_info; |
2126 | |
4617 | 2127 /* Setup our I/O op functions */ |
8446 | 2128 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2129 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2130 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2131 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2132 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2133 |
2134 /* Keep track of this transfer for later */ | |
2135 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2136 | |
2137 /* Now perform the request */ | |
9466 | 2138 if (file) |
2139 gaim_xfer_request_accepted(xfer, file); | |
2140 else | |
2141 gaim_xfer_request(xfer); | |
3630 | 2142 } |
2143 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2144 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2145 GaimConnection *gc = sess->aux_data; |
7283 | 2146 OscarData *od = gc->proto_data; |
6029 | 2147 GaimAccount *account = gc->account; |
2148 aim_conn_t *bosconn; | |
2149 char *host; int port; | |
2150 int i, rc; | |
2086 | 2151 va_list ap; |
2704 | 2152 struct aim_authresp_info *info; |
6029 | 2153 |
5575 | 2154 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2155 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2156 va_start(ap, fr); |
2704 | 2157 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2158 va_end(ap); |
2159 | |
8660 | 2160 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2161 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2162 |
4293 | 2163 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2164 char buf[256]; |
2704 | 2165 switch (info->errorcode) { |
2086 | 2166 case 0x05: |
2167 /* Incorrect nick/password */ | |
6498 | 2168 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2169 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2170 break; |
2171 case 0x11: | |
2172 /* Suspended account */ | |
6498 | 2173 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2174 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2175 break; |
3498 | 2176 case 0x14: |
2177 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2178 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2179 break; |
2086 | 2180 case 0x18: |
2181 /* connecting too frequently */ | |
6498 | 2182 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2183 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 | 2184 break; |
2185 case 0x1c: | |
2186 /* client too old */ | |
6498 | 2187 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2188 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
|
2189 gaim_connection_error(gc, buf); |
2086 | 2190 break; |
2191 default: | |
6623 | 2192 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2193 break; |
2194 } | |
8660 | 2195 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2196 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2197 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2198 "Error URL: %s\n", info->errorurl); |
2086 | 2199 od->killme = TRUE; |
2200 return 1; | |
2201 } | |
2202 | |
2203 | |
9992 | 2204 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2205 |
2704 | 2206 if (info->email) { |
8660 | 2207 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2208 } else { |
8660 | 2209 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2210 } |
10042 | 2211 |
8660 | 2212 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2213 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2214 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2215 aim_conn_kill(sess, &fr->conn); |
2086 | 2216 |
2217 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2218 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2219 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2220 od->killme = TRUE; |
2221 return 0; | |
2222 } | |
2223 | |
4649 | 2224 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2225 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2226 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2227 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2228 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2229 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2230 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2231 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2232 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2234 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2235 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2237 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2239 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2240 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2241 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2242 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2243 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2244 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2245 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2246 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
|
2247 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2248 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2249 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2250 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2251 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2252 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2253 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
|
2254 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
|
2255 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
|
2256 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2257 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2258 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2259 #ifndef NOSSI |
4642 | 2260 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2261 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2262 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2263 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2264 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2265 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2266 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2267 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2268 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2269 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2270 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2271 |
7283 | 2272 od->conn = bosconn; |
2704 | 2273 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2274 if (info->bosip[i] == ':') { | |
2275 port = atoi(&(info->bosip[i+1])); | |
2086 | 2276 break; |
2277 } | |
2278 } | |
2704 | 2279 host = g_strndup(info->bosip, i); |
2086 | 2280 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2281 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2282 g_free(host); |
4366 | 2283 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2284 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2285 od->killme = TRUE; |
2286 return 0; | |
2287 } | |
4293 | 2288 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2289 gaim_input_remove(gc->inpa); |
2704 | 2290 |
7283 | 2291 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2292 ck[3] = 0x64; |
7282 | 2293 |
2086 | 2294 return 1; |
2295 } | |
2296 | |
7285 | 2297 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2298 struct pieceofcrap { |
5575 | 2299 GaimConnection *gc; |
2086 | 2300 unsigned long offset; |
2301 unsigned long len; | |
2302 char *modname; | |
2303 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2304 aim_conn_t *conn; |
2086 | 2305 unsigned int inpa; |
2306 }; | |
2307 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2308 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2309 { |
2310 struct pieceofcrap *pos = data; | |
7283 | 2311 OscarData *od = pos->gc->proto_data; |
2086 | 2312 char in = '\0'; |
2313 int x = 0; | |
2314 unsigned char m[17]; | |
2315 | |
2316 while (read(pos->fd, &in, 1) == 1) { | |
2317 if (in == '\n') | |
2318 x++; | |
2319 else if (in != '\r') | |
2320 x = 0; | |
2321 if (x == 2) | |
2322 break; | |
2323 in = '\0'; | |
2324 } | |
2325 if (in != '\n') { | |
4056 | 2326 char buf[256]; |
2327 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
|
2328 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2329 gaim_notify_warning(pos->gc, NULL, |
7422 | 2330 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2331 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2332 gaim_input_remove(pos->inpa); |
2086 | 2333 close(pos->fd); |
2334 g_free(pos); | |
2335 return; | |
2336 } | |
2337 read(pos->fd, m, 16); | |
2338 m[16] = '\0'; | |
8660 | 2339 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2340 for (x = 0; x < 16; x++) |
8660 | 2341 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2342 | |
2343 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2344 gaim_input_remove(pos->inpa); |
2086 | 2345 close(pos->fd); |
2346 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2347 g_free(pos); | |
2348 } | |
2349 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2350 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2351 struct pieceofcrap *pos = data; |
5420 | 2352 gchar *buf; |
2086 | 2353 |
4366 | 2354 pos->fd = source; |
2355 | |
2086 | 2356 if (source < 0) { |
5420 | 2357 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
|
2358 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2359 gaim_notify_warning(pos->gc, NULL, |
7422 | 2360 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2361 buf); |
5420 | 2362 g_free(buf); |
2086 | 2363 if (pos->modname) |
2364 g_free(pos->modname); | |
2365 g_free(pos); | |
2366 return; | |
2367 } | |
2368 | |
5420 | 2369 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2370 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2371 write(pos->fd, buf, strlen(buf)); | |
5420 | 2372 g_free(buf); |
2086 | 2373 if (pos->modname) |
2374 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2375 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2376 return; |
2377 } | |
2378 | |
2379 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2380 #define AIM_MAX_FILE_SIZE 98304 | |
2381 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2382 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2383 va_list ap; |
2384 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2385 fu32_t offset, len; |
2086 | 2386 char *modname; |
2387 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2388 va_start(ap, fr); |
4200 | 2389 offset = va_arg(ap, fu32_t); |
2390 len = va_arg(ap, fu32_t); | |
2086 | 2391 modname = va_arg(ap, char *); |
2392 va_end(ap); | |
2393 | |
8660 | 2394 gaim_debug_misc("oscar", |
5556 | 2395 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2396 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2397 |
2086 | 2398 if (len == 0) { |
8660 | 2399 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2400 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2401 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2402 return 1; | |
2403 } | |
9625 | 2404 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2405 #if 0 | |
2086 | 2406 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2407 char *buf; | |
2408 int i = 8; | |
2409 if (modname) | |
2410 i += strlen(modname); | |
2411 buf = g_malloc(i); | |
2412 i = 0; | |
2413 if (modname) { | |
2414 memcpy(buf, modname, strlen(modname)); | |
2415 i += strlen(modname); | |
2416 } | |
2417 buf[i++] = offset & 0xff; | |
2418 buf[i++] = (offset >> 8) & 0xff; | |
2419 buf[i++] = (offset >> 16) & 0xff; | |
2420 buf[i++] = (offset >> 24) & 0xff; | |
2421 buf[i++] = len & 0xff; | |
2422 buf[i++] = (len >> 8) & 0xff; | |
2423 buf[i++] = (len >> 16) & 0xff; | |
2424 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2425 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2426 "hashing request\n"); |
2086 | 2427 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2428 g_free(buf); | |
2429 return 1; | |
2430 } | |
9625 | 2431 #endif |
2086 | 2432 |
2433 pos = g_new0(struct pieceofcrap, 1); | |
2434 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2435 pos->conn = fr->conn; |
2086 | 2436 |
2437 pos->offset = offset; | |
2438 pos->len = len; | |
2439 pos->modname = modname ? g_strdup(modname) : NULL; | |
2440 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2441 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2442 char buf[256]; |
2086 | 2443 if (pos->modname) |
2444 g_free(pos->modname); | |
2445 g_free(pos); | |
4056 | 2446 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
|
2447 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2448 gaim_notify_warning(pos->gc, NULL, |
7422 | 2449 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2450 buf); |
2086 | 2451 } |
2452 | |
2453 return 1; | |
2454 } | |
2455 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2456 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2457 GaimConnection *gc = sess->aux_data; |
7283 | 2458 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2459 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2460 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2461 #if 0 |
2462 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2463 #endif | |
7011 | 2464 va_list ap; |
2465 char *key; | |
2086 | 2466 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2467 va_start(ap, fr); |
2086 | 2468 key = va_arg(ap, char *); |
2469 va_end(ap); | |
2470 | |
4617 | 2471 if (od->icq) { |
3458 | 2472 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2473 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2474 gaim_account_get_password(account), &info, key); |
3458 | 2475 } else { |
2476 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2477 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2478 gaim_account_get_password(account), &info, key); |
3458 | 2479 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2480 |
7283 | 2481 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2482 ck[2] = 0x6c; |
7282 | 2483 |
2086 | 2484 return 1; |
2485 } | |
2486 | |
2675 | 2487 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2488 GaimConnection *gc = sess->aux_data; |
2647 | 2489 struct chat_connection *chatcon; |
2490 static int id = 1; | |
2491 | |
6905 | 2492 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
|
2493 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
|
2494 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
|
2495 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
|
2496 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2497 |
2672 | 2498 aim_clientready(sess, fr->conn); |
2675 | 2499 |
2647 | 2500 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2501 chatcon->id = id; | |
8733 | 2502 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2503 |
2504 return 1; | |
2505 } | |
2506 | |
2675 | 2507 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2508 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2509 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2510 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2511 |
2512 aim_clientready(sess, fr->conn); | |
2513 | |
2514 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2515 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2516 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2517 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2518 |
3694 | 2519 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2520 | |
2521 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2522 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2523 | |
7282 | 2524 aim_email_sendcookies(sess); |
2525 aim_email_activate(sess); | |
3694 | 2526 aim_clientready(sess, fr->conn); |
2527 | |
2528 return 1; | |
2529 } | |
2530 | |
4804 | 2531 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2532 GaimConnection *gc = sess->aux_data; |
7283 | 2533 OscarData *od = gc->proto_data; |
4804 | 2534 |
2535 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2536 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2537 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2538 | |
2539 aim_clientready(sess, fr->conn); | |
2540 | |
4823 | 2541 od->iconconnecting = FALSE; |
2542 | |
4804 | 2543 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2544 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2545 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2546 |
2547 return 1; | |
2548 } | |
2549 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2550 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2551 GaimConnection *gc = data; |
7283 | 2552 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2553 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2554 aim_conn_t *tstconn; |
2086 | 2555 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2556 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2557 close(source); |
2558 return; | |
2559 } | |
2560 | |
4617 | 2561 od = gc->proto_data; |
2562 sess = od->sess; | |
2086 | 2563 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2564 tstconn->fd = source; |
2086 | 2565 |
2566 if (source < 0) { | |
2567 aim_conn_kill(sess, &tstconn); | |
8660 | 2568 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2569 "unable to connect to chatnav server\n"); |
2086 | 2570 return; |
2571 } | |
2572 | |
2573 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2574 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2575 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2576 } |
2577 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2578 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2579 { |
5575 | 2580 GaimConnection *gc = data; |
7283 | 2581 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2582 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2583 aim_conn_t *tstconn; |
2086 | 2584 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2585 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2586 close(source); |
2587 return; | |
2588 } | |
2589 | |
4617 | 2590 od = gc->proto_data; |
2591 sess = od->sess; | |
2086 | 2592 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2593 tstconn->fd = source; |
2086 | 2594 |
2595 if (source < 0) { | |
2596 aim_conn_kill(sess, &tstconn); | |
8660 | 2597 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2598 "unable to connect to authorizer\n"); |
2086 | 2599 return; |
2600 } | |
2601 | |
2602 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2603 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2604 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2605 } |
2606 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2607 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2608 { |
2609 struct chat_connection *ccon = data; | |
5575 | 2610 GaimConnection *gc = ccon->gc; |
7283 | 2611 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2612 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2613 aim_conn_t *tstconn; |
2086 | 2614 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2615 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2616 close(source); |
2617 g_free(ccon->show); | |
2618 g_free(ccon->name); | |
2619 g_free(ccon); | |
2620 return; | |
2621 } | |
2622 | |
4617 | 2623 od = gc->proto_data; |
2624 sess = od->sess; | |
2086 | 2625 tstconn = ccon->conn; |
4366 | 2626 tstconn->fd = source; |
2086 | 2627 |
2628 if (source < 0) { | |
2629 aim_conn_kill(sess, &tstconn); | |
2630 g_free(ccon->show); | |
2631 g_free(ccon->name); | |
2632 g_free(ccon); | |
2633 return; | |
2634 } | |
2635 | |
2636 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2637 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2638 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2639 } |
2640 | |
3694 | 2641 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2642 GaimConnection *gc = data; |
7283 | 2643 OscarData *od; |
3694 | 2644 aim_session_t *sess; |
2645 aim_conn_t *tstconn; | |
2646 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2647 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2648 close(source); |
2649 return; | |
2650 } | |
2651 | |
4617 | 2652 od = gc->proto_data; |
2653 sess = od->sess; | |
3694 | 2654 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2655 tstconn->fd = source; |
3694 | 2656 |
2657 if (source < 0) { | |
2658 aim_conn_kill(sess, &tstconn); | |
8660 | 2659 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2660 "unable to connect to email server\n"); |
3694 | 2661 return; |
2662 } | |
2663 | |
2664 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2665 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2666 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2667 "email: connected\n"); |
3694 | 2668 } |
2669 | |
4804 | 2670 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2671 GaimConnection *gc = data; |
7283 | 2672 OscarData *od; |
4804 | 2673 aim_session_t *sess; |
2674 aim_conn_t *tstconn; | |
2675 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2676 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2677 close(source); |
2678 return; | |
2679 } | |
2680 | |
2681 od = gc->proto_data; | |
2682 sess = od->sess; | |
2683 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2684 tstconn->fd = source; | |
2685 | |
2686 if (source < 0) { | |
2687 aim_conn_kill(sess, &tstconn); | |
8660 | 2688 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2689 "unable to connect to icon server\n"); |
4804 | 2690 return; |
2691 } | |
2692 | |
2693 aim_conn_completeconnect(sess, tstconn); | |
2694 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2695 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2696 } |
2697 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2698 /* 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
|
2699 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2700 GaimConnection *gc = sess->aux_data; |
2701 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2702 aim_conn_t *tstconn; |
4452 | 2703 int i; |
2086 | 2704 char *host; |
2705 int port; | |
4821 | 2706 va_list ap; |
2707 struct aim_redirect_data *redir; | |
2086 | 2708 |
5575 | 2709 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2710 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2711 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2712 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2713 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2714 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2715 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2716 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2717 port = atoi(&(redir->ip[i+1])); |
2086 | 2718 break; |
2719 } | |
2720 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2721 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2722 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2723 switch(redir->group) { |
2086 | 2724 case 0x7: /* Authorizer */ |
8660 | 2725 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2726 "Reconnecting with authorizor...\n"); |
2086 | 2727 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2728 if (tstconn == NULL) { | |
8660 | 2729 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2730 "unable to reconnect with authorizer\n"); |
2086 | 2731 g_free(host); |
2732 return 1; | |
2733 } | |
4649 | 2734 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2735 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2736 |
2737 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2738 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2739 aim_conn_kill(sess, &tstconn); |
8660 | 2740 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2741 "unable to reconnect with authorizer\n"); |
2086 | 2742 g_free(host); |
2743 return 1; | |
2744 } | |
4293 | 2745 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2746 break; |
2747 | |
2086 | 2748 case 0xd: /* ChatNav */ |
2749 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2750 if (tstconn == NULL) { | |
8660 | 2751 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2752 "unable to connect to chatnav server\n"); |
2086 | 2753 g_free(host); |
2754 return 1; | |
2755 } | |
4649 | 2756 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2757 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2758 |
2759 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2760 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2761 aim_conn_kill(sess, &tstconn); |
8660 | 2762 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2763 "unable to connect to chatnav server\n"); |
2086 | 2764 g_free(host); |
2765 return 1; | |
2766 } | |
4293 | 2767 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2768 break; |
2769 | |
2770 case 0xe: { /* Chat */ | |
2086 | 2771 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2772 |
2086 | 2773 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2774 if (tstconn == NULL) { | |
8660 | 2775 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2776 "unable to connect to chat server\n"); |
2086 | 2777 g_free(host); |
2778 return 1; | |
2779 } | |
2780 | |
4649 | 2781 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2782 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2783 | |
2086 | 2784 ccon = g_new0(struct chat_connection, 1); |
2785 ccon->conn = tstconn; | |
2786 ccon->gc = gc; | |
2787 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2788 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2789 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2790 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2791 ccon->show = extract_name(redir->chat.room); |
4634 | 2792 |
2086 | 2793 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2794 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2795 aim_conn_kill(sess, &tstconn); |
8660 | 2796 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2797 "unable to connect to chat server\n"); |
2086 | 2798 g_free(host); |
2799 g_free(ccon->show); | |
2800 g_free(ccon->name); | |
2801 g_free(ccon); | |
2802 return 1; | |
2803 } | |
4293 | 2804 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2805 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2806 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2807 ccon->name, ccon->exchange); |
4194 | 2808 } break; |
3694 | 2809 |
4804 | 2810 case 0x0010: { /* icon */ |
2811 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2812 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2813 "unable to connect to icon server\n"); |
4804 | 2814 g_free(host); |
2815 return 1; | |
2816 } | |
2817 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2818 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2819 | |
2820 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2821 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2822 aim_conn_kill(sess, &tstconn); |
8660 | 2823 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2824 "unable to connect to icon server\n"); |
4804 | 2825 g_free(host); |
2826 return 1; | |
2827 } | |
2828 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2829 } break; | |
2830 | |
3694 | 2831 case 0x0018: { /* email */ |
2832 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2833 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2834 "unable to connect to email server\n"); |
3694 | 2835 g_free(host); |
2836 return 1; | |
2837 } | |
4649 | 2838 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2839 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2840 | |
2841 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2842 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2843 aim_conn_kill(sess, &tstconn); |
8660 | 2844 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2845 "unable to connect to email server\n"); |
3694 | 2846 g_free(host); |
2847 return 1; | |
2848 } | |
4293 | 2849 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2850 } break; |
2851 | |
2086 | 2852 default: /* huh? */ |
8660 | 2853 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2854 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2855 redir->group); |
2086 | 2856 break; |
2857 } | |
2858 | |
2859 g_free(host); | |
2860 return 1; | |
2861 } | |
2862 | |
10042 | 2863 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
2864 { | |
2865 GaimConnection *gc; | |
2866 GaimAccount *account; | |
2867 OscarData *od; | |
4738 | 2868 struct buddyinfo *bi; |
2993 | 2869 time_t time_idle = 0, signon = 0; |
2870 int type = 0; | |
2871 int caps = 0; | |
2086 | 2872 va_list ap; |
4738 | 2873 aim_userinfo_t *info; |
10042 | 2874 gboolean buddy_is_away = FALSE; |
2875 | |
2876 gc = sess->aux_data; | |
2877 account = gaim_connection_get_account(gc); | |
2878 od = gc->proto_data; | |
4194 | 2879 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2880 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2881 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2882 va_end(ap); |
2883 | |
2993 | 2884 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2885 caps = info->capabilities; | |
3267 | 2886 |
4766 | 2887 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2888 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 2889 buddy_is_away = TRUE; |
2890 } | |
2891 | |
2993 | 2892 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2893 type = (info->icqinfo.status << 16); |
3013 | 2894 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2895 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 2896 buddy_is_away = TRUE; |
3013 | 2897 } |
2993 | 2898 } |
2899 | |
7141 | 2900 if (caps & AIM_CAPS_ICQ_DIRECT) |
2901 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2902 |
2903 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2904 time(&time_idle); |
2905 time_idle -= info->idletime*60; | |
9295 | 2906 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2907 } |
2908 | |
5836 | 2909 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2910 signon = info->onlinesince; | |
2911 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2912 signon = time(NULL) - info->sessionlen; |
2086 | 2913 |
9982 | 2914 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) |
5575 | 2915 gaim_connection_set_display_name(gc, info->sn); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2916 |
9982 | 2917 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 2918 if (!bi) { |
2919 bi = g_new0(struct buddyinfo, 1); | |
9982 | 2920 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 2921 } |
4739 | 2922 bi->typingnot = FALSE; |
2923 bi->ico_informed = FALSE; | |
6857 | 2924 bi->ipaddr = info->icqinfo.ipaddr; |
2925 | |
2926 /* Available message stuff */ | |
6292 | 2927 free(bi->availmsg); |
7011 | 2928 if (info->avail != NULL) |
8225 | 2929 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2930 else |
6292 | 2931 bi->availmsg = NULL; |
4732 | 2932 |
4804 | 2933 /* Server stored icon stuff */ |
4853 | 2934 if (info->iconcsumlen) { |
7125 | 2935 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2936 char *b16 = NULL, *filepath = NULL; |
7093 | 2937 GaimBuddy *b = NULL; |
4853 | 2938 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2939 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 2940 b = gaim_find_buddy(account, info->sn); |
7093 | 2941 /* |
2942 * If for some reason the checksum is valid, but cached file is not.. | |
2943 * we want to know. | |
2944 */ | |
7693 | 2945 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2946 if (filename != NULL) { |
2947 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2948 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2949 "icon_checksum"); | |
9801 | 2950 else { |
2951 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2952 filename, NULL); | |
2953 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2954 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2955 "icon_checksum"); | |
2956 g_free(filepath); | |
2957 } | |
7093 | 2958 } else |
2959 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2960 |
4853 | 2961 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2962 GSList *cur = od->requesticon; | |
2963 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2964 cur = cur->next; | |
2965 if (!cur) { | |
9982 | 2966 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 2967 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2968 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2969 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2970 } |
2971 } | |
6053 | 2972 g_free(b16); |
4853 | 2973 } |
2974 | |
10042 | 2975 /* XXX - Represent other ICQ statuses */ |
2976 if (buddy_is_away == TRUE) | |
2977 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
2978 else | |
2979 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
9982 | 2980 gaim_prpl_got_user_login_time(account, info->sn, signon); |
2981 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); | |
2982 | |
2983 if (time_idle > 0) | |
2984 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 2985 else |
2986 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 2987 |
2988 return 1; | |
2989 } | |
2990 | |
8341 | 2991 static void gaim_check_comment(OscarData *od, const char *str) { |
2992 if ((str == NULL) || strcmp(str, ck)) | |
2993 aim_locate_setcaps(od->sess, caps_aim); | |
2994 else | |
2995 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2996 } | |
2997 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2998 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2999 GaimConnection *gc = sess->aux_data; |
7283 | 3000 OscarData *od = gc->proto_data; |
9982 | 3001 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3002 va_list ap; |
4739 | 3003 aim_userinfo_t *info; |
2086 | 3004 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3005 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3006 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3007 va_end(ap); |
3008 | |
9982 | 3009 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3010 |
7261 | 3011 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3012 |
2086 | 3013 return 1; |
3014 } | |
3015 | |
4617 | 3016 /* BBB */ |
3952 | 3017 /* |
4617 | 3018 * This is called after a remote AIM user has connected to us. We |
3019 * want to do some voodoo with the socket file descriptors, add a | |
3020 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3021 */ |
4656 | 3022 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3023 GaimConnection *gc = sess->aux_data; |
7283 | 3024 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3025 GaimXfer *xfer; |
5146 | 3026 struct aim_oft_info *oft_info; |
3630 | 3027 va_list ap; |
3028 aim_conn_t *conn, *listenerconn; | |
4656 | 3029 |
8660 | 3030 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3031 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3032 va_start(ap, fr); |
3033 conn = va_arg(ap, aim_conn_t *); | |
3034 listenerconn = va_arg(ap, aim_conn_t *); | |
3035 va_end(ap); | |
3036 | |
4617 | 3037 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3038 return 1; | |
3039 | |
5146 | 3040 if (!(oft_info = xfer->data)) |
4617 | 3041 return 1; |
3042 | |
3630 | 3043 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3044 gaim_input_remove(xfer->watcher); |
3630 | 3045 aim_conn_kill(sess, &listenerconn); |
3046 | |
5146 | 3047 oft_info->conn = conn; |
3048 xfer->fd = oft_info->conn->fd; | |
3049 | |
3050 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3051 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3052 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3053 |
3054 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3055 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3056 |
3057 return 0; | |
3058 } | |
3059 | |
3952 | 3060 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3061 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3062 * user in order to transfer a file. |
3952 | 3063 */ |
4617 | 3064 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
|
3065 GaimXfer *xfer; |
5146 | 3066 struct aim_oft_info *oft_info; |
4656 | 3067 |
8660 | 3068 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3069 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3070 if (!(xfer = data)) |
3071 return; | |
5146 | 3072 if (!(oft_info = xfer->data)) |
3630 | 3073 return; |
8446 | 3074 if (source < 0) { |
3075 gaim_xfer_cancel_remote(xfer); | |
4617 | 3076 return; |
8446 | 3077 } |
4617 | 3078 |
3079 xfer->fd = source; | |
5146 | 3080 oft_info->conn->fd = source; |
3081 | |
3082 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3083 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3084 |
3085 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3086 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3087 |
3088 return; | |
3630 | 3089 } |
3090 | |
3952 | 3091 /* |
4617 | 3092 * This is called when a buddy sends us some file info. This happens when they |
3093 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3094 * You should send them the exact same info except use the real cookie. We also |
4617 | 3095 * get like totally ready to like, receive the file, kay? |
3952 | 3096 */ |
4617 | 3097 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3098 GaimConnection *gc = sess->aux_data; |
7283 | 3099 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3100 GaimXfer *xfer; |
5146 | 3101 struct aim_oft_info *oft_info; |
4617 | 3102 va_list ap; |
3103 aim_conn_t *conn; | |
3104 fu8_t *cookie; | |
3105 struct aim_fileheader_t *fh; | |
4656 | 3106 |
8660 | 3107 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3108 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3109 va_start(ap, fr); |
3110 conn = va_arg(ap, aim_conn_t *); | |
3111 cookie = va_arg(ap, fu8_t *); | |
3112 fh = va_arg(ap, struct aim_fileheader_t *); | |
3113 va_end(ap); | |
3114 | |
3115 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3116 return 1; | |
3117 | |
5146 | 3118 if (!(oft_info = xfer->data)) |
4617 | 3119 return 1; |
3120 | |
3121 /* We want to stop listening with a normal thingy */ | |
3122 gaim_input_remove(xfer->watcher); | |
3123 xfer->watcher = 0; | |
3124 | |
5146 | 3125 /* They sent us some information about the file they're sending */ |
3126 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3127 | |
3128 /* Fill in the cookie */ | |
3129 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3130 | |
4617 | 3131 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3132 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3133 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3134 | |
3135 return 0; | |
3630 | 3136 } |
3137 | |
3952 | 3138 /* |
4657 | 3139 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3140 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3141 */ |
4617 | 3142 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3143 GaimConnection *gc = sess->aux_data; |
7283 | 3144 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3145 GaimXfer *xfer; |
4617 | 3146 va_list ap; |
3147 aim_conn_t *conn; | |
3148 fu8_t *cookie; | |
3149 struct aim_fileheader_t *fh; | |
4656 | 3150 |
8660 | 3151 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3152 va_start(ap, fr); |
3153 conn = va_arg(ap, aim_conn_t *); | |
3154 cookie = va_arg(ap, fu8_t *); | |
3155 fh = va_arg(ap, struct aim_fileheader_t *); | |
3156 va_end(ap); | |
3157 | |
3158 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3159 return 1; | |
3160 | |
4656 | 3161 /* We want to stop listening with a normal thingy */ |
3162 gaim_input_remove(xfer->watcher); | |
3163 xfer->watcher = 0; | |
3164 | |
4617 | 3165 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3166 | |
3167 return 0; | |
3630 | 3168 } |
4617 | 3169 |
3170 /* | |
3171 * We just sent a file to someone. They said they got it and everything, | |
3172 * so we can close our direct connection and what not. | |
3173 */ | |
3174 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3175 GaimConnection *gc = sess->aux_data; |
7283 | 3176 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3177 GaimXfer *xfer; |
4617 | 3178 va_list ap; |
3179 aim_conn_t *conn; | |
3180 fu8_t *cookie; | |
3181 struct aim_fileheader_t *fh; | |
4656 | 3182 |
8660 | 3183 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3184 va_start(ap, fr); |
3185 conn = va_arg(ap, aim_conn_t *); | |
3186 cookie = va_arg(ap, fu8_t *); | |
3187 fh = va_arg(ap, struct aim_fileheader_t *); | |
3188 va_end(ap); | |
3189 | |
3190 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3191 return 1; | |
3192 | |
4656 | 3193 xfer->fd = conn->fd; |
4617 | 3194 gaim_xfer_end(xfer); |
3195 | |
3196 return 0; | |
3197 } | |
3630 | 3198 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3199 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3200 GaimConnection *gc = sess->aux_data; |
7283 | 3201 OscarData *od = gc->proto_data; |
8708 | 3202 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3203 GaimConvImFlags flags = 0; |
4738 | 3204 struct buddyinfo *bi; |
5575 | 3205 const char *iconfile; |
9806 | 3206 GString *message; |
3207 gchar *tmp; | |
3208 aim_mpmsg_section_t *curpart; | |
3209 | |
3210 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3211 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3212 |
8708 | 3213 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3214 if (!bi) { |
3215 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3216 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3217 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3218 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3219 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3220 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3221 |
4738 | 3222 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3223 bi->typingnot = TRUE; | |
3224 else | |
3225 bi->typingnot = FALSE; | |
3226 | |
4380 | 3227 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3228 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3229 "%s has an icon\n", userinfo->sn); |
4738 | 3230 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3231 bi->ico_need = TRUE; | |
3232 bi->ico_len = args->iconlen; | |
3233 bi->ico_csum = args->iconsum; | |
3234 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3235 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3236 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3237 |
8708 | 3238 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3239 (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
|
3240 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3241 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3242 |
5575 | 3243 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3244 char *buf = g_malloc(st.st_size); |
5575 | 3245 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3246 if (file) { |
9532 | 3247 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3248 int len = fread(buf, 1, st.st_size, file); |
8660 | 3249 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3250 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3251 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3252 userinfo->sn, len, st.st_size); |
4617 | 3253 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3254 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3255 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3256 } else |
8660 | 3257 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3258 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3259 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3260 } else |
8660 | 3261 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3262 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3263 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3264 |
9806 | 3265 message = g_string_new(""); |
3266 curpart = args->mpmsg.parts; | |
3267 while (curpart != NULL) { | |
9908 | 3268 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3269 curpart->data, curpart->datalen); |
3270 if (tmp != NULL) { | |
3271 g_string_append(message, tmp); | |
3272 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3273 } |
9806 | 3274 |
3275 curpart = curpart->next; | |
3276 } | |
3277 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3278 |
8666 | 3279 /* |
8995 | 3280 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3281 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3282 * so any HTML we receive is intended to be displayed |
3283 * | |
3284 * Note: There *may* be some clients which send messages as HTML formatted - | |
3285 * they need to be special-cased somehow. | |
8666 | 3286 */ |
9982 | 3287 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3288 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3289 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3290 g_free(tmp); |
3291 tmp = tmp2; | |
3292 } | |
3293 | |
6982 | 3294 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3295 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3296 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3297 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3298 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3299 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3300 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3301 GaimConnection *gc; |
9933 | 3302 GaimAccount *account; |
9070 | 3303 OscarData *od; |
9933 | 3304 const char *username = NULL; |
3305 char *message = NULL; | |
9070 | 3306 |
3307 g_return_val_if_fail(sess != NULL, 0); | |
3308 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3309 | |
3310 gc = sess->aux_data; | |
9933 | 3311 account = gaim_connection_get_account(gc); |
9070 | 3312 od = gc->proto_data; |
9933 | 3313 username = gaim_account_get_username(account); |
3314 | |
3315 if (args == NULL) | |
4121 | 3316 return 0; |
4194 | 3317 |
9933 | 3318 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3319 userinfo->sn, args->status); | |
3320 | |
3321 if (args->msg != NULL) | |
3322 { | |
3323 if (args->encoding != NULL) | |
3324 { | |
3325 char *encoding = NULL; | |
3326 encoding = oscar_encoding_extract(args->encoding); | |
3327 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3328 g_free(encoding); | |
3329 } else { | |
3330 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3331 message = g_strdup(args->msg); | |
3332 } | |
3333 } | |
2869 | 3334 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3335 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3336 char *name; |
5234 | 3337 GHashTable *components; |
3338 | |
9933 | 3339 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3340 g_free(message); | |
4121 | 3341 return 1; |
9933 | 3342 } |
5234 | 3343 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3344 g_free); | |
4121 | 3345 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3346 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3347 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
|
3348 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3349 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3350 userinfo->sn, |
9933 | 3351 message, |
5234 | 3352 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3353 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3354 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3355 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3356 /* BBB */ |
3357 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3358 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3359 GaimXfer *xfer; |
5146 | 3360 struct aim_oft_info *oft_info; |
3361 | |
3362 if (!args->cookie || !args->port || !args->verifiedip || | |
3363 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3364 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3365 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3366 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3367 "information.\n", userinfo->sn); |
5146 | 3368 if (args->proxyip) |
8660 | 3369 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3370 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3371 "does not support this yet.\n"); |
9933 | 3372 g_free(message); |
4617 | 3373 return 1; |
4656 | 3374 } |
4617 | 3375 |
3376 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3377 /* 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
|
3378 * directory -- remove the star and trailing slash so we don't save |
4617 | 3379 * directories that look like 'dirname\*' -- arl */ |
3380 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3381 if (tmp && (tmp[1] == '*')) { | |
3382 tmp[0] = '\0'; | |
3383 } | |
8660 | 3384 gaim_debug_warning("oscar", |
8446 | 3385 "We're receiving a whole directory! What fun! " |
3386 "Especially since we don't support that!\n"); | |
4617 | 3387 } |
3388 | |
3389 /* Build the file transfer handle */ | |
3390 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3391 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3392 xfer->remote_port = args->port; |
4617 | 3393 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3394 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3395 gaim_xfer_set_message(xfer, message); |
5146 | 3396 |
3397 /* Create the oscar-specific data */ | |
5163 | 3398 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3399 if (args->proxyip) |
5146 | 3400 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3401 if (args->verifiedip) |
5146 | 3402 oft_info->verifiedip = g_strdup(args->verifiedip); |
3403 xfer->data = oft_info; | |
4617 | 3404 |
3405 /* Setup our I/O op functions */ | |
8446 | 3406 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3407 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3408 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
|
3409 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3410 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3411 |
3412 /* Keep track of this transfer for later */ | |
3413 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3414 | |
3415 /* Now perform the request */ | |
3416 gaim_xfer_request(xfer); | |
3417 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3418 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3419 GaimXfer *xfer; |
8660 | 3420 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3421 "AAA - File transfer canceled by remote user\n"); |
4617 | 3422 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
|
3423 gaim_xfer_cancel_remote(xfer); |
4617 | 3424 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3425 /* | |
3426 * This gets sent by the receiver of a file | |
3427 * as they connect directly to us. If we don't | |
3428 * get this, then maybe a third party connected | |
3429 * to us, and we shouldn't send them anything. | |
3430 */ | |
3431 } else { | |
8660 | 3432 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3433 "unknown rendezvous status!\n"); |
3630 | 3434 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3435 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3436 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3437 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3438 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3439 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3440 args->info.icon.length); |
6871 | 3441 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3442 /* 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
|
3443 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3444 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
|
3445 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3446 |
4212 | 3447 if (!args->verifiedip) { |
8983 | 3448 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3449 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3450 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3451 g_free(message); |
4650 | 3452 return 1; |
4212 | 3453 } |
3454 | |
8660 | 3455 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3456 "%s received direct im request from %s (%s)\n", |
8983 | 3457 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3458 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3459 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3460 d->sn = g_strdup(userinfo->sn); |
8983 | 3461 /* Let's use the clientip here, because I think that's what AIM does. |
3462 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3463 * and then ask them to connect to us. */ | |
3464 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->clientip, args->port?args->port:5190); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3465 memcpy(d->cookie, args->cookie, 8); |
9070 | 3466 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3467 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3468 | |
8971 | 3469 oscar_direct_im_destroy(od, dim); |
8984 | 3470 d->donttryagain = TRUE; |
8971 | 3471 accept_direct_im_request(d); |
3472 } else { | |
8983 | 3473 if (dim && !dim->connected) |
8971 | 3474 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3475 "already connected to that buddy!"); | |
5575 | 3476 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
|
3477 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3478 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3479 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3480 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3481 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3482 "revealed, this may be considered a privacy " |
9972 | 3483 "risk."), |
3484 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3485 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3486 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3487 /* FIXME: we should actually send a packet on cancel */ | |
3488 } | |
8708 | 3489 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3490 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
|
3491 } else { |
8660 | 3492 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3493 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3494 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3495 |
9933 | 3496 g_free(message); |
3497 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3498 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3499 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3500 |
3453 | 3501 /* |
4230 | 3502 * Authorization Functions |
3503 * Most of these are callbacks from dialogs. They're used by both | |
3504 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3505 */ |
4269 | 3506 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3507 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3508 GaimConnection *gc = data->gc; |
4244 | 3509 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3510 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3511 OscarData *od = gc->proto_data; |
6695 | 3512 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3513 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3514 if (buddy && group) { |
8660 | 3515 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3516 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3517 buddy->name, group->name); |
4889 | 3518 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3519 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3520 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3521 } |
4230 | 3522 } |
4337 | 3523 } |
3524 | |
3525 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3526 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3527 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3528 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3529 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3530 data); |
4230 | 3531 } |
3532 | |
3533 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3534 GaimConnection *gc = data->gc; |
4244 | 3535 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3536 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3537 /* Remove from local list */ |
3538 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3539 gaim_blist_remove_buddy(b); | |
4244 | 3540 } |
3541 | |
5836 | 3542 oscar_free_name_data(data); |
4230 | 3543 } |
3544 | |
9030 | 3545 |
3546 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3547 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3548 GaimBuddy *buddy; |
4269 | 3549 gchar *dialog_msg, *nombre; |
3550 | |
4687 | 3551 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3552 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3553 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3554 else |
4830 | 3555 nombre = NULL; |
3556 | |
3557 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 | 3558 data->gc = gc; |
3559 data->name = g_strdup(name); | |
3560 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3561 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3562 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3563 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3564 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3565 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3566 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3567 |
3568 g_free(dialog_msg); | |
3569 g_free(nombre); | |
3570 } | |
3571 | |
9030 | 3572 |
3573 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3574 GaimBuddy *buddy; | |
3575 GaimConnection *gc; | |
3576 | |
3577 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3578 | |
3579 buddy = (GaimBuddy *) node; | |
3580 gc = gaim_account_get_connection(buddy->account); | |
3581 gaim_auth_sendrequest(gc, buddy->name); | |
3582 } | |
3583 | |
4230 | 3584 /* When other people ask you for authorization */ |
3585 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3586 GaimConnection *gc = data->gc; |
4244 | 3587 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3588 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3589 OscarData *od = gc->proto_data; |
4236 | 3590 #ifdef NOSSI |
6695 | 3591 GaimBuddy *buddy; |
4244 | 3592 gchar message; |
3593 message = 0; | |
4687 | 3594 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3595 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3596 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3597 #else |
4889 | 3598 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3599 #endif |
4244 | 3600 } |
3601 | |
5836 | 3602 oscar_free_name_data(data); |
3141 | 3603 } |
3604 | |
4230 | 3605 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3606 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3607 GaimConnection *gc = data->gc; |
4244 | 3608 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3609 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3610 OscarData *od = gc->proto_data; |
4230 | 3611 #ifdef NOSSI |
4617 | 3612 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3613 #else |
4889 | 3614 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3615 #endif |
4244 | 3616 } |
4337 | 3617 } |
3618 | |
3619 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3620 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3621 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3622 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3623 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3624 data); |
3141 | 3625 } |
3626 | |
7023 | 3627 /* When someone sends you buddies */ |
3628 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3629 GaimConnection *gc = data->gc; |
4244 | 3630 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3631 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3632 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3633 } |
3634 | |
5836 | 3635 oscar_free_name_data(data); |
3453 | 3636 } |
3637 | |
4075 | 3638 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 | 3639 GaimConnection *gc = sess->aux_data; |
9908 | 3640 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3641 gchar **msg1, **msg2; |
6051 | 3642 int i, numtoks; |
4076 | 3643 |
4121 | 3644 if (!args->type || !args->msg || !args->uin) |
3645 return 1; | |
4194 | 3646 |
8660 | 3647 gaim_debug_info("oscar", |
9908 | 3648 "Received a channel 4 message of type 0x%02hhx.\n", |
3649 args->type); | |
4076 | 3650 |
9919 | 3651 /* |
3652 * Split up the message at the delimeter character, then convert each | |
3653 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3654 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3655 * character in whatever encoding the message was sent in. Type 1 | |
3656 * messages are always made up of only one part, so we can easily account | |
3657 * for this suck-ass part of the protocol by splitting the string into at | |
3658 * most 1 baby string. | |
3659 */ | |
3660 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3661 for (numtoks=0; msg1[numtoks]; numtoks++); |
3662 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3663 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3664 gaim_str_strip_cr(msg1[i]); |
9908 | 3665 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3666 } |
3667 msg2[i] = NULL; | |
3668 | |
3952 | 3669 switch (args->type) { |
4173 | 3670 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3671 if (i >= 1) { |
5556 | 3672 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3673 gchar *tmp; |
3674 | |
3675 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3676 tmp = gaim_escape_html(msg2[0]); |
8493 | 3677 |
4076 | 3678 if (t) { /* This is an offline message */ |
9680 | 3679 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3680 #ifdef HAVE_TM_GMTOFF |
9724 | 3681 time_t now; |
3682 struct tm *tm; | |
3683 now = time(NULL); | |
3684 tm = localtime(&now); | |
3685 t += tm->tm_gmtoff; | |
9698 | 3686 #else |
3687 # ifdef HAVE_TIMEZONE | |
9680 | 3688 tzset(); |
3689 t -= timezone; | |
9698 | 3690 # endif |
3691 #endif | |
8514 | 3692 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3693 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3694 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3695 } |
3696 g_free(uin); | |
8493 | 3697 g_free(tmp); |
4075 | 3698 } |
3316 | 3699 } break; |
3700 | |
4173 | 3701 case 0x04: { /* Someone sent you a URL */ |
4076 | 3702 if (i >= 2) { |
7385 | 3703 if (msg2[1] != NULL) { |
3704 gchar *uin = g_strdup_printf("%u", args->uin); | |
3705 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3706 msg2[1], | |
3707 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3708 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3709 g_free(uin); | |
3710 g_free(message); | |
3711 } | |
3453 | 3712 } |
3713 } break; | |
3714 | |
4173 | 3715 case 0x06: { /* Someone requested authorization */ |
4076 | 3716 if (i >= 6) { |
4230 | 3717 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3718 gchar *dialog_msg = g_strdup_printf(_("The user %u wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); |
8660 | 3719 gaim_debug_info("oscar", |
5556 | 3720 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3721 args->uin); |
4076 | 3722 data->gc = gc; |
5556 | 3723 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3724 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3725 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3726 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3727 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3728 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3729 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3730 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3731 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3732 g_free(dialog_msg); |
3733 } | |
3141 | 3734 } break; |
3735 | |
4173 | 3736 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3737 if (i >= 1) { |
7023 | 3738 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
|
3739 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3740 dialog_msg); |
4076 | 3741 g_free(dialog_msg); |
3742 } | |
3141 | 3743 } break; |
3744 | |
4173 | 3745 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3746 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
|
3747 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3748 dialog_msg); |
3141 | 3749 g_free(dialog_msg); |
3750 } break; | |
3751 | |
4333 | 3752 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3753 if (i >= 5) { | |
3754 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
|
3755 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3756 g_free(dialog_msg); |
3757 } | |
3758 } break; | |
3759 | |
4173 | 3760 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3761 if (i >= 6) { |
4194 | 3762 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
|
3763 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3764 g_free(dialog_msg); |
3765 } | |
4075 | 3766 } break; |
3767 | |
4173 | 3768 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3769 if (i >= 6) { |
4308 | 3770 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
|
3771 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3772 g_free(dialog_msg); |
3773 } | |
4075 | 3774 } break; |
3775 | |
4173 | 3776 case 0x12: { |
3141 | 3777 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3778 /* Someone added you to their buddy list? */ |
3141 | 3779 } break; |
3780 | |
7023 | 3781 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3782 guint i, num; |
3453 | 3783 gchar **text; |
4173 | 3784 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3785 if (text) { |
3786 num = 0; | |
3787 for (i=0; i<strlen(text[0]); i++) | |
3788 num = num*10 + text[0][i]-48; | |
3789 for (i=0; i<num; i++) { | |
4230 | 3790 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3791 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 | 3792 data->gc = gc; |
4790 | 3793 data->name = g_strdup(text[i*2+1]); |
3794 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3795 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3796 gaim_request_action(gc, NULL, message, |
7023 | 3797 _("Do you want to add this buddy " |
3798 "to your buddy list?"), | |
9972 | 3799 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3800 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3801 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3802 g_free(message); |
3803 } | |
3804 g_strfreev(text); | |
3805 } | |
3806 } break; | |
3807 | |
7023 | 3808 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3809 /* This is boring and silly. */ |
3810 } break; | |
3811 | |
3141 | 3812 default: { |
8660 | 3813 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3814 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3815 "(type 0x%02hhx).\n", args->type); |
3141 | 3816 } break; |
3817 } | |
3818 | |
4076 | 3819 g_strfreev(msg1); |
3820 g_strfreev(msg2); | |
3821 | |
3141 | 3822 return 1; |
3823 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3824 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3825 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3826 fu16_t channel; |
3827 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3828 aim_userinfo_t *userinfo; |
2086 | 3829 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3830 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3831 va_start(ap, fr); |
4200 | 3832 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3833 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3834 |
3141 | 3835 switch (channel) { |
3836 case 1: { /* standard message */ | |
3837 struct aim_incomingim_ch1_args *args; | |
3838 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3839 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3840 } break; | |
3841 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3842 case 2: { /* rendezvous */ |
3141 | 3843 struct aim_incomingim_ch2_args *args; |
3844 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3845 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3846 } break; | |
3847 | |
3848 case 4: { /* ICQ */ | |
3849 struct aim_incomingim_ch4_args *args; | |
3850 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3851 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3852 } break; |
3853 | |
3854 default: { | |
8660 | 3855 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3856 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3857 "0x%04hx).", channel); |
3141 | 3858 } break; |
2086 | 3859 } |
3860 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3861 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3862 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3863 return ret; |
2086 | 3864 } |
3865 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3866 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3867 GaimConnection *gc = sess->aux_data; |
3868 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3869 char *buf; |
2086 | 3870 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3871 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3872 aim_userinfo_t *userinfo; |
2086 | 3873 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3874 va_start(ap, fr); |
4200 | 3875 chan = (fu16_t)va_arg(ap, unsigned int); |
3876 userinfo = va_arg(ap, aim_userinfo_t *); | |
3877 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3878 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3879 va_end(ap); |
3880 | |
3881 switch(reason) { | |
5420 | 3882 case 0: /* Invalid (0) */ |
3883 buf = g_strdup_printf( | |
3884 ngettext( | |
4276 | 3885 "You missed %hu message from %s because it was invalid.", |
3886 "You missed %hu messages from %s because they were invalid.", | |
3887 nummissed), | |
4282 | 3888 nummissed, |
3889 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3890 break; |
5420 | 3891 case 1: /* Message too large */ |
3892 buf = g_strdup_printf( | |
3893 ngettext( | |
4276 | 3894 "You missed %hu message from %s because it was too large.", |
3895 "You missed %hu messages from %s because they were too large.", | |
3896 nummissed), | |
4282 | 3897 nummissed, |
3898 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3899 break; |
5420 | 3900 case 2: /* Rate exceeded */ |
3901 buf = g_strdup_printf( | |
3902 ngettext( | |
4276 | 3903 "You missed %hu message from %s because the rate limit has been exceeded.", |
3904 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3905 nummissed), | |
4282 | 3906 nummissed, |
3907 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3908 break; |
5420 | 3909 case 3: /* Evil Sender */ |
3910 buf = g_strdup_printf( | |
3911 ngettext( | |
4276 | 3912 "You missed %hu message from %s because he/she was too evil.", |
3913 "You missed %hu messages from %s because he/she was too evil.", | |
3914 nummissed), | |
4282 | 3915 nummissed, |
3916 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3917 break; |
5420 | 3918 case 4: /* Evil Receiver */ |
3919 buf = g_strdup_printf( | |
3920 ngettext( | |
4276 | 3921 "You missed %hu message from %s because you are too evil.", |
3922 "You missed %hu messages from %s because you are too evil.", | |
3923 nummissed), | |
4282 | 3924 nummissed, |
3925 userinfo->sn); | |
2086 | 3926 break; |
3927 default: | |
5420 | 3928 buf = g_strdup_printf( |
3929 ngettext( | |
4276 | 3930 "You missed %hu message from %s for an unknown reason.", |
3931 "You missed %hu messages from %s for an unknown reason.", | |
3932 nummissed), | |
4282 | 3933 nummissed, |
3934 userinfo->sn); | |
2086 | 3935 break; |
3936 } | |
8733 | 3937 |
9627 | 3938 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3939 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3940 g_free(buf); |
2086 | 3941 |
3942 return 1; | |
3943 } | |
3944 | |
4194 | 3945 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3946 GaimConnection *gc = sess->aux_data; |
7283 | 3947 OscarData *od = gc->proto_data; |
4617 | 3948 |
3949 /* BBB */ | |
3630 | 3950 switch (reason) { |
4151 | 3951 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3952 GaimXfer *xfer; |
8971 | 3953 struct oscar_direct_im *dim; |
3954 | |
8660 | 3955 gaim_debug_info("oscar", |
9070 | 3956 "AAA - Other user declined some sort of direct " |
8971 | 3957 "connect attempt (automaticly?)\n"); |
4617 | 3958 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
|
3959 gaim_xfer_cancel_remote(xfer); |
8971 | 3960 else if ((dim = oscar_direct_im_find(od, who))) { |
3961 /* AAA should use find by cookie or something here */ | |
3962 oscar_direct_im_disconnect(od, dim); | |
3963 } | |
4151 | 3964 } break; |
3965 | |
3966 default: { | |
8660 | 3967 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3968 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3969 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3970 } |
3630 | 3971 |
3972 } | |
3973 | |
3974 return 0; | |
3975 } | |
3976 | |
4194 | 3977 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3978 GaimConnection *gc = sess->aux_data; |
4151 | 3979 |
3980 switch(reason) { | |
3981 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3982 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3983 | |
3984 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3985 |
3986 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3987 statusmsg = oscar_icqstatus(state); |
4151 | 3988 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3989 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3990 g_free(statusmsg); | |
4151 | 3991 g_strfreev(splitmsg); |
9244 | 3992 |
9797 | 3993 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 3994 |
3995 g_free(title); | |
3996 g_free(dialogmsg); | |
4151 | 3997 } break; |
3998 | |
3999 default: { | |
8660 | 4000 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4001 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4002 "Type 0x%04hx\n", who, reason); |
4151 | 4003 } break; |
4004 } /* end of switch */ | |
4005 | |
4006 return 0; | |
4007 } | |
4008 | |
3212 | 4009 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4010 va_list ap; | |
4011 fu16_t chan, reason; | |
4012 char *who; | |
4013 | |
4014 va_start(ap, fr); | |
4200 | 4015 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4016 who = va_arg(ap, char *); |
4200 | 4017 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4018 |
3952 | 4019 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4020 char *cookie = va_arg(ap, char *); |
4151 | 4021 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4022 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4023 fu32_t state = 0; |
4151 | 4024 char *msg = NULL; |
4025 if (reason == 0x0003) { | |
4200 | 4026 state = va_arg(ap, fu32_t); |
4151 | 4027 msg = va_arg(ap, char *); |
4028 } | |
4029 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4030 } | |
3952 | 4031 |
3212 | 4032 va_end(ap); |
4033 | |
4034 return 1; | |
4035 } | |
4036 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4037 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4038 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4039 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4040 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4041 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4042 va_start(ap, fr); |
4199 | 4043 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4044 va_end(ap); |
4045 | |
8660 | 4046 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4047 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4048 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4049 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4050 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4051 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4052 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4053 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4054 |
2086 | 4055 return 1; |
4056 } | |
4057 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4058 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4059 GaimConnection *gc = sess->aux_data; |
4617 | 4060 #if 0 |
7283 | 4061 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4062 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4063 #endif |
4617 | 4064 va_list ap; |
4065 fu16_t reason; | |
4066 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4067 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4068 va_start(ap, fr); |
4617 | 4069 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4070 data = va_arg(ap, char *); |
2086 | 4071 va_end(ap); |
4072 | |
8660 | 4073 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4074 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 4075 |
4076 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4077 #if 0 |
4617 | 4078 /* If this was a file transfer request, data is a cookie */ |
4079 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
|
4080 gaim_xfer_cancel_remote(xfer); |
3630 | 4081 return 1; |
4082 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4083 #endif |
3630 | 4084 |
4617 | 4085 /* Data is assumed to be the destination sn */ |
9826 | 4086 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4087 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4088 g_free(buf); | |
4089 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4090 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4091 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4092 } | |
4093 g_free(buf); | |
4094 | |
2086 | 4095 return 1; |
4096 } | |
4097 | |
3595 | 4098 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4099 GaimConnection *gc = sess->aux_data; |
3595 | 4100 va_list ap; |
4101 fu16_t type1, type2; | |
4102 char *sn; | |
4103 | |
4104 va_start(ap, fr); | |
4199 | 4105 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4106 sn = va_arg(ap, char *); |
4199 | 4107 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4108 va_end(ap); |
4109 | |
4110 switch (type2) { | |
4111 case 0x0000: { /* Text has been cleared */ | |
4112 serv_got_typing_stopped(gc, sn); | |
4113 } break; | |
4114 | |
4115 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4116 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4117 } break; |
4118 | |
4119 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4120 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4121 } break; |
4122 | |
4123 default: { | |
8660 | 4124 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 | 4125 } break; |
4126 } | |
4127 | |
4128 return 1; | |
4129 } | |
4130 | |
7141 | 4131 /* |
4132 * We get this error when there was an error in the locate family. This | |
7259 | 4133 * happens when you request info of someone who is offline. |
7141 | 4134 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4135 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4136 gchar *buf; |
2086 | 4137 va_list ap; |
5420 | 4138 fu16_t reason; |
2086 | 4139 char *destn; |
4140 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4141 va_start(ap, fr); |
4199 | 4142 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4143 destn = va_arg(ap, char *); |
4144 va_end(ap); | |
4145 | |
7781 | 4146 if (destn == NULL) |
7793 | 4147 return 1; |
9627 | 4148 |
9826 | 4149 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4150 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4151 g_free(buf); | |
9627 | 4152 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4153 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4154 } | |
4155 g_free(buf); | |
2086 | 4156 |
4157 return 1; | |
4158 } | |
4159 | |
7011 | 4160 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4161 GaimConnection *gc = sess->aux_data; |
8700 | 4162 GaimAccount *account = gaim_connection_get_account(gc); |
4163 GString *str; | |
9244 | 4164 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4165 va_list ap; |
7011 | 4166 aim_userinfo_t *userinfo; |
2086 | 4167 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4168 va_start(ap, fr); |
7011 | 4169 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4170 va_end(ap); |
4171 | |
8700 | 4172 str = g_string_new(""); |
4173 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4174 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4175 |
10116 | 4176 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
4177 time_t t = userinfo->onlinesince; | |
4178 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); | |
4179 } | |
4180 | |
4181 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
4182 time_t t = userinfo->membersince; | |
4183 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); | |
4184 } | |
7011 | 4185 |
4186 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4187 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4188 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4189 g_free(tmp); |
4190 } | |
4191 | |
8701 | 4192 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4193 |
4194 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4195 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4196 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4197 g_free(tmp); | |
7011 | 4198 if (away_utf8 != NULL) { |
8700 | 4199 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4200 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4201 } |
7011 | 4202 } |
4203 | |
4204 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4205 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4206 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4207 g_free(tmp); | |
7011 | 4208 if (info_utf8 != NULL) { |
8700 | 4209 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4210 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4211 } |
7011 | 4212 } |
4213 | |
8701 | 4214 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4215 g_string_free(str, TRUE); |
9244 | 4216 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4217 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4218 g_free(title); |
8700 | 4219 g_free(tmp); |
4151 | 4220 |
2086 | 4221 return 1; |
4222 } | |
4223 | |
8341 | 4224 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4225 { | |
4226 aim_session_t *sess = data; | |
4227 GaimConnection *gc = sess->aux_data; | |
4228 OscarData *od = (OscarData *)gc->proto_data; | |
4229 | |
4230 aim_locate_dorequest(data); | |
4231 od->getinfotimer = 0; | |
4232 | |
4233 return FALSE; | |
4234 } | |
4235 | |
4236 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4237 { | |
4238 GaimConnection *gc = sess->aux_data; | |
4239 OscarData *od = (OscarData *)gc->proto_data; | |
4240 | |
4241 /* | |
4242 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4243 * us from hitting the rate limit due to request away messages and info | |
4244 * too quickly. | |
4245 */ | |
4246 if (od->getinfotimer == 0) | |
4247 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4248 | |
4249 return 1; | |
4250 } | |
4251 | |
4252 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4253 { | |
2086 | 4254 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4255 fu16_t id; |
2086 | 4256 va_list ap; |
4257 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4258 va_start(ap, fr); |
4199 | 4259 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4260 msg = va_arg(ap, char *); |
4261 va_end(ap); | |
4262 | |
8660 | 4263 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4264 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4265 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4266 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4267 _("Your AIM connection may be lost."), NULL); |
2086 | 4268 |
4269 return 1; | |
4270 } | |
4271 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4272 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4273 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4274 fu16_t type; |
5575 | 4275 GaimConnection *gc = sess->aux_data; |
7283 | 4276 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4277 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4278 va_start(ap, fr); |
4199 | 4279 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4280 |
4281 switch(type) { | |
4282 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4283 fu8_t maxrooms; |
2086 | 4284 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4285 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4286 |
4199 | 4287 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4288 exchangecount = va_arg(ap, int); |
4289 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4290 | |
8660 | 4291 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4292 "chat info: Chat Rights:\n"); |
8660 | 4293 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4294 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4295 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4296 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4297 for (i = 0; i < exchangecount; i++) |
8660 | 4298 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4299 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4300 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4301 while (od->create_rooms) { |
4302 struct create_room *cr = od->create_rooms->data; | |
8660 | 4303 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4304 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4305 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4306 g_free(cr->name); |
4617 | 4307 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4308 g_free(cr); |
2086 | 4309 } |
4310 } | |
4311 break; | |
4312 case 0x0008: { | |
4313 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4314 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4315 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4316 fu32_t createtime; |
2086 | 4317 |
4318 fqcn = va_arg(ap, char *); | |
4200 | 4319 instance = (fu16_t)va_arg(ap, unsigned int); |
4320 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4321 flags = (fu16_t)va_arg(ap, unsigned int); | |
4322 createtime = va_arg(ap, fu32_t); | |
4323 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4324 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4325 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4326 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4327 name = va_arg(ap, char *); | |
4328 ck = va_arg(ap, char *); | |
4194 | 4329 |
8660 | 4330 gaim_debug_misc("oscar", |
5556 | 4331 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4332 fqcn, |
4333 exchange, instance, flags, | |
4334 createtime, | |
4335 maxmsglen, maxoccupancy, createperms, unknown, | |
4336 name, ck); | |
4617 | 4337 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4338 } |
4339 break; | |
4340 default: | |
8660 | 4341 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4342 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4343 break; |
4344 } | |
4194 | 4345 |
4346 va_end(ap); | |
4347 | |
2086 | 4348 return 1; |
4349 } | |
4350 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4351 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4352 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4353 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4354 aim_userinfo_t *info; |
5575 | 4355 GaimConnection *g = sess->aux_data; |
2086 | 4356 |
4357 struct chat_connection *c = NULL; | |
4358 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4359 va_start(ap, fr); |
2086 | 4360 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4361 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4362 va_end(ap); |
4363 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4364 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4365 if (!c) |
4366 return 1; | |
4367 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4368 for (i = 0; i < count; i++) |
9846 | 4369 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4370 |
4371 return 1; | |
4372 } | |
4373 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4374 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4375 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4376 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4377 aim_userinfo_t *info; |
5575 | 4378 GaimConnection *g = sess->aux_data; |
2086 | 4379 |
4380 struct chat_connection *c = NULL; | |
4381 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4382 va_start(ap, fr); |
2086 | 4383 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4384 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4385 va_end(ap); |
4386 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4387 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4388 if (!c) |
4389 return 1; | |
4390 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4391 for (i = 0; i < count; i++) |
8733 | 4392 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4393 |
4394 return 1; | |
4395 } | |
4396 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4397 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
|
4398 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4399 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4400 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4401 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4402 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4403 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4404 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4405 fu32_t creationtime; |
5575 | 4406 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4407 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
|
4408 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4409 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4410 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4411 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4412 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4413 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4414 roomdesc = va_arg(ap, char *); |
4200 | 4415 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4416 creationtime = va_arg(ap, fu32_t); | |
4417 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4418 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4419 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4420 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4421 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4422 |
8660 | 4423 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4424 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4425 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4426 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4427 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4428 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4429 |
2086 | 4430 return 1; |
4431 } | |
4432 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4433 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4434 GaimConnection *gc = sess->aux_data; |
8225 | 4435 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4436 gchar *utf8; | |
2086 | 4437 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4438 aim_userinfo_t *info; |
8225 | 4439 int len; |
2086 | 4440 char *msg; |
8219 | 4441 char *charset; |
2086 | 4442 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4443 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4444 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4445 len = va_arg(ap, int); |
4194 | 4446 msg = va_arg(ap, char *); |
8219 | 4447 charset = va_arg(ap, char *); |
4194 | 4448 va_end(ap); |
2086 | 4449 |
8225 | 4450 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4451 if (utf8 == NULL) |
4452 /* The conversion failed! */ | |
8668 | 4453 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4454 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4455 g_free(utf8); | |
2086 | 4456 |
4457 return 1; | |
4458 } | |
4459 | |
3694 | 4460 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4461 va_list ap; | |
5575 | 4462 GaimConnection *gc = sess->aux_data; |
3694 | 4463 struct aim_emailinfo *emailinfo; |
3725 | 4464 int havenewmail; |
7297 | 4465 char *alertitle, *alerturl; |
3694 | 4466 |
4467 va_start(ap, fr); | |
4468 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4469 havenewmail = va_arg(ap, int); |
7301 | 4470 alertitle = va_arg(ap, char *); |
4471 alerturl = va_arg(ap, char *); | |
3694 | 4472 va_end(ap); |
4473 | |
9661 | 4474 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4475 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4476 emailinfo->domain ? "@" : "", | |
4477 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4478 if (emailinfo->unread && havenewmail) |
4479 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4480 g_free(to); |
3694 | 4481 } |
7297 | 4482 |
7301 | 4483 if (alertitle) |
8660 | 4484 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4485 |
4486 return 1; | |
4487 } | |
4488 | |
4804 | 4489 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4490 GaimConnection *gc = sess->aux_data; |
7283 | 4491 OscarData *od = gc->proto_data; |
4804 | 4492 char *sn; |
4493 | |
4494 sn = od->requesticon->data; | |
8660 | 4495 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4496 "removing %s from hash table\n", sn); |
4804 | 4497 od->requesticon = g_slist_remove(od->requesticon, sn); |
4498 free(sn); | |
4499 | |
4500 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4501 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4502 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4503 |
4504 return 1; | |
4505 } | |
4506 | |
4507 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4508 GaimConnection *gc = sess->aux_data; |
7283 | 4509 OscarData *od = gc->proto_data; |
4804 | 4510 GSList *cur; |
4511 va_list ap; | |
4512 char *sn; | |
4853 | 4513 fu8_t *iconcsum, *icon; |
4514 fu16_t iconcsumlen, iconlen; | |
4804 | 4515 |
4516 va_start(ap, fr); | |
4517 sn = va_arg(ap, char *); | |
4853 | 4518 iconcsum = va_arg(ap, fu8_t *); |
4519 iconcsumlen = va_arg(ap, int); | |
4804 | 4520 icon = va_arg(ap, fu8_t *); |
4521 iconlen = va_arg(ap, int); | |
4522 va_end(ap); | |
4523 | |
4853 | 4524 if (iconlen > 0) { |
4525 char *b16; | |
6695 | 4526 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4527 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4528 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4529 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4530 if (b16) { |
7693 | 4531 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4532 g_free(b16); |
5129 | 4533 } |
4853 | 4534 } |
4804 | 4535 |
4536 cur = od->requesticon; | |
4537 while (cur) { | |
4538 char *cursn = cur->data; | |
4539 if (!aim_sncmp(cursn, sn)) { | |
4540 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4541 free(cursn); | |
4542 cur = od->requesticon; | |
4543 } else | |
4544 cur = cur->next; | |
4545 } | |
4546 | |
4547 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4548 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4549 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4550 |
4551 return 1; | |
4552 } | |
4553 | |
4554 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4555 GaimConnection *gc = data; |
7283 | 4556 OscarData *od = gc->proto_data; |
7011 | 4557 aim_userinfo_t *userinfo; |
4804 | 4558 aim_conn_t *conn; |
4559 | |
4560 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4561 if (!conn) { |
4562 if (!od->iconconnecting) { | |
4563 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4564 od->iconconnecting = TRUE; | |
4565 } | |
4804 | 4566 return FALSE; |
4567 } | |
4568 | |
5842 | 4569 if (od->set_icon) { |
6039 | 4570 struct stat st; |
4571 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4572 if (iconfile == NULL) { | |
8363 | 4573 aim_ssi_delicon(od->sess); |
6039 | 4574 } else if (!stat(iconfile, &st)) { |
4575 char *buf = g_malloc(st.st_size); | |
4576 FILE *file = fopen(iconfile, "rb"); | |
4577 if (file) { | |
9532 | 4578 /* XXX - Use g_file_get_contents()? */ |
6039 | 4579 fread(buf, 1, st.st_size, file); |
4580 fclose(file); | |
8660 | 4581 gaim_debug_info("oscar", |
6039 | 4582 "Uploading icon to icon server\n"); |
6879 | 4583 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4584 } else |
8660 | 4585 gaim_debug_error("oscar", |
6039 | 4586 "Can't open buddy icon file!\n"); |
4587 g_free(buf); | |
4588 } else { | |
8660 | 4589 gaim_debug_error("oscar", |
6039 | 4590 "Can't stat buddy icon file!\n"); |
5842 | 4591 } |
4592 od->set_icon = FALSE; | |
4593 } | |
4594 | |
4595 if (!od->requesticon) { | |
8660 | 4596 gaim_debug_misc("oscar", |
5842 | 4597 "no more icons to request\n"); |
4598 return FALSE; | |
4599 } | |
4600 | |
7045 | 4601 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4602 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4603 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4604 return FALSE; |
4605 } else { | |
4606 char *sn = od->requesticon->data; | |
4607 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4608 free(sn); | |
4609 } | |
4610 | |
4611 return TRUE; | |
4612 } | |
4613 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4614 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4615 * 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
|
4616 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4617 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4618 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4619 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4620 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4621 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4622 va_start(ap, fr); |
4199 | 4623 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4624 sn = va_arg(ap, char *); |
4625 va_end(ap); | |
4626 | |
8660 | 4627 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4628 |
4629 return 1; | |
4630 } | |
4631 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4632 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
|
4633 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4634 "invalid", |
4194 | 4635 "change", |
4636 "warning", | |
4637 "limit", | |
4638 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4639 }; |
2086 | 4640 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4641 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4642 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4643 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4644 va_start(ap, fr); |
4200 | 4645 code = (fu16_t)va_arg(ap, unsigned int); |
4646 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4647 windowsize = va_arg(ap, fu32_t); | |
4648 clear = va_arg(ap, fu32_t); | |
4649 alert = va_arg(ap, fu32_t); | |
4650 limit = va_arg(ap, fu32_t); | |
4651 disconnect = va_arg(ap, fu32_t); | |
4652 currentavg = va_arg(ap, fu32_t); | |
4653 maxavg = va_arg(ap, fu32_t); | |
2086 | 4654 va_end(ap); |
4655 | |
8660 | 4656 gaim_debug_misc("oscar", |
5556 | 4657 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4658 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4659 (code < 5) ? codes[code] : codes[0], |
4660 rateclass, | |
4661 currentavg, maxavg, | |
4662 alert, clear, | |
4663 limit, disconnect, | |
4664 windowsize); | |
4665 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4666 /* XXX fix these values */ |
2086 | 4667 if (code == AIM_RATE_CODE_CHANGE) { |
4668 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4669 aim_conn_setlatency(fr->conn, 0); |
2086 | 4670 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4671 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4672 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4673 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4674 _("The last action you attempted could not be " |
4675 "performed because you are over the rate limit. " | |
4676 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4677 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4678 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4679 aim_conn_setlatency(fr->conn, 0); |
2086 | 4680 } |
4681 | |
4682 return 1; | |
4683 } | |
4684 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4685 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4686 GaimConnection *gc = sess->aux_data; |
4687 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4688 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4689 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4690 aim_userinfo_t *userinfo; |
2086 | 4691 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4692 va_start(ap, fr); |
4199 | 4693 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4694 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4695 va_end(ap); |
4696 | |
9982 | 4697 /* XXX - What's with the + 0.5? */ |
4698 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4699 |
4700 return 1; | |
4701 } | |
4702 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4703 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4704 GaimConnection *gc = sess->aux_data; |
4705 GaimAccount *account = gaim_connection_get_account(gc); | |
4706 int warning_level; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4707 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4708 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4709 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4710 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4711 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4712 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4713 |
9982 | 4714 warning_level = info->warnlevel/10.0 + 0.5; |
4715 | |
4716 /* | |
4717 * XXX - Calling this is probably not good. We just want to set the | |
4718 * warning level for our account, not tell the user that we were just | |
4719 * warned. | |
4720 */ | |
4721 gaim_prpl_got_account_warning_level(account, NULL, warning_level); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4722 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4723 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4724 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4725 |
4649 | 4726 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4727 GaimConnection *gc = sess->aux_data; |
7283 | 4728 OscarData *od = gc->proto_data; |
4649 | 4729 va_list ap; |
4730 fu16_t code; | |
4731 char *msg; | |
4732 | |
4733 va_start(ap, fr); | |
4734 code = (fu16_t)va_arg(ap, int); | |
4735 msg = va_arg(ap, char *); | |
4736 va_end(ap); | |
4737 | |
8660 | 4738 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4739 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4740 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4741 if (code == 0x0001) { |
6113 | 4742 gc->wants_to_die = TRUE; |
5579 | 4743 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4744 } else { |
5579 | 4745 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4746 } |
4666 | 4747 od->killme = TRUE; |
4649 | 4748 } |
4749 | |
4750 return 1; | |
4751 } | |
4752 | |
2675 | 4753 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4754 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4755 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4756 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4757 |
4758 #ifndef NOSSI | |
8660 | 4759 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4760 aim_ssi_reqrights(sess); |
6350 | 4761 aim_ssi_reqdata(sess); |
4230 | 4762 #endif |
4763 | |
7011 | 4764 aim_locate_reqrights(sess); |
7285 | 4765 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4766 aim_im_reqparams(sess); |
7334 | 4767 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4768 |
4769 #ifdef NOSSI | |
8660 | 4770 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4771 aim_bos_reqrights(sess, fr->conn); |
4230 | 4772 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4773 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4774 #endif | |
2086 | 4775 |
7283 | 4776 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4777 | |
2086 | 4778 return 1; |
4779 } | |
4780 | |
2675 | 4781 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4782 GaimConnection *gc = sess->aux_data; |
7283 | 4783 OscarData *od = gc->proto_data; |
2647 | 4784 |
6905 | 4785 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4786 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4787 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4788 | |
2672 | 4789 aim_clientready(sess, fr->conn); |
8660 | 4790 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4791 |
2647 | 4792 if (od->chpass) { |
8660 | 4793 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4794 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4795 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4796 od->oldp = NULL; |
2647 | 4797 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4798 od->newp = NULL; |
2647 | 4799 od->chpass = FALSE; |
4800 } | |
2979 | 4801 if (od->setnick) { |
8660 | 4802 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4803 aim_admin_setnick(sess, fr->conn, od->newsn); |
4804 g_free(od->newsn); | |
4805 od->newsn = NULL; | |
4806 od->setnick = FALSE; | |
4807 } | |
2647 | 4808 if (od->conf) { |
8660 | 4809 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4810 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4811 od->conf = FALSE; |
4812 } | |
4813 if (od->reqemail) { | |
8660 | 4814 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4815 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4816 od->reqemail = FALSE; |
4817 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4818 if (od->setemail) { |
8660 | 4819 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4820 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4821 g_free(od->email); |
5497 | 4822 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4823 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4824 } |
2647 | 4825 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4826 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4827 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4828 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4829 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
|
4830 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4831 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4832 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4833 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4834 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4835 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4836 |
4194 | 4837 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4838 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4839 "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
|
4840 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4841 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4842 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4843 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4844 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4845 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4846 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4847 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4848 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4849 |
4617 | 4850 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4851 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4852 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4853 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4854 |
2993 | 4855 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4856 { | |
5575 | 4857 GaimConnection *gc = sess->aux_data; |
7283 | 4858 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4859 va_list ap; |
4860 fu16_t maxsiglen; | |
2993 | 4861 |
4862 va_start(ap, fr); | |
4199 | 4863 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4864 va_end(ap); |
4865 | |
8660 | 4866 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4867 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4868 |
4617 | 4869 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4870 | |
4871 if (od->icq) | |
7334 | 4872 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4873 else |
7334 | 4874 aim_locate_setcaps(od->sess, caps_aim); |
4875 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4876 |
4877 return 1; | |
4878 } | |
4879 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4880 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
|
4881 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4882 fu16_t maxbuddies, maxwatchers; |
5575 | 4883 GaimConnection *gc = sess->aux_data; |
7283 | 4884 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4885 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4886 va_start(ap, fr); |
4199 | 4887 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4888 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4889 va_end(ap); |
4890 | |
8660 | 4891 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4892 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4893 |
4617 | 4894 od->rights.maxbuddies = (guint)maxbuddies; |
4895 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4896 |
2086 | 4897 return 1; |
4898 } | |
4899 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4900 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4901 GaimConnection *gc = sess->aux_data; |
7283 | 4902 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4903 va_list ap; |
4904 fu16_t maxpermits, maxdenies; | |
2086 | 4905 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4906 va_start(ap, fr); |
4199 | 4907 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4908 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4909 va_end(ap); |
4910 | |
8660 | 4911 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4912 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4913 |
4617 | 4914 od->rights.maxpermits = (guint)maxpermits; |
4915 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4916 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4917 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4918 serv_finish_login(gc); |
4919 | |
8660 | 4920 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4921 |
2672 | 4922 aim_clientready(sess, fr->conn); |
5948 | 4923 aim_srv_setavailmsg(sess, NULL); |
7474 | 4924 aim_srv_setidle(sess, 0); |
4617 | 4925 |
4664 | 4926 if (od->icq) { |
4927 aim_icq_reqofflinemsgs(sess); | |
4928 aim_icq_hideip(sess); | |
4929 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4930 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4931 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4932 if (sess->authinfo->email) |
4933 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4934 |
4935 return 1; | |
4936 } | |
4937 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4938 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
|
4939 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4940 struct aim_icq_offlinemsg *msg; |
4075 | 4941 struct aim_incomingim_ch4_args args; |
4942 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4943 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4944 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4945 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4946 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4947 |
8660 | 4948 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4949 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4950 args.uin = msg->sender; |
4951 args.type = msg->type; | |
4173 | 4952 args.flags = msg->flags; |
4076 | 4953 args.msglen = msg->msglen; |
4075 | 4954 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4955 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4956 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4957 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4958 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4959 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4960 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4961 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
|
4962 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4963 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4964 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4965 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4966 |
7388 | 4967 #if 0 |
4968 /* | |
7465 | 4969 * Update, 2003-11-09: |
4970 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4971 * | |
7388 | 4972 * It may not be my place to do this, but... |
4973 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4974 * stupid, and should not exist for % switches (%x in our case) that request | |
4975 * a year in the preferred representation for the current locale. For that | |
4976 * reason I've chosen to not use this workaround (n., see kluge). | |
4977 * | |
4978 * I have a date. I want to show it to the user in the "preferred" way. | |
4979 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4980 * what the locale wanted. | |
4981 * | |
4982 * If I have a necessity for a full representation of the year in the current | |
4983 * locale, then I'll use a switch that returns a full representation of the | |
4984 * year. | |
4985 * | |
4986 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4987 * (because you're anal, or whatever), then change the f***ing locale. | |
4988 * | |
4989 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4990 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4991 * |
4992 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4993 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4994 */ |
4995 | |
4996 /* | |
4997 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4998 * "last 2 digits" warning. |
4999 */ | |
5000 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
5001 const struct tm *tm) | |
5002 { | |
5003 return strftime(s, max, fmt, tm); | |
5004 } | |
7388 | 5005 #endif |
7386 | 5006 |
4624 | 5007 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
|
5008 { |
5575 | 5009 GaimConnection *gc = sess->aux_data; |
8670 | 5010 OscarData *od = (OscarData *)gc->proto_data; |
5011 GaimBuddy *buddy; | |
8853 | 5012 struct buddyinfo *bi = NULL; |
4624 | 5013 gchar who[16]; |
8670 | 5014 GString *str; |
5015 gchar *primary, *utf8; | |
9634 | 5016 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5017 va_list ap; |
4151 | 5018 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5019 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5020 va_start(ap, fr); |
4151 | 5021 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5022 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5023 |
4664 | 5024 if (!info->uin) |
5025 return 0; | |
5026 | |
8670 | 5027 str = g_string_sized_new(100); |
5556 | 5028 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5029 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5030 if (buddy != NULL) | |
5031 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5032 | |
5033 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5034 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5035 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5036 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5037 (bi->ipaddr & 0xff000000) >> 24, | |
5038 (bi->ipaddr & 0x00ff0000) >> 16, | |
5039 (bi->ipaddr & 0x0000ff00) >> 8, | |
5040 (bi->ipaddr & 0x000000ff)); | |
8701 | 5041 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5042 g_free(tstr); |
5043 } | |
8701 | 5044 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5045 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5046 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5047 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5048 g_free(utf8); | |
4625 | 5049 } |
5050 if (info->numaddresses && info->email2) { | |
5051 int i; | |
5052 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5053 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5054 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5055 g_free(utf8); | |
4643 | 5056 } |
4625 | 5057 } |
4624 | 5058 } |
8701 | 5059 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5060 if (info->gender != 0) |
5061 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5062 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5063 char date[30]; |
5064 struct tm tm; | |
5065 tm.tm_mday = (int)info->birthday; | |
5066 tm.tm_mon = (int)info->birthmonth-1; | |
5067 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5068 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5069 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5070 } |
4624 | 5071 if (info->age) { |
5072 char age[5]; | |
5073 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5074 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5075 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5076 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5077 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5078 g_free(utf8); | |
4819 | 5079 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5080 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5081 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5082 g_free(utf8); | |
5083 } | |
5084 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5085 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5086 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5087 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5088 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5089 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5090 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5091 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5092 } |
4641 | 5093 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5094 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5095 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5096 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5097 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5098 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5099 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5100 } |
4641 | 5101 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5102 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5103 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5104 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5105 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5106 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5107 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5108 g_free(utf8); | |
4624 | 5109 } |
8670 | 5110 g_string_append_printf(str, "\n<hr>\n"); |
5111 } | |
5112 | |
9634 | 5113 if (buddy != NULL) |
5114 alias = gaim_buddy_get_alias(buddy); | |
5115 else | |
5116 alias = who; | |
5117 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5118 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5119 g_free(primary); |
8670 | 5120 g_string_free(str, TRUE); |
4151 | 5121 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5122 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5123 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5124 |
4759 | 5125 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5126 { | |
5575 | 5127 GaimConnection *gc = sess->aux_data; |
4820 | 5128 gchar who[16], *utf8; |
6695 | 5129 GaimBuddy *b; |
4759 | 5130 va_list ap; |
5131 struct aim_icq_info *info; | |
5132 | |
5133 va_start(ap, fr); | |
5134 info = va_arg(ap, struct aim_icq_info *); | |
5135 va_end(ap); | |
5136 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5137 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5138 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5139 serv_got_alias(gc, who, utf8); |
4759 | 5140 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5141 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5142 } |
4820 | 5143 g_free(utf8); |
4759 | 5144 } |
5145 | |
5146 return 1; | |
5147 } | |
5148 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5149 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
|
5150 { |
7032 | 5151 GaimConnection *gc = sess->aux_data; |
5152 gchar *text; | |
5153 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5154 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5155 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5156 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5157 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5158 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5159 url = va_arg(ap, char *); |
4199 | 5160 wid = (fu16_t) va_arg(ap, int); |
5161 hei = (fu16_t) va_arg(ap, int); | |
5162 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5163 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5164 |
7032 | 5165 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5166 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5167 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5168 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5169 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5170 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5171 |
7032 | 5172 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5173 { | |
6873 | 5174 GaimConnection *gc = sess->aux_data; |
5175 gchar *secondary; | |
5176 GString *text; | |
5177 int i, num; | |
2086 | 5178 va_list ap; |
6873 | 5179 char *email, *SNs; |
2086 | 5180 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5181 va_start(ap, fr); |
6873 | 5182 email = va_arg(ap, char *); |
2086 | 5183 num = va_arg(ap, int); |
5184 SNs = va_arg(ap, char *); | |
5185 va_end(ap); | |
5186 | |
8152 | 5187 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5188 text = g_string_new(""); |
2086 | 5189 for (i = 0; i < num; i++) |
6873 | 5190 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5191 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5192 | |
5193 g_free(secondary); | |
5194 g_string_free(text, TRUE); | |
2086 | 5195 |
5196 return 1; | |
5197 } | |
5198 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5199 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5200 va_list ap; |
6873 | 5201 char *email; |
5420 | 5202 char *buf; |
2086 | 5203 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5204 va_start(ap, fr); |
6873 | 5205 email = va_arg(ap, char *); |
2086 | 5206 va_end(ap); |
5207 | |
6873 | 5208 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
|
5209 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5210 g_free(buf); |
2086 | 5211 |
5212 return 1; | |
5213 } | |
5214 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5215 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5216 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5217 fu16_t status; |
2086 | 5218 va_list ap; |
5219 char msg[256]; | |
5220 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5221 va_start(ap, fr); |
4199 | 5222 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5223 va_end(ap); |
5224 | |
8660 | 5225 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5226 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5227 status ? "unknown" : "email sent"); |
5228 if (!status) { | |
5302 | 5229 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5230 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5231 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5232 } |
5233 | |
5234 return 1; | |
5235 } | |
5236 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5237 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5238 GaimConnection *gc = sess->aux_data; |
2086 | 5239 va_list ap; |
3912 | 5240 fu16_t perms, err; |
5241 char *url, *sn, *email; | |
5242 int change; | |
2086 | 5243 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5244 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5245 change = va_arg(ap, int); |
4199 | 5246 perms = (fu16_t) va_arg(ap, unsigned int); |
5247 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5248 url = va_arg(ap, char *); |
5249 sn = va_arg(ap, char *); | |
5250 email = va_arg(ap, char *); | |
2086 | 5251 va_end(ap); |
5252 | |
8660 | 5253 gaim_debug_misc("oscar", |
9626 | 5254 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5255 change ? "change" : "request", perms, err, | |
5256 (url != NULL) ? url : "(null)", | |
5257 (sn != NULL) ? sn : "(null)", | |
5258 (email != NULL) ? email : "(null)"); | |
5259 | |
5260 if ((err > 0) && (url != NULL)) { | |
3912 | 5261 char *dialog_msg; |
5262 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5263 switch (err) { | |
5264 case 0x0001: { | |
5265 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5266 } break; | |
5267 case 0x0006: { | |
5268 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5269 } break; | |
5270 case 0x000b: { | |
5271 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5272 } break; | |
5273 case 0x001d: { | |
5274 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); | |
5275 } break; | |
5276 case 0x0021: { | |
5277 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); | |
5278 } break; | |
5279 case 0x0023: { | |
5280 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5281 } break; | |
5282 default: { | |
5283 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5284 } break; | |
5285 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5286 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5287 g_free(dialog_top); |
5288 g_free(dialog_msg); | |
5289 return 1; | |
5290 } | |
5291 | |
9626 | 5292 if (sn != NULL) { |
4585 | 5293 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
|
5294 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5295 g_free(dialog_msg); |
5296 } | |
5297 | |
9626 | 5298 if (email != NULL) { |
5575 | 5299 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5300 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5301 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5302 g_free(dialog_msg); |
2086 | 5303 } |
5304 | |
5305 return 1; | |
5306 } | |
5307 | |
5575 | 5308 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5309 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5310 aim_flap_nop(od->sess, od->conn); |
2086 | 5311 } |
5312 | |
6059 | 5313 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5314 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5315 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5316 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5317 if (typing == GAIM_TYPING) |
4870 | 5318 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5319 else if (typing == GAIM_TYPED) |
4870 | 5320 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5321 else | |
5322 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5323 else { |
5300 | 5324 /* Don't send if this turkey is in our deny list */ |
5325 GSList *list; | |
5326 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5327 if (!list) { | |
7261 | 5328 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5329 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5330 if (typing == GAIM_TYPING) |
5300 | 5331 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5332 else if (typing == GAIM_TYPED) |
5300 | 5333 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5334 else | |
5335 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5336 } | |
3595 | 5337 } |
5338 } | |
2993 | 5339 return 0; |
5340 } | |
9030 | 5341 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5342 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimConvImFlags); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5343 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5344 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5345 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5346 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
|
5347 int ret = 0; |
5575 | 5348 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5349 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5350 |
4838 | 5351 if (dim && dim->connected) { |
5352 /* If we're directly connected, send a direct IM */ | |
6982 | 5353 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5354 } else { |
4738 | 5355 struct buddyinfo *bi; |
3008 | 5356 struct aim_sendimext_args args; |
5357 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5358 gsize len; |
8962 | 5359 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5360 | |
5361 if (strstr(message, "<IMG ")) | |
5362 gaim_conversation_write(conv, "", | |
5363 _("Your IM Image was not sent. " | |
5364 "You must be Direct Connected to send IM Images."), | |
5365 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5366 |
7261 | 5367 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5368 if (!bi) { |
5369 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5370 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5371 } |
5372 | |
3008 | 5373 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5374 if (od->icq) { |
5375 args.features = features_icq; | |
5376 args.featureslen = sizeof(features_icq); | |
3008 | 5377 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5378 } else { |
5379 args.features = features_aim; | |
5380 args.featureslen = sizeof(features_aim); | |
4972 | 5381 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5382 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5383 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5384 } |
4269 | 5385 |
4738 | 5386 if (bi->ico_need) { |
8660 | 5387 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5388 "Sending buddy icon request with message\n"); |
3008 | 5389 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5390 bi->ico_need = FALSE; |
3008 | 5391 } |
4269 | 5392 |
5575 | 5393 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5394 FILE *file = fopen(iconfile, "rb"); |
3008 | 5395 if (file) { |
5396 char *buf = g_malloc(st.st_size); | |
9532 | 5397 /* XXX - Use g_file_get_contents()? */ |
3008 | 5398 fread(buf, 1, st.st_size, file); |
6039 | 5399 fclose(file); |
4269 | 5400 |
3008 | 5401 args.iconlen = st.st_size; |
4617 | 5402 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5403 args.iconstamp = st.st_mtime; |
5404 | |
7406 | 5405 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5406 bi->ico_informed = FALSE; |
7406 | 5407 bi->ico_sent = FALSE; |
5408 } | |
4738 | 5409 |
5410 if (!bi->ico_informed) { | |
8660 | 5411 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5412 "Claiming to have a buddy icon\n"); |
4738 | 5413 args.flags |= AIM_IMFLAGS_HASICON; |
5414 bi->ico_me_len = args.iconlen; | |
5415 bi->ico_me_csum = args.iconsum; | |
5416 bi->ico_me_time = args.iconstamp; | |
5417 bi->ico_informed = TRUE; | |
5418 } | |
5419 | |
3008 | 5420 g_free(buf); |
2086 | 5421 } |
5422 } | |
4269 | 5423 |
3008 | 5424 args.destsn = name; |
4269 | 5425 |
8985 | 5426 /* |
5427 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5428 * strip all HTML | |
5429 */ | |
9975 | 5430 if (aim_sn_is_icq(name) ) { |
8995 | 5431 /* being sent to an ICQ user */ |
9975 | 5432 if (!aim_sn_is_icq(gaim_account_get_username(gc->account))) { |
8995 | 5433 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5434 tmpmsg = gaim_str_add_cr(message); | |
5435 } else { | |
5436 /* from an ICQ user - do nothing */ | |
5437 tmpmsg = g_strdup(message); | |
5438 } | |
5439 } else { | |
5440 /* being sent to an AIM user */ | |
9975 | 5441 if (aim_sn_is_icq(gaim_account_get_username(gc->account))) { |
8995 | 5442 /* from an ICQ user */ |
5443 tmpmsg2 = gaim_strdup_withhtml(message); | |
5444 tmpmsg = gaim_escape_html(tmpmsg2); | |
5445 g_free(tmpmsg2); | |
5446 } else | |
5447 tmpmsg = gaim_strdup_withhtml(message); | |
5448 } | |
6310 | 5449 len = strlen(tmpmsg); |
5450 | |
9830 | 5451 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5452 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5453 args.charset, args.charsubset, args.msglen); | |
4617 | 5454 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5455 g_free((char *)args.msg); |
2086 | 5456 } |
4838 | 5457 |
6310 | 5458 g_free(tmpmsg); |
5459 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5460 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5461 return 1; |
6310 | 5462 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5463 return ret; |
2086 | 5464 } |
5465 | |
7011 | 5466 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5467 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5468 |
9975 | 5469 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5470 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5471 else |
7235 | 5472 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5473 } |
5474 | |
8950 | 5475 #if 0 |
7011 | 5476 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5477 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5478 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5479 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5480 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5481 maiden, NULL, NULL, city, state, NULL, 0, web); |
5482 } | |
8950 | 5483 #endif |
2086 | 5484 |
5575 | 5485 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5486 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5487 aim_srv_setidle(od->sess, time); |
2086 | 5488 } |
5489 | |
5954 | 5490 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5491 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5492 int charset = 0; |
6019 | 5493 char *text_html = NULL; |
5129 | 5494 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5495 gsize msglen = 0; |
2993 | 5496 |
4617 | 5497 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5498 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5499 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5500 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5501 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5502 "again when you are fully connected.")); |
4617 | 5503 |
7334 | 5504 if (!text) { |
5505 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5506 return; | |
5507 } | |
10097 | 5508 |
7334 | 5509 text_html = gaim_strdup_withhtml(text); |
9807 | 5510 charset = oscar_charset_check(text_html); |
9826 | 5511 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5512 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5513 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5514 g_free(msg); | |
9826 | 5515 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5516 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5517 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5518 g_free(msg); | |
5519 } else { | |
5520 msglen = strlen(text_html); | |
5521 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5522 } | |
5523 | |
5524 if (msglen > od->rights.maxsiglen) { | |
5525 gchar *errstr; | |
5526 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5527 "has been exceeded. Gaim has truncated it for you.", | |
5528 "The maximum profile length of %d bytes " | |
5529 "has been exceeded. Gaim has truncated it for you.", | |
5530 od->rights.maxsiglen), od->rights.maxsiglen); | |
5531 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5532 g_free(errstr); | |
5533 } | |
5534 | |
5535 g_free(text_html); | |
2993 | 5536 |
5537 return; | |
2086 | 5538 } |
5539 | |
9991 | 5540 static void |
5541 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5542 { |
9991 | 5543 GaimConnection *gc = gaim_account_get_connection(account); |
5544 OscarData *od = (OscarData *)gc->proto_data; | |
9992 | 5545 GaimStatusType *status_type; |
9991 | 5546 GaimStatusPrimitive primitive; |
5547 GaimPresence *presence; | |
5548 const gchar *status_id; | |
9807 | 5549 int charset = 0; |
6019 | 5550 gchar *text_html = NULL; |
5129 | 5551 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5552 gsize msglen = 0; |
2993 | 5553 |
9992 | 5554 status_type = gaim_status_get_type(status); |
5555 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5556 status_id = gaim_status_get_id(status); |
5557 presence = gaim_account_get_presence(account); | |
5558 | |
5559 if (primitive == GAIM_STATUS_HIDDEN) | |
8257 | 5560 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5561 else |
5562 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5563 | |
8476 | 5564 |
8257 | 5565 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5566 | |
2993 | 5567 if (od->rights.maxawaymsglen == 0) |
9991 | 5568 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5569 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5570 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5571 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5572 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5573 "fully connected.")); |
5129 | 5574 |
9992 | 5575 if (primitive == GAIM_STATUS_AVAILABLE) { |
7334 | 5576 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
9995 | 5577 #if 0 |
5578 /* Set an available message */ | |
5579 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); | |
5580 aim_srv_setavailmsg(od->sess, text); | |
5581 #endif | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5582 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5583 } |
9995 | 5584 |
5585 /* | |
5586 * XXX - Using status_id below is definitely wrong. We want to get | |
5587 * the away message that the Gaim user just set. We probably want | |
5588 * to get a certain attribute from status->attr_values, but I don't | |
5589 * think any of that is implemented yet. | |
5590 * | |
5591 * Something like | |
5592 * text_html = gaim_status_get_attr_string(status, "message"); | |
5593 */ | |
5594 status_id = gaim_status_get_name(status); | |
9991 | 5595 text_html = gaim_strdup_withhtml(status_id); |
5596 | |
9807 | 5597 charset = oscar_charset_check(text_html); |
9826 | 5598 if (charset == AIM_CHARSET_UNICODE) { |
6019 | 5599 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5600 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5601 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5602 g_free(msg); |
9826 | 5603 } else if (charset == AIM_CHARSET_CUSTOM) { |
6019 | 5604 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5605 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5606 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5607 g_free(msg); |
5608 } else { | |
6019 | 5609 msglen = strlen(text_html); |
7011 | 5610 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5611 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5612 } |
5613 | |
5614 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5615 gchar *errstr; |
5616 | |
6308 | 5617 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5618 "has been exceeded. Gaim has truncated it for you.", | |
5619 "The maximum away message length of %d bytes " | |
5620 "has been exceeded. Gaim has truncated it for you.", | |
5621 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5622 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5623 g_free(errstr); |
5624 } | |
10097 | 5625 |
6019 | 5626 g_free(text_html); |
8257 | 5627 |
2993 | 5628 return; |
5629 } | |
5630 | |
9991 | 5631 static void |
5632 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5633 { |
9991 | 5634 GaimConnection *gc = gaim_account_get_connection(account); |
5635 OscarData *od = (OscarData *)gc->proto_data; | |
5636 const gchar *status_id = gaim_status_get_id(status); | |
5637 | |
5638 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) | |
5575 | 5639 account->perm_deny = 4; |
8265 | 5640 else |
5575 | 5641 account->perm_deny = 3; |
9991 | 5642 |
8265 | 5643 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5644 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5645 |
9991 | 5646 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5647 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5648 |
5649 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5650 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5651 |
5652 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5653 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5654 |
5655 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5656 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5657 |
5658 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5659 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5660 |
5661 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5662 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5663 |
5664 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5665 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5666 |
5667 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5668 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5669 |
5670 return; | |
5671 } | |
5672 | |
9991 | 5673 static void |
5674 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5675 { |
9991 | 5676 GaimConnection *gc = gaim_account_get_connection(account); |
5677 OscarData *od = (OscarData *)gc->proto_data; | |
2993 | 5678 |
5679 if (od->icq) | |
9988 | 5680 oscar_set_status_icq(account, status); |
2993 | 5681 else |
9988 | 5682 oscar_set_status_aim(account, status); |
2993 | 5683 |
5684 return; | |
2086 | 5685 } |
5686 | |
9991 | 5687 static void |
5688 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5689 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5690 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5691 } |
5692 | |
9285 | 5693 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5694 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5695 |
5696 if (!aim_snvalid(buddy->name)) { | |
8092 | 5697 gchar *buf; |
9285 | 5698 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 | 5699 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5700 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5701 g_free(buf); |
8150 | 5702 |
5703 /* Remove from local list */ | |
9285 | 5704 gaim_blist_remove_buddy(buddy); |
8150 | 5705 |
8092 | 5706 return; |
5707 } | |
5708 | |
4230 | 5709 #ifdef NOSSI |
9285 | 5710 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5711 #else |
9285 | 5712 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5713 if (buddy && group) { | |
8660 | 5714 gaim_debug_info("oscar", |
9285 | 5715 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5716 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5717 } |
5718 } | |
5719 #endif | |
8150 | 5720 |
4759 | 5721 if (od->icq) |
9285 | 5722 aim_icq_getalias(od->sess, buddy->name); |
5723 } | |
5724 | |
5725 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5726 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5727 #ifdef NOSSI |
5728 char buf[MSG_LEN]; | |
5729 int n=0; | |
9285 | 5730 |
4230 | 5731 while (buddies) { |
9381 | 5732 GaimBuddy *buddy = buddies->data; |
4230 | 5733 if (n > MSG_LEN - 18) { |
7285 | 5734 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5735 n = 0; |
3092 | 5736 } |
9381 | 5737 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5738 buddies = buddies->next; |
5739 } | |
7285 | 5740 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5741 #else |
9285 | 5742 |
4230 | 5743 if (od->sess->ssi.received_data) { |
9285 | 5744 GList *curb = buddies; |
5745 GList *curg = groups; | |
5746 while ((curb != NULL) && (curg != NULL)) { | |
5747 GaimBuddy *buddy = curb->data; | |
5748 GaimGroup *group = curg->data; | |
5749 oscar_add_buddy(gc, buddy, group); | |
5750 curb = curb->next; | |
5751 curg = curg->next; | |
4230 | 5752 } |
5753 } | |
5754 #endif | |
5755 } | |
5756 | |
9285 | 5757 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5758 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5759 |
4230 | 5760 #ifdef NOSSI |
9285 | 5761 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5762 #else |
5763 if (od->sess->ssi.received_data) { | |
8660 | 5764 gaim_debug_info("oscar", |
9285 | 5765 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5766 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5767 } |
5768 #endif | |
5769 } | |
5770 | |
9285 | 5771 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5772 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5773 |
4230 | 5774 #ifdef NOSSI |
9285 | 5775 for (cur = buddies; cur != NULL; cur = cur->next) { |
5776 GaimBuddy *buddy = cur->data; | |
5777 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5778 } | |
4230 | 5779 #else |
5780 if (od->sess->ssi.received_data) { | |
9285 | 5781 GList *curb = buddies; |
5782 GList *curg = groups; | |
5783 while ((curb != NULL) && (curg != NULL)) { | |
5784 GaimBuddy *buddy = curb->data; | |
5785 GaimGroup *group = curg->data; | |
5786 oscar_remove_buddy(gc, buddy, group); | |
5787 curb = curb->next; | |
5788 curg = curg->next; | |
3092 | 5789 } |
4230 | 5790 } |
5791 #endif | |
5792 } | |
5793 | |
5794 #ifndef NOSSI | |
5575 | 5795 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5796 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5797 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5798 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5799 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5800 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5801 } |
5802 } | |
5803 | |
5575 | 5804 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5805 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5806 if (od->sess->ssi.received_data) { |
5807 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5808 if (gname) { | |
8660 | 5809 gaim_debug_info("oscar", |
9586 | 5810 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5811 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5812 } |
5813 } | |
5814 } | |
5815 | |
9285 | 5816 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5817 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5818 |
5819 if (od->sess->ssi.received_data) { | |
9285 | 5820 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5821 GList *cur, *groups = NULL; | |
5822 | |
5823 /* Make a list of what the groups each buddy is in */ | |
5824 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5825 GaimBlistNode *node = cur->data; | |
5826 groups = g_list_append(groups, node->parent); | |
5827 } | |
5828 | |
5829 oscar_remove_buddies(gc, moved_buddies, groups); | |
5830 oscar_add_buddies(gc, moved_buddies, groups); | |
5831 g_list_free(groups); | |
8660 | 5832 gaim_debug_info("oscar", |
9285 | 5833 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5834 } else { |
9285 | 5835 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5836 gaim_debug_info("oscar", |
9285 | 5837 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5838 } |
5839 } | |
5840 } | |
5841 | |
5968 | 5842 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5843 aim_session_t *sess = data; | |
6350 | 5844 aim_ssi_reqdata(sess); |
5968 | 5845 return FALSE; |
5846 } | |
5847 | |
4642 | 5848 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5849 GaimConnection *gc = sess->aux_data; |
7283 | 5850 OscarData *od = gc->proto_data; |
4642 | 5851 va_list ap; |
5852 fu16_t reason; | |
5853 | |
5854 va_start(ap, fr); | |
5855 reason = (fu16_t)va_arg(ap, unsigned int); | |
5856 va_end(ap); | |
5857 | |
8660 | 5858 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5859 |
5860 if (reason == 0x0005) { | |
5892 | 5861 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5862 _("Gaim was temporarily unable to retrieve your buddy list from the AIM servers. Your buddy list is not lost, and will probably become available in a few hours.")); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5863 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5864 } |
5865 | |
5866 /* Activate SSI */ | |
5867 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5868 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5869 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5870 aim_ssi_enable(od->sess); |
5871 | |
5872 return 1; | |
5873 } | |
5874 | |
2991 | 5875 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5876 GaimConnection *gc = sess->aux_data; |
7283 | 5877 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 5878 int i; |
5879 va_list ap; | |
5880 int numtypes; | |
4230 | 5881 fu16_t *maxitems; |
2991 | 5882 |
5883 va_start(ap, fr); | |
4230 | 5884 numtypes = va_arg(ap, int); |
5885 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5886 va_end(ap); |
5887 | |
8660 | 5888 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5889 |
4230 | 5890 for (i=0; i<numtypes; i++) |
8660 | 5891 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5892 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5893 |
8660 | 5894 gaim_debug_misc(NULL, "\n"); |
4230 | 5895 |
5896 if (numtypes >= 0) | |
5897 od->rights.maxbuddies = maxitems[0]; | |
5898 if (numtypes >= 1) | |
5899 od->rights.maxgroups = maxitems[1]; | |
5900 if (numtypes >= 2) | |
5901 od->rights.maxpermits = maxitems[2]; | |
5902 if (numtypes >= 3) | |
5903 od->rights.maxdenies = maxitems[3]; | |
2991 | 5904 |
5905 return 1; | |
5906 } | |
5907 | |
5908 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5909 GaimConnection *gc = sess->aux_data; |
5910 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 5911 GaimStatus *status; |
7283 | 5912 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5913 GaimGroup *g; |
5914 GaimBuddy *b; | |
2995 | 5915 struct aim_ssi_item *curitem; |
2991 | 5916 int tmp; |
4230 | 5917 va_list ap; |
8219 | 5918 fu16_t fmtver, numitems; |
5919 struct aim_ssi_item *items; | |
5920 fu32_t timestamp; | |
4230 | 5921 |
5922 va_start(ap, fr); | |
5923 fmtver = (fu16_t)va_arg(ap, int); | |
5924 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5925 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5926 timestamp = va_arg(ap, fu32_t); |
8219 | 5927 va_end(ap); |
2991 | 5928 |
8660 | 5929 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5930 "ssi: syncing local list and server list\n"); |
2991 | 5931 |
8219 | 5932 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5933 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 | 5934 return 1; |
5935 } | |
5936 | |
2991 | 5937 /* Clean the buddy list */ |
4889 | 5938 aim_ssi_cleanlist(sess); |
2991 | 5939 |
8150 | 5940 { /* If not in server list then prune from local list */ |
5941 GaimBlistNode *gnode, *cnode, *bnode; | |
5942 GaimBuddyList *blist; | |
9539 | 5943 GSList *cur, *next; |
8150 | 5944 |
5945 /* Buddies */ | |
5946 cur = NULL; | |
5947 if ((blist = gaim_get_blist()) != NULL) { | |
5948 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5949 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5950 continue; | |
5951 g = (GaimGroup *)gnode; | |
5952 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5953 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5954 continue; | |
5955 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5956 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5957 continue; | |
5958 b = (GaimBuddy *)bnode; | |
5959 if (b->account == gc->account) { | |
5960 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5961 /* If the buddy is an ICQ user then load his nickname */ | |
5962 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5963 char *alias; |
8150 | 5964 if (servernick) |
5965 serv_got_alias(gc, b->name, servernick); | |
5966 | |
5967 /* Store local alias on server */ | |
8214 | 5968 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5969 if (!alias && b->alias && strlen(b->alias)) |
5970 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5971 free(alias); | |
5972 } else { | |
8660 | 5973 gaim_debug_info("oscar", |
8150 | 5974 "ssi: removing buddy %s from local list\n", b->name); |
5975 /* We can't actually remove now because it will screw up our looping */ | |
5976 cur = g_slist_prepend(cur, b); | |
5977 } | |
5978 } | |
5979 } | |
5980 } | |
5981 } | |
5982 } | |
8175 | 5983 |
8150 | 5984 while (cur != NULL) { |
5985 b = cur->data; | |
5986 cur = g_slist_remove(cur, b); | |
5987 gaim_blist_remove_buddy(b); | |
5988 } | |
5989 | |
5990 /* Permit list */ | |
5991 if (gc->account->permit) { | |
9539 | 5992 next = gc->account->permit; |
5993 while (next != NULL) { | |
5994 cur = next; | |
5995 next = next->next; | |
8150 | 5996 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5997 gaim_debug_info("oscar", |
8150 | 5998 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5999 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6000 } | |
9539 | 6001 } |
8150 | 6002 } |
6003 | |
6004 /* Deny list */ | |
6005 if (gc->account->deny) { | |
9539 | 6006 next = gc->account->deny; |
6007 while (next != NULL) { | |
6008 cur = next; | |
6009 next = next->next; | |
8150 | 6010 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6011 gaim_debug_info("oscar", |
8150 | 6012 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6013 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6014 } | |
9539 | 6015 } |
8150 | 6016 } |
6017 /* Presence settings (idle time visibility) */ | |
6018 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6019 if (!(tmp & 0x400)) | |
6020 aim_ssi_setpresence(sess, tmp | 0x400); | |
6021 } /* end pruning buddies from local list */ | |
6022 | |
2991 | 6023 /* Add from server list to local list */ |
4230 | 6024 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6025 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6026 switch (curitem->type) { |
4230 | 6027 case 0x0000: { /* Buddy */ |
4251 | 6028 if (curitem->name) { |
4292 | 6029 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6030 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6031 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6032 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6033 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6034 /* Should gname be freed here? -- elb */ |
4754 | 6035 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6036 free(alias); |
8150 | 6037 if (b) { |
4292 | 6038 /* Get server stored alias */ |
4705 | 6039 if (alias_utf8) { |
8150 | 6040 g_free(b->alias); |
6041 b->alias = g_strdup(alias_utf8); | |
4705 | 6042 } |
4282 | 6043 } else { |
8150 | 6044 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6045 |
4754 | 6046 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6047 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6048 gaim_blist_add_group(g, NULL); |
6049 } | |
5146 | 6050 |
8660 | 6051 gaim_debug_info("oscar", |
9285 | 6052 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6053 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6054 } |
8341 | 6055 if (!aim_sncmp(curitem->name, account->username)) { |
6056 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6057 gaim_check_comment(od, comment); | |
6058 free(comment); | |
6059 } | |
7162 | 6060 g_free(gname_utf8); |
6061 g_free(alias_utf8); | |
2991 | 6062 } |
4230 | 6063 } break; |
6064 | |
6065 case 0x0001: { /* Group */ | |
4282 | 6066 /* Shouldn't add empty groups */ |
4230 | 6067 } break; |
6068 | |
6069 case 0x0002: { /* Permit buddy */ | |
2991 | 6070 if (curitem->name) { |
4230 | 6071 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6072 GSList *list; |
5575 | 6073 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6074 if (!list) { |
8660 | 6075 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6076 "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
|
6077 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6078 } |
6079 } | |
4230 | 6080 } break; |
6081 | |
6082 case 0x0003: { /* Deny buddy */ | |
2991 | 6083 if (curitem->name) { |
6084 GSList *list; | |
5575 | 6085 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6086 if (!list) { |
8660 | 6087 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6088 "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
|
6089 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6090 } |
6091 } | |
4230 | 6092 } break; |
6093 | |
6094 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6095 if (curitem->data) { |
6096 fu8_t permdeny; | |
5575 | 6097 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6098 gaim_debug_info("oscar", |
5575 | 6099 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6100 account->perm_deny = permdeny; | |
6101 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6102 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6103 } |
2991 | 6104 } |
6105 } | |
4230 | 6106 } break; |
6107 | |
6108 case 0x0005: { /* Presence setting */ | |
3109 | 6109 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6110 } break; |
2991 | 6111 } /* End of switch on curitem->type */ |
6112 } /* End of for loop */ | |
4230 | 6113 |
9991 | 6114 /* |
6115 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6116 * this. We probably want the SSI status setting to override the local | |
6117 * setting. | |
6118 */ | |
9982 | 6119 status = gaim_presence_get_active_status(account->presence); |
6120 if (gaim_status_is_available(status)) | |
4901 | 6121 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6122 | |
4342 | 6123 /* Activate SSI */ |
6124 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6125 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6126 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6127 "ssi: activating server-stored buddy list\n"); |
4642 | 6128 aim_ssi_enable(sess); |
4342 | 6129 |
2991 | 6130 return 1; |
2086 | 6131 } |
4230 | 6132 |
6133 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6134 GaimConnection *gc = sess->aux_data; |
4230 | 6135 va_list ap; |
6136 struct aim_ssi_tmp *retval; | |
6137 | |
6138 va_start(ap, fr); | |
6139 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6140 va_end(ap); | |
6141 | |
6142 while (retval) { | |
8660 | 6143 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6144 "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 | 6145 |
6146 if (retval->ack != 0xffff) | |
6147 switch (retval->ack) { | |
6148 case 0x0000: { /* added successfully */ | |
6149 } break; | |
6150 | |
4829 | 6151 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6152 gchar *buf; | |
6153 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 | 6154 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6155 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6156 g_free(buf); |
6157 } | |
6158 | |
7023 | 6159 case 0x000e: { /* buddy requires authorization */ |
4828 | 6160 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6161 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6162 } break; |
6163 | |
6164 default: { /* La la la */ | |
5197 | 6165 gchar *buf; |
8660 | 6166 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6167 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 | 6168 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6169 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6170 g_free(buf); |
4230 | 6171 } break; |
6172 } | |
6173 | |
6174 retval = retval->next; | |
6175 } | |
6176 | |
6177 return 1; | |
6178 } | |
6179 | |
8227 | 6180 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6181 GaimConnection *gc = sess->aux_data; | |
6182 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6183 GaimBuddy *b; | |
6184 GaimGroup *g; | |
6185 va_list ap; | |
6186 fu16_t type; | |
6187 const char *name; | |
6188 | |
6189 va_start(ap, fr); | |
6190 type = (fu16_t)va_arg(ap, int); | |
6191 name = va_arg(ap, char *); | |
6192 va_end(ap); | |
6193 | |
6194 if ((type != 0x0000) || (name == NULL)) | |
6195 return 1; | |
6196 | |
6197 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6198 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6199 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6200 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6201 b = gaim_find_buddy(gc->account, name); | |
6202 free(alias); | |
6203 | |
6204 if (b) { | |
6205 /* Get server stored alias */ | |
6206 if (alias_utf8) { | |
6207 g_free(b->alias); | |
6208 b->alias = g_strdup(alias_utf8); | |
6209 } | |
6210 } else { | |
6211 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6212 | |
6213 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6214 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6215 gaim_blist_add_group(g, NULL); | |
6216 } | |
6217 | |
8660 | 6218 gaim_debug_info("oscar", |
9285 | 6219 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6220 gaim_blist_add_buddy(b, NULL, g, NULL); |
6221 } | |
6222 g_free(gname_utf8); | |
6223 g_free(alias_utf8); | |
6224 | |
6225 return 1; | |
6226 } | |
6227 | |
4230 | 6228 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6229 GaimConnection *gc = sess->aux_data; |
4230 | 6230 va_list ap; |
6231 char *sn, *msg; | |
4236 | 6232 gchar *dialog_msg, *nombre; |
4230 | 6233 struct name_data *data; |
6695 | 6234 GaimBuddy *buddy; |
4230 | 6235 |
6236 va_start(ap, fr); | |
6237 sn = va_arg(ap, char *); | |
6238 msg = va_arg(ap, char *); | |
6239 va_end(ap); | |
6240 | |
8660 | 6241 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6242 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6243 |
4687 | 6244 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6245 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6246 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6247 else |
6248 nombre = g_strdup(sn); | |
6249 | |
6250 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 | 6251 data = g_new(struct name_data, 1); |
6252 data->gc = gc; | |
6253 data->name = g_strdup(sn); | |
6254 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6255 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6256 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6257 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6258 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6259 G_CALLBACK(oscar_free_name_data)); |
4236 | 6260 |
4230 | 6261 g_free(dialog_msg); |
4236 | 6262 g_free(nombre); |
4230 | 6263 |
6264 return 1; | |
6265 } | |
6266 | |
6267 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6268 GaimConnection *gc = sess->aux_data; |
4230 | 6269 va_list ap; |
6270 char *sn, *msg; | |
4236 | 6271 gchar *dialog_msg, *nombre; |
4230 | 6272 struct name_data *data; |
6695 | 6273 GaimBuddy *buddy; |
4230 | 6274 |
6275 va_start(ap, fr); | |
6276 sn = va_arg(ap, char *); | |
6277 msg = va_arg(ap, char *); | |
6278 va_end(ap); | |
6279 | |
8660 | 6280 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6281 "ssi: received authorization request from %s\n", sn); |
4230 | 6282 |
4687 | 6283 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6284 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6285 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6286 else |
6287 nombre = g_strdup(sn); | |
6288 | |
4337 | 6289 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
4230 | 6290 data = g_new(struct name_data, 1); |
6291 data->gc = gc; | |
6292 data->name = g_strdup(sn); | |
6293 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6294 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6295 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6296 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6297 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6298 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6299 |
4230 | 6300 g_free(dialog_msg); |
4236 | 6301 g_free(nombre); |
4230 | 6302 |
6303 return 1; | |
6304 } | |
6305 | |
6306 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6307 GaimConnection *gc = sess->aux_data; |
4230 | 6308 va_list ap; |
6309 char *sn, *msg; | |
4236 | 6310 gchar *dialog_msg, *nombre; |
4230 | 6311 fu8_t reply; |
6695 | 6312 GaimBuddy *buddy; |
4230 | 6313 |
6314 va_start(ap, fr); | |
6315 sn = va_arg(ap, char *); | |
6316 reply = (fu8_t)va_arg(ap, int); | |
6317 msg = va_arg(ap, char *); | |
6318 va_end(ap); | |
6319 | |
8660 | 6320 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6321 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6322 |
4687 | 6323 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6324 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6325 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6326 else |
6327 nombre = g_strdup(sn); | |
6328 | |
4230 | 6329 if (reply) { |
6330 /* Granted */ | |
7023 | 6331 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
|
6332 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6333 } else { |
6334 /* Denied */ | |
7023 | 6335 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
|
6336 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6337 } |
6338 g_free(dialog_msg); | |
4236 | 6339 g_free(nombre); |
4230 | 6340 |
6341 return 1; | |
6342 } | |
6343 | |
6344 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6345 GaimConnection *gc = sess->aux_data; |
4230 | 6346 va_list ap; |
6347 char *sn; | |
6695 | 6348 GaimBuddy *buddy; |
4230 | 6349 |
6350 va_start(ap, fr); | |
6351 sn = va_arg(ap, char *); | |
6352 va_end(ap); | |
6353 | |
4687 | 6354 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6355 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6356 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6357 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6358 |
6359 return 1; | |
6360 } | |
4269 | 6361 #endif |
2086 | 6362 |
5575 | 6363 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6364 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6365 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6366 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6367 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6368 pce->label = _("_Room:"); |
5234 | 6369 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6370 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6371 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6372 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6373 pce->label = _("_Exchange:"); |
5234 | 6374 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6375 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6376 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6377 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6378 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6379 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6380 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6381 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6382 |
9754 | 6383 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6384 { | |
6385 GHashTable *defaults; | |
6386 | |
6387 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6388 | |
6389 if (chat_name != NULL) | |
6390 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6391 | |
6392 return defaults; | |
6393 } | |
6394 | |
9917 | 6395 static char *oscar_get_chat_name(GHashTable *data) { |
6396 return g_strdup(g_hash_table_lookup(data, "room")); | |
6397 } | |
6398 | |
8308 | 6399 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6400 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6401 aim_conn_t *cur; |
5234 | 6402 char *name, *exchange; |
6403 | |
6404 name = g_hash_table_lookup(data, "room"); | |
6405 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6406 |
8660 | 6407 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6408 "Attempting to join chat room %s.\n", name); |
8308 | 6409 |
6410 if ((name == NULL) || (*name == '\0')) { | |
6411 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6412 return; | |
6413 } | |
6414 | |
4617 | 6415 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6416 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6417 "chatnav exists, creating room\n"); |
5234 | 6418 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6419 } else { |
6420 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6421 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6422 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6423 "chatnav does not exist, opening chatnav\n"); |
5234 | 6424 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6425 cr->name = g_strdup(name); |
4617 | 6426 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6427 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6428 } |
6429 } | |
6430 | |
8308 | 6431 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6432 OscarData *od = (OscarData *)gc->proto_data; | |
6433 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6434 |
6435 if (!ccon) | |
6436 return; | |
6437 | |
8225 | 6438 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6439 ccon->exchange, ccon->name, 0x0); |
6440 } | |
6441 | |
8308 | 6442 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6443 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6444 GSList *bcs = gc->buddy_chats; | |
5679 | 6445 GaimConversation *b = NULL; |
2086 | 6446 struct chat_connection *c = NULL; |
6447 int count = 0; | |
6448 | |
6449 while (bcs) { | |
6450 count++; | |
5679 | 6451 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6452 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6453 break; |
6454 bcs = bcs->next; | |
6455 b = NULL; | |
6456 } | |
6457 | |
6458 if (!b) | |
6459 return; | |
6460 | |
8660 | 6461 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6462 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6463 |
8308 | 6464 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6465 if (c != NULL) { |
4617 | 6466 if (od) |
6467 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6468 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6469 gaim_input_remove(c->inpa); |
8308 | 6470 if (gc && od->sess) |
4617 | 6471 aim_conn_kill(od->sess, &c->conn); |
2086 | 6472 g_free(c->name); |
6473 g_free(c->show); | |
6474 g_free(c); | |
6475 } | |
6476 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6477 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6478 } |
6479 | |
8219 | 6480 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6481 OscarData *od = (OscarData *)gc->proto_data; | |
6482 GaimConversation *conv = NULL; | |
2086 | 6483 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6484 char *buf, *buf2; |
9830 | 6485 fu16_t charset, charsubset; |
9807 | 6486 char *charsetstr = NULL; |
10111 | 6487 int len; |
8219 | 6488 |
6489 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6490 return -EINVAL; |
2086 | 6491 |
8219 | 6492 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6493 return -EINVAL; |
2086 | 6494 |
8219 | 6495 buf = gaim_strdup_withhtml(message); |
6496 len = strlen(buf); | |
6497 | |
8962 | 6498 if (strstr(buf, "<IMG ")) |
6499 gaim_conversation_write(conv, "", | |
6500 _("Your IM Image was not sent. " | |
6501 "You cannot send IM Images in AIM chats."), | |
6502 GAIM_MESSAGE_ERROR, time(NULL)); | |
6503 | |
9830 | 6504 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6505 if ((len > c->maxlen) || (len > c->maxvis)) { |
6506 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6507 return -E2BIG; |
8359 | 6508 } |
6509 | |
9831 | 6510 if (charset == AIM_CHARSET_ASCII) |
6511 charsetstr = "us-ascii"; | |
6512 else if (charset == AIM_CHARSET_UNICODE) | |
6513 charsetstr = "unicode-2-0"; | |
6514 else if (charset == AIM_CHARSET_CUSTOM) | |
6515 charsetstr = "iso-8859-1"; | |
9807 | 6516 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6517 g_free(buf2); |
8359 | 6518 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6519 return 0; |
2086 | 6520 } |
6521 | |
10042 | 6522 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6523 { | |
4766 | 6524 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6525 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6526 return "icq"; |
6527 else | |
6528 return "aim"; | |
6529 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6530 |
9975 | 6531 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6532 return "icq"; |
6533 return "aim"; | |
6534 } | |
6535 | |
9972 | 6536 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6537 { |
7334 | 6538 GaimConnection *gc = NULL; |
6539 OscarData *od = NULL; | |
10042 | 6540 GaimAccount *account = NULL; |
6541 GaimPresence *presence; | |
6542 GaimStatus *status; | |
6543 const char *status_id; | |
4687 | 6544 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6545 int i = 0; | |
7334 | 6546 aim_userinfo_t *userinfo = NULL; |
6547 | |
6548 if (b != NULL) | |
6549 account = b->account; | |
6550 if (account != NULL) | |
6551 gc = account->gc; | |
6552 if (gc != NULL) | |
6553 od = gc->proto_data; | |
7945 | 6554 if (od != NULL) |
6555 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6556 |
10042 | 6557 presence = gaim_buddy_get_presence(b); |
6558 status = gaim_presence_get_active_status(presence); | |
6559 status_id = gaim_status_get_id(status); | |
6560 | |
6561 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6562 char *gname; |
7334 | 6563 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6564 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6565 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6566 emblems[i++] = "notauthorized"; | |
6567 } else { | |
6568 emblems[i++] = "offline"; | |
6569 } | |
6570 } | |
4916 | 6571 |
10042 | 6572 if (b->name && aim_sn_is_icq(b->name)) { |
6573 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6574 emblems[i++] = "invisible"; | |
6575 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6576 emblems[i++] = "freeforchat"; |
10042 | 6577 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6578 emblems[i++] = "dnd"; |
10042 | 6579 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6580 emblems[i++] = "na"; |
10042 | 6581 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6582 emblems[i++] = "occupied"; |
10042 | 6583 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6584 emblems[i++] = "away"; |
10042 | 6585 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6586 emblems[i++] = "away"; | |
6587 } | |
6588 | |
6589 if (userinfo != NULL ) { | |
6590 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6591 emblems[i++] = "unconfirmed"; */ | |
6592 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6593 emblems[i++] = "admin"; | |
6594 if (userinfo->flags & AIM_FLAG_AOL) | |
6595 emblems[i++] = "aol"; | |
6596 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6597 emblems[i++] = "wireless"; | |
6598 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6599 emblems[i++] = "activebuddy"; | |
6600 | |
6601 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6602 emblems[i++] = "hiptop"; |
6603 | |
10042 | 6604 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6605 emblems[i++] = "secure"; |
10042 | 6606 } |
7334 | 6607 |
4687 | 6608 *se = emblems[0]; |
6609 *sw = emblems[1]; | |
6610 *nw = emblems[2]; | |
6611 *ne = emblems[3]; | |
6612 } | |
6613 | |
6695 | 6614 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6615 GaimConnection *gc = b->account->gc; |
7283 | 6616 OscarData *od = gc->proto_data; |
7045 | 6617 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6618 GString *str = g_string_new(""); |
5131 | 6619 |
6620 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6621 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6622 |
6623 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6624 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6625 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6626 g_free(charset); |
7011 | 6627 if (away_utf8 != NULL) { |
7091 | 6628 gchar *tmp1, *tmp2; |
9627 | 6629 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6630 g_free(away_utf8); |
8571 | 6631 tmp1 = gaim_escape_html(tmp2); |
7091 | 6632 g_free(tmp2); |
8700 | 6633 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6634 g_free(tmp1); |
8701 | 6635 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6636 g_free(tmp2); |
5836 | 6637 } |
5131 | 6638 } |
8701 | 6639 } |
6640 | |
6641 return g_string_free(str, FALSE); | |
5131 | 6642 } |
6643 | |
10042 | 6644 static char *oscar_status_text(GaimBuddy *b) |
6645 { | |
6646 GaimConnection *gc; | |
6647 OscarData *od; | |
6648 GaimStatus *status; | |
5167 | 6649 gchar *ret = NULL; |
6650 | |
10042 | 6651 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6652 od = gc->proto_data; | |
6653 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6654 | |
6655 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6656 if (aim_sn_is_icq(b->name)) |
8701 | 6657 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6658 else |
6659 ret = g_strdup(_("Away")); | |
5836 | 6660 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6661 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6662 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6663 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6664 } else { |
5167 | 6665 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6666 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6667 ret = g_strdup(_("Not Authorized")); | |
6668 else | |
6669 ret = g_strdup(_("Offline")); | |
6670 } | |
6671 | |
6672 return ret; | |
6673 } | |
6674 | |
5842 | 6675 |
5844 | 6676 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6677 GaimConnection *gc = sess->aux_data; |
7283 | 6678 OscarData *od = gc->proto_data; |
5892 | 6679 va_list ap; |
5842 | 6680 fu16_t type; |
5892 | 6681 fu8_t flags = 0, length = 0; |
6682 char *md5 = NULL; | |
6683 | |
7334 | 6684 |
5842 | 6685 va_start(ap, fr); |
6686 type = va_arg(ap, int); | |
5892 | 6687 |
6688 switch(type) { | |
6689 case 0x0000: | |
6690 case 0x0001: { | |
6691 flags = va_arg(ap, int); | |
6692 length = va_arg(ap, int); | |
6693 md5 = va_arg(ap, char *); | |
6694 | |
6695 if (flags == 0x41) { | |
6696 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6697 od->iconconnecting = TRUE; | |
6698 od->set_icon = TRUE; | |
6699 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6700 } else { | |
6039 | 6701 struct stat st; |
6702 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6703 if (iconfile == NULL) { | |
8363 | 6704 aim_ssi_delicon(od->sess); |
6039 | 6705 } else if (!stat(iconfile, &st)) { |
6706 char *buf = g_malloc(st.st_size); | |
6707 FILE *file = fopen(iconfile, "rb"); | |
6708 if (file) { | |
9532 | 6709 /* XXX - Use g_file_get_contents()? */ |
6039 | 6710 fread(buf, 1, st.st_size, file); |
6711 fclose(file); | |
8660 | 6712 gaim_debug_info("oscar", |
10042 | 6713 "Uploading icon to icon server\n"); |
6879 | 6714 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6715 } else |
8660 | 6716 gaim_debug_error("oscar", |
10042 | 6717 "Can't open buddy icon file!\n"); |
6039 | 6718 g_free(buf); |
6719 } else { | |
8660 | 6720 gaim_debug_error("oscar", |
10042 | 6721 "Can't stat buddy icon file!\n"); |
5892 | 6722 } |
6723 } | |
8363 | 6724 } else if (flags == 0x81) { |
6725 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6726 if (iconfile == NULL) | |
6727 aim_ssi_delicon(od->sess); | |
6728 else | |
6729 aim_ssi_seticon(od->sess, md5, length); | |
6730 } | |
5892 | 6731 } break; |
6732 | |
6733 case 0x0002: { /* We just set an "available" message? */ | |
6734 } break; | |
6735 } | |
6736 | |
5842 | 6737 va_end(ap); |
5844 | 6738 |
6739 return 0; | |
5842 | 6740 } |
5892 | 6741 |
5575 | 6742 static void oscar_set_permit_deny(GaimConnection *gc) { |
6743 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6744 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6745 #ifdef NOSSI |
8143 | 6746 GSList *list; |
4230 | 6747 char buf[MAXMSGLEN]; |
6748 int at; | |
6749 | |
5575 | 6750 switch(account->perm_deny) { |
8175 | 6751 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6752 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6753 break; |
8175 | 6754 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6755 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6756 break; |
8175 | 6757 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6758 list = account->permit; |
4230 | 6759 at = 0; |
6760 while (list) { | |
6761 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6762 list = list->next; | |
6763 } | |
6764 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6765 break; | |
8175 | 6766 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6767 list = account->deny; |
4230 | 6768 at = 0; |
6769 while (list) { | |
6770 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6771 list = list->next; | |
6772 } | |
6773 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6774 break; | |
6775 default: | |
6776 break; | |
2086 | 6777 } |
4230 | 6778 #else |
8175 | 6779 if (od->sess->ssi.received_data) { |
6780 switch (account->perm_deny) { | |
6781 case GAIM_PRIVACY_ALLOW_ALL: | |
6782 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6783 break; | |
6784 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6785 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6786 break; | |
6787 case GAIM_PRIVACY_ALLOW_USERS: | |
6788 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6789 break; | |
6790 case GAIM_PRIVACY_DENY_ALL: | |
6791 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6792 break; | |
6793 case GAIM_PRIVACY_DENY_USERS: | |
6794 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6795 break; | |
6796 default: | |
6797 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6798 break; | |
6799 } | |
6800 } | |
4230 | 6801 #endif |
2086 | 6802 } |
6803 | |
5575 | 6804 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6805 #ifdef NOSSI |
8143 | 6806 if (gc->account->perm_deny == 3) |
4269 | 6807 oscar_set_permit_deny(gc); |
6808 #else | |
7283 | 6809 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6810 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6811 if (od->sess->ssi.received_data) |
4889 | 6812 aim_ssi_addpermit(od->sess, who); |
4230 | 6813 #endif |
2086 | 6814 } |
6815 | |
5575 | 6816 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6817 #ifdef NOSSI |
8143 | 6818 if (gc->account->perm_deny == 4) |
4269 | 6819 oscar_set_permit_deny(gc); |
6820 #else | |
7283 | 6821 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6822 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6823 if (od->sess->ssi.received_data) |
4889 | 6824 aim_ssi_adddeny(od->sess, who); |
4230 | 6825 #endif |
2086 | 6826 } |
6827 | |
5575 | 6828 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6829 #ifdef NOSSI |
8143 | 6830 if (gc->account->perm_deny == 3) |
4269 | 6831 oscar_set_permit_deny(gc); |
6832 #else | |
7283 | 6833 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6834 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6835 if (od->sess->ssi.received_data) |
4889 | 6836 aim_ssi_delpermit(od->sess, who); |
4230 | 6837 #endif |
2086 | 6838 } |
6839 | |
5575 | 6840 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6841 #ifdef NOSSI |
8143 | 6842 if (gc->account->perm_deny == 4) |
4269 | 6843 oscar_set_permit_deny(gc); |
6844 #else | |
7283 | 6845 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6846 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6847 if (od->sess->ssi.received_data) |
4889 | 6848 aim_ssi_deldeny(od->sess, who); |
4230 | 6849 #endif |
2086 | 6850 } |
6851 | |
9975 | 6852 static GList * |
6853 oscar_status_types(GaimAccount *account) | |
2086 | 6854 { |
9975 | 6855 GList *status_types = NULL; |
6856 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6857 |
9973 | 6858 g_return_val_if_fail(account != NULL, NULL); |
6859 | |
10042 | 6860 /* Oscar-common status types */ |
9991 | 6861 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
6862 OSCAR_STATUS_ID_OFFLINE, | |
6863 _("Offline"), FALSE, FALSE, FALSE); | |
9976 | 6864 status_types = g_list_append(status_types, type); |
6865 | |
9991 | 6866 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
6867 OSCAR_STATUS_ID_ONLINE, | |
6868 _("Online"), FALSE, FALSE, FALSE); | |
9976 | 6869 status_types = g_list_append(status_types, type); |
6870 | |
9991 | 6871 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6872 OSCAR_STATUS_ID_AVAILABLE, | |
6873 _("Available"), TRUE, TRUE, FALSE); | |
9976 | 6874 status_types = g_list_append(status_types, type); |
6875 | |
10042 | 6876 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, |
6877 OSCAR_STATUS_ID_AWAY, | |
6878 _("Away"), TRUE, TRUE, FALSE); | |
6879 status_types = g_list_append(status_types, type); | |
6880 | |
6881 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
6882 OSCAR_STATUS_ID_INVISIBLE, | |
6883 _("Invisible"), TRUE, TRUE, TRUE); | |
6884 status_types = g_list_append(status_types, type); | |
6885 | |
6886 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
6887 return status_types; | |
6888 | |
6889 /* ICQ-specific status types */ | |
6890 | |
9991 | 6891 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6892 OSCAR_STATUS_ID_FREE4CHAT, | |
6893 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 6894 status_types = g_list_append(status_types, type); |
6895 | |
9991 | 6896 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
6897 OSCAR_STATUS_ID_OCCUPIED, | |
6898 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 6899 status_types = g_list_append(status_types, type); |
6900 | |
9991 | 6901 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6902 OSCAR_STATUS_ID_DND, | |
6903 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 6904 status_types = g_list_append(status_types, type); |
6905 | |
9991 | 6906 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6907 OSCAR_STATUS_ID_NA, | |
6908 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 6909 status_types = g_list_append(status_types, type); |
9975 | 6910 |
6911 return status_types; | |
4333 | 6912 } |
6913 | |
7172 | 6914 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6915 GaimConnection *gc = data->gc; |
6916 OscarData *od = gc->proto_data; | |
7172 | 6917 GaimBuddy *b; |
6918 GaimGroup *g; | |
6919 | |
6920 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6921 oscar_free_name_data(data); | |
6922 return; | |
6923 } | |
6924 | |
6925 if (!(g = gaim_find_buddys_group(b))) { | |
6926 oscar_free_name_data(data); | |
6927 return; | |
6928 } | |
6929 | |
6930 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6931 |
6932 if (!aim_sncmp(data->name, gc->account->username)) | |
6933 gaim_check_comment(od, text); | |
6934 | |
7172 | 6935 oscar_free_name_data(data); |
6936 } | |
6937 | |
9030 | 6938 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6939 | |
6940 GaimBuddy *buddy; | |
6941 GaimConnection *gc; | |
6942 OscarData *od; | |
6943 struct name_data *data; | |
7172 | 6944 GaimGroup *g; |
6945 char *comment; | |
6946 gchar *comment_utf8; | |
9631 | 6947 gchar *title; |
7172 | 6948 |
9030 | 6949 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6950 | |
6951 buddy = (GaimBuddy *) node; | |
6952 gc = gaim_account_get_connection(buddy->account); | |
6953 od = gc->proto_data; | |
6954 | |
6955 data = g_new(struct name_data, 1); | |
6956 | |
6957 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6958 return; |
9030 | 6959 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6960 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6961 | |
6962 data->gc = gc; | |
9030 | 6963 data->name = g_strdup(buddy->name); |
7172 | 6964 data->nick = NULL; |
6965 | |
9631 | 6966 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6967 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6968 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6969 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6970 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6971 data); | |
9631 | 6972 g_free(title); |
7172 | 6973 |
6974 free(comment); | |
6975 g_free(comment_utf8); | |
6976 } | |
6977 | |
9030 | 6978 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6979 | |
6980 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6981 OscarData *od = gc->proto_data; |
9030 | 6982 |
4333 | 6983 GList *m = NULL; |
9030 | 6984 GaimBlistNodeAction *act; |
6985 | |
6986 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6987 oscar_buddycb_edit_comment, NULL); | |
6988 m = g_list_append(m, act); | |
7172 | 6989 |
4333 | 6990 if (od->icq) { |
4624 | 6991 #if 0 |
9030 | 6992 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6993 oscar_get_icqstatusmsg, NULL); | |
6994 m = g_list_append(m, act); | |
4624 | 6995 #endif |
4333 | 6996 } else { |
7011 | 6997 aim_userinfo_t *userinfo; |
9030 | 6998 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6999 | |
7000 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7001 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7002 | |
7011 | 7003 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7004 act = gaim_blist_node_action_new(_("Direct IM"), |
7005 oscar_ask_direct_im, NULL); | |
7006 m = g_list_append(m, act); | |
5917 | 7007 } |
9466 | 7008 #if 0 |
7011 | 7009 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7010 act = gaim_blist_node_action_new(_("Get File"), |
7011 oscar_ask_getfile, NULL); | |
7012 m = g_list_append(m, act); | |
5917 | 7013 } |
4826 | 7014 #endif |
4333 | 7015 } |
5131 | 7016 } |
5197 | 7017 |
5131 | 7018 if (od->sess->ssi.received_data) { |
9030 | 7019 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7020 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7021 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
7022 gaim_auth_sendrequest_menu, NULL); | |
7023 m = g_list_append(m, act); | |
4333 | 7024 } |
4916 | 7025 } |
7026 | |
4333 | 7027 return m; |
7028 } | |
7029 | |
9030 | 7030 |
7031 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7032 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7033 return oscar_buddy_menu((GaimBuddy *) node); | |
7034 } else { | |
7035 return NULL; | |
7036 } | |
7037 } | |
7038 | |
7039 | |
5575 | 7040 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7041 OscarData *od = gc->proto_data; |
5575 | 7042 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7043 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7044 od->setnick = TRUE; | |
7045 od->newsn = g_strdup(nick); | |
7046 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7047 } else { | |
7048 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7049 } | |
7050 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7051 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7052 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7053 } |
7054 } | |
7055 | |
9015 | 7056 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7057 { |
9015 | 7058 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7059 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7060 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7061 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7062 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7063 gc); |
4333 | 7064 } |
7065 | |
9015 | 7066 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7067 { |
9015 | 7068 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7069 OscarData *od = gc->proto_data; |
4333 | 7070 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7071 | |
7072 if (conn) { | |
7073 aim_admin_reqconfirm(od->sess, conn); | |
7074 } else { | |
7075 od->conf = TRUE; | |
7076 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7077 } | |
7078 } | |
7079 | |
9015 | 7080 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7081 { |
9015 | 7082 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7083 OscarData *od = gc->proto_data; |
4333 | 7084 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7085 | |
7086 if (conn) { | |
7087 aim_admin_getinfo(od->sess, conn, 0x11); | |
7088 } else { | |
7089 od->reqemail = TRUE; | |
7090 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7091 } | |
7092 } | |
7093 | |
5575 | 7094 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7095 { |
7283 | 7096 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7097 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
|
7098 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7099 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7100 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7101 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7102 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7103 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7104 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7105 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7106 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7107 |
9015 | 7108 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7109 { |
9015 | 7110 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7111 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7112 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7113 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7114 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7115 gc); |
4333 | 7116 } |
7117 | |
9015 | 7118 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7119 { |
9015 | 7120 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7121 OscarData *od = gc->proto_data; |
4333 | 7122 gchar *nombre, *text, *tmp; |
6695 | 7123 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7124 int num=0; |
7125 | |
6873 | 7126 text = g_strdup(""); |
4333 | 7127 |
4785 | 7128 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7129 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7130 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7131 continue; | |
6695 | 7132 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7133 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7134 continue; |
6695 | 7135 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7136 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7137 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7138 continue; | |
7139 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7140 if (gaim_buddy_get_alias_only(buddy)) |
7141 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7142 else |
7143 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7144 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7145 g_free(text); |
7146 text = tmp; | |
7147 g_free(nombre); | |
7148 num++; | |
7149 } | |
4333 | 7150 } |
2979 | 7151 } |
4333 | 7152 } |
7153 | |
7154 if (!num) { | |
7155 g_free(text); | |
6873 | 7156 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7157 } | |
7158 | |
7159 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7160 "the following buddies"), _("You can re-request " | |
7161 "authorization from these buddies by " | |
7162 "right-clicking on them and selecting " | |
7163 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7164 g_free(text); |
2979 | 7165 } |
7166 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7167 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7168 { |
8950 | 7169 OscarData *od = (OscarData *)gc->proto_data; |
7170 | |
7171 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7172 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7173 |
9015 | 7174 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7175 { |
9015 | 7176 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7177 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7178 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7179 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7180 "searching for."), |
8697 | 7181 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7182 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7183 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7184 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7185 |
9015 | 7186 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7187 { |
9015 | 7188 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7189 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7190 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7191 |
9015 | 7192 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7193 { |
9015 | 7194 GaimConnection *gc = (GaimConnection *) action->context; |
9809 | 7195 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7196 } |
7197 | |
9015 | 7198 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7199 { |
9015 | 7200 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7201 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7202 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7203 |
9015 | 7204 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7205 { |
9015 | 7206 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7207 OscarData *od = gc->proto_data; |
5575 | 7208 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6400
diff
changeset
|
7209 gaim_notify_uri(gc, substituted); |
5517 | 7210 g_free(substituted); |
4333 | 7211 } |
7212 | |
9015 | 7213 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7214 { |
9015 | 7215 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7216 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7217 } | |
7218 | |
5842 | 7219 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7220 { | |
7283 | 7221 OscarData *od = gc->proto_data; |
5844 | 7222 aim_session_t *sess = od->sess; |
5842 | 7223 FILE *file; |
7224 struct stat st; | |
5844 | 7225 |
6039 | 7226 if (iconfile == NULL) { |
8363 | 7227 aim_ssi_delicon(od->sess); |
6039 | 7228 } else if (!stat(iconfile, &st)) { |
5842 | 7229 char *buf = g_malloc(st.st_size); |
7230 file = fopen(iconfile, "rb"); | |
7231 if (file) { | |
6052 | 7232 md5_state_t *state; |
6039 | 7233 char md5[16]; |
9532 | 7234 /* XXX - Use g_file_get_contents()? */ |
5842 | 7235 int len = fread(buf, 1, st.st_size, file); |
6039 | 7236 fclose(file); |
6052 | 7237 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7238 md5_init(state); |
7239 md5_append(state, buf, len); | |
7240 md5_finish(state, md5); | |
7241 g_free(state); | |
7242 aim_ssi_seticon(sess, md5, 16); | |
7243 } else | |
8660 | 7244 gaim_debug_error("oscar", |
5842 | 7245 "Can't open buddy icon file!\n"); |
7246 g_free(buf); | |
7247 } else | |
8660 | 7248 gaim_debug_error("oscar", |
5842 | 7249 "Can't stat buddy icon file!\n"); |
7250 } | |
7251 | |
7252 | |
9015 | 7253 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7254 { |
9015 | 7255 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7256 OscarData *od = gc->proto_data; |
4333 | 7257 GList *m = NULL; |
9015 | 7258 GaimPluginAction *act; |
7259 | |
7260 act = gaim_plugin_action_new(_("Set User Info..."), | |
7261 oscar_show_set_info); | |
7262 m = g_list_append(m, act); | |
4333 | 7263 |
8576 | 7264 if (od->icq) { |
9015 | 7265 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7266 oscar_show_set_info_icqurl); | |
7267 m = g_list_append(m, act); | |
8576 | 7268 } |
7269 | |
9015 | 7270 act = gaim_plugin_action_new(_("Change Password..."), |
7271 oscar_change_pass); | |
7272 m = g_list_append(m, act); | |
4617 | 7273 |
7274 if (od->sess->authinfo->chpassurl) { | |
9015 | 7275 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7276 oscar_show_chpassurl); | |
7277 m = g_list_append(m, act); | |
7278 | |
7279 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7280 oscar_show_imforwardingurl); | |
7281 m = g_list_append(m, act); | |
7026 | 7282 } |
7283 | |
5238 | 7284 if (!od->icq) { |
4617 | 7285 /* AIM actions */ |
7286 m = g_list_append(m, NULL); | |
4333 | 7287 |
9015 | 7288 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7289 oscar_show_format_screenname); | |
7290 m = g_list_append(m, act); | |
7291 | |
7292 act = gaim_plugin_action_new(_("Confirm Account"), | |
7293 oscar_confirm_account); | |
7294 m = g_list_append(m, act); | |
7295 | |
7296 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7297 oscar_show_email); | |
7298 m = g_list_append(m, act); | |
7299 | |
7300 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7301 oscar_show_change_email); | |
7302 m = g_list_append(m, act); | |
2086 | 7303 } |
4333 | 7304 |
7305 m = g_list_append(m, NULL); | |
7306 | |
9015 | 7307 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7308 oscar_show_awaitingauth); | |
7309 m = g_list_append(m, act); | |
4333 | 7310 |
2086 | 7311 m = g_list_append(m, NULL); |
4333 | 7312 |
9015 | 7313 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7314 oscar_show_find_email); | |
7315 m = g_list_append(m, act); | |
4333 | 7316 |
8591 | 7317 #if 0 |
9015 | 7318 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7319 show_find_info); | |
7320 m = g_list_append(m, act); | |
8591 | 7321 #endif |
2086 | 7322 |
7323 return m; | |
7324 } | |
7325 | |
5575 | 7326 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7327 { |
7283 | 7328 OscarData *od = gc->proto_data; |
4617 | 7329 |
7330 if (od->icq) { | |
7331 aim_icq_changepasswd(od->sess, new); | |
2086 | 7332 } else { |
4617 | 7333 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7334 if (conn) { | |
7335 aim_admin_changepasswd(od->sess, conn, new, old); | |
7336 } else { | |
7337 od->chpass = TRUE; | |
7338 od->oldp = g_strdup(old); | |
7339 od->newp = g_strdup(new); | |
7340 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7341 } | |
2086 | 7342 } |
7343 } | |
7344 | |
6059 | 7345 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7346 { |
7283 | 7347 OscarData *od = gc->proto_data; |
8971 | 7348 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
|
7349 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7350 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7351 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7352 |
8971 | 7353 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7354 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7355 |
9935 | 7356 static void |
7357 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7358 { | |
7359 GaimConnection *gc = data; | |
7360 OscarData *od = gc->proto_data; | |
7361 aim_session_t *sess = od->sess; | |
7362 fu32_t presence; | |
7363 | |
7364 presence = aim_ssi_getpresence(sess->ssi.local); | |
7365 | |
7366 if (value) { | |
9992 | 7367 /* Based on the packet capture I thought it was the first one */ |
7368 /* Stu thinks it's the second one. */ | |
7369 /* presence |= 0x00400000; */ | |
9971 | 7370 presence &= ~0x00020000; |
9935 | 7371 aim_ssi_setpresence(sess, presence); |
7372 } else { | |
9992 | 7373 /* presence &= ~0x00400000; */ |
9971 | 7374 presence |= 0x00020000; |
9935 | 7375 aim_ssi_setpresence(sess, presence); |
7376 } | |
7377 } | |
7378 | |
7379 static GaimPluginPrefFrame * | |
9936 | 7380 get_plugin_pref_frame(GaimPlugin *plugin) |
7381 { | |
9935 | 7382 GaimPluginPrefFrame *frame; |
7383 GaimPluginPref *ppref; | |
7384 | |
7385 frame = gaim_plugin_pref_frame_new(); | |
7386 | |
7387 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7388 gaim_plugin_pref_frame_add(frame, ppref); | |
7389 | |
7390 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7391 gaim_plugin_pref_frame_add(frame, ppref); | |
7392 | |
7393 return frame; | |
7394 } | |
7395 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7396 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7397 { |
9308 | 7398 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7399 NULL, /* user_splits */ |
7400 NULL, /* protocol_options */ | |
7401 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7402 oscar_list_icon, /* list_icon */ | |
7403 oscar_list_emblems, /* list_emblems */ | |
7404 oscar_status_text, /* status_text */ | |
7405 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7406 oscar_status_types, /* status_types */ |
9475 | 7407 oscar_blist_node_menu, /* blist_node_menu */ |
7408 oscar_chat_info, /* chat_info */ | |
9754 | 7409 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7410 oscar_login, /* login */ |
7411 oscar_close, /* close */ | |
7412 oscar_send_im, /* send_im */ | |
7413 oscar_set_info, /* set_info */ | |
7414 oscar_send_typing, /* send_typing */ | |
7415 oscar_get_info, /* get_info */ | |
9973 | 7416 oscar_set_status, /* set_status */ |
9475 | 7417 oscar_set_idle, /* set_idle */ |
7418 oscar_change_passwd, /* change_passwd */ | |
7419 oscar_add_buddy, /* add_buddy */ | |
7420 oscar_add_buddies, /* add_buddies */ | |
7421 oscar_remove_buddy, /* remove_buddy */ | |
7422 oscar_remove_buddies, /* remove_buddies */ | |
7423 oscar_add_permit, /* add_permit */ | |
7424 oscar_add_deny, /* add_deny */ | |
7425 oscar_rem_permit, /* rem_permit */ | |
7426 oscar_rem_deny, /* rem_deny */ | |
7427 oscar_set_permit_deny, /* set_permit_deny */ | |
7428 oscar_warn, /* warn */ | |
7429 oscar_join_chat, /* join_chat */ | |
7430 NULL, /* reject_chat */ | |
9973 | 7431 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7432 oscar_chat_invite, /* chat_invite */ |
7433 oscar_chat_leave, /* chat_leave */ | |
7434 NULL, /* chat_whisper */ | |
7435 oscar_send_chat, /* chat_send */ | |
7436 oscar_keepalive, /* keepalive */ | |
7437 NULL, /* register_user */ | |
7438 NULL, /* get_cb_info */ | |
7439 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7440 #ifndef NOSSI |
9475 | 7441 oscar_alias_buddy, /* alias_buddy */ |
7442 oscar_move_buddy, /* group_buddy */ | |
7443 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7444 #else |
9475 | 7445 NULL, /* alias_buddy */ |
7446 NULL, /* group_buddy */ | |
7447 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7448 #endif |
9475 | 7449 NULL, /* buddy_free */ |
7450 oscar_convo_closed, /* convo_closed */ | |
7451 NULL, /* normalize */ | |
7452 oscar_set_icon, /* set_buddy_icon */ | |
7453 NULL, /* remove_group */ | |
7454 NULL, /* get_cb_real_name */ | |
7455 NULL, /* set_chat_topic */ | |
7456 NULL, /* find_blist_chat */ | |
7457 NULL, /* roomlist_get_list */ | |
7458 NULL, /* roomlist_cancel */ | |
7459 NULL, /* roomlist_expand_category */ | |
7460 oscar_can_receive_file, /* can_receive_file */ | |
7461 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7462 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7463 |
9935 | 7464 static GaimPluginUiInfo prefs_info = { |
7465 get_plugin_pref_frame | |
7466 }; | |
7467 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7468 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7469 { |
9943 | 7470 GAIM_PLUGIN_MAGIC, |
7471 GAIM_MAJOR_VERSION, | |
7472 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7473 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7474 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7475 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7476 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7477 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7478 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7479 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7480 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7481 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7482 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7483 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7484 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7485 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7486 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7487 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7488 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7489 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7490 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7491 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7492 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7493 NULL, /**< ui_info */ |
8993 | 7494 &prpl_info, /**< extra_info */ |
9935 | 7495 &prefs_info, /**< prefs_info */ |
9015 | 7496 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7497 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7498 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7499 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7500 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7501 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7502 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7503 |
9830 | 7504 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7505 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7506 | |
7507 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7508 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7509 | |
7510 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7511 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7512 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7513 my_protocol = plugin; |
9935 | 7514 |
7515 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7516 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7517 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7518 } |
7519 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7520 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |