Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 10350:d962fc7778f1
[gaim-migrate @ 11565]
We need this.
Oh "WE" need this. What about YOU need this?
I'd rather kiss a wookie.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 13 Dec 2004 01:19:05 +0000 |
parents | 0ad82da3ffcf |
children | cbfd90f7fa47 |
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 |
10329 | 65 #define FAIM_DEBUG_LEVEL 0 |
66 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
67 static GaimPlugin *my_protocol = NULL; |
4249 | 68 |
7376 | 69 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
70 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 71 |
4665 | 72 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
73 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 74 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 75 |
7283 | 76 typedef struct _OscarData OscarData; |
77 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
78 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
79 aim_conn_t *conn; |
2086 | 80 |
81 guint cnpa; | |
82 guint paspa; | |
3694 | 83 guint emlpa; |
4804 | 84 guint icopa; |
2086 | 85 |
4823 | 86 gboolean iconconnecting; |
5842 | 87 gboolean set_icon; |
4823 | 88 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
89 GSList *create_rooms; |
2086 | 90 |
91 gboolean conf; | |
92 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
93 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
94 char *email; |
2979 | 95 gboolean setnick; |
96 char *newsn; | |
2086 | 97 gboolean chpass; |
98 char *oldp; | |
99 char *newp; | |
9971 | 100 |
2086 | 101 GSList *oscar_chats; |
102 GSList *direct_ims; | |
3630 | 103 GSList *file_transfers; |
4738 | 104 GHashTable *buddyinfo; |
4804 | 105 GSList *requesticon; |
2086 | 106 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
107 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
108 gboolean icq; |
4804 | 109 guint icontimer; |
5968 | 110 guint getblisttimer; |
8341 | 111 guint getinfotimer; |
2993 | 112 |
113 struct { | |
4230 | 114 guint maxwatchers; /* max users who can watch you */ |
2993 | 115 guint maxbuddies; /* max users you can watch */ |
4230 | 116 guint maxgroups; /* max groups in server list */ |
2993 | 117 guint maxpermits; /* max users on permit list */ |
118 guint maxdenies; /* max users on deny list */ | |
119 guint maxsiglen; /* max size (bytes) of profile */ | |
120 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
121 } rights; | |
2086 | 122 }; |
123 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
124 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
125 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
126 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
127 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
128 |
2086 | 129 struct chat_connection { |
130 char *name; | |
131 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
132 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
133 fu16_t instance; |
2086 | 134 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
|
135 aim_conn_t *conn; |
2086 | 136 int inpa; |
137 int id; | |
5575 | 138 GaimConnection *gc; /* i hate this. */ |
8733 | 139 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
140 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
141 int maxvis; |
2086 | 142 }; |
143 | |
8971 | 144 struct oscar_direct_im { |
5575 | 145 GaimConnection *gc; |
2086 | 146 char name[80]; |
147 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
148 aim_conn_t *conn; |
3008 | 149 gboolean connected; |
8978 | 150 gboolean gpc_pend; |
151 gboolean killme; | |
8984 | 152 gboolean donttryagain; |
2086 | 153 }; |
154 | |
155 struct ask_direct { | |
5575 | 156 GaimConnection *gc; |
2086 | 157 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
158 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
159 fu8_t cookie[8]; |
8984 | 160 gboolean donttryagain; |
2086 | 161 }; |
162 | |
7011 | 163 /* |
164 * Various PRPL-specific buddy info that we want to keep track of | |
165 * Some other info is maintained by locate.c, and I'd like to move | |
166 * the rest of this to libfaim, mostly im.c | |
167 */ | |
4738 | 168 struct buddyinfo { |
169 gboolean typingnot; | |
6292 | 170 gchar *availmsg; |
6857 | 171 fu32_t ipaddr; |
5836 | 172 |
173 unsigned long ico_me_len; | |
174 unsigned long ico_me_csum; | |
175 time_t ico_me_time; | |
176 gboolean ico_informed; | |
4738 | 177 |
178 unsigned long ico_len; | |
179 unsigned long ico_csum; | |
180 time_t ico_time; | |
181 gboolean ico_need; | |
7406 | 182 gboolean ico_sent; |
2086 | 183 }; |
184 | |
4230 | 185 struct name_data { |
5575 | 186 GaimConnection *gc; |
4230 | 187 gchar *name; |
3453 | 188 gchar *nick; |
3141 | 189 }; |
190 | |
5129 | 191 static char *msgerrreason[] = { |
192 N_("Invalid error"), | |
193 N_("Invalid SNAC"), | |
194 N_("Rate to host"), | |
195 N_("Rate to client"), | |
196 N_("Not logged in"), | |
197 N_("Service unavailable"), | |
198 N_("Service not defined"), | |
199 N_("Obsolete SNAC"), | |
200 N_("Not supported by host"), | |
201 N_("Not supported by client"), | |
202 N_("Refused by client"), | |
203 N_("Reply too big"), | |
204 N_("Responses lost"), | |
205 N_("Request denied"), | |
206 N_("Busted SNAC payload"), | |
207 N_("Insufficient rights"), | |
208 N_("In local permit/deny"), | |
209 N_("Too evil (sender)"), | |
210 N_("Too evil (receiver)"), | |
211 N_("User temporarily unavailable"), | |
212 N_("No match"), | |
213 N_("List overflow"), | |
214 N_("Request ambiguous"), | |
215 N_("Queue full"), | |
216 N_("Not while on AOL") | |
217 }; | |
218 static int msgerrreasonlen = 25; | |
219 | |
220 /* All the libfaim->gaim callback functions */ | |
221 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
222 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
223 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
224 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
225 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
226 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 231 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 232 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 233 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
234 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
|
235 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
|
236 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
|
237 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
|
238 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 239 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
240 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
241 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 242 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 243 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
244 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
245 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
250 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
251 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
252 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
253 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
254 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
255 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
270 #ifndef NOSSI | |
271 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 275 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 276 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
277 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
280 #endif | |
281 | |
282 /* for DirectIM/image transfer */ | |
283 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
284 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 286 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 287 |
288 /* for file transfer */ | |
289 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
290 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
291 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
292 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
293 | |
294 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 295 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 296 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 297 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 298 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
299 | |
5836 | 300 static void oscar_free_name_data(struct name_data *data) { |
4230 | 301 g_free(data->name); |
302 g_free(data->nick); | |
303 g_free(data); | |
304 } | |
305 | |
5836 | 306 static void oscar_free_buddyinfo(void *data) { |
307 struct buddyinfo *bi = data; | |
6292 | 308 g_free(bi->availmsg); |
5836 | 309 g_free(bi); |
310 } | |
311 | |
9807 | 312 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 313 { |
314 int i = 0; | |
9826 | 315 int charset = AIM_CHARSET_ASCII; |
5129 | 316 |
317 /* Determine how we can send this message. Per the warnings elsewhere | |
318 * in this file, these little checks determine the simplest encoding | |
319 * we can use for a given message send using it. */ | |
320 while (utf8[i]) { | |
321 if ((unsigned char)utf8[i] > 0x7f) { | |
322 /* not ASCII! */ | |
9826 | 323 charset = AIM_CHARSET_CUSTOM; |
5129 | 324 break; |
325 } | |
326 i++; | |
327 } | |
328 while (utf8[i]) { | |
329 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
330 * followed by 0xc0-0xc3 in the second */ | |
331 if ((unsigned char)utf8[i] < 0x80) { | |
332 i++; | |
333 continue; | |
334 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
335 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
336 i += 2; | |
337 continue; | |
338 } | |
9826 | 339 charset = AIM_CHARSET_UNICODE; |
5129 | 340 break; |
341 } | |
342 | |
9807 | 343 return charset; |
5129 | 344 } |
345 | |
8225 | 346 /* |
347 * Take a string of the form charset="bleh" where bleh is | |
348 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
349 * return a newly allocated string containing bleh. | |
350 */ | |
351 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 352 { |
8225 | 353 gchar *ret = NULL; |
354 char *begin, *end; | |
355 | |
9933 | 356 g_return_val_if_fail(encoding != NULL, NULL); |
357 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
358 /* Make sure encoding begins with charset= */ |
8225 | 359 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
360 return NULL; | |
361 | |
362 begin = strchr(encoding, '"'); | |
363 end = strrchr(encoding, '"'); | |
364 | |
365 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
366 return NULL; | |
367 | |
368 ret = g_strndup(begin+1, (end-1) - begin); | |
369 | |
370 return ret; | |
371 } | |
372 | |
9830 | 373 static gchar * |
374 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 375 { |
376 gchar *utf8 = NULL; | |
9595 | 377 |
378 if ((encoding == NULL) || encoding[0] == '\0') { | |
379 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
380 | |
9639 | 381 } else if (!strcmp(encoding, "iso-8859-1") |
382 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 383 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
384 | |
385 } else if (!strcmp(encoding, "unicode-2-0")) { | |
386 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
387 | |
388 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
389 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
10096 | 390 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 391 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
392 } | |
393 | |
394 /* | |
395 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
396 * we have been unable to convert the text to utf-8 from the encoding | |
397 * that was specified. So we check if the text is valid utf-8 then | |
398 * just copy it. | |
399 */ | |
400 if (utf8 == NULL) { | |
9638 | 401 if (textlen != 0 && *text != '\0' |
402 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 403 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 404 else |
9481 | 405 utf8 = g_strndup(text, textlen); |
5129 | 406 } |
407 | |
408 return utf8; | |
409 } | |
410 | |
9830 | 411 static gchar * |
9908 | 412 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 413 { |
414 gchar *ret = NULL; | |
415 GError *err = NULL; | |
416 | |
9908 | 417 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
418 return NULL; | |
419 | |
420 if (strcasecmp("UTF-8", charsetstr)) { | |
421 if (fallback) | |
422 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
423 else | |
424 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
425 if (err != NULL) { | |
426 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
427 charsetstr, err->message); | |
428 g_error_free(err); | |
429 } | |
430 } else { | |
431 if (g_utf8_validate(data, datalen, NULL)) | |
432 ret = g_strndup(data, datalen); | |
433 else | |
434 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
435 } | |
436 | |
437 return ret; | |
438 } | |
439 | |
440 /* | |
441 * We try decoding using two different character sets. The charset | |
442 * specified in the IM determines the order in which we attempt to | |
443 * decode. We do this because there are lots of broken ICQ clients | |
444 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
445 * able to deal with that crap, then people complain like banshees. | |
446 * charsetstr1 is always set to what the correct encoding should be. | |
447 */ | |
448 static gchar * | |
449 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
450 { | |
451 gchar *ret = NULL; | |
452 const gchar *charsetstr1, *charsetstr2; | |
453 | |
454 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 455 |
456 if ((datalen == 0) || (data == NULL)) | |
457 return NULL; | |
458 | |
9908 | 459 if (charset == AIM_CHARSET_UNICODE) { |
460 charsetstr1 = "UCS-2BE"; | |
461 charsetstr2 = "UTF-8"; | |
462 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 463 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 464 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 465 else |
9908 | 466 charsetstr1 = "ISO-8859-1"; |
467 charsetstr2 = "UTF-8"; | |
468 } else if (charset == AIM_CHARSET_ASCII) { | |
469 /* Should just be "ASCII" */ | |
9914 | 470 charsetstr1 = "ASCII"; |
9908 | 471 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
472 } else if (charset == 0x000d) { | |
9830 | 473 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 474 charsetstr1 = "ISO-8859-1"; |
475 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
476 } else { | |
9830 | 477 /* Unknown, hope for valid UTF-8... */ |
9908 | 478 charsetstr1 = "UTF-8"; |
479 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
480 } | |
481 | |
482 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
483 if (ret == NULL) | |
484 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
485 if (ret == NULL) | |
486 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 487 |
488 return ret; | |
489 } | |
490 | |
491 static void | |
492 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 493 gchar **msg, int *msglen_int, |
9830 | 494 fu16_t *charset, fu16_t *charsubset) |
495 { | |
496 OscarData *od = gc->proto_data; | |
497 GaimAccount *account = gaim_connection_get_account(gc); | |
498 GError *err = NULL; | |
499 aim_userinfo_t *userinfo = NULL; | |
500 const gchar *charsetstr; | |
10039 | 501 gsize msglen; |
9830 | 502 |
503 /* Attempt to send as ASCII */ | |
10098 | 504 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 505 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 506 *charset = AIM_CHARSET_ASCII; |
9830 | 507 *charsubset = 0x0000; |
10039 | 508 *msglen_int = msglen; |
9830 | 509 return; |
510 } | |
511 | |
512 /* | |
9908 | 513 * If we're sending to an ICQ user, and they are advertising the |
514 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 515 */ |
9975 | 516 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 517 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
518 | |
519 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
10039 | 520 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
9830 | 521 if (*msg != NULL) { |
522 *charset = AIM_CHARSET_UNICODE; | |
523 *charsubset = 0x0000; | |
10039 | 524 *msglen_int = msglen; |
9830 | 525 return; |
526 } | |
527 } | |
528 | |
529 /* | |
530 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
531 * ICQ then attempt to send as the user specified character encoding. | |
532 */ | |
533 charsetstr = "ISO-8859-1"; | |
9975 | 534 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 535 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
536 | |
10097 | 537 /* |
538 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
539 * can be converted to "charsetstr" | |
540 */ | |
10039 | 541 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 542 if (*msg != NULL) { |
543 *charset = AIM_CHARSET_CUSTOM; | |
544 *charsubset = 0x0000; | |
10039 | 545 *msglen_int = msglen; |
9830 | 546 return; |
547 } | |
548 | |
549 /* | |
550 * Nothing else worked, so send as UCS-2BE. | |
551 */ | |
10039 | 552 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 553 if (*msg != NULL) { |
554 *charset = AIM_CHARSET_UNICODE; | |
555 *charsubset = 0x0000; | |
10039 | 556 *msglen_int = msglen; |
9830 | 557 return; |
558 } | |
559 | |
9908 | 560 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 561 g_error_free(err); |
562 | |
563 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
564 *msg = g_strdup(from); | |
10039 | 565 *msglen_int = strlen(*msg); |
9830 | 566 *charset = AIM_CHARSET_ASCII; |
567 *charsubset = 0x0000; | |
568 return; | |
569 } | |
570 | |
9407 | 571 gchar *oscar_caps_to_string(guint caps) |
8701 | 572 { |
9407 | 573 GString *str; |
574 gchar *tmp; | |
8701 | 575 guint bit = 1; |
576 | |
9407 | 577 str = g_string_new(""); |
578 | |
8701 | 579 if (!caps) { |
580 return NULL; | |
581 } else while (bit <= AIM_CAPS_LAST) { | |
582 if (bit & caps) { | |
583 switch (bit) { | |
584 case AIM_CAPS_BUDDYICON: | |
585 tmp = _("Buddy Icon"); | |
586 break; | |
587 case AIM_CAPS_TALK: | |
588 tmp = _("Voice"); | |
589 break; | |
590 case AIM_CAPS_DIRECTIM: | |
591 tmp = _("AIM Direct IM"); | |
592 break; | |
593 case AIM_CAPS_CHAT: | |
594 tmp = _("Chat"); | |
595 break; | |
596 case AIM_CAPS_GETFILE: | |
597 tmp = _("Get File"); | |
598 break; | |
599 case AIM_CAPS_SENDFILE: | |
600 tmp = _("Send File"); | |
601 break; | |
602 case AIM_CAPS_GAMES: | |
603 case AIM_CAPS_GAMES2: | |
604 tmp = _("Games"); | |
605 break; | |
606 case AIM_CAPS_ADDINS: | |
607 tmp = _("Add-Ins"); | |
608 break; | |
609 case AIM_CAPS_SENDBUDDYLIST: | |
610 tmp = _("Send Buddy List"); | |
611 break; | |
612 case AIM_CAPS_ICQ_DIRECT: | |
613 tmp = _("ICQ Direct Connect"); | |
614 break; | |
615 case AIM_CAPS_APINFO: | |
616 tmp = _("AP User"); | |
617 break; | |
618 case AIM_CAPS_ICQRTF: | |
619 tmp = _("ICQ RTF"); | |
620 break; | |
621 case AIM_CAPS_EMPTY: | |
622 tmp = _("Nihilist"); | |
623 break; | |
624 case AIM_CAPS_ICQSERVERRELAY: | |
625 tmp = _("ICQ Server Relay"); | |
626 break; | |
627 case AIM_CAPS_ICQUTF8OLD: | |
628 tmp = _("Old ICQ UTF8"); | |
629 break; | |
630 case AIM_CAPS_TRILLIANCRYPT: | |
631 tmp = _("Trillian Encryption"); | |
632 break; | |
633 case AIM_CAPS_ICQUTF8: | |
634 tmp = _("ICQ UTF8"); | |
635 break; | |
636 case AIM_CAPS_HIPTOP: | |
637 tmp = _("Hiptop"); | |
638 break; | |
639 case AIM_CAPS_SECUREIM: | |
640 tmp = _("Security Enabled"); | |
641 break; | |
642 case AIM_CAPS_VIDEO: | |
643 tmp = _("Video Chat"); | |
644 break; | |
645 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
646 case AIM_CAPS_ICHATAV: | |
647 tmp = _("iChat AV"); | |
648 break; | |
649 case AIM_CAPS_LIVEVIDEO: | |
650 tmp = _("Live Video"); | |
651 break; | |
652 case AIM_CAPS_CAMERA: | |
653 tmp = _("Camera"); | |
654 break; | |
655 default: | |
656 tmp = NULL; | |
657 break; | |
658 } | |
659 if (tmp) | |
9532 | 660 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 661 } |
662 bit <<= 1; | |
663 } | |
9407 | 664 |
665 return g_string_free(str, FALSE); | |
8701 | 666 } |
667 | |
668 static char *oscar_icqstatus(int state) { | |
669 /* Make a cute little string that shows the status of the dude or dudet */ | |
670 if (state & AIM_ICQ_STATE_CHAT) | |
671 return g_strdup_printf(_("Free For Chat")); | |
672 else if (state & AIM_ICQ_STATE_DND) | |
673 return g_strdup_printf(_("Do Not Disturb")); | |
674 else if (state & AIM_ICQ_STATE_OUT) | |
675 return g_strdup_printf(_("Not Available")); | |
676 else if (state & AIM_ICQ_STATE_BUSY) | |
677 return g_strdup_printf(_("Occupied")); | |
678 else if (state & AIM_ICQ_STATE_AWAY) | |
679 return g_strdup_printf(_("Away")); | |
680 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
681 return g_strdup_printf(_("Web Aware")); | |
682 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
683 return g_strdup_printf(_("Invisible")); | |
684 else | |
685 return g_strdup_printf(_("Online")); | |
686 } | |
687 | |
9973 | 688 static void |
689 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 690 { |
691 gchar *utf8; | |
692 | |
693 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 694 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 695 g_free(utf8); |
696 } | |
697 } | |
698 | |
9973 | 699 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 700 { |
10042 | 701 OscarData *od; |
702 GaimAccount *account; | |
703 GaimPresence *presence; | |
704 GaimPresence *buddy_presence; | |
8701 | 705 GaimGroup *g = NULL; |
706 struct buddyinfo *bi = NULL; | |
707 char *tmp; | |
708 | |
10042 | 709 od = gc->proto_data; |
710 account = gaim_connection_get_account(gc); | |
711 presence = gaim_account_get_presence(account); | |
712 buddy_presence = gaim_buddy_get_presence(b); | |
713 | |
714 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 715 return; |
716 | |
717 if (userinfo == NULL) | |
718 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
719 | |
720 if (b == NULL) | |
10042 | 721 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 722 |
723 if (b != NULL) | |
724 g = gaim_find_buddys_group(b); | |
725 | |
726 if (userinfo != NULL) | |
727 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
728 | |
8733 | 729 if (b != NULL) { |
10042 | 730 if (gaim_presence_is_online(buddy_presence)) { |
9975 | 731 if (aim_sn_is_icq(b->name)) { |
8733 | 732 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
733 oscar_string_append(str, newline, _("Status"), tmp); | |
734 g_free(tmp); | |
735 } | |
736 } else { | |
9625 | 737 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 738 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
739 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
740 else | |
741 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 742 } |
8733 | 743 } |
8701 | 744 |
745 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 746 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 747 (bi->ipaddr & 0xff000000) >> 24, |
748 (bi->ipaddr & 0x00ff0000) >> 16, | |
749 (bi->ipaddr & 0x0000ff00) >> 8, | |
750 (bi->ipaddr & 0x000000ff)); | |
751 oscar_string_append(str, newline, _("IP Address"), tmp); | |
752 g_free(tmp); | |
753 } | |
754 | |
755 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
756 tmp = oscar_caps_to_string(userinfo->capabilities); | |
757 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 758 g_free(tmp); |
8701 | 759 } |
760 | |
761 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
762 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
763 if (tmp != NULL) { | |
9625 | 764 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 765 g_free(tmp); |
9625 | 766 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
767 g_free(tmp2); | |
8701 | 768 } |
769 } | |
770 | |
10042 | 771 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_presence_is_available(presence)) { |
8701 | 772 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
773 oscar_string_append(str, newline, _("Available"), tmp); | |
774 g_free(tmp); | |
775 } | |
776 } | |
777 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
778 static char *extract_name(const char *name) { |
4121 | 779 char *tmp, *x; |
2086 | 780 int i, j; |
4120 | 781 |
782 if (!name) | |
4121 | 783 return NULL; |
10042 | 784 |
4120 | 785 x = strchr(name, '-'); |
4121 | 786 |
2086 | 787 if (!x) return NULL; |
788 x = strchr(++x, '-'); | |
789 if (!x) return NULL; | |
790 tmp = g_strdup(++x); | |
791 | |
792 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
793 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
794 if (x[i] != '%') { |
2086 | 795 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
796 continue; |
2086 | 797 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
798 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
799 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
800 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 801 } |
802 | |
803 tmp[j] = 0; | |
804 return tmp; | |
805 } | |
806 | |
5575 | 807 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 808 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 809 struct chat_connection *c = NULL; |
810 | |
811 while (g) { | |
812 c = (struct chat_connection *)g->data; | |
813 if (c->id == id) | |
814 break; | |
815 g = g->next; | |
816 c = NULL; | |
817 } | |
818 | |
819 return c; | |
820 } | |
821 | |
5575 | 822 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
|
823 aim_conn_t *conn) { |
7283 | 824 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 825 struct chat_connection *c = NULL; |
826 | |
827 while (g) { | |
828 c = (struct chat_connection *)g->data; | |
829 if (c->conn == conn) | |
830 break; | |
831 g = g->next; | |
832 c = NULL; | |
833 } | |
834 | |
835 return c; | |
836 } | |
837 | |
8219 | 838 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
839 GaimConversation *conv) { | |
840 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
841 struct chat_connection *c = NULL; | |
842 | |
843 while (g) { | |
844 c = (struct chat_connection *)g->data; | |
8733 | 845 if (c->conv == conv) |
8219 | 846 break; |
847 g = g->next; | |
848 c = NULL; | |
849 } | |
850 | |
851 return c; | |
852 } | |
853 | |
8971 | 854 /***************************************************************************** |
855 * Begin scary direct im stuff | |
856 *****************************************************************************/ | |
857 | |
858 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
859 GSList *d = od->direct_ims; | |
860 struct oscar_direct_im *m = NULL; | |
861 | |
862 while (d) { | |
863 m = (struct oscar_direct_im *)d->data; | |
864 if (!aim_sncmp(who, m->name)) | |
865 return m; | |
866 d = d->next; | |
867 } | |
868 | |
869 return NULL; | |
870 } | |
871 | |
872 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
873 { | |
874 gaim_debug_info("oscar", | |
875 "destroying Direct IM for %s.\n", dim->name); | |
876 | |
877 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 878 if (dim->gpc_pend) { |
879 dim->killme = TRUE; | |
880 return; | |
881 } | |
8971 | 882 if (dim->watcher) |
883 gaim_input_remove(dim->watcher); | |
884 if (dim->conn) { | |
10271 | 885 aim_conn_close(dim->conn); |
8971 | 886 aim_conn_kill(od->sess, &dim->conn); |
887 } | |
888 g_free(dim); | |
889 } | |
890 | |
891 /* the only difference between this and destroy is this writes a conv message */ | |
892 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
893 { | |
894 GaimConversation *conv; | |
895 char buf[256]; | |
896 | |
897 gaim_debug_info("oscar", | |
898 "%s disconnected Direct IM.\n", dim->name); | |
899 | |
900 if (dim->connected) | |
901 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 902 else |
8971 | 903 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
904 | |
10246 | 905 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
906 gaim_connection_get_account(dim->gc)); | |
8971 | 907 if (conv) { |
908 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 909 gaim_conversation_update_progress(conv, 0); |
8971 | 910 } else { |
911 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
912 } | |
913 | |
914 oscar_direct_im_destroy(od, dim); | |
915 | |
916 return; | |
917 } | |
918 | |
919 /* oops i made two of these. this one just calls the other one. */ | |
920 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
921 { | |
922 GaimConnection *gc = sess->aux_data; | |
923 OscarData *od = (OscarData *)gc->proto_data; | |
924 struct oscar_direct_im *dim; | |
925 char *sn; | |
926 | |
927 sn = g_strdup(aim_odc_getsn(conn)); | |
928 dim = oscar_direct_im_find(od, sn); | |
929 oscar_direct_im_disconnect(od, dim); | |
930 g_free(sn); | |
931 } | |
932 | |
933 static void destroy_direct_im_request(struct ask_direct *d) { | |
934 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
935 | |
936 g_free(d->sn); | |
937 g_free(d); | |
938 } | |
939 | |
940 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
941 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
942 struct oscar_direct_im *dim = data; | |
943 GaimConnection *gc = dim->gc; | |
944 OscarData *od = gc->proto_data; | |
945 GaimConversation *conv; | |
946 char buf[256]; | |
947 struct sockaddr name; | |
948 socklen_t name_len = 1; | |
949 | |
950 g_return_if_fail(gc != NULL); | |
951 | |
8978 | 952 dim->gpc_pend = FALSE; |
953 if (dim->killme) { | |
954 oscar_direct_im_destroy(od, dim); | |
955 return; | |
956 } | |
957 | |
8971 | 958 if (!g_list_find(gaim_connections_get_all(), gc)) { |
959 oscar_direct_im_destroy(od, dim); | |
960 return; | |
961 } | |
962 | |
963 if (source < 0) { | |
8984 | 964 if (dim->donttryagain) { |
965 oscar_direct_im_disconnect(od, dim); | |
966 return; | |
967 } else { | |
968 fu8_t cookie[8]; | |
969 char *who = g_strdup(dim->name); | |
970 const char *tmp = aim_odc_getcookie(dim->conn); | |
971 | |
972 memcpy(cookie, tmp, 8); | |
973 oscar_direct_im_destroy(od, dim); | |
974 oscar_direct_im_initiate(gc, who, cookie); | |
975 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
976 g_free(who); | |
977 return; | |
978 } | |
8971 | 979 } |
980 | |
981 dim->conn->fd = source; | |
982 aim_conn_completeconnect(od->sess, dim->conn); | |
983 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
984 | |
985 /* This is the best way to see if we're connected or not */ | |
8983 | 986 /* Is this really needed? */ |
8971 | 987 if (getpeername(source, &name, &name_len) == 0) { |
988 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
989 dim->connected = TRUE; | |
990 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 991 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
992 } else { | |
8984 | 993 if (dim->donttryagain) { |
994 oscar_direct_im_disconnect(od, dim); | |
995 return; | |
996 } else { | |
997 fu8_t cookie[8]; | |
998 char *who = g_strdup(dim->name); | |
999 const char *tmp = aim_odc_getcookie(dim->conn); | |
1000 | |
1001 memcpy(cookie, tmp, 8); | |
1002 oscar_direct_im_destroy(od, dim); | |
1003 oscar_direct_im_initiate(gc, who, cookie); | |
1004 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1005 g_free(who); | |
1006 return; | |
1007 } | |
8983 | 1008 } |
1009 | |
1010 | |
8971 | 1011 } |
1012 | |
1013 static void accept_direct_im_request(struct ask_direct *d) { | |
1014 GaimConnection *gc = d->gc; | |
1015 OscarData *od; | |
1016 struct oscar_direct_im *dim; | |
1017 char *host; int port = 5190; | |
1018 int i, rc; | |
8982 | 1019 char *tmp; |
1020 GaimConversation *conv; | |
8971 | 1021 |
1022 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1023 destroy_direct_im_request(d); | |
1024 return; | |
1025 } | |
1026 | |
1027 od = (OscarData *)gc->proto_data; | |
1028 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1029 | |
1030 dim = oscar_direct_im_find(od, d->sn); | |
1031 if (dim && dim->connected) { | |
1032 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1033 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1034 return; | |
1035 } | |
1036 dim = g_new0(struct oscar_direct_im, 1); | |
1037 dim->gc = d->gc; | |
8984 | 1038 dim->donttryagain = d->donttryagain; |
8971 | 1039 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1040 | |
1041 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1042 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1043 if (!dim->conn) { | |
1044 oscar_direct_im_disconnect(od, dim); | |
1045 destroy_direct_im_request(d); | |
1046 return; | |
1047 } | |
1048 | |
1049 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1050 gaim_odc_incoming, 0); | |
1051 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1052 gaim_odc_typing, 0); | |
1053 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1054 gaim_odc_update_ui, 0); | |
1055 | |
1056 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1057 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1058 if (d->ip[i] == ':') { | |
1059 port = atoi(&(d->ip[i+1])); | |
1060 break; | |
1061 } | |
1062 } | |
1063 host = g_strndup(d->ip, i); | |
1064 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1065 dim->gpc_pend = TRUE; |
8971 | 1066 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1067 |
1068 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1069 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1070 port); | |
1071 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1072 g_free(tmp); | |
8983 | 1073 |
8971 | 1074 g_free(host); |
1075 if (rc < 0) { | |
8978 | 1076 dim->gpc_pend = FALSE; |
8971 | 1077 oscar_direct_im_disconnect(od, dim); |
1078 destroy_direct_im_request(d); | |
1079 return; | |
1080 } | |
1081 | |
1082 destroy_direct_im_request(d); | |
1083 | |
1084 return; | |
1085 } | |
1086 | |
1087 /* | |
1088 * We have just established a socket with the other dude, so set up some handlers. | |
1089 */ | |
1090 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1091 GaimConnection *gc = sess->aux_data; |
7283 | 1092 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1093 GaimConversation *conv; |
8971 | 1094 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1095 char buf[256]; |
8971 | 1096 char *sn; |
1097 va_list ap; | |
1098 aim_conn_t *newconn, *listenerconn; | |
1099 | |
1100 va_start(ap, fr); | |
1101 newconn = va_arg(ap, aim_conn_t *); | |
1102 listenerconn = va_arg(ap, aim_conn_t *); | |
1103 va_end(ap); | |
1104 | |
10271 | 1105 aim_conn_close(listenerconn); |
8971 | 1106 aim_conn_kill(sess, &listenerconn); |
1107 | |
1108 sn = g_strdup(aim_odc_getsn(newconn)); | |
1109 | |
1110 gaim_debug_info("oscar", | |
1111 "DirectIM: initiate success to %s\n", sn); | |
1112 dim = oscar_direct_im_find(od, sn); | |
1113 | |
1114 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1115 gaim_input_remove(dim->watcher); | |
1116 dim->conn = newconn; | |
1117 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1118 dim->connected = TRUE; | |
1119 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1120 g_free(sn); | |
1121 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1122 | |
1123 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1124 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1125 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1126 | |
1127 return 1; | |
1128 } | |
1129 | |
1130 /* | |
1131 * This is called when each chunk of an image is received. It can be used to | |
1132 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1133 * nasty, you sicko. | |
1134 */ | |
1135 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1136 va_list ap; | |
1137 char *sn; | |
1138 double percent; | |
1139 GaimConnection *gc = sess->aux_data; | |
1140 OscarData *od = (OscarData *)gc->proto_data; | |
1141 GaimConversation *c; | |
1142 struct oscar_direct_im *dim; | |
1143 | |
1144 va_start(ap, fr); | |
1145 sn = va_arg(ap, char *); | |
1146 percent = va_arg(ap, double); | |
1147 va_end(ap); | |
1148 | |
1149 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1150 return 1; | |
1151 if (dim->watcher) { | |
1152 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1153 /* The callback will callback? I don't get how that would happen here. */ | |
1154 dim->watcher = 0; | |
1155 } | |
1156 | |
10246 | 1157 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1158 gaim_connection_get_account(gc)); | |
8971 | 1159 if (c != NULL) |
1160 gaim_conversation_update_progress(c, percent); | |
1161 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1162 oscar_callback, dim->conn); | |
1163 | |
1164 return 1; | |
1165 } | |
1166 | |
1167 /* | |
1168 * This is called after a direct IM has been received in its entirety. This | |
1169 * function is passed a long chunk of data which contains the IM with any | |
1170 * data chunks (images) appended to it. | |
1171 * | |
1172 * This function rips out all the data chunks and creates an imgstore for | |
1173 * each one. In order to do this, it first goes through the IM and takes | |
1174 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1175 * with one compatible with the imgstore Gaim core code. For each one, we | |
1176 * then read in chunks of data from the end of the message and actually | |
1177 * create the img store using the given data. | |
1178 * | |
1179 * For somewhat easy reference, here's a sample message | |
1180 * (without the whitespace and asterisks): | |
1181 * | |
1182 * <HTML><BODY BGCOLOR="#ffffff"> | |
1183 * <FONT LANG="0"> | |
1184 * This is a really stupid picture:<BR> | |
1185 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1186 * Yeah it is<BR> | |
1187 * Here is another one:<BR> | |
1188 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1189 * </FONT> | |
1190 * </BODY></HTML> | |
1191 * <BINARY> | |
1192 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1193 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1194 * </BINARY> | |
1195 */ | |
1196 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1197 GaimConnection *gc = sess->aux_data; | |
1198 GaimConvImFlags imflags = 0; | |
1199 gchar *utf8; | |
1200 GString *newmsg = g_string_new(""); | |
1201 GSList *images = NULL; | |
1202 va_list ap; | |
1203 const char *sn, *msg, *msgend, *binary; | |
1204 size_t len; | |
1205 int encoding, isawaymsg; | |
1206 | |
1207 va_start(ap, fr); | |
1208 sn = va_arg(ap, const char *); | |
1209 msg = va_arg(ap, const char *); | |
1210 len = va_arg(ap, size_t); | |
1211 encoding = va_arg(ap, int); | |
1212 isawaymsg = va_arg(ap, int); | |
1213 va_end(ap); | |
1214 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1215 |
8660 | 1216 gaim_debug_info("oscar", |
8971 | 1217 "Got DirectIM message from %s\n", sn); |
1218 | |
1219 if (isawaymsg) | |
1220 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1221 | |
1222 /* message has a binary trailer */ | |
1223 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1224 GData *attribs; | |
1225 const char *tmp, *start, *end, *last = NULL; | |
1226 | |
1227 tmp = msg; | |
1228 | |
1229 /* for each valid image tag... */ | |
1230 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1231 const char *id, *src, *datasize; | |
1232 const char *tag = NULL, *data = NULL; | |
1233 size_t size; | |
1234 int imgid = 0; | |
1235 | |
1236 /* update the location of the last img tag */ | |
1237 last = end; | |
1238 | |
1239 /* grab attributes */ | |
1240 id = g_datalist_get_data(&attribs, "id"); | |
1241 src = g_datalist_get_data(&attribs, "src"); | |
1242 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1243 | |
1244 /* if we have id & datasize, build the data tag */ | |
1245 if (id && datasize) | |
1246 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1247 | |
1248 /* if we have a tag, find the start of the data */ | |
1249 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1250 data += strlen(tag); | |
1251 | |
1252 /* check the data is here and store it */ | |
1253 if (data + (size = atoi(datasize)) <= msgend) | |
1254 imgid = gaim_imgstore_add(data, size, src); | |
1255 | |
1256 /* | |
1257 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1258 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1259 */ | |
1260 /* if we have a stored image... */ | |
1261 if (imgid) { | |
1262 /* append the message up to the tag */ | |
1263 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1264 if (utf8 != NULL) { | |
1265 newmsg = g_string_append(newmsg, utf8); | |
1266 g_free(utf8); | |
1267 } | |
1268 | |
1269 /* write the new image tag */ | |
1270 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1271 | |
1272 /* and record the image number */ | |
1273 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1274 } else { | |
1275 /* otherwise, copy up to the end of the tag */ | |
1276 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1277 if (utf8 != NULL) { | |
1278 newmsg = g_string_append(newmsg, utf8); | |
1279 g_free(utf8); | |
1280 } | |
1281 } | |
1282 | |
1283 /* clear the attribute list */ | |
1284 g_datalist_clear(&attribs); | |
1285 | |
1286 /* continue from the end of the tag */ | |
1287 tmp = end + 1; | |
1288 } | |
1289 | |
1290 /* append any remaining message data (without the > :-) */ | |
1291 if (last++ && (last < binary)) | |
1292 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1293 | |
1294 /* set the flag if we caught any images */ | |
1295 if (images) | |
1296 imflags |= GAIM_CONV_IM_IMAGES; | |
1297 } else { | |
1298 g_string_append_len(newmsg, msg, len); | |
1299 } | |
1300 | |
10318 | 1301 /* Convert to UTF8 */ |
1302 /* (This hasn't been tested very much) */ | |
1303 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1304 if (utf8 != NULL) { | |
1305 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1306 g_free(utf8); | |
1307 } | |
1308 | |
1309 /* free the message */ | |
8971 | 1310 g_string_free(newmsg, TRUE); |
1311 | |
1312 /* unref any images we allocated */ | |
1313 if (images) { | |
1314 GSList *tmp; | |
1315 int id; | |
1316 | |
1317 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1318 id = GPOINTER_TO_INT(tmp->data); | |
1319 gaim_imgstore_unref(id); | |
1320 } | |
1321 | |
1322 g_slist_free(images); | |
1323 } | |
1324 | |
1325 return 1; | |
1326 } | |
1327 | |
1328 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1329 va_list ap; | |
1330 char *sn; | |
1331 int typing; | |
1332 GaimConnection *gc = sess->aux_data; | |
1333 | |
1334 va_start(ap, fr); | |
1335 sn = va_arg(ap, char *); | |
1336 typing = va_arg(ap, int); | |
1337 va_end(ap); | |
1338 | |
1339 if (typing == 0x0002) { | |
1340 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1341 gaim_debug_info("oscar", | |
1342 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1343 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1344 } else if (typing == 0x0001) | |
1345 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1346 else | |
1347 serv_got_typing_stopped(gc, sn); | |
1348 return 1; | |
1349 } | |
1350 | |
1351 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1352 char *buf; | |
1353 size_t len; | |
1354 int ret; | |
1355 GString *msg = g_string_new("<HTML><BODY>"); | |
1356 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1357 GData *attribs; | |
1358 const char *start, *end, *last; | |
1359 int oscar_id = 0; | |
1360 | |
1361 last = message; | |
1362 | |
1363 /* for each valid IMG tag... */ | |
1364 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1365 GaimStoredImage *image = NULL; | |
1366 const char *id; | |
1367 | |
1368 if (start - last) { | |
1369 g_string_append_len(msg, last, start - last); | |
1370 } | |
1371 | |
1372 id = g_datalist_get_data(&attribs, "id"); | |
1373 | |
1374 /* ... if it refers to a valid gaim image ... */ | |
1375 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1376 /* ... append the message from start to the tag ... */ | |
9126 | 1377 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1378 const char *filename = gaim_imgstore_get_filename(image); |
1379 gpointer imgdata = gaim_imgstore_get_data(image); | |
1380 | |
1381 oscar_id++; | |
1382 | |
1383 /* ... insert a new img tag with the oscar id ... */ | |
1384 if (filename) | |
1385 g_string_append_printf(msg, | |
9126 | 1386 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1387 filename, oscar_id, size); |
1388 else | |
1389 g_string_append_printf(msg, | |
9126 | 1390 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1391 oscar_id, size); |
1392 | |
1393 /* ... and append the data to the binary section ... */ | |
9126 | 1394 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1395 oscar_id, size); |
1396 data = g_string_append_len(data, imgdata, size); | |
1397 data = g_string_append(data, "</DATA>"); | |
1398 } | |
1399 /* If the tag is invalid, skip it, thus no else here */ | |
1400 | |
1401 g_datalist_clear(&attribs); | |
1402 | |
1403 /* continue from the end of the tag */ | |
1404 last = end + 1; | |
1405 } | |
1406 | |
1407 /* append any remaining message data (without the > :-) */ | |
1408 if (last && *last) | |
1409 msg = g_string_append(msg, last); | |
1410 | |
1411 /* if we inserted any images in the binary section, append it */ | |
1412 if (oscar_id) { | |
1413 msg = g_string_append_len(msg, data->str, data->len); | |
1414 msg = g_string_append(msg, "</BINARY>"); | |
1415 } | |
1416 | |
1417 len = msg->len; | |
1418 buf = msg->str; | |
1419 g_string_free(msg, FALSE); | |
1420 g_string_free(data, TRUE); | |
1421 | |
1422 | |
1423 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1424 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1425 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1426 else | |
1427 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1428 | |
1429 g_free(buf); | |
1430 | |
1431 return ret; | |
1432 } | |
1433 | |
1434 struct ask_do_dir_im { | |
1435 char *who; | |
1436 GaimConnection *gc; | |
1437 }; | |
1438 | |
1439 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1440 g_free(data->who); | |
1441 g_free(data); | |
1442 } | |
1443 | |
8983 | 1444 /* this function is used to initiate a direct im session with someone. |
1445 * we start listening on a port and send a request. they either connect | |
1446 * or send some kind of reply. If they can't connect, they ask us to | |
1447 * connect to them, and so we do that. | |
1448 * | |
1449 * this function will also get called if the other side initiate's a direct | |
1450 * im and we try to connect and fail. in that case cookie will not be null. | |
1451 * | |
1452 * note that cookie is an 8 byte string that isn't NULL terminated | |
1453 */ | |
1454 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1455 OscarData *od; |
1456 struct oscar_direct_im *dim; | |
1457 int listenfd; | |
8982 | 1458 const char *ip; |
8971 | 1459 |
1460 od = (OscarData *)gc->proto_data; | |
1461 | |
8983 | 1462 dim = oscar_direct_im_find(od, who); |
8971 | 1463 if (dim) { |
1464 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1465 oscar_direct_im_disconnect(od, dim); | |
1466 gaim_debug_info("oscar", | |
1467 "Gave up on old direct IM, trying again\n"); | |
1468 } else { | |
1469 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1470 return; |
8971 | 1471 } |
1472 } | |
1473 dim = g_new0(struct oscar_direct_im, 1); | |
1474 dim->gc = gc; | |
8983 | 1475 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1476 |
1477 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1478 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1479 if (listenfd >= 0) |
1480 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1481 if (dim->conn != NULL) { |
8982 | 1482 char *tmp; |
1483 GaimConversation *conv; | |
1484 | |
8971 | 1485 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1486 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1487 oscar_callback, dim->conn); | |
1488 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1489 gaim_odc_initiate, 0); | |
8982 | 1490 |
8983 | 1491 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1492 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1493 gaim_network_get_port_from_fd(listenfd)); |
1494 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1495 g_free(tmp); | |
8971 | 1496 } else { |
1497 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1498 oscar_direct_im_destroy(od, dim); | |
1499 } | |
8983 | 1500 } |
1501 | |
1502 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1503 GaimConnection *gc = data->gc; | |
1504 | |
1505 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1506 g_free(data->who); | |
1507 g_free(data); | |
1508 return; | |
1509 } | |
1510 | |
1511 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1512 g_free(data->who); |
1513 g_free(data); | |
1514 } | |
1515 | |
1516 /* this is the right click menu cb thingy */ | |
9030 | 1517 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1518 | |
1519 GaimBuddy *buddy; | |
1520 GaimConnection *gc; | |
8971 | 1521 gchar *buf; |
9030 | 1522 struct ask_do_dir_im *data; |
1523 | |
1524 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1525 | |
1526 buddy = (GaimBuddy *) node; | |
1527 gc = gaim_account_get_connection(buddy->account); | |
1528 | |
1529 data = g_new0(struct ask_do_dir_im, 1); | |
1530 data->who = g_strdup(buddy->name); | |
8971 | 1531 data->gc = gc; |
9030 | 1532 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1533 buddy->name); | |
8971 | 1534 |
1535 gaim_request_action(gc, NULL, buf, | |
9030 | 1536 _("Because this reveals your IP address, it " |
1537 "may be considered a privacy risk. Do you " | |
1538 "wish to continue?"), | |
1539 0, data, 2, | |
1540 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1541 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1542 g_free(buf); |
1543 } | |
1544 | |
1545 /***************************************************************************** | |
1546 * End scary direct im stuff | |
1547 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1548 |
4617 | 1549 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1550 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1551 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1552 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1553 OscarData *od; |
2086 | 1554 |
1555 if (!gc) { | |
8660 | 1556 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1557 "oscar callback for closed connection (1).\n"); |
2086 | 1558 return; |
1559 } | |
1560 | |
7283 | 1561 od = (OscarData *)gc->proto_data; |
2086 | 1562 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1563 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1564 /* oh boy. this is probably bad. i guess the only thing we |
1565 * can really do is return? */ | |
8660 | 1566 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1567 "oscar callback for closed connection (2).\n"); |
8660 | 1568 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1569 return; |
1570 } | |
1571 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1572 if (condition & GAIM_INPUT_READ) { |
4617 | 1573 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1574 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1575 "got information on rendezvous listener\n"); |
4617 | 1576 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1577 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1578 "connection error (rendezvous listener)\n"); |
4617 | 1579 aim_conn_kill(od->sess, &conn); |
8446 | 1580 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1581 } |
1582 } else { | |
4617 | 1583 if (aim_get_command(od->sess, conn) >= 0) { |
1584 aim_rxdispatch(od->sess); | |
6029 | 1585 if (od->killme) { |
8660 | 1586 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1587 return; |
1588 } | |
2086 | 1589 } else { |
1590 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1591 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1592 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1593 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1594 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1595 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1596 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1597 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1598 char *buf; |
8660 | 1599 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1600 "disconnected from chat room %s\n", c->name); |
2086 | 1601 c->conn = NULL; |
1602 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1603 gaim_input_remove(c->inpa); |
2086 | 1604 c->inpa = 0; |
1605 c->fd = -1; | |
4617 | 1606 aim_conn_kill(od->sess, &conn); |
5420 | 1607 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1608 if (conv) |
1609 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1610 else | |
1611 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1612 g_free(buf); |
2086 | 1613 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1614 if (od->cnpa > 0) |
1615 gaim_input_remove(od->cnpa); | |
1616 od->cnpa = 0; | |
8660 | 1617 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1618 "removing chatnav input watcher\n"); |
4617 | 1619 while (od->create_rooms) { |
1620 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1621 g_free(cr->name); |
4617 | 1622 od->create_rooms = |
1623 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1624 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1625 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1626 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1627 NULL); |
2086 | 1628 } |
4617 | 1629 aim_conn_kill(od->sess, &conn); |
2086 | 1630 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1631 if (od->paspa > 0) |
1632 gaim_input_remove(od->paspa); | |
1633 od->paspa = 0; | |
8660 | 1634 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1635 "removing authconn input watcher\n"); |
4617 | 1636 aim_conn_kill(od->sess, &conn); |
3694 | 1637 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1638 if (od->emlpa > 0) |
1639 gaim_input_remove(od->emlpa); | |
1640 od->emlpa = 0; | |
8660 | 1641 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1642 "removing email input watcher\n"); |
4617 | 1643 aim_conn_kill(od->sess, &conn); |
4804 | 1644 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1645 if (od->icopa > 0) | |
1646 gaim_input_remove(od->icopa); | |
1647 od->icopa = 0; | |
8660 | 1648 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1649 "removing icon input watcher\n"); |
4804 | 1650 aim_conn_kill(od->sess, &conn); |
2086 | 1651 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1652 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1653 gaim_odc_disconnect(od->sess, conn); |
1654 aim_conn_kill(od->sess, &conn); | |
2086 | 1655 } else { |
8660 | 1656 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1657 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1658 conn->type); |
4617 | 1659 aim_conn_kill(od->sess, &conn); |
2086 | 1660 } |
1661 } | |
1662 } | |
1663 } | |
1664 } | |
1665 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1666 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1667 GaimConnection *gc = sess->aux_data; |
7285 | 1668 gchar *s = g_strdup_vprintf(format, va); |
1669 gchar *buf; | |
1670 | |
1671 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1672 gaim_debug_info("oscar", buf); |
7285 | 1673 if (buf[strlen(buf)-1] != '\n') |
8660 | 1674 gaim_debug_info(NULL, "\n"); |
7285 | 1675 g_free(buf); |
2086 | 1676 g_free(s); |
1677 } | |
1678 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1679 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1680 { |
5575 | 1681 GaimConnection *gc = data; |
7283 | 1682 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1683 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1684 aim_conn_t *conn; |
2086 | 1685 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1686 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1687 close(source); |
1688 return; | |
1689 } | |
1690 | |
4617 | 1691 od = gc->proto_data; |
1692 sess = od->sess; | |
2086 | 1693 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1694 conn->fd = source; |
2086 | 1695 |
1696 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1697 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1698 return; |
1699 } | |
1700 | |
1701 aim_conn_completeconnect(sess, conn); | |
4617 | 1702 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1703 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1704 | |
8660 | 1705 gaim_debug_info("oscar", |
7282 | 1706 "Screen name sent, waiting for response\n"); |
7283 | 1707 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1708 ck[1] = 0x65; |
2086 | 1709 } |
1710 | |
5575 | 1711 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1712 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1713 aim_conn_t *conn; |
5575 | 1714 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1715 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1716 |
8660 | 1717 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1718 |
8437 | 1719 if (!aim_snvalid(gaim_account_get_username(account))) { |
1720 gchar *buf; | |
8590 | 1721 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 | 1722 gaim_connection_error(gc, buf); |
1723 g_free(buf); | |
1724 } | |
1725 | |
9975 | 1726 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1727 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1728 } else { |
6622 | 1729 gc->flags |= GAIM_CONNECTION_HTML; |
1730 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1731 } |
5836 | 1732 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1733 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1734 sess = g_new0(aim_session_t, 1); |
10329 | 1735 aim_session_init(sess, TRUE, FAIM_DEBUG_LEVEL); |
2086 | 1736 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1737 /* |
1738 * We need an immediate queue because we don't use a while-loop | |
1739 * to see if things need to be sent. | |
1740 */ | |
2086 | 1741 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1742 od->sess = sess; |
2086 | 1743 sess->aux_data = gc; |
1744 | |
9935 | 1745 /* Connect to core Gaim signals */ |
10087 | 1746 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1747 |
2086 | 1748 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1749 if (conn == NULL) { | |
8660 | 1750 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1751 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1752 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1753 return; |
1754 } | |
1755 | |
4649 | 1756 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1757 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1758 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1759 | |
1760 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1761 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1762 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1763 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1764 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1765 return; |
1766 } | |
7282 | 1767 |
7283 | 1768 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1769 ck[0] = 0x5a; |
5575 | 1770 } |
1771 | |
1772 static void oscar_close(GaimConnection *gc) { | |
7283 | 1773 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1774 |
1775 while (od->oscar_chats) { | |
1776 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1777 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1778 gaim_input_remove(n->inpa); |
2086 | 1779 g_free(n->name); |
1780 g_free(n->show); | |
4617 | 1781 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1782 g_free(n); |
1783 } | |
4617 | 1784 while (od->direct_ims) { |
8971 | 1785 struct oscar_direct_im *n = od->direct_ims->data; |
1786 oscar_direct_im_destroy(od, n); | |
2086 | 1787 } |
4617 | 1788 /* BBB */ |
1789 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1790 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1791 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1792 gaim_xfer_cancel_local(xfer); |
3630 | 1793 } |
4804 | 1794 while (od->requesticon) { |
1795 char *sn = od->requesticon->data; | |
1796 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1797 free(sn); | |
1798 } | |
4738 | 1799 g_hash_table_destroy(od->buddyinfo); |
4617 | 1800 while (od->create_rooms) { |
1801 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1802 g_free(cr->name); |
4617 | 1803 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1804 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1805 } |
4617 | 1806 if (od->email) |
1807 g_free(od->email); | |
1808 if (od->newp) | |
1809 g_free(od->newp); | |
1810 if (od->oldp) | |
1811 g_free(od->oldp); | |
2086 | 1812 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1813 gaim_input_remove(gc->inpa); |
4617 | 1814 if (od->cnpa > 0) |
1815 gaim_input_remove(od->cnpa); | |
1816 if (od->paspa > 0) | |
1817 gaim_input_remove(od->paspa); | |
1818 if (od->emlpa > 0) | |
1819 gaim_input_remove(od->emlpa); | |
4804 | 1820 if (od->icopa > 0) |
1821 gaim_input_remove(od->icopa); | |
6907 | 1822 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1823 gaim_timeout_remove(od->icontimer); |
8341 | 1824 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1825 gaim_timeout_remove(od->getblisttimer); |
8341 | 1826 if (od->getinfotimer > 0) |
1827 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1828 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1829 |
4617 | 1830 aim_session_kill(od->sess); |
1831 g_free(od->sess); | |
1832 od->sess = NULL; | |
2086 | 1833 g_free(gc->proto_data); |
1834 gc->proto_data = NULL; | |
8660 | 1835 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1836 } |
1837 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1838 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1839 GaimConnection *gc = data; |
7283 | 1840 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1841 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1842 aim_conn_t *bosconn; |
2086 | 1843 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1844 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1845 close(source); |
1846 return; | |
1847 } | |
1848 | |
4617 | 1849 od = gc->proto_data; |
1850 sess = od->sess; | |
1851 bosconn = od->conn; | |
4366 | 1852 bosconn->fd = source; |
2086 | 1853 |
1854 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1855 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1856 return; |
1857 } | |
1858 | |
1859 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1860 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1861 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1862 gaim_connection_update_progress(gc, |
7283 | 1863 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1864 ck[4] = 0x61; |
2086 | 1865 } |
1866 | |
4617 | 1867 /* BBB */ |
4656 | 1868 /* |
1869 * This little area in oscar.c is the nexus of file transfer code, | |
1870 * so I wrote a little explanation of what happens. I am such a | |
1871 * ninja. | |
1872 * | |
1873 * The series of events for a file send is: | |
1874 * -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
|
1875 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1876 * listening socket, then asks the remote user to connect to us (and |
1877 * gives them the file name, port, IP, etc.) | |
1878 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1879 * in oscar_sendfile_estblsh) | |
1880 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1881 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1882 * connection. | |
1883 * -We get drunk because file transfer kicks ass. | |
1884 * | |
1885 * The series of events for a file receive is: | |
1886 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1887 * -Gaim user selects file to name and location to save file to and | |
1888 * oscar_xfer_init is called | |
1889 * -It connects to the remote user using the IP they gave us earlier | |
1890 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1891 * them an AIM_CB_OFT_ACK. | |
1892 * -They begin to send us lots of raw data. | |
1893 * -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
|
1894 * the connection. |
4656 | 1895 */ |
1896 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1897 | |
8446 | 1898 /* |
1899 * Miscellaneous xfer functions | |
1900 */ | |
1901 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1902 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1903 GaimXfer *xfer; |
5146 | 1904 struct aim_oft_info *oft_info; |
4656 | 1905 |
1906 while (fts) { | |
1907 xfer = fts->data; | |
5146 | 1908 oft_info = xfer->data; |
1909 | |
8446 | 1910 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1911 return xfer; |
1912 | |
1913 fts = g_slist_next(fts); | |
1914 } | |
1915 | |
1916 return NULL; | |
1917 } | |
1918 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1919 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1920 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1921 GaimXfer *xfer; |
5146 | 1922 struct aim_oft_info *oft_info; |
4656 | 1923 |
1924 while (fts) { | |
1925 xfer = fts->data; | |
5146 | 1926 oft_info = xfer->data; |
1927 | |
1928 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1929 return xfer; |
1930 | |
1931 fts = g_slist_next(fts); | |
1932 } | |
1933 | |
1934 return NULL; | |
1935 } | |
1936 | |
8446 | 1937 static void oscar_xfer_end(GaimXfer *xfer) |
1938 { | |
1939 struct aim_oft_info *oft_info = xfer->data; | |
1940 GaimConnection *gc = oft_info->sess->aux_data; | |
1941 OscarData *od = gc->proto_data; | |
1942 | |
8660 | 1943 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1944 |
1945 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1946 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1947 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1948 } | |
1949 | |
1950 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1951 aim_oft_destroyinfo(oft_info); | |
1952 xfer->data = NULL; | |
1953 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1954 } | |
1955 | |
1956 /* | |
1957 * xfer functions used when receiving files | |
1958 */ | |
1959 | |
1960 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1961 { | |
1962 struct aim_oft_info *oft_info = xfer->data; | |
1963 GaimConnection *gc = oft_info->sess->aux_data; | |
1964 OscarData *od = gc->proto_data; | |
1965 | |
8660 | 1966 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1967 |
1968 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1969 if (oft_info->conn) { | |
1970 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1971 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1972 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1973 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1974 if (xfer->fd == -1) { | |
1975 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1976 _("Unable to establish file descriptor.")); | |
1977 gaim_xfer_cancel_local(xfer); | |
1978 } | |
1979 } else { | |
1980 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1981 _("Unable to create new connection.")); | |
1982 gaim_xfer_cancel_local(xfer); | |
1983 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1984 } | |
1985 | |
1986 } | |
1987 | |
1988 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1989 { | |
1990 struct aim_oft_info *oft_info = xfer->data; | |
1991 GaimConnection *gc = oft_info->sess->aux_data; | |
1992 OscarData *od = gc->proto_data; | |
1993 | |
8660 | 1994 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1995 |
9771 | 1996 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1997 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1998 |
1999 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2000 aim_oft_destroyinfo(oft_info); | |
2001 xfer->data = NULL; | |
2002 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2003 } | |
2004 | |
2005 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
2006 { | |
2007 struct aim_oft_info *oft_info = xfer->data; | |
2008 | |
2009 /* Update our rolling checksum. Like Walmart, yo. */ | |
2010 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2011 } | |
2012 | |
2013 /* | |
2014 * xfer functions used when sending files | |
2015 */ | |
2016 | |
2017 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2018 { | |
2019 struct aim_oft_info *oft_info = xfer->data; | |
2020 GaimConnection *gc = oft_info->sess->aux_data; | |
2021 OscarData *od = gc->proto_data; | |
2022 int listenfd; | |
2023 | |
8660 | 2024 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2025 |
2026 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2027 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2028 oft_info->fh.name[63] = '\0'; | |
2029 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2030 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2031 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2032 | |
2033 /* Create a listening socket and an associated libfaim conn */ | |
2034 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2035 gaim_xfer_cancel_local(xfer); | |
2036 return; | |
2037 } | |
2038 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2039 oft_info->port = xfer->local_port; | |
2040 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2041 gaim_xfer_cancel_local(xfer); | |
2042 return; | |
2043 } | |
8660 | 2044 gaim_debug_misc("oscar", |
8446 | 2045 "port is %hu, ip is %s\n", |
2046 xfer->local_port, oft_info->clientip); | |
2047 if (oft_info->conn) { | |
2048 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2049 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2050 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2051 } else { | |
2052 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2053 _("Unable to establish listener socket.")); | |
2054 gaim_xfer_cancel_local(xfer); | |
2055 } | |
2056 } | |
2057 | |
2058 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2059 { | |
2060 struct aim_oft_info *oft_info = xfer->data; | |
2061 GaimConnection *gc = oft_info->sess->aux_data; | |
2062 OscarData *od = gc->proto_data; | |
2063 | |
8660 | 2064 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2065 |
9771 | 2066 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2067 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2068 |
2069 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2070 aim_oft_destroyinfo(oft_info); | |
2071 xfer->data = NULL; | |
2072 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2073 } | |
2074 | |
2075 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2076 { | |
2077 struct aim_oft_info *oft_info = xfer->data; | |
2078 | |
2079 /* I'm not sure I like how we do this. --marv | |
2080 * I do. AIM file transfers aren't really meant to be thought | |
2081 * of as a transferring just a single file. The rendezvous | |
2082 * establishes a connection between two computers, and then | |
2083 * those computers can use the same connection for transferring | |
2084 * multiple files. So we don't want the Gaim core up and closing | |
2085 * the socket all willy-nilly. We want to do that in the oscar | |
2086 * prpl, whenever one side or the other says they're finished | |
2087 * using the connection. There might be a better way to intercept | |
2088 * the socket from the core, however... --KingAnt | |
2089 */ | |
2090 | |
2091 /* | |
2092 * If we're done sending, intercept the socket from the core ft code | |
2093 * and wait for the other guy to send the "done" OFT packet. | |
2094 */ | |
2095 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2096 gaim_input_remove(xfer->watcher); | |
2097 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2098 xfer->fd = 0; | |
2099 gaim_xfer_set_completed(xfer, TRUE); | |
2100 } | |
2101 } | |
2102 | |
9466 | 2103 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2104 gboolean can_receive = FALSE; | |
2105 OscarData *od = gc->proto_data; | |
2106 | |
2107 if (!od->icq) { | |
2108 aim_userinfo_t *userinfo; | |
2109 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2110 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2111 can_receive = TRUE; | |
2112 } | |
2113 | |
2114 return can_receive; | |
2115 } | |
2116 | |
2117 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2118 |
2119 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2120 GaimXfer *xfer; |
5146 | 2121 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2122 const char *ip; |
3752 | 2123 |
9030 | 2124 od = (OscarData *)gc->proto_data; |
2125 | |
4617 | 2126 /* You want to send a file to someone else, you're so generous */ |
2127 | |
2128 /* Build the file transfer handle */ | |
9466 | 2129 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2130 |
5146 | 2131 /* Create the oscar-specific data */ |
8838 | 2132 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2133 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2134 xfer->data = oft_info; |
2135 | |
4617 | 2136 /* Setup our I/O op functions */ |
8446 | 2137 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2138 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2139 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2140 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2141 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2142 |
2143 /* Keep track of this transfer for later */ | |
2144 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2145 | |
2146 /* Now perform the request */ | |
9466 | 2147 if (file) |
2148 gaim_xfer_request_accepted(xfer, file); | |
2149 else | |
2150 gaim_xfer_request(xfer); | |
3630 | 2151 } |
2152 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2153 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2154 GaimConnection *gc = sess->aux_data; |
7283 | 2155 OscarData *od = gc->proto_data; |
6029 | 2156 GaimAccount *account = gc->account; |
2157 aim_conn_t *bosconn; | |
2158 char *host; int port; | |
2159 int i, rc; | |
2086 | 2160 va_list ap; |
2704 | 2161 struct aim_authresp_info *info; |
6029 | 2162 |
5575 | 2163 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2164 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2165 va_start(ap, fr); |
2704 | 2166 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2167 va_end(ap); |
2168 | |
8660 | 2169 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2170 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2171 |
4293 | 2172 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2173 char buf[256]; |
2704 | 2174 switch (info->errorcode) { |
2086 | 2175 case 0x05: |
2176 /* Incorrect nick/password */ | |
6498 | 2177 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2178 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2179 break; |
2180 case 0x11: | |
2181 /* Suspended account */ | |
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, _("Your account is currently suspended.")); |
2086 | 2184 break; |
3498 | 2185 case 0x14: |
2186 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2187 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2188 break; |
2086 | 2189 case 0x18: |
2190 /* connecting too frequently */ | |
6498 | 2191 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2192 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 | 2193 break; |
2194 case 0x1c: | |
2195 /* client too old */ | |
6498 | 2196 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2197 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
|
2198 gaim_connection_error(gc, buf); |
2086 | 2199 break; |
2200 default: | |
6623 | 2201 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2202 break; |
2203 } | |
8660 | 2204 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2205 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2206 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2207 "Error URL: %s\n", info->errorurl); |
2086 | 2208 od->killme = TRUE; |
2209 return 1; | |
2210 } | |
2211 | |
2212 | |
9992 | 2213 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2214 |
2704 | 2215 if (info->email) { |
8660 | 2216 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2217 } else { |
8660 | 2218 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2219 } |
10042 | 2220 |
8660 | 2221 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2222 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2223 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2224 aim_conn_kill(sess, &fr->conn); |
2086 | 2225 |
2226 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2227 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2228 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2229 od->killme = TRUE; |
2230 return 0; | |
2231 } | |
2232 | |
4649 | 2233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2234 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2235 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2237 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2239 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2240 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2241 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2242 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2243 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2244 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2245 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2246 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2247 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2248 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2249 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2250 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2251 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2252 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2253 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2254 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2255 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
|
2256 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2257 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2258 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2259 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2260 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2261 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2262 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
|
2263 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
|
2264 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
|
2265 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2266 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2267 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2268 #ifndef NOSSI |
4642 | 2269 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2270 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2271 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2272 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2273 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2274 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2275 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2276 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2277 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2278 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2279 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2280 |
7283 | 2281 od->conn = bosconn; |
2704 | 2282 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2283 if (info->bosip[i] == ':') { | |
2284 port = atoi(&(info->bosip[i+1])); | |
2086 | 2285 break; |
2286 } | |
2287 } | |
2704 | 2288 host = g_strndup(info->bosip, i); |
2086 | 2289 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2290 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2291 g_free(host); |
4366 | 2292 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2293 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2294 od->killme = TRUE; |
2295 return 0; | |
2296 } | |
4293 | 2297 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2298 gaim_input_remove(gc->inpa); |
2704 | 2299 |
7283 | 2300 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2301 ck[3] = 0x64; |
7282 | 2302 |
2086 | 2303 return 1; |
2304 } | |
2305 | |
7285 | 2306 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2307 struct pieceofcrap { |
5575 | 2308 GaimConnection *gc; |
2086 | 2309 unsigned long offset; |
2310 unsigned long len; | |
2311 char *modname; | |
2312 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2313 aim_conn_t *conn; |
2086 | 2314 unsigned int inpa; |
2315 }; | |
2316 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2317 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2318 { |
2319 struct pieceofcrap *pos = data; | |
7283 | 2320 OscarData *od = pos->gc->proto_data; |
2086 | 2321 char in = '\0'; |
2322 int x = 0; | |
2323 unsigned char m[17]; | |
2324 | |
2325 while (read(pos->fd, &in, 1) == 1) { | |
2326 if (in == '\n') | |
2327 x++; | |
2328 else if (in != '\r') | |
2329 x = 0; | |
2330 if (x == 2) | |
2331 break; | |
2332 in = '\0'; | |
2333 } | |
2334 if (in != '\n') { | |
4056 | 2335 char buf[256]; |
2336 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
|
2337 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2338 gaim_notify_warning(pos->gc, NULL, |
7422 | 2339 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2340 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2341 gaim_input_remove(pos->inpa); |
2086 | 2342 close(pos->fd); |
2343 g_free(pos); | |
2344 return; | |
2345 } | |
2346 read(pos->fd, m, 16); | |
2347 m[16] = '\0'; | |
8660 | 2348 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2349 for (x = 0; x < 16; x++) |
8660 | 2350 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2351 | |
2352 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2353 gaim_input_remove(pos->inpa); |
2086 | 2354 close(pos->fd); |
2355 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2356 g_free(pos); | |
2357 } | |
2358 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2359 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2360 struct pieceofcrap *pos = data; |
5420 | 2361 gchar *buf; |
2086 | 2362 |
4366 | 2363 pos->fd = source; |
2364 | |
2086 | 2365 if (source < 0) { |
5420 | 2366 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
|
2367 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2368 gaim_notify_warning(pos->gc, NULL, |
7422 | 2369 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2370 buf); |
5420 | 2371 g_free(buf); |
2086 | 2372 if (pos->modname) |
2373 g_free(pos->modname); | |
2374 g_free(pos); | |
2375 return; | |
2376 } | |
2377 | |
5420 | 2378 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2379 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2380 write(pos->fd, buf, strlen(buf)); | |
5420 | 2381 g_free(buf); |
2086 | 2382 if (pos->modname) |
2383 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2384 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2385 return; |
2386 } | |
2387 | |
2388 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2389 #define AIM_MAX_FILE_SIZE 98304 | |
2390 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2391 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2392 va_list ap; |
2393 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2394 fu32_t offset, len; |
2086 | 2395 char *modname; |
2396 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2397 va_start(ap, fr); |
4200 | 2398 offset = va_arg(ap, fu32_t); |
2399 len = va_arg(ap, fu32_t); | |
2086 | 2400 modname = va_arg(ap, char *); |
2401 va_end(ap); | |
2402 | |
8660 | 2403 gaim_debug_misc("oscar", |
5556 | 2404 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2405 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2406 |
2086 | 2407 if (len == 0) { |
8660 | 2408 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2409 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2410 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2411 return 1; | |
2412 } | |
9625 | 2413 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2414 #if 0 | |
2086 | 2415 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2416 char *buf; | |
2417 int i = 8; | |
2418 if (modname) | |
2419 i += strlen(modname); | |
2420 buf = g_malloc(i); | |
2421 i = 0; | |
2422 if (modname) { | |
2423 memcpy(buf, modname, strlen(modname)); | |
2424 i += strlen(modname); | |
2425 } | |
2426 buf[i++] = offset & 0xff; | |
2427 buf[i++] = (offset >> 8) & 0xff; | |
2428 buf[i++] = (offset >> 16) & 0xff; | |
2429 buf[i++] = (offset >> 24) & 0xff; | |
2430 buf[i++] = len & 0xff; | |
2431 buf[i++] = (len >> 8) & 0xff; | |
2432 buf[i++] = (len >> 16) & 0xff; | |
2433 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2434 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2435 "hashing request\n"); |
2086 | 2436 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2437 g_free(buf); | |
2438 return 1; | |
2439 } | |
9625 | 2440 #endif |
2086 | 2441 |
2442 pos = g_new0(struct pieceofcrap, 1); | |
2443 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2444 pos->conn = fr->conn; |
2086 | 2445 |
2446 pos->offset = offset; | |
2447 pos->len = len; | |
2448 pos->modname = modname ? g_strdup(modname) : NULL; | |
2449 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2450 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2451 char buf[256]; |
2086 | 2452 if (pos->modname) |
2453 g_free(pos->modname); | |
2454 g_free(pos); | |
4056 | 2455 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
|
2456 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2457 gaim_notify_warning(pos->gc, NULL, |
7422 | 2458 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2459 buf); |
2086 | 2460 } |
2461 | |
2462 return 1; | |
2463 } | |
2464 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2465 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2466 GaimConnection *gc = sess->aux_data; |
7283 | 2467 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2468 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2469 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2470 #if 0 |
2471 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2472 #endif | |
7011 | 2473 va_list ap; |
2474 char *key; | |
2086 | 2475 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2476 va_start(ap, fr); |
2086 | 2477 key = va_arg(ap, char *); |
2478 va_end(ap); | |
2479 | |
4617 | 2480 if (od->icq) { |
3458 | 2481 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2482 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2483 gaim_account_get_password(account), &info, key); |
3458 | 2484 } else { |
2485 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2486 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2487 gaim_account_get_password(account), &info, key); |
3458 | 2488 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2489 |
7283 | 2490 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2491 ck[2] = 0x6c; |
7282 | 2492 |
2086 | 2493 return 1; |
2494 } | |
2495 | |
2675 | 2496 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2497 GaimConnection *gc = sess->aux_data; |
2647 | 2498 struct chat_connection *chatcon; |
2499 static int id = 1; | |
2500 | |
6905 | 2501 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
|
2502 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
|
2503 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
|
2504 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
|
2505 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2506 |
2672 | 2507 aim_clientready(sess, fr->conn); |
2675 | 2508 |
2647 | 2509 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2510 chatcon->id = id; | |
8733 | 2511 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2512 |
2513 return 1; | |
2514 } | |
2515 | |
2675 | 2516 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2517 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2518 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2519 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2520 |
2521 aim_clientready(sess, fr->conn); | |
2522 | |
2523 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2524 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2525 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2526 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2527 |
3694 | 2528 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2529 | |
2530 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2531 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2532 | |
7282 | 2533 aim_email_sendcookies(sess); |
2534 aim_email_activate(sess); | |
3694 | 2535 aim_clientready(sess, fr->conn); |
2536 | |
2537 return 1; | |
2538 } | |
2539 | |
4804 | 2540 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2541 GaimConnection *gc = sess->aux_data; |
7283 | 2542 OscarData *od = gc->proto_data; |
4804 | 2543 |
2544 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2545 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2546 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2547 | |
2548 aim_clientready(sess, fr->conn); | |
2549 | |
4823 | 2550 od->iconconnecting = FALSE; |
2551 | |
4804 | 2552 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2553 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2554 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2555 |
2556 return 1; | |
2557 } | |
2558 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2559 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2560 GaimConnection *gc = data; |
7283 | 2561 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2562 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2563 aim_conn_t *tstconn; |
2086 | 2564 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2565 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2566 close(source); |
2567 return; | |
2568 } | |
2569 | |
4617 | 2570 od = gc->proto_data; |
2571 sess = od->sess; | |
2086 | 2572 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2573 tstconn->fd = source; |
2086 | 2574 |
2575 if (source < 0) { | |
2576 aim_conn_kill(sess, &tstconn); | |
8660 | 2577 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2578 "unable to connect to chatnav server\n"); |
2086 | 2579 return; |
2580 } | |
2581 | |
2582 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2583 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2584 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2585 } |
2586 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2587 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2588 { |
5575 | 2589 GaimConnection *gc = data; |
7283 | 2590 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2591 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2592 aim_conn_t *tstconn; |
2086 | 2593 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2594 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2595 close(source); |
2596 return; | |
2597 } | |
2598 | |
4617 | 2599 od = gc->proto_data; |
2600 sess = od->sess; | |
2086 | 2601 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2602 tstconn->fd = source; |
2086 | 2603 |
2604 if (source < 0) { | |
2605 aim_conn_kill(sess, &tstconn); | |
8660 | 2606 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2607 "unable to connect to authorizer\n"); |
2086 | 2608 return; |
2609 } | |
2610 | |
2611 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2612 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2613 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2614 } |
2615 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2616 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2617 { |
2618 struct chat_connection *ccon = data; | |
5575 | 2619 GaimConnection *gc = ccon->gc; |
7283 | 2620 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2621 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2622 aim_conn_t *tstconn; |
2086 | 2623 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2624 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2625 close(source); |
2626 g_free(ccon->show); | |
2627 g_free(ccon->name); | |
2628 g_free(ccon); | |
2629 return; | |
2630 } | |
2631 | |
4617 | 2632 od = gc->proto_data; |
2633 sess = od->sess; | |
2086 | 2634 tstconn = ccon->conn; |
4366 | 2635 tstconn->fd = source; |
2086 | 2636 |
2637 if (source < 0) { | |
2638 aim_conn_kill(sess, &tstconn); | |
2639 g_free(ccon->show); | |
2640 g_free(ccon->name); | |
2641 g_free(ccon); | |
2642 return; | |
2643 } | |
2644 | |
2645 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2646 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2647 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2648 } |
2649 | |
3694 | 2650 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2651 GaimConnection *gc = data; |
7283 | 2652 OscarData *od; |
3694 | 2653 aim_session_t *sess; |
2654 aim_conn_t *tstconn; | |
2655 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2656 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2657 close(source); |
2658 return; | |
2659 } | |
2660 | |
4617 | 2661 od = gc->proto_data; |
2662 sess = od->sess; | |
3694 | 2663 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2664 tstconn->fd = source; |
3694 | 2665 |
2666 if (source < 0) { | |
2667 aim_conn_kill(sess, &tstconn); | |
8660 | 2668 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2669 "unable to connect to email server\n"); |
3694 | 2670 return; |
2671 } | |
2672 | |
2673 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2674 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2675 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2676 "email: connected\n"); |
3694 | 2677 } |
2678 | |
4804 | 2679 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2680 GaimConnection *gc = data; |
7283 | 2681 OscarData *od; |
4804 | 2682 aim_session_t *sess; |
2683 aim_conn_t *tstconn; | |
2684 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2685 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2686 close(source); |
2687 return; | |
2688 } | |
2689 | |
2690 od = gc->proto_data; | |
2691 sess = od->sess; | |
2692 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2693 tstconn->fd = source; | |
2694 | |
2695 if (source < 0) { | |
2696 aim_conn_kill(sess, &tstconn); | |
8660 | 2697 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2698 "unable to connect to icon server\n"); |
4804 | 2699 return; |
2700 } | |
2701 | |
2702 aim_conn_completeconnect(sess, tstconn); | |
2703 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2704 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2705 } |
2706 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2707 /* 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
|
2708 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2709 GaimConnection *gc = sess->aux_data; |
2710 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2711 aim_conn_t *tstconn; |
4452 | 2712 int i; |
2086 | 2713 char *host; |
2714 int port; | |
4821 | 2715 va_list ap; |
2716 struct aim_redirect_data *redir; | |
2086 | 2717 |
5575 | 2718 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2719 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2720 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2721 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2722 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2723 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2724 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2725 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2726 port = atoi(&(redir->ip[i+1])); |
2086 | 2727 break; |
2728 } | |
2729 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2730 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2731 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2732 switch(redir->group) { |
2086 | 2733 case 0x7: /* Authorizer */ |
8660 | 2734 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2735 "Reconnecting with authorizor...\n"); |
2086 | 2736 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2737 if (tstconn == NULL) { | |
8660 | 2738 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2739 "unable to reconnect with authorizer\n"); |
2086 | 2740 g_free(host); |
2741 return 1; | |
2742 } | |
4649 | 2743 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2744 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2745 |
2746 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2747 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2748 aim_conn_kill(sess, &tstconn); |
8660 | 2749 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2750 "unable to reconnect with authorizer\n"); |
2086 | 2751 g_free(host); |
2752 return 1; | |
2753 } | |
4293 | 2754 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2755 break; |
2756 | |
2086 | 2757 case 0xd: /* ChatNav */ |
2758 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2759 if (tstconn == NULL) { | |
8660 | 2760 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2761 "unable to connect to chatnav server\n"); |
2086 | 2762 g_free(host); |
2763 return 1; | |
2764 } | |
4649 | 2765 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2766 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2767 |
2768 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2769 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2770 aim_conn_kill(sess, &tstconn); |
8660 | 2771 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2772 "unable to connect to chatnav server\n"); |
2086 | 2773 g_free(host); |
2774 return 1; | |
2775 } | |
4293 | 2776 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2777 break; |
2778 | |
2779 case 0xe: { /* Chat */ | |
2086 | 2780 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2781 |
2086 | 2782 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2783 if (tstconn == NULL) { | |
8660 | 2784 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2785 "unable to connect to chat server\n"); |
2086 | 2786 g_free(host); |
2787 return 1; | |
2788 } | |
2789 | |
4649 | 2790 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2791 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2792 | |
2086 | 2793 ccon = g_new0(struct chat_connection, 1); |
2794 ccon->conn = tstconn; | |
2795 ccon->gc = gc; | |
2796 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2797 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2798 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2799 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2800 ccon->show = extract_name(redir->chat.room); |
4634 | 2801 |
2086 | 2802 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2803 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2804 aim_conn_kill(sess, &tstconn); |
8660 | 2805 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2806 "unable to connect to chat server\n"); |
2086 | 2807 g_free(host); |
2808 g_free(ccon->show); | |
2809 g_free(ccon->name); | |
2810 g_free(ccon); | |
2811 return 1; | |
2812 } | |
4293 | 2813 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2814 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2815 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2816 ccon->name, ccon->exchange); |
4194 | 2817 } break; |
3694 | 2818 |
4804 | 2819 case 0x0010: { /* icon */ |
2820 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2821 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2822 "unable to connect to icon server\n"); |
4804 | 2823 g_free(host); |
2824 return 1; | |
2825 } | |
2826 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2827 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2828 | |
2829 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2830 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2831 aim_conn_kill(sess, &tstconn); |
8660 | 2832 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2833 "unable to connect to icon server\n"); |
4804 | 2834 g_free(host); |
2835 return 1; | |
2836 } | |
2837 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2838 } break; | |
2839 | |
3694 | 2840 case 0x0018: { /* email */ |
2841 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2842 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2843 "unable to connect to email server\n"); |
3694 | 2844 g_free(host); |
2845 return 1; | |
2846 } | |
4649 | 2847 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2848 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2849 | |
2850 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2851 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2852 aim_conn_kill(sess, &tstconn); |
8660 | 2853 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2854 "unable to connect to email server\n"); |
3694 | 2855 g_free(host); |
2856 return 1; | |
2857 } | |
4293 | 2858 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2859 } break; |
2860 | |
2086 | 2861 default: /* huh? */ |
8660 | 2862 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2863 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2864 redir->group); |
2086 | 2865 break; |
2866 } | |
2867 | |
2868 g_free(host); | |
2869 return 1; | |
2870 } | |
2871 | |
10042 | 2872 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
2873 { | |
2874 GaimConnection *gc; | |
2875 GaimAccount *account; | |
2876 OscarData *od; | |
4738 | 2877 struct buddyinfo *bi; |
2993 | 2878 time_t time_idle = 0, signon = 0; |
2879 int type = 0; | |
2880 int caps = 0; | |
2086 | 2881 va_list ap; |
4738 | 2882 aim_userinfo_t *info; |
10042 | 2883 gboolean buddy_is_away = FALSE; |
2884 | |
2885 gc = sess->aux_data; | |
2886 account = gaim_connection_get_account(gc); | |
2887 od = gc->proto_data; | |
4194 | 2888 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2889 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2890 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2891 va_end(ap); |
2892 | |
10130 | 2893 g_return_val_if_fail(info != NULL, 1); |
2894 g_return_val_if_fail(info->sn != NULL, 1); | |
2895 | |
2993 | 2896 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2897 caps = info->capabilities; | |
3267 | 2898 |
4766 | 2899 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2900 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 2901 buddy_is_away = TRUE; |
2902 } | |
2903 | |
2993 | 2904 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2905 type = (info->icqinfo.status << 16); |
3013 | 2906 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2907 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 2908 buddy_is_away = TRUE; |
3013 | 2909 } |
2993 | 2910 } |
2911 | |
7141 | 2912 if (caps & AIM_CAPS_ICQ_DIRECT) |
2913 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2914 |
2915 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2916 time(&time_idle); |
2917 time_idle -= info->idletime*60; | |
9295 | 2918 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2919 } |
2920 | |
5836 | 2921 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2922 signon = info->onlinesince; | |
2923 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2924 signon = time(NULL) - info->sessionlen; |
2086 | 2925 |
9982 | 2926 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) |
5575 | 2927 gaim_connection_set_display_name(gc, info->sn); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2928 |
9982 | 2929 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 2930 if (!bi) { |
2931 bi = g_new0(struct buddyinfo, 1); | |
9982 | 2932 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 2933 } |
4739 | 2934 bi->typingnot = FALSE; |
2935 bi->ico_informed = FALSE; | |
6857 | 2936 bi->ipaddr = info->icqinfo.ipaddr; |
2937 | |
2938 /* Available message stuff */ | |
6292 | 2939 free(bi->availmsg); |
7011 | 2940 if (info->avail != NULL) |
8225 | 2941 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2942 else |
6292 | 2943 bi->availmsg = NULL; |
4732 | 2944 |
4804 | 2945 /* Server stored icon stuff */ |
4853 | 2946 if (info->iconcsumlen) { |
7125 | 2947 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2948 char *b16 = NULL, *filepath = NULL; |
7093 | 2949 GaimBuddy *b = NULL; |
4853 | 2950 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2951 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 2952 b = gaim_find_buddy(account, info->sn); |
7093 | 2953 /* |
2954 * If for some reason the checksum is valid, but cached file is not.. | |
2955 * we want to know. | |
2956 */ | |
7693 | 2957 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2958 if (filename != NULL) { |
2959 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2960 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2961 "icon_checksum"); | |
9801 | 2962 else { |
2963 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2964 filename, NULL); | |
2965 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2966 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2967 "icon_checksum"); | |
2968 g_free(filepath); | |
2969 } | |
7093 | 2970 } else |
2971 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2972 |
4853 | 2973 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2974 GSList *cur = od->requesticon; | |
2975 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2976 cur = cur->next; | |
2977 if (!cur) { | |
9982 | 2978 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 2979 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2980 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2981 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2982 } |
2983 } | |
6053 | 2984 g_free(b16); |
4853 | 2985 } |
2986 | |
10042 | 2987 /* XXX - Represent other ICQ statuses */ |
2988 if (buddy_is_away == TRUE) | |
2989 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
2990 else | |
2991 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
9982 | 2992 gaim_prpl_got_user_login_time(account, info->sn, signon); |
2993 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); | |
2994 | |
2995 if (time_idle > 0) | |
2996 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 2997 else |
2998 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 2999 |
3000 return 1; | |
3001 } | |
3002 | |
8341 | 3003 static void gaim_check_comment(OscarData *od, const char *str) { |
3004 if ((str == NULL) || strcmp(str, ck)) | |
3005 aim_locate_setcaps(od->sess, caps_aim); | |
3006 else | |
3007 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3008 } | |
3009 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3010 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3011 GaimConnection *gc = sess->aux_data; |
7283 | 3012 OscarData *od = gc->proto_data; |
9982 | 3013 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3014 va_list ap; |
4739 | 3015 aim_userinfo_t *info; |
2086 | 3016 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3017 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3018 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3019 va_end(ap); |
3020 | |
9982 | 3021 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3022 |
7261 | 3023 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3024 |
2086 | 3025 return 1; |
3026 } | |
3027 | |
4617 | 3028 /* BBB */ |
3952 | 3029 /* |
4617 | 3030 * This is called after a remote AIM user has connected to us. We |
3031 * want to do some voodoo with the socket file descriptors, add a | |
3032 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3033 */ |
4656 | 3034 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3035 GaimConnection *gc = sess->aux_data; |
7283 | 3036 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3037 GaimXfer *xfer; |
5146 | 3038 struct aim_oft_info *oft_info; |
3630 | 3039 va_list ap; |
3040 aim_conn_t *conn, *listenerconn; | |
4656 | 3041 |
8660 | 3042 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3043 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3044 va_start(ap, fr); |
3045 conn = va_arg(ap, aim_conn_t *); | |
3046 listenerconn = va_arg(ap, aim_conn_t *); | |
3047 va_end(ap); | |
3048 | |
4617 | 3049 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3050 return 1; | |
3051 | |
5146 | 3052 if (!(oft_info = xfer->data)) |
4617 | 3053 return 1; |
3054 | |
3630 | 3055 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3056 gaim_input_remove(xfer->watcher); |
3630 | 3057 aim_conn_kill(sess, &listenerconn); |
3058 | |
5146 | 3059 oft_info->conn = conn; |
3060 xfer->fd = oft_info->conn->fd; | |
3061 | |
3062 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3063 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3064 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3065 |
3066 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3067 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3068 |
3069 return 0; | |
3070 } | |
3071 | |
3952 | 3072 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3073 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3074 * user in order to transfer a file. |
3952 | 3075 */ |
4617 | 3076 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
|
3077 GaimXfer *xfer; |
5146 | 3078 struct aim_oft_info *oft_info; |
4656 | 3079 |
8660 | 3080 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3081 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3082 if (!(xfer = data)) |
3083 return; | |
5146 | 3084 if (!(oft_info = xfer->data)) |
3630 | 3085 return; |
8446 | 3086 if (source < 0) { |
3087 gaim_xfer_cancel_remote(xfer); | |
4617 | 3088 return; |
8446 | 3089 } |
4617 | 3090 |
3091 xfer->fd = source; | |
5146 | 3092 oft_info->conn->fd = source; |
3093 | |
3094 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3095 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3096 |
3097 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3098 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3099 |
3100 return; | |
3630 | 3101 } |
3102 | |
3952 | 3103 /* |
4617 | 3104 * This is called when a buddy sends us some file info. This happens when they |
3105 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3106 * You should send them the exact same info except use the real cookie. We also |
4617 | 3107 * get like totally ready to like, receive the file, kay? |
3952 | 3108 */ |
4617 | 3109 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3110 GaimConnection *gc = sess->aux_data; |
7283 | 3111 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3112 GaimXfer *xfer; |
5146 | 3113 struct aim_oft_info *oft_info; |
4617 | 3114 va_list ap; |
3115 aim_conn_t *conn; | |
3116 fu8_t *cookie; | |
3117 struct aim_fileheader_t *fh; | |
4656 | 3118 |
8660 | 3119 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3120 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3121 va_start(ap, fr); |
3122 conn = va_arg(ap, aim_conn_t *); | |
3123 cookie = va_arg(ap, fu8_t *); | |
3124 fh = va_arg(ap, struct aim_fileheader_t *); | |
3125 va_end(ap); | |
3126 | |
3127 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3128 return 1; | |
3129 | |
5146 | 3130 if (!(oft_info = xfer->data)) |
4617 | 3131 return 1; |
3132 | |
3133 /* We want to stop listening with a normal thingy */ | |
3134 gaim_input_remove(xfer->watcher); | |
3135 xfer->watcher = 0; | |
3136 | |
5146 | 3137 /* They sent us some information about the file they're sending */ |
3138 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3139 | |
3140 /* Fill in the cookie */ | |
3141 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3142 | |
4617 | 3143 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3144 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3145 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3146 | |
3147 return 0; | |
3630 | 3148 } |
3149 | |
3952 | 3150 /* |
4657 | 3151 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3152 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3153 */ |
4617 | 3154 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3155 GaimConnection *gc = sess->aux_data; |
7283 | 3156 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3157 GaimXfer *xfer; |
4617 | 3158 va_list ap; |
3159 aim_conn_t *conn; | |
3160 fu8_t *cookie; | |
3161 struct aim_fileheader_t *fh; | |
4656 | 3162 |
8660 | 3163 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3164 va_start(ap, fr); |
3165 conn = va_arg(ap, aim_conn_t *); | |
3166 cookie = va_arg(ap, fu8_t *); | |
3167 fh = va_arg(ap, struct aim_fileheader_t *); | |
3168 va_end(ap); | |
3169 | |
3170 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3171 return 1; | |
3172 | |
4656 | 3173 /* We want to stop listening with a normal thingy */ |
3174 gaim_input_remove(xfer->watcher); | |
3175 xfer->watcher = 0; | |
3176 | |
4617 | 3177 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3178 | |
3179 return 0; | |
3630 | 3180 } |
4617 | 3181 |
3182 /* | |
3183 * We just sent a file to someone. They said they got it and everything, | |
3184 * so we can close our direct connection and what not. | |
3185 */ | |
3186 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3187 GaimConnection *gc = sess->aux_data; |
7283 | 3188 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3189 GaimXfer *xfer; |
4617 | 3190 va_list ap; |
3191 aim_conn_t *conn; | |
3192 fu8_t *cookie; | |
3193 struct aim_fileheader_t *fh; | |
4656 | 3194 |
8660 | 3195 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3196 va_start(ap, fr); |
3197 conn = va_arg(ap, aim_conn_t *); | |
3198 cookie = va_arg(ap, fu8_t *); | |
3199 fh = va_arg(ap, struct aim_fileheader_t *); | |
3200 va_end(ap); | |
3201 | |
3202 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3203 return 1; | |
3204 | |
4656 | 3205 xfer->fd = conn->fd; |
4617 | 3206 gaim_xfer_end(xfer); |
3207 | |
3208 return 0; | |
3209 } | |
3630 | 3210 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3211 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3212 GaimConnection *gc = sess->aux_data; |
7283 | 3213 OscarData *od = gc->proto_data; |
8708 | 3214 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3215 GaimConvImFlags flags = 0; |
4738 | 3216 struct buddyinfo *bi; |
5575 | 3217 const char *iconfile; |
9806 | 3218 GString *message; |
3219 gchar *tmp; | |
3220 aim_mpmsg_section_t *curpart; | |
3221 | |
3222 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3223 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3224 |
8708 | 3225 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3226 if (!bi) { |
3227 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3228 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3229 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3230 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3231 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3232 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3233 |
4738 | 3234 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3235 bi->typingnot = TRUE; | |
3236 else | |
3237 bi->typingnot = FALSE; | |
3238 | |
4380 | 3239 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3240 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3241 "%s has an icon\n", userinfo->sn); |
4738 | 3242 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3243 bi->ico_need = TRUE; | |
3244 bi->ico_len = args->iconlen; | |
3245 bi->ico_csum = args->iconsum; | |
3246 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3247 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3248 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3249 |
8708 | 3250 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3251 (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
|
3252 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3253 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3254 |
5575 | 3255 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3256 char *buf = g_malloc(st.st_size); |
5575 | 3257 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3258 if (file) { |
9532 | 3259 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3260 int len = fread(buf, 1, st.st_size, file); |
8660 | 3261 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3262 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3263 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3264 userinfo->sn, len, st.st_size); |
4617 | 3265 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3266 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3267 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3268 } else |
8660 | 3269 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3270 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3271 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3272 } else |
8660 | 3273 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3274 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3275 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3276 |
9806 | 3277 message = g_string_new(""); |
3278 curpart = args->mpmsg.parts; | |
3279 while (curpart != NULL) { | |
9908 | 3280 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3281 curpart->data, curpart->datalen); |
3282 if (tmp != NULL) { | |
3283 g_string_append(message, tmp); | |
3284 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3285 } |
9806 | 3286 |
3287 curpart = curpart->next; | |
3288 } | |
3289 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3290 |
8666 | 3291 /* |
8995 | 3292 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3293 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3294 * so any HTML we receive is intended to be displayed |
3295 * | |
3296 * Note: There *may* be some clients which send messages as HTML formatted - | |
3297 * they need to be special-cased somehow. | |
8666 | 3298 */ |
9982 | 3299 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3300 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3301 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3302 g_free(tmp); |
3303 tmp = tmp2; | |
3304 } | |
3305 | |
6982 | 3306 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3307 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3308 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3309 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3310 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3311 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3312 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3313 GaimConnection *gc; |
9933 | 3314 GaimAccount *account; |
9070 | 3315 OscarData *od; |
9933 | 3316 const char *username = NULL; |
3317 char *message = NULL; | |
9070 | 3318 |
3319 g_return_val_if_fail(sess != NULL, 0); | |
3320 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3321 | |
3322 gc = sess->aux_data; | |
9933 | 3323 account = gaim_connection_get_account(gc); |
9070 | 3324 od = gc->proto_data; |
9933 | 3325 username = gaim_account_get_username(account); |
3326 | |
3327 if (args == NULL) | |
4121 | 3328 return 0; |
4194 | 3329 |
9933 | 3330 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3331 userinfo->sn, args->status); | |
3332 | |
3333 if (args->msg != NULL) | |
3334 { | |
3335 if (args->encoding != NULL) | |
3336 { | |
3337 char *encoding = NULL; | |
3338 encoding = oscar_encoding_extract(args->encoding); | |
3339 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3340 g_free(encoding); | |
3341 } else { | |
3342 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3343 message = g_strdup(args->msg); | |
3344 } | |
3345 } | |
2869 | 3346 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3347 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3348 char *name; |
5234 | 3349 GHashTable *components; |
3350 | |
9933 | 3351 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3352 g_free(message); | |
4121 | 3353 return 1; |
9933 | 3354 } |
5234 | 3355 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3356 g_free); | |
4121 | 3357 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3358 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3359 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
|
3360 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3361 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3362 userinfo->sn, |
9933 | 3363 message, |
5234 | 3364 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3365 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3366 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3367 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3368 /* BBB */ |
3369 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3370 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3371 GaimXfer *xfer; |
5146 | 3372 struct aim_oft_info *oft_info; |
3373 | |
3374 if (!args->cookie || !args->port || !args->verifiedip || | |
3375 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3376 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3377 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3378 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3379 "information.\n", userinfo->sn); |
5146 | 3380 if (args->proxyip) |
8660 | 3381 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3382 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3383 "does not support this yet.\n"); |
9933 | 3384 g_free(message); |
4617 | 3385 return 1; |
4656 | 3386 } |
4617 | 3387 |
3388 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3389 /* 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
|
3390 * directory -- remove the star and trailing slash so we don't save |
4617 | 3391 * directories that look like 'dirname\*' -- arl */ |
3392 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3393 if (tmp && (tmp[1] == '*')) { | |
3394 tmp[0] = '\0'; | |
3395 } | |
8660 | 3396 gaim_debug_warning("oscar", |
8446 | 3397 "We're receiving a whole directory! What fun! " |
3398 "Especially since we don't support that!\n"); | |
4617 | 3399 } |
3400 | |
3401 /* Build the file transfer handle */ | |
3402 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3403 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3404 xfer->remote_port = args->port; |
4617 | 3405 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3406 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3407 gaim_xfer_set_message(xfer, message); |
5146 | 3408 |
3409 /* Create the oscar-specific data */ | |
5163 | 3410 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3411 if (args->proxyip) |
5146 | 3412 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3413 if (args->verifiedip) |
5146 | 3414 oft_info->verifiedip = g_strdup(args->verifiedip); |
3415 xfer->data = oft_info; | |
4617 | 3416 |
3417 /* Setup our I/O op functions */ | |
8446 | 3418 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3419 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3420 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
|
3421 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3422 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3423 |
3424 /* Keep track of this transfer for later */ | |
3425 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3426 | |
3427 /* Now perform the request */ | |
3428 gaim_xfer_request(xfer); | |
3429 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3430 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3431 GaimXfer *xfer; |
8660 | 3432 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3433 "AAA - File transfer canceled by remote user\n"); |
4617 | 3434 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
|
3435 gaim_xfer_cancel_remote(xfer); |
4617 | 3436 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3437 /* | |
3438 * This gets sent by the receiver of a file | |
3439 * as they connect directly to us. If we don't | |
3440 * get this, then maybe a third party connected | |
3441 * to us, and we shouldn't send them anything. | |
3442 */ | |
3443 } else { | |
8660 | 3444 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3445 "unknown rendezvous status!\n"); |
3630 | 3446 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3447 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3448 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3449 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3450 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3451 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3452 args->info.icon.length); |
6871 | 3453 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3454 /* 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
|
3455 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3456 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
|
3457 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3458 |
4212 | 3459 if (!args->verifiedip) { |
8983 | 3460 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3461 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3462 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3463 g_free(message); |
4650 | 3464 return 1; |
4212 | 3465 } |
3466 | |
8660 | 3467 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3468 "%s received direct im request from %s (%s)\n", |
8983 | 3469 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3470 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3471 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3472 d->sn = g_strdup(userinfo->sn); |
8983 | 3473 /* Let's use the clientip here, because I think that's what AIM does. |
3474 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3475 * and then ask them to connect to us. */ | |
3476 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
|
3477 memcpy(d->cookie, args->cookie, 8); |
9070 | 3478 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3479 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3480 | |
8971 | 3481 oscar_direct_im_destroy(od, dim); |
8984 | 3482 d->donttryagain = TRUE; |
8971 | 3483 accept_direct_im_request(d); |
3484 } else { | |
8983 | 3485 if (dim && !dim->connected) |
8971 | 3486 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3487 "already connected to that buddy!"); | |
5575 | 3488 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
|
3489 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3490 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3491 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3492 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3493 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3494 "revealed, this may be considered a privacy " |
9972 | 3495 "risk."), |
3496 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3497 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3498 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3499 /* FIXME: we should actually send a packet on cancel */ | |
3500 } | |
8708 | 3501 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3502 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
|
3503 } else { |
8660 | 3504 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3505 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3506 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3507 |
9933 | 3508 g_free(message); |
3509 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3510 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3511 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3512 |
3453 | 3513 /* |
4230 | 3514 * Authorization Functions |
3515 * Most of these are callbacks from dialogs. They're used by both | |
3516 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3517 */ |
4269 | 3518 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3519 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3520 GaimConnection *gc = data->gc; |
4244 | 3521 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3522 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3523 OscarData *od = gc->proto_data; |
6695 | 3524 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3525 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3526 if (buddy && group) { |
8660 | 3527 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3528 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3529 buddy->name, group->name); |
4889 | 3530 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3531 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3532 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3533 } |
4230 | 3534 } |
4337 | 3535 } |
3536 | |
3537 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3538 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3539 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3540 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3541 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3542 data); |
4230 | 3543 } |
3544 | |
3545 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3546 GaimConnection *gc = data->gc; |
4244 | 3547 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3548 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3549 /* Remove from local list */ |
3550 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3551 gaim_blist_remove_buddy(b); | |
4244 | 3552 } |
3553 | |
5836 | 3554 oscar_free_name_data(data); |
4230 | 3555 } |
3556 | |
9030 | 3557 |
3558 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3559 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3560 GaimBuddy *buddy; |
4269 | 3561 gchar *dialog_msg, *nombre; |
3562 | |
4687 | 3563 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3564 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3565 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3566 else |
4830 | 3567 nombre = NULL; |
3568 | |
3569 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 | 3570 data->gc = gc; |
3571 data->name = g_strdup(name); | |
3572 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3573 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3574 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3575 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3576 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3577 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3578 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3579 |
3580 g_free(dialog_msg); | |
3581 g_free(nombre); | |
3582 } | |
3583 | |
9030 | 3584 |
3585 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3586 GaimBuddy *buddy; | |
3587 GaimConnection *gc; | |
3588 | |
3589 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3590 | |
3591 buddy = (GaimBuddy *) node; | |
3592 gc = gaim_account_get_connection(buddy->account); | |
3593 gaim_auth_sendrequest(gc, buddy->name); | |
3594 } | |
3595 | |
4230 | 3596 /* When other people ask you for authorization */ |
3597 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3598 GaimConnection *gc = data->gc; |
4244 | 3599 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3600 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3601 OscarData *od = gc->proto_data; |
4236 | 3602 #ifdef NOSSI |
6695 | 3603 GaimBuddy *buddy; |
4244 | 3604 gchar message; |
3605 message = 0; | |
4687 | 3606 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3607 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3608 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3609 #else |
4889 | 3610 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3611 #endif |
4244 | 3612 } |
3613 | |
5836 | 3614 oscar_free_name_data(data); |
3141 | 3615 } |
3616 | |
4230 | 3617 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3618 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3619 GaimConnection *gc = data->gc; |
4244 | 3620 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3621 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3622 OscarData *od = gc->proto_data; |
4230 | 3623 #ifdef NOSSI |
4617 | 3624 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3625 #else |
4889 | 3626 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3627 #endif |
4244 | 3628 } |
4337 | 3629 } |
3630 | |
3631 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3632 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3633 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3634 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3635 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3636 data); |
3141 | 3637 } |
3638 | |
7023 | 3639 /* When someone sends you buddies */ |
3640 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3641 GaimConnection *gc = data->gc; |
4244 | 3642 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3643 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3644 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3645 } |
3646 | |
5836 | 3647 oscar_free_name_data(data); |
3453 | 3648 } |
3649 | |
4075 | 3650 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 | 3651 GaimConnection *gc = sess->aux_data; |
9908 | 3652 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3653 gchar **msg1, **msg2; |
6051 | 3654 int i, numtoks; |
4076 | 3655 |
4121 | 3656 if (!args->type || !args->msg || !args->uin) |
3657 return 1; | |
4194 | 3658 |
8660 | 3659 gaim_debug_info("oscar", |
9908 | 3660 "Received a channel 4 message of type 0x%02hhx.\n", |
3661 args->type); | |
4076 | 3662 |
9919 | 3663 /* |
3664 * Split up the message at the delimeter character, then convert each | |
3665 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3666 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3667 * character in whatever encoding the message was sent in. Type 1 | |
3668 * messages are always made up of only one part, so we can easily account | |
3669 * for this suck-ass part of the protocol by splitting the string into at | |
3670 * most 1 baby string. | |
3671 */ | |
3672 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3673 for (numtoks=0; msg1[numtoks]; numtoks++); |
3674 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3675 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3676 gaim_str_strip_cr(msg1[i]); |
9908 | 3677 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3678 } |
3679 msg2[i] = NULL; | |
3680 | |
3952 | 3681 switch (args->type) { |
4173 | 3682 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3683 if (i >= 1) { |
5556 | 3684 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3685 gchar *tmp; |
3686 | |
3687 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3688 tmp = gaim_escape_html(msg2[0]); |
8493 | 3689 |
4076 | 3690 if (t) { /* This is an offline message */ |
9680 | 3691 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3692 #ifdef HAVE_TM_GMTOFF |
9724 | 3693 time_t now; |
3694 struct tm *tm; | |
3695 now = time(NULL); | |
3696 tm = localtime(&now); | |
3697 t += tm->tm_gmtoff; | |
9698 | 3698 #else |
3699 # ifdef HAVE_TIMEZONE | |
9680 | 3700 tzset(); |
3701 t -= timezone; | |
9698 | 3702 # endif |
3703 #endif | |
8514 | 3704 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3705 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3706 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3707 } |
3708 g_free(uin); | |
8493 | 3709 g_free(tmp); |
4075 | 3710 } |
3316 | 3711 } break; |
3712 | |
4173 | 3713 case 0x04: { /* Someone sent you a URL */ |
4076 | 3714 if (i >= 2) { |
7385 | 3715 if (msg2[1] != NULL) { |
3716 gchar *uin = g_strdup_printf("%u", args->uin); | |
3717 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3718 msg2[1], | |
3719 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3720 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3721 g_free(uin); | |
3722 g_free(message); | |
3723 } | |
3453 | 3724 } |
3725 } break; | |
3726 | |
4173 | 3727 case 0x06: { /* Someone requested authorization */ |
4076 | 3728 if (i >= 6) { |
4230 | 3729 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3730 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 | 3731 gaim_debug_info("oscar", |
5556 | 3732 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3733 args->uin); |
4076 | 3734 data->gc = gc; |
5556 | 3735 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3736 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3737 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3738 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3739 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3740 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3741 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3742 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3743 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3744 g_free(dialog_msg); |
3745 } | |
3141 | 3746 } break; |
3747 | |
4173 | 3748 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3749 if (i >= 1) { |
7023 | 3750 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
|
3751 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3752 dialog_msg); |
4076 | 3753 g_free(dialog_msg); |
3754 } | |
3141 | 3755 } break; |
3756 | |
4173 | 3757 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3758 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
|
3759 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3760 dialog_msg); |
3141 | 3761 g_free(dialog_msg); |
3762 } break; | |
3763 | |
4333 | 3764 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3765 if (i >= 5) { | |
3766 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
|
3767 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3768 g_free(dialog_msg); |
3769 } | |
3770 } break; | |
3771 | |
4173 | 3772 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3773 if (i >= 6) { |
4194 | 3774 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
|
3775 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3776 g_free(dialog_msg); |
3777 } | |
4075 | 3778 } break; |
3779 | |
4173 | 3780 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3781 if (i >= 6) { |
4308 | 3782 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
|
3783 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3784 g_free(dialog_msg); |
3785 } | |
4075 | 3786 } break; |
3787 | |
4173 | 3788 case 0x12: { |
3141 | 3789 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3790 /* Someone added you to their buddy list? */ |
3141 | 3791 } break; |
3792 | |
7023 | 3793 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3794 guint i, num; |
3453 | 3795 gchar **text; |
4173 | 3796 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3797 if (text) { |
3798 num = 0; | |
3799 for (i=0; i<strlen(text[0]); i++) | |
3800 num = num*10 + text[0][i]-48; | |
3801 for (i=0; i<num; i++) { | |
4230 | 3802 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3803 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 | 3804 data->gc = gc; |
4790 | 3805 data->name = g_strdup(text[i*2+1]); |
3806 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3807 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3808 gaim_request_action(gc, NULL, message, |
7023 | 3809 _("Do you want to add this buddy " |
3810 "to your buddy list?"), | |
9972 | 3811 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3812 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3813 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3814 g_free(message); |
3815 } | |
3816 g_strfreev(text); | |
3817 } | |
3818 } break; | |
3819 | |
7023 | 3820 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3821 /* This is boring and silly. */ |
3822 } break; | |
3823 | |
3141 | 3824 default: { |
8660 | 3825 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3826 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3827 "(type 0x%02hhx).\n", args->type); |
3141 | 3828 } break; |
3829 } | |
3830 | |
4076 | 3831 g_strfreev(msg1); |
3832 g_strfreev(msg2); | |
3833 | |
3141 | 3834 return 1; |
3835 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3836 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3837 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3838 fu16_t channel; |
3839 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3840 aim_userinfo_t *userinfo; |
2086 | 3841 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3842 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3843 va_start(ap, fr); |
4200 | 3844 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3845 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3846 |
3141 | 3847 switch (channel) { |
3848 case 1: { /* standard message */ | |
3849 struct aim_incomingim_ch1_args *args; | |
3850 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3851 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3852 } break; | |
3853 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3854 case 2: { /* rendezvous */ |
3141 | 3855 struct aim_incomingim_ch2_args *args; |
3856 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3857 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3858 } break; | |
3859 | |
3860 case 4: { /* ICQ */ | |
3861 struct aim_incomingim_ch4_args *args; | |
3862 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3863 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3864 } break; |
3865 | |
3866 default: { | |
8660 | 3867 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3868 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3869 "0x%04hx).", channel); |
3141 | 3870 } break; |
2086 | 3871 } |
3872 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3873 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3874 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3875 return ret; |
2086 | 3876 } |
3877 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3878 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3879 GaimConnection *gc = sess->aux_data; |
3880 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3881 char *buf; |
2086 | 3882 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3883 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3884 aim_userinfo_t *userinfo; |
2086 | 3885 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3886 va_start(ap, fr); |
4200 | 3887 chan = (fu16_t)va_arg(ap, unsigned int); |
3888 userinfo = va_arg(ap, aim_userinfo_t *); | |
3889 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3890 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3891 va_end(ap); |
3892 | |
3893 switch(reason) { | |
5420 | 3894 case 0: /* Invalid (0) */ |
3895 buf = g_strdup_printf( | |
3896 ngettext( | |
4276 | 3897 "You missed %hu message from %s because it was invalid.", |
3898 "You missed %hu messages from %s because they were invalid.", | |
3899 nummissed), | |
4282 | 3900 nummissed, |
3901 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3902 break; |
5420 | 3903 case 1: /* Message too large */ |
3904 buf = g_strdup_printf( | |
3905 ngettext( | |
4276 | 3906 "You missed %hu message from %s because it was too large.", |
3907 "You missed %hu messages from %s because they were too large.", | |
3908 nummissed), | |
4282 | 3909 nummissed, |
3910 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3911 break; |
5420 | 3912 case 2: /* Rate exceeded */ |
3913 buf = g_strdup_printf( | |
3914 ngettext( | |
4276 | 3915 "You missed %hu message from %s because the rate limit has been exceeded.", |
3916 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3917 nummissed), | |
4282 | 3918 nummissed, |
3919 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3920 break; |
5420 | 3921 case 3: /* Evil Sender */ |
3922 buf = g_strdup_printf( | |
3923 ngettext( | |
4276 | 3924 "You missed %hu message from %s because he/she was too evil.", |
3925 "You missed %hu messages from %s because he/she was too evil.", | |
3926 nummissed), | |
4282 | 3927 nummissed, |
3928 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3929 break; |
5420 | 3930 case 4: /* Evil Receiver */ |
3931 buf = g_strdup_printf( | |
3932 ngettext( | |
4276 | 3933 "You missed %hu message from %s because you are too evil.", |
3934 "You missed %hu messages from %s because you are too evil.", | |
3935 nummissed), | |
4282 | 3936 nummissed, |
3937 userinfo->sn); | |
2086 | 3938 break; |
3939 default: | |
5420 | 3940 buf = g_strdup_printf( |
3941 ngettext( | |
4276 | 3942 "You missed %hu message from %s for an unknown reason.", |
3943 "You missed %hu messages from %s for an unknown reason.", | |
3944 nummissed), | |
4282 | 3945 nummissed, |
3946 userinfo->sn); | |
2086 | 3947 break; |
3948 } | |
8733 | 3949 |
9627 | 3950 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3951 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3952 g_free(buf); |
2086 | 3953 |
3954 return 1; | |
3955 } | |
3956 | |
4194 | 3957 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3958 GaimConnection *gc = sess->aux_data; |
7283 | 3959 OscarData *od = gc->proto_data; |
4617 | 3960 |
3961 /* BBB */ | |
3630 | 3962 switch (reason) { |
4151 | 3963 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3964 GaimXfer *xfer; |
8971 | 3965 struct oscar_direct_im *dim; |
3966 | |
8660 | 3967 gaim_debug_info("oscar", |
9070 | 3968 "AAA - Other user declined some sort of direct " |
8971 | 3969 "connect attempt (automaticly?)\n"); |
4617 | 3970 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
|
3971 gaim_xfer_cancel_remote(xfer); |
8971 | 3972 else if ((dim = oscar_direct_im_find(od, who))) { |
3973 /* AAA should use find by cookie or something here */ | |
3974 oscar_direct_im_disconnect(od, dim); | |
3975 } | |
4151 | 3976 } break; |
3977 | |
3978 default: { | |
8660 | 3979 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3980 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3981 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3982 } |
3630 | 3983 |
3984 } | |
3985 | |
3986 return 0; | |
3987 } | |
3988 | |
4194 | 3989 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3990 GaimConnection *gc = sess->aux_data; |
4151 | 3991 |
3992 switch(reason) { | |
3993 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3994 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3995 | |
3996 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3997 |
3998 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3999 statusmsg = oscar_icqstatus(state); |
4151 | 4000 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4001 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4002 g_free(statusmsg); | |
4151 | 4003 g_strfreev(splitmsg); |
9244 | 4004 |
9797 | 4005 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4006 |
4007 g_free(title); | |
4008 g_free(dialogmsg); | |
4151 | 4009 } break; |
4010 | |
4011 default: { | |
8660 | 4012 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4013 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4014 "Type 0x%04hx\n", who, reason); |
4151 | 4015 } break; |
4016 } /* end of switch */ | |
4017 | |
4018 return 0; | |
4019 } | |
4020 | |
3212 | 4021 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4022 va_list ap; | |
4023 fu16_t chan, reason; | |
4024 char *who; | |
4025 | |
4026 va_start(ap, fr); | |
4200 | 4027 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4028 who = va_arg(ap, char *); |
4200 | 4029 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4030 |
3952 | 4031 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4032 char *cookie = va_arg(ap, char *); |
4151 | 4033 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4034 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4035 fu32_t state = 0; |
4151 | 4036 char *msg = NULL; |
4037 if (reason == 0x0003) { | |
4200 | 4038 state = va_arg(ap, fu32_t); |
4151 | 4039 msg = va_arg(ap, char *); |
4040 } | |
4041 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4042 } | |
3952 | 4043 |
3212 | 4044 va_end(ap); |
4045 | |
4046 return 1; | |
4047 } | |
4048 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4049 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4050 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4051 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4052 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4053 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4054 va_start(ap, fr); |
4199 | 4055 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4056 va_end(ap); |
4057 | |
8660 | 4058 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4059 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4060 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4061 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4062 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4063 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4064 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4065 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4066 |
2086 | 4067 return 1; |
4068 } | |
4069 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4070 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4071 GaimConnection *gc = sess->aux_data; |
4617 | 4072 #if 0 |
7283 | 4073 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4074 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4075 #endif |
4617 | 4076 va_list ap; |
4077 fu16_t reason; | |
4078 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4079 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4080 va_start(ap, fr); |
4617 | 4081 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4082 data = va_arg(ap, char *); |
2086 | 4083 va_end(ap); |
4084 | |
8660 | 4085 gaim_debug_error("oscar", |
10130 | 4086 "Message error with data %s and reason %hu\n", |
4087 (data != NULL ? data : ""), reason); | |
4617 | 4088 |
4089 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4090 #if 0 |
4617 | 4091 /* If this was a file transfer request, data is a cookie */ |
4092 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
|
4093 gaim_xfer_cancel_remote(xfer); |
3630 | 4094 return 1; |
4095 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4096 #endif |
3630 | 4097 |
4617 | 4098 /* Data is assumed to be the destination sn */ |
9826 | 4099 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4100 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4101 g_free(buf); | |
4102 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4103 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4104 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4105 } | |
4106 g_free(buf); | |
4107 | |
2086 | 4108 return 1; |
4109 } | |
4110 | |
3595 | 4111 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4112 GaimConnection *gc = sess->aux_data; |
3595 | 4113 va_list ap; |
4114 fu16_t type1, type2; | |
4115 char *sn; | |
4116 | |
4117 va_start(ap, fr); | |
4199 | 4118 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4119 sn = va_arg(ap, char *); |
4199 | 4120 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4121 va_end(ap); |
4122 | |
4123 switch (type2) { | |
4124 case 0x0000: { /* Text has been cleared */ | |
4125 serv_got_typing_stopped(gc, sn); | |
4126 } break; | |
4127 | |
4128 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4129 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4130 } break; |
4131 | |
4132 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4133 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4134 } break; |
4135 | |
4136 default: { | |
8660 | 4137 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 | 4138 } break; |
4139 } | |
4140 | |
4141 return 1; | |
4142 } | |
4143 | |
7141 | 4144 /* |
4145 * We get this error when there was an error in the locate family. This | |
7259 | 4146 * happens when you request info of someone who is offline. |
7141 | 4147 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4148 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4149 gchar *buf; |
2086 | 4150 va_list ap; |
5420 | 4151 fu16_t reason; |
2086 | 4152 char *destn; |
4153 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4154 va_start(ap, fr); |
4199 | 4155 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4156 destn = va_arg(ap, char *); |
4157 va_end(ap); | |
4158 | |
7781 | 4159 if (destn == NULL) |
7793 | 4160 return 1; |
9627 | 4161 |
9826 | 4162 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4163 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4164 g_free(buf); | |
9627 | 4165 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4166 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4167 } | |
4168 g_free(buf); | |
2086 | 4169 |
4170 return 1; | |
4171 } | |
4172 | |
7011 | 4173 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4174 GaimConnection *gc = sess->aux_data; |
8700 | 4175 GaimAccount *account = gaim_connection_get_account(gc); |
4176 GString *str; | |
9244 | 4177 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4178 va_list ap; |
7011 | 4179 aim_userinfo_t *userinfo; |
2086 | 4180 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4181 va_start(ap, fr); |
7011 | 4182 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4183 va_end(ap); |
4184 | |
8700 | 4185 str = g_string_new(""); |
4186 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4187 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4188 |
10116 | 4189 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
4190 time_t t = userinfo->onlinesince; | |
4191 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); | |
4192 } | |
4193 | |
4194 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
4195 time_t t = userinfo->membersince; | |
4196 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); | |
4197 } | |
7011 | 4198 |
4199 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4200 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4201 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4202 g_free(tmp); |
4203 } | |
4204 | |
8701 | 4205 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4206 |
4207 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4208 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4209 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4210 g_free(tmp); | |
7011 | 4211 if (away_utf8 != NULL) { |
8700 | 4212 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4213 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4214 } |
7011 | 4215 } |
4216 | |
4217 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4218 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4219 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4220 g_free(tmp); | |
7011 | 4221 if (info_utf8 != NULL) { |
8700 | 4222 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4223 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4224 } |
7011 | 4225 } |
4226 | |
8701 | 4227 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4228 g_string_free(str, TRUE); |
9244 | 4229 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4230 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4231 g_free(title); |
8700 | 4232 g_free(tmp); |
4151 | 4233 |
2086 | 4234 return 1; |
4235 } | |
4236 | |
8341 | 4237 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4238 { | |
4239 aim_session_t *sess = data; | |
4240 GaimConnection *gc = sess->aux_data; | |
4241 OscarData *od = (OscarData *)gc->proto_data; | |
4242 | |
4243 aim_locate_dorequest(data); | |
4244 od->getinfotimer = 0; | |
4245 | |
4246 return FALSE; | |
4247 } | |
4248 | |
4249 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4250 { | |
4251 GaimConnection *gc = sess->aux_data; | |
4252 OscarData *od = (OscarData *)gc->proto_data; | |
4253 | |
4254 /* | |
4255 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4256 * us from hitting the rate limit due to request away messages and info | |
4257 * too quickly. | |
4258 */ | |
4259 if (od->getinfotimer == 0) | |
10198 | 4260 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4261 |
4262 return 1; | |
4263 } | |
4264 | |
4265 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4266 { | |
2086 | 4267 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4268 fu16_t id; |
2086 | 4269 va_list ap; |
4270 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4271 va_start(ap, fr); |
4199 | 4272 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4273 msg = va_arg(ap, char *); |
4274 va_end(ap); | |
4275 | |
8660 | 4276 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4277 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4278 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4279 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4280 _("Your AIM connection may be lost."), NULL); |
2086 | 4281 |
4282 return 1; | |
4283 } | |
4284 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4285 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4286 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4287 fu16_t type; |
5575 | 4288 GaimConnection *gc = sess->aux_data; |
7283 | 4289 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4290 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4291 va_start(ap, fr); |
4199 | 4292 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4293 |
4294 switch(type) { | |
4295 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4296 fu8_t maxrooms; |
2086 | 4297 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4298 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4299 |
4199 | 4300 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4301 exchangecount = va_arg(ap, int); |
4302 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4303 | |
8660 | 4304 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4305 "chat info: Chat Rights:\n"); |
8660 | 4306 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4307 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4308 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4309 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4310 for (i = 0; i < exchangecount; i++) |
8660 | 4311 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4312 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4313 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4314 while (od->create_rooms) { |
4315 struct create_room *cr = od->create_rooms->data; | |
8660 | 4316 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4317 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4318 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4319 g_free(cr->name); |
4617 | 4320 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4321 g_free(cr); |
2086 | 4322 } |
4323 } | |
4324 break; | |
4325 case 0x0008: { | |
4326 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4327 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4328 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4329 fu32_t createtime; |
2086 | 4330 |
4331 fqcn = va_arg(ap, char *); | |
4200 | 4332 instance = (fu16_t)va_arg(ap, unsigned int); |
4333 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4334 flags = (fu16_t)va_arg(ap, unsigned int); | |
4335 createtime = va_arg(ap, fu32_t); | |
4336 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4337 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4338 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4339 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4340 name = va_arg(ap, char *); | |
4341 ck = va_arg(ap, char *); | |
4194 | 4342 |
8660 | 4343 gaim_debug_misc("oscar", |
5556 | 4344 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4345 fqcn, |
4346 exchange, instance, flags, | |
4347 createtime, | |
4348 maxmsglen, maxoccupancy, createperms, unknown, | |
4349 name, ck); | |
4617 | 4350 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4351 } |
4352 break; | |
4353 default: | |
8660 | 4354 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4355 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4356 break; |
4357 } | |
4194 | 4358 |
4359 va_end(ap); | |
4360 | |
2086 | 4361 return 1; |
4362 } | |
4363 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4364 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4365 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4366 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4367 aim_userinfo_t *info; |
5575 | 4368 GaimConnection *g = sess->aux_data; |
2086 | 4369 |
4370 struct chat_connection *c = NULL; | |
4371 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4372 va_start(ap, fr); |
2086 | 4373 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4374 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4375 va_end(ap); |
4376 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4377 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4378 if (!c) |
4379 return 1; | |
4380 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4381 for (i = 0; i < count; i++) |
9846 | 4382 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4383 |
4384 return 1; | |
4385 } | |
4386 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4387 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4388 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4389 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4390 aim_userinfo_t *info; |
5575 | 4391 GaimConnection *g = sess->aux_data; |
2086 | 4392 |
4393 struct chat_connection *c = NULL; | |
4394 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4395 va_start(ap, fr); |
2086 | 4396 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4397 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4398 va_end(ap); |
4399 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4400 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4401 if (!c) |
4402 return 1; | |
4403 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4404 for (i = 0; i < count; i++) |
8733 | 4405 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4406 |
4407 return 1; | |
4408 } | |
4409 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4410 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
|
4411 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4412 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4413 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4414 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4415 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4416 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4417 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4418 fu32_t creationtime; |
5575 | 4419 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4420 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
|
4421 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4422 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4423 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4424 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4425 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4426 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4427 roomdesc = va_arg(ap, char *); |
4200 | 4428 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4429 creationtime = va_arg(ap, fu32_t); | |
4430 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4431 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4432 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4433 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4434 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4435 |
8660 | 4436 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4437 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4438 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4439 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4440 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4441 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4442 |
2086 | 4443 return 1; |
4444 } | |
4445 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4446 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4447 GaimConnection *gc = sess->aux_data; |
8225 | 4448 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4449 gchar *utf8; | |
2086 | 4450 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4451 aim_userinfo_t *info; |
8225 | 4452 int len; |
2086 | 4453 char *msg; |
8219 | 4454 char *charset; |
2086 | 4455 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4456 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4457 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4458 len = va_arg(ap, int); |
4194 | 4459 msg = va_arg(ap, char *); |
8219 | 4460 charset = va_arg(ap, char *); |
4194 | 4461 va_end(ap); |
2086 | 4462 |
8225 | 4463 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4464 if (utf8 == NULL) |
4465 /* The conversion failed! */ | |
8668 | 4466 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4467 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4468 g_free(utf8); | |
2086 | 4469 |
4470 return 1; | |
4471 } | |
4472 | |
3694 | 4473 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4474 va_list ap; | |
5575 | 4475 GaimConnection *gc = sess->aux_data; |
3694 | 4476 struct aim_emailinfo *emailinfo; |
3725 | 4477 int havenewmail; |
7297 | 4478 char *alertitle, *alerturl; |
3694 | 4479 |
4480 va_start(ap, fr); | |
4481 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4482 havenewmail = va_arg(ap, int); |
7301 | 4483 alertitle = va_arg(ap, char *); |
4484 alerturl = va_arg(ap, char *); | |
3694 | 4485 va_end(ap); |
4486 | |
9661 | 4487 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4488 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4489 emailinfo->domain ? "@" : "", | |
4490 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4491 if (emailinfo->unread && havenewmail) |
4492 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4493 g_free(to); |
3694 | 4494 } |
10157 | 4495 |
7301 | 4496 if (alertitle) |
8660 | 4497 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4498 |
4499 return 1; | |
4500 } | |
4501 | |
4804 | 4502 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4503 GaimConnection *gc = sess->aux_data; |
7283 | 4504 OscarData *od = gc->proto_data; |
4804 | 4505 char *sn; |
4506 | |
4507 sn = od->requesticon->data; | |
8660 | 4508 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4509 "removing %s from hash table\n", sn); |
4804 | 4510 od->requesticon = g_slist_remove(od->requesticon, sn); |
4511 free(sn); | |
4512 | |
4513 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4514 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4515 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4516 |
4517 return 1; | |
4518 } | |
4519 | |
4520 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4521 GaimConnection *gc = sess->aux_data; |
7283 | 4522 OscarData *od = gc->proto_data; |
4804 | 4523 GSList *cur; |
4524 va_list ap; | |
4525 char *sn; | |
4853 | 4526 fu8_t *iconcsum, *icon; |
4527 fu16_t iconcsumlen, iconlen; | |
4804 | 4528 |
4529 va_start(ap, fr); | |
4530 sn = va_arg(ap, char *); | |
4853 | 4531 iconcsum = va_arg(ap, fu8_t *); |
4532 iconcsumlen = va_arg(ap, int); | |
4804 | 4533 icon = va_arg(ap, fu8_t *); |
4534 iconlen = va_arg(ap, int); | |
4535 va_end(ap); | |
4536 | |
4853 | 4537 if (iconlen > 0) { |
4538 char *b16; | |
6695 | 4539 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4540 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4541 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4542 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4543 if (b16) { |
7693 | 4544 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4545 g_free(b16); |
5129 | 4546 } |
4853 | 4547 } |
4804 | 4548 |
4549 cur = od->requesticon; | |
4550 while (cur) { | |
4551 char *cursn = cur->data; | |
4552 if (!aim_sncmp(cursn, sn)) { | |
4553 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4554 free(cursn); | |
4555 cur = od->requesticon; | |
4556 } else | |
4557 cur = cur->next; | |
4558 } | |
4559 | |
4560 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4561 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4562 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4563 |
4564 return 1; | |
4565 } | |
4566 | |
4567 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4568 GaimConnection *gc = data; |
7283 | 4569 OscarData *od = gc->proto_data; |
7011 | 4570 aim_userinfo_t *userinfo; |
4804 | 4571 aim_conn_t *conn; |
4572 | |
4573 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4574 if (!conn) { |
4575 if (!od->iconconnecting) { | |
4576 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4577 od->iconconnecting = TRUE; | |
4578 } | |
4804 | 4579 return FALSE; |
4580 } | |
4581 | |
5842 | 4582 if (od->set_icon) { |
6039 | 4583 struct stat st; |
4584 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4585 if (iconfile == NULL) { | |
8363 | 4586 aim_ssi_delicon(od->sess); |
6039 | 4587 } else if (!stat(iconfile, &st)) { |
4588 char *buf = g_malloc(st.st_size); | |
4589 FILE *file = fopen(iconfile, "rb"); | |
4590 if (file) { | |
9532 | 4591 /* XXX - Use g_file_get_contents()? */ |
6039 | 4592 fread(buf, 1, st.st_size, file); |
4593 fclose(file); | |
8660 | 4594 gaim_debug_info("oscar", |
6039 | 4595 "Uploading icon to icon server\n"); |
6879 | 4596 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4597 } else |
8660 | 4598 gaim_debug_error("oscar", |
6039 | 4599 "Can't open buddy icon file!\n"); |
4600 g_free(buf); | |
4601 } else { | |
8660 | 4602 gaim_debug_error("oscar", |
6039 | 4603 "Can't stat buddy icon file!\n"); |
5842 | 4604 } |
4605 od->set_icon = FALSE; | |
4606 } | |
4607 | |
4608 if (!od->requesticon) { | |
8660 | 4609 gaim_debug_misc("oscar", |
5842 | 4610 "no more icons to request\n"); |
4611 return FALSE; | |
4612 } | |
4613 | |
7045 | 4614 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4615 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4616 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4617 return FALSE; |
4618 } else { | |
4619 char *sn = od->requesticon->data; | |
4620 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4621 free(sn); | |
4622 } | |
4623 | |
4624 return TRUE; | |
4625 } | |
4626 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4627 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4628 * 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
|
4629 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4630 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4631 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4632 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4633 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4634 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4635 va_start(ap, fr); |
4199 | 4636 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4637 sn = va_arg(ap, char *); |
4638 va_end(ap); | |
4639 | |
8660 | 4640 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4641 |
4642 return 1; | |
4643 } | |
4644 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4645 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
|
4646 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4647 "invalid", |
4194 | 4648 "change", |
4649 "warning", | |
4650 "limit", | |
4651 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4652 }; |
2086 | 4653 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4654 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4655 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4656 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4657 va_start(ap, fr); |
4200 | 4658 code = (fu16_t)va_arg(ap, unsigned int); |
4659 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4660 windowsize = va_arg(ap, fu32_t); | |
4661 clear = va_arg(ap, fu32_t); | |
4662 alert = va_arg(ap, fu32_t); | |
4663 limit = va_arg(ap, fu32_t); | |
4664 disconnect = va_arg(ap, fu32_t); | |
4665 currentavg = va_arg(ap, fu32_t); | |
4666 maxavg = va_arg(ap, fu32_t); | |
2086 | 4667 va_end(ap); |
4668 | |
8660 | 4669 gaim_debug_misc("oscar", |
5556 | 4670 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4671 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4672 (code < 5) ? codes[code] : codes[0], |
4673 rateclass, | |
4674 currentavg, maxavg, | |
4675 alert, clear, | |
4676 limit, disconnect, | |
4677 windowsize); | |
4678 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4679 /* XXX fix these values */ |
2086 | 4680 if (code == AIM_RATE_CODE_CHANGE) { |
4681 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4682 aim_conn_setlatency(fr->conn, 0); |
2086 | 4683 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4684 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4685 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4686 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4687 _("The last action you attempted could not be " |
4688 "performed because you are over the rate limit. " | |
4689 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4690 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4691 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4692 aim_conn_setlatency(fr->conn, 0); |
2086 | 4693 } |
4694 | |
4695 return 1; | |
4696 } | |
4697 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4698 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4699 GaimConnection *gc = sess->aux_data; |
4700 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4701 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4702 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4703 aim_userinfo_t *userinfo; |
2086 | 4704 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4705 va_start(ap, fr); |
4199 | 4706 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4707 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4708 va_end(ap); |
4709 | |
9982 | 4710 /* XXX - What's with the + 0.5? */ |
4711 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4712 |
4713 return 1; | |
4714 } | |
4715 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4716 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4717 GaimConnection *gc = sess->aux_data; |
4718 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4719 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4720 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4721 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4722 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4723 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4724 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4725 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4726 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4727 |
9982 | 4728 warning_level = info->warnlevel/10.0 + 0.5; |
4729 | |
10152 | 4730 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4731 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4732 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4733 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4734 |
4649 | 4735 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4736 GaimConnection *gc = sess->aux_data; |
7283 | 4737 OscarData *od = gc->proto_data; |
4649 | 4738 va_list ap; |
4739 fu16_t code; | |
4740 char *msg; | |
4741 | |
4742 va_start(ap, fr); | |
4743 code = (fu16_t)va_arg(ap, int); | |
4744 msg = va_arg(ap, char *); | |
4745 va_end(ap); | |
4746 | |
8660 | 4747 gaim_debug_info("oscar", |
10130 | 4748 "Disconnected. Code is 0x%04x and msg is %s\n", code, |
4749 (msg != NULL ? msg : "")); | |
4750 | |
4649 | 4751 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4752 if (code == 0x0001) { |
6113 | 4753 gc->wants_to_die = TRUE; |
5579 | 4754 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4755 } else { |
5579 | 4756 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4757 } |
4666 | 4758 od->killme = TRUE; |
4649 | 4759 } |
4760 | |
4761 return 1; | |
4762 } | |
4763 | |
2675 | 4764 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4765 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4766 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4767 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4768 |
4769 #ifndef NOSSI | |
8660 | 4770 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4771 aim_ssi_reqrights(sess); |
6350 | 4772 aim_ssi_reqdata(sess); |
4230 | 4773 #endif |
4774 | |
7011 | 4775 aim_locate_reqrights(sess); |
7285 | 4776 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4777 aim_im_reqparams(sess); |
7334 | 4778 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4779 |
4780 #ifdef NOSSI | |
8660 | 4781 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4782 aim_bos_reqrights(sess, fr->conn); |
4230 | 4783 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4784 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4785 #endif | |
2086 | 4786 |
7283 | 4787 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4788 | |
2086 | 4789 return 1; |
4790 } | |
4791 | |
2675 | 4792 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4793 GaimConnection *gc = sess->aux_data; |
7283 | 4794 OscarData *od = gc->proto_data; |
2647 | 4795 |
6905 | 4796 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4797 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4798 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4799 | |
2672 | 4800 aim_clientready(sess, fr->conn); |
8660 | 4801 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4802 |
2647 | 4803 if (od->chpass) { |
8660 | 4804 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4805 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4806 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4807 od->oldp = NULL; |
2647 | 4808 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4809 od->newp = NULL; |
2647 | 4810 od->chpass = FALSE; |
4811 } | |
2979 | 4812 if (od->setnick) { |
8660 | 4813 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4814 aim_admin_setnick(sess, fr->conn, od->newsn); |
4815 g_free(od->newsn); | |
4816 od->newsn = NULL; | |
4817 od->setnick = FALSE; | |
4818 } | |
2647 | 4819 if (od->conf) { |
8660 | 4820 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4821 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4822 od->conf = FALSE; |
4823 } | |
4824 if (od->reqemail) { | |
8660 | 4825 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4826 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4827 od->reqemail = FALSE; |
4828 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4829 if (od->setemail) { |
8660 | 4830 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4831 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4832 g_free(od->email); |
5497 | 4833 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4834 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4835 } |
2647 | 4836 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4837 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4838 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4839 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4840 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
|
4841 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4842 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4843 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4844 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4845 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4846 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4847 |
4194 | 4848 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4849 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4850 "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
|
4851 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4852 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4853 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4854 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4855 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4856 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4857 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4858 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4859 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4860 |
4617 | 4861 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4862 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4863 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4864 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4865 |
2993 | 4866 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4867 { | |
5575 | 4868 GaimConnection *gc = sess->aux_data; |
7283 | 4869 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4870 va_list ap; |
4871 fu16_t maxsiglen; | |
2993 | 4872 |
4873 va_start(ap, fr); | |
4199 | 4874 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4875 va_end(ap); |
4876 | |
8660 | 4877 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4878 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4879 |
4617 | 4880 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4881 | |
4882 if (od->icq) | |
7334 | 4883 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4884 else |
7334 | 4885 aim_locate_setcaps(od->sess, caps_aim); |
4886 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4887 |
4888 return 1; | |
4889 } | |
4890 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4891 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
|
4892 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4893 fu16_t maxbuddies, maxwatchers; |
5575 | 4894 GaimConnection *gc = sess->aux_data; |
7283 | 4895 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4896 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4897 va_start(ap, fr); |
4199 | 4898 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4899 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4900 va_end(ap); |
4901 | |
8660 | 4902 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4903 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4904 |
4617 | 4905 od->rights.maxbuddies = (guint)maxbuddies; |
4906 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4907 |
2086 | 4908 return 1; |
4909 } | |
4910 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4911 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4912 GaimConnection *gc = sess->aux_data; |
7283 | 4913 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4914 va_list ap; |
4915 fu16_t maxpermits, maxdenies; | |
2086 | 4916 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4917 va_start(ap, fr); |
4199 | 4918 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4919 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4920 va_end(ap); |
4921 | |
8660 | 4922 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4923 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4924 |
4617 | 4925 od->rights.maxpermits = (guint)maxpermits; |
4926 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4927 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4928 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4929 serv_finish_login(gc); |
4930 | |
8660 | 4931 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4932 |
2672 | 4933 aim_clientready(sess, fr->conn); |
5948 | 4934 aim_srv_setavailmsg(sess, NULL); |
7474 | 4935 aim_srv_setidle(sess, 0); |
4617 | 4936 |
4664 | 4937 if (od->icq) { |
4938 aim_icq_reqofflinemsgs(sess); | |
4939 aim_icq_hideip(sess); | |
4940 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4941 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4942 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4943 if (sess->authinfo->email) |
4944 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4945 |
4946 return 1; | |
4947 } | |
4948 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4949 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
|
4950 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4951 struct aim_icq_offlinemsg *msg; |
4075 | 4952 struct aim_incomingim_ch4_args args; |
4953 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4954 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4955 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4956 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4957 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4958 |
8660 | 4959 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4960 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4961 args.uin = msg->sender; |
4962 args.type = msg->type; | |
4173 | 4963 args.flags = msg->flags; |
4076 | 4964 args.msglen = msg->msglen; |
4075 | 4965 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4966 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4967 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4968 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4969 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4970 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4971 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4972 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
|
4973 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4974 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4975 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4976 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4977 |
7388 | 4978 #if 0 |
4979 /* | |
7465 | 4980 * Update, 2003-11-09: |
4981 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4982 * | |
7388 | 4983 * It may not be my place to do this, but... |
4984 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4985 * stupid, and should not exist for % switches (%x in our case) that request | |
4986 * a year in the preferred representation for the current locale. For that | |
4987 * reason I've chosen to not use this workaround (n., see kluge). | |
4988 * | |
4989 * I have a date. I want to show it to the user in the "preferred" way. | |
4990 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4991 * what the locale wanted. | |
4992 * | |
4993 * If I have a necessity for a full representation of the year in the current | |
4994 * locale, then I'll use a switch that returns a full representation of the | |
4995 * year. | |
4996 * | |
4997 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4998 * (because you're anal, or whatever), then change the f***ing locale. | |
4999 * | |
5000 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5001 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5002 * |
5003 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5004 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5005 */ |
5006 | |
5007 /* | |
5008 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5009 * "last 2 digits" warning. |
5010 */ | |
10157 | 5011 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5012 const struct tm *tm) |
5013 { | |
5014 return strftime(s, max, fmt, tm); | |
5015 } | |
7388 | 5016 #endif |
7386 | 5017 |
4624 | 5018 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
|
5019 { |
5575 | 5020 GaimConnection *gc = sess->aux_data; |
8670 | 5021 OscarData *od = (OscarData *)gc->proto_data; |
5022 GaimBuddy *buddy; | |
8853 | 5023 struct buddyinfo *bi = NULL; |
4624 | 5024 gchar who[16]; |
8670 | 5025 GString *str; |
5026 gchar *primary, *utf8; | |
9634 | 5027 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5028 va_list ap; |
4151 | 5029 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5030 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5031 va_start(ap, fr); |
4151 | 5032 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5033 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5034 |
4664 | 5035 if (!info->uin) |
5036 return 0; | |
5037 | |
8670 | 5038 str = g_string_sized_new(100); |
5556 | 5039 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5040 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5041 if (buddy != NULL) | |
5042 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5043 | |
5044 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5045 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5046 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5047 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5048 (bi->ipaddr & 0xff000000) >> 24, | |
5049 (bi->ipaddr & 0x00ff0000) >> 16, | |
5050 (bi->ipaddr & 0x0000ff00) >> 8, | |
5051 (bi->ipaddr & 0x000000ff)); | |
8701 | 5052 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5053 g_free(tstr); |
5054 } | |
8701 | 5055 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5056 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5057 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5058 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5059 g_free(utf8); | |
4625 | 5060 } |
5061 if (info->numaddresses && info->email2) { | |
5062 int i; | |
5063 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5064 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5065 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5066 g_free(utf8); | |
4643 | 5067 } |
4625 | 5068 } |
4624 | 5069 } |
8701 | 5070 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5071 if (info->gender != 0) |
5072 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5073 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5074 char date[30]; |
5075 struct tm tm; | |
5076 tm.tm_mday = (int)info->birthday; | |
5077 tm.tm_mon = (int)info->birthmonth-1; | |
5078 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5079 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5080 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5081 } |
4624 | 5082 if (info->age) { |
5083 char age[5]; | |
5084 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5085 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5086 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5087 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5088 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5089 g_free(utf8); | |
4819 | 5090 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5091 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5092 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5093 g_free(utf8); | |
5094 } | |
5095 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5096 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5097 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5098 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5099 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5100 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5101 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5102 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5103 } |
4641 | 5104 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5105 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5106 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5107 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5108 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5109 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5110 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5111 } |
4641 | 5112 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5113 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5114 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5115 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5116 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5117 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5118 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5119 g_free(utf8); | |
4624 | 5120 } |
8670 | 5121 g_string_append_printf(str, "\n<hr>\n"); |
5122 } | |
5123 | |
9634 | 5124 if (buddy != NULL) |
5125 alias = gaim_buddy_get_alias(buddy); | |
5126 else | |
5127 alias = who; | |
5128 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5129 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5130 g_free(primary); |
8670 | 5131 g_string_free(str, TRUE); |
4151 | 5132 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5133 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5134 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5135 |
4759 | 5136 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5137 { | |
5575 | 5138 GaimConnection *gc = sess->aux_data; |
4820 | 5139 gchar who[16], *utf8; |
6695 | 5140 GaimBuddy *b; |
4759 | 5141 va_list ap; |
5142 struct aim_icq_info *info; | |
5143 | |
5144 va_start(ap, fr); | |
5145 info = va_arg(ap, struct aim_icq_info *); | |
5146 va_end(ap); | |
5147 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5148 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5149 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5150 serv_got_alias(gc, who, utf8); |
4759 | 5151 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5152 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5153 } |
4820 | 5154 g_free(utf8); |
4759 | 5155 } |
5156 | |
5157 return 1; | |
5158 } | |
5159 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5160 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
|
5161 { |
7032 | 5162 GaimConnection *gc = sess->aux_data; |
5163 gchar *text; | |
5164 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5165 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5166 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5167 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5168 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5169 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5170 url = va_arg(ap, char *); |
4199 | 5171 wid = (fu16_t) va_arg(ap, int); |
5172 hei = (fu16_t) va_arg(ap, int); | |
5173 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5174 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5175 |
7032 | 5176 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5177 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5178 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5179 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5180 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5181 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5182 |
7032 | 5183 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5184 { | |
6873 | 5185 GaimConnection *gc = sess->aux_data; |
5186 gchar *secondary; | |
5187 GString *text; | |
5188 int i, num; | |
2086 | 5189 va_list ap; |
6873 | 5190 char *email, *SNs; |
2086 | 5191 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5192 va_start(ap, fr); |
6873 | 5193 email = va_arg(ap, char *); |
2086 | 5194 num = va_arg(ap, int); |
5195 SNs = va_arg(ap, char *); | |
5196 va_end(ap); | |
5197 | |
8152 | 5198 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5199 text = g_string_new(""); |
2086 | 5200 for (i = 0; i < num; i++) |
6873 | 5201 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5202 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5203 | |
5204 g_free(secondary); | |
5205 g_string_free(text, TRUE); | |
2086 | 5206 |
5207 return 1; | |
5208 } | |
5209 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5210 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5211 va_list ap; |
6873 | 5212 char *email; |
5420 | 5213 char *buf; |
2086 | 5214 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5215 va_start(ap, fr); |
6873 | 5216 email = va_arg(ap, char *); |
2086 | 5217 va_end(ap); |
5218 | |
6873 | 5219 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
|
5220 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5221 g_free(buf); |
2086 | 5222 |
5223 return 1; | |
5224 } | |
5225 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5226 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5227 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5228 fu16_t status; |
2086 | 5229 va_list ap; |
5230 char msg[256]; | |
5231 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5232 va_start(ap, fr); |
4199 | 5233 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5234 va_end(ap); |
5235 | |
8660 | 5236 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5237 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5238 status ? "unknown" : "email sent"); |
5239 if (!status) { | |
5302 | 5240 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5241 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5242 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5243 } |
5244 | |
5245 return 1; | |
5246 } | |
5247 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5248 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5249 GaimConnection *gc = sess->aux_data; |
2086 | 5250 va_list ap; |
3912 | 5251 fu16_t perms, err; |
5252 char *url, *sn, *email; | |
5253 int change; | |
2086 | 5254 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5255 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5256 change = va_arg(ap, int); |
4199 | 5257 perms = (fu16_t) va_arg(ap, unsigned int); |
5258 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5259 url = va_arg(ap, char *); |
5260 sn = va_arg(ap, char *); | |
5261 email = va_arg(ap, char *); | |
2086 | 5262 va_end(ap); |
5263 | |
8660 | 5264 gaim_debug_misc("oscar", |
9626 | 5265 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5266 change ? "change" : "request", perms, err, | |
5267 (url != NULL) ? url : "(null)", | |
5268 (sn != NULL) ? sn : "(null)", | |
5269 (email != NULL) ? email : "(null)"); | |
5270 | |
5271 if ((err > 0) && (url != NULL)) { | |
3912 | 5272 char *dialog_msg; |
5273 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5274 switch (err) { | |
5275 case 0x0001: { | |
5276 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5277 } break; | |
5278 case 0x0006: { | |
5279 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5280 } break; | |
5281 case 0x000b: { | |
5282 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5283 } break; | |
5284 case 0x001d: { | |
5285 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); | |
5286 } break; | |
5287 case 0x0021: { | |
5288 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); | |
5289 } break; | |
5290 case 0x0023: { | |
5291 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5292 } break; | |
5293 default: { | |
5294 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5295 } break; | |
5296 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5297 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5298 g_free(dialog_top); |
5299 g_free(dialog_msg); | |
5300 return 1; | |
5301 } | |
5302 | |
9626 | 5303 if (sn != NULL) { |
4585 | 5304 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
|
5305 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5306 g_free(dialog_msg); |
5307 } | |
5308 | |
9626 | 5309 if (email != NULL) { |
5575 | 5310 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5311 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5312 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5313 g_free(dialog_msg); |
2086 | 5314 } |
5315 | |
5316 return 1; | |
5317 } | |
5318 | |
5575 | 5319 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5320 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5321 aim_flap_nop(od->sess, od->conn); |
2086 | 5322 } |
5323 | |
6059 | 5324 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5325 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5326 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5327 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5328 if (typing == GAIM_TYPING) |
4870 | 5329 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5330 else if (typing == GAIM_TYPED) |
4870 | 5331 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5332 else | |
5333 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5334 else { |
5300 | 5335 /* Don't send if this turkey is in our deny list */ |
5336 GSList *list; | |
5337 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5338 if (!list) { | |
7261 | 5339 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5340 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5341 if (typing == GAIM_TYPING) |
5300 | 5342 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5343 else if (typing == GAIM_TYPED) |
5300 | 5344 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5345 else | |
5346 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5347 } | |
3595 | 5348 } |
5349 } | |
2993 | 5350 return 0; |
5351 } | |
9030 | 5352 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5353 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
|
5354 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5355 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5356 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5357 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5358 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
|
5359 int ret = 0; |
10246 | 5360 const char *iconfile = gaim_account_get_buddy_icon(account); |
8800 | 5361 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5362 |
4838 | 5363 if (dim && dim->connected) { |
5364 /* If we're directly connected, send a direct IM */ | |
6982 | 5365 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5366 } else { |
4738 | 5367 struct buddyinfo *bi; |
3008 | 5368 struct aim_sendimext_args args; |
5369 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5370 gsize len; |
10246 | 5371 GaimConversation *conv; |
5372 | |
5373 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5374 |
5375 if (strstr(message, "<IMG ")) | |
5376 gaim_conversation_write(conv, "", | |
5377 _("Your IM Image was not sent. " | |
5378 "You must be Direct Connected to send IM Images."), | |
5379 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5380 |
10246 | 5381 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5382 if (!bi) { |
5383 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5384 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5385 } |
5386 | |
3008 | 5387 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5388 if (od->icq) { |
5389 args.features = features_icq; | |
5390 args.featureslen = sizeof(features_icq); | |
3008 | 5391 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5392 } else { |
5393 args.features = features_aim; | |
5394 args.featureslen = sizeof(features_aim); | |
4972 | 5395 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5396 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5397 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5398 } |
4269 | 5399 |
4738 | 5400 if (bi->ico_need) { |
8660 | 5401 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5402 "Sending buddy icon request with message\n"); |
3008 | 5403 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5404 bi->ico_need = FALSE; |
3008 | 5405 } |
4269 | 5406 |
5575 | 5407 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5408 FILE *file = fopen(iconfile, "rb"); |
3008 | 5409 if (file) { |
5410 char *buf = g_malloc(st.st_size); | |
9532 | 5411 /* XXX - Use g_file_get_contents()? */ |
3008 | 5412 fread(buf, 1, st.st_size, file); |
6039 | 5413 fclose(file); |
4269 | 5414 |
3008 | 5415 args.iconlen = st.st_size; |
4617 | 5416 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5417 args.iconstamp = st.st_mtime; |
5418 | |
7406 | 5419 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5420 bi->ico_informed = FALSE; |
7406 | 5421 bi->ico_sent = FALSE; |
5422 } | |
4738 | 5423 |
5424 if (!bi->ico_informed) { | |
8660 | 5425 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5426 "Claiming to have a buddy icon\n"); |
4738 | 5427 args.flags |= AIM_IMFLAGS_HASICON; |
5428 bi->ico_me_len = args.iconlen; | |
5429 bi->ico_me_csum = args.iconsum; | |
5430 bi->ico_me_time = args.iconstamp; | |
5431 bi->ico_informed = TRUE; | |
5432 } | |
5433 | |
3008 | 5434 g_free(buf); |
2086 | 5435 } |
5436 } | |
4269 | 5437 |
3008 | 5438 args.destsn = name; |
4269 | 5439 |
8985 | 5440 /* |
5441 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5442 * strip all HTML | |
5443 */ | |
9975 | 5444 if (aim_sn_is_icq(name) ) { |
8995 | 5445 /* being sent to an ICQ user */ |
10246 | 5446 if (!aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5447 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5448 tmpmsg = gaim_str_add_cr(message); | |
5449 } else { | |
5450 /* from an ICQ user - do nothing */ | |
5451 tmpmsg = g_strdup(message); | |
5452 } | |
5453 } else { | |
5454 /* being sent to an AIM user */ | |
10246 | 5455 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5456 /* from an ICQ user */ |
5457 tmpmsg2 = gaim_strdup_withhtml(message); | |
5458 tmpmsg = gaim_escape_html(tmpmsg2); | |
5459 g_free(tmpmsg2); | |
5460 } else | |
5461 tmpmsg = gaim_strdup_withhtml(message); | |
5462 } | |
6310 | 5463 len = strlen(tmpmsg); |
5464 | |
9830 | 5465 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5466 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5467 args.charset, args.charsubset, args.msglen); | |
4617 | 5468 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5469 g_free((char *)args.msg); |
2086 | 5470 } |
4838 | 5471 |
6310 | 5472 g_free(tmpmsg); |
5473 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5474 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5475 return 1; |
6310 | 5476 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5477 return ret; |
2086 | 5478 } |
5479 | |
7011 | 5480 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5481 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5482 |
9975 | 5483 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5484 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5485 else |
7235 | 5486 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5487 } |
5488 | |
8950 | 5489 #if 0 |
7011 | 5490 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5491 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5492 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5493 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5494 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5495 maiden, NULL, NULL, city, state, NULL, 0, web); |
5496 } | |
8950 | 5497 #endif |
2086 | 5498 |
5575 | 5499 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5500 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5501 aim_srv_setidle(od->sess, time); |
2086 | 5502 } |
5503 | |
5954 | 5504 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5505 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5506 int charset = 0; |
6019 | 5507 char *text_html = NULL; |
5129 | 5508 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5509 gsize msglen = 0; |
2993 | 5510 |
4617 | 5511 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5512 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5513 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5514 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5515 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5516 "again when you are fully connected.")); |
4617 | 5517 |
7334 | 5518 if (!text) { |
5519 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5520 return; | |
5521 } | |
10097 | 5522 |
7334 | 5523 text_html = gaim_strdup_withhtml(text); |
9807 | 5524 charset = oscar_charset_check(text_html); |
9826 | 5525 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5526 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5527 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5528 g_free(msg); | |
9826 | 5529 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5530 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5531 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5532 g_free(msg); | |
5533 } else { | |
5534 msglen = strlen(text_html); | |
5535 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5536 } | |
5537 | |
5538 if (msglen > od->rights.maxsiglen) { | |
5539 gchar *errstr; | |
5540 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5541 "has been exceeded. Gaim has truncated it for you.", | |
5542 "The maximum profile length of %d bytes " | |
5543 "has been exceeded. Gaim has truncated it for you.", | |
5544 od->rights.maxsiglen), od->rights.maxsiglen); | |
5545 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5546 g_free(errstr); | |
5547 } | |
5548 | |
5549 g_free(text_html); | |
2993 | 5550 |
5551 return; | |
2086 | 5552 } |
5553 | |
9991 | 5554 static void |
5555 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5556 { |
9991 | 5557 GaimConnection *gc = gaim_account_get_connection(account); |
5558 OscarData *od = (OscarData *)gc->proto_data; | |
9992 | 5559 GaimStatusType *status_type; |
9991 | 5560 GaimStatusPrimitive primitive; |
5561 GaimPresence *presence; | |
5562 const gchar *status_id; | |
9807 | 5563 int charset = 0; |
10196 | 5564 const gchar *text_html = NULL; |
5129 | 5565 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5566 gsize msglen = 0; |
2993 | 5567 |
9992 | 5568 status_type = gaim_status_get_type(status); |
5569 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5570 status_id = gaim_status_get_id(status); |
5571 presence = gaim_account_get_presence(account); | |
5572 | |
10196 | 5573 gaim_debug_info("oscar", "Setting status to %s\n", status_id); |
5574 | |
2993 | 5575 if (od->rights.maxawaymsglen == 0) |
9991 | 5576 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
|
5577 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5578 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5579 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5580 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5581 "fully connected.")); |
5129 | 5582 |
9992 | 5583 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5584 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5585 | |
7334 | 5586 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5587 |
5588 text_html = gaim_status_get_attr_string(status, "message"); | |
5589 if (text_html != NULL) { | |
5590 aim_srv_setavailmsg(od->sess, text_html); | |
5591 } | |
10196 | 5592 |
5593 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5594 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5595 | |
10196 | 5596 text_html = gaim_status_get_attr_string(status, "message"); |
5597 | |
5598 if (text_html == NULL) { | |
5599 text_html = _("Away"); | |
5600 } | |
5601 | |
5602 charset = oscar_charset_check(text_html); | |
5603 if (charset == AIM_CHARSET_UNICODE) { | |
5604 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5605 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5606 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5607 g_free(msg); | |
5608 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5609 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5610 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5611 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5612 g_free(msg); | |
5613 } else { | |
5614 msglen = strlen(text_html); | |
5615 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5616 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5617 } | |
5618 | |
5619 if (msglen > od->rights.maxawaymsglen) { | |
5620 gchar *errstr; | |
5621 | |
5622 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
5623 "has been exceeded. Gaim has truncated it for you.", | |
5624 "The maximum away message length of %d bytes " | |
5625 "has been exceeded. Gaim has truncated it for you.", | |
5626 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5627 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5628 g_free(errstr); | |
5629 } | |
5630 | |
10197 | 5631 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5632 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5633 | |
5129 | 5634 } else { |
10196 | 5635 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5636 | |
5637 } | |
2993 | 5638 } |
5639 | |
9991 | 5640 static void |
5641 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5642 { |
9991 | 5643 GaimConnection *gc = gaim_account_get_connection(account); |
5644 OscarData *od = (OscarData *)gc->proto_data; | |
5645 const gchar *status_id = gaim_status_get_id(status); | |
5646 | |
5647 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) | |
5575 | 5648 account->perm_deny = 4; |
8265 | 5649 else |
5575 | 5650 account->perm_deny = 3; |
9991 | 5651 |
8265 | 5652 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5653 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5654 |
9991 | 5655 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5656 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5657 |
5658 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5659 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5660 |
5661 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5662 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5663 |
5664 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5665 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5666 |
5667 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5668 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5669 |
5670 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5671 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5672 |
5673 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5674 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5675 |
5676 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5677 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5678 |
5679 return; | |
5680 } | |
5681 | |
9991 | 5682 static void |
5683 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5684 { |
9991 | 5685 GaimConnection *gc = gaim_account_get_connection(account); |
5686 OscarData *od = (OscarData *)gc->proto_data; | |
2993 | 5687 |
5688 if (od->icq) | |
9988 | 5689 oscar_set_status_icq(account, status); |
2993 | 5690 else |
9988 | 5691 oscar_set_status_aim(account, status); |
2993 | 5692 |
5693 return; | |
2086 | 5694 } |
5695 | |
9991 | 5696 static void |
5697 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5698 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5699 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5700 } |
5701 | |
9285 | 5702 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5703 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5704 |
5705 if (!aim_snvalid(buddy->name)) { | |
8092 | 5706 gchar *buf; |
9285 | 5707 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 | 5708 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5709 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5710 g_free(buf); |
8150 | 5711 |
5712 /* Remove from local list */ | |
9285 | 5713 gaim_blist_remove_buddy(buddy); |
8150 | 5714 |
8092 | 5715 return; |
5716 } | |
5717 | |
4230 | 5718 #ifdef NOSSI |
9285 | 5719 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5720 #else |
9285 | 5721 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5722 if (buddy && group) { | |
8660 | 5723 gaim_debug_info("oscar", |
9285 | 5724 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5725 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5726 } |
5727 } | |
5728 #endif | |
8150 | 5729 |
10157 | 5730 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5731 if (od->icq) |
9285 | 5732 aim_icq_getalias(od->sess, buddy->name); |
5733 } | |
5734 | |
5735 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5736 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5737 #ifdef NOSSI |
5738 char buf[MSG_LEN]; | |
5739 int n=0; | |
9285 | 5740 |
4230 | 5741 while (buddies) { |
9381 | 5742 GaimBuddy *buddy = buddies->data; |
4230 | 5743 if (n > MSG_LEN - 18) { |
7285 | 5744 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5745 n = 0; |
3092 | 5746 } |
9381 | 5747 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5748 buddies = buddies->next; |
5749 } | |
7285 | 5750 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5751 #else |
9285 | 5752 |
4230 | 5753 if (od->sess->ssi.received_data) { |
9285 | 5754 GList *curb = buddies; |
5755 GList *curg = groups; | |
5756 while ((curb != NULL) && (curg != NULL)) { | |
5757 GaimBuddy *buddy = curb->data; | |
5758 GaimGroup *group = curg->data; | |
5759 oscar_add_buddy(gc, buddy, group); | |
5760 curb = curb->next; | |
5761 curg = curg->next; | |
4230 | 5762 } |
5763 } | |
5764 #endif | |
5765 } | |
5766 | |
9285 | 5767 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5768 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5769 |
4230 | 5770 #ifdef NOSSI |
9285 | 5771 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5772 #else |
5773 if (od->sess->ssi.received_data) { | |
8660 | 5774 gaim_debug_info("oscar", |
9285 | 5775 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5776 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5777 } |
5778 #endif | |
5779 } | |
5780 | |
9285 | 5781 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5782 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5783 |
4230 | 5784 #ifdef NOSSI |
9285 | 5785 for (cur = buddies; cur != NULL; cur = cur->next) { |
5786 GaimBuddy *buddy = cur->data; | |
5787 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5788 } | |
4230 | 5789 #else |
5790 if (od->sess->ssi.received_data) { | |
9285 | 5791 GList *curb = buddies; |
5792 GList *curg = groups; | |
5793 while ((curb != NULL) && (curg != NULL)) { | |
5794 GaimBuddy *buddy = curb->data; | |
5795 GaimGroup *group = curg->data; | |
5796 oscar_remove_buddy(gc, buddy, group); | |
5797 curb = curb->next; | |
5798 curg = curg->next; | |
3092 | 5799 } |
4230 | 5800 } |
5801 #endif | |
5802 } | |
5803 | |
5804 #ifndef NOSSI | |
5575 | 5805 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5806 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5807 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5808 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5809 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5810 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5811 } |
5812 } | |
5813 | |
5575 | 5814 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5815 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5816 if (od->sess->ssi.received_data) { |
5817 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5818 if (gname) { | |
8660 | 5819 gaim_debug_info("oscar", |
9586 | 5820 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5821 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5822 } |
5823 } | |
5824 } | |
5825 | |
9285 | 5826 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5827 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5828 |
5829 if (od->sess->ssi.received_data) { | |
9285 | 5830 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5831 GList *cur, *groups = NULL; | |
5832 | |
5833 /* Make a list of what the groups each buddy is in */ | |
5834 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5835 GaimBlistNode *node = cur->data; | |
5836 groups = g_list_append(groups, node->parent); | |
5837 } | |
5838 | |
5839 oscar_remove_buddies(gc, moved_buddies, groups); | |
5840 oscar_add_buddies(gc, moved_buddies, groups); | |
5841 g_list_free(groups); | |
8660 | 5842 gaim_debug_info("oscar", |
9285 | 5843 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5844 } else { |
9285 | 5845 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5846 gaim_debug_info("oscar", |
9285 | 5847 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5848 } |
5849 } | |
5850 } | |
5851 | |
5968 | 5852 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5853 aim_session_t *sess = data; | |
6350 | 5854 aim_ssi_reqdata(sess); |
5968 | 5855 return FALSE; |
5856 } | |
5857 | |
4642 | 5858 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5859 GaimConnection *gc = sess->aux_data; |
7283 | 5860 OscarData *od = gc->proto_data; |
4642 | 5861 va_list ap; |
5862 fu16_t reason; | |
5863 | |
5864 va_start(ap, fr); | |
5865 reason = (fu16_t)va_arg(ap, unsigned int); | |
5866 va_end(ap); | |
5867 | |
8660 | 5868 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5869 |
5870 if (reason == 0x0005) { | |
5892 | 5871 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5872 _("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
|
5873 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5874 } |
5875 | |
5876 /* Activate SSI */ | |
5877 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5878 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5879 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5880 aim_ssi_enable(od->sess); |
5881 | |
5882 return 1; | |
5883 } | |
5884 | |
2991 | 5885 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5886 GaimConnection *gc = sess->aux_data; |
7283 | 5887 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 5888 int i; |
5889 va_list ap; | |
5890 int numtypes; | |
4230 | 5891 fu16_t *maxitems; |
2991 | 5892 |
5893 va_start(ap, fr); | |
4230 | 5894 numtypes = va_arg(ap, int); |
5895 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5896 va_end(ap); |
5897 | |
8660 | 5898 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5899 |
4230 | 5900 for (i=0; i<numtypes; i++) |
8660 | 5901 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5902 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5903 |
8660 | 5904 gaim_debug_misc(NULL, "\n"); |
4230 | 5905 |
5906 if (numtypes >= 0) | |
5907 od->rights.maxbuddies = maxitems[0]; | |
5908 if (numtypes >= 1) | |
5909 od->rights.maxgroups = maxitems[1]; | |
5910 if (numtypes >= 2) | |
5911 od->rights.maxpermits = maxitems[2]; | |
5912 if (numtypes >= 3) | |
5913 od->rights.maxdenies = maxitems[3]; | |
2991 | 5914 |
5915 return 1; | |
5916 } | |
5917 | |
5918 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5919 GaimConnection *gc = sess->aux_data; |
5920 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 5921 GaimStatus *status; |
7283 | 5922 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5923 GaimGroup *g; |
5924 GaimBuddy *b; | |
2995 | 5925 struct aim_ssi_item *curitem; |
2991 | 5926 int tmp; |
4230 | 5927 va_list ap; |
8219 | 5928 fu16_t fmtver, numitems; |
5929 struct aim_ssi_item *items; | |
5930 fu32_t timestamp; | |
4230 | 5931 |
5932 va_start(ap, fr); | |
5933 fmtver = (fu16_t)va_arg(ap, int); | |
5934 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5935 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5936 timestamp = va_arg(ap, fu32_t); |
8219 | 5937 va_end(ap); |
2991 | 5938 |
8660 | 5939 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5940 "ssi: syncing local list and server list\n"); |
2991 | 5941 |
8219 | 5942 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5943 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 | 5944 return 1; |
5945 } | |
5946 | |
2991 | 5947 /* Clean the buddy list */ |
4889 | 5948 aim_ssi_cleanlist(sess); |
2991 | 5949 |
8150 | 5950 { /* If not in server list then prune from local list */ |
5951 GaimBlistNode *gnode, *cnode, *bnode; | |
5952 GaimBuddyList *blist; | |
9539 | 5953 GSList *cur, *next; |
8150 | 5954 |
5955 /* Buddies */ | |
5956 cur = NULL; | |
5957 if ((blist = gaim_get_blist()) != NULL) { | |
5958 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5959 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5960 continue; | |
5961 g = (GaimGroup *)gnode; | |
5962 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5963 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5964 continue; | |
5965 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5966 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5967 continue; | |
5968 b = (GaimBuddy *)bnode; | |
5969 if (b->account == gc->account) { | |
5970 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5971 /* If the buddy is an ICQ user then load his nickname */ | |
5972 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5973 char *alias; |
8150 | 5974 if (servernick) |
5975 serv_got_alias(gc, b->name, servernick); | |
5976 | |
5977 /* Store local alias on server */ | |
8214 | 5978 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5979 if (!alias && b->alias && strlen(b->alias)) |
5980 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5981 free(alias); | |
5982 } else { | |
8660 | 5983 gaim_debug_info("oscar", |
8150 | 5984 "ssi: removing buddy %s from local list\n", b->name); |
5985 /* We can't actually remove now because it will screw up our looping */ | |
5986 cur = g_slist_prepend(cur, b); | |
5987 } | |
5988 } | |
5989 } | |
5990 } | |
5991 } | |
5992 } | |
8175 | 5993 |
8150 | 5994 while (cur != NULL) { |
5995 b = cur->data; | |
5996 cur = g_slist_remove(cur, b); | |
5997 gaim_blist_remove_buddy(b); | |
5998 } | |
5999 | |
6000 /* Permit list */ | |
6001 if (gc->account->permit) { | |
9539 | 6002 next = gc->account->permit; |
6003 while (next != NULL) { | |
6004 cur = next; | |
6005 next = next->next; | |
8150 | 6006 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6007 gaim_debug_info("oscar", |
8150 | 6008 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6009 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6010 } | |
9539 | 6011 } |
8150 | 6012 } |
6013 | |
6014 /* Deny list */ | |
6015 if (gc->account->deny) { | |
9539 | 6016 next = gc->account->deny; |
6017 while (next != NULL) { | |
6018 cur = next; | |
6019 next = next->next; | |
8150 | 6020 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6021 gaim_debug_info("oscar", |
8150 | 6022 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6023 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6024 } | |
9539 | 6025 } |
8150 | 6026 } |
6027 /* Presence settings (idle time visibility) */ | |
6028 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6029 if (!(tmp & 0x400)) | |
6030 aim_ssi_setpresence(sess, tmp | 0x400); | |
6031 } /* end pruning buddies from local list */ | |
6032 | |
2991 | 6033 /* Add from server list to local list */ |
4230 | 6034 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6035 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6036 switch (curitem->type) { |
4230 | 6037 case 0x0000: { /* Buddy */ |
4251 | 6038 if (curitem->name) { |
4292 | 6039 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6040 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6041 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6042 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6043 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6044 /* Should gname be freed here? -- elb */ |
4754 | 6045 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6046 free(alias); |
8150 | 6047 if (b) { |
4292 | 6048 /* Get server stored alias */ |
4705 | 6049 if (alias_utf8) { |
8150 | 6050 g_free(b->alias); |
6051 b->alias = g_strdup(alias_utf8); | |
4705 | 6052 } |
4282 | 6053 } else { |
8150 | 6054 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6055 |
4754 | 6056 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6057 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6058 gaim_blist_add_group(g, NULL); |
6059 } | |
5146 | 6060 |
8660 | 6061 gaim_debug_info("oscar", |
9285 | 6062 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6063 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6064 } |
8341 | 6065 if (!aim_sncmp(curitem->name, account->username)) { |
6066 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6067 gaim_check_comment(od, comment); | |
6068 free(comment); | |
6069 } | |
7162 | 6070 g_free(gname_utf8); |
6071 g_free(alias_utf8); | |
2991 | 6072 } |
4230 | 6073 } break; |
6074 | |
6075 case 0x0001: { /* Group */ | |
4282 | 6076 /* Shouldn't add empty groups */ |
4230 | 6077 } break; |
6078 | |
6079 case 0x0002: { /* Permit buddy */ | |
2991 | 6080 if (curitem->name) { |
4230 | 6081 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6082 GSList *list; |
5575 | 6083 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6084 if (!list) { |
8660 | 6085 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6086 "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
|
6087 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6088 } |
6089 } | |
4230 | 6090 } break; |
6091 | |
6092 case 0x0003: { /* Deny buddy */ | |
2991 | 6093 if (curitem->name) { |
6094 GSList *list; | |
5575 | 6095 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6096 if (!list) { |
8660 | 6097 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6098 "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
|
6099 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6100 } |
6101 } | |
4230 | 6102 } break; |
6103 | |
6104 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6105 if (curitem->data) { |
6106 fu8_t permdeny; | |
5575 | 6107 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6108 gaim_debug_info("oscar", |
5575 | 6109 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6110 account->perm_deny = permdeny; | |
6111 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6112 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6113 } |
2991 | 6114 } |
6115 } | |
4230 | 6116 } break; |
6117 | |
6118 case 0x0005: { /* Presence setting */ | |
3109 | 6119 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6120 } break; |
2991 | 6121 } /* End of switch on curitem->type */ |
6122 } /* End of for loop */ | |
4230 | 6123 |
9991 | 6124 /* |
6125 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6126 * this. We probably want the SSI status setting to override the local | |
6127 * setting. | |
6128 */ | |
9982 | 6129 status = gaim_presence_get_active_status(account->presence); |
6130 if (gaim_status_is_available(status)) | |
4901 | 6131 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6132 | |
4342 | 6133 /* Activate SSI */ |
6134 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6135 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6136 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6137 "ssi: activating server-stored buddy list\n"); |
4642 | 6138 aim_ssi_enable(sess); |
4342 | 6139 |
2991 | 6140 return 1; |
2086 | 6141 } |
4230 | 6142 |
6143 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6144 GaimConnection *gc = sess->aux_data; |
4230 | 6145 va_list ap; |
6146 struct aim_ssi_tmp *retval; | |
6147 | |
6148 va_start(ap, fr); | |
6149 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6150 va_end(ap); | |
6151 | |
6152 while (retval) { | |
8660 | 6153 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6154 "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 | 6155 |
6156 if (retval->ack != 0xffff) | |
6157 switch (retval->ack) { | |
6158 case 0x0000: { /* added successfully */ | |
6159 } break; | |
6160 | |
4829 | 6161 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6162 gchar *buf; | |
6163 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 | 6164 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6165 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6166 g_free(buf); |
6167 } | |
6168 | |
7023 | 6169 case 0x000e: { /* buddy requires authorization */ |
4828 | 6170 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6171 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6172 } break; |
6173 | |
6174 default: { /* La la la */ | |
5197 | 6175 gchar *buf; |
8660 | 6176 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6177 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 | 6178 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6179 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6180 g_free(buf); |
4230 | 6181 } break; |
6182 } | |
6183 | |
6184 retval = retval->next; | |
6185 } | |
6186 | |
6187 return 1; | |
6188 } | |
6189 | |
8227 | 6190 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6191 GaimConnection *gc = sess->aux_data; | |
6192 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6193 GaimBuddy *b; | |
6194 GaimGroup *g; | |
6195 va_list ap; | |
6196 fu16_t type; | |
6197 const char *name; | |
6198 | |
6199 va_start(ap, fr); | |
6200 type = (fu16_t)va_arg(ap, int); | |
6201 name = va_arg(ap, char *); | |
6202 va_end(ap); | |
6203 | |
6204 if ((type != 0x0000) || (name == NULL)) | |
6205 return 1; | |
6206 | |
6207 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6208 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6209 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6210 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6211 b = gaim_find_buddy(gc->account, name); | |
6212 free(alias); | |
6213 | |
6214 if (b) { | |
6215 /* Get server stored alias */ | |
6216 if (alias_utf8) { | |
6217 g_free(b->alias); | |
6218 b->alias = g_strdup(alias_utf8); | |
6219 } | |
6220 } else { | |
6221 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6222 | |
6223 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6224 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6225 gaim_blist_add_group(g, NULL); | |
6226 } | |
6227 | |
8660 | 6228 gaim_debug_info("oscar", |
9285 | 6229 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6230 gaim_blist_add_buddy(b, NULL, g, NULL); |
6231 } | |
6232 g_free(gname_utf8); | |
6233 g_free(alias_utf8); | |
6234 | |
6235 return 1; | |
6236 } | |
6237 | |
4230 | 6238 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6239 GaimConnection *gc = sess->aux_data; |
4230 | 6240 va_list ap; |
6241 char *sn, *msg; | |
4236 | 6242 gchar *dialog_msg, *nombre; |
4230 | 6243 struct name_data *data; |
6695 | 6244 GaimBuddy *buddy; |
4230 | 6245 |
6246 va_start(ap, fr); | |
6247 sn = va_arg(ap, char *); | |
6248 msg = va_arg(ap, char *); | |
6249 va_end(ap); | |
6250 | |
8660 | 6251 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6252 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6253 |
4687 | 6254 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6255 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6256 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6257 else |
6258 nombre = g_strdup(sn); | |
6259 | |
6260 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 | 6261 data = g_new(struct name_data, 1); |
6262 data->gc = gc; | |
6263 data->name = g_strdup(sn); | |
6264 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6265 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6266 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6267 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6268 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6269 G_CALLBACK(oscar_free_name_data)); |
4236 | 6270 |
4230 | 6271 g_free(dialog_msg); |
4236 | 6272 g_free(nombre); |
4230 | 6273 |
6274 return 1; | |
6275 } | |
6276 | |
6277 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6278 GaimConnection *gc = sess->aux_data; |
4230 | 6279 va_list ap; |
6280 char *sn, *msg; | |
4236 | 6281 gchar *dialog_msg, *nombre; |
4230 | 6282 struct name_data *data; |
6695 | 6283 GaimBuddy *buddy; |
4230 | 6284 |
6285 va_start(ap, fr); | |
6286 sn = va_arg(ap, char *); | |
6287 msg = va_arg(ap, char *); | |
6288 va_end(ap); | |
6289 | |
8660 | 6290 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6291 "ssi: received authorization request from %s\n", sn); |
4230 | 6292 |
4687 | 6293 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6294 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6295 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6296 else |
6297 nombre = g_strdup(sn); | |
6298 | |
4337 | 6299 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 | 6300 data = g_new(struct name_data, 1); |
6301 data->gc = gc; | |
6302 data->name = g_strdup(sn); | |
6303 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6304 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6305 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6306 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6307 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6308 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6309 |
4230 | 6310 g_free(dialog_msg); |
4236 | 6311 g_free(nombre); |
4230 | 6312 |
6313 return 1; | |
6314 } | |
6315 | |
6316 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6317 GaimConnection *gc = sess->aux_data; |
4230 | 6318 va_list ap; |
6319 char *sn, *msg; | |
4236 | 6320 gchar *dialog_msg, *nombre; |
4230 | 6321 fu8_t reply; |
6695 | 6322 GaimBuddy *buddy; |
4230 | 6323 |
6324 va_start(ap, fr); | |
6325 sn = va_arg(ap, char *); | |
6326 reply = (fu8_t)va_arg(ap, int); | |
6327 msg = va_arg(ap, char *); | |
6328 va_end(ap); | |
6329 | |
8660 | 6330 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6331 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6332 |
4687 | 6333 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6334 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6335 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6336 else |
6337 nombre = g_strdup(sn); | |
6338 | |
4230 | 6339 if (reply) { |
6340 /* Granted */ | |
7023 | 6341 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
|
6342 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6343 } else { |
6344 /* Denied */ | |
7023 | 6345 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
|
6346 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6347 } |
6348 g_free(dialog_msg); | |
4236 | 6349 g_free(nombre); |
4230 | 6350 |
6351 return 1; | |
6352 } | |
6353 | |
6354 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6355 GaimConnection *gc = sess->aux_data; |
4230 | 6356 va_list ap; |
6357 char *sn; | |
6695 | 6358 GaimBuddy *buddy; |
4230 | 6359 |
6360 va_start(ap, fr); | |
6361 sn = va_arg(ap, char *); | |
6362 va_end(ap); | |
6363 | |
4687 | 6364 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6365 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6366 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6367 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6368 |
6369 return 1; | |
6370 } | |
4269 | 6371 #endif |
2086 | 6372 |
5575 | 6373 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6374 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6375 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6376 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6377 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6378 pce->label = _("_Room:"); |
5234 | 6379 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6380 m = g_list_append(m, pce); |
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 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6383 pce->label = _("_Exchange:"); |
5234 | 6384 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6385 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6386 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6387 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6388 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6389 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6390 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6391 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6392 |
9754 | 6393 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6394 { | |
6395 GHashTable *defaults; | |
6396 | |
6397 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6398 | |
6399 if (chat_name != NULL) | |
6400 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6401 | |
6402 return defaults; | |
6403 } | |
6404 | |
9917 | 6405 static char *oscar_get_chat_name(GHashTable *data) { |
6406 return g_strdup(g_hash_table_lookup(data, "room")); | |
6407 } | |
6408 | |
8308 | 6409 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6410 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6411 aim_conn_t *cur; |
5234 | 6412 char *name, *exchange; |
6413 | |
6414 name = g_hash_table_lookup(data, "room"); | |
6415 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6416 |
8660 | 6417 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6418 "Attempting to join chat room %s.\n", name); |
8308 | 6419 |
6420 if ((name == NULL) || (*name == '\0')) { | |
6421 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6422 return; | |
6423 } | |
6424 | |
4617 | 6425 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6426 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6427 "chatnav exists, creating room\n"); |
5234 | 6428 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6429 } else { |
6430 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6431 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6432 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6433 "chatnav does not exist, opening chatnav\n"); |
5234 | 6434 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6435 cr->name = g_strdup(name); |
4617 | 6436 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6437 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6438 } |
6439 } | |
6440 | |
8308 | 6441 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6442 OscarData *od = (OscarData *)gc->proto_data; | |
6443 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6444 |
6445 if (!ccon) | |
6446 return; | |
6447 | |
8225 | 6448 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6449 ccon->exchange, ccon->name, 0x0); |
6450 } | |
6451 | |
8308 | 6452 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6453 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6454 GSList *bcs = gc->buddy_chats; | |
5679 | 6455 GaimConversation *b = NULL; |
2086 | 6456 struct chat_connection *c = NULL; |
6457 int count = 0; | |
6458 | |
6459 while (bcs) { | |
6460 count++; | |
5679 | 6461 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6462 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6463 break; |
6464 bcs = bcs->next; | |
6465 b = NULL; | |
6466 } | |
6467 | |
6468 if (!b) | |
6469 return; | |
6470 | |
8660 | 6471 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6472 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6473 |
8308 | 6474 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6475 if (c != NULL) { |
4617 | 6476 if (od) |
6477 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6478 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6479 gaim_input_remove(c->inpa); |
8308 | 6480 if (gc && od->sess) |
4617 | 6481 aim_conn_kill(od->sess, &c->conn); |
2086 | 6482 g_free(c->name); |
6483 g_free(c->show); | |
6484 g_free(c); | |
6485 } | |
6486 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6487 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6488 } |
6489 | |
8219 | 6490 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6491 OscarData *od = (OscarData *)gc->proto_data; | |
6492 GaimConversation *conv = NULL; | |
2086 | 6493 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6494 char *buf, *buf2; |
9830 | 6495 fu16_t charset, charsubset; |
9807 | 6496 char *charsetstr = NULL; |
10111 | 6497 int len; |
8219 | 6498 |
6499 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6500 return -EINVAL; |
2086 | 6501 |
8219 | 6502 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6503 return -EINVAL; |
2086 | 6504 |
8219 | 6505 buf = gaim_strdup_withhtml(message); |
6506 len = strlen(buf); | |
6507 | |
8962 | 6508 if (strstr(buf, "<IMG ")) |
6509 gaim_conversation_write(conv, "", | |
6510 _("Your IM Image was not sent. " | |
6511 "You cannot send IM Images in AIM chats."), | |
6512 GAIM_MESSAGE_ERROR, time(NULL)); | |
6513 | |
9830 | 6514 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6515 if ((len > c->maxlen) || (len > c->maxvis)) { |
6516 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6517 return -E2BIG; |
8359 | 6518 } |
6519 | |
9831 | 6520 if (charset == AIM_CHARSET_ASCII) |
6521 charsetstr = "us-ascii"; | |
6522 else if (charset == AIM_CHARSET_UNICODE) | |
6523 charsetstr = "unicode-2-0"; | |
6524 else if (charset == AIM_CHARSET_CUSTOM) | |
6525 charsetstr = "iso-8859-1"; | |
9807 | 6526 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6527 g_free(buf2); |
8359 | 6528 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6529 return 0; |
2086 | 6530 } |
6531 | |
10042 | 6532 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6533 { | |
4766 | 6534 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6535 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6536 return "icq"; |
6537 else | |
6538 return "aim"; | |
6539 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6540 |
9975 | 6541 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6542 return "icq"; |
6543 return "aim"; | |
6544 } | |
6545 | |
9972 | 6546 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6547 { |
7334 | 6548 GaimConnection *gc = NULL; |
6549 OscarData *od = NULL; | |
10042 | 6550 GaimAccount *account = NULL; |
6551 GaimPresence *presence; | |
6552 GaimStatus *status; | |
6553 const char *status_id; | |
4687 | 6554 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6555 int i = 0; | |
7334 | 6556 aim_userinfo_t *userinfo = NULL; |
6557 | |
6558 if (b != NULL) | |
6559 account = b->account; | |
6560 if (account != NULL) | |
6561 gc = account->gc; | |
6562 if (gc != NULL) | |
6563 od = gc->proto_data; | |
7945 | 6564 if (od != NULL) |
6565 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6566 |
10042 | 6567 presence = gaim_buddy_get_presence(b); |
6568 status = gaim_presence_get_active_status(presence); | |
6569 status_id = gaim_status_get_id(status); | |
6570 | |
6571 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6572 char *gname; |
7334 | 6573 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6574 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6575 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6576 emblems[i++] = "notauthorized"; | |
6577 } else { | |
6578 emblems[i++] = "offline"; | |
6579 } | |
6580 } | |
4916 | 6581 |
10042 | 6582 if (b->name && aim_sn_is_icq(b->name)) { |
6583 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6584 emblems[i++] = "invisible"; | |
6585 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6586 emblems[i++] = "freeforchat"; |
10042 | 6587 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6588 emblems[i++] = "dnd"; |
10042 | 6589 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6590 emblems[i++] = "na"; |
10042 | 6591 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6592 emblems[i++] = "occupied"; |
10042 | 6593 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6594 emblems[i++] = "away"; |
10042 | 6595 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6596 emblems[i++] = "away"; | |
6597 } | |
6598 | |
6599 if (userinfo != NULL ) { | |
6600 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6601 emblems[i++] = "unconfirmed"; */ | |
6602 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6603 emblems[i++] = "admin"; | |
6604 if (userinfo->flags & AIM_FLAG_AOL) | |
6605 emblems[i++] = "aol"; | |
6606 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6607 emblems[i++] = "wireless"; | |
6608 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6609 emblems[i++] = "activebuddy"; | |
6610 | |
6611 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6612 emblems[i++] = "hiptop"; |
6613 | |
10042 | 6614 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6615 emblems[i++] = "secure"; |
10042 | 6616 } |
7334 | 6617 |
4687 | 6618 *se = emblems[0]; |
6619 *sw = emblems[1]; | |
6620 *nw = emblems[2]; | |
6621 *ne = emblems[3]; | |
6622 } | |
6623 | |
6695 | 6624 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6625 GaimConnection *gc = b->account->gc; |
7283 | 6626 OscarData *od = gc->proto_data; |
7045 | 6627 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6628 GString *str = g_string_new(""); |
5131 | 6629 |
6630 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6631 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6632 |
6633 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6634 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6635 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6636 g_free(charset); |
7011 | 6637 if (away_utf8 != NULL) { |
7091 | 6638 gchar *tmp1, *tmp2; |
9627 | 6639 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6640 g_free(away_utf8); |
8571 | 6641 tmp1 = gaim_escape_html(tmp2); |
7091 | 6642 g_free(tmp2); |
8700 | 6643 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6644 g_free(tmp1); |
8701 | 6645 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6646 g_free(tmp2); |
5836 | 6647 } |
5131 | 6648 } |
8701 | 6649 } |
6650 | |
6651 return g_string_free(str, FALSE); | |
5131 | 6652 } |
6653 | |
10042 | 6654 static char *oscar_status_text(GaimBuddy *b) |
6655 { | |
6656 GaimConnection *gc; | |
6657 OscarData *od; | |
6658 GaimStatus *status; | |
5167 | 6659 gchar *ret = NULL; |
6660 | |
10042 | 6661 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6662 od = gc->proto_data; | |
6663 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6664 | |
6665 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6666 if (aim_sn_is_icq(b->name)) |
8701 | 6667 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6668 else |
6669 ret = g_strdup(_("Away")); | |
5836 | 6670 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6671 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6672 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6673 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6674 } else { |
5167 | 6675 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6676 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6677 ret = g_strdup(_("Not Authorized")); | |
6678 else | |
6679 ret = g_strdup(_("Offline")); | |
6680 } | |
6681 | |
6682 return ret; | |
6683 } | |
6684 | |
5842 | 6685 |
5844 | 6686 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6687 GaimConnection *gc = sess->aux_data; |
7283 | 6688 OscarData *od = gc->proto_data; |
5892 | 6689 va_list ap; |
5842 | 6690 fu16_t type; |
5892 | 6691 fu8_t flags = 0, length = 0; |
6692 char *md5 = NULL; | |
6693 | |
7334 | 6694 |
5842 | 6695 va_start(ap, fr); |
6696 type = va_arg(ap, int); | |
5892 | 6697 |
6698 switch(type) { | |
6699 case 0x0000: | |
6700 case 0x0001: { | |
6701 flags = va_arg(ap, int); | |
6702 length = va_arg(ap, int); | |
6703 md5 = va_arg(ap, char *); | |
6704 | |
6705 if (flags == 0x41) { | |
6706 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6707 od->iconconnecting = TRUE; | |
6708 od->set_icon = TRUE; | |
6709 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6710 } else { | |
6039 | 6711 struct stat st; |
6712 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6713 if (iconfile == NULL) { | |
8363 | 6714 aim_ssi_delicon(od->sess); |
6039 | 6715 } else if (!stat(iconfile, &st)) { |
6716 char *buf = g_malloc(st.st_size); | |
6717 FILE *file = fopen(iconfile, "rb"); | |
6718 if (file) { | |
9532 | 6719 /* XXX - Use g_file_get_contents()? */ |
6039 | 6720 fread(buf, 1, st.st_size, file); |
6721 fclose(file); | |
8660 | 6722 gaim_debug_info("oscar", |
10042 | 6723 "Uploading icon to icon server\n"); |
6879 | 6724 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6725 } else |
8660 | 6726 gaim_debug_error("oscar", |
10042 | 6727 "Can't open buddy icon file!\n"); |
6039 | 6728 g_free(buf); |
6729 } else { | |
8660 | 6730 gaim_debug_error("oscar", |
10042 | 6731 "Can't stat buddy icon file!\n"); |
5892 | 6732 } |
6733 } | |
8363 | 6734 } else if (flags == 0x81) { |
6735 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6736 if (iconfile == NULL) | |
6737 aim_ssi_delicon(od->sess); | |
6738 else | |
6739 aim_ssi_seticon(od->sess, md5, length); | |
6740 } | |
5892 | 6741 } break; |
6742 | |
6743 case 0x0002: { /* We just set an "available" message? */ | |
6744 } break; | |
6745 } | |
6746 | |
5842 | 6747 va_end(ap); |
5844 | 6748 |
6749 return 0; | |
5842 | 6750 } |
5892 | 6751 |
5575 | 6752 static void oscar_set_permit_deny(GaimConnection *gc) { |
6753 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6754 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6755 #ifdef NOSSI |
8143 | 6756 GSList *list; |
4230 | 6757 char buf[MAXMSGLEN]; |
6758 int at; | |
6759 | |
5575 | 6760 switch(account->perm_deny) { |
8175 | 6761 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6762 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6763 break; |
8175 | 6764 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6765 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6766 break; |
8175 | 6767 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6768 list = account->permit; |
4230 | 6769 at = 0; |
6770 while (list) { | |
6771 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6772 list = list->next; | |
6773 } | |
6774 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6775 break; | |
8175 | 6776 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6777 list = account->deny; |
4230 | 6778 at = 0; |
6779 while (list) { | |
6780 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6781 list = list->next; | |
6782 } | |
6783 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6784 break; | |
6785 default: | |
6786 break; | |
2086 | 6787 } |
4230 | 6788 #else |
8175 | 6789 if (od->sess->ssi.received_data) { |
6790 switch (account->perm_deny) { | |
6791 case GAIM_PRIVACY_ALLOW_ALL: | |
6792 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6793 break; | |
6794 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6795 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6796 break; | |
6797 case GAIM_PRIVACY_ALLOW_USERS: | |
6798 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6799 break; | |
6800 case GAIM_PRIVACY_DENY_ALL: | |
6801 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6802 break; | |
6803 case GAIM_PRIVACY_DENY_USERS: | |
6804 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6805 break; | |
6806 default: | |
6807 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6808 break; | |
6809 } | |
6810 } | |
4230 | 6811 #endif |
2086 | 6812 } |
6813 | |
5575 | 6814 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6815 #ifdef NOSSI |
8143 | 6816 if (gc->account->perm_deny == 3) |
4269 | 6817 oscar_set_permit_deny(gc); |
6818 #else | |
7283 | 6819 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6820 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6821 if (od->sess->ssi.received_data) |
4889 | 6822 aim_ssi_addpermit(od->sess, who); |
4230 | 6823 #endif |
2086 | 6824 } |
6825 | |
5575 | 6826 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6827 #ifdef NOSSI |
8143 | 6828 if (gc->account->perm_deny == 4) |
4269 | 6829 oscar_set_permit_deny(gc); |
6830 #else | |
7283 | 6831 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6832 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6833 if (od->sess->ssi.received_data) |
4889 | 6834 aim_ssi_adddeny(od->sess, who); |
4230 | 6835 #endif |
2086 | 6836 } |
6837 | |
5575 | 6838 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6839 #ifdef NOSSI |
8143 | 6840 if (gc->account->perm_deny == 3) |
4269 | 6841 oscar_set_permit_deny(gc); |
6842 #else | |
7283 | 6843 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6844 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6845 if (od->sess->ssi.received_data) |
4889 | 6846 aim_ssi_delpermit(od->sess, who); |
4230 | 6847 #endif |
2086 | 6848 } |
6849 | |
5575 | 6850 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6851 #ifdef NOSSI |
8143 | 6852 if (gc->account->perm_deny == 4) |
4269 | 6853 oscar_set_permit_deny(gc); |
6854 #else | |
7283 | 6855 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6856 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6857 if (od->sess->ssi.received_data) |
4889 | 6858 aim_ssi_deldeny(od->sess, who); |
4230 | 6859 #endif |
2086 | 6860 } |
6861 | |
9975 | 6862 static GList * |
6863 oscar_status_types(GaimAccount *account) | |
2086 | 6864 { |
9975 | 6865 GList *status_types = NULL; |
6866 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6867 |
9973 | 6868 g_return_val_if_fail(account != NULL, NULL); |
6869 | |
10042 | 6870 /* Oscar-common status types */ |
9991 | 6871 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
6872 OSCAR_STATUS_ID_OFFLINE, | |
6873 _("Offline"), FALSE, FALSE, FALSE); | |
9976 | 6874 status_types = g_list_append(status_types, type); |
6875 | |
9991 | 6876 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
6877 OSCAR_STATUS_ID_ONLINE, | |
6878 _("Online"), FALSE, FALSE, FALSE); | |
9976 | 6879 status_types = g_list_append(status_types, type); |
6880 | |
10198 | 6881 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
6882 OSCAR_STATUS_ID_AVAILABLE, | |
6883 _("Available"), TRUE, TRUE, FALSE, | |
6884 "message", _("Message"), | |
6885 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 6886 status_types = g_list_append(status_types, type); |
6887 | |
10195 | 6888 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
6889 OSCAR_STATUS_ID_AWAY, | |
6890 _("Away"), TRUE, TRUE, FALSE, | |
6891 "message", _("Message"), | |
6892 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 6893 status_types = g_list_append(status_types, type); |
6894 | |
6895 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
6896 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 6897 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 6898 status_types = g_list_append(status_types, type); |
6899 | |
6900 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
6901 return status_types; | |
6902 | |
6903 /* ICQ-specific status types */ | |
6904 | |
9991 | 6905 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6906 OSCAR_STATUS_ID_FREE4CHAT, | |
6907 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 6908 status_types = g_list_append(status_types, type); |
6909 | |
9991 | 6910 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
6911 OSCAR_STATUS_ID_OCCUPIED, | |
6912 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 6913 status_types = g_list_append(status_types, type); |
6914 | |
9991 | 6915 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6916 OSCAR_STATUS_ID_DND, | |
6917 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 6918 status_types = g_list_append(status_types, type); |
6919 | |
9991 | 6920 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6921 OSCAR_STATUS_ID_NA, | |
6922 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 6923 status_types = g_list_append(status_types, type); |
9975 | 6924 |
6925 return status_types; | |
4333 | 6926 } |
6927 | |
7172 | 6928 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6929 GaimConnection *gc = data->gc; |
6930 OscarData *od = gc->proto_data; | |
7172 | 6931 GaimBuddy *b; |
6932 GaimGroup *g; | |
6933 | |
6934 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6935 oscar_free_name_data(data); | |
6936 return; | |
6937 } | |
6938 | |
6939 if (!(g = gaim_find_buddys_group(b))) { | |
6940 oscar_free_name_data(data); | |
6941 return; | |
6942 } | |
6943 | |
6944 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6945 |
6946 if (!aim_sncmp(data->name, gc->account->username)) | |
6947 gaim_check_comment(od, text); | |
6948 | |
7172 | 6949 oscar_free_name_data(data); |
6950 } | |
6951 | |
9030 | 6952 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6953 | |
6954 GaimBuddy *buddy; | |
6955 GaimConnection *gc; | |
6956 OscarData *od; | |
6957 struct name_data *data; | |
7172 | 6958 GaimGroup *g; |
6959 char *comment; | |
6960 gchar *comment_utf8; | |
9631 | 6961 gchar *title; |
7172 | 6962 |
9030 | 6963 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6964 | |
6965 buddy = (GaimBuddy *) node; | |
6966 gc = gaim_account_get_connection(buddy->account); | |
6967 od = gc->proto_data; | |
6968 | |
6969 data = g_new(struct name_data, 1); | |
6970 | |
6971 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6972 return; |
9030 | 6973 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6974 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6975 | |
6976 data->gc = gc; | |
9030 | 6977 data->name = g_strdup(buddy->name); |
7172 | 6978 data->nick = NULL; |
6979 | |
9631 | 6980 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6981 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6982 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6983 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6984 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6985 data); | |
9631 | 6986 g_free(title); |
7172 | 6987 |
6988 free(comment); | |
6989 g_free(comment_utf8); | |
6990 } | |
6991 | |
9030 | 6992 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6993 | |
6994 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6995 OscarData *od = gc->proto_data; |
9030 | 6996 |
4333 | 6997 GList *m = NULL; |
9030 | 6998 GaimBlistNodeAction *act; |
6999 | |
7000 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
7001 oscar_buddycb_edit_comment, NULL); | |
7002 m = g_list_append(m, act); | |
7172 | 7003 |
4333 | 7004 if (od->icq) { |
4624 | 7005 #if 0 |
9030 | 7006 act = gaim_blist_node_action_new(_("Get Status Msg"), |
7007 oscar_get_icqstatusmsg, NULL); | |
7008 m = g_list_append(m, act); | |
4624 | 7009 #endif |
4333 | 7010 } else { |
7011 | 7011 aim_userinfo_t *userinfo; |
9030 | 7012 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7013 | |
7014 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7015 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7016 | |
7011 | 7017 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7018 act = gaim_blist_node_action_new(_("Direct IM"), |
7019 oscar_ask_direct_im, NULL); | |
7020 m = g_list_append(m, act); | |
5917 | 7021 } |
9466 | 7022 #if 0 |
7011 | 7023 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7024 act = gaim_blist_node_action_new(_("Get File"), |
7025 oscar_ask_getfile, NULL); | |
7026 m = g_list_append(m, act); | |
5917 | 7027 } |
4826 | 7028 #endif |
4333 | 7029 } |
5131 | 7030 } |
5197 | 7031 |
5131 | 7032 if (od->sess->ssi.received_data) { |
9030 | 7033 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7034 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7035 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
7036 gaim_auth_sendrequest_menu, NULL); | |
7037 m = g_list_append(m, act); | |
4333 | 7038 } |
4916 | 7039 } |
10157 | 7040 |
4333 | 7041 return m; |
7042 } | |
7043 | |
9030 | 7044 |
7045 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7046 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7047 return oscar_buddy_menu((GaimBuddy *) node); | |
7048 } else { | |
7049 return NULL; | |
7050 } | |
7051 } | |
7052 | |
7053 | |
5575 | 7054 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7055 OscarData *od = gc->proto_data; |
5575 | 7056 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7057 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7058 od->setnick = TRUE; | |
7059 od->newsn = g_strdup(nick); | |
7060 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7061 } else { | |
7062 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7063 } | |
7064 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7065 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7066 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7067 } |
7068 } | |
7069 | |
9015 | 7070 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7071 { |
9015 | 7072 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7073 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7074 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7075 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7076 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7077 gc); |
4333 | 7078 } |
7079 | |
9015 | 7080 static void oscar_confirm_account(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_reqconfirm(od->sess, conn); | |
7088 } else { | |
7089 od->conf = TRUE; | |
7090 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7091 } | |
7092 } | |
7093 | |
9015 | 7094 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7095 { |
9015 | 7096 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7097 OscarData *od = gc->proto_data; |
4333 | 7098 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7099 | |
7100 if (conn) { | |
7101 aim_admin_getinfo(od->sess, conn, 0x11); | |
7102 } else { | |
7103 od->reqemail = TRUE; | |
7104 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7105 } | |
7106 } | |
7107 | |
5575 | 7108 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7109 { |
7283 | 7110 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7111 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
|
7112 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7113 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7114 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7115 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7116 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7117 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7118 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7119 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7120 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7121 |
9015 | 7122 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7123 { |
9015 | 7124 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7125 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7126 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7127 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7128 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7129 gc); |
4333 | 7130 } |
7131 | |
9015 | 7132 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7133 { |
9015 | 7134 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7135 OscarData *od = gc->proto_data; |
4333 | 7136 gchar *nombre, *text, *tmp; |
6695 | 7137 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7138 int num=0; |
7139 | |
6873 | 7140 text = g_strdup(""); |
4333 | 7141 |
4785 | 7142 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7143 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7144 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7145 continue; | |
6695 | 7146 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7147 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7148 continue; |
6695 | 7149 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7150 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7151 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7152 continue; | |
7153 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7154 if (gaim_buddy_get_alias_only(buddy)) |
7155 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7156 else |
7157 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7158 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7159 g_free(text); |
7160 text = tmp; | |
7161 g_free(nombre); | |
7162 num++; | |
7163 } | |
4333 | 7164 } |
2979 | 7165 } |
4333 | 7166 } |
7167 | |
7168 if (!num) { | |
7169 g_free(text); | |
6873 | 7170 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7171 } | |
7172 | |
7173 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7174 "the following buddies"), _("You can re-request " | |
7175 "authorization from these buddies by " | |
7176 "right-clicking on them and selecting " | |
7177 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7178 g_free(text); |
2979 | 7179 } |
7180 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7181 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7182 { |
8950 | 7183 OscarData *od = (OscarData *)gc->proto_data; |
7184 | |
7185 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7186 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7187 |
9015 | 7188 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7189 { |
9015 | 7190 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7191 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7192 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7193 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7194 "searching for."), |
8697 | 7195 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7196 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7197 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7198 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7199 |
9015 | 7200 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7201 { |
9015 | 7202 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7203 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7204 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7205 |
9015 | 7206 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7207 { |
9015 | 7208 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7209 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7210 } |
7211 | |
9015 | 7212 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7213 { |
9015 | 7214 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7215 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7216 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7217 |
9015 | 7218 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7219 { |
9015 | 7220 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7221 OscarData *od = gc->proto_data; |
5575 | 7222 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7223 gaim_notify_uri(gc, substituted); |
5517 | 7224 g_free(substituted); |
4333 | 7225 } |
7226 | |
9015 | 7227 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7228 { |
9015 | 7229 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7230 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7231 } |
7232 | |
5842 | 7233 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7234 { | |
7283 | 7235 OscarData *od = gc->proto_data; |
5844 | 7236 aim_session_t *sess = od->sess; |
5842 | 7237 FILE *file; |
7238 struct stat st; | |
5844 | 7239 |
6039 | 7240 if (iconfile == NULL) { |
8363 | 7241 aim_ssi_delicon(od->sess); |
6039 | 7242 } else if (!stat(iconfile, &st)) { |
5842 | 7243 char *buf = g_malloc(st.st_size); |
7244 file = fopen(iconfile, "rb"); | |
7245 if (file) { | |
6052 | 7246 md5_state_t *state; |
6039 | 7247 char md5[16]; |
9532 | 7248 /* XXX - Use g_file_get_contents()? */ |
5842 | 7249 int len = fread(buf, 1, st.st_size, file); |
6039 | 7250 fclose(file); |
6052 | 7251 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7252 md5_init(state); |
7253 md5_append(state, buf, len); | |
7254 md5_finish(state, md5); | |
7255 g_free(state); | |
7256 aim_ssi_seticon(sess, md5, 16); | |
7257 } else | |
8660 | 7258 gaim_debug_error("oscar", |
5842 | 7259 "Can't open buddy icon file!\n"); |
7260 g_free(buf); | |
7261 } else | |
8660 | 7262 gaim_debug_error("oscar", |
5842 | 7263 "Can't stat buddy icon file!\n"); |
7264 } | |
7265 | |
7266 | |
9015 | 7267 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7268 { |
9015 | 7269 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7270 OscarData *od = gc->proto_data; |
4333 | 7271 GList *m = NULL; |
9015 | 7272 GaimPluginAction *act; |
7273 | |
7274 act = gaim_plugin_action_new(_("Set User Info..."), | |
7275 oscar_show_set_info); | |
7276 m = g_list_append(m, act); | |
4333 | 7277 |
8576 | 7278 if (od->icq) { |
9015 | 7279 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7280 oscar_show_set_info_icqurl); | |
7281 m = g_list_append(m, act); | |
8576 | 7282 } |
7283 | |
9015 | 7284 act = gaim_plugin_action_new(_("Change Password..."), |
7285 oscar_change_pass); | |
7286 m = g_list_append(m, act); | |
4617 | 7287 |
7288 if (od->sess->authinfo->chpassurl) { | |
9015 | 7289 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7290 oscar_show_chpassurl); | |
7291 m = g_list_append(m, act); | |
7292 | |
7293 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7294 oscar_show_imforwardingurl); | |
7295 m = g_list_append(m, act); | |
7026 | 7296 } |
7297 | |
5238 | 7298 if (!od->icq) { |
4617 | 7299 /* AIM actions */ |
7300 m = g_list_append(m, NULL); | |
4333 | 7301 |
9015 | 7302 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7303 oscar_show_format_screenname); | |
7304 m = g_list_append(m, act); | |
7305 | |
7306 act = gaim_plugin_action_new(_("Confirm Account"), | |
7307 oscar_confirm_account); | |
7308 m = g_list_append(m, act); | |
7309 | |
7310 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7311 oscar_show_email); | |
7312 m = g_list_append(m, act); | |
7313 | |
7314 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7315 oscar_show_change_email); | |
7316 m = g_list_append(m, act); | |
2086 | 7317 } |
4333 | 7318 |
7319 m = g_list_append(m, NULL); | |
7320 | |
9015 | 7321 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7322 oscar_show_awaitingauth); | |
7323 m = g_list_append(m, act); | |
4333 | 7324 |
2086 | 7325 m = g_list_append(m, NULL); |
4333 | 7326 |
9015 | 7327 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7328 oscar_show_find_email); | |
7329 m = g_list_append(m, act); | |
4333 | 7330 |
8591 | 7331 #if 0 |
9015 | 7332 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7333 show_find_info); | |
7334 m = g_list_append(m, act); | |
8591 | 7335 #endif |
2086 | 7336 |
7337 return m; | |
7338 } | |
7339 | |
5575 | 7340 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7341 { |
7283 | 7342 OscarData *od = gc->proto_data; |
4617 | 7343 |
7344 if (od->icq) { | |
7345 aim_icq_changepasswd(od->sess, new); | |
2086 | 7346 } else { |
4617 | 7347 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7348 if (conn) { | |
7349 aim_admin_changepasswd(od->sess, conn, new, old); | |
7350 } else { | |
7351 od->chpass = TRUE; | |
7352 od->oldp = g_strdup(old); | |
7353 od->newp = g_strdup(new); | |
7354 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7355 } | |
2086 | 7356 } |
7357 } | |
7358 | |
6059 | 7359 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7360 { |
7283 | 7361 OscarData *od = gc->proto_data; |
8971 | 7362 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
|
7363 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7364 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7365 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7366 |
8971 | 7367 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7368 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7369 |
9935 | 7370 static void |
7371 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7372 { | |
7373 GaimConnection *gc = data; | |
7374 OscarData *od = gc->proto_data; | |
7375 aim_session_t *sess = od->sess; | |
7376 fu32_t presence; | |
7377 | |
7378 presence = aim_ssi_getpresence(sess->ssi.local); | |
7379 | |
7380 if (value) { | |
9992 | 7381 /* Based on the packet capture I thought it was the first one */ |
7382 /* Stu thinks it's the second one. */ | |
7383 /* presence |= 0x00400000; */ | |
9971 | 7384 presence &= ~0x00020000; |
9935 | 7385 aim_ssi_setpresence(sess, presence); |
7386 } else { | |
9992 | 7387 /* presence &= ~0x00400000; */ |
9971 | 7388 presence |= 0x00020000; |
9935 | 7389 aim_ssi_setpresence(sess, presence); |
7390 } | |
7391 } | |
7392 | |
7393 static GaimPluginPrefFrame * | |
9936 | 7394 get_plugin_pref_frame(GaimPlugin *plugin) |
7395 { | |
9935 | 7396 GaimPluginPrefFrame *frame; |
7397 GaimPluginPref *ppref; | |
7398 | |
7399 frame = gaim_plugin_pref_frame_new(); | |
7400 | |
7401 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7402 gaim_plugin_pref_frame_add(frame, ppref); | |
7403 | |
7404 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7405 gaim_plugin_pref_frame_add(frame, ppref); | |
7406 | |
7407 return frame; | |
7408 } | |
7409 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7410 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7411 { |
9308 | 7412 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7413 NULL, /* user_splits */ |
7414 NULL, /* protocol_options */ | |
7415 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7416 oscar_list_icon, /* list_icon */ | |
7417 oscar_list_emblems, /* list_emblems */ | |
7418 oscar_status_text, /* status_text */ | |
7419 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7420 oscar_status_types, /* status_types */ |
9475 | 7421 oscar_blist_node_menu, /* blist_node_menu */ |
7422 oscar_chat_info, /* chat_info */ | |
9754 | 7423 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7424 oscar_login, /* login */ |
7425 oscar_close, /* close */ | |
7426 oscar_send_im, /* send_im */ | |
7427 oscar_set_info, /* set_info */ | |
7428 oscar_send_typing, /* send_typing */ | |
7429 oscar_get_info, /* get_info */ | |
9973 | 7430 oscar_set_status, /* set_status */ |
9475 | 7431 oscar_set_idle, /* set_idle */ |
7432 oscar_change_passwd, /* change_passwd */ | |
7433 oscar_add_buddy, /* add_buddy */ | |
7434 oscar_add_buddies, /* add_buddies */ | |
7435 oscar_remove_buddy, /* remove_buddy */ | |
7436 oscar_remove_buddies, /* remove_buddies */ | |
7437 oscar_add_permit, /* add_permit */ | |
7438 oscar_add_deny, /* add_deny */ | |
7439 oscar_rem_permit, /* rem_permit */ | |
7440 oscar_rem_deny, /* rem_deny */ | |
7441 oscar_set_permit_deny, /* set_permit_deny */ | |
7442 oscar_warn, /* warn */ | |
7443 oscar_join_chat, /* join_chat */ | |
7444 NULL, /* reject_chat */ | |
9973 | 7445 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7446 oscar_chat_invite, /* chat_invite */ |
7447 oscar_chat_leave, /* chat_leave */ | |
7448 NULL, /* chat_whisper */ | |
7449 oscar_send_chat, /* chat_send */ | |
7450 oscar_keepalive, /* keepalive */ | |
7451 NULL, /* register_user */ | |
7452 NULL, /* get_cb_info */ | |
7453 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7454 #ifndef NOSSI |
9475 | 7455 oscar_alias_buddy, /* alias_buddy */ |
7456 oscar_move_buddy, /* group_buddy */ | |
7457 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7458 #else |
9475 | 7459 NULL, /* alias_buddy */ |
7460 NULL, /* group_buddy */ | |
7461 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7462 #endif |
9475 | 7463 NULL, /* buddy_free */ |
7464 oscar_convo_closed, /* convo_closed */ | |
7465 NULL, /* normalize */ | |
7466 oscar_set_icon, /* set_buddy_icon */ | |
7467 NULL, /* remove_group */ | |
7468 NULL, /* get_cb_real_name */ | |
7469 NULL, /* set_chat_topic */ | |
7470 NULL, /* find_blist_chat */ | |
7471 NULL, /* roomlist_get_list */ | |
7472 NULL, /* roomlist_cancel */ | |
7473 NULL, /* roomlist_expand_category */ | |
7474 oscar_can_receive_file, /* can_receive_file */ | |
7475 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7476 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7477 |
9935 | 7478 static GaimPluginUiInfo prefs_info = { |
7479 get_plugin_pref_frame | |
7480 }; | |
7481 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7482 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7483 { |
9943 | 7484 GAIM_PLUGIN_MAGIC, |
7485 GAIM_MAJOR_VERSION, | |
7486 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7487 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7488 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7489 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7490 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7491 GAIM_PRIORITY_DEFAULT, /**< priority */ |
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 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7494 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7495 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7496 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7497 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7498 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7499 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7500 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7501 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7502 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7503 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7504 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7505 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7506 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7507 NULL, /**< ui_info */ |
8993 | 7508 &prpl_info, /**< extra_info */ |
9935 | 7509 &prefs_info, /**< prefs_info */ |
9015 | 7510 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7511 }; |
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 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7514 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7515 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7516 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7517 |
9830 | 7518 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7519 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7520 | |
7521 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7522 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7523 | |
7524 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7525 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
|
7526 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7527 my_protocol = plugin; |
9935 | 7528 |
7529 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7530 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7531 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7532 } |
7533 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7534 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |